pi-kot 0.1.39 → 0.1.41

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 (102) hide show
  1. package/README.md +14 -0
  2. package/dist/client/assets/index-CBtH0h8n.js +196 -0
  3. package/dist/client/assets/index-CBtH0h8n.js.map +1 -0
  4. package/dist/client/assets/index-CS1o5rLO.css +1 -0
  5. package/dist/client/assets/vendor-icons-BpFAkgBQ.js +2 -0
  6. package/dist/client/assets/vendor-icons-BpFAkgBQ.js.map +1 -0
  7. package/dist/client/assets/{vendor-markdown-DUXj0nma.js → vendor-markdown-BDlxJt__.js} +2 -2
  8. package/dist/client/assets/{vendor-markdown-DUXj0nma.js.map → vendor-markdown-BDlxJt__.js.map} +1 -1
  9. package/dist/client/assets/vendor-prism-CNIrsK0M.js +4 -0
  10. package/dist/client/assets/{vendor-prism-tzddbd4Y.js.map → vendor-prism-CNIrsK0M.js.map} +1 -1
  11. package/dist/client/index.html +5 -5
  12. package/dist/server/archive-retention.test.d.ts +2 -0
  13. package/dist/server/archive-retention.test.d.ts.map +1 -0
  14. package/dist/server/archive-retention.test.js +63 -0
  15. package/dist/server/archive-retention.test.js.map +1 -0
  16. package/dist/server/contexts/web-ui.md +12 -3
  17. package/dist/server/event-stream.d.ts.map +1 -1
  18. package/dist/server/event-stream.js +14 -0
  19. package/dist/server/event-stream.js.map +1 -1
  20. package/dist/server/file-manager.d.ts +4 -0
  21. package/dist/server/file-manager.d.ts.map +1 -1
  22. package/dist/server/file-manager.js +49 -0
  23. package/dist/server/file-manager.js.map +1 -1
  24. package/dist/server/index.d.ts.map +1 -1
  25. package/dist/server/index.js +88 -0
  26. package/dist/server/index.js.map +1 -1
  27. package/dist/server/processes/envelope.d.ts +5 -0
  28. package/dist/server/processes/envelope.d.ts.map +1 -0
  29. package/dist/server/processes/envelope.js +29 -0
  30. package/dist/server/processes/envelope.js.map +1 -0
  31. package/dist/server/processes/log-store.d.ts +24 -0
  32. package/dist/server/processes/log-store.d.ts.map +1 -0
  33. package/dist/server/processes/log-store.js +86 -0
  34. package/dist/server/processes/log-store.js.map +1 -0
  35. package/dist/server/processes/manager.d.ts +56 -0
  36. package/dist/server/processes/manager.d.ts.map +1 -0
  37. package/dist/server/processes/manager.js +343 -0
  38. package/dist/server/processes/manager.js.map +1 -0
  39. package/dist/server/processes/processes.test.d.ts +2 -0
  40. package/dist/server/processes/processes.test.d.ts.map +1 -0
  41. package/dist/server/processes/processes.test.js +85 -0
  42. package/dist/server/processes/processes.test.js.map +1 -0
  43. package/dist/server/processes/prompt-strings.d.ts +7 -0
  44. package/dist/server/processes/prompt-strings.d.ts.map +1 -0
  45. package/dist/server/processes/prompt-strings.js +28 -0
  46. package/dist/server/processes/prompt-strings.js.map +1 -0
  47. package/dist/server/processes/tool.d.ts +3 -0
  48. package/dist/server/processes/tool.d.ts.map +1 -0
  49. package/dist/server/processes/tool.js +160 -0
  50. package/dist/server/processes/tool.js.map +1 -0
  51. package/dist/server/processes/types.d.ts +125 -0
  52. package/dist/server/processes/types.d.ts.map +1 -0
  53. package/dist/server/processes/types.js +13 -0
  54. package/dist/server/processes/types.js.map +1 -0
  55. package/dist/server/processes/watches.d.ts +13 -0
  56. package/dist/server/processes/watches.d.ts.map +1 -0
  57. package/dist/server/processes/watches.js +55 -0
  58. package/dist/server/processes/watches.js.map +1 -0
  59. package/dist/server/routes/config.js +2 -2
  60. package/dist/server/routes/config.js.map +1 -1
  61. package/dist/server/routes/exec.d.ts.map +1 -1
  62. package/dist/server/routes/exec.js +8 -1
  63. package/dist/server/routes/exec.js.map +1 -1
  64. package/dist/server/routes/files-batch-delete.test.d.ts +2 -0
  65. package/dist/server/routes/files-batch-delete.test.d.ts.map +1 -0
  66. package/dist/server/routes/files-batch-delete.test.js +165 -0
  67. package/dist/server/routes/files-batch-delete.test.js.map +1 -0
  68. package/dist/server/routes/files-batch-download.test.d.ts +2 -0
  69. package/dist/server/routes/files-batch-download.test.d.ts.map +1 -0
  70. package/dist/server/routes/files-batch-download.test.js +79 -0
  71. package/dist/server/routes/files-batch-download.test.js.map +1 -0
  72. package/dist/server/routes/files.d.ts.map +1 -1
  73. package/dist/server/routes/files.js +145 -3
  74. package/dist/server/routes/files.js.map +1 -1
  75. package/dist/server/routes/git.d.ts.map +1 -1
  76. package/dist/server/routes/git.js +4 -1
  77. package/dist/server/routes/git.js.map +1 -1
  78. package/dist/server/routes/processes.d.ts +3 -0
  79. package/dist/server/routes/processes.d.ts.map +1 -0
  80. package/dist/server/routes/processes.js +63 -0
  81. package/dist/server/routes/processes.js.map +1 -0
  82. package/dist/server/routes/sessions.d.ts.map +1 -1
  83. package/dist/server/routes/sessions.js +30 -1
  84. package/dist/server/routes/sessions.js.map +1 -1
  85. package/dist/server/routes/terminal.d.ts.map +1 -1
  86. package/dist/server/routes/terminal.js +4 -2
  87. package/dist/server/routes/terminal.js.map +1 -1
  88. package/dist/server/session-store.d.ts +16 -2
  89. package/dist/server/session-store.d.ts.map +1 -1
  90. package/dist/server/session-store.js +111 -6
  91. package/dist/server/session-store.js.map +1 -1
  92. package/dist/server/ui-settings-store.d.ts +3 -0
  93. package/dist/server/ui-settings-store.d.ts.map +1 -1
  94. package/dist/server/ui-settings-store.js +11 -1
  95. package/dist/server/ui-settings-store.js.map +1 -1
  96. package/package.json +1 -1
  97. package/dist/client/assets/index-B959AkDe.css +0 -1
  98. package/dist/client/assets/index-BH5vWV2p.js +0 -192
  99. package/dist/client/assets/index-BH5vWV2p.js.map +0 -1
  100. package/dist/client/assets/vendor-icons-xTgSApeH.js +0 -2
  101. package/dist/client/assets/vendor-icons-xTgSApeH.js.map +0 -1
  102. package/dist/client/assets/vendor-prism-tzddbd4Y.js +0 -4
@@ -0,0 +1,196 @@
1
+ import{n as e,r as t,t as n}from"./rolldown-runtime-QTnfLwEv.js";import{$ as r,A as i,B as a,C as o,D as s,E as c,F as l,G as u,H as d,I as f,J as p,K as m,L as h,M as g,N as _,O as v,P as y,Q as b,R as x,S,T as C,U as w,V as T,W as E,X as D,Y as O,Z as k,_ as A,a as j,b as M,c as N,d as P,et as F,f as I,g as L,h as R,i as z,it as ee,j as B,k as V,l as H,m as U,n as te,nt as ne,o as re,p as ie,q as ae,r as oe,rt as se,s as ce,t as le,tt as ue,u as de,v as fe,w as pe,x as me,y as he,z as ge}from"./vendor-icons-BpFAkgBQ.js";import{n as _e,t as ve}from"./vendor-prism-CNIrsK0M.js";import{a as ye,c as be,i as xe,n as Se,o as Ce,r as we,s as Te,t as Ee}from"./vendor-markdown-BDlxJt__.js";import{t as De}from"./vendor-katex-4z5K3dyr.js";import{A as Oe,B as W,C as ke,D as Ae,E as je,F as Me,H as Ne,I as Pe,L as Fe,M as Ie,N as Le,O as Re,P as ze,R as Be,S as Ve,T as He,U as Ue,V as We,W as Ge,_ as Ke,a as qe,b as Je,c as Ye,d as Xe,f as Ze,g as Qe,h as $e,i as et,j as tt,k as nt,l as rt,m as it,n as at,o as ot,p as st,r as ct,s as lt,t as ut,u as dt,v as ft,w as pt,x as mt,y as ht,z as gt}from"./vendor-codemirror-BB16Y9B-.js";import{n as _t,t as vt}from"./vendor-xterm-DXwh06H3.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var yt=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),bt=n(((e,t)=>{t.exports=yt()})),xt=n((e=>{var t=ee();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.7`})),St=n(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=xt()})),Ct=n((e=>{var t=bt(),n=ee(),r=St();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),m=Symbol.for(`react.transitional.element`),h=Symbol.for(`react.portal`),g=Symbol.for(`react.fragment`),_=Symbol.for(`react.strict_mode`),v=Symbol.for(`react.profiler`),y=Symbol.for(`react.consumer`),b=Symbol.for(`react.context`),x=Symbol.for(`react.forward_ref`),S=Symbol.for(`react.suspense`),C=Symbol.for(`react.suspense_list`),w=Symbol.for(`react.memo`),T=Symbol.for(`react.lazy`),E=Symbol.for(`react.activity`),D=Symbol.for(`react.memo_cache_sentinel`),O=Symbol.iterator;function k(e){return typeof e!=`object`||!e?null:(e=O&&e[O]||e[`@@iterator`],typeof e==`function`?e:null)}var A=Symbol.for(`react.client.reference`);function j(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===A?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case g:return`Fragment`;case v:return`Profiler`;case _:return`StrictMode`;case S:return`Suspense`;case C:return`SuspenseList`;case E:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case h:return`Portal`;case b:return e.displayName||`Context`;case y:return(e._context.displayName||`Context`)+`.Consumer`;case x:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case w:return t=e.displayName||null,t===null?j(e.type)||`Memo`:t;case T:t=e._payload,e=e._init;try{return j(e(t))}catch{}}return null}var M=Array.isArray,N=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F={pending:!1,data:null,method:null,action:null},I=[],L=-1;function R(e){return{current:e}}function z(e){0>L||(e.current=I[L],I[L]=null,L--)}function B(e,t){L++,I[L]=e.current,e.current=t}var V=R(null),H=R(null),U=R(null),te=R(null);function ne(e,t){switch(B(U,t),B(H,e),B(V,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Ud(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Ud(t),e=Wd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}z(V),B(V,e)}function re(){z(V),z(H),z(U)}function ie(e){e.memoizedState!==null&&B(te,e);var t=V.current,n=Wd(t,e.type);t!==n&&(B(H,e),B(V,n))}function ae(e){H.current===e&&(z(V),z(H)),te.current===e&&(z(te),$f._currentValue=F)}var oe,se;function ce(e){if(oe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);oe=t&&t[1]||``,se=-1<e.stack.indexOf(`
2
+ at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
3
+ `+oe+e+se}var le=!1;function ue(e,t){if(!e||le)return``;le=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
4
+ `),l=s.split(`
5
+ `);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
6
+ `+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{le=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?ce(n):``}function de(e,t){switch(e.tag){case 26:case 27:case 5:return ce(e.type);case 16:return ce(`Lazy`);case 13:return e.child!==t&&t!==null?ce(`Suspense Fallback`):ce(`Suspense`);case 19:return ce(`SuspenseList`);case 0:case 15:return ue(e.type,!1);case 11:return ue(e.type.render,!1);case 1:return ue(e.type,!0);case 31:return ce(`Activity`);default:return``}}function fe(e){try{var t=``,n=null;do t+=de(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
7
+ Error generating stack: `+e.message+`
8
+ `+e.stack}}var pe=Object.prototype.hasOwnProperty,me=t.unstable_scheduleCallback,he=t.unstable_cancelCallback,ge=t.unstable_shouldYield,_e=t.unstable_requestPaint,ve=t.unstable_now,ye=t.unstable_getCurrentPriorityLevel,be=t.unstable_ImmediatePriority,xe=t.unstable_UserBlockingPriority,Se=t.unstable_NormalPriority,Ce=t.unstable_LowPriority,we=t.unstable_IdlePriority,Te=t.log,Ee=t.unstable_setDisableYieldValue,De=null,Oe=null;function W(e){if(typeof Te==`function`&&Ee(e),Oe&&typeof Oe.setStrictMode==`function`)try{Oe.setStrictMode(De,e)}catch{}}var ke=Math.clz32?Math.clz32:Me,Ae=Math.log,je=Math.LN2;function Me(e){return e>>>=0,e===0?32:31-(Ae(e)/je|0)|0}var Ne=256,Pe=262144,Fe=4194304;function Ie(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Le(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Ie(n))):i=Ie(o):i=Ie(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Ie(n))):i=Ie(o)):i=Ie(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function Re(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function ze(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Be(){var e=Fe;return Fe<<=1,!(Fe&62914560)&&(Fe=4194304),e}function Ve(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function He(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ue(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-ke(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&We(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function We(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-ke(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function Ge(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-ke(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function Ke(e,t){var n=t&-t;return n=n&42?1:qe(n),(n&(e.suspendedLanes|t))===0?n:0}function qe(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Je(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function Ye(){var e=P.p;return e===0?(e=window.event,e===void 0?32:hp(e.type)):e}function Xe(e,t){var n=P.p;try{return P.p=e,t()}finally{P.p=n}}var Ze=Math.random().toString(36).slice(2),Qe=`__reactFiber$`+Ze,$e=`__reactProps$`+Ze,et=`__reactContainer$`+Ze,tt=`__reactEvents$`+Ze,nt=`__reactListeners$`+Ze,rt=`__reactHandles$`+Ze,it=`__reactResources$`+Ze,at=`__reactMarker$`+Ze;function ot(e){delete e[Qe],delete e[$e],delete e[tt],delete e[nt],delete e[rt]}function st(e){var t=e[Qe];if(t)return t;for(var n=e.parentNode;n;){if(t=n[et]||n[Qe]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=pf(e);e!==null;){if(n=e[Qe])return n;e=pf(e)}return t}e=n,n=e.parentNode}return null}function ct(e){if(e=e[Qe]||e[et]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function lt(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function ut(e){var t=e[it];return t||=e[it]={hoistableStyles:new Map,hoistableScripts:new Map},t}function dt(e){e[at]=!0}var ft=new Set,pt={};function mt(e,t){ht(e,t),ht(e+`Capture`,t)}function ht(e,t){for(pt[e]=t,e=0;e<t.length;e++)ft.add(t[e])}var gt=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),_t={},vt={};function yt(e){return pe.call(vt,e)?!0:pe.call(_t,e)?!1:gt.test(e)?vt[e]=!0:(_t[e]=!0,!1)}function xt(e,t,n){if(yt(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,``+n)}}function Ct(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,``+n)}}function wt(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,``+r)}}function Tt(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function Et(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function G(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Dt(e){if(!e._valueTracker){var t=Et(e)?`checked`:`value`;e._valueTracker=G(e,t,``+e[t])}}function Ot(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=Et(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function kt(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}var At=/[\n"\\]/g;function jt(e){return e.replace(At,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function Mt(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+Tt(t)):e.value!==``+Tt(t)&&(e.value=``+Tt(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):Pt(e,o,Tt(n)):Pt(e,o,Tt(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+Tt(s):e.removeAttribute(`name`)}function Nt(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){Dt(e);return}n=n==null?``:``+Tt(n),t=t==null?n:``+Tt(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),Dt(e)}function Pt(e,t,n){t===`number`&&kt(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function Ft(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+Tt(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function It(e,t,n){if(t!=null&&(t=``+Tt(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+Tt(n)}function K(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(M(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=Tt(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),Dt(e)}function Lt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Rt=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function zt(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||Rt.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function Bt(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&zt(e,a,r)}else for(var o in t)t.hasOwnProperty(o)&&zt(e,o,t[o])}function Vt(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var Ht=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),Ut=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Wt(e){return Ut.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function Gt(){}var Kt=null;function qt(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Jt=null,Yt=null;function Xt(e){var t=ct(e);if(t&&(e=t.stateNode)){var n=e[$e]||null;a:switch(e=t.stateNode,t.type){case`input`:if(Mt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+jt(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[$e]||null;if(!a)throw Error(i(90));Mt(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&Ot(r)}break a;case`textarea`:It(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&Ft(e,!!n.multiple,t,!1)}}}var Zt=!1;function Qt(e,t,n){if(Zt)return e(t,n);Zt=!0;try{return e(t)}finally{if(Zt=!1,(Jt!==null||Yt!==null)&&(yu(),Jt&&(t=Jt,e=Yt,Yt=Jt=null,Xt(t),e)))for(t=0;t<e.length;t++)Xt(e[t])}}function $t(e,t){var n=e.stateNode;if(n===null)return null;var r=n[$e]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=!(e===`button`||e===`input`||e===`select`||e===`textarea`)),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var en=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),tn=!1;if(en)try{var nn={};Object.defineProperty(nn,"passive",{get:function(){tn=!0}}),window.addEventListener(`test`,nn,nn),window.removeEventListener(`test`,nn,nn)}catch{tn=!1}var rn=null,an=null,on=null;function sn(){if(on)return on;var e,t=an,n=t.length,r,i=`value`in rn?rn.value:rn.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return on=i.slice(e,1<r?1-r:void 0)}function cn(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function ln(){return!0}function un(){return!1}function dn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?ln:un,this.isPropagationStopped=un,this}return f(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=ln)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=ln)},persist:function(){},isPersistent:ln}),t}var fn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},pn=dn(fn),mn=f({},fn,{view:0,detail:0}),hn=dn(mn),gn,_n,vn,yn=f({},mn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:An,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==vn&&(vn&&e.type===`mousemove`?(gn=e.screenX-vn.screenX,_n=e.screenY-vn.screenY):_n=gn=0,vn=e),gn)},movementY:function(e){return`movementY`in e?e.movementY:_n}}),bn=dn(yn),xn=dn(f({},yn,{dataTransfer:0})),Sn=dn(f({},mn,{relatedTarget:0})),Cn=dn(f({},fn,{animationName:0,elapsedTime:0,pseudoElement:0})),wn=dn(f({},fn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),Tn=dn(f({},fn,{data:0})),En={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},Dn={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},On={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function kn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=On[e])?!!t[e]:!1}function An(){return kn}var jn=dn(f({},mn,{key:function(e){if(e.key){var t=En[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=cn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?Dn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:An,charCode:function(e){return e.type===`keypress`?cn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?cn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),Mn=dn(f({},yn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Nn=dn(f({},mn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:An})),Pn=dn(f({},fn,{propertyName:0,elapsedTime:0,pseudoElement:0})),Fn=dn(f({},yn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),In=dn(f({},fn,{newState:0,oldState:0})),Ln=[9,13,27,32],Rn=en&&`CompositionEvent`in window,zn=null;en&&`documentMode`in document&&(zn=document.documentMode);var Bn=en&&`TextEvent`in window&&!zn,Vn=en&&(!Rn||zn&&8<zn&&11>=zn),Hn=` `,Un=!1;function Wn(e,t){switch(e){case`keyup`:return Ln.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Gn(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Kn=!1;function qn(e,t){switch(e){case`compositionend`:return Gn(t);case`keypress`:return t.which===32?(Un=!0,Hn):null;case`textInput`:return e=t.data,e===Hn&&Un?null:e;default:return null}}function Jn(e,t){if(Kn)return e===`compositionend`||!Rn&&Wn(e,t)?(e=sn(),on=an=rn=null,Kn=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return Vn&&t.locale!==`ko`?null:t.data;default:return null}}var Yn={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Xn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!Yn[e.type]:t===`textarea`}function Zn(e,t,n,r){Jt?Yt?Yt.push(r):Yt=[r]:Jt=r,t=Dd(t,`onChange`),0<t.length&&(n=new pn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var Qn=null,$n=null;function er(e){yd(e,0)}function tr(e){if(Ot(lt(e)))return e}function nr(e,t){if(e===`change`)return t}var rr=!1;if(en){var ir;if(en){var ar=`oninput`in document;if(!ar){var or=document.createElement(`div`);or.setAttribute(`oninput`,`return;`),ar=typeof or.oninput==`function`}ir=ar}else ir=!1;rr=ir&&(!document.documentMode||9<document.documentMode)}function sr(){Qn&&(Qn.detachEvent(`onpropertychange`,cr),$n=Qn=null)}function cr(e){if(e.propertyName===`value`&&tr($n)){var t=[];Zn(t,$n,e,qt(e)),Qt(er,t)}}function lr(e,t,n){e===`focusin`?(sr(),Qn=t,$n=n,Qn.attachEvent(`onpropertychange`,cr)):e===`focusout`&&sr()}function ur(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return tr($n)}function dr(e,t){if(e===`click`)return tr(t)}function fr(e,t){if(e===`input`||e===`change`)return tr(t)}function pr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var mr=typeof Object.is==`function`?Object.is:pr;function hr(e,t){if(mr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!pe.call(t,i)||!mr(e[i],t[i]))return!1}return!0}function gr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function _r(e,t){var n=gr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=gr(n)}}function vr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?vr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function yr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=kt(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=kt(e.document)}return t}function br(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var xr=en&&`documentMode`in document&&11>=document.documentMode,Sr=null,Cr=null,wr=null,Tr=!1;function Er(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Tr||Sr==null||Sr!==kt(r)||(r=Sr,`selectionStart`in r&&br(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),wr&&hr(wr,r)||(wr=r,r=Dd(Cr,`onSelect`),0<r.length&&(t=new pn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Sr)))}function Dr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var Or={animationend:Dr(`Animation`,`AnimationEnd`),animationiteration:Dr(`Animation`,`AnimationIteration`),animationstart:Dr(`Animation`,`AnimationStart`),transitionrun:Dr(`Transition`,`TransitionRun`),transitionstart:Dr(`Transition`,`TransitionStart`),transitioncancel:Dr(`Transition`,`TransitionCancel`),transitionend:Dr(`Transition`,`TransitionEnd`)},kr={},Ar={};en&&(Ar=document.createElement(`div`).style,`AnimationEvent`in window||(delete Or.animationend.animation,delete Or.animationiteration.animation,delete Or.animationstart.animation),`TransitionEvent`in window||delete Or.transitionend.transition);function jr(e){if(kr[e])return kr[e];if(!Or[e])return e;var t=Or[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Ar)return kr[e]=t[n];return e}var Mr=jr(`animationend`),Nr=jr(`animationiteration`),Pr=jr(`animationstart`),Fr=jr(`transitionrun`),Ir=jr(`transitionstart`),Lr=jr(`transitioncancel`),Rr=jr(`transitionend`),zr=new Map,Br=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);Br.push(`scrollEnd`);function Vr(e,t){zr.set(e,t),mt(t,[e])}var Hr=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},Ur=[],Wr=0,Gr=0;function Kr(){for(var e=Wr,t=Gr=Wr=0;t<e;){var n=Ur[t];Ur[t++]=null;var r=Ur[t];Ur[t++]=null;var i=Ur[t];Ur[t++]=null;var a=Ur[t];if(Ur[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&Xr(n,i,a)}}function qr(e,t,n,r){Ur[Wr++]=e,Ur[Wr++]=t,Ur[Wr++]=n,Ur[Wr++]=r,Gr|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Jr(e,t,n,r){return qr(e,t,n,r),Zr(e)}function Yr(e,t){return qr(e,null,null,t),Zr(e)}function Xr(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-ke(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function Zr(e){if(50<uu)throw uu=0,du=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Qr={};function $r(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ei(e,t,n,r){return new $r(e,t,n,r)}function ti(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ni(e,t){var n=e.alternate;return n===null?(n=ei(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function ri(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function ii(e,t,n,r,a,o){var s=0;if(r=e,typeof e==`function`)ti(e)&&(s=1);else if(typeof e==`string`)s=Wf(e,n,V.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case E:return e=ei(31,n,t,a),e.elementType=E,e.lanes=o,e;case g:return ai(n.children,a,o,t);case _:s=8,a|=24;break;case v:return e=ei(12,n,t,a|2),e.elementType=v,e.lanes=o,e;case S:return e=ei(13,n,t,a),e.elementType=S,e.lanes=o,e;case C:return e=ei(19,n,t,a),e.elementType=C,e.lanes=o,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case b:s=10;break a;case y:s=9;break a;case x:s=11;break a;case w:s=14;break a;case T:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=ei(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function ai(e,t,n,r){return e=ei(7,e,r,t),e.lanes=n,e}function oi(e,t,n){return e=ei(6,e,null,t),e.lanes=n,e}function si(e){var t=ei(18,null,null,0);return t.stateNode=e,t}function ci(e,t,n){return t=ei(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var li=new WeakMap;function ui(e,t){if(typeof e==`object`&&e){var n=li.get(e);return n===void 0?(t={value:e,source:t,stack:fe(t)},li.set(e,t),t):n}return{value:e,source:t,stack:fe(t)}}var di=[],fi=0,pi=null,mi=0,hi=[],gi=0,_i=null,q=1,vi=``;function yi(e,t){di[fi++]=mi,di[fi++]=pi,pi=e,mi=t}function bi(e,t,n){hi[gi++]=q,hi[gi++]=vi,hi[gi++]=_i,_i=e;var r=q;e=vi;var i=32-ke(r)-1;r&=~(1<<i),n+=1;var a=32-ke(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,q=1<<32-ke(t)+i|n<<i|r,vi=a+e}else q=1<<a|n<<i|r,vi=e}function xi(e){e.return!==null&&(yi(e,1),bi(e,1,0))}function Si(e){for(;e===pi;)pi=di[--fi],di[fi]=null,mi=di[--fi],di[fi]=null;for(;e===_i;)_i=hi[--gi],hi[gi]=null,vi=hi[--gi],hi[gi]=null,q=hi[--gi],hi[gi]=null}function Ci(e,t){hi[gi++]=q,hi[gi++]=vi,hi[gi++]=_i,q=t.id,vi=t.overflow,_i=e}var wi=null,Ti=null,J=!1,Ei=null,Di=!1,Oi=Error(i(519));function ki(e){throw Pi(ui(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Oi}function Ai(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[Qe]=e,t[$e]=r,n){case`dialog`:bd(`cancel`,t),bd(`close`,t);break;case`iframe`:case`object`:case`embed`:bd(`load`,t);break;case`video`:case`audio`:for(n=0;n<_d.length;n++)bd(_d[n],t);break;case`source`:bd(`error`,t);break;case`img`:case`image`:case`link`:bd(`error`,t),bd(`load`,t);break;case`details`:bd(`toggle`,t);break;case`input`:bd(`invalid`,t),Nt(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:bd(`invalid`,t);break;case`textarea`:bd(`invalid`,t),K(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||Nd(t.textContent,n)?(r.popover!=null&&(bd(`beforetoggle`,t),bd(`toggle`,t)),r.onScroll!=null&&bd(`scroll`,t),r.onScrollEnd!=null&&bd(`scrollend`,t),r.onClick!=null&&(t.onclick=Gt),t=!0):t=!1,t||ki(e,!0)}function ji(e){for(wi=e.return;wi;)switch(wi.tag){case 5:case 31:case 13:Di=!1;return;case 27:case 3:Di=!0;return;default:wi=wi.return}}function Mi(e){if(e!==wi)return!1;if(!J)return ji(e),J=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!==`form`&&n!==`button`)||Gd(e.type,e.memoizedProps)),n=!n),n&&Ti&&ki(e),ji(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Ti=ff(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Ti=ff(e)}else t===27?(t=Ti,$d(e.type)?(e=df,df=null,Ti=e):Ti=t):Ti=wi?uf(e.stateNode.nextSibling):null;return!0}function Ni(){Ti=wi=null,J=!1}function Y(){var e=Ei;return e!==null&&(Xl===null?Xl=e:Xl.push.apply(Xl,e),Ei=null),e}function Pi(e){Ei===null?Ei=[e]:Ei.push(e)}var Fi=R(null),Ii=null,Li=null;function Ri(e,t,n){B(Fi,t._currentValue),t._currentValue=n}function zi(e){e._currentValue=Fi.current,z(Fi)}function Bi(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Vi(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),Bi(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),Bi(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function Hi(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;mr(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===te.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[$f]:e.push($f))}a=a.return}e!==null&&Vi(t,e,n,r),t.flags|=262144}function Ui(e){for(e=e.firstContext;e!==null;){if(!mr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Wi(e){Ii=e,Li=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Gi(e){return qi(Ii,e)}function Ki(e,t){return Ii===null&&Wi(e),qi(e,t)}function qi(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},Li===null){if(e===null)throw Error(i(308));Li=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Li=Li.next=t;return n}var Ji=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Yi=t.unstable_scheduleCallback,Xi=t.unstable_NormalPriority,Zi={$$typeof:b,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Qi(){return{controller:new Ji,data:new Map,refCount:0}}function $i(e){e.refCount--,e.refCount===0&&Yi(Xi,function(){e.controller.abort()})}var ea=null,ta=0,na=0,ra=null;function ia(e,t){if(ea===null){var n=ea=[];ta=0,na=dd(),ra={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return ta++,t.then(aa,aa),t}function aa(){if(--ta===0&&ea!==null){ra!==null&&(ra.status=`fulfilled`);var e=ea;ea=null,na=0,ra=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function oa(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var sa=N.S;N.S=function(e,t){$l=ve(),typeof t==`object`&&t&&typeof t.then==`function`&&ia(e,t),sa!==null&&sa(e,t)};var ca=R(null);function la(){var e=ca.current;return e===null?Pl.pooledCache:e}function ua(e,t){t===null?B(ca,ca.current):B(ca,t.pool)}function da(){var e=la();return e===null?null:{parent:Zi._currentValue,pool:e}}var fa=Error(i(460)),pa=Error(i(474)),ma=Error(i(542)),ha={then:function(){}};function ga(e){return e=e.status,e===`fulfilled`||e===`rejected`}function _a(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(Gt,Gt),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,xa(e),e;default:if(typeof t.status==`string`)t.then(Gt,Gt);else{if(e=Pl,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,xa(e),e}throw ya=t,fa}}function va(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(ya=e,fa):e}}var ya=null;function ba(){if(ya===null)throw Error(i(459));var e=ya;return ya=null,e}function xa(e){if(e===fa||e===ma)throw Error(i(483))}var Sa=null,Ca=0;function wa(e){var t=Ca;return Ca+=1,Sa===null&&(Sa=[]),_a(Sa,e,t)}function Ta(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function Ea(e,t){throw t.$$typeof===p?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function Da(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=ni(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=oi(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===g?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===T&&va(i)===t.type)?(t=a(t,n.props),Ta(t,n),t.return=e,t):(t=ii(n.type,n.key,n.props,null,e.mode,r),Ta(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=ci(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=ai(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=oi(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case m:return n=ii(t.type,t.key,t.props,null,e.mode,n),Ta(n,t),n.return=e,n;case h:return t=ci(t,e.mode,n),t.return=e,t;case T:return t=va(t),f(e,t,n)}if(M(t)||k(t))return t=ai(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,wa(t),n);if(t.$$typeof===b)return f(e,Ki(e,t),n);Ea(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case m:return n.key===i?l(e,t,n,r):null;case h:return n.key===i?u(e,t,n,r):null;case T:return n=va(n),p(e,t,n,r)}if(M(n)||k(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,wa(n),r);if(n.$$typeof===b)return p(e,t,Ki(e,n),r);Ea(e,n)}return null}function _(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case m:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case h:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case T:return r=va(r),_(e,t,n,r,i)}if(M(r)||k(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return _(e,t,n,wa(r),i);if(r.$$typeof===b)return _(e,t,n,Ki(t,r),i);Ea(t,r)}return null}function v(i,a,s,c){for(var l=null,u=null,d=a,m=a=0,h=null;d!==null&&m<s.length;m++){d.index>m?(h=d,d=null):h=d.sibling;var g=p(i,d,s[m],c);if(g===null){d===null&&(d=h);break}e&&d&&g.alternate===null&&t(i,d),a=o(g,a,m),u===null?l=g:u.sibling=g,u=g,d=h}if(m===s.length)return n(i,d),J&&yi(i,m),l;if(d===null){for(;m<s.length;m++)d=f(i,s[m],c),d!==null&&(a=o(d,a,m),u===null?l=d:u.sibling=d,u=d);return J&&yi(i,m),l}for(d=r(d);m<s.length;m++)h=_(d,i,m,s[m],c),h!==null&&(e&&h.alternate!==null&&d.delete(h.key===null?m:h.key),a=o(h,a,m),u===null?l=h:u.sibling=h,u=h);return e&&d.forEach(function(e){return t(i,e)}),J&&yi(i,m),l}function y(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,m=s,h=s=0,g=null,v=c.next();m!==null&&!v.done;h++,v=c.next()){m.index>h?(g=m,m=null):g=m.sibling;var y=p(a,m,v.value,l);if(y===null){m===null&&(m=g);break}e&&m&&y.alternate===null&&t(a,m),s=o(y,s,h),d===null?u=y:d.sibling=y,d=y,m=g}if(v.done)return n(a,m),J&&yi(a,h),u;if(m===null){for(;!v.done;h++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,h),d===null?u=v:d.sibling=v,d=v);return J&&yi(a,h),u}for(m=r(m);!v.done;h++,v=c.next())v=_(m,a,h,v.value,l),v!==null&&(e&&v.alternate!==null&&m.delete(v.key===null?h:v.key),s=o(v,s,h),d===null?u=v:d.sibling=v,d=v);return e&&m.forEach(function(e){return t(a,e)}),J&&yi(a,h),u}function x(e,r,o,c){if(typeof o==`object`&&o&&o.type===g&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case m:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===g){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===T&&va(l)===r.type){n(e,r.sibling),c=a(r,o.props),Ta(c,o),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}o.type===g?(c=ai(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=ii(o.type,o.key,o.props,null,e.mode,c),Ta(c,o),c.return=e,e=c)}return s(e);case h:a:{for(l=o.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=ci(o,e.mode,c),c.return=e,e=c}return s(e);case T:return o=va(o),x(e,r,o,c)}if(M(o))return v(e,r,o,c);if(k(o)){if(l=k(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),y(e,r,o,c)}if(typeof o.then==`function`)return x(e,r,wa(o),c);if(o.$$typeof===b)return x(e,r,Ki(e,o),c);Ea(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=oi(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Ca=0;var i=x(e,t,n,r);return Sa=null,i}catch(t){if(t===fa||t===ma)throw t;var a=ei(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Oa=Da(!0),ka=Da(!1),Aa=!1;function ja(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ma(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Na(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Pa(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Nl&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Zr(e),Xr(e,null,n),t}return qr(e,r,t,n),Zr(e)}function Fa(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ge(e,n)}}function Ia(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var La=!1;function Ra(){if(La){var e=ra;if(e!==null)throw e}}function za(e,t,n,r){La=!1;var i=e.updateQueue;Aa=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var p=s.lane&-536870913,m=p!==s.lane;if(m?(Il&p)===p:(r&p)===p){p!==0&&p===na&&(La=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var h=e,g=s;p=t;var _=n;switch(g.tag){case 1:if(h=g.payload,typeof h==`function`){d=h.call(_,d,p);break a}d=h;break a;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,p=typeof h==`function`?h.call(_,d,p):h,p==null)break a;d=f({},d,p);break a;case 2:Aa=!0}}p=s.callback,p!==null&&(e.flags|=64,m&&(e.flags|=8192),m=i.callbacks,m===null?i.callbacks=[p]:m.push(p))}else m={lane:p,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=m,c=d):u=u.next=m,o|=p;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;m=s,s=m.next,m.next=null,i.lastBaseUpdate=m,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Wl|=o,e.lanes=o,e.memoizedState=d}}function Ba(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function Va(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Ba(n[e],t)}var Ha=R(null),Ua=R(0);function Wa(e,t){e=Hl,B(Ua,e),B(Ha,t),Hl=e|t.baseLanes}function Ga(){B(Ua,Hl),B(Ha,Ha.current)}function Ka(){Hl=Ua.current,z(Ha),z(Ua)}var qa=R(null),Ja=null;function Ya(e){var t=e.alternate;B(eo,eo.current&1),B(qa,e),Ja===null&&(t===null||Ha.current!==null||t.memoizedState!==null)&&(Ja=e)}function Xa(e){B(eo,eo.current),B(qa,e),Ja===null&&(Ja=e)}function Za(e){e.tag===22?(B(eo,eo.current),B(qa,e),Ja===null&&(Ja=e)):Qa(e)}function Qa(){B(eo,eo.current),B(qa,qa.current)}function $a(e){z(qa),Ja===e&&(Ja=null),z(eo)}var eo=R(0);function to(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||sf(n)||cf(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var no=0,X=null,ro=null,io=null,ao=!1,oo=!1,so=!1,co=0,lo=0,uo=null,fo=0;function po(){throw Error(i(321))}function mo(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!mr(e[n],t[n]))return!1;return!0}function ho(e,t,n,r,i,a){return no=a,X=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,N.H=e===null||e.memoizedState===null?js:Ms,so=!1,a=n(r,i),so=!1,oo&&(a=_o(t,n,r,i)),go(e),a}function go(e){N.H=As;var t=ro!==null&&ro.next!==null;if(no=0,io=ro=X=null,ao=!1,lo=0,uo=null,t)throw Error(i(300));e===null||Ys||(e=e.dependencies,e!==null&&Ui(e)&&(Ys=!0))}function _o(e,t,n,r){X=e;var a=0;do{if(oo&&(uo=null),lo=0,oo=!1,25<=a)throw Error(i(301));if(a+=1,io=ro=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}N.H=Ns,o=t(n,r)}while(oo);return o}function vo(){var e=N.H,t=e.useState()[0];return t=typeof t.then==`function`?wo(t):t,e=e.useState()[0],(ro===null?null:ro.memoizedState)!==e&&(X.flags|=1024),t}function yo(){var e=co!==0;return co=0,e}function bo(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function xo(e){if(ao){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}ao=!1}no=0,io=ro=X=null,oo=!1,lo=co=0,uo=null}function Z(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return io===null?X.memoizedState=io=e:io=io.next=e,io}function So(){if(ro===null){var e=X.alternate;e=e===null?null:e.memoizedState}else e=ro.next;var t=io===null?X.memoizedState:io.next;if(t!==null)io=t,ro=e;else{if(e===null)throw X.alternate===null?Error(i(467)):Error(i(310));ro=e,e={memoizedState:ro.memoizedState,baseState:ro.baseState,baseQueue:ro.baseQueue,queue:ro.queue,next:null},io===null?X.memoizedState=io=e:io=io.next=e}return io}function Co(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function wo(e){var t=lo;return lo+=1,uo===null&&(uo=[]),e=_a(uo,e,t),t=X,(io===null?t.memoizedState:io.next)===null&&(t=t.alternate,N.H=t===null||t.memoizedState===null?js:Ms),e}function To(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return wo(e);if(e.$$typeof===b)return Gi(e)}throw Error(i(438,String(e)))}function Eo(e){var t=null,n=X.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=X.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=Co(),X.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=D;return t.index++,n}function Do(e,t){return typeof t==`function`?t(e):t}function Oo(e){return ko(So(),ro,e)}function ko(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(no&f)===f:(Il&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===na&&(d=!0);else if((no&p)===p){u=u.next,p===na&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,X.lanes|=p,Wl|=p;f=u.action,so&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,X.lanes|=f,Wl|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!mr(o,e.memoizedState)&&(Ys=!0,d&&(n=ra,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function Ao(e){var t=So(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);mr(o,t.memoizedState)||(Ys=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function jo(e,t,n){var r=X,a=So(),o=J;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!mr((ro||a).memoizedState,n);if(s&&(a.memoizedState=n,Ys=!0),a=a.queue,ns(Po.bind(null,r,a,e),[e]),a.getSnapshot!==t||s||io!==null&&io.memoizedState.tag&1){if(r.flags|=2048,Zo(9,{destroy:void 0},No.bind(null,r,a,n,t),null),Pl===null)throw Error(i(349));o||no&127||Mo(r,t,n)}return n}function Mo(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=X.updateQueue,t===null?(t=Co(),X.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function No(e,t,n,r){t.value=n,t.getSnapshot=r,Fo(t)&&Io(e)}function Po(e,t,n){return n(function(){Fo(t)&&Io(e)})}function Fo(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!mr(e,n)}catch{return!0}}function Io(e){var t=Yr(e,2);t!==null&&mu(t,e,2)}function Lo(e){var t=Z();if(typeof e==`function`){var n=e;if(e=n(),so){W(!0);try{n()}finally{W(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Do,lastRenderedState:e},t}function Ro(e,t,n,r){return e.baseState=n,ko(e,ro,typeof r==`function`?r:Do)}function zo(e,t,n,r,a){if(Ds(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};N.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,Bo(t,o)):(o.next=n.next,t.pending=n.next=o)}}function Bo(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=N.T,o={};N.T=o;try{var s=n(i,r),c=N.S;c!==null&&c(o,s),Vo(e,t,s)}catch(n){Uo(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),N.T=a}}else try{a=n(i,r),Vo(e,t,a)}catch(n){Uo(e,t,n)}}function Vo(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Ho(e,t,n)},function(n){return Uo(e,t,n)}):Ho(e,t,n)}function Ho(e,t,n){t.status=`fulfilled`,t.value=n,Wo(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Bo(e,n)))}function Uo(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,Wo(t),t=t.next;while(t!==r)}e.action=null}function Wo(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Go(e,t){return t}function Ko(e,t){if(J){var n=Pl.formState;if(n!==null){a:{var r=X;if(J){if(Ti){b:{for(var i=Ti,a=Di;i.nodeType!==8;){if(!a){i=null;break b}if(i=uf(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){Ti=uf(i.nextSibling),r=i.data===`F!`;break a}}ki(r)}r=!1}r&&(t=n[0])}}return n=Z(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Go,lastRenderedState:t},n.queue=r,n=ws.bind(null,X,r),r.dispatch=n,r=Lo(!1),a=Es.bind(null,X,!1,r.queue),r=Z(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=zo.bind(null,X,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function qo(e){return Jo(So(),ro,e)}function Jo(e,t,n){if(t=ko(e,t,Go)[0],e=Oo(Do)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=wo(t)}catch(e){throw e===fa?ma:e}else r=t;t=So();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(X.flags|=2048,Zo(9,{destroy:void 0},Yo.bind(null,i,n),null)),[r,a,e]}function Yo(e,t){e.action=t}function Xo(e){var t=So(),n=ro;if(n!==null)return Jo(t,n,e);So(),t=t.memoizedState,n=So();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function Zo(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=X.updateQueue,t===null&&(t=Co(),X.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function Qo(){return So().memoizedState}function $o(e,t,n,r){var i=Z();X.flags|=e,i.memoizedState=Zo(1|t,{destroy:void 0},n,r===void 0?null:r)}function es(e,t,n,r){var i=So();r=r===void 0?null:r;var a=i.memoizedState.inst;ro!==null&&r!==null&&mo(r,ro.memoizedState.deps)?i.memoizedState=Zo(t,a,n,r):(X.flags|=e,i.memoizedState=Zo(1|t,a,n,r))}function ts(e,t){$o(8390656,8,e,t)}function ns(e,t){es(2048,8,e,t)}function rs(e){X.flags|=4;var t=X.updateQueue;if(t===null)t=Co(),X.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function is(e){var t=So().memoizedState;return rs({ref:t,nextImpl:e}),function(){if(Nl&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function as(e,t){return es(4,2,e,t)}function os(e,t){return es(4,4,e,t)}function ss(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function cs(e,t,n){n=n==null?null:n.concat([e]),es(4,4,ss.bind(null,t,e),n)}function ls(){}function us(e,t){var n=So();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&mo(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function ds(e,t){var n=So();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&mo(t,r[1]))return r[0];if(r=e(),so){W(!0);try{e()}finally{W(!1)}}return n.memoizedState=[r,t],r}function fs(e,t,n){return n===void 0||no&1073741824&&!(Il&261930)?e.memoizedState=t:(e.memoizedState=n,e=pu(),X.lanes|=e,Wl|=e,n)}function ps(e,t,n,r){return mr(n,t)?n:Ha.current===null?!(no&42)||no&1073741824&&!(Il&261930)?(Ys=!0,e.memoizedState=n):(e=pu(),X.lanes|=e,Wl|=e,t):(e=fs(e,n,r),mr(e,t)||(Ys=!0),e)}function ms(e,t,n,r,i){var a=P.p;P.p=a!==0&&8>a?a:8;var o=N.T,s={};N.T=s,Es(e,!1,t,n);try{var c=i(),l=N.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Ts(e,t,oa(c,r),fu(e)):Ts(e,t,r,fu(e))}catch(n){Ts(e,t,{then:function(){},status:`rejected`,reason:n},fu())}finally{P.p=a,o!==null&&s.types!==null&&(o.types=s.types),N.T=o}}function hs(){}function gs(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=_s(e).queue;ms(e,a,t,F,n===null?hs:function(){return vs(e),n(r)})}function _s(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:F,baseState:F,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Do,lastRenderedState:F},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Do,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function vs(e){var t=_s(e);t.next===null&&(t=e.alternate.memoizedState),Ts(e,t.next.queue,{},fu())}function ys(){return Gi($f)}function bs(){return So().memoizedState}function xs(){return So().memoizedState}function Ss(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=fu();e=Na(n);var r=Pa(t,e,n);r!==null&&(mu(r,t,n),Fa(r,t,n)),t={cache:Qi()},e.payload=t;return}t=t.return}}function Cs(e,t,n){var r=fu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Ds(e)?Os(t,n):(n=Jr(e,t,n,r),n!==null&&(mu(n,e,r),ks(n,t,r)))}function ws(e,t,n){Ts(e,t,n,fu())}function Ts(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ds(e))Os(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,mr(s,o))return qr(e,t,i,0),Pl===null&&Kr(),!1}catch{}if(n=Jr(e,t,i,r),n!==null)return mu(n,e,r),ks(n,t,r),!0}return!1}function Es(e,t,n,r){if(r={lane:2,revertLane:dd(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Ds(e)){if(t)throw Error(i(479))}else t=Jr(e,n,r,2),t!==null&&mu(t,e,2)}function Ds(e){var t=e.alternate;return e===X||t!==null&&t===X}function Os(e,t){oo=ao=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function ks(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ge(e,n)}}var As={readContext:Gi,use:To,useCallback:po,useContext:po,useEffect:po,useImperativeHandle:po,useLayoutEffect:po,useInsertionEffect:po,useMemo:po,useReducer:po,useRef:po,useState:po,useDebugValue:po,useDeferredValue:po,useTransition:po,useSyncExternalStore:po,useId:po,useHostTransitionStatus:po,useFormState:po,useActionState:po,useOptimistic:po,useMemoCache:po,useCacheRefresh:po};As.useEffectEvent=po;var js={readContext:Gi,use:To,useCallback:function(e,t){return Z().memoizedState=[e,t===void 0?null:t],e},useContext:Gi,useEffect:ts,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),$o(4194308,4,ss.bind(null,t,e),n)},useLayoutEffect:function(e,t){return $o(4194308,4,e,t)},useInsertionEffect:function(e,t){$o(4,2,e,t)},useMemo:function(e,t){var n=Z();t=t===void 0?null:t;var r=e();if(so){W(!0);try{e()}finally{W(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=Z();if(n!==void 0){var i=n(t);if(so){W(!0);try{n(t)}finally{W(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Cs.bind(null,X,e),[r.memoizedState,e]},useRef:function(e){var t=Z();return e={current:e},t.memoizedState=e},useState:function(e){e=Lo(e);var t=e.queue,n=ws.bind(null,X,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:ls,useDeferredValue:function(e,t){return fs(Z(),e,t)},useTransition:function(){var e=Lo(!1);return e=ms.bind(null,X,e.queue,!0,!1),Z().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=X,a=Z();if(J){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Pl===null)throw Error(i(349));Il&127||Mo(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,ts(Po.bind(null,r,o,e),[e]),r.flags|=2048,Zo(9,{destroy:void 0},No.bind(null,r,o,n,t),null),n},useId:function(){var e=Z(),t=Pl.identifierPrefix;if(J){var n=vi,r=q;n=(r&~(1<<32-ke(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=co++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=fo++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:ys,useFormState:Ko,useActionState:Ko,useOptimistic:function(e){var t=Z();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Es.bind(null,X,!0,n),n.dispatch=t,[e,t]},useMemoCache:Eo,useCacheRefresh:function(){return Z().memoizedState=Ss.bind(null,X)},useEffectEvent:function(e){var t=Z(),n={impl:e};return t.memoizedState=n,function(){if(Nl&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},Ms={readContext:Gi,use:To,useCallback:us,useContext:Gi,useEffect:ns,useImperativeHandle:cs,useInsertionEffect:as,useLayoutEffect:os,useMemo:ds,useReducer:Oo,useRef:Qo,useState:function(){return Oo(Do)},useDebugValue:ls,useDeferredValue:function(e,t){return ps(So(),ro.memoizedState,e,t)},useTransition:function(){var e=Oo(Do)[0],t=So().memoizedState;return[typeof e==`boolean`?e:wo(e),t]},useSyncExternalStore:jo,useId:bs,useHostTransitionStatus:ys,useFormState:qo,useActionState:qo,useOptimistic:function(e,t){return Ro(So(),ro,e,t)},useMemoCache:Eo,useCacheRefresh:xs};Ms.useEffectEvent=is;var Ns={readContext:Gi,use:To,useCallback:us,useContext:Gi,useEffect:ns,useImperativeHandle:cs,useInsertionEffect:as,useLayoutEffect:os,useMemo:ds,useReducer:Ao,useRef:Qo,useState:function(){return Ao(Do)},useDebugValue:ls,useDeferredValue:function(e,t){var n=So();return ro===null?fs(n,e,t):ps(n,ro.memoizedState,e,t)},useTransition:function(){var e=Ao(Do)[0],t=So().memoizedState;return[typeof e==`boolean`?e:wo(e),t]},useSyncExternalStore:jo,useId:bs,useHostTransitionStatus:ys,useFormState:Xo,useActionState:Xo,useOptimistic:function(e,t){var n=So();return ro===null?(n.baseState=e,[e,n.queue.dispatch]):Ro(n,ro,e,t)},useMemoCache:Eo,useCacheRefresh:xs};Ns.useEffectEvent=is;function Ps(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:f({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Fs={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=fu(),i=Na(r);i.payload=t,n!=null&&(i.callback=n),t=Pa(e,i,r),t!==null&&(mu(t,e,r),Fa(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=fu(),i=Na(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Pa(e,i,r),t!==null&&(mu(t,e,r),Fa(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=fu(),r=Na(n);r.tag=2,t!=null&&(r.callback=t),t=Pa(e,r,n),t!==null&&(mu(t,e,n),Fa(t,e,n))}};function Is(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!hr(n,r)||!hr(i,a):!0}function Ls(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Fs.enqueueReplaceState(t,t.state,null)}function Rs(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=f({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function zs(e){Hr(e)}function Bs(e){console.error(e)}function Vs(e){Hr(e)}function Hs(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Us(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Ws(e,t,n){return n=Na(n),n.tag=3,n.payload={element:null},n.callback=function(){Hs(e,t)},n}function Gs(e){return e=Na(e),e.tag=3,e}function Ks(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){Us(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Us(t,n,r),typeof i!=`function`&&(nu===null?nu=new Set([this]):nu.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function qs(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&Hi(t,n,a,!0),n=qa.current,n!==null){switch(n.tag){case 31:case 13:return Ja===null?Eu():n.alternate===null&&Ul===0&&(Ul=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===ha?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),Gu(e,r,a)),!1;case 22:return n.flags|=65536,r===ha?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),Gu(e,r,a)),!1}throw Error(i(435,n.tag))}return Gu(e,r,a),Eu(),!1}if(J)return t=qa.current,t===null?(r!==Oi&&(t=Error(i(423),{cause:r}),Pi(ui(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=ui(r,n),a=Ws(e.stateNode,r,a),Ia(e,a),Ul!==4&&(Ul=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==Oi&&(e=Error(i(422),{cause:r}),Pi(ui(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=ui(o,n),Yl===null?Yl=[o]:Yl.push(o),Ul!==4&&(Ul=2),t===null)return!0;r=ui(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Ws(n.stateNode,r,e),Ia(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(nu===null||!nu.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=Gs(a),Ks(a,e,n,r),Ia(n,a),!1}n=n.return}while(n!==null);return!1}var Js=Error(i(461)),Ys=!1;function Xs(e,t,n,r){t.child=e===null?ka(t,null,n,r):Oa(t,e.child,n,r)}function Zs(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return Wi(t),r=ho(e,t,n,o,a,i),s=yo(),e!==null&&!Ys?(bo(e,t,i),xc(e,t,i)):(J&&s&&xi(t),t.flags|=1,Xs(e,t,r,i),t.child)}function Qs(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!ti(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,$s(e,t,a,r,i)):(e=ii(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!Sc(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?hr:n,n(o,r)&&e.ref===t.ref)return xc(e,t,i)}return t.flags|=1,e=ni(a,r),e.ref=t.ref,e.return=t,t.child=e}function $s(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(hr(a,r)&&e.ref===t.ref)if(Ys=!1,t.pendingProps=r=a,Sc(e,i))e.flags&131072&&(Ys=!0);else return t.lanes=e.lanes,xc(e,t,i)}return sc(e,t,n,r,i)}function ec(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return nc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&ua(t,a===null?null:a.cachePool),a===null?Ga():Wa(t,a),Za(t);else return r=t.lanes=536870912,nc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&ua(t,null),Ga(),Qa(t)):(ua(t,a.cachePool),Wa(t,a),Qa(t),t.memoizedState=null);return Xs(e,t,i,n),t.child}function tc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function nc(e,t,n,r,i){var a=la();return a=a===null?null:{parent:Zi._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&ua(t,null),Ga(),Za(t),e!==null&&Hi(e,t,r,!0),t.childLanes=i,null}function rc(e,t){return t=gc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function ic(e,t,n){return Oa(t,e.child,null,n),e=rc(t,t.pendingProps),e.flags|=2,$a(t),t.memoizedState=null,e}function ac(e,t,n){var r=t.pendingProps,a=(t.flags&128)!=0;if(t.flags&=-129,e===null){if(J){if(r.mode===`hidden`)return e=rc(t,r),t.lanes=536870912,tc(null,e);if(Xa(t),(e=Ti)?(e=of(e,Di),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:_i===null?null:{id:q,overflow:vi},retryLane:536870912,hydrationErrors:null},n=si(e),n.return=t,t.child=n,wi=t,Ti=null)):e=null,e===null)throw ki(t);return t.lanes=536870912,null}return rc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(Xa(t),a)if(t.flags&256)t.flags&=-257,t=ic(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558));else if(Ys||Hi(e,t,n,!1),a=(n&e.childLanes)!==0,Ys||a){if(r=Pl,r!==null&&(s=Ke(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,Yr(e,s),mu(r,e,s),Js;Eu(),t=ic(e,t,n)}else e=o.treeContext,Ti=uf(s.nextSibling),wi=t,J=!0,Ei=null,Di=!1,e!==null&&Ci(t,e),t=rc(t,r),t.flags|=4096;return t}return e=ni(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function oc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function sc(e,t,n,r,i){return Wi(t),n=ho(e,t,n,r,void 0,i),r=yo(),e!==null&&!Ys?(bo(e,t,i),xc(e,t,i)):(J&&r&&xi(t),t.flags|=1,Xs(e,t,n,i),t.child)}function cc(e,t,n,r,i,a){return Wi(t),t.updateQueue=null,n=_o(t,r,n,i),go(e),r=yo(),e!==null&&!Ys?(bo(e,t,a),xc(e,t,a)):(J&&r&&xi(t),t.flags|=1,Xs(e,t,n,a),t.child)}function lc(e,t,n,r,i){if(Wi(t),t.stateNode===null){var a=Qr,o=n.contextType;typeof o==`object`&&o&&(a=Gi(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Fs,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},ja(t),o=n.contextType,a.context=typeof o==`object`&&o?Gi(o):Qr,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Ps(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&Fs.enqueueReplaceState(a,a.state,null),za(t,r,a,i),Ra(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Rs(n,s);a.props=c;var l=a.context,u=n.contextType;o=Qr,typeof u==`object`&&u&&(o=Gi(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Ls(t,a,r,o),Aa=!1;var f=t.memoizedState;a.state=f,za(t,r,a,i),Ra(),l=t.memoizedState,s||f!==l||Aa?(typeof d==`function`&&(Ps(t,n,d,r),l=t.memoizedState),(c=Aa||Is(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,Ma(e,t),o=t.memoizedProps,u=Rs(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=Qr,typeof l==`object`&&l&&(c=Gi(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Ls(t,a,r,c),Aa=!1,f=t.memoizedState,a.state=f,za(t,r,a,i),Ra();var p=t.memoizedState;o!==d||f!==p||Aa||e!==null&&e.dependencies!==null&&Ui(e.dependencies)?(typeof s==`function`&&(Ps(t,n,s,r),p=t.memoizedState),(u=Aa||Is(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&Ui(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,oc(e,t),r=(t.flags&128)!=0,a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=Oa(t,e.child,null,i),t.child=Oa(t,null,n,i)):Xs(e,t,n,i),t.memoizedState=a.state,e=t.child):e=xc(e,t,i),e}function uc(e,t,n,r){return Ni(),t.flags|=256,Xs(e,t,n,r),t.child}var dc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function fc(e){return{baseLanes:e,cachePool:da()}}function pc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=ql),e}function mc(e,t,n){var r=t.pendingProps,a=!1,o=(t.flags&128)!=0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:(eo.current&2)!=0),s&&(a=!0,t.flags&=-129),s=(t.flags&32)!=0,t.flags&=-33,e===null){if(J){if(a?Ya(t):Qa(t),(e=Ti)?(e=of(e,Di),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:_i===null?null:{id:q,overflow:vi},retryLane:536870912,hydrationErrors:null},n=si(e),n.return=t,t.child=n,wi=t,Ti=null)):e=null,e===null)throw ki(t);return cf(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,a?(Qa(t),a=t.mode,c=gc({mode:`hidden`,children:c},a),r=ai(r,a,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=fc(n),r.childLanes=pc(e,s,n),t.memoizedState=dc,tc(null,r)):(Ya(t),hc(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(Ya(t),t.flags&=-257,t=_c(e,t,n)):t.memoizedState===null?(Qa(t),c=r.fallback,a=t.mode,r=gc({mode:`visible`,children:r.children},a),c=ai(c,a,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,Oa(t,e.child,null,n),r=t.child,r.memoizedState=fc(n),r.childLanes=pc(e,s,n),t.memoizedState=dc,t=tc(null,r)):(Qa(t),t.child=e.child,t.flags|=128,t=null);else if(Ya(t),cf(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(i(419)),r.stack=``,r.digest=s,Pi({value:r,source:null,stack:null}),t=_c(e,t,n)}else if(Ys||Hi(e,t,n,!1),s=(n&e.childLanes)!==0,Ys||s){if(s=Pl,s!==null&&(r=Ke(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,Yr(e,r),mu(s,e,r),Js;sf(c)||Eu(),t=_c(e,t,n)}else sf(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,Ti=uf(c.nextSibling),wi=t,J=!0,Ei=null,Di=!1,e!==null&&Ci(t,e),t=hc(t,r.children),t.flags|=4096);return t}return a?(Qa(t),c=r.fallback,a=t.mode,l=e.child,u=l.sibling,r=ni(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=ai(c,a,n,null),c.flags|=2):c=ni(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,tc(null,r),r=t.child,c=e.child.memoizedState,c===null?c=fc(n):(a=c.cachePool,a===null?a=da():(l=Zi._currentValue,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),r.memoizedState=c,r.childLanes=pc(e,s,n),t.memoizedState=dc,tc(e.child,r)):(Ya(t),n=e.child,e=n.sibling,n=ni(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function hc(e,t){return t=gc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function gc(e,t){return e=ei(22,e,null,t),e.lanes=0,e}function _c(e,t,n){return Oa(t,e.child,null,n),e=hc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function vc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Bi(e.return,t,n)}function yc(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function bc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=eo.current,s=(o&2)!=0;if(s?(o=o&1|2,t.flags|=128):o&=1,B(eo,o),Xs(e,t,r,n),r=J?mi:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&vc(e,n,t);else if(e.tag===19)vc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&to(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),yc(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&to(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}yc(t,!0,n,null,a,r);break;case`together`:yc(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function xc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Wl|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(Hi(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=ni(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=ni(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Sc(e,t){return(e.lanes&t)===0?(e=e.dependencies,!!(e!==null&&Ui(e))):!0}function Cc(e,t,n){switch(t.tag){case 3:ne(t,t.stateNode.containerInfo),Ri(t,Zi,e.memoizedState.cache),Ni();break;case 27:case 5:ie(t);break;case 4:ne(t,t.stateNode.containerInfo);break;case 10:Ri(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Xa(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(Ya(t),e=xc(e,t,n),e===null?null:e.sibling):mc(e,t,n):(Ya(t),t.flags|=128,null);Ya(t);break;case 19:var i=(e.flags&128)!=0;if(r=(n&t.childLanes)!==0,r||=(Hi(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return bc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),B(eo,eo.current),r)break;return null;case 22:return t.lanes=0,ec(e,t,n,t.pendingProps);case 24:Ri(t,Zi,e.memoizedState.cache)}return xc(e,t,n)}function wc(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)Ys=!0;else{if(!Sc(e,n)&&!(t.flags&128))return Ys=!1,Cc(e,t,n);Ys=!!(e.flags&131072)}else Ys=!1,J&&t.flags&1048576&&bi(t,mi,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=va(t.elementType),t.type=e,typeof e==`function`)ti(e)?(r=Rs(e,r),t.tag=1,t=lc(null,t,e,r,n)):(t.tag=0,t=sc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===x){t.tag=11,t=Zs(null,t,e,r,n);break a}else if(a===w){t.tag=14,t=Qs(null,t,e,r,n);break a}}throw t=j(e)||e,Error(i(306,t,``))}}return t;case 0:return sc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=Rs(r,t.pendingProps),lc(e,t,r,a,n);case 3:a:{if(ne(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,Ma(e,t),za(t,r,null,n);var s=t.memoizedState;if(r=s.cache,Ri(t,Zi,r),r!==o.cache&&Vi(t,[Zi],n,!0),Ra(),r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=uc(e,t,r,n);break a}else if(r!==a){a=ui(Error(i(424)),t),Pi(a),t=uc(e,t,r,n);break a}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(Ti=uf(e.firstChild),wi=t,J=!0,Ei=null,Di=!0,n=ka(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Ni(),r===a){t=xc(e,t,n);break a}Xs(e,t,r,n)}t=t.child}return t;case 26:return oc(e,t),e===null?(n=jf(t.type,null,t.pendingProps,null))?t.memoizedState=n:J||(n=t.type,e=t.pendingProps,r=Hd(U.current).createElement(n),r[Qe]=t,r[$e]=e,Id(r,n,e),dt(r),t.stateNode=r):t.memoizedState=jf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return ie(t),e===null&&J&&(r=t.stateNode=mf(t.type,t.pendingProps,U.current),wi=t,Di=!0,a=Ti,$d(t.type)?(df=a,Ti=uf(r.firstChild)):Ti=a),Xs(e,t,t.pendingProps.children,n),oc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&J&&((a=r=Ti)&&(r=rf(r,t.type,t.pendingProps,Di),r===null?a=!1:(t.stateNode=r,wi=t,Ti=uf(r.firstChild),Di=!1,a=!0)),a||ki(t)),ie(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,Gd(a,o)?r=null:s!==null&&Gd(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=ho(e,t,vo,null,null,n),$f._currentValue=a),oc(e,t),Xs(e,t,r,n),t.child;case 6:return e===null&&J&&((e=n=Ti)&&(n=af(n,t.pendingProps,Di),n===null?e=!1:(t.stateNode=n,wi=t,Ti=null,e=!0)),e||ki(t)),null;case 13:return mc(e,t,n);case 4:return ne(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Oa(t,null,r,n):Xs(e,t,r,n),t.child;case 11:return Zs(e,t,t.type,t.pendingProps,n);case 7:return Xs(e,t,t.pendingProps,n),t.child;case 8:return Xs(e,t,t.pendingProps.children,n),t.child;case 12:return Xs(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Ri(t,t.type,r.value),Xs(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,Wi(t),a=Gi(a),r=r(a),t.flags|=1,Xs(e,t,r,n),t.child;case 14:return Qs(e,t,t.type,t.pendingProps,n);case 15:return $s(e,t,t.type,t.pendingProps,n);case 19:return bc(e,t,n);case 31:return ac(e,t,n);case 22:return ec(e,t,n,t.pendingProps);case 24:return Wi(t),r=Gi(Zi),e===null?(a=la(),a===null&&(a=Pl,o=Qi(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},ja(t),Ri(t,Zi,a)):((e.lanes&n)!==0&&(Ma(e,t),za(t,null,null,n),Ra()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,Ri(t,Zi,r),r!==a.cache&&Vi(t,[Zi],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),Ri(t,Zi,r))),Xs(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function Tc(e){e.flags|=4}function Ec(e,t,n,r,i){if((t=(e.mode&32)!=0)&&(t=!1),t){if(e.flags|=16777216,(i&335544128)===i)if(e.stateNode.complete)e.flags|=8192;else if(Cu())e.flags|=8192;else throw ya=ha,pa}else e.flags&=-16777217}function Dc(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!Gf(t))if(Cu())e.flags|=8192;else throw ya=ha,pa}function Oc(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:Be(),e.lanes|=t,Jl|=t)}function kc(e,t){if(!J)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Ac(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function jc(e,t,n){var r=t.pendingProps;switch(Si(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ac(t),null;case 1:return Ac(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),zi(Zi),re(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Mi(t)?Tc(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Y())),Ac(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(Tc(t),o===null?(Ac(t),Ec(t,a,null,r,n)):(Ac(t),Dc(t,o))):o?o===e.memoizedState?(Ac(t),t.flags&=-16777217):(Tc(t),Ac(t),Dc(t,o)):(e=e.memoizedProps,e!==r&&Tc(t),Ac(t),Ec(t,a,e,r,n)),null;case 27:if(ae(t),n=U.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Tc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Ac(t),null}e=V.current,Mi(t)?Ai(t,e):(e=mf(a,r,n),t.stateNode=e,Tc(t))}return Ac(t),null;case 5:if(ae(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Tc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Ac(t),null}if(o=V.current,Mi(t))Ai(t,o);else{var s=Hd(U.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[Qe]=t,o[$e]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(Id(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&Tc(t)}}return Ac(t),Ec(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Tc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=U.current,Mi(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=wi,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[Qe]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Nd(e.nodeValue,n)),e||ki(t,!0)}else e=Hd(e).createTextNode(r),e[Qe]=t,t.stateNode=e}return Ac(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Mi(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[Qe]=t}else Ni(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ac(t),e=!1}else n=Y(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?($a(t),t):($a(t),null);if(t.flags&128)throw Error(i(558))}return Ac(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Mi(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[Qe]=t}else Ni(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ac(t),a=!1}else a=Y(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?($a(t),t):($a(t),null)}return $a(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Oc(t,t.updateQueue),Ac(t),null);case 4:return re(),e===null&&Cd(t.stateNode.containerInfo),Ac(t),null;case 10:return zi(t.type),Ac(t),null;case 19:if(z(eo),r=t.memoizedState,r===null)return Ac(t),null;if(a=(t.flags&128)!=0,o=r.rendering,o===null)if(a)kc(r,!1);else{if(Ul!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=to(e),o!==null){for(t.flags|=128,kc(r,!1),e=o.updateQueue,t.updateQueue=e,Oc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)ri(n,e),n=n.sibling;return B(eo,eo.current&1|2),J&&yi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&ve()>eu&&(t.flags|=128,a=!0,kc(r,!1),t.lanes=4194304)}else{if(!a)if(e=to(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Oc(t,e),kc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!J)return Ac(t),null}else 2*ve()-r.renderingStartTime>eu&&n!==536870912&&(t.flags|=128,a=!0,kc(r,!1),t.lanes=4194304);r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(Ac(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=ve(),e.sibling=null,n=eo.current,B(eo,a?n&1|2:n&1),J&&yi(t,r.treeForkCount),e);case 22:case 23:return $a(t),Ka(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Ac(t),t.subtreeFlags&6&&(t.flags|=8192)):Ac(t),n=t.updateQueue,n!==null&&Oc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&z(ca),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),zi(Zi),Ac(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function Mc(e,t){switch(Si(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return zi(Zi),re(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ae(t),null;case 31:if(t.memoizedState!==null){if($a(t),t.alternate===null)throw Error(i(340));Ni()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if($a(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Ni()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return z(eo),null;case 4:return re(),null;case 10:return zi(t.type),null;case 22:case 23:return $a(t),Ka(),e!==null&&z(ca),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return zi(Zi),null;case 25:return null;default:return null}}function Nc(e,t){switch(Si(t),t.tag){case 3:zi(Zi),re();break;case 26:case 27:case 5:ae(t);break;case 4:re();break;case 31:t.memoizedState!==null&&$a(t);break;case 13:$a(t);break;case 19:z(eo);break;case 10:zi(t.type);break;case 22:case 23:$a(t),Ka(),e!==null&&z(ca);break;case 24:zi(Zi)}}function Pc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Wu(t,t.return,e)}}function Fc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Wu(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Wu(t,t.return,e)}}function Ic(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Va(t,n)}catch(t){Wu(e,e.return,t)}}}function Lc(e,t,n){n.props=Rs(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Wu(e,t,n)}}function Rc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Wu(e,t,n)}}function zc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){Wu(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Wu(e,t,n)}else n.current=null}function Bc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Wu(e,e.return,t)}}function Vc(e,t,n){try{var r=e.stateNode;Ld(r,e.type,n,t),r[$e]=t}catch(t){Wu(e,e.return,t)}}function Hc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&$d(e.type)||e.tag===4}function Uc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Hc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&$d(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Wc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Gt));else if(r!==4&&(r===27&&$d(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Wc(e,t,n),e=e.sibling;e!==null;)Wc(e,t,n),e=e.sibling}function Gc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&$d(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Gc(e,t,n),e=e.sibling;e!==null;)Gc(e,t,n),e=e.sibling}function Kc(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Id(t,r,n),t[Qe]=e,t[$e]=n}catch(t){Wu(e,e.return,t)}}var qc=!1,Jc=!1,Yc=!1,Xc=typeof WeakSet==`function`?WeakSet:Set,Zc=null;function Qc(e,t){if(e=e.containerInfo,Bd=cp,e=yr(e),br(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(Vd={focusedElem:e,selectionRange:n},cp=!1,Zc=t;Zc!==null;)if(t=Zc,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,Zc=e;else for(;Zc!==null;){switch(t=Zc,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n<e.length;n++)a=e[n],a.ref.impl=a.nextImpl;break;case 11:case 15:break;case 1:if(e&1024&&o!==null){e=void 0,n=t,a=o.memoizedProps,o=o.memoizedState,r=n.stateNode;try{var h=Rs(n.type,a);e=r.getSnapshotBeforeUpdate(h,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){Wu(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)nf(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:nf(e);break;default:e.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(i(163))}if(e=t.sibling,e!==null){e.return=t.return,Zc=e;break}Zc=t.return}}function $c(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:ml(e,n),r&4&&Pc(5,n);break;case 1:if(ml(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){Wu(n,n.return,e)}else{var i=Rs(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Wu(n,n.return,e)}}r&64&&Ic(n),r&512&&Rc(n,n.return);break;case 3:if(ml(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{Va(e,t)}catch(e){Wu(n,n.return,e)}}break;case 27:t===null&&r&4&&Kc(n);case 26:case 5:ml(e,n),t===null&&r&4&&Bc(n),r&512&&Rc(n,n.return);break;case 12:ml(e,n);break;case 31:ml(e,n),r&4&&al(e,n);break;case 13:ml(e,n),r&4&&ol(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=Ju.bind(null,n),lf(e,n))));break;case 22:if(r=n.memoizedState!==null||qc,!r){t=t!==null&&t.memoizedState!==null||Jc,i=qc;var a=Jc;qc=r,(Jc=t)&&!a?gl(e,n,(n.subtreeFlags&8772)!=0):ml(e,n),qc=i,Jc=a}break;case 30:break;default:ml(e,n)}}function el(e){var t=e.alternate;t!==null&&(e.alternate=null,el(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&ot(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var tl=null,nl=!1;function rl(e,t,n){for(n=n.child;n!==null;)il(e,t,n),n=n.sibling}function il(e,t,n){if(Oe&&typeof Oe.onCommitFiberUnmount==`function`)try{Oe.onCommitFiberUnmount(De,n)}catch{}switch(n.tag){case 26:Jc||zc(n,t),rl(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:Jc||zc(n,t);var r=tl,i=nl;$d(n.type)&&(tl=n.stateNode,nl=!1),rl(e,t,n),hf(n.stateNode),tl=r,nl=i;break;case 5:Jc||zc(n,t);case 6:if(r=tl,i=nl,tl=null,rl(e,t,n),tl=r,nl=i,tl!==null)if(nl)try{(tl.nodeType===9?tl.body:tl.nodeName===`HTML`?tl.ownerDocument.body:tl).removeChild(n.stateNode)}catch(e){Wu(n,t,e)}else try{tl.removeChild(n.stateNode)}catch(e){Wu(n,t,e)}break;case 18:tl!==null&&(nl?(e=tl,ef(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Pp(e)):ef(tl,n.stateNode));break;case 4:r=tl,i=nl,tl=n.stateNode.containerInfo,nl=!0,rl(e,t,n),tl=r,nl=i;break;case 0:case 11:case 14:case 15:Fc(2,n,t),Jc||Fc(4,n,t),rl(e,t,n);break;case 1:Jc||(zc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Lc(n,t,r)),rl(e,t,n);break;case 21:rl(e,t,n);break;case 22:Jc=(r=Jc)||n.memoizedState!==null,rl(e,t,n),Jc=r;break;default:rl(e,t,n)}}function al(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Pp(e)}catch(e){Wu(t,t.return,e)}}}function ol(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Pp(e)}catch(e){Wu(t,t.return,e)}}function sl(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Xc),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Xc),t;default:throw Error(i(435,e.tag))}}function cl(e,t){var n=sl(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=Yu.bind(null,e,t);t.then(r,r)}})}function ll(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r],o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 27:if($d(c.type)){tl=c.stateNode,nl=!1;break a}break;case 5:tl=c.stateNode,nl=!1;break a;case 3:case 4:tl=c.stateNode.containerInfo,nl=!0;break a}c=c.return}if(tl===null)throw Error(i(160));il(o,s,a),tl=null,nl=!1,o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)dl(t,e),t=t.sibling}var ul=null;function dl(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:ll(t,e),fl(e),r&4&&(Fc(3,e,e.return),Pc(3,e),Fc(5,e,e.return));break;case 1:ll(t,e),fl(e),r&512&&(Jc||n===null||zc(n,n.return)),r&64&&qc&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var a=ul;if(ll(t,e),fl(e),r&512&&(Jc||n===null||zc(n,n.return)),r&4){var o=n===null?null:n.memoizedState;if(r=e.memoizedState,n===null)if(r===null)if(e.stateNode===null){a:{r=e.type,n=e.memoizedProps,a=a.ownerDocument||a;b:switch(r){case`title`:o=a.getElementsByTagName(`title`)[0],(!o||o[at]||o[Qe]||o.namespaceURI===`http://www.w3.org/2000/svg`||o.hasAttribute(`itemprop`))&&(o=a.createElement(r),a.head.insertBefore(o,a.querySelector(`head > title`))),Id(o,r,n),o[Qe]=e,dt(o),r=o;break a;case`link`:var s=Hf(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&o.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&o.getAttribute(`title`)===(n.title==null?null:n.title)&&o.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(c,1);break b}}o=a.createElement(r),Id(o,r,n),a.head.appendChild(o);break;case`meta`:if(s=Hf(`meta`,`content`,a).get(r+(n.content||``))){for(c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`content`)===(n.content==null?null:``+n.content)&&o.getAttribute(`name`)===(n.name==null?null:n.name)&&o.getAttribute(`property`)===(n.property==null?null:n.property)&&o.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&o.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){s.splice(c,1);break b}}o=a.createElement(r),Id(o,r,n),a.head.appendChild(o);break;default:throw Error(i(468,r))}o[Qe]=e,dt(o),r=o}e.stateNode=r}else Uf(a,e.type,e.stateNode);else e.stateNode=Lf(a,r,e.memoizedProps);else o===r?r===null&&e.stateNode!==null&&Vc(e,e.memoizedProps,n.memoizedProps):(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?Uf(a,e.type,e.stateNode):Lf(a,r,e.memoizedProps))}break;case 27:ll(t,e),fl(e),r&512&&(Jc||n===null||zc(n,n.return)),n!==null&&r&4&&Vc(e,e.memoizedProps,n.memoizedProps);break;case 5:if(ll(t,e),fl(e),r&512&&(Jc||n===null||zc(n,n.return)),e.flags&32){a=e.stateNode;try{Lt(a,``)}catch(t){Wu(e,e.return,t)}}r&4&&e.stateNode!=null&&(a=e.memoizedProps,Vc(e,a,n===null?a:n.memoizedProps)),r&1024&&(Yc=!0);break;case 6:if(ll(t,e),fl(e),r&4){if(e.stateNode===null)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){Wu(e,e.return,t)}}break;case 3:if(Vf=null,a=ul,ul=vf(t.containerInfo),ll(t,e),ul=a,fl(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Pp(t.containerInfo)}catch(t){Wu(e,e.return,t)}Yc&&(Yc=!1,pl(e));break;case 4:r=ul,ul=vf(e.stateNode.containerInfo),ll(t,e),fl(e),ul=r;break;case 12:ll(t,e),fl(e);break;case 31:ll(t,e),fl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,cl(e,r)));break;case 13:ll(t,e),fl(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(Ql=ve()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,cl(e,r)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=qc,d=Jc;if(qc=u||a,Jc=d||l,ll(t,e),Jc=d,qc=u,fl(e),r&8192)a:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||qc||Jc||hl(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(o=l.stateNode,a)s=o.style,typeof s.setProperty==`function`?s.setProperty(`display`,`none`,`important`):s.display=`none`;else{c=l.stateNode;var f=l.memoizedProps.style,p=f!=null&&f.hasOwnProperty(`display`)?f.display:null;c.style.display=p==null||typeof p==`boolean`?``:(``+p).trim()}}catch(e){Wu(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?``:l.memoizedProps}catch(e){Wu(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;a?tf(m,!0):tf(l.stateNode,!1)}catch(e){Wu(l,l.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break a;for(;t.sibling===null;){if(t.return===null||t.return===e)break a;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,cl(e,n))));break;case 19:ll(t,e),fl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,cl(e,r)));break;case 30:break;case 21:break;default:ll(t,e),fl(e)}}function fl(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Hc(r)){n=r;break}r=r.return}if(n==null)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;Gc(e,Uc(e),a);break;case 5:var o=n.stateNode;n.flags&32&&(Lt(o,``),n.flags&=-33),Gc(e,Uc(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;Wc(e,Uc(e),s);break;default:throw Error(i(161))}}catch(t){Wu(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function pl(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;pl(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function ml(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)$c(e,t.alternate,t),t=t.sibling}function hl(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Fc(4,t,t.return),hl(t);break;case 1:zc(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&Lc(t,t.return,n),hl(t);break;case 27:hf(t.stateNode);case 26:case 5:zc(t,t.return),hl(t);break;case 22:t.memoizedState===null&&hl(t);break;case 30:hl(t);break;default:hl(t)}e=e.sibling}}function gl(e,t,n){for(n&&=(t.subtreeFlags&8772)!=0,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:gl(i,a,n),Pc(4,a);break;case 1:if(gl(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){Wu(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)Ba(c[i],s)}catch(e){Wu(r,r.return,e)}}n&&o&64&&Ic(a),Rc(a,a.return);break;case 27:Kc(a);case 26:case 5:gl(i,a,n),n&&r===null&&o&4&&Bc(a),Rc(a,a.return);break;case 12:gl(i,a,n);break;case 31:gl(i,a,n),n&&o&4&&al(i,a);break;case 13:gl(i,a,n),n&&o&4&&ol(i,a);break;case 22:a.memoizedState===null&&gl(i,a,n),Rc(a,a.return);break;case 30:break;default:gl(i,a,n)}t=t.sibling}}function _l(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&$i(n))}function vl(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&$i(e))}function yl(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)bl(e,t,n,r),t=t.sibling}function bl(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:yl(e,t,n,r),i&2048&&Pc(9,t);break;case 1:yl(e,t,n,r);break;case 3:yl(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&$i(e)));break;case 12:if(i&2048){yl(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){Wu(t,t.return,e)}}else yl(e,t,n,r);break;case 31:yl(e,t,n,r);break;case 13:yl(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?yl(e,t,n,r):(a._visibility|=2,xl(e,t,n,r,(t.subtreeFlags&10256)!=0||!1)):a._visibility&2?yl(e,t,n,r):Sl(e,t),i&2048&&_l(o,t);break;case 24:yl(e,t,n,r),i&2048&&vl(t.alternate,t);break;default:yl(e,t,n,r)}}function xl(e,t,n,r,i){for(i&&=(t.subtreeFlags&10256)!=0||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:xl(a,o,s,c,i),Pc(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,xl(a,o,s,c,i)):u._visibility&2?xl(a,o,s,c,i):Sl(a,o),i&&l&2048&&_l(o.alternate,o);break;case 24:xl(a,o,s,c,i),i&&l&2048&&vl(o.alternate,o);break;default:xl(a,o,s,c,i)}t=t.sibling}}function Sl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Sl(n,r),i&2048&&_l(r.alternate,r);break;case 24:Sl(n,r),i&2048&&vl(r.alternate,r);break;default:Sl(n,r)}t=t.sibling}}var Cl=8192;function wl(e,t,n){if(e.subtreeFlags&Cl)for(e=e.child;e!==null;)Tl(e,t,n),e=e.sibling}function Tl(e,t,n){switch(e.tag){case 26:wl(e,t,n),e.flags&Cl&&e.memoizedState!==null&&Kf(n,ul,e.memoizedState,e.memoizedProps);break;case 5:wl(e,t,n);break;case 3:case 4:var r=ul;ul=vf(e.stateNode.containerInfo),wl(e,t,n),ul=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Cl,Cl=16777216,wl(e,t,n),Cl=r):wl(e,t,n));break;default:wl(e,t,n)}}function El(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Dl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];Zc=r,Al(r,e)}El(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Ol(e),e=e.sibling}function Ol(e){switch(e.tag){case 0:case 11:case 15:Dl(e),e.flags&2048&&Fc(9,e,e.return);break;case 3:Dl(e);break;case 12:Dl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,kl(e)):Dl(e);break;default:Dl(e)}}function kl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];Zc=r,Al(r,e)}El(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Fc(8,t,t.return),kl(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,kl(t));break;default:kl(t)}e=e.sibling}}function Al(e,t){for(;Zc!==null;){var n=Zc;switch(n.tag){case 0:case 11:case 15:Fc(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:$i(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,Zc=r;else a:for(n=e;Zc!==null;){r=Zc;var i=r.sibling,a=r.return;if(el(r),r===n){Zc=null;break a}if(i!==null){i.return=a,Zc=i;break a}Zc=a}}}var jl={getCacheForType:function(e){var t=Gi(Zi),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Gi(Zi).controller.signal}},Ml=typeof WeakMap==`function`?WeakMap:Map,Nl=0,Pl=null,Fl=null,Il=0,Ll=0,Rl=null,zl=!1,Bl=!1,Vl=!1,Hl=0,Ul=0,Wl=0,Gl=0,Kl=0,ql=0,Jl=0,Yl=null,Xl=null,Zl=!1,Ql=0,$l=0,eu=1/0,tu=null,nu=null,ru=0,iu=null,au=null,ou=0,su=0,cu=null,lu=null,uu=0,du=null;function fu(){return Nl&2&&Il!==0?Il&-Il:N.T===null?Ye():dd()}function pu(){if(ql===0)if(!(Il&536870912)||J){var e=Pe;Pe<<=1,!(Pe&3932160)&&(Pe=262144),ql=e}else ql=536870912;return e=qa.current,e!==null&&(e.flags|=32),ql}function mu(e,t,n){(e===Pl&&(Ll===2||Ll===9)||e.cancelPendingCommit!==null)&&(xu(e,0),vu(e,Il,ql,!1)),He(e,n),(!(Nl&2)||e!==Pl)&&(e===Pl&&(!(Nl&2)&&(Gl|=n),Ul===4&&vu(e,Il,ql,!1)),rd(e))}function hu(e,t,n){if(Nl&6)throw Error(i(327));var r=!n&&(t&127)==0&&(t&e.expiredLanes)===0||Re(e,t),a=r?ku(e,t):Du(e,t,!0),o=r;do{if(a===0){Bl&&!r&&vu(e,t,0,!1);break}else{if(n=e.current.alternate,o&&!_u(n)){a=Du(e,t,!1),o=!1;continue}if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=Yl;var l=c.current.memoizedState.isDehydrated;if(l&&(xu(c,s).flags|=256),s=Du(c,s,!1),s!==2){if(Vl&&!l){c.errorRecoveryDisabledLanes|=o,Gl|=o,a=4;break a}o=Xl,Xl=a,o!==null&&(Xl===null?Xl=o:Xl.push.apply(Xl,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){xu(e,0),vu(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t)break;case 6:vu(r,t,ql,!zl);break a;case 2:Xl=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=Ql+300-ve(),10<a)){if(vu(r,t,ql,!zl),Le(r,0,!0)!==0)break a;ou=t,r.timeoutHandle=Jd(gu.bind(null,r,n,Xl,tu,Zl,t,ql,Gl,Jl,zl,o,`Throttled`,-0,0),a);break a}gu(r,n,Xl,tu,Zl,t,ql,Gl,Jl,zl,o,null,-0,0)}}break}while(1);rd(e)}function gu(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Gt},Tl(t,a,d);var m=(a&62914560)===a?Ql-ve():(a&4194048)===a?$l-ve():0;if(m=Jf(d,m),m!==null){ou=a,e.cancelPendingCommit=m(Iu.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),vu(e,a,o,!l);return}}Iu(e,t,a,n,r,i,o,s,c)}function _u(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!mr(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function vu(e,t,n,r){t&=~Kl,t&=~Gl,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-ke(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&We(e,n,t)}function yu(){return Nl&6?!0:(id(0,!1),!1)}function bu(){if(Fl!==null){if(Ll===0)var e=Fl.return;else e=Fl,Li=Ii=null,xo(e),Sa=null,Ca=0,e=Fl;for(;e!==null;)Nc(e.alternate,e),e=e.return;Fl=null}}function xu(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,Yd(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),ou=0,bu(),Pl=e,Fl=n=ni(e.current,null),Il=t,Ll=0,Rl=null,zl=!1,Bl=Re(e,t),Vl=!1,Jl=ql=Kl=Gl=Wl=Ul=0,Xl=Yl=null,Zl=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-ke(r),a=1<<i;t|=e[i],r&=~a}return Hl=t,Kr(),n}function Su(e,t){X=null,N.H=As,t===fa||t===ma?(t=ba(),Ll=3):t===pa?(t=ba(),Ll=4):Ll=t===Js?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Rl=t,Fl===null&&(Ul=1,Hs(e,ui(t,e.current)))}function Cu(){var e=qa.current;return e===null?!0:(Il&4194048)===Il?Ja===null:(Il&62914560)===Il||Il&536870912?e===Ja:!1}function wu(){var e=N.H;return N.H=As,e===null?As:e}function Tu(){var e=N.A;return N.A=jl,e}function Eu(){Ul=4,zl||(Il&4194048)!==Il&&qa.current!==null||(Bl=!0),!(Wl&134217727)&&!(Gl&134217727)||Pl===null||vu(Pl,Il,ql,!1)}function Du(e,t,n){var r=Nl;Nl|=2;var i=wu(),a=Tu();(Pl!==e||Il!==t)&&(tu=null,xu(e,t)),t=!1;var o=Ul;a:do try{if(Ll!==0&&Fl!==null){var s=Fl,c=Rl;switch(Ll){case 8:bu(),o=6;break a;case 3:case 2:case 9:case 6:qa.current===null&&(t=!0);var l=Ll;if(Ll=0,Rl=null,Nu(e,s,c,l),n&&Bl){o=0;break a}break;default:l=Ll,Ll=0,Rl=null,Nu(e,s,c,l)}}Ou(),o=Ul;break}catch(t){Su(e,t)}while(1);return t&&e.shellSuspendCounter++,Li=Ii=null,Nl=r,N.H=i,N.A=a,Fl===null&&(Pl=null,Il=0,Kr()),o}function Ou(){for(;Fl!==null;)ju(Fl)}function ku(e,t){var n=Nl;Nl|=2;var r=wu(),a=Tu();Pl!==e||Il!==t?(tu=null,eu=ve()+500,xu(e,t)):Bl=Re(e,t);a:do try{if(Ll!==0&&Fl!==null){t=Fl;var o=Rl;b:switch(Ll){case 1:Ll=0,Rl=null,Nu(e,t,o,1);break;case 2:case 9:if(ga(o)){Ll=0,Rl=null,Mu(t);break}t=function(){Ll!==2&&Ll!==9||Pl!==e||(Ll=7),rd(e)},o.then(t,t);break a;case 3:Ll=7;break a;case 4:Ll=5;break a;case 7:ga(o)?(Ll=0,Rl=null,Mu(t)):(Ll=0,Rl=null,Nu(e,t,o,7));break;case 5:var s=null;switch(Fl.tag){case 26:s=Fl.memoizedState;case 5:case 27:var c=Fl;if(s?Gf(s):c.stateNode.complete){Ll=0,Rl=null;var l=c.sibling;if(l!==null)Fl=l;else{var u=c.return;u===null?Fl=null:(Fl=u,Pu(u))}break b}}Ll=0,Rl=null,Nu(e,t,o,5);break;case 6:Ll=0,Rl=null,Nu(e,t,o,6);break;case 8:bu(),Ul=6;break a;default:throw Error(i(462))}}Au();break}catch(t){Su(e,t)}while(1);return Li=Ii=null,N.H=r,N.A=a,Nl=n,Fl===null?(Pl=null,Il=0,Kr(),Ul):0}function Au(){for(;Fl!==null&&!ge();)ju(Fl)}function ju(e){var t=wc(e.alternate,e,Hl);e.memoizedProps=e.pendingProps,t===null?Pu(e):Fl=t}function Mu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=cc(n,t,t.pendingProps,t.type,void 0,Il);break;case 11:t=cc(n,t,t.pendingProps,t.type.render,t.ref,Il);break;case 5:xo(t);default:Nc(n,t),t=Fl=ri(t,Hl),t=wc(n,t,Hl)}e.memoizedProps=e.pendingProps,t===null?Pu(e):Fl=t}function Nu(e,t,n,r){Li=Ii=null,xo(t),Sa=null,Ca=0;var i=t.return;try{if(qs(e,i,t,n,Il)){Ul=1,Hs(e,ui(n,e.current)),Fl=null;return}}catch(t){if(i!==null)throw Fl=i,t;Ul=1,Hs(e,ui(n,e.current)),Fl=null;return}t.flags&32768?(J||r===1?e=!0:Bl||Il&536870912?e=!1:(zl=e=!0,(r===2||r===9||r===3||r===6)&&(r=qa.current,r!==null&&r.tag===13&&(r.flags|=16384))),Fu(t,e)):Pu(t)}function Pu(e){var t=e;do{if(t.flags&32768){Fu(t,zl);return}e=t.return;var n=jc(t.alternate,t,Hl);if(n!==null){Fl=n;return}if(t=t.sibling,t!==null){Fl=t;return}Fl=t=e}while(t!==null);Ul===0&&(Ul=5)}function Fu(e,t){do{var n=Mc(e.alternate,e);if(n!==null){n.flags&=32767,Fl=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Fl=e;return}Fl=e=n}while(e!==null);Ul=6,Fl=null}function Iu(e,t,n,r,a,o,s,c,l){e.cancelPendingCommit=null;do Vu();while(ru!==0);if(Nl&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));if(o=t.lanes|t.childLanes,o|=Gr,Ue(e,n,o,s,c,l),e===Pl&&(Fl=Pl=null,Il=0),au=t,iu=e,ou=n,su=o,cu=a,lu=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,Xu(Se,function(){return Hu(),null})):(e.callbackNode=null,e.callbackPriority=0),r=(t.flags&13878)!=0,t.subtreeFlags&13878||r){r=N.T,N.T=null,a=P.p,P.p=2,s=Nl,Nl|=4;try{Qc(e,t,n)}finally{Nl=s,P.p=a,N.T=r}}ru=1,Lu(),Ru(),zu()}}function Lu(){if(ru===1){ru=0;var e=iu,t=au,n=(t.flags&13878)!=0;if(t.subtreeFlags&13878||n){n=N.T,N.T=null;var r=P.p;P.p=2;var i=Nl;Nl|=4;try{dl(t,e);var a=Vd,o=yr(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&vr(s.ownerDocument.documentElement,s)){if(c!==null&&br(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=_r(s,h),v=_r(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}cp=!!Bd,Vd=Bd=null}finally{Nl=i,P.p=r,N.T=n}}e.current=t,ru=2}}function Ru(){if(ru===2){ru=0;var e=iu,t=au,n=(t.flags&8772)!=0;if(t.subtreeFlags&8772||n){n=N.T,N.T=null;var r=P.p;P.p=2;var i=Nl;Nl|=4;try{$c(e,t.alternate,t)}finally{Nl=i,P.p=r,N.T=n}}ru=3}}function zu(){if(ru===4||ru===3){ru=0,_e();var e=iu,t=au,n=ou,r=lu;t.subtreeFlags&10256||t.flags&10256?ru=5:(ru=0,au=iu=null,Bu(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(nu=null),Je(n),t=t.stateNode,Oe&&typeof Oe.onCommitFiberRoot==`function`)try{Oe.onCommitFiberRoot(De,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=N.T,i=P.p,P.p=2,N.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{N.T=t,P.p=i}}ou&3&&Vu(),rd(e),i=e.pendingLanes,n&261930&&i&42?e===du?uu++:(uu=0,du=e):uu=0,id(0,!1)}}function Bu(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,$i(t)))}function Vu(){return Lu(),Ru(),zu(),Hu()}function Hu(){if(ru!==5)return!1;var e=iu,t=su;su=0;var n=Je(ou),r=N.T,a=P.p;try{P.p=32>n?32:n,N.T=null,n=cu,cu=null;var o=iu,s=ou;if(ru=0,au=iu=null,ou=0,Nl&6)throw Error(i(331));var c=Nl;if(Nl|=4,Ol(o.current),bl(o,o.current,s,n),Nl=c,id(0,!1),Oe&&typeof Oe.onPostCommitFiberRoot==`function`)try{Oe.onPostCommitFiberRoot(De,o)}catch{}return!0}finally{P.p=a,N.T=r,Bu(e,t)}}function Uu(e,t,n){t=ui(n,t),t=Ws(e.stateNode,t,2),e=Pa(e,t,2),e!==null&&(He(e,2),rd(e))}function Wu(e,t,n){if(e.tag===3)Uu(e,e,n);else for(;t!==null;){if(t.tag===3){Uu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(nu===null||!nu.has(r))){e=ui(n,e),n=Gs(2),r=Pa(t,n,2),r!==null&&(Ks(n,r,t,e),He(r,2),rd(r));break}}t=t.return}}function Gu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Ml;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Vl=!0,i.add(n),e=Ku.bind(null,e,t,n),t.then(e,e))}function Ku(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Pl===e&&(Il&n)===n&&(Ul===4||Ul===3&&(Il&62914560)===Il&&300>ve()-Ql?!(Nl&2)&&xu(e,0):Kl|=n,Jl===Il&&(Jl=0)),rd(e)}function qu(e,t){t===0&&(t=Be()),e=Yr(e,t),e!==null&&(He(e,t),rd(e))}function Ju(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),qu(e,n)}function Yu(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),qu(e,n)}function Xu(e,t){return me(e,t)}var Zu=null,Qu=null,$u=!1,ed=!1,td=!1,nd=0;function rd(e){e!==Qu&&e.next===null&&(Qu===null?Zu=Qu=e:Qu=Qu.next=e),ed=!0,$u||($u=!0,ud())}function id(e,t){if(!td&&ed){td=!0;do for(var n=!1,r=Zu;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-ke(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,ld(r,a))}else a=Il,a=Le(r,r===Pl?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||Re(r,a)||(n=!0,ld(r,a));r=r.next}while(n);td=!1}}function ad(){od()}function od(){ed=$u=!1;var e=0;nd!==0&&qd()&&(e=nd);for(var t=ve(),n=null,r=Zu;r!==null;){var i=r.next,a=sd(r,t);a===0?(r.next=null,n===null?Zu=i:n.next=i,i===null&&(Qu=n)):(n=r,(e!==0||a&3)&&(ed=!0)),r=i}ru!==0&&ru!==5||id(e,!1),nd!==0&&(nd=0)}function sd(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-ke(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=ze(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Pl,n=Il,n=Le(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Ll===2||Ll===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&he(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||Re(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&he(r),Je(n)){case 2:case 8:n=xe;break;case 32:n=Se;break;case 268435456:n=we;break;default:n=Se}return r=cd.bind(null,e),n=me(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&he(r),e.callbackPriority=2,e.callbackNode=null,2}function cd(e,t){if(ru!==0&&ru!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(Vu()&&e.callbackNode!==n)return null;var r=Il;return r=Le(e,e===Pl?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(hu(e,r,t),sd(e,ve()),e.callbackNode!=null&&e.callbackNode===n?cd.bind(null,e):null)}function ld(e,t){if(Vu())return null;hu(e,t,!0)}function ud(){Zd(function(){Nl&6?me(be,ad):od()})}function dd(){if(nd===0){var e=na;e===0&&(e=Ne,Ne<<=1,!(Ne&261888)&&(Ne=256)),nd=e}return nd}function fd(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:Wt(``+e)}function pd(e,t){var n=t.ownerDocument.createElement(`input`);return n.name=t.name,n.value=t.value,e.id&&n.setAttribute(`form`,e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function md(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=fd((i[$e]||null).action),o=r.submitter;o&&(t=(t=o[$e]||null)?fd(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new pn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(nd!==0){var e=o?pd(i,o):new FormData(i);gs(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?pd(i,o):new FormData(i),gs(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var hd=0;hd<Br.length;hd++){var gd=Br[hd];Vr(gd.toLowerCase(),`on`+(gd[0].toUpperCase()+gd.slice(1)))}Vr(Mr,`onAnimationEnd`),Vr(Nr,`onAnimationIteration`),Vr(Pr,`onAnimationStart`),Vr(`dblclick`,`onDoubleClick`),Vr(`focusin`,`onFocus`),Vr(`focusout`,`onBlur`),Vr(Fr,`onTransitionRun`),Vr(Ir,`onTransitionStart`),Vr(Lr,`onTransitionCancel`),Vr(Rr,`onTransitionEnd`),ht(`onMouseEnter`,[`mouseout`,`mouseover`]),ht(`onMouseLeave`,[`mouseout`,`mouseover`]),ht(`onPointerEnter`,[`pointerout`,`pointerover`]),ht(`onPointerLeave`,[`pointerout`,`pointerover`]),mt(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),mt(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),mt(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),mt(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),mt(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),mt(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var _d=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),vd=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(_d));function yd(e,t){t=(t&4)!=0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Hr(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Hr(e)}i.currentTarget=null,a=c}}}}function bd(e,t){var n=t[tt];n===void 0&&(n=t[tt]=new Set);var r=e+`__bubble`;n.has(r)||(wd(t,e,2,!1),n.add(r))}function xd(e,t,n){var r=0;t&&(r|=4),wd(n,e,r,t)}var Sd=`_reactListening`+Math.random().toString(36).slice(2);function Cd(e){if(!e[Sd]){e[Sd]=!0,ft.forEach(function(t){t!==`selectionchange`&&(vd.has(t)||xd(t,!1,e),xd(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Sd]||(t[Sd]=!0,xd(`selectionchange`,!1,t))}}function wd(e,t,n,r){switch(hp(t)){case 2:var i=lp;break;case 8:i=up;break;default:i=dp}n=i.bind(null,t,n,e),i=void 0,!tn||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function Td(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var c=r.stateNode.containerInfo;if(c===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;c!==null;){if(s=st(c),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=a=s;continue a}c=c.parentNode}}r=r.return}Qt(function(){var r=a,i=qt(n),s=[];a:{var c=zr.get(e);if(c!==void 0){var l=pn,u=e;switch(e){case`keypress`:if(cn(n)===0)break a;case`keydown`:case`keyup`:l=jn;break;case`focusin`:u=`focus`,l=Sn;break;case`focusout`:u=`blur`,l=Sn;break;case`beforeblur`:case`afterblur`:l=Sn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=bn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=xn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=Nn;break;case Mr:case Nr:case Pr:l=Cn;break;case Rr:l=Pn;break;case`scroll`:case`scrollend`:l=hn;break;case`wheel`:l=Fn;break;case`copy`:case`cut`:case`paste`:l=wn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=Mn;break;case`toggle`:case`beforetoggle`:l=In}var d=(t&4)!=0,f=!d&&(e===`scroll`||e===`scrollend`),p=d?c===null?null:c+`Capture`:c;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=$t(m,p),g!=null&&d.push(Ed(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(c=e===`mouseover`||e===`pointerover`,l=e===`mouseout`||e===`pointerout`,c&&n!==Kt&&(u=n.relatedTarget||n.fromElement)&&(st(u)||u[et]))break a;if((l||c)&&(c=i.window===i?i:(c=i.ownerDocument)?c.defaultView||c.parentWindow:window,l?(u=n.relatedTarget||n.toElement,l=r,u=u?st(u):null,u!==null&&(f=o(u),d=u.tag,u!==f||d!==5&&d!==27&&d!==6)&&(u=null)):(l=null,u=r),l!==u)){if(d=bn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=Mn,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?c:lt(l),h=u==null?c:lt(u),c=new d(g,m+`leave`,l,n,i),c.target=f,c.relatedTarget=h,g=null,st(i)===r&&(d=new d(p,m+`enter`,u,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,l&&u)b:{for(d=Od,p=l,m=u,h=0,g=p;g;g=d(g))h++;g=0;for(var _=m;_;_=d(_))g++;for(;0<h-g;)p=d(p),h--;for(;0<g-h;)m=d(m),g--;for(;h--;){if(p===m||m!==null&&p===m.alternate){d=p;break b}p=d(p),m=d(m)}d=null}else d=null;l!==null&&kd(s,c,l,d,!1),u!==null&&f!==null&&kd(s,f,u,d,!0)}}a:{if(c=r?lt(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var v=nr;else if(Xn(c))if(rr)v=fr;else{v=ur;var y=lr}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&Vt(r.elementType)&&(v=nr):v=dr;if(v&&=v(e,r)){Zn(s,v,n,i);break a}y&&y(e,c,r),e===`focusout`&&r&&c.type===`number`&&r.memoizedProps.value!=null&&Pt(c,`number`,c.value)}switch(y=r?lt(r):window,e){case`focusin`:(Xn(y)||y.contentEditable===`true`)&&(Sr=y,Cr=r,wr=null);break;case`focusout`:wr=Cr=Sr=null;break;case`mousedown`:Tr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:Tr=!1,Er(s,n,i);break;case`selectionchange`:if(xr)break;case`keydown`:case`keyup`:Er(s,n,i)}var b;if(Rn)b:{switch(e){case`compositionstart`:var x=`onCompositionStart`;break b;case`compositionend`:x=`onCompositionEnd`;break b;case`compositionupdate`:x=`onCompositionUpdate`;break b}x=void 0}else Kn?Wn(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(Vn&&n.locale!==`ko`&&(Kn||x!==`onCompositionStart`?x===`onCompositionEnd`&&Kn&&(b=sn()):(rn=i,an=`value`in rn?rn.value:rn.textContent,Kn=!0)),y=Dd(r,x),0<y.length&&(x=new Tn(x,e,null,n,i),s.push({event:x,listeners:y}),b?x.data=b:(b=Gn(n),b!==null&&(x.data=b)))),(b=Bn?qn(e,n):Jn(e,n))&&(x=Dd(r,`onBeforeInput`),0<x.length&&(y=new Tn(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:y,listeners:x}),y.data=b)),md(s,e,r,n,i)}yd(s,t)})}function Ed(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Dd(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=$t(e,n),i!=null&&r.unshift(Ed(e,i,a)),i=$t(e,t),i!=null&&r.push(Ed(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Od(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function kd(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=$t(n,a),l!=null&&o.unshift(Ed(n,l,c))):i||(l=$t(n,a),l!=null&&o.push(Ed(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Ad=/\r\n?/g,jd=/\u0000|\uFFFD/g;function Md(e){return(typeof e==`string`?e:``+e).replace(Ad,`
9
+ `).replace(jd,``)}function Nd(e,t){return t=Md(t),Md(e)===t}function Pd(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||Lt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Lt(e,``+r);break;case`className`:Ct(e,`class`,r);break;case`tabIndex`:Ct(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Ct(e,n,r);break;case`style`:Bt(e,r,o);break;case`data`:if(t!==`object`){Ct(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Wt(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof o==`function`&&(n===`formAction`?(t!==`input`&&Pd(e,t,`name`,a.name,a,null),Pd(e,t,`formEncType`,a.formEncType,a,null),Pd(e,t,`formMethod`,a.formMethod,a,null),Pd(e,t,`formTarget`,a.formTarget,a,null)):(Pd(e,t,`encType`,a.encType,a,null),Pd(e,t,`method`,a.method,a,null),Pd(e,t,`target`,a.target,a,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Wt(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=Gt);break;case`onScroll`:r!=null&&bd(`scroll`,e);break;case`onScrollEnd`:r!=null&&bd(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=Wt(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:bd(`beforetoggle`,e),bd(`toggle`,e),xt(e,`popover`,r);break;case`xlinkActuate`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:wt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:wt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:wt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:xt(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=Ht.get(n)||n,xt(e,n,r))}}function Fd(e,t,n,r,a,o){switch(n){case`style`:Bt(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?Lt(e,r):(typeof r==`number`||typeof r==`bigint`)&&Lt(e,``+r);break;case`onScroll`:r!=null&&bd(`scroll`,e);break;case`onScrollEnd`:r!=null&&bd(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=Gt);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!pt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[$e]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):xt(e,n,r)}}}function Id(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:bd(`error`,e),bd(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Pd(e,t,o,s,n,null)}}a&&Pd(e,t,`srcSet`,n.srcSet,n,null),r&&Pd(e,t,`src`,n.src,n,null);return;case`input`:bd(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:Pd(e,t,r,d,n,null)}}Nt(e,o,c,l,u,s,a,!1);return;case`select`:for(a in bd(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Pd(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&Ft(e,!!r,n,!0):Ft(e,!!r,t,!1);return;case`textarea`:for(s in bd(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:Pd(e,t,s,c,n,null)}K(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:Pd(e,t,l,r,n,null)}return;case`dialog`:bd(`beforetoggle`,e),bd(`toggle`,e),bd(`cancel`,e),bd(`close`,e);break;case`iframe`:case`object`:bd(`load`,e);break;case`video`:case`audio`:for(r=0;r<_d.length;r++)bd(_d[r],e);break;case`image`:bd(`error`,e),bd(`load`,e);break;case`details`:bd(`toggle`,e);break;case`embed`:case`source`:case`link`:bd(`error`,e),bd(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Pd(e,t,u,r,n,null)}return;default:if(Vt(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Fd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Pd(e,t,c,r,n,null))}function Ld(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||Pd(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&Pd(e,t,p,m,r,f)}}Mt(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||Pd(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&Pd(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?Ft(e,!!n,n?[]:``,!1):Ft(e,!!n,t,!0)):Ft(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Pd(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&Pd(e,t,s,a,r,o)}It(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:Pd(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Pd(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&Pd(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:Pd(e,t,u,p,r,m)}return;default:if(Vt(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Fd(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Fd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Pd(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||Pd(e,t,f,p,r,m)}function Rd(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function zd(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Rd(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Rd(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var Bd=null,Vd=null;function Hd(e){return e.nodeType===9?e:e.ownerDocument}function Ud(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Wd(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function Gd(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Kd=null;function qd(){var e=window.event;return e&&e.type===`popstate`?e===Kd?!1:(Kd=e,!0):(Kd=null,!1)}var Jd=typeof setTimeout==`function`?setTimeout:void 0,Yd=typeof clearTimeout==`function`?clearTimeout:void 0,Xd=typeof Promise==`function`?Promise:void 0,Zd=typeof queueMicrotask==`function`?queueMicrotask:Xd===void 0?Jd:function(e){return Xd.resolve(null).then(e).catch(Qd)};function Qd(e){setTimeout(function(){throw e})}function $d(e){return e===`head`}function ef(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Pp(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)hf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,hf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[at]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&hf(e.ownerDocument.body);n=i}while(n);Pp(t)}function tf(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function nf(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:nf(n),ot(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function rf(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[at])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=uf(e.nextSibling),e===null)break}return null}function af(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=uf(e.nextSibling),e===null))return null;return e}function of(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=uf(e.nextSibling),e===null))return null;return e}function sf(e){return e.data===`$?`||e.data===`$~`}function cf(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function lf(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function uf(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var df=null;function ff(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return uf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function pf(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function mf(e,t,n){switch(t=Hd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function hf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);ot(e)}var gf=new Map,_f=new Set;function vf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var yf=P.d;P.d={f:bf,r:xf,D:wf,C:Tf,L:Ef,m:Df,X:kf,S:Of,M:Af};function bf(){var e=yf.f(),t=yu();return e||t}function xf(e){var t=ct(e);t!==null&&t.tag===5&&t.type===`form`?vs(t):yf.r(e)}var Sf=typeof document>`u`?null:document;function Cf(e,t,n){var r=Sf;if(r&&typeof t==`string`&&t){var i=jt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),_f.has(i)||(_f.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Id(t,`link`,e),dt(t),r.head.appendChild(t)))}}function wf(e){yf.D(e),Cf(`dns-prefetch`,e,null)}function Tf(e,t){yf.C(e,t),Cf(`preconnect`,e,t)}function Ef(e,t,n){yf.L(e,t,n);var r=Sf;if(r&&e&&t){var i=`link[rel="preload"][as="`+jt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+jt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+jt(n.imageSizes)+`"]`)):i+=`[href="`+jt(e)+`"]`;var a=i;switch(t){case`style`:a=Mf(e);break;case`script`:a=Q(e)}gf.has(a)||(e=f({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),gf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Nf(a))||t===`script`&&r.querySelector(If(a))||(t=r.createElement(`link`),Id(t,`link`,e),dt(t),r.head.appendChild(t)))}}function Df(e,t){yf.m(e,t);var n=Sf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+jt(r)+`"][href="`+jt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Q(e)}if(!gf.has(a)&&(e=f({rel:`modulepreload`,href:e},t),gf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(If(a)))return}r=n.createElement(`link`),Id(r,`link`,e),dt(r),n.head.appendChild(r)}}}function Of(e,t,n){yf.S(e,t,n);var r=Sf;if(r&&e){var i=ut(r).hoistableStyles,a=Mf(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Nf(a)))s.loading=5;else{e=f({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=gf.get(a))&&zf(e,n);var c=o=r.createElement(`link`);dt(c),Id(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Rf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function kf(e,t){yf.X(e,t);var n=Sf;if(n&&e){var r=ut(n).hoistableScripts,i=Q(e),a=r.get(i);a||(a=n.querySelector(If(i)),a||(e=f({src:e,async:!0},t),(t=gf.get(i))&&Bf(e,t),a=n.createElement(`script`),dt(a),Id(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Af(e,t){yf.M(e,t);var n=Sf;if(n&&e){var r=ut(n).hoistableScripts,i=Q(e),a=r.get(i);a||(a=n.querySelector(If(i)),a||(e=f({src:e,async:!0,type:`module`},t),(t=gf.get(i))&&Bf(e,t),a=n.createElement(`script`),dt(a),Id(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function jf(e,t,n,r){var a=(a=U.current)?vf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Mf(n.href),n=ut(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Mf(n.href);var o=ut(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Nf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),gf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},gf.set(e,n),o||Ff(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Q(n),n=ut(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Mf(e){return`href="`+jt(e)+`"`}function Nf(e){return`link[rel="stylesheet"][`+e+`]`}function Pf(e){return f({},e,{"data-precedence":e.precedence,precedence:null})}function Ff(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Id(t,`link`,n),dt(t),e.head.appendChild(t))}function Q(e){return`[src="`+jt(e)+`"]`}function If(e){return`script[async]`+e}function Lf(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+jt(n.href)+`"]`);if(r)return t.instance=r,dt(r),r;var a=f({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),dt(r),Id(r,`style`,a),Rf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Mf(n.href);var o=e.querySelector(Nf(a));if(o)return t.state.loading|=4,t.instance=o,dt(o),o;r=Pf(n),(a=gf.get(a))&&zf(r,a),o=(e.ownerDocument||e).createElement(`link`),dt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Id(o,`link`,r),t.state.loading|=4,Rf(o,n.precedence,e),t.instance=o;case`script`:return o=Q(n.src),(a=e.querySelector(If(o)))?(t.instance=a,dt(a),a):(r=n,(a=gf.get(o))&&(r=f({},n),Bf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),dt(a),Id(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Rf(r,n.precedence,e));return t.instance}function Rf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function zf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Bf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Vf=null;function Hf(e,t,n){if(Vf===null){var r=new Map,i=Vf=new Map;i.set(n,r)}else i=Vf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[at]||a[Qe]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Uf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Wf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Gf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Kf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Mf(r.href),a=t.querySelector(Nf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Yf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,dt(a);return}a=t.ownerDocument||t,r=Pf(r),(i=gf.get(i))&&zf(r,i),a=a.createElement(`link`),dt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Id(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Yf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var qf=0;function Jf(e,t){return e.stylesheets&&e.count===0&&Zf(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&Zf(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&qf===0&&(qf=62500*zd());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Zf(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>qf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Yf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Zf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Xf=null;function Zf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Xf=new Map,t.forEach(Qf,e),Xf=null,Yf.call(e))}function Qf(e,t){if(!(t.state.loading&4)){var n=Xf.get(e);if(n)var r=n.get(null);else{n=new Map,Xf.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=Yf.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var $f={$$typeof:b,Provider:null,Consumer:null,_currentValue:F,_currentValue2:F,_threadCount:0};function ep(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ve(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ve(0),this.hiddenUpdates=Ve(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function tp(e,t,n,r,i,a,o,s,c,l,u,d){return e=new ep(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=ei(3,null,null,t),e.current=a,a.stateNode=e,t=Qi(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},ja(a),e}function np(e){return e?(e=Qr,e):Qr}function rp(e,t,n,r,i,a){i=np(i),r.context===null?r.context=i:r.pendingContext=i,r=Na(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Pa(e,r,t),n!==null&&(mu(n,e,t),Fa(n,e,t))}function ip(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function ap(e,t){ip(e,t),(e=e.alternate)&&ip(e,t)}function op(e){if(e.tag===13||e.tag===31){var t=Yr(e,67108864);t!==null&&mu(t,e,67108864),ap(e,67108864)}}function sp(e){if(e.tag===13||e.tag===31){var t=fu();t=qe(t);var n=Yr(e,t);n!==null&&mu(n,e,t),ap(e,t)}}var cp=!0;function lp(e,t,n,r){var i=N.T;N.T=null;var a=P.p;try{P.p=2,dp(e,t,n,r)}finally{P.p=a,N.T=i}}function up(e,t,n,r){var i=N.T;N.T=null;var a=P.p;try{P.p=8,dp(e,t,n,r)}finally{P.p=a,N.T=i}}function dp(e,t,n,r){if(cp){var i=fp(r);if(i===null)Td(e,t,r,pp,n),wp(e,r);else if(Ep(i,e,t,n,r))r.stopPropagation();else if(wp(e,r),t&4&&-1<Cp.indexOf(e)){for(;i!==null;){var a=ct(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Ie(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-ke(o);s.entanglements[1]|=c,o&=~c}rd(a),!(Nl&6)&&(eu=ve()+500,id(0,!1))}}break;case 31:case 13:s=Yr(a,2),s!==null&&mu(s,a,2),yu(),ap(a,2)}if(a=fp(r),a===null&&Td(e,t,r,pp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Td(e,t,r,null,n)}}function fp(e){return e=qt(e),mp(e)}var pp=null;function mp(e){if(pp=null,e=st(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return pp=e,null}function hp(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(ye()){case be:return 2;case xe:return 8;case Se:case Ce:return 32;case we:return 268435456;default:return 32}default:return 32}}var gp=!1,_p=null,vp=null,yp=null,bp=new Map,xp=new Map,Sp=[],Cp=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function wp(e,t){switch(e){case`focusin`:case`focusout`:_p=null;break;case`dragenter`:case`dragleave`:vp=null;break;case`mouseover`:case`mouseout`:yp=null;break;case`pointerover`:case`pointerout`:bp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:xp.delete(t.pointerId)}}function Tp(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=ct(t),t!==null&&op(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Ep(e,t,n,r,i){switch(t){case`focusin`:return _p=Tp(_p,e,t,n,r,i),!0;case`dragenter`:return vp=Tp(vp,e,t,n,r,i),!0;case`mouseover`:return yp=Tp(yp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return bp.set(a,Tp(bp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,xp.set(a,Tp(xp.get(a)||null,e,t,n,r,i)),!0}return!1}function Dp(e){var t=st(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,Xe(e.priority,function(){sp(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,Xe(e.priority,function(){sp(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Op(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=fp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Kt=r,n.target.dispatchEvent(r),Kt=null}else return t=ct(n),t!==null&&op(t),e.blockedOn=n,!1;t.shift()}return!0}function kp(e,t,n){Op(e)&&n.delete(t)}function Ap(){gp=!1,_p!==null&&Op(_p)&&(_p=null),vp!==null&&Op(vp)&&(vp=null),yp!==null&&Op(yp)&&(yp=null),bp.forEach(kp),xp.forEach(kp)}function jp(e,n){e.blockedOn===n&&(e.blockedOn=null,gp||(gp=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Ap)))}var Mp=null;function Np(e){Mp!==e&&(Mp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Mp===e&&(Mp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(mp(r||n)===null)continue;break}var a=ct(n);a!==null&&(e.splice(t,3),t-=3,gs(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Pp(e){function t(t){return jp(t,e)}_p!==null&&jp(_p,e),vp!==null&&jp(vp,e),yp!==null&&jp(yp,e),bp.forEach(t),xp.forEach(t);for(var n=0;n<Sp.length;n++){var r=Sp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Sp.length&&(n=Sp[0],n.blockedOn===null);)Dp(n),n.blockedOn===null&&Sp.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[$e]||null;if(typeof a==`function`)o||Np(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[$e]||null)s=o.formAction;else if(mp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Np(n)}}}function Fp(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Ip(e){this._internalRoot=e}Lp.prototype.render=Ip.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;rp(n,fu(),e,t,null,null)},Lp.prototype.unmount=Ip.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;rp(e.current,2,null,e,null,null),yu(),t[et]=null}};function Lp(e){this._internalRoot=e}Lp.prototype.unstable_scheduleHydration=function(e){if(e){var t=Ye();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Sp.length&&t!==0&&t<Sp[n].priority;n++);Sp.splice(n,0,e),n===0&&Dp(e)}};var Rp=n.version;if(Rp!==`19.2.7`)throw Error(i(527,Rp,`19.2.7`));P.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:d(e),e=e===null?null:e.stateNode,e};var zp={bundleType:0,version:`19.2.7`,rendererPackageName:`react-dom`,currentDispatcherRef:N,reconcilerVersion:`19.2.7`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Bp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Bp.isDisabled&&Bp.supportsFiber)try{De=Bp.inject(zp),Oe=Bp}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=zs,s=Bs,c=Vs;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=tp(e,1,!1,null,null,n,r,null,o,s,c,Fp),e[et]=t.current,Cd(e),new Ip(t)}})),wt=n(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Ct()})),Tt=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},Et=(e=>e?Tt(e):Tt),G=t(ee(),1),Dt=e=>e;function Ot(e,t=Dt){let n=G.useSyncExternalStore(e.subscribe,G.useCallback(()=>t(e.getState()),[e,t]),G.useCallback(()=>t(e.getInitialState()),[e,t]));return G.useDebugValue(n),n}var kt=e=>{let t=Et(e),n=e=>Ot(t,e);return Object.assign(n,t),n},At=(e=>e?kt(e):kt),jt=wt(),Mt=e({ApiError:()=>It,REASONING_LEVELS:()=>hr,UNAUTHORIZED_EVENT:()=>Pt,abortSession:()=>Jt,addCustomProvider:()=>Fn,answerAskQuestion:()=>Xn,archiveSession:()=>Zt,cancelExec:()=>Un,checkExtensionUpdates:()=>pr,checkSdkUpdate:()=>Rt,checkTunnel:()=>Ur,clearInboxUI:()=>sr,clearProcesses:()=>Zr,clearStoredToken:()=>Bt,clearToolProjectOverride:()=>Lr,cloneRepo:()=>Cn,compactSession:()=>Wn,completeFiles:()=>dr,createProjectAPI:()=>nn,createSession:()=>Ut,deleteArchivedSession:()=>en,deleteMcpServer:()=>Ar,deleteProjectAPI:()=>rn,detachWorkerUI:()=>cr,disableSupervisorUI:()=>ir,doctorTunnel:()=>Wr,enableSupervisorUI:()=>rr,execCommandStream:()=>Hn,fetchAuthStatus:()=>Vt,fetchExtensions:()=>fr,fetchHomeDir:()=>cn,fetchInbox:()=>or,fetchOrchestrationConfig:()=>tr,fetchProjects:()=>tn,fetchProviders:()=>wn,fetchSdkPackages:()=>yr,fetchSessionExtensions:()=>Cr,filesBatchDelete:()=>vn,filesBatchDownload:()=>gn,filesBatchMove:()=>yn,filesDelete:()=>_n,filesDownload:()=>hn,filesMkdir:()=>mn,filesMove:()=>bn,filesRead:()=>dn,filesRename:()=>pn,filesSearch:()=>xn,filesTree:()=>un,filesUpload:()=>Sn,filesWrite:()=>fn,forkSession:()=>Jn,getAuthSummary:()=>Tn,getCompactions:()=>Gn,getEnabledModels:()=>Ln,getMcpSettings:()=>Er,getModelsJson:()=>Mn,getPendingPlanReviews:()=>Zn,getPlanModeStatus:()=>$n,getProcessOutput:()=>Qr,getProjectSystemPrompt:()=>on,getSessionContext:()=>Kt,getSessionMessages:()=>Gt,getSessionModel:()=>Bn,getSessionOrchestrationRole:()=>nr,getSessionTree:()=>Kn,getSettings:()=>On,getSkillDetail:()=>Vr,getStoredToken:()=>zt,getTunnelStatus:()=>Gr,getTurnDiff:()=>Yn,getUiSettings:()=>An,getVersions:()=>Lt,getVisionConfig:()=>gr,grantStdioMcpTrust:()=>Mr,installSdkPackage:()=>br,invokeExtensionCommand:()=>wr,killProcess:()=>Xr,killWorkerUI:()=>lr,listArchivedSessions:()=>$t,listArtifacts:()=>Jr,listDir:()=>ln,listMcpServers:()=>Or,listProcesses:()=>Yr,listSessions:()=>Wt,listSkills:()=>Rr,listToolOverrides:()=>Ir,listTools:()=>Pr,listWorkers:()=>ar,login:()=>Ht,navigateSession:()=>qn,onUnauthorized:()=>Ft,probeMcpServer:()=>jr,probeProvider:()=>Pn,putModelsJson:()=>Nn,reloadAgent:()=>vr,removeApiKey:()=>Dn,removeCustomProvider:()=>In,removeSdkPackage:()=>xr,renameSession:()=>Xt,reorderProjectsAPI:()=>an,respondExtensionUI:()=>Tr,resumeWorkerUI:()=>ur,revokeStdioMcpTrust:()=>Nr,sendProcessStdin:()=>$r,sendPrompt:()=>qt,setAllSkillsEnabled:()=>Br,setApiKey:()=>En,setEnabledModels:()=>Rn,setMcpEnabled:()=>Dr,setPlanMode:()=>er,setProjectSystemPrompt:()=>sn,setSessionModel:()=>zn,setSessionThinking:()=>Vn,setSkillEnabled:()=>zr,setToolEnabled:()=>Fr,setVisionConfig:()=>_r,startTunnel:()=>Kr,steerSession:()=>Yt,stopTunnel:()=>qr,submitPlanReviewDecision:()=>Qn,toggleSdkPackage:()=>Sr,unarchiveSession:()=>Qt,updateExtension:()=>mr,updateSettings:()=>kn,updateSkill:()=>Hr,updateUiSettings:()=>jn,upsertMcpServer:()=>kr}),Nt=``,Pt=`pi-kot:unauthorized`;function Ft(e){let t=()=>e();return window.addEventListener(Pt,t),()=>window.removeEventListener(Pt,t)}var It=class extends Error{status;constructor(e,t){super(t),this.status=e,this.name=`ApiError`}};async function K(e,t,n){let r={};n!==void 0&&(r[`Content-Type`]=`application/json`);let i=zt();i!==void 0&&(r.Authorization=`Bearer ${i}`);let a=await fetch(`${Nt}${t}`,{method:e,headers:r,body:n===void 0?void 0:JSON.stringify(n)});if(a.status!==204){if(a.status===401&&(Bt(),window.dispatchEvent(new Event(Pt))),!a.ok){let e=await a.json().catch(()=>({}));throw new It(a.status,e.message??e.error??a.statusText)}return a.json()}}async function Lt(){return K(`GET`,`/api/v1/version`)}async function Rt(){return K(`GET`,`/api/v1/version/check-update`)}function zt(){try{return localStorage.getItem(`pi-kot/auth-token`)??void 0}catch{return}}function Bt(){try{localStorage.removeItem(`pi-kot/auth-token`)}catch{}}async function Vt(){return K(`GET`,`/api/v1/auth/status`)}async function Ht(e){let t=await fetch(`${Nt}/api/v1/auth/login`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({password:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw new It(t.status,e.error??`login_failed`)}let n=await t.json();try{localStorage.setItem(`pi-kot/auth-token`,n.token)}catch{}return n}async function Ut(e={}){return K(`POST`,`/api/v1/sessions`,e)}async function Wt(e){return K(`GET`,`/api/v1/sessions${e===void 0?``:`?projectId=${encodeURIComponent(e)}`}`)}async function Gt(e){return K(`GET`,`/api/v1/sessions/${encodeURIComponent(e)}/messages`)}async function Kt(e){return K(`GET`,`/api/v1/sessions/${encodeURIComponent(e)}/context`)}async function qt(e,t,n,r){return K(`POST`,`/api/v1/sessions/${encodeURIComponent(e)}/prompt`,{text:t,streamingBehavior:n,images:r})}async function Jt(e){return K(`POST`,`/api/v1/sessions/${encodeURIComponent(e)}/abort`)}async function Yt(e,t,n=`steer`,r){return K(`POST`,`/api/v1/sessions/${encodeURIComponent(e)}/steer`,{text:t,mode:n,images:r})}async function Xt(e,t){return K(`PATCH`,`/api/v1/sessions/${encodeURIComponent(e)}/name`,{name:t})}async function Zt(e,t){return K(`POST`,`/api/v1/sessions/${encodeURIComponent(e)}/archive`,t===void 0?void 0:{projectId:t})}async function Qt(e,t){return K(`POST`,`/api/v1/sessions/${encodeURIComponent(e)}/unarchive`,{projectId:t})}async function $t(e){return K(`GET`,`/api/v1/sessions?projectId=${encodeURIComponent(e)}&archived=true`)}async function en(e,t){return K(`DELETE`,`/api/v1/sessions/${encodeURIComponent(e)}/archived?projectId=${encodeURIComponent(t)}`)}async function tn(){return K(`GET`,`/api/v1/projects`)}async function nn(e,t){return K(`POST`,`/api/v1/projects`,{name:e,path:t})}async function rn(e){return K(`DELETE`,`/api/v1/projects/${encodeURIComponent(e)}`)}async function an(e){return K(`PUT`,`/api/v1/projects/order`,{ids:e})}async function on(e){return K(`GET`,`/api/v1/projects/${encodeURIComponent(e)}/system-prompt`)}async function sn(e,t){return K(`PUT`,`/api/v1/projects/${encodeURIComponent(e)}/system-prompt`,{addendum:t})}async function cn(){return(await K(`GET`,`/api/v1/filesystem/home`)).home}async function ln(e){return(await K(`GET`,`/api/v1/filesystem/list?path=${encodeURIComponent(e)}`)).entries}async function un(e,t){let n=new URLSearchParams({projectId:e});return t!==void 0&&n.set(`maxDepth`,String(t)),K(`GET`,`/api/v1/files/tree?${n.toString()}`)}async function dn(e,t){return K(`GET`,`/api/v1/files/read?${new URLSearchParams({projectId:e,path:t}).toString()}`)}async function fn(e,t,n){return K(`PUT`,`/api/v1/files/write`,{projectId:e,path:t,content:n})}async function pn(e,t,n){return K(`POST`,`/api/v1/files/rename`,{projectId:e,path:t,name:n})}async function mn(e,t,n){return K(`POST`,`/api/v1/files/mkdir`,{projectId:e,parentPath:t,name:n})}async function hn(e,t){let n=zt(),r=new URLSearchParams({projectId:e,path:t}),i=await fetch(`${Nt}/api/v1/files/download?${r.toString()}`,{headers:n===void 0?{}:{Authorization:`Bearer ${n}`}});if(i.status===401&&(Bt(),window.dispatchEvent(new Event(Pt))),!i.ok){let e=await i.json().catch(()=>({}));throw new It(i.status,e.message??e.error??i.statusText)}let a=await i.blob(),o=i.headers.get(`Content-Disposition`)??``,s=o.match(/filename\*?=UTF-8''([^;]+)/)||o.match(/filename="?([^";]+)"?/),c=s?decodeURIComponent(s[1]):t.split(`/`).pop()??`download`,l=URL.createObjectURL(a),u=document.createElement(`a`);u.href=l,u.download=c,u.style.display=`none`,document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(l)}async function gn(e,t){let n=zt(),r=await fetch(`${Nt}/api/v1/files/batch-download`,{method:`POST`,headers:{"Content-Type":`application/json`,...n===void 0?{}:{Authorization:`Bearer ${n}`}},body:JSON.stringify({projectId:e,paths:t})});if(r.status===401&&(Bt(),window.dispatchEvent(new Event(Pt))),!r.ok){let e=await r.json().catch(()=>({}));throw new It(r.status,e.message??e.error??r.statusText)}let i=await r.blob(),a=r.headers.get(`Content-Disposition`)??``,o=a.match(/filename\*?=UTF-8''([^;]+)/)||a.match(/filename="?([^";]+)"?/),s=o?decodeURIComponent(o[1]):`selected-files.zip`,c=URL.createObjectURL(i),l=document.createElement(`a`);l.href=c,l.download=s,l.style.display=`none`,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(c)}async function _n(e,t,n){let r=new URLSearchParams({projectId:e,path:t});return n?.recursive===!0&&r.set(`recursive`,`true`),K(`DELETE`,`/api/v1/files/delete?${r.toString()}`)}async function vn(e,t,n){return K(`POST`,`/api/v1/files/batch-delete`,{projectId:e,paths:t,recursive:n?.recursive??!0})}async function yn(e,t){return K(`POST`,`/api/v1/files/batch-move`,{projectId:e,moves:t})}async function bn(e,t,n){let r={},i=zt();i!==void 0&&(r.Authorization=`Bearer ${i}`);let a=await fetch(`${Nt}/api/v1/files/move`,{method:`POST`,headers:{...r,"Content-Type":`application/json`},body:JSON.stringify({projectId:e,src:t,dest:n})});if(a.status===401&&(Bt(),window.dispatchEvent(new Event(Pt))),!a.ok){let e=await a.json().catch(()=>({}));throw new It(a.status,e.message??e.error??a.statusText)}return a.json()}async function xn(e,t,n){let r=new URLSearchParams({projectId:e,q:t});return n?.limit!==void 0&&r.set(`limit`,String(n.limit)),n?.regex&&r.set(`regex`,`1`),n?.caseSensitive&&r.set(`caseSensitive`,`1`),K(`GET`,`/api/v1/files/search?${r.toString()}`)}async function Sn(e,t,n,r){let i=new FormData;i.append(`projectId`,e),i.append(`parentPath`,t),r?.overwrite===!0&&i.append(`overwrite`,`1`);for(let[e,t]of n.entries()){let n=t,r=n.uploadRelativePath??n.webkitRelativePath;r&&r.length>0&&i.append(`path:${e}`,r),i.append(`file:${e}`,t,r&&r.length>0?r:t.name)}let a={},o=zt();o!==void 0&&(a.Authorization=`Bearer ${o}`);let s=await fetch(`${Nt}/api/v1/files/upload`,{method:`POST`,headers:a,body:i});if(s.status===401&&(Bt(),window.dispatchEvent(new Event(Pt))),!s.ok){let e=await s.json().catch(()=>({}));throw new It(s.status,e.message??e.error??s.statusText)}return s.json()}function Cn(e,t,n){let r=new AbortController,i=zt(),a={"Content-Type":`application/json`};return i!==void 0&&(a.Authorization=`Bearer ${i}`),(async()=>{try{let n=await fetch(`${Nt}/api/v1/projects/clone`,{method:`POST`,headers:a,body:JSON.stringify(e),signal:r.signal});if(!n.ok){let e=await n.json().catch(()=>({}));throw new It(n.status,e.message??e.error??`Clone failed`)}let i=n.body?.getReader();if(!i)throw new It(0,`No response body`);let o=new TextDecoder,s=``;for(;;){let{done:e,value:n}=await i.read();if(e)break;s+=o.decode(n,{stream:!0});let r=s.split(`
10
+ `);s=r.pop()??``;for(let e of r)if(e.startsWith(`data: `))try{t(JSON.parse(e.slice(6)))}catch{}}}catch(e){if(r.signal.aborted)return;n?.(e instanceof Error?e:Error(String(e)))}})(),()=>r.abort()}async function wn(e){return K(`GET`,`/api/v1/config/providers${e?`?scoped=true`:``}`)}async function Tn(){return K(`GET`,`/api/v1/config/auth`)}async function En(e,t){return K(`PUT`,`/api/v1/config/auth/${encodeURIComponent(e)}`,{apiKey:t})}async function Dn(e){await K(`DELETE`,`/api/v1/config/auth/${encodeURIComponent(e)}`)}async function On(){return K(`GET`,`/api/v1/config/settings`)}async function kn(e){return K(`PUT`,`/api/v1/config/settings`,e)}async function An(){return K(`GET`,`/api/v1/config/ui-settings`)}async function jn(e){return K(`PUT`,`/api/v1/config/ui-settings`,e)}async function Mn(){return K(`GET`,`/api/v1/config/models`)}async function Nn(e){return K(`PUT`,`/api/v1/config/models`,e)}async function Pn(e){return K(`POST`,`/api/v1/config/providers/probe`,e)}async function Fn(e,t){return K(`POST`,`/api/v1/config/providers`,{providerName:e,config:t})}async function In(e){return K(`DELETE`,`/api/v1/config/providers/${encodeURIComponent(e)}`)}async function Ln(){return K(`GET`,`/api/v1/config/enabled-models`)}async function Rn(e){return K(`PUT`,`/api/v1/config/enabled-models`,{enabledModels:e})}async function zn(e,t,n,r){return K(`POST`,`/api/v1/sessions/${encodeURIComponent(e)}/model`,{provider:t,modelId:n,...r===void 0?{}:{thinkingLevel:r}})}async function Bn(e){return K(`GET`,`/api/v1/sessions/${encodeURIComponent(e)}/model`)}async function Vn(e,t){return K(`POST`,`/api/v1/sessions/${encodeURIComponent(e)}/thinking`,{thinkingLevel:t})}function Hn(e,t,n){let r={"Content-Type":`application/json`},i=zt();i&&(r.Authorization=`Bearer ${i}`);let a=new AbortController;return{promise:fetch(`/api/v1/sessions/${encodeURIComponent(e)}/exec-stream`,{method:`POST`,headers:r,signal:a.signal,body:JSON.stringify({command:t,excludeFromContext:n?.excludeFromContext})}).then(async e=>{if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.message||`exec-stream failed: ${e.status}`)}return e.json()}),abort:()=>a.abort()}}async function Un(e){let t={"Content-Type":`application/json`},n=zt();n&&(t.Authorization=`Bearer ${n}`);let r=await fetch(`/api/v1/sessions/${encodeURIComponent(e)}/exec-cancel`,{method:`POST`,headers:t,body:`{}`});r.ok||console.warn(`cancelExec failed:`,r.status)}async function Wn(e,t){return K(`POST`,`/api/v1/sessions/${encodeURIComponent(e)}/compact`,t===void 0?{}:{customInstructions:t})}async function Gn(e){return K(`GET`,`/api/v1/sessions/${encodeURIComponent(e)}/compactions`)}async function Kn(e){return K(`GET`,`/api/v1/sessions/${encodeURIComponent(e)}/tree`)}async function qn(e,t,n){return K(`POST`,`/api/v1/sessions/${encodeURIComponent(e)}/navigate`,{entryId:t,...n})}async function Jn(e,t){return K(`POST`,`/api/v1/sessions/${encodeURIComponent(e)}/fork`,{entryId:t})}async function Yn(e,t,n){let r=new URLSearchParams;t!==void 0&&r.set(`startIndex`,String(t)),n!==void 0&&r.set(`endIndex`,String(n));let i=r.toString();return K(`GET`,`/api/v1/sessions/${encodeURIComponent(e)}/turn-diff${i.length>0?`?${i}`:``}`)}async function Xn(e,t,n,r=!1){await K(`POST`,`/api/v1/sessions/${encodeURIComponent(e)}/ask-user-question/answer`,{requestId:t,answers:n,cancelled:r})}async function Zn(e){return(await K(`GET`,`/api/v1/sessions/${encodeURIComponent(e)}/plan-review/pending`)).pending}async function Qn(e,t,n){await K(`POST`,`/api/v1/sessions/${encodeURIComponent(e)}/plan-review/${encodeURIComponent(t)}/decision`,n)}async function $n(e){return K(`GET`,`/api/v1/sessions/${encodeURIComponent(e)}/plan-mode`)}async function er(e,t){return K(`POST`,`/api/v1/sessions/${encodeURIComponent(e)}/plan-mode`,typeof t==`boolean`?{active:t}:{})}async function tr(){return K(`GET`,`/api/v1/orchestration/config`)}async function nr(e){return K(`GET`,`/api/v1/orchestration/sessions/${encodeURIComponent(e)}`)}async function rr(e){return K(`POST`,`/api/v1/orchestration/sessions/${encodeURIComponent(e)}/enable`)}async function ir(e){return K(`POST`,`/api/v1/orchestration/sessions/${encodeURIComponent(e)}/disable`)}async function ar(e){return K(`GET`,`/api/v1/orchestration/sessions/${encodeURIComponent(e)}/workers`)}async function or(e){return K(`GET`,`/api/v1/orchestration/sessions/${encodeURIComponent(e)}/inbox`)}async function sr(e){return K(`POST`,`/api/v1/orchestration/sessions/${encodeURIComponent(e)}/inbox/clear`)}async function cr(e,t){return K(`POST`,`/api/v1/orchestration/sessions/${encodeURIComponent(e)}/workers/${encodeURIComponent(t)}/detach`)}async function lr(e,t){return K(`POST`,`/api/v1/orchestration/sessions/${encodeURIComponent(e)}/workers/${encodeURIComponent(t)}/kill`)}async function ur(e,t){return K(`POST`,`/api/v1/orchestration/sessions/${encodeURIComponent(e)}/workers/${encodeURIComponent(t)}/resume`)}async function dr(e,t,n){let r=new URLSearchParams({projectId:e,query:t});return n?.limit!==void 0&&r.set(`limit`,String(n.limit)),K(`GET`,`/api/v1/files/complete?${r.toString()}`)}async function fr(){return K(`GET`,`/api/v1/extensions`)}async function pr(){return K(`GET`,`/api/v1/extensions/updates`)}async function mr(e){return K(`POST`,`/api/v1/extensions/update`,{package:e})}var hr=[`off`,`low`,`medium`,`high`,`xhigh`];async function gr(){return K(`GET`,`/api/v1/extensions/vision-config`)}async function _r(e){return K(`PUT`,`/api/v1/extensions/vision-config`,e)}async function vr(){return K(`POST`,`/api/v1/control/reload`)}async function yr(e){return K(`GET`,`/api/v1/extensions/sdk-packages${e===void 0?``:`?cwd=${encodeURIComponent(e)}`}`)}async function br(e,t,n){return K(`POST`,`/api/v1/extensions/sdk-packages/install`,{source:e,local:t,cwd:n})}async function xr(e,t,n){return K(`POST`,`/api/v1/extensions/sdk-packages/remove`,{source:e,local:t,cwd:n})}async function Sr(e,t,n,r){return K(`POST`,`/api/v1/extensions/sdk-packages/toggle`,{source:e,scope:t,disabled:n,cwd:r})}async function Cr(e){return K(`GET`,`/api/v1/sessions/${encodeURIComponent(e)}/extensions`)}async function wr(e,t,n){return K(`POST`,`/api/v1/sessions/${encodeURIComponent(e)}/command`,{command:t,args:n})}async function Tr(e,t,n){return K(`POST`,`/api/v1/sessions/${encodeURIComponent(e)}/extension-ui/respond`,{requestId:t,value:n})}async function Er(){return K(`GET`,`/api/v1/mcp/settings`)}async function Dr(e){return K(`PUT`,`/api/v1/mcp/settings`,{enabled:e})}async function Or(e){return K(`GET`,`/api/v1/mcp/servers${e===void 0?``:`?projectId=${encodeURIComponent(e)}`}`)}async function kr(e,t){return K(`PUT`,`/api/v1/mcp/servers/${encodeURIComponent(e)}`,t)}async function Ar(e){return K(`DELETE`,`/api/v1/mcp/servers/${encodeURIComponent(e)}`)}async function jr(e,t){let n=t===void 0?``:`?projectId=${encodeURIComponent(t)}`;return K(`POST`,`/api/v1/mcp/servers/${encodeURIComponent(e)}/probe${n}`)}async function Mr(e){return K(`POST`,`/api/v1/mcp/trust/${encodeURIComponent(e)}`)}async function Nr(e){return K(`DELETE`,`/api/v1/mcp/trust/${encodeURIComponent(e)}`)}async function Pr(e){return K(`GET`,`/api/v1/config/tools${e===void 0?``:`?projectId=${encodeURIComponent(e)}`}`)}async function Fr(e,t,n,r){let i=r?.projectId===void 0?``:`?projectId=${encodeURIComponent(r.projectId)}`;return K(`PUT`,`/api/v1/config/tools/${encodeURIComponent(e)}/${encodeURIComponent(t)}/enabled${i}`,{enabled:n,scope:r?.scope})}async function Ir(){return K(`GET`,`/api/v1/config/tools/overrides`)}async function Lr(e,t,n){return K(`DELETE`,`/api/v1/config/tools/${encodeURIComponent(e)}/${encodeURIComponent(t)}/enabled?projectId=${encodeURIComponent(n)}`)}async function Rr(e){return K(`GET`,`/api/v1/config/skills${e===void 0?``:`?projectId=${encodeURIComponent(e)}`}`)}async function zr(e,t,n){let r=n?.projectId===void 0?``:`?projectId=${encodeURIComponent(n.projectId)}`;return K(`PUT`,`/api/v1/config/skills/${encodeURIComponent(e)}/enabled${r}`,{enabled:t,scope:n?.scope})}async function Br(e){return K(`PUT`,`/api/v1/config/skills/all/enabled`,{enabled:e})}async function Vr(e){return K(`GET`,`/api/v1/config/skills/${encodeURIComponent(e)}`)}async function Hr(e,t){return K(`PUT`,`/api/v1/config/skills/${encodeURIComponent(e)}`,t)}async function Ur(){return K(`GET`,`/api/v1/tunnel/check`)}async function Wr(){return K(`GET`,`/api/v1/tunnel/doctor`)}async function Gr(){return K(`GET`,`/api/v1/tunnel/status`)}async function Kr(e){return K(`POST`,`/api/v1/tunnel/start`,e??{})}async function qr(){return K(`POST`,`/api/v1/tunnel/stop`)}async function Jr(e){return K(`GET`,`/api/v1/artifacts${e?`?cwd=${encodeURIComponent(e)}`:``}`)}async function Yr(e){return K(`GET`,`/api/v1/sessions/${encodeURIComponent(e)}/processes`)}async function Xr(e,t){return K(`POST`,`/api/v1/sessions/${encodeURIComponent(e)}/processes/${encodeURIComponent(t)}/kill`)}async function Zr(e){return K(`DELETE`,`/api/v1/sessions/${encodeURIComponent(e)}/processes/finished`)}async function Qr(e,t,n=200){return K(`GET`,`/api/v1/sessions/${encodeURIComponent(e)}/processes/${encodeURIComponent(t)}/output?lines=${n}`)}async function $r(e,t,n,r){return K(`POST`,`/api/v1/sessions/${encodeURIComponent(e)}/processes/${encodeURIComponent(t)}/stdin`,{input:n,end:r})}var ei=3e4,ti=new Set([401,404,409]);function ni(e){return Math.min(2**e*1e3,ei)}function ri(e,t){return new Promise((n,r)=>{if(t?.aborted===!0){r(new DOMException(`Aborted`,`AbortError`));return}let i=setTimeout(n,e);t?.addEventListener(`abort`,()=>{clearTimeout(i),r(new DOMException(`Aborted`,`AbortError`))},{once:!0})})}function ii(e,t){let{signal:n,onEvent:r,onClose:i,onReconnect:a,maxReconnects:o=0}=t,s=!1,c=0,l=new AbortController,u=()=>{c=0,l.abort(),l=new AbortController},d=()=>{document.visibilityState===`visible`&&u()};document.addEventListener(`visibilitychange`,d),window.addEventListener(`online`,u);async function f(){for(;!s&&!(n?.aborted??!1);)try{let t=`/api/v1/sessions/${encodeURIComponent(e)}/stream`,i={Accept:`text/event-stream`},a=zt();a!==void 0&&(i.Authorization=`Bearer ${a}`);let o=await fetch(t,{headers:i,signal:l.signal});if(!o.ok)throw ti.has(o.status)?(o.status===401&&Bt(),Error(`SSE terminated: ${o.status}`)):Error(`SSE non-ok: ${o.status}`);c=0;let u=o.body.pipeThrough(new TextDecoderStream).getReader(),d=``;for(;!s&&!(n?.aborted??!1);){let{value:e,done:t}=await u.read();if(t)break;d+=e;let n;for(;(n=d.indexOf(`
11
+
12
+ `))!==-1;){let e=d.slice(0,n);d=d.slice(n+2);for(let t of e.split(`
13
+ `))if(t.startsWith(`data: `))try{let e=JSON.parse(t.slice(6));await r(e)}catch{}}}}catch(e){if(s||n?.aborted)break;let t=e instanceof Error?e.message:String(e);if(t.startsWith(`SSE terminated:`)||(c++,o>0&&c>o))break;let r=ni(c);a?.({attempt:c,delayMs:r,reason:t});try{await ri(r,n)}catch{break}}i?.()}return f().catch(()=>{}),{close:()=>{s=!0,l.abort(),document.removeEventListener(`visibilitychange`,d),window.removeEventListener(`online`,u)}}}var ai=At((e,t)=>({pendingBySession:{},setPending:t=>e(e=>({pendingBySession:{...e.pendingBySession,[t.sessionId]:t}})),clearPending:(n,r)=>{let i=t().pendingBySession[n];i!==void 0&&(r!==void 0&&i.requestId!==r||e(e=>({pendingBySession:{...e.pendingBySession,[n]:void 0}})))}})),oi=`modulepreload`,si=function(e){return`/`+e},ci={},li=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,new URL(`../../../src/node/plugins/importAnalysisBuild.ts`,import.meta.url)).href}r=o(t.map(t=>{if(t=si(t,n),t=s(t),t in ci)return;ci[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:oi,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},ui=e({usePlanReviewStore:()=>di}),di=At((e,t)=>({isOpen:!1,activeReview:null,viewMode:`preview`,editedContent:``,submitting:!1,error:null,planModeActive:!1,fetchPlanModeStatus:async n=>{let r=n??Y.getState().activeSessionId;if(r)try{let[n,i]=await Promise.all([$n(r).catch(()=>null),Zn(r).catch(()=>null)]);if(n&&typeof n.planModeActive==`boolean`&&e({planModeActive:n.planModeActive}),Array.isArray(i))if(i.length>0){let t=i[0];e({activeReview:{requestId:t.requestId,sessionId:r,planFilePath:t.planFilePath,planContent:t.planContent},editedContent:t.planContent,isOpen:!0,planModeActive:!0})}else{let n=t().activeReview;n&&(n.sessionId===r?n.requestId&&e({activeReview:{...n,requestId:void 0}}):e({activeReview:null,isOpen:!1,editedContent:``}))}}catch{}},openReview:t=>{e({activeReview:t,editedContent:t.planContent,isOpen:!0,error:null,viewMode:`preview`})},openFileReview:async(n=`PLAN.md`,r)=>{let i=r??Y.getState().activeSessionId,a=Y.getState().activeProjectId??`default`,o=t().activeReview,s,c;if(i)try{let[t,r]=await Promise.all([Zn(i).catch(()=>[]),$n(i).catch(()=>null)]);if(r&&typeof r.planModeActive==`boolean`&&e({planModeActive:r.planModeActive}),Array.isArray(t)&&t.length>0){let e=t.find(e=>{if(e.planFilePath===n)return!0;let t=e.planFilePath.replace(/\\/g,`/`),r=n.replace(/\\/g,`/`);return t.endsWith(`/${r}`)||r.endsWith(`/${t}`)||t===r})??(t.length===1?t[0]:void 0);e&&(s=e.requestId,c=e.planContent)}}catch{}try{let r=c;r||=(await dn(a,n)).content;let l=o&&o.planContent.trim()!==t().editedContent.trim()?t().editedContent:r;e({activeReview:{requestId:s,sessionId:i??``,planFilePath:n,planContent:r},editedContent:l,isOpen:!0,viewMode:`preview`,error:null})}catch(t){e({isOpen:!0,error:`Could not load ${n}: ${t instanceof Error?t.message:String(t)}`})}},closeReview:()=>{e({isOpen:!1,error:null})},setViewMode:t=>e({viewMode:t}),setEditedContent:t=>e({editedContent:t}),setPlanModeActive:t=>e({planModeActive:t}),resolveReview:n=>{let{activeReview:r}=t();r&&r.requestId===n&&e({activeReview:null,isOpen:!1,error:null,editedContent:``})},savePlanContent:async()=>{let{activeReview:n,editedContent:r}=t();n&&(await fn(Y.getState().activeProjectId??`default`,n.planFilePath,r),e({activeReview:{...n,planContent:r}}))},exitPlanMode:async()=>{let t=Y.getState().activeSessionId;if(t){let{setPlanMode:e}=await li(async()=>{let{setPlanMode:e}=await Promise.resolve().then(()=>Mt);return{setPlanMode:e}},void 0);await e(t,!1).catch(()=>{})}e({planModeActive:!1})},submitDecision:async({approved:n,feedback:r})=>{let{activeReview:i,editedContent:a,submitting:o}=t();if(!(!i||o)){e({submitting:!0,error:null});try{let o=a.trim()!==i.planContent.trim(),s=i.sessionId||Y.getState().activeSessionId,c=Y.getState().activeProjectId??`default`;if(o&&await fn(c,i.planFilePath,a).catch(()=>{}),i.requestId){if(await Qn(i.sessionId,i.requestId,{approved:n,feedback:r,updatedContent:o?a:void 0}),n&&s){let{setPlanMode:t}=await li(async()=>{let{setPlanMode:e}=await Promise.resolve().then(()=>Mt);return{setPlanMode:e}},void 0);await t(s,!1).catch(()=>{}),e({planModeActive:!1})}}else if(s)if(n){let n=r?`\n\nImplementation Notes:\n${r}`:``;if(await Y.getState().sendPrompt(`Plan approved!${n}\nPlease proceed with executing the implementation steps in ${i.planFilePath}.`),t().planModeActive){let{setPlanMode:t}=await li(async()=>{let{setPlanMode:e}=await Promise.resolve().then(()=>Mt);return{setPlanMode:e}},void 0);await t(s,!1).catch(()=>{}),e({planModeActive:!1})}}else await Y.getState().sendPrompt(`Please revise ${i.planFilePath} based on the following feedback:\n${r||`Please address the review comments.`}`);e({submitting:!1,isOpen:!1,activeReview:null,editedContent:``})}catch(t){throw e({submitting:!1,error:t instanceof Error?t.message:`Failed to submit plan decision`}),t}}}})),fi=0,pi=At(e=>({activeInteraction:void 0,commandRunning:!1,activeCommand:void 0,notifications:[],pushEvent:t=>{switch(t.type.replace(/^extension_ui_/,``)){case`select`:case`confirm`:case`input`:e({activeInteraction:t,commandRunning:!0});break;case`status`:{let e=t;if(e.key===`plan-mode`){let t=!!(e.status&&(e.status.includes(`plan`)||e.status.includes(`📋`)||e.status.includes(`⏸`)));li(async()=>{let{usePlanReviewStore:e}=await Promise.resolve().then(()=>ui);return{usePlanReviewStore:e}},void 0).then(({usePlanReviewStore:e})=>{e.getState().setPlanModeActive(t)})}break}case`notify`:{let n=t,r=`ext-notif-${++fi}`,i={id:r,message:n.message,type:n.notificationType,createdAt:Date.now()};e(e=>({notifications:[...e.notifications,i]})),n.message.includes(`planning mode enabled`)?li(async()=>{let{usePlanReviewStore:e}=await Promise.resolve().then(()=>ui);return{usePlanReviewStore:e}},void 0).then(({usePlanReviewStore:e})=>{e.getState().setPlanModeActive(!0)}):(n.message.includes(`returned to idle`)||n.message.includes(`plan mode has ended`)||n.message.includes(`plan mode off`))&&li(async()=>{let{usePlanReviewStore:e}=await Promise.resolve().then(()=>ui);return{usePlanReviewStore:e}},void 0).then(({usePlanReviewStore:e})=>{e.getState().setPlanModeActive(!1)}),setTimeout(()=>{e(e=>({notifications:e.notifications.filter(e=>e.id!==r)}))},8e3);break}case`done`:e({activeInteraction:void 0,commandRunning:!1,activeCommand:void 0});break}},clearInteraction:()=>{e({activeInteraction:void 0})},cancelCommand:()=>{e({activeInteraction:void 0,commandRunning:!1,activeCommand:void 0})},dismissNotification:t=>{e(e=>({notifications:e.notifications.filter(e=>e.id!==t)}))}})),mi=`pi-kot/viewer-width`;function hi(){try{let e=localStorage.getItem(mi);if(e!==null){let t=Number(e);if(!isNaN(t)&&t>=280&&t<=900)return t}}catch{}return 480}var gi=`pi-kot/artifact-viewer-width`;function _i(){try{let e=localStorage.getItem(gi);if(e!==null){let t=Number(e);if(!isNaN(t)&&t>=280&&t<=900)return t}}catch{}return 480}var q=At((e,t)=>({sidebarCollapsed:!1,showTreePanel:!1,showSettings:!1,showOrch:!1,showMCP:!1,showTerminal:!1,showAddProjectDialog:!1,explorerTab:void 0,viewerTabs:[],viewerActivePath:void 0,artifactItems:[],artifactActiveId:void 0,artifactWidth:typeof window<`u`&&window.innerWidth<=600?Math.max(280,Math.min(420,window.innerWidth-40)):420,showArtifacts:!1,artifactViewerTabs:[],artifactViewerActiveId:void 0,artifactViewerWidth:typeof window<`u`&&window.innerWidth<=600?Math.max(280,Math.min(_i(),window.innerWidth-40)):_i(),viewerWidth:typeof window<`u`&&window.innerWidth<=600?Math.max(280,Math.min(hi(),window.innerWidth-40)):hi(),isMobile:typeof window<`u`?window.innerWidth<=600:!1,fileRev:{},fileChangeTick:0,fileChanged:t=>e(e=>({fileRev:{...e.fileRev,[t]:(e.fileRev[t]??0)+1},fileChangeTick:e.fileChangeTick+1})),bumpFileTick:()=>e(e=>({fileChangeTick:e.fileChangeTick+1})),toggleSidebar:()=>{let{sidebarCollapsed:n,setExplorerTab:r}=t();n&&r(void 0),e({sidebarCollapsed:!n})},setSidebarCollapsed:t=>e({sidebarCollapsed:t}),closeSidebarOnMobile:()=>{window.innerWidth<=600&&e({sidebarCollapsed:!0})},setShowTreePanel:t=>e({showTreePanel:t}),setShowSettings:t=>e({showSettings:t}),setShowOrch:t=>e({showOrch:t}),setShowMCP:t=>e({showMCP:t}),setShowTerminal:t=>e({showTerminal:t}),setShowAddProjectDialog:t=>e({showAddProjectDialog:t}),setExplorerTab:t=>e({explorerTab:t}),toggleExplorerTab:n=>{let{explorerTab:r}=t();e(r===n?{explorerTab:void 0}:{explorerTab:n,sidebarCollapsed:!0})},openFileViewer:(n,r)=>{let{viewerTabs:i}=t();i.find(e=>e.path===n)?e({viewerActivePath:n}):e({viewerTabs:[...i,{path:n,name:r}],viewerActivePath:n})},closeAllViewerTabs:()=>e({viewerTabs:[],viewerActivePath:void 0}),closeFileViewerTab:n=>{let{viewerTabs:r,viewerActivePath:i}=t(),a=r.filter(e=>e.path!==n),o=i;if(i===n){let e=r.findIndex(e=>e.path===n);o=a.length>0?a[Math.min(e,a.length-1)].path:void 0}e({viewerTabs:a,viewerActivePath:o})},setViewerActivePath:t=>e({viewerActivePath:t}),setViewerWidth:t=>{let n=Math.min(900,Math.max(280,Math.round(t)));try{localStorage.setItem(mi,String(n))}catch{}e({viewerWidth:n})},pushArtifact:t=>{let n=`artifact-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,r={...t,id:n,createdAt:Date.now()};e(e=>e.artifactItems.some(e=>e.title===t.title&&e.content===t.content&&e.type===t.type)?{}:{artifactItems:[...e.artifactItems,r],artifactActiveId:n})},setArtifactActiveId:t=>e({artifactActiveId:t}),setArtifactWidth:t=>e({artifactWidth:Math.min(900,Math.max(280,Math.round(t)))}),clearArtifacts:t=>e(e=>({artifactItems:e.artifactItems.filter(e=>e.sessionId!==t),artifactActiveId:void 0,showArtifacts:!1})),setShowArtifacts:t=>e({showArtifacts:t}),openArtifactViewer:(n,r,i)=>{let{artifactViewerTabs:a}=t();a.find(e=>e.id===n)?e({artifactViewerActiveId:n}):e({artifactViewerTabs:[...a,{id:n,title:r,type:i}],artifactViewerActiveId:n})},closeAllArtifactViewerTabs:()=>e({artifactViewerTabs:[],artifactViewerActiveId:void 0}),closeArtifactViewerTab:n=>{let{artifactViewerTabs:r,artifactViewerActiveId:i}=t(),a=r.filter(e=>e.id!==n),o=i;if(i===n){let e=r.findIndex(e=>e.id===n);o=a.length>0?a[Math.min(e,a.length-1)].id:void 0}e({artifactViewerTabs:a,artifactViewerActiveId:o})},setArtifactViewerActiveId:t=>e({artifactViewerActiveId:t}),setArtifactViewerWidth:t=>{let n=Math.min(900,Math.max(280,Math.round(t)));try{localStorage.setItem(gi,String(n))}catch{}e({artifactViewerWidth:n})},closeAllPanels:()=>e({showTreePanel:!1,showSettings:!1,showOrch:!1,showMCP:!1,showTerminal:!1,showAddProjectDialog:!1,explorerTab:void 0}),setIsMobile:t=>e({isMobile:t})})),vi=`pi-kot/favorite-sessions`;function yi(){try{if(typeof localStorage>`u`)return[];let e=localStorage.getItem(vi);return e?JSON.parse(e):[]}catch{return[]}}function bi(e){try{if(typeof localStorage>`u`)return;localStorage.setItem(vi,JSON.stringify(e))}catch{}}function xi(e){try{jn({favoriteSessions:e}).catch(()=>{})}catch{}}var Si=yi(),Ci=At((e,t)=>({favorites:Si,favoriteSet:new Set(Si),isFavorite:e=>t().favoriteSet.has(e),toggle:n=>{let r=t().favorites,i=r.includes(n)?r.filter(e=>e!==n):[...r,n];bi(i),xi(i),e({favorites:i,favoriteSet:new Set(i)})},unfavorite:n=>{let r=t().favorites;if(!r.includes(n))return;let i=r.filter(e=>e!==n);bi(i),xi(i),e({favorites:i,favoriteSet:new Set(i)})},prune:n=>{let r=new Set(n),i=t().favorites,a=i.filter(e=>r.has(e));a.length!==i.length&&(bi(a),xi(a),e({favorites:a,favoriteSet:new Set(a)}))},setFavorites:(t,n=!1)=>{let r=Array.from(new Set(t));bi(r),n&&xi(r),e({favorites:r,favoriteSet:new Set(r)})}})),wi=new Set([`running`,`terminating`,`terminate_timeout`]),Ti=[],J=At(e=>({bySession:{},alertsBySession:{},setProcesses:(t,n)=>e(e=>{let r=e.bySession[t];if(r&&r.length===n.length){let t=!0;for(let e=0;e<r.length;e++)if(r[e].id!==n[e].id||r[e].status!==n[e].status||r[e].exitCode!==n[e].exitCode){t=!1;break}if(t)return e}return{bySession:{...e.bySession,[t]:n}}}),addAlert:(t,n)=>e(e=>({alertsBySession:{...e.alertsBySession,[t]:[n,...e.alertsBySession[t]??[]]}})),clearAlerts:t=>e(e=>({alertsBySession:{...e.alertsBySession,[t]:[]}}))}));function Ei(e,t){return e.bySession[t]??Ti}function Di(e,t){if(!t)return 0;let n=e.bySession[t];if(!n)return 0;let r=0;for(let e of n)wi.has(e.status)&&r++;return r}var Oi=[],ki=new Map,Ai=`pi-kot/active-project-id`,ji=`pi-kot/active-session-id`;function Mi(){try{let e=window.location.hash.match(/^#\/project\/([^/]+)/);return e?e[1]:localStorage.getItem(Ai)??void 0}catch{return}}function Ni(){try{let e=window.location.hash.match(/^#\/project\/[^/]+\/session\/([^/]+)/);return e?e[1]:localStorage.getItem(ji)??void 0}catch{return}}var Y=At((e,t)=>({projects:[],activeProjectId:Mi(),sessions:[],projectSessions:{},archivedSessions:{},activeSessionId:Ni(),messages:[],compactionsBySession:{},compactionEndCountBySession:{},queuedBySession:{},streamState:{text:``,activeToolName:void 0,isStreaming:!1},activeCompaction:null,streamingMessage:void 0,isStreaming:!1,loading:!1,error:void 0,sseClient:void 0,connectionState:`disconnected`,loadProjects:async()=>{try{let{projects:n}=await tn(),r=t().activeProjectId;if(r!==void 0&&!n.some(e=>e.id===r)&&(r=void 0),r===void 0&&n.length>0&&(r=n[0].id),e({projects:n,activeProjectId:r}),r!==void 0){try{localStorage.setItem(Ai,r)}catch{}await t().loadProjectSessions(r)}}catch(t){e({error:t instanceof Error?t.message:`Failed to load projects`})}},setActiveProject:async n=>{try{localStorage.setItem(Ai,n),localStorage.removeItem(ji)}catch{}e({activeProjectId:n,activeSessionId:void 0,messages:[]}),t().sseClient?.close(),e({sseClient:void 0,connectionState:`disconnected`}),await t().loadProjectSessions(n)},loadProjectSessions:async t=>{try{let{sessions:n}=await Wt(t);e(e=>({projectSessions:{...e.projectSessions,[t]:n},sessions:n}))}catch(t){e({error:t instanceof Error?t.message:`Failed to load sessions`})}},refreshSessions:async()=>{let{activeProjectId:e}=t();e!==void 0&&await t().loadProjectSessions(e)},createAndActivate:async n=>{e({loading:!0,error:void 0});let r=n??t().activeProjectId??`default`;try{let n=await Ut({projectId:r}),i={sessionId:n.sessionId,projectId:n.projectId,isLive:!0,messageCount:0,lastActivityAt:n.createdAt,createdAt:n.createdAt};e(e=>({sessions:[i,...e.sessions],projectSessions:e.activeProjectId?{...e.projectSessions,[e.activeProjectId]:[i,...e.projectSessions[e.activeProjectId]??[]]}:e.projectSessions,activeSessionId:n.sessionId,messages:[],loading:!1}));try{localStorage.setItem(ji,n.sessionId)}catch{}return t().connectSSE(n.sessionId),n.sessionId}catch(t){return e({loading:!1,error:t instanceof Error?t.message:`Failed to create session`}),``}},setActiveSession:async n=>{try{localStorage.setItem(ji,n)}catch{}t().sseClient?.close(),e({activeSessionId:n,messages:[],streamState:{text:``,activeToolName:void 0,isStreaming:!1},activeCompaction:null,streamingMessage:void 0,isStreaming:!1,queuedBySession:{},error:void 0});try{let{messages:t}=await Gt(n);e({messages:t,streamingMessage:void 0})}catch(t){e({error:t instanceof Error?t.message:`Failed to load messages`})}t().connectSSE(n),di.getState().fetchPlanModeStatus(n)},connectSSE:n=>{t().sseClient?.close(),e({connectionState:`connecting`});let r,i,a=()=>{r=void 0,i!==void 0&&(e({streamingMessage:i,isStreaming:!0}),i=void 0)},o=!1,s=!1,c=()=>{if(o){s=!0;return}o=!0,Gt(n).then(({messages:t})=>{e({messages:t})}).catch(()=>{}).finally(()=>{s?(s=!1,o=!1,c()):o=!1})};t().loadCompactions(n),e({sseClient:ii(n,{onEvent:o=>{switch(e({connectionState:`connected`}),o.type){case`snapshot`:{let t=o.messages??[],n=o.isStreaming===!0;e({messages:t,streamingMessage:void 0,isStreaming:n,streamState:{text:``,activeToolName:void 0,isStreaming:n}});break}case`agent_start`:e({streamState:{text:``,activeToolName:void 0,isStreaming:!0},isStreaming:!0,streamingMessage:void 0});break;case`message_update`:{let t=o.message;t!==void 0&&typeof t==`object`&&(i=t,r===void 0&&(r=requestAnimationFrame(a)));let n=o.assistantMessageEvent;if(n?.type===`text_delta`){let t=n.delta;t&&e(e=>({streamState:{...e.streamState,text:e.streamState.text+t}}))}break}case`tool_execution_start`:{let t=o.toolName,{toolCallId:n,args:r}=o;n&&typeof r==`object`&&r&&ki.set(n,r),e(e=>({streamState:{...e.streamState,activeToolName:t}}));break}case`tool_execution_end`:{let{toolCallId:t,toolName:n,result:r,isError:i}=o;e(e=>({streamState:{...e.streamState,activeToolName:void 0},messages:[...e.messages,{role:`toolResult`,toolCallId:t??``,toolName:n??`tool`,content:r?.content??[],details:r?.details,isError:i===!0}]}));let a=t?ki.get(t):void 0;if(t&&ki.delete(t),n&&/[_-]?(write|write_file|edit|edit_file|apply_patch|patch|bash|shell|run|exec|mv|cp|rm|mkdir|create|rename|delete|remove|move|copy)[_-]?/i.test(n)){let e=a?.path;setTimeout(()=>{let t=q.getState(),n;if(typeof e==`string`&&e.length>0){let r=t.viewerTabs.find(t=>e===t.path||e.endsWith(`/`+t.path));n=r?r.path:e.startsWith(`./`)?e.slice(2):e}n===void 0?t.bumpFileTick():t.fileChanged(n)},80)}break}case`tool_result`:r!==void 0&&(cancelAnimationFrame(r),r=void 0),a(),c();break;case`message_end`:{r!==void 0&&(cancelAnimationFrame(r),r=void 0),a();let n=t().streamingMessage;e(e=>({streamingMessage:void 0,messages:n?[...e.messages,n]:e.messages}));break}case`ask_user_question`:{let{requestId:e,questions:t}=o;ai.getState().setPending({requestId:e,sessionId:n,questions:t});break}case`ask_user_question_cancelled`:{let{requestId:e}=o;ai.getState().clearPending(n,e);break}case`plan_review_requested`:{let{requestId:e,planFilePath:t,planContent:r}=o;di.getState().openReview({requestId:e,sessionId:n,planFilePath:t,planContent:r});break}case`plan_review_resolved`:{let{requestId:e}=o;di.getState().resolveReview(e);break}case`process_update`:{let{processes:e}=o;J.getState().setProcesses(n,e);break}case`process_alert`:{let{alert:e}=o;J.getState().addAlert(n,e);break}case`compaction_start`:{let t=o;e(e=>({activeCompaction:{reason:t.reason??`overflow`,startedAt:Date.now()}}));break}case`compaction_end`:{let r=o,i=r.result,a=i?{id:`syn-compact-${Date.now()}`,timestamp:new Date().toISOString(),summary:i.summary??``,tokensBefore:i.tokensBefore??0,estimatedTokensAfter:i.estimatedTokensAfter,insertBeforeIndex:0,archivedMessages:[]}:null;e(e=>({activeCompaction:e.activeCompaction?{...e.activeCompaction,completedAt:Date.now(),aborted:r.aborted??!1,errorMessage:r.errorMessage,tokensBefore:r.result?.tokensBefore,estimatedTokensAfter:r.result?.estimatedTokensAfter}:null,compactionEndCountBySession:{...e.compactionEndCountBySession,[n]:(e.compactionEndCountBySession[n]??0)+1},compactionsBySession:a?{...e.compactionsBySession,[n]:[a,...e.compactionsBySession[n]??Oi]}:e.compactionsBySession})),t().loadCompactions(n).then(()=>c()),setTimeout(()=>{let r=t();r.activeSessionId===n&&r.activeCompaction?.completedAt&&e({activeCompaction:null})},5e3);break}case`queued`:{let t=o,r=Array.isArray(t.steering)?t.steering.filter(e=>typeof e==`string`):[],i=Array.isArray(t.followUp)?t.followUp.filter(e=>typeof e==`string`):[];e(e=>({queuedBySession:{...e.queuedBySession,[n]:r.length===0&&i.length===0?void 0:{steering:r,followUp:i}}}));break}case`agent_end`:{r!==void 0&&(cancelAnimationFrame(r),r=void 0),a();let t=o;if(t.willRetry===!0)e({streamingMessage:void 0});else{let r=t.errorMessage,i=t.messages;if(!r&&i&&i.length>0){let e=i[i.length-1];e?.role===`assistant`&&e?.stopReason===`error`&&(r=e.errorMessage)}e(e=>({streamState:{text:``,activeToolName:void 0,isStreaming:!1},streamingMessage:void 0,isStreaming:!1,error:r??void 0,queuedBySession:{...e.queuedBySession,[n]:void 0}}))}c(),di.getState().fetchPlanModeStatus(n),setTimeout(()=>{q.getState().bumpFileTick()},150);break}case`auto_retry_start`:{let t=o;e({error:`Model error — retrying (${t.attempt??`?`}/${t.maxAttempts??`?`}): ${t.errorMessage??`Unknown error`}`});break}case`auto_retry_end`:e({error:void 0});break;case`extension_ui_status`:case`extension_ui_select`:case`extension_ui_confirm`:case`extension_ui_input`:case`extension_ui_notify`:case`extension_ui_done`:pi.getState().pushEvent(o);break;case`exec_start`:{let{command:t,excludeFromContext:n}=o,r={role:`bashExecution`,command:t,output:``,exitCode:void 0,cancelled:!1,truncated:!1,excludeFromContext:n,timestamp:Date.now(),_pendingExec:!0};e(e=>({messages:[...e.messages,r]}));break}case`exec_update`:{let{output:t}=o;e(e=>{let n=[...e.messages],r=n[n.length-1];return r&&r._pendingExec&&(r.output=(r.output??``)+t),{messages:n}});break}case`exec_end`:{let{exitCode:n,output:r,error:i,cancelled:a}=o;e(e=>{let t=[...e.messages],o=t[t.length-1];if(o&&o._pendingExec){let e=o;a?(e.cancelled=!0,e.exitCode=n):(e.exitCode=n,e.cancelled=!1),e.output=i?`${e.output}${r}\n\n[error] ${i}`:r,e.truncated=!1,e._pendingExec=!1}return{messages:t}});let s=t().activeSessionId;s!==void 0&&setTimeout(()=>t().reloadMessages(s),500);break}}},onReconnect:({attempt:t})=>{e({connectionState:`connecting`}),t>1&&e({error:`Reconnecting... (attempt ${t})`})},onClose:()=>{e({connectionState:`disconnected`})}})})},sendPrompt:async(n,r)=>{let{activeSessionId:i}=t();if(i===void 0)return;let a=[{type:`text`,text:n}];if(r!==void 0&&r.length>0)for(let e of r)a.push({type:`image`,mimeType:e.mimeType,data:`data:${e.mimeType};base64,${e.data}`,__blobUrl:!0});e(e=>({messages:[...e.messages,{role:`user`,content:a}]}));try{await qt(i,n,void 0,r)}catch(t){e(e=>({error:t instanceof Error?t.message:`Failed to send prompt`,streamState:e.streamState.isStreaming?{text:``,activeToolName:void 0,isStreaming:!1}:e.streamState}))}},sendSteer:async(n,r)=>{let{activeSessionId:i}=t();if(i===void 0)return;let a=[{type:`text`,text:n}];if(r!==void 0&&r.length>0)for(let e of r)a.push({type:`image`,mimeType:e.mimeType,data:`data:${e.mimeType};base64,${e.data}`,__blobUrl:!0});e(e=>({messages:[...e.messages,{role:`user`,content:a,metadata:{steer:!0}}]}));try{await Yt(i,n,`steer`,r)}catch(t){e(e=>({error:t instanceof Error?t.message:`Failed to steer`,streamState:e.streamState.isStreaming?{text:``,activeToolName:void 0,isStreaming:!1}:e.streamState}))}},sendFollowUp:async(n,r)=>{let{activeSessionId:i}=t();if(i===void 0)return;let a=[{type:`text`,text:n}];if(r!==void 0&&r.length>0)for(let e of r)a.push({type:`image`,mimeType:e.mimeType,data:`data:${e.mimeType};base64,${e.data}`,__blobUrl:!0});e(e=>({messages:[...e.messages,{role:`user`,content:a,metadata:{followUp:!0}}]}));try{await Yt(i,n,`followUp`,r)}catch(t){e(e=>({error:t instanceof Error?t.message:`Failed to follow up`,streamState:e.streamState.isStreaming?{text:``,activeToolName:void 0,isStreaming:!1}:e.streamState}))}},abort:async()=>{let{activeSessionId:n}=t();if(n!==void 0){e({streamState:{text:``,activeToolName:void 0,isStreaming:!1},activeCompaction:null,streamingMessage:void 0,isStreaming:!1});try{await Jt(n)}catch{}}},renameSession:async(t,n)=>{try{await Xt(t,n),e(e=>({sessions:e.sessions.map(e=>e.sessionId===t?{...e,name:n}:e),projectSessions:Object.fromEntries(Object.entries(e.projectSessions).map(([e,r])=>[e,r.map(e=>e.sessionId===t?{...e,name:n}:e)]))}))}catch(t){e({error:t instanceof Error?t.message:`Failed to rename session`})}},archiveSession:async n=>{let r=t(),i=r.sessions.find(e=>e.sessionId===n)?.projectId??r.activeProjectId;try{await Zt(n,i),Ci.getState().unfavorite(n);let r=t().activeSessionId===n;if(e(e=>({sessions:e.sessions.filter(e=>e.sessionId!==n),projectSessions:i?{...e.projectSessions,[i]:(e.projectSessions[i]??[]).filter(e=>e.sessionId!==n)}:e.projectSessions,activeSessionId:e.activeSessionId===n?void 0:e.activeSessionId})),r)try{localStorage.removeItem(ji)}catch{}i&&t().loadArchivedSessions(i)}catch(t){e({error:t instanceof Error?t.message:`Failed to archive session`})}},unarchiveSession:async(n,r)=>{try{await Qt(n,r),await t().loadProjectSessions(r),await t().loadArchivedSessions(r)}catch(t){e({error:t instanceof Error?t.message:`Failed to restore session`})}},loadArchivedSessions:async t=>{try{let{listArchivedSessions:n}=await li(async()=>{let{listArchivedSessions:e}=await Promise.resolve().then(()=>Mt);return{listArchivedSessions:e}},void 0),{sessions:r}=await n(t);e(e=>({archivedSessions:{...e.archivedSessions,[t]:r}}))}catch{}},deleteArchivedSession:async(t,n)=>{try{let{deleteArchivedSession:r}=await li(async()=>{let{deleteArchivedSession:e}=await Promise.resolve().then(()=>Mt);return{deleteArchivedSession:e}},void 0);await r(t,n),e(e=>({archivedSessions:{...e.archivedSessions,[n]:(e.archivedSessions[n]??[]).filter(e=>e.sessionId!==t)}}))}catch(t){e({error:t instanceof Error?t.message:`Failed to permanently delete session`})}},loadCompactions:async t=>{try{let{compactions:n}=await Gn(t);n.length>0&&e(e=>({compactionsBySession:{...e.compactionsBySession,[t]:n}}))}catch{}},compactAndReload:async e=>{let n=await Wn(e);return await t().loadCompactions(e),await t().reloadMessages(e),n},reloadMessages:async t=>{try{let{getSessionMessages:n}=await li(async()=>{let{getSessionMessages:e}=await Promise.resolve().then(()=>Mt);return{getSessionMessages:e}},void 0),{messages:r}=await n(t);e({messages:r})}catch{}},clearError:()=>e({error:void 0}),deleteProject:async n=>{try{await rn(n);let r=t();if(r.activeProjectId===n)try{localStorage.removeItem(Ai),localStorage.removeItem(ji)}catch{}let i=r.activeProjectId,a=r.sessions;r.activeProjectId===n&&(i=void 0,a=[]),t().sseClient?.close();let{projects:o}=await tn();if(i===void 0&&o.length>0){i=o[0].id;let{sessions:e}=await Wt(i);a=e}e({projects:o,activeProjectId:i,activeSessionId:void 0,messages:[],sessions:a,projectSessions:i?{[i]:a}:{},sseClient:void 0,streamState:{text:``,activeToolName:void 0,isStreaming:!1},error:void 0})}catch(t){e({error:t instanceof Error?t.message:`Failed to delete project`})}},reorderProjects:async n=>{let r=t().projects,i=new Map(r.map(e=>[e.id,e])),a=n.map(e=>i.get(e)).filter(e=>e!==void 0);if(a.length===r.length){e({projects:a,error:void 0});try{let{projects:t}=await an(n);e({projects:t})}catch(t){throw e({projects:r,error:t instanceof Error?t.message:`Failed to reorder projects`}),t}}},moveProject:async(e,n)=>{let{projects:r,reorderProjects:i}=t(),a=r.findIndex(t=>t.id===e);if(a===-1)return;let o=n===`up`?a-1:a+1;if(o<0||o>=r.length)return;let s=r.map(e=>e.id);[s[a],s[o]]=[s[o],s[a]],await i(s)},getSessionTree:async e=>{let{getSessionTree:t}=await li(async()=>{let{getSessionTree:e}=await Promise.resolve().then(()=>Mt);return{getSessionTree:e}},void 0);return t(e)},navigateSession:async(e,t,n)=>{let{navigateSession:r}=await li(async()=>{let{navigateSession:e}=await Promise.resolve().then(()=>Mt);return{navigateSession:e}},void 0);return r(e,t,n)},forkSession:async(e,t)=>{let{forkSession:n}=await li(async()=>{let{forkSession:e}=await Promise.resolve().then(()=>Mt);return{forkSession:e}},void 0);return n(e,t)}})),Pi={rewind:!1,subagents:!1,orchestration:!1,loading:!0},Fi=null,Ii=null;function Li(){let[e,t]=(0,G.useState)(Fi??Pi),n=(0,G.useRef)(!0);return(0,G.useEffect)(()=>{if(n.current=!0,Fi!==null){t(Fi);return}return Ii===null&&(Ii=fr().then(e=>{let r=e.detected.some(e=>e.name.includes(`rewind`)||e.name.includes(`pi-rewind`)||e.name.includes(`@ayulab/pi-rewind`)),i=e.recommended.some(e=>e.installed&&(e.id===`pi-rewind`||e.name===`@ayulab/pi-rewind`)),a=e.detected.some(e=>e.agentTypes?.includes(`scout`)||e.name.includes(`subagents`))||e.recommended.some(e=>e.installed&&(e.id===`pi-subagents`||e.id===`@ifi/pi-extension-subagents`)),o=e.detected.some(e=>e.name.includes(`orchestr`))||e.recommended.some(e=>e.id===`pi-orchestration`&&e.installed);Fi={rewind:r||i,subagents:a,orchestration:o,loading:!1},n.current&&t(Fi)}).catch(()=>{Fi={rewind:!1,subagents:!1,orchestration:!1,loading:!1},n.current&&t(Fi)})),Ii.then(()=>{n.current&&Fi!==null&&t(Fi)}),()=>{n.current=!1}},[]),e}function Ri(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;let n=document.implementation.createHTMLDocument(),r=n.createElement(`base`),i=n.createElement(`a`);return n.head.appendChild(r),n.body.appendChild(i),t&&(r.href=t),i.href=e,i.href}var zi=(()=>{let e=0,t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function Bi(e){let t=[];for(let n=0,r=e.length;n<r;n++)t.push(e[n]);return t}var Vi=null;function Hi(e={}){return Vi||(e.includeStyleProperties?(Vi=e.includeStyleProperties,Vi):(Vi=Bi(window.getComputedStyle(document.documentElement)),Vi))}function Ui(e,t){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return n?parseFloat(n.replace(`px`,``)):0}function Wi(e){let t=Ui(e,`border-left-width`),n=Ui(e,`border-right-width`);return e.clientWidth+t+n}function Gi(e){let t=Ui(e,`border-top-width`),n=Ui(e,`border-bottom-width`);return e.clientHeight+t+n}function Ki(e,t={}){return{width:t.width||Wi(e),height:t.height||Gi(e)}}function qi(){let e,t;try{t=process}catch{}let n=t&&t.env?t.env.devicePixelRatio:null;return n&&(e=parseInt(n,10),Number.isNaN(e)&&(e=1)),e||window.devicePixelRatio||1}var Ji=16384;function Yi(e){(e.width>Ji||e.height>Ji)&&(e.width>Ji&&e.height>Ji?e.width>e.height?(e.height*=Ji/e.width,e.width=Ji):(e.width*=Ji/e.height,e.height=Ji):e.width>Ji?(e.height*=Ji/e.width,e.width=Ji):(e.width*=Ji/e.height,e.height=Ji))}function Xi(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=n,r.crossOrigin=`anonymous`,r.decoding=`async`,r.src=e})}async function Zi(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(e=>`data:image/svg+xml;charset=utf-8,${e}`)}async function Qi(e,t,n){let r=`http://www.w3.org/2000/svg`,i=document.createElementNS(r,`svg`),a=document.createElementNS(r,`foreignObject`);return i.setAttribute(`width`,`${t}`),i.setAttribute(`height`,`${n}`),i.setAttribute(`viewBox`,`0 0 ${t} ${n}`),a.setAttribute(`width`,`100%`),a.setAttribute(`height`,`100%`),a.setAttribute(`x`,`0`),a.setAttribute(`y`,`0`),a.setAttribute(`externalResourcesRequired`,`true`),i.appendChild(a),a.appendChild(e),Zi(i)}var $i=(e,t)=>{if(e instanceof t)return!0;let n=Object.getPrototypeOf(e);return n===null?!1:n.constructor.name===t.name||$i(n,t)};function ea(e){let t=e.getPropertyValue(`content`);return`${e.cssText} content: '${t.replace(/'|"/g,``)}';`}function ta(e,t){return Hi(t).map(t=>`${t}: ${e.getPropertyValue(t)}${e.getPropertyPriority(t)?` !important`:``};`).join(` `)}function na(e,t,n,r){let i=`.${e}:${t}`,a=n.cssText?ea(n):ta(n,r);return document.createTextNode(`${i}{${a}}`)}function ra(e,t,n,r){let i=window.getComputedStyle(e,n),a=i.getPropertyValue(`content`);if(a===``||a===`none`)return;let o=zi();try{t.className=`${t.className} ${o}`}catch{return}let s=document.createElement(`style`);s.appendChild(na(o,n,i,r)),t.appendChild(s)}function ia(e,t,n){ra(e,t,`:before`,n),ra(e,t,`:after`,n)}var aa=`application/font-woff`,oa=`image/jpeg`,sa={woff:aa,woff2:aa,ttf:`application/font-truetype`,eot:`application/vnd.ms-fontobject`,png:`image/png`,jpg:oa,jpeg:oa,gif:`image/gif`,tiff:`image/tiff`,svg:`image/svg+xml`,webp:`image/webp`};function ca(e){let t=/\.([^./]*?)$/g.exec(e);return t?t[1]:``}function la(e){return sa[ca(e).toLowerCase()]||``}function ua(e){return e.split(/,/)[1]}function da(e){return e.search(/^(data:)/)!==-1}function fa(e,t){return`data:${t};base64,${e}`}async function pa(e,t,n){let r=await fetch(e,t);if(r.status===404)throw Error(`Resource "${r.url}" not found`);let i=await r.blob();return new Promise((e,t)=>{let a=new FileReader;a.onerror=t,a.onloadend=()=>{try{e(n({res:r,result:a.result}))}catch(e){t(e)}},a.readAsDataURL(i)})}var ma={};function ha(e,t,n){let r=e.replace(/\?.*/,``);return n&&(r=e),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,``)),t?`[${t}]${r}`:r}async function ga(e,t,n){let r=ha(e,t,n.includeQueryParams);if(ma[r]!=null)return ma[r];n.cacheBust&&(e+=(/\?/.test(e)?`&`:`?`)+new Date().getTime());let i;try{i=fa(await pa(e,n.fetchRequestInit,({res:e,result:n})=>(t||=e.headers.get(`Content-Type`)||``,ua(n))),t)}catch(t){i=n.imagePlaceholder||``;let r=`Failed to fetch resource: ${e}`;t&&(r=typeof t==`string`?t:t.message),r&&console.warn(r)}return ma[r]=i,i}async function _a(e){let t=e.toDataURL();return t===`data:,`?e.cloneNode(!1):Xi(t)}async function va(e,t){if(e.currentSrc){let t=document.createElement(`canvas`),n=t.getContext(`2d`);return t.width=e.clientWidth,t.height=e.clientHeight,n?.drawImage(e,0,0,t.width,t.height),Xi(t.toDataURL())}let n=e.poster;return Xi(await ga(n,la(n),t))}async function ya(e,t){try{if(e?.contentDocument?.body)return await ka(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function ba(e,t){return $i(e,HTMLCanvasElement)?_a(e):$i(e,HTMLVideoElement)?va(e,t):$i(e,HTMLIFrameElement)?ya(e,t):e.cloneNode(Sa(e))}var xa=e=>e.tagName!=null&&e.tagName.toUpperCase()===`SLOT`,Sa=e=>e.tagName!=null&&e.tagName.toUpperCase()===`SVG`;async function Ca(e,t,n){if(Sa(t))return t;let r=[];return r=xa(e)&&e.assignedNodes?Bi(e.assignedNodes()):$i(e,HTMLIFrameElement)&&e.contentDocument?.body?Bi(e.contentDocument.body.childNodes):Bi((e.shadowRoot??e).childNodes),r.length===0||$i(e,HTMLVideoElement)||await r.reduce((e,r)=>e.then(()=>ka(r,n)).then(e=>{e&&t.appendChild(e)}),Promise.resolve()),t}function wa(e,t,n){let r=t.style;if(!r)return;let i=window.getComputedStyle(e);i.cssText?(r.cssText=i.cssText,r.transformOrigin=i.transformOrigin):Hi(n).forEach(n=>{let a=i.getPropertyValue(n);n===`font-size`&&a.endsWith(`px`)&&(a=`${Math.floor(parseFloat(a.substring(0,a.length-2)))-.1}px`),$i(e,HTMLIFrameElement)&&n===`display`&&a===`inline`&&(a=`block`),n===`d`&&t.getAttribute(`d`)&&(a=`path(${t.getAttribute(`d`)})`),r.setProperty(n,a,i.getPropertyPriority(n))})}function Ta(e,t){$i(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),$i(e,HTMLInputElement)&&t.setAttribute(`value`,e.value)}function Ea(e,t){if($i(e,HTMLSelectElement)){let n=t,r=Array.from(n.children).find(t=>e.value===t.getAttribute(`value`));r&&r.setAttribute(`selected`,``)}}function Da(e,t,n){return $i(t,Element)&&(wa(e,t,n),ia(e,t,n),Ta(e,t),Ea(e,t)),t}async function Oa(e,t){let n=e.querySelectorAll?e.querySelectorAll(`use`):[];if(n.length===0)return e;let r={};for(let i=0;i<n.length;i++){let a=n[i].getAttribute(`xlink:href`);if(a){let n=e.querySelector(a),i=document.querySelector(a);!n&&i&&!r[a]&&(r[a]=await ka(i,t,!0))}}let i=Object.values(r);if(i.length){let t=`http://www.w3.org/1999/xhtml`,n=document.createElementNS(t,`svg`);n.setAttribute(`xmlns`,t),n.style.position=`absolute`,n.style.width=`0`,n.style.height=`0`,n.style.overflow=`hidden`,n.style.display=`none`;let r=document.createElementNS(t,`defs`);n.appendChild(r);for(let e=0;e<i.length;e++)r.appendChild(i[e]);e.appendChild(n)}return e}async function ka(e,t,n){return!n&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(e=>ba(e,t)).then(n=>Ca(e,n,t)).then(n=>Da(e,n,t)).then(e=>Oa(e,t))}var Aa=/url\((['"]?)([^'"]+?)\1\)/g,ja=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Ma=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Na(e){let t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,`\\$1`);return RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,`g`)}function Pa(e){let t=[];return e.replace(Aa,(e,n,r)=>(t.push(r),e)),t.filter(e=>!da(e))}async function Fa(e,t,n,r,i){try{let a=n?Ri(t,n):t,o=la(t),s;return s=i?fa(await i(a),o):await ga(a,o,r),e.replace(Na(t),`$1${s}$3`)}catch{}return e}function Ia(e,{preferredFontFormat:t}){return t?e.replace(Ma,e=>{for(;;){let[n,,r]=ja.exec(e)||[];if(!r)return``;if(r===t)return`src: ${n};`}}):e}function La(e){return e.search(Aa)!==-1}async function Ra(e,t,n){if(!La(e))return e;let r=Ia(e,n);return Pa(r).reduce((e,r)=>e.then(e=>Fa(e,r,t,n)),Promise.resolve(r))}async function za(e,t,n){let r=t.style?.getPropertyValue(e);if(r){let i=await Ra(r,null,n);return t.style.setProperty(e,i,t.style.getPropertyPriority(e)),!0}return!1}async function Ba(e,t){await za(`background`,e,t)||await za(`background-image`,e,t),await za(`mask`,e,t)||await za(`-webkit-mask`,e,t)||await za(`mask-image`,e,t)||await za(`-webkit-mask-image`,e,t)}async function Va(e,t){let n=$i(e,HTMLImageElement);if(!(n&&!da(e.src))&&!($i(e,SVGImageElement)&&!da(e.href.baseVal)))return;let r=n?e.src:e.href.baseVal,i=await ga(r,la(r),t);await new Promise((r,a)=>{e.onload=r,e.onerror=t.onImageErrorHandler?(...e)=>{try{r(t.onImageErrorHandler(...e))}catch(e){a(e)}}:a;let o=e;o.decode&&=r,o.loading===`lazy`&&(o.loading=`eager`),n?(e.srcset=``,e.src=i):e.href.baseVal=i})}async function Ha(e,t){let n=Bi(e.childNodes).map(e=>Ua(e,t));await Promise.all(n).then(()=>e)}async function Ua(e,t){$i(e,Element)&&(await Ba(e,t),await Va(e,t),await Ha(e,t))}function Wa(e,t){let{style:n}=e;t.backgroundColor&&(n.backgroundColor=t.backgroundColor),t.width&&(n.width=`${t.width}px`),t.height&&(n.height=`${t.height}px`);let r=t.style;return r!=null&&Object.keys(r).forEach(e=>{n[e]=r[e]}),e}var Ga={};async function Ka(e){let t=Ga[e];return t??(t={url:e,cssText:await(await fetch(e)).text()},Ga[e]=t,t)}async function qa(e,t){let n=e.cssText,r=/url\(["']?([^"')]+)["']?\)/g,i=(n.match(/url\([^)]+\)/g)||[]).map(async i=>{let a=i.replace(r,`$1`);return a.startsWith(`https://`)||(a=new URL(a,e.url).href),pa(a,t.fetchRequestInit,({result:e})=>(n=n.replace(i,`url(${e})`),[i,e]))});return Promise.all(i).then(()=>n)}function Ja(e){if(e==null)return[];let t=[],n=e.replace(/(\/\*[\s\S]*?\*\/)/gi,``),r=RegExp(`((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})`,`gi`);for(;;){let e=r.exec(n);if(e===null)break;t.push(e[0])}n=n.replace(r,``);let i=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,a=RegExp(`((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})`,`gi`);for(;;){let e=i.exec(n);if(e===null){if(e=a.exec(n),e===null)break;i.lastIndex=a.lastIndex}else a.lastIndex=i.lastIndex;t.push(e[0])}return t}async function Ya(e,t){let n=[],r=[];return e.forEach(n=>{if(`cssRules`in n)try{Bi(n.cssRules||[]).forEach((e,i)=>{if(e.type===CSSRule.IMPORT_RULE){let a=i+1,o=e.href,s=Ka(o).then(e=>qa(e,t)).then(e=>Ja(e).forEach(e=>{try{n.insertRule(e,e.startsWith(`@import`)?a+=1:n.cssRules.length)}catch(t){console.error(`Error inserting rule from remote css`,{rule:e,error:t})}})).catch(e=>{console.error(`Error loading remote css`,e.toString())});r.push(s)}})}catch(i){let a=e.find(e=>e.href==null)||document.styleSheets[0];n.href!=null&&r.push(Ka(n.href).then(e=>qa(e,t)).then(e=>Ja(e).forEach(e=>{a.insertRule(e,a.cssRules.length)})).catch(e=>{console.error(`Error loading remote stylesheet`,e)})),console.error(`Error inlining remote css file`,i)}}),Promise.all(r).then(()=>(e.forEach(e=>{if(`cssRules`in e)try{Bi(e.cssRules||[]).forEach(e=>{n.push(e)})}catch(t){console.error(`Error while reading CSS rules from ${e.href}`,t)}}),n))}function Xa(e){return e.filter(e=>e.type===CSSRule.FONT_FACE_RULE).filter(e=>La(e.style.getPropertyValue(`src`)))}async function Za(e,t){if(e.ownerDocument==null)throw Error(`Provided element is not within a Document`);return Xa(await Ya(Bi(e.ownerDocument.styleSheets),t))}function Qa(e){return e.trim().replace(/["']/g,``)}function $a(e){let t=new Set;function n(e){(e.style.fontFamily||getComputedStyle(e).fontFamily).split(`,`).forEach(e=>{t.add(Qa(e))}),Array.from(e.children).forEach(e=>{e instanceof HTMLElement&&n(e)})}return n(e),t}async function eo(e,t){let n=await Za(e,t),r=$a(e);return(await Promise.all(n.filter(e=>r.has(Qa(e.style.fontFamily))).map(e=>{let n=e.parentStyleSheet?e.parentStyleSheet.href:null;return Ra(e.cssText,n,t)}))).join(`
14
+ `)}async function to(e,t){let n=t.fontEmbedCSS==null?t.skipFonts?null:await eo(e,t):t.fontEmbedCSS;if(n){let t=document.createElement(`style`),r=document.createTextNode(n);t.appendChild(r),e.firstChild?e.insertBefore(t,e.firstChild):e.appendChild(t)}}async function no(e,t={}){let{width:n,height:r}=Ki(e,t),i=await ka(e,t,!0);return await to(i,t),await Ua(i,t),Wa(i,t),await Qi(i,n,r)}async function X(e,t={}){let{width:n,height:r}=Ki(e,t),i=await Xi(await no(e,t)),a=document.createElement(`canvas`),o=a.getContext(`2d`),s=t.pixelRatio||qi(),c=t.canvasWidth||n,l=t.canvasHeight||r;return a.width=c*s,a.height=l*s,t.skipAutoScale||Yi(a),a.style.width=`${c}`,a.style.height=`${l}`,t.backgroundColor&&(o.fillStyle=t.backgroundColor,o.fillRect(0,0,a.width,a.height)),o.drawImage(i,0,0,a.width,a.height),a}async function ro(e,t={}){return(await X(e,t)).toDataURL()}var io=/^#L(\d+)(?:-L?(\d+))?/,ao=new Set([`dockerfile`,`makefile`,`license`,`readme`,`procfile`,`gemfile`,`rakefile`,`containerfile`]);function oo(e){return!e||e.length===0?!1:!!(e.includes(`/`)||e.includes(`\\`)||/\.[a-zA-Z0-9_-]+$/.test(e)&&e!==`.`&&e!==`..`||ao.has(e.toLowerCase()))}function so(e){let t=[],n=e.length;for(let r=0;r<n;r++){if(e[r]!==`@`||r>0&&!/\s/.test(e[r-1]))continue;let i=r+1;if(i>=n)continue;let a=e[i];if(a===`(`||a===`{`||a===`[`||a===`-`||/\s/.test(a))continue;let o=``,s,c;if(a===`"`){let t=i+1,r=t;for(;r<n&&e[r]!==`"`&&e[r]!==`
15
+ `&&e[r]!==`\r`;)r++;if(r>=n||e[r]!==`"`)continue;let a=e.slice(t,r);if(a.length===0||a.includes(`,`)||(o=a,i=r+1,i<n&&e[i]===`,`))continue;let l=e.slice(i).match(io);if(l&&(s=Number(l[1]),c=l[2]===void 0?s:Number(l[2]),i+=l[0].length),i<n&&e[i]===`,`)continue}else{let t=i;for(;i<n&&!/\s/.test(e[i]);)i++;let r=e.slice(t,i),a=r.match(/[?,;:!)\]]+$/);if(a&&(r=r.slice(0,-a[0].length),i-=a[0].length),r.startsWith(`-`)||r.startsWith(`$`)||/[(){}[\],"';=$*<>|]/.test(r))continue;let l=r.match(/^(.*?)#L(\d+)(?:-L?(\d+))?$/);if(l?(o=l[1]??``,s=Number(l[2]),c=l[3]===void 0?s:Number(l[3])):o=r,s===void 0&&!oo(o))continue}if(o.length===0)continue;let l=e.slice(r,i);t.push({key:`${r}:${l}`,start:r,end:i,path:o,startLine:s,endLine:c,raw:l}),r=i-1}return t}var co=new Set([`write`,`edit`]);function lo(e,t){let n=new Set,r=[];for(let i of e){let e=i.content;if(Array.isArray(e))for(let i of e){let e=i;if(e?.type!==`toolCall`)continue;let a=e.name;if(typeof a!=`string`||!co.has(a))continue;let o=typeof e.id==`string`?e.id:void 0,s=o===void 0?void 0:t(o);if(s===void 0||s.isError===!0)continue;let c=e.arguments,l=typeof c?.path==`string`?c.path:void 0;l===void 0||l.length===0||n.has(l)||(n.add(l),r.push(l))}}return r}function uo(e){let t=e.split(/[\\/]/);return t[t.length-1]??e}function fo(e){let t=e.includes(`\r
16
+ `)?`\r
17
+ `:`
18
+ `,n=e.split(/\r?\n/),r=[],i=null,a=0,o=null,s=new Map;for(let e=0;e<n.length;e++){let t=n[e];if(o){r.push(t),RegExp(`</${o}\\s*>`,`i`).test(t)&&(o=null);continue}let c=t.match(/^ {0,3}(`{3,}|~{3,})/);if(c){let e=c[1][0],n=c[1].length;i?e===i.marker&&n>=i.size&&(i=null):i={marker:e,size:n},a=0,r.push(t);continue}if(i){r.push(t);continue}let l=t.match(/<(code|pre|script|style)\b/i);if(l){let e=l[1].toLowerCase(),n=t.slice((l.index??0)+l[0].length);RegExp(`</${e}\\s*>`,`i`).test(n)||(o=e),a=0,r.push(t);continue}if(/^(?: {4}|\t)/.test(t)||t.trim()===``){a=0,r.push(t);continue}if(a||t.includes("`")){a=bo(t,a),r.push(t);continue}let u=t.match(/^([ ]{0,3})\\\[[ \t]*(.+?)[ \t]*\\\][ \t]*$/);if(u){let e=u[2].trim();if(e){r.push(`${u[1]}$$`,`${u[1]}${e}`,`${u[1]}$$`);continue}}let d=t.match(/^([ ]{0,3})\\\[[ \t]*$/);if(d){let t=yo(n,e+1);if(t!==-1){r.push(`${d[1]}$$`,...n.slice(e+1,t).map(e=>vo(e,d[1])),`${d[1]}$$`),e=t;continue}}let f=t.match(/^([ \t]{0,3})\$\$(.+)\$\$[ \t]*$/);if(f){let e=f[2].trim();if(e){r.push(`${f[1]}$$`,`${f[1]}${e}`,`${f[1]}$$`);continue}}let p=t.match(/^([ \t]{0,3})\$\$(.+)$/);if(p){let t=p[1],i=p[2].trimEnd();if(i&&!i.includes(`$$`)){let a=po(n,e+1,t,s);if(a){r.push(`${t}$$`,`${t}${i}`);for(let i=e+1;i<a.index;i++)r.push(vo(n[i],t));a.content&&r.push(`${t}${a.content}`),r.push(`${t}$$`),e=a.index;continue}}}let m=t.match(/^([ \t]{0,3})\$\$\s*$/);if(m){let t=m[1],i=po(n,e+1,t,s);if(i&&(i.glued||t!==``)){r.push(`${t}$$`);for(let a=e+1;a<i.index;a++)r.push(vo(n[a],t));i.content&&r.push(`${t}${i.content}`),r.push(`${t}$$`),e=i.index;continue}}r.push(xo(t))}return r.join(t)}function po(e,t,n,r){let i=r.get(n);if(i!==void 0&&t<i)return null;for(let i=t;i<e.length;i++){let t=e[i];if(mo(t,n))return{index:i,content:``,glued:!1};if(_o(t)||go(t))return r.set(n,i),null;let a=ho(t,n);if(a!==null)return{index:i,content:a,glued:!0}}return r.set(n,e.length),null}function mo(e,t){return t===``?/^ {0,3}\$\$\s*$/.test(e):e.startsWith(t)&&/^\$\$\s*$/.test(e.slice(t.length))}function ho(e,t){if(!e.startsWith(t))return null;let n=e.slice(t.length).match(/^(.+?)\$\$\s*$/);if(!n)return null;let r=n[1].trimEnd();return r&&!r.includes(`$$`)?r:null}function go(e){return/^ {0,3}\$\$(?:\S|[ \t]+\S)/.test(e)}function _o(e){return/^ {0,3}(`{3,}|~{3,})/.test(e)||/^[ \t]*(?:[-+*]|\d{1,9}[.)])(?:[ \t]+|$)/.test(e)||/^ {0,3}#{1,6}(?:[ \t]+|$)/.test(e)||/^ {0,3}>/.test(e)||/<(code|pre|script|style)\b/i.test(e)}function vo(e,t){if(!t||!e||e.startsWith(` `))return e;let n=e.match(/^ */)?.[0].length??0;return n>=t.length?e:`${t.slice(n)}${e}`}function yo(e,t){for(let n=t;n<e.length;n++){let t=e[n];if(/^ {0,3}\\\][ \t]*$/.test(t))return n;if(/^ {0,3}(`{3,}|~{3,})/.test(t)||/^ {0,3}\\\[[ \t]*$/.test(t)||/<(code|pre|script|style)\b/i.test(t))return-1}return-1}function bo(e,t){let n=t;for(let t=0;t<e.length;){if(e[t]!=="`"){t++;continue}let r=t+1;for(;e[r]==="`";)r++;let i=r-t;n===0?n=i:i===n&&(n=0),t=r}return n}function xo(e){return/^\s{0,3}\[[^\]]+\]:/.test(e)||/]\s*\(/.test(e)||/<(?:!--|\/?[A-Za-z][^>]*>)/.test(e)||/\b(?:https?|file|mailto):/i.test(e)||/\b[A-Za-z]:\\/.test(e)?e:e.replace(/(?<!\\)\\\(([^`\r\n$]+?)(?<!\\)\\\)/g,(e,t)=>t.trim()?`$${t}$`:e)}var Z=be(),So=/<proposed_plan>([\s\S]*?)<\/proposed_plan>/gi,Co=/^light|clean|terracotta|sage$/i;function wo({className:e,children:t,...n}){let[r,i]=(0,G.useState)(()=>{if(typeof window>`u`)return!1;try{let e=document.documentElement.getAttribute(`data-theme`);if(e&&Co.test(e))return!0}catch{}return window.matchMedia?.(`(prefers-color-scheme: light)`)?.matches??!1});(0,G.useEffect)(()=>{let e=document.documentElement,t=()=>{let t=e.getAttribute(`data-theme`);i(!!(t&&Co.test(t)))};t();let n=window.matchMedia?.(`(prefers-color-scheme: dark)`),r=()=>t();n?.addEventListener?.(`change`,r);let a=new MutationObserver(r);return e&&a.observe(e,{attributes:!0,attributeFilter:[`data-theme`]}),()=>{n?.removeEventListener?.(`change`,r),a.disconnect()}},[]);let a=/language-([\w-]+)/.exec(e??``),o=String(t??``).replace(/\n$/,``);if(!(a!==null||o.includes(`
19
+ `)))return(0,Z.jsx)(`code`,{className:`inline-code`,...n,children:t});let s=a?.[1]??`text`,c=r?_e.vsLight:_e.vsDark,l=r?`#f8fafc`:`#0d0d0d`;return(0,Z.jsxs)(`div`,{className:`code-block-wrap`,children:[(0,Z.jsx)(To,{code:o}),(0,Z.jsx)(ve,{code:o,language:s,theme:c,children:({style:e,tokens:t,getLineProps:n,getTokenProps:r})=>(0,Z.jsx)(`pre`,{className:`code-block`,style:{...e,background:l},children:t.map((e,t)=>(0,Z.jsx)(`div`,{...n({line:e}),children:e.map((e,t)=>(0,Z.jsx)(`span`,{...r({token:e})},t))},t))})})]})}function To({code:e}){let[t,n]=(0,G.useState)(!1),r=()=>{n(!0),setTimeout(()=>n(!1),1200)},i=e=>{try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),document.execCommand(`copy`),document.body.removeChild(t),r()}catch{}};return(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{if(!e)return;let t=navigator.clipboard?.writeText?.bind(navigator.clipboard);t===void 0?i(e):t(e).then(r).catch(()=>i(e))},className:`code-copy-btn`,title:`Copy code block`,"aria-label":`Copy code block`,children:t?(0,Z.jsx)(F,{size:13}):(0,Z.jsx)(w,{size:13})})}function Eo({src:e,alt:t}){let[n,r]=(0,G.useState)(!1);if(e&&(e.toLowerCase().endsWith(`.html`)||e.toLowerCase().endsWith(`.htm`)))return(0,Z.jsxs)(`div`,{style:{padding:`12px`,border:`1px dashed var(--border)`,borderRadius:`6px`,margin:`12px 0`,background:`var(--bg-subtle)`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,marginBottom:`4px`},children:[(0,Z.jsx)(`span`,{style:{fontSize:`16px`},children:`⚠️`}),(0,Z.jsx)(`span`,{style:{fontSize:`13px`,fontWeight:600,color:`var(--text-primary)`},children:`HTML Preview Blocked`})]}),(0,Z.jsxs)(`p`,{style:{margin:0,fontSize:`12px`,color:`var(--text-secondary)`,lineHeight:1.4},children:[`The agent attempted to embed `,(0,Z.jsx)(`strong`,{children:e.split(`/`).pop()||e}),` as an image. HTML files cannot be displayed this way. To view the live preview, open the `,(0,Z.jsx)(`strong`,{children:`Artifacts`}),` tab and click on the file.`]})]});if(n||!e){let n=t||(e?e.split(`/`).pop():`Image unavailable`);return(0,Z.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:`6px`,padding:`4px 10px`,margin:`4px 0`,fontSize:`12px`,color:`var(--text-muted, #888)`,background:`var(--bg-subtle, rgba(255,255,255,0.04))`,border:`1px solid var(--border, rgba(255,255,255,0.1))`,borderRadius:`6px`,maxWidth:`100%`,userSelect:`none`},title:e?`Unable to load: ${e}`:`Image unavailable`,children:[(0,Z.jsx)(i,{size:13,style:{flexShrink:0,opacity:.7}}),(0,Z.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:n})]})}return(0,Z.jsx)(`img`,{src:e,alt:t??``,loading:`lazy`,onError:()=>r(!0),style:{maxWidth:`100%`,height:`auto`,borderRadius:4,boxShadow:`0 1px 4px rgba(0,0,0,0.1)`,display:`inline-block`}})}var Do={h1:({children:e})=>(0,Z.jsx)(`h1`,{className:`md-h1`,children:e}),h2:({children:e})=>(0,Z.jsx)(`h2`,{className:`md-h2`,children:e}),h3:({children:e})=>(0,Z.jsx)(`h3`,{className:`md-h3`,children:e}),h4:({children:e})=>(0,Z.jsx)(`h4`,{className:`md-h4`,children:e}),p:({children:e})=>(0,Z.jsx)(`p`,{className:`md-p`,children:e}),ul:({children:e})=>(0,Z.jsx)(`ul`,{className:`md-ul`,children:e}),ol:({children:e})=>(0,Z.jsx)(`ol`,{className:`md-ol`,children:e}),li:({children:e})=>(0,Z.jsx)(`li`,{className:`md-li`,children:e}),blockquote:({children:e})=>(0,Z.jsx)(`blockquote`,{className:`md-blockquote`,children:e}),hr:()=>(0,Z.jsx)(`hr`,{className:`md-hr`}),a:({href:e,children:t})=>(0,Z.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`md-link`,children:t}),img:({src:e,alt:t})=>(0,Z.jsx)(Eo,{src:e,alt:t}),table:({children:e})=>(0,Z.jsx)(`div`,{className:`table-wrapper`,children:(0,Z.jsx)(`table`,{className:`md-table`,children:e})}),th:({children:e})=>(0,Z.jsx)(`th`,{className:`md-th`,children:e}),td:({children:e})=>(0,Z.jsx)(`td`,{className:`md-td`,children:e}),strong:({children:e})=>(0,Z.jsx)(`strong`,{className:`md-strong`,children:e}),em:({children:e})=>(0,Z.jsx)(`em`,{children:e}),code:wo,pre:({children:e})=>(0,Z.jsx)(Z.Fragment,{children:e})},Oo=[Ce,[xe,{...ye,attributes:{...ye.attributes,div:[...ye.attributes?.div??[],[`style`,/.*/]],span:[...ye.attributes?.span??[],[`style`,/.*/]],strong:[...ye.attributes?.strong??[],[`style`,/.*/]],p:[...ye.attributes?.p??[],[`style`,/.*/]]},strip:[...ye.strip||[],`iframe`,`script`,`object`,`form`,`style`]}],[De,{throwOnError:!1,strict:!1}]];function ko({content:e}){return(0,Z.jsxs)(`div`,{style:{border:`1px solid var(--accent-subtle, rgba(255,255,255,0.12))`,borderRadius:`var(--radius-md, 10px)`,padding:`16px 20px`,margin:`16px 0`,background:`var(--bg-glass-strong, rgba(255,255,255,0.04))`},children:[(0,Z.jsx)(`div`,{style:{fontSize:`11px`,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.08em`,color:`var(--text-dim, rgba(255,255,255,0.3))`,marginBottom:`12px`},children:`Proposed Plan`}),(0,Z.jsx)(jo,{text:e})]})}function Ao(e){let t=[],n=0,r;for(So.lastIndex=0;(r=So.exec(e))!==null;)r.index>n&&t.push(e.slice(n,r.index)),t.push((0,Z.jsx)(ko,{content:r[1].trim()},r.index)),n=r.index+r[0].length;return n<e.length&&t.push(e.slice(n)),t.length>0?t:[e]}var jo=(0,G.memo)(function({text:e,chatStyleBreaks:t}){let n=t?[Se,Ee,we]:[Se,Ee],r=(0,G.useMemo)(()=>Ao(xo(fo(e))),[e]);return r.length===1&&typeof r[0]==`string`?(0,Z.jsx)(`div`,{className:`md-root text-sm break-words`,style:{overflowWrap:`anywhere`},children:(0,Z.jsx)(Te,{remarkPlugins:n,rehypePlugins:Oo,components:Do,children:r[0]})}):(0,Z.jsx)(`div`,{className:`md-root text-sm break-words`,style:{overflowWrap:`anywhere`},children:r.map((e,t)=>typeof e==`string`?(0,Z.jsx)(Te,{remarkPlugins:n,rehypePlugins:Oo,components:Do,children:e},t):e)})}),Mo={id:`en`,label:`English`,messages:{"chat.placeholder":`Send a message...`,"chat.waitingForModel":`waiting for model…`,"settings.language":`Language`,"settings.systemDefault":`System Default`,"settings.title":`Settings`,"settings.tabs.appearance":`Appearance`,"settings.tabs.providers":`Providers`,"settings.tabs.agent":`Agent`,"settings.tabs.general":`General`,"settings.tabs.packages":`Packages`,"settings.tabs.skills":`Skills`,"settings.tabs.tunnel":`Tunnel`,"sidebar.newSession":`New session`,"sidebar.favorites":`★ Favorites`,"sidebar.showMore":`↓ {count} more session`,"sidebar.showMorePlural":`↓ {count} more sessions`,"sidebar.showLess":`↑ Show less`,"sidebar.noSessions":`No sessions yet — click + to start one`,"sidebar.noMatches":`No matches for "{query}"`,"sidebar.nav.mcp":`MCP`,"sidebar.nav.settings":`Settings`,"sidebar.nav.signOut":`Sign out`,"settings.general.about":`About`,"settings.appearance.fontSizeHint":`Applies to chat, markdown, and tools. Editor remains monospace.`,"settings.appearance.trailAuto":`Auto`,"settings.appearance.trailExpandAll":`Expand All`,"settings.appearance.trailHint":`Default view for tool trails. Applies to both active and finished runs.`,"settings.appearance.swipeSidebar":`Swipe left/right opens sidebar`,"settings.appearance.swipeSidebarHint":`Touch screens: horizontal swipes open/collapse the sidebar. Turn off if scrolling triggers it.`,"settings.appearance.splitFlap":`Animated split-flap welcome`,"settings.appearance.splitFlapHint":`Airport-style departure board centered in an empty chat. Off → classic “send a message” welcome.`,"settings.appearance.splitFlapPhrases":`Phrases (comma-separated)`,"settings.appearance.splitFlapPhrasesHint":`Board flips between phrases. Enter or click away to apply (shown in caps on the board).`,"settings.general.aboutDesc":`pi-kot — a web UI for the pi coding agent.`,"settings.general.versions":`Versions`,"settings.general.server":`pi-kot server`,"settings.general.sdk":`pi SDK`,"settings.general.latestSdk":`Latest SDK`,"settings.general.checkFailed":`Check failed`,"settings.general.updateAvailable":`Update available`,"settings.general.upToDate":`Up to date`,"settings.general.checking":`Checking…`,"settings.general.checkAgain":`Check again`,"settings.general.checkForUpdates":`Check for updates`,"settings.general.reloadPage":`Reload page`,"settings.appearance.title":`Appearance`,"settings.appearance.theme":`Theme`,"settings.appearance.accent":`Accent Color`,"settings.appearance.yourMessageBubble":`Message Bubble Color`,"settings.appearance.chat":`Chat`,"settings.appearance.preferencesSaved":`Preferences saved server-side (survives cache clears).`,"settings.appearance.preferencesLocal":`Server offline — saved locally only.`,"settings.appearance.preview":`Preview`,"settings.appearance.previewUser":`Your messages will look like this.`,"settings.appearance.previewAssistant":`The assistant reply sits here for reference.`,"settings.appearance.background":`Background`,"settings.appearance.text":`Text`,"settings.appearance.border":`Border`,"settings.appearance.resetDefaults":`Reset to defaults`,"settings.appearance.stickyUserHeader":`Sticky user header`,"settings.appearance.flyToTop":`Fly to top`,"settings.appearance.flyToTopDesc":`Anchors your newest message near the top while it streams. Reply grows below and auto-scroll takes over once it fills the screen.`,"settings.appearance.showTokenUsage":`Show token usage`,"settings.appearance.showTurnFiles":`Show turn-written files`,"settings.appearance.showTurnFilesDesc":`File chips under each reply for files the agent wrote, with per-turn diff.`,"settings.appearance.images":`Images`,"settings.appearance.compressImages":`Compress images`,"settings.appearance.showThinking":`Show thinking blocks`,"settings.appearance.groupedToolDisplay":`Grouped tool display`,"settings.appearance.groupedToolDisplayDesc":`Collapse consecutive tool calls (like file edits) into a single summary block.`,"settings.appearance.emptyState":`Empty state`,"settings.providers.loading":`Loading providers…`,"settings.providers.description":`Built-in providers and anything in models.json. Stored API keys are presence-only — actual values are never sent to the browser.`,"settings.providers.addCustom":`+ Add Custom Provider`,"settings.providers.noProviders":`No providers configured.`,"settings.providers.keySet":`key set`,"settings.providers.noKey":`no key`,"settings.providers.via":`via`,"settings.providers.replaceKey":`Replace key`,"settings.providers.addKey":`Add key`,"settings.providers.remove":`Remove`,"settings.providers.deleteProvider":`Delete provider`,"settings.providers.removeFromModels":`Remove from models.json`,"settings.providers.pasteKey":`Paste API key`,"settings.providers.save":`Save`,"settings.providers.saving":`Saving…`,"settings.providers.cancel":`Cancel`,"settings.providers.modelsCount":`models`,"settings.providers.deleteProviderConfirm":`Remove provider from models.json? This can be undone by adding it again.`,"settings.providers.delete":`Delete`,"settings.providers.showRaw":`Show models.json raw editor`,"settings.providers.hideRaw":`Hide models.json raw editor`,"settings.providers.reload":`Reload`,"settings.providers.model.default":`Default`,"settings.providers.model.disabled":`Disabled`,"settings.providers.model.custom":`Custom`,"settings.providers.model.id":`ID *`,"settings.providers.model.idPlaceholder":`model-id`,"settings.providers.model.name":`Name`,"settings.providers.model.namePlaceholder":`Display name`,"settings.providers.model.apiOverride":`API override`,"settings.providers.model.apiDefault":`Default`,"settings.providers.model.apiOpenAiCompat":`OpenAI Compatible`,"settings.providers.model.apiOpenAiResponses":`OpenAI Responses API`,"settings.providers.model.apiAnthropic":`Anthropic Messages API`,"settings.providers.model.apiGoogle":`Google Generative AI`,"settings.providers.model.reasoning":`Reasoning / thinking`,"settings.providers.model.imageInput":`Image input`,"settings.providers.model.deepSeekCompat":`DeepSeek thinking compatibility`,"settings.providers.model.thinkingLevelMap":`Thinking level map`,"settings.providers.model.clearAll":`clear all`,"settings.providers.model.contextWindow":`Context window (tokens)`,"settings.providers.model.maxTokens":`Max output tokens`,"settings.providers.model.cost":`Cost (per million tokens)`,"settings.providers.model.removeModel":`Remove model`,"settings.agent.loading":`Loading settings…`,"settings.agent.defaultProvider":`Default provider`,"settings.agent.defaultProviderHint":`Select an LLM provider`,"settings.agent.defaultModel":`Default model`,"settings.agent.defaultModelHint":`Model from the selected provider`,"settings.agent.thinkingLevel":`Thinking level`,"settings.agent.thinkingLevelHint":`off, minimal, low, medium, high, xhigh`,"settings.agent.modelScope":`Model Scope`,"settings.packages.title":`Packages`,"settings.packages.toolsIntegrations":`🛠️ Tools & Integrations`,"settings.packages.productivity":`⚡ Productivity`,"settings.packages.installedGlobal":`Installed (global)`,"settings.packages.installedProject":`Installed (project)`,"settings.packages.installed":`Installed`,"settings.packages.installAction":`Install`,"settings.packages.installing":`Installing…`,"settings.packages.disable":`Disable`,"settings.packages.enable":`Enable`,"settings.packages.uninstall":`Uninstall`,"settings.packages.uninstallConfirm":`Uninstall`,"settings.packages.enabledStatus":`Enabled`,"settings.packages.disabledStatus":`Disabled`,"settings.agent.instructionsHint":`Global behavioral guidelines`,"settings.agent.orchestrator":`Orchestrator`,"settings.agent.hideUnusedModels":`Hide unused models — only show selected models in dropdowns`,"settings.agent.allModelsVisible":`All models visible`,"settings.agent.modelsSelected":`{n} of {m} models selected`,"settings.agent.selectModels":`Select models`,"settings.agent.searchModels":`Search models…`,"settings.agent.selectAll":`Select All`,"settings.agent.untickAll":`Untick All`,"settings.agent.noModelsMatch":`No models match “{search}”`,"settings.agent.saving":`Saving…`,"settings.agent.saved":`Saved`,"settings.agent.saveSelection":`Save selection`,"settings.agent.cancel":`Cancel`,"settings.agent.orchProvider":`Orch provider`,"settings.agent.orchProviderHint":`Model for supervisor/worker sessions (leave empty to use default)`,"settings.agent.useDefault":`(use default)`,"settings.agent.orchModel":`Orch model`,"settings.agent.orchModelHint":`Model for supervisor/worker sessions`,"settings.skills.title":`Skills`,"settings.skills.loading":`Loading skills…`,"settings.skills.description":`Skills are self-contained capability packages loaded from ~/.pi/agent/skills/ and project skill directories. Toggle individual skills on or off.`,"settings.skills.searchPlaceholder":`Search skills…`,"settings.skills.allCount":`All ({count})`,"settings.skills.sourceGlobal":`Global skill`,"settings.skills.sourceProject":`Project skill`,"settings.skills.sourceExtension":`Extension: {path}`,"settings.skills.edit":`✎ Edit`,"settings.skills.editExtensionDisabled":`Extension skills cannot be edited`,"settings.skills.editSkill":`Edit skill`,"settings.skills.manualOnly":`manual only`,"settings.skills.manualOnlyTitle":`Hidden from system prompt; use /skill:name to invoke`,"settings.skills.projectOn":`project: on`,"settings.skills.projectOff":`project: off`,"settings.skills.projectOverrideActive":`Per-project override active`,"settings.skills.disabled":`disabled`,"settings.skills.diagnosticError":`Error`,"settings.skills.diagnosticCollision":`Collision`,"settings.skills.diagnosticWarning":`Warning`,"settings.skills.diagnosticWinner":`Winner: {path}`,"settings.skills.diagnosticLoser":`Loser: {path}`,"settings.skills.noSkillsMatch":`No skills match “{search}”`,"settings.skills.noSkillsFound":`No skills found.`,"settings.skills.disableAll":`Disable All`,"settings.skills.enableAll":`Enable All`,"settings.skills.editor.loading":`Loading…`,"settings.skills.editor.backToSkills":`← Back to skills`,"settings.skills.editor.back":`← Back`,"settings.skills.editor.description":`Description`,"settings.skills.editor.descriptionPlaceholder":`What does this skill do?`,"settings.skills.editor.instructions":`Instructions`,"settings.skills.editor.edit":`Edit`,"settings.skills.editor.preview":`Preview`,"settings.skills.editor.instructionsPlaceholder":`Skill instructions (Markdown)…`,"settings.skills.editor.save":`Save`,"settings.tunnel.title":`Tunnel`,"settings.mcp.title":`MCP Servers`,"settings.mcp.status":`Running Status`,"settings.mcp.servers":`Servers List`,"settings.mcp.loading":`Loading MCP configuration...`,"settings.mcp.serversConnected":`servers connected`,"settings.mcp.enabled":`Enabled`,"settings.mcp.disabled":`Disabled`,"settings.mcp.tools":`tools`,"settings.mcp.name":`Name`,"settings.mcp.type":`Type`,"settings.mcp.remoteUrl":`Remote URL`,"settings.mcp.command":`Command`,"settings.mcp.args":`Args`,"settings.mcp.workingDirectory":`Working Directory`,"settings.mcp.environmentVariables":`Environment Variables`,"settings.mcp.disabledDesc":`Disabled servers don't connect or contribute tools`,"settings.mcp.url":`URL`,"settings.mcp.transport":`Transport`,"settings.mcp.auto":`Auto`,"settings.mcp.headers":`Headers`,"settings.mcp.addHeader":`+ Header`,"settings.mcp.addEnv":`+ Env`,"settings.mcp.cancel":`Cancel`,"settings.mcp.saveChanges":`Save changes`,"settings.mcp.saving":`Saving...`,"settings.mcp.save":`Save`,"settings.mcp.disable":`Disable`,"settings.mcp.enable":`Enable`,"settings.mcp.delete":`Delete`,"settings.mcp.globalEnabled":`Global: enabled`,"settings.mcp.globalDisabled":`Global: disabled`,"settings.mcp.projectOverride":`Project override`,"settings.mcp.noOverride":`No override`,"settings.packages.install":`📥 Install Package`,"settings.packages.installSubheading":`Install from npm (npm:@org/package), git (git:github.com/...), or a local path.`,"settings.packages.packageSource":`Package source`,"settings.packages.scope":`Scope`,"settings.packages.global":`global`,"settings.packages.project":`project`,"settings.packages.fullInstallSpec":`Full install spec`,"settings.packages.piInstall":`pi install`,"settings.packages.noPackages":`No extension packages configured yet.`,"settings.packages.globalScope":`Global scope`,"settings.packages.projectScope":`Project scope`,"settings.packages.unknown":`unknown`,"settings.packages.checkUpdates":`Check Updates`,"settings.packages.checking":`Checking…`,"settings.packages.updatesAvailable":`update(s) available`,"settings.packages.useUpdateButton":`Use the Update button on each package card above.`,"settings.packages.allUpToDate":`All packages are up to date.`,"settings.packages.visionToolDetected":`pi-vision-tool detected`,"settings.packages.provider":`Provider`,"settings.packages.auto":`auto`,"settings.packages.model":`Model`,"settings.packages.maxDimension":`Max dimension`,"settings.packages.jpegQuality":`JPEG quality`,"settings.packages.reasoning":`Reasoning`,"settings.packages.recommended":`💎 Recommended`,"settings.packages.recommendedSubheading":`Curated extensions optimised for pi-kot.`,"settings.packages.updates":`🔄 Updates`,"settings.packages.update":`Update`,"settings.packages.visionTool":`👁️ Vision Tool Settings`,"settings.packages.visionToolSubheading":`Configure default provider and model for image descriptions.`,"settings.packages.agentReload":`🔄 Agent Reload`,"settings.packages.agentReloadSubheading":`Reload the pi agent configuration (MCP + extension cache) after installing or updating extensions.`,"settings.packages.reloadNow":`Reload Agent Now`,"settings.tunnel.diagnostics":`Diagnostics`,"settings.tunnel.download":`Download`,"settings.tunnel.mode":`mode`,"settings.tunnel.blockers":`Blockers`,"settings.tunnel.provider":`Provider`,"chat.thinking":`Thinking`,"chat.steer":`steer`,"chat.followUp":`follow-up`,"chat.branchSummary":`Branch Summary`,"chat.details":`Details`,"chat.emptyState":`chat with pi coding agent`,"chat.startChatting":`Send a message to start chatting`,"chat.toolInput":`input`,"chat.toolJustification":`Justification`,"chat.groupedTools":`Grouped tools`,"chat.trail":`Trail`,"chat.running":`running…`,"chat.runningShort":`running`,"chat.compacted":`Compacted`,"chat.hideArchived":`Hide archived messages`,"chat.expandArchived":`Expand {count} archived message(s)`,"chat.msg":`msg`,"chat.tok":`tok`,"chat.compaction_cancelled":`Compaction cancelled`,"chat.compaction_failed":`Compaction failed`,"chat.summarizing":`Summarizing…`,"chat.compacting":`Compacting`,"chat.autoCompacting":`Auto-compacting`,"chat.descOverflow":`Context overflow detected. Compressing older messages to make room...`,"chat.descThreshold":`Context usage threshold reached. Compressing older messages...`,"chat.descManual":`Compressing session context...`,"app.noArchived":`No archived sessions — they appear here once archived`,"app.selectSession":`Select or create a session`,"app.startChatting":`to start chatting with the coding agent`,"app.removeProject":`Remove project?`,"artifacts.stream":`Stream`,"artifacts.noStream":`No stream artifacts for this session.`,"artifacts.saved":`Saved`,"artifacts.refreshSaved":`Refresh saved artifacts`,"artifacts.noSaved":`No saved artifacts.`,"artifacts.agentCreated":`Agent-created files in .pi/artifacts/`,"artifacts.selectProject":`Select a project to see saved artifacts`,"artifacts.openNewTab":`Open in new tab (full browser experience)`,"artifacts.justNow":`just now`,"artifacts.mAgo":`m ago`,"artifacts.hAgo":`h ago`,"artifacts.dAgo":`d ago`,"settings.tunnel.status":`Status`,"settings.tunnel.install":`Install: `,"settings.tunnel.active":`Tunnel Active`,"settings.tunnel.copy":`Copy`,"settings.tunnel.copied":`Copied!`,"settings.tunnel.failed":`Failed`,"settings.tunnel.ngrokInstalled":`ngrok installed`,"settings.tunnel.ngrokNotInstalled":`ngrok not installed`,"settings.tunnel.serverListening":`Server listening on`,"settings.tunnel.runDoctor":`Run Doctor`,"settings.tunnel.start":`Start Tunnel`,"settings.tunnel.stop":`Stop Tunnel`,"settings.tunnel.starting":`Starting...`,"settings.tunnel.stopping":`Stopping...`,"settings.addProvider.title":`Add Custom Provider`,"settings.addProvider.stepUrl":`URL & Auth`,"settings.addProvider.stepTesting":`Testing Connection…`,"settings.addProvider.stepModels":`Configure Models`,"settings.addProvider.stepSave":`Provider Added`,"settings.addProvider.baseUrl":`Base URL`,"settings.addProvider.providerName":`Provider Name`,"settings.addProvider.apiKey":`API Key (optional)`,"settings.addProvider.apiType":`API Type`,"settings.addProvider.testing":`Testing…`,"settings.addProvider.testConnection":`Test Connection`,"settings.addProvider.name":`Name`,"settings.addProvider.context":`Context`,"settings.addProvider.maxTokens":`Max tokens`,"settings.addProvider.thinking":`Thinking`,"settings.addProvider.vision":`Vision`,"settings.addProvider.saving":`Saving…`,"settings.addProvider.saveProvider":`Save Provider`,"settings.addProvider.providerAdded":`Provider Added`,"settings.addProvider.providerAddedDesc":`Provider saved successfully. You can now select these models in the chat.`}},No={id:`zh-CN`,label:`简体中文`,messages:{"chat.placeholder":`发送消息...`,"chat.waitingForModel":`等待模型响应...`,"settings.language":`语言`,"settings.systemDefault":`系统默认`,"settings.title":`设置`,"settings.tabs.appearance":`外观`,"settings.tabs.providers":`模型提供商`,"settings.tabs.agent":`智能体`,"settings.tabs.general":`通用`,"settings.tabs.packages":`插件包`,"settings.tabs.skills":`技能`,"settings.tabs.tunnel":`隧道`,"sidebar.newSession":`新会话`,"sidebar.favorites":`★ 收藏`,"sidebar.showMore":`↓ 更多 {count} 个会话`,"sidebar.showMorePlural":`↓ 更多 {count} 个会话`,"sidebar.showLess":`↑ 收起`,"sidebar.noSessions":`暂无会话 — 点击 + 开始`,"sidebar.noMatches":`未找到与 "{query}" 相关的结果`,"sidebar.nav.mcp":`MCP 控制`,"sidebar.nav.settings":`设置`,"sidebar.nav.signOut":`退出登录`,"settings.general.about":`关于`,"settings.general.aboutDesc":`pi-kot — pi 智能体 Web 客户端。`,"settings.general.versions":`版本信息`,"settings.general.server":`pi-kot 服务端`,"settings.general.sdk":`pi SDK`,"settings.general.latestSdk":`最新 SDK`,"settings.general.checkFailed":`检查失败`,"settings.general.updateAvailable":`有可用更新`,"settings.general.upToDate":`已是最新版本`,"settings.general.checking":`正在检查...`,"settings.general.checkAgain":`重新检查`,"settings.general.checkForUpdates":`检查更新`,"settings.appearance.fontSizeHint":`应用于聊天、Markdown和工具,编辑器保持等宽字体。`,"settings.appearance.trailAuto":`自动`,"settings.appearance.trailExpandAll":`全部展开`,"settings.appearance.trailHint":`工具执行轨迹的默认视图,适用于进行中和已完成的执行。`,"settings.appearance.swipeSidebar":`左右滑动打开侧边栏`,"settings.appearance.swipeSidebarHint":`触控屏:水平滑动可以打开或折叠侧边栏。如果滚动时误触可以关闭此功能。`,"settings.appearance.splitFlap":`动态翻页欢迎动画`,"settings.appearance.splitFlapHint":`在空聊天居中显示类似机场的航班显示板,关闭后显示经典的“发送消息”欢迎页。`,"settings.appearance.splitFlapPhrases":`欢迎短语 (以逗号分隔)`,"settings.appearance.splitFlapPhrasesHint":`显示板会在这些短语间翻页切换。按回车或点击外部生效 (在显示板上以大写显示)。`,"settings.general.title":`通用`,"settings.appearance.title":`外观`,"settings.appearance.theme":`主题`,"settings.appearance.accent":`主题色`,"settings.appearance.yourMessageBubble":`消息气泡颜色`,"settings.appearance.chat":`聊天`,"settings.appearance.preferencesSaved":`首选项已在服务端保存(清理缓存后仍保留)。`,"settings.appearance.preferencesLocal":`服务器离线 — 仅保存在本地。`,"settings.appearance.preview":`预览`,"settings.appearance.previewUser":`您的消息将呈现如此样式。`,"settings.appearance.previewAssistant":`助手的回复在此作为参考。`,"settings.appearance.background":`背景`,"settings.appearance.text":`文本`,"settings.appearance.border":`边框`,"settings.appearance.resetDefaults":`恢复默认`,"settings.appearance.stickyUserHeader":`吸顶用户消息头`,"settings.appearance.flyToTop":`飞至顶部`,"settings.appearance.flyToTopDesc":`在流式输出时将您最新的消息固定在顶部附近。回复会在下方延伸,并在填满屏幕后接管自动滚动。`,"settings.appearance.showTokenUsage":`显示 Token 用量`,"settings.appearance.showTurnFiles":`显示此轮生成的文件`,"settings.appearance.showTurnFilesDesc":`在每条回复下方显示智能体写入的文件卡片及该轮的代码差异。`,"settings.appearance.images":`图片`,"settings.appearance.compressImages":`压缩图片`,"settings.appearance.showThinking":`显示思考过程`,"settings.appearance.groupedToolDisplay":`分组工具展示`,"settings.appearance.groupedToolDisplayDesc":`将连续的工具调用(如文件编辑)折叠为单个摘要块。`,"settings.appearance.emptyState":`空状态`,"settings.general.reloadPage":`刷新页面`,"settings.providers.loading":`正在加载模型供应商...`,"settings.providers.description":`包含内置的供应商和 models.json 中的自定义供应商。API 密钥仅显示状态,实际值永远不会发送到浏览器。`,"settings.providers.addCustom":`+ 添加自定义供应商`,"settings.providers.noProviders":`未配置供应商。`,"settings.providers.keySet":`已设置密钥`,"settings.providers.noKey":`无密钥`,"settings.providers.via":`来自`,"settings.providers.replaceKey":`替换密钥`,"settings.providers.addKey":`添加密钥`,"settings.providers.remove":`移除`,"settings.providers.deleteProvider":`删除供应商`,"settings.providers.removeFromModels":`从 models.json 中移除`,"settings.providers.pasteKey":`粘贴 API 密钥`,"settings.providers.save":`保存`,"settings.providers.saving":`保存中...`,"settings.providers.cancel":`取消`,"settings.providers.modelsCount":`个模型`,"settings.providers.deleteProviderConfirm":`确认从 models.json 中移除?重新添加即可撤销此操作。`,"settings.providers.delete":`删除`,"settings.providers.showRaw":`显示 models.json 源码编辑器`,"settings.providers.hideRaw":`隐藏 models.json 源码编辑器`,"settings.providers.reload":`重新加载`,"settings.providers.model.default":`默认`,"settings.providers.model.disabled":`禁用`,"settings.providers.model.custom":`自定义`,"settings.providers.model.id":`ID *`,"settings.providers.model.idPlaceholder":`模型 ID`,"settings.providers.model.name":`名称`,"settings.providers.model.namePlaceholder":`显示名称`,"settings.providers.model.apiOverride":`API 覆盖`,"settings.providers.model.apiDefault":`默认`,"settings.providers.model.apiOpenAiCompat":`OpenAI 兼容`,"settings.providers.model.apiOpenAiResponses":`OpenAI Responses API`,"settings.providers.model.apiAnthropic":`Anthropic Messages API`,"settings.providers.model.apiGoogle":`Google Generative AI`,"settings.providers.model.reasoning":`推理 / 思考`,"settings.providers.model.imageInput":`图像输入`,"settings.providers.model.deepSeekCompat":`DeepSeek 思考模式兼容`,"settings.providers.model.thinkingLevelMap":`思考等级映射`,"settings.providers.model.clearAll":`清除全部`,"settings.providers.model.contextWindow":`上下文窗口 (tokens)`,"settings.providers.model.maxTokens":`最大输出 tokens`,"settings.providers.model.cost":`成本 (每百万 tokens)`,"settings.providers.model.removeModel":`移除模型`,"settings.agent.loading":`正在加载设置...`,"settings.agent.defaultProvider":`默认供应商`,"settings.agent.defaultProviderHint":`选择一个大语言模型供应商`,"settings.agent.defaultModel":`默认模型`,"settings.agent.defaultModelHint":`选择选定供应商提供的模型`,"settings.agent.thinkingLevel":`思考深度`,"settings.agent.thinkingLevelHint":`关闭, 最小, 低, 中等, 高, 极高`,"settings.agent.modelScope":`模型范围`,"settings.packages.title":`扩展包`,"settings.packages.toolsIntegrations":`🛠️ 工具与集成`,"settings.packages.productivity":`⚡ 生产力`,"settings.packages.installedGlobal":`已安装 (全局)`,"settings.packages.installedProject":`已安装 (项目)`,"settings.packages.installed":`已安装`,"settings.packages.installAction":`安装`,"settings.packages.installing":`安装中...`,"settings.packages.disable":`禁用`,"settings.packages.enable":`启用`,"settings.packages.uninstall":`卸载`,"settings.packages.uninstallConfirm":`卸载`,"settings.packages.enabledStatus":`已启用`,"settings.agent.instructionsHint":`全局行为指南`,"settings.agent.orchestrator":`协调者 (Orchestrator)`,"settings.agent.hideUnusedModels":`隐藏未使用的模型 — 仅在下拉菜单中显示已选模型`,"settings.agent.allModelsVisible":`所有模型均可见`,"settings.agent.modelsSelected":`{n} / {m} 个模型已选`,"settings.agent.selectModels":`选择模型`,"settings.agent.searchModels":`搜索模型...`,"settings.agent.selectAll":`全选`,"settings.agent.untickAll":`取消全选`,"settings.agent.noModelsMatch":`没有模型匹配 “{search}”`,"settings.agent.saving":`保存中...`,"settings.agent.saved":`已保存`,"settings.agent.saveSelection":`保存选择`,"settings.agent.cancel":`取消`,"settings.agent.orchProvider":`Orch 供应商`,"settings.agent.orchProviderHint":`监督/工作器会话所使用的模型 (留空则使用默认设置)`,"settings.agent.useDefault":`(使用默认设置)`,"settings.agent.orchModel":`Orch 模型`,"settings.agent.orchModelHint":`监督/工作器会话所使用的模型`,"settings.mcp.title":`MCP 服务器`,"settings.mcp.status":`运行状态`,"settings.mcp.servers":`服务器列表`,"settings.mcp.loading":`正在加载 MCP 配置...`,"settings.mcp.serversConnected":`个服务器已连接`,"settings.mcp.enabled":`已启用`,"settings.mcp.disabledStatus":`已禁用`,"settings.mcp.tools":`个工具`,"settings.mcp.name":`名称`,"settings.mcp.type":`类型`,"settings.mcp.remoteUrl":`远程 URL`,"settings.mcp.command":`命令`,"settings.mcp.args":`参数`,"settings.mcp.workingDirectory":`工作目录`,"settings.mcp.environmentVariables":`环境变量`,"settings.mcp.disabledDesc":`禁用的服务器不会连接或提供工具`,"settings.mcp.url":`URL`,"settings.mcp.transport":`传输协议`,"settings.mcp.auto":`自动`,"settings.mcp.headers":`请求头 (Headers)`,"settings.mcp.addHeader":`+ 请求头`,"settings.mcp.addEnv":`+ 环境变量`,"settings.mcp.cancel":`取消`,"settings.mcp.saveChanges":`保存更改`,"settings.mcp.saving":`保存中...`,"settings.mcp.save":`保存`,"settings.mcp.disable":`禁用`,"settings.mcp.enable":`启用`,"settings.mcp.delete":`删除`,"settings.mcp.globalEnabled":`全局: 已启用`,"settings.mcp.globalDisabled":`全局: 已禁用`,"settings.mcp.projectOverride":`项目级覆盖`,"settings.mcp.noOverride":`无覆盖`,"settings.tunnel.title":`内网穿透`,"settings.tunnel.status":`状态`,"settings.packages.global":`全局`,"settings.packages.project":`项目`,"settings.packages.fullInstallSpec":`完整安装规范`,"settings.packages.piInstall":`pi install`,"settings.packages.noPackages":`尚未配置任何扩展包。`,"settings.packages.globalScope":`全局`,"settings.packages.projectScope":`项目`,"settings.packages.unknown":`未知`,"settings.packages.checkUpdates":`检查更新`,"settings.packages.checking":`检查中...`,"settings.packages.updatesAvailable":`个更新可用`,"settings.packages.useUpdateButton":`请使用上面每个包卡片上的“更新”按钮。`,"settings.packages.allUpToDate":`所有包均已是最新版本。`,"settings.packages.visionToolDetected":`检测到 pi-vision-tool`,"settings.packages.provider":`供应商`,"settings.packages.auto":`自动`,"settings.packages.model":`模型`,"settings.packages.maxDimension":`最大尺寸`,"settings.packages.jpegQuality":`JPEG 质量`,"settings.packages.reasoning":`思考过程`,"settings.packages.recommended":`💎 推荐扩展包`,"settings.packages.recommendedSubheading":`为 pi-kot 优化的精选扩展。`,"settings.packages.updates":`🔄 更新`,"settings.packages.update":`更新`,"settings.packages.visionTool":`👁️ 视觉工具设置`,"settings.packages.visionToolSubheading":`配置用于图像描述的默认供应商和模型。`,"settings.packages.agentReload":`🔄 重启智能体`,"settings.packages.agentReloadSubheading":`在安装或更新扩展后,重新加载智能体配置(MCP + 扩展缓存)。`,"settings.skills.title":`技能`,"settings.skills.loading":`正在加载技能...`,"settings.skills.description":`技能是独立的包,从 ~/.pi/agent/skills/ 和项目技能目录中加载。可以单独开启或关闭技能。`,"settings.skills.searchPlaceholder":`搜索技能...`,"settings.skills.allCount":`全部 ({count})`,"settings.skills.sourceGlobal":`全局技能`,"settings.skills.sourceProject":`项目技能`,"settings.skills.sourceExtension":`扩展: {path}`,"settings.skills.edit":`✎ 编辑`,"settings.skills.editExtensionDisabled":`扩展技能无法编辑`,"settings.skills.editSkill":`编辑技能`,"settings.skills.manualOnly":`仅限手动`,"settings.skills.manualOnlyTitle":`对系统提示词隐藏;使用 /skill:name 调用`,"settings.skills.projectOn":`项目: 开启`,"settings.skills.projectOff":`项目: 关闭`,"settings.skills.projectOverrideActive":`项目级覆盖已激活`,"settings.skills.disabled":`已禁用`,"settings.skills.diagnosticError":`错误`,"settings.skills.diagnosticCollision":`冲突`,"settings.skills.diagnosticWarning":`警告`,"settings.skills.diagnosticWinner":`获胜方: {path}`,"settings.skills.diagnosticLoser":`落败方: {path}`,"settings.skills.noSkillsMatch":`没有技能匹配 “{search}”`,"settings.skills.noSkillsFound":`未找到技能。`,"settings.skills.disableAll":`全部禁用`,"settings.skills.enableAll":`全部启用`,"settings.skills.editor.loading":`加载中...`,"settings.skills.editor.backToSkills":`← 返回技能列表`,"settings.skills.editor.back":`← 返回`,"settings.skills.editor.description":`描述`,"settings.skills.editor.descriptionPlaceholder":`这个技能是做什么的?`,"settings.skills.editor.instructions":`指令`,"settings.skills.editor.edit":`编辑`,"settings.skills.editor.preview":`预览`,"settings.skills.editor.instructionsPlaceholder":`技能指令 (Markdown格式)...`,"settings.skills.editor.save":`保存`,"chat.steer":`引导方向`,"chat.followUp":`追加问题`,"chat.branchSummary":`分支摘要`,"chat.details":`详细信息`,"chat.emptyState":`与 pi 编程智能体聊天`,"chat.startChatting":`发送消息以开始聊天`,"chat.toolInput":`输入参数`,"chat.toolJustification":`推理说明`,"chat.groupedTools":`折叠的工具`,"chat.trail":`工具链`,"chat.running":`运行中...`,"chat.runningShort":`运行中`,"chat.compacted":`已压缩`,"chat.hideArchived":`隐藏已归档消息`,"chat.expandArchived":`展开 {count} 条已归档消息`,"chat.msg":`消息`,"chat.tok":`词元`,"chat.compaction_cancelled":`压缩已取消`,"chat.compaction_failed":`压缩失败`,"chat.summarizing":`生成摘要中...`,"chat.compacting":`压缩中`,"chat.autoCompacting":`自动压缩中`,"chat.descOverflow":`检测到上下文溢出。正在压缩较早的消息以腾出空间...`,"chat.descThreshold":`达到上下文使用阈值。正在压缩较早的消息...`,"chat.descManual":`正在压缩会话上下文...`,"app.noArchived":`没有归档的会话 — 归档后它们将显示在这里`,"app.selectSession":`选择或创建一个会话`,"app.startChatting":`开始与编程智能体聊天`,"app.removeProject":`移除项目?`,"artifacts.stream":`流数据`,"artifacts.noStream":`此会话没有流式组件。`,"artifacts.saved":`已保存`,"artifacts.refreshSaved":`刷新已保存的组件`,"artifacts.noSaved":`没有已保存的组件。`,"artifacts.agentCreated":`.pi/artifacts/ 中智能体创建的文件`,"artifacts.selectProject":`选择一个项目以查看已保存的组件`,"artifacts.openNewTab":`在新标签页中打开(完整浏览器体验)`,"artifacts.justNow":`刚刚`,"artifacts.mAgo":`分钟前`,"artifacts.hAgo":`小时前`,"artifacts.dAgo":`天前`,"settings.addProvider.title":`添加自定义供应商`,"settings.addProvider.stepUrl":`URL 与认证`,"settings.addProvider.stepTesting":`测试连接...`,"settings.addProvider.stepModels":`配置模型`,"settings.addProvider.stepSave":`供应商已添加`,"settings.addProvider.baseUrl":`基础 URL`,"settings.addProvider.providerName":`供应商名称`,"settings.addProvider.apiKey":`API 密钥 (可选)`,"settings.addProvider.apiType":`API 类型`,"settings.addProvider.testing":`测试中...`,"settings.addProvider.testConnection":`测试连接`,"settings.addProvider.name":`名称`,"settings.addProvider.context":`上下文长度`,"settings.addProvider.maxTokens":`最大输出长度`,"settings.addProvider.thinking":`思考过程`,"settings.addProvider.vision":`视觉功能`,"settings.addProvider.saving":`保存中...`,"settings.addProvider.saveProvider":`保存供应商`,"settings.addProvider.providerAdded":`供应商已添加`,"settings.addProvider.providerAddedDesc":`供应商保存成功。您现在可以在对话中选择这些模型。`}},Po=new Map;function Fo(e){if(!e.id.trim())throw Error(`Locale id must not be empty`);if(Po.has(e.id))throw Error(`Locale already registered: ${e.id}`);Po.set(e.id,e)}function Io(e){return Po.get(e)}function Lo(){return[...Po.keys()]}function Ro(e){for(let t of e){let e=t.toLowerCase();if(e===`en`||e.startsWith(`en-`))return`en`;if(e===`zh`||e.startsWith(`zh-`))return`zh-CN`}return`en`}Fo(Mo),Fo(No);function zo(e,t={}){return e.replace(/\{([\w.-]+)\}/g,(e,n)=>{let r=t[n];return r===void 0?e:String(r)})}function Bo(e,t,n,r={}){let i=n[e]?.[t]??n.en?.[t];return i===void 0?t:zo(i,r)}var Vo=`pi-kot/locale`,Ho=`en`,Uo=(0,G.createContext)(null);function Wo(){return Object.fromEntries(Lo().flatMap(e=>{let t=Io(e);return t?[[e,t.messages]]:[]}))}function Go(){try{let e=window.localStorage.getItem(Vo);if(e===`en`||e===`zh-CN`)return e}catch{}return Ro(window.navigator.languages.length?window.navigator.languages:[window.navigator.language])}function Ko({children:e}){let[t,n]=(0,G.useState)(Ho),[r,i]=(0,G.useState)(!1),a=(0,G.useMemo)(()=>Lo().map(e=>Io(e)).filter(e=>!!e),[]),o=(0,G.useMemo)(()=>Wo(),[]);(0,G.useEffect)(()=>{let e=Go();n(e),document.documentElement.lang=e,i(!0)},[]);let s=(0,G.useCallback)(e=>{if(Io(e)){n(e),document.documentElement.lang=e;try{window.localStorage.setItem(Vo,e)}catch{}}},[]),c=(0,G.useCallback)((e,n)=>Bo(t,e,o,n),[t,o]),l=(0,G.useMemo)(()=>({locale:r?t:Ho,setLocale:s,t:c,supportedLocales:a}),[r,t,s,c,a]);return(0,Z.jsx)(Uo.Provider,{value:l,children:e})}function qo(){let e=(0,G.useContext)(Uo);if(!e)throw Error(`useI18n must be used inside I18nProvider`);return e}var Jo=96;function Yo(e){return e.scrollHeight-e.scrollTop-e.clientHeight<=Jo}function Xo(e){let t=e;for(;t instanceof HTMLElement;){let e=window.getComputedStyle(t);if(/(auto|scroll)/.test(e.overflowY))return t;t=t.parentElement}}function Zo({event:e,renderArchived:t}){let{t:n}=qo(),[i,a]=(0,G.useState)(!1),o=new Date(e.timestamp),c=`${o.toLocaleDateString()} ${o.toLocaleTimeString()}`,l=e.archivedMessages.length,u=e.summary.replace(/^(Goal|Summary):\s*/i,``),d=(0,G.useRef)(null),f=e=>{let t=Xo(d.current),n=t!==void 0&&Yo(t);a(e),e&&n&&window.requestAnimationFrame(()=>{t.scrollTop=t.scrollHeight})},p=e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>f(!1),style:{display:`flex`,width:`100%`,alignItems:`center`,justifyContent:`center`,gap:`4px`,padding:`6px 8px`,fontSize:`10px`,textTransform:`uppercase`,letterSpacing:`0.05em`,color:`var(--text-dim)`,background:`transparent`,border:`none`,borderRadius:`var(--radius-sm)`,cursor:`pointer`},title:n(`chat.hideArchived`),"aria-label":`Collapse compaction summary from ${e}`,children:[(0,Z.jsx)(r,{size:11}),n(`chat.collapse`)]});return(0,Z.jsxs)(`div`,{ref:d,style:{margin:`8px 0`,borderRadius:`var(--radius-sm)`,border:`1px solid var(--border)`,background:`var(--bg-glass)`,overflow:`hidden`},children:[i&&(0,Z.jsxs)(`div`,{style:{borderBottom:`1px solid var(--border)`,padding:`12px`},children:[p(`top`),e.summary.length>0&&(0,Z.jsx)(`div`,{style:{margin:`12px 0`,padding:`8px 10px`,borderRadius:`var(--radius-sm)`,background:`var(--bg-glass-strong)`,fontSize:`11px`,lineHeight:`1.6`,color:`var(--text-secondary)`,whiteSpace:`pre-wrap`},children:u}),(0,Z.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`10px`,opacity:.85},children:t?.()}),(0,Z.jsx)(`div`,{style:{marginTop:`12px`},children:p(`bottom`)})]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>f(!i),style:{display:`flex`,width:`100%`,alignItems:`center`,gap:`8px`,padding:`8px 12px`,textAlign:`left`,fontSize:`12px`,color:`var(--text-secondary)`,background:`transparent`,border:`none`,cursor:`pointer`,transition:`background var(--duration) var(--ease)`},onMouseEnter:e=>{e.currentTarget.style.background=`var(--bg-glass-hover)`},onMouseLeave:e=>{e.currentTarget.style.background=`transparent`},title:i?n(`chat.hideArchived`):n(`chat.expandArchived`).replace(`{count}`,l.toString()),children:[i?(0,Z.jsx)(k,{size:12,style:{color:`var(--accent)`}}):(0,Z.jsx)(b,{size:12,style:{color:`var(--accent)`}}),(0,Z.jsx)(s,{size:12,style:{color:`var(--accent)`,flexShrink:0}}),(0,Z.jsx)(`span`,{style:{flex:1,fontWeight:600,color:`var(--text-primary)`,fontFeatureSettings:`'tnum'`},children:n(`chat.compacted`)}),(0,Z.jsxs)(`span`,{style:{fontFamily:`monospace`,fontSize:`10px`,color:`var(--text-dim)`,fontVariantNumeric:`tabular-nums`,whiteSpace:`nowrap`},children:[`-`,l,` `,n(`chat.msg`),` · -`,e.tokensBefore.toLocaleString(),` `,n(`chat.tok`),e.estimatedTokensAfter!==void 0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{style:{margin:`0 2px`,color:`var(--border)`},children:`→`}),`~`,e.estimatedTokensAfter.toLocaleString(),` tok`]})]}),(0,Z.jsx)(`span`,{style:{fontSize:`10px`,color:`var(--text-dim)`,fontVariantNumeric:`tabular-nums`,whiteSpace:`nowrap`},children:c})]}),!i&&e.summary.length>0&&(0,Z.jsx)(`div`,{style:{padding:`0 12px 8px 12px`,fontSize:`11px`,lineHeight:`1.4`,color:`var(--text-dim)`,overflow:`hidden`,whiteSpace:`nowrap`,textOverflow:`ellipsis`},children:u})]})}function Qo(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function $o(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Qo(Object(n),!0).forEach((function(t){es(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Qo(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function es(e,t,n){return(t=function(e){var t=function(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}(e,`string`);return typeof t==`symbol`?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ts(e,t){if(e==null)return{};var n,r,i=function(e,t){if(e==null)return{};var n,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function ns(e,t){return is(e)||function(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}(e,t)||os(e,t)||cs()}function rs(e){return function(e){if(Array.isArray(e))return ss(e)}(e)||as(e)||os(e)||function(){throw TypeError(`Invalid attempt to spread non-iterable instance.
20
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function is(e){if(Array.isArray(e))return e}function as(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function os(e,t){if(e){if(typeof e==`string`)return ss(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ss(e,t):void 0}}function ss(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function cs(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
21
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ls(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=os(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
22
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}var us=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};function ds(e,t){return e(t={exports:{}},t.exports),t.exports}var fs=ds((function(e){(function(){var t={}.hasOwnProperty;function n(){for(var e=[],r=0;r<arguments.length;r++){var i=arguments[r];if(i){var a=typeof i;if(a===`string`||a===`number`)e.push(i);else if(Array.isArray(i)){if(i.length){var o=n.apply(null,i);o&&e.push(o)}}else if(a===`object`){if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes(`[native code]`)){e.push(i.toString());continue}for(var s in i)t.call(i,s)&&i[s]&&e.push(s)}}}return e.join(` `)}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})),ps={hunkClassName:``,lineClassName:``,gutterClassName:``,codeClassName:``,monotonous:!1,gutterType:`default`,viewType:`split`,widgets:{},hideGutter:!1,selectedChanges:[],generateAnchorID:function(){},generateLineClassName:function(){},renderGutter:function(e){var t=e.renderDefault;return(0,e.wrapInAnchor)(t())},codeEvents:{},gutterEvents:{}},ms=(0,G.createContext)(ps),hs=ms.Provider,gs=function(){return(0,G.useContext)(ms)},_s=ds((function(e,t){(function(t){function n(e){var t=e.slice(11),n=null,r=null;switch(t.indexOf(`"`)){case-1:n=(o=t.split(` `))[0].slice(2),r=o[1].slice(2);break;case 0:var i=t.indexOf(`"`,2);n=t.slice(3,i);var a=t.indexOf(`"`,i+1);r=a<0?t.slice(i+4):t.slice(a+3,-1);break;default:var o;n=(o=t.split(` `))[0].slice(2),r=o[1].slice(3,-1)}return{oldPath:n,newPath:r}}e.exports={parse:function(e){for(var t,r,i,a,o,s=[],c=2,l=e.split(`
23
+ `),u=l.length,d=0;d<u;){var f=l[d];if(f.indexOf(`diff --git`)===0){t={hunks:[],oldEndingNewLine:!0,newEndingNewLine:!0,oldPath:(o=n(f)).oldPath,newPath:o.newPath},s.push(t);var p,m=null;simiLoop:for(;p=l[++d];){var h=p.indexOf(` `),g=h>-1?p.slice(0,h):g;switch(g){case`diff`:d--;break simiLoop;case`deleted`:case`new`:var _=p.slice(h+1);_.indexOf(`file mode`)===0&&(t[g===`new`?`newMode`:`oldMode`]=_.slice(10));break;case`similarity`:t.similarity=parseInt(p.split(` `)[2],10);break;case`index`:var v=p.slice(h+1).split(` `),y=v[0].split(`..`);t.oldRevision=y[0],t.newRevision=y[1],v[1]&&(t.oldMode=t.newMode=v[1]);break;case`copy`:case`rename`:var b=p.slice(h+1);b.indexOf(`from`)===0?t.oldPath=b.slice(5):t.newPath=b.slice(3),m=g;break;case`---`:var x=p.slice(h+1),S=l[++d].slice(4);x===`/dev/null`?(S=S.slice(2),m=`add`):S===`/dev/null`?(x=x.slice(2),m=`delete`):(m=`modify`,x=x.slice(2),S=S.slice(2)),x&&(t.oldPath=x),S&&(t.newPath=S),c=5;break simiLoop}}t.type=m||`modify`}else if(f.indexOf(`Binary`)===0)t.isBinary=!0,t.type=f.indexOf(`/dev/null and`)>=0?`add`:f.indexOf(`and /dev/null`)>=0?`delete`:`modify`,c=2,t=null;else if(c===5)if(f.indexOf(`@@`)===0){var C=/^@@\s+-([0-9]+)(,([0-9]+))?\s+\+([0-9]+)(,([0-9]+))?/.exec(f);r={content:f,oldStart:C[1]-0,newStart:C[4]-0,oldLines:C[3]-0||1,newLines:C[6]-0||1,changes:[]},t.hunks.push(r),i=r.oldStart,a=r.newStart}else{var w=f.slice(0,1),T={content:f.slice(1)};switch(w){case`+`:T.type=`insert`,T.isInsert=!0,T.lineNumber=a,a++;break;case`-`:T.type=`delete`,T.isDelete=!0,T.lineNumber=i,i++;break;case` `:T.type=`normal`,T.isNormal=!0,T.oldLineNumber=i,T.newLineNumber=a,i++,a++;break;case`\\`:var E=r.changes[r.changes.length-1];E.isDelete||(t.newEndingNewLine=!1),E.isInsert||(t.oldEndingNewLine=!1)}T.type&&r.changes.push(T)}d++}return s}}})()}));function vs(e){return e.type===`insert`}function ys(e){return e.type===`delete`}function bs(e){return e.type===`normal`}function xs(e,t){var n=t.nearbySequences===`zip`?function(e){return ns(e.reduce((function(e,t,n){var r=ns(e,3),i=r[0],a=r[1],o=r[2];return a?vs(t)&&o>=0?(i.splice(o+1,0,t),[i,t,o+2]):(i.push(t),[i,t,ys(t)&&ys(a)?o:n]):(i.push(t),[i,t,ys(t)?n:-1])}),[[],null,-1]),1)[0]}(e.changes):e.changes;return $o($o({},e),{},{isPlain:!1,changes:n})}function Ss(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=function(e){if(e.startsWith(`diff --git`))return e;var t=e.indexOf(`
24
+ `),n=e.indexOf(`
25
+ `,t+1),r=e.slice(0,t),i=e.slice(t+1,n),a=r.split(` `).slice(1,-3).join(` `),o=i.split(` `).slice(1,-3).join(` `);return[`diff --git a/${a} b/${o}`,`index 1111111..2222222 100644`,`--- a/${a}`,`+++ b/${o}`,e.slice(n+1)].join(`
26
+ `)}(e.trimStart());return _s.parse(n).map((function(e){return function(e,t){var n=e.hunks.map((function(e){return xs(e,t)}));return $o($o({},e),{},{hunks:n})}(e,t)}))}function Cs(e){return e[0]}function ws(e){return e[e.length-1]}function Ts(e){return[`${e}Start`,`${e}Lines`]}function Es(e){return e===`old`?function(e){return vs(e)?-1:bs(e)?e.oldLineNumber:e.lineNumber}:function(e){return ys(e)?-1:bs(e)?e.newLineNumber:e.lineNumber}}function Ds(e,t){return function(n,r){var i=n[e],a=i+n[t];return r>=i&&r<a}}function Os(e,t){return function(n,r,i){var a=n[e]+n[t],o=r[e];return i>=a&&i<o}}function ks(e){var t=Es(e),n=function(e){var t=ns(Ts(e),2),n=Ds(t[0],t[1]);return function(e,t){return e.find((function(e){return n(e,t)}))}}(e);return function(e,r){var i=n(e,r);if(i)return i.changes.find((function(e){return t(e)===r}))}}function As(e){var t=e===`old`?`new`:`old`,n=ns(Ts(e),2),r=n[0],i=n[1],a=ns(Ts(t),2),o=a[0],s=a[1],c=Es(e),l=Es(t),u=Ds(r,i),d=Os(r,i);return function(e,t){var n=Cs(e);if(t<n[r]){var a=n[r]-t;return n[o]-a}var f=ws(e);if(f[r]+f[i]<=t){var p=t-f[r]-f[i];return f[o]+f[s]+p}for(var m=0;m<e.length;m++){var h=e[m],g=e[m+1];if(u(h,t)){var _=h.changes.findIndex((function(e){return c(e)===t})),v=h.changes[_];if(bs(v))return l(v);var y=ys(v)?_+1:_-1,b=h.changes[y];if(!b)return-1;var x=vs(v)?`delete`:`insert`;return b.type===x?l(b):-1}if(d(h,g,t)){var S=t-h[r]-h[i];return h[o]+h[s]+S}}throw Error(`Unexpected line position ${t}`)}}var js=function(){this.__data__=[],this.size=0},Ms=function(e,t){return e===t||e!=e&&t!=t},Ns=function(e,t){for(var n=e.length;n--;)if(Ms(e[n][0],t))return n;return-1},Ps=Array.prototype.splice,Fs=function(e){var t=this.__data__,n=Ns(t,e);return!(n<0)&&(n==t.length-1?t.pop():Ps.call(t,n,1),--this.size,!0)},Is=function(e){var t=this.__data__,n=Ns(t,e);return n<0?void 0:t[n][1]},Ls=function(e){return Ns(this.__data__,e)>-1},Rs=function(e,t){var n=this.__data__,r=Ns(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};function zs(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}zs.prototype.clear=js,zs.prototype.delete=Fs,zs.prototype.get=Is,zs.prototype.has=Ls,zs.prototype.set=Rs;var Bs=zs,Vs=function(){this.__data__=new Bs,this.size=0},Hs=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Us=function(e){return this.__data__.get(e)},Ws=function(e){return this.__data__.has(e)},Gs=typeof us==`object`&&us&&us.Object===Object&&us,Ks=typeof self==`object`&&self&&self.Object===Object&&self,qs=Gs||Ks||Function(`return this`)(),Js=qs.Symbol,Ys=Object.prototype,Xs=Ys.hasOwnProperty,Zs=Ys.toString,Qs=Js?Js.toStringTag:void 0,$s=function(e){var t=Xs.call(e,Qs),n=e[Qs];try{e[Qs]=void 0;var r=!0}catch{}var i=Zs.call(e);return r&&(t?e[Qs]=n:delete e[Qs]),i},ec=Object.prototype.toString,tc=function(e){return ec.call(e)},nc=Js?Js.toStringTag:void 0,rc=function(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:nc&&nc in Object(e)?$s(e):tc(e)},ic=function(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)},ac=function(e){if(!ic(e))return!1;var t=rc(e);return t==`[object Function]`||t==`[object GeneratorFunction]`||t==`[object AsyncFunction]`||t==`[object Proxy]`},oc=qs[`__core-js_shared__`],sc=function(){var e=/[^.]+$/.exec(oc&&oc.keys&&oc.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}(),cc=function(e){return!!sc&&sc in e},lc=Function.prototype.toString,uc=function(e){if(e!=null){try{return lc.call(e)}catch{}try{return e+``}catch{}}return``},dc=/^\[object .+?Constructor\]$/,fc=Function.prototype,pc=Object.prototype,mc=fc.toString,hc=pc.hasOwnProperty,gc=RegExp(`^`+mc.call(hc).replace(/[\\^$.*+?()[\]{}|]/g,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`),_c=function(e){return!(!ic(e)||cc(e))&&(ac(e)?gc:dc).test(uc(e))},vc=function(e,t){return e?.[t]},yc=function(e,t){var n=vc(e,t);return _c(n)?n:void 0},bc=yc(qs,`Map`),xc=yc(Object,`create`),Sc=function(){this.__data__=xc?xc(null):{},this.size=0},Cc=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t},wc=Object.prototype.hasOwnProperty,Tc=function(e){var t=this.__data__;if(xc){var n=t[e];return n===`__lodash_hash_undefined__`?void 0:n}return wc.call(t,e)?t[e]:void 0},Ec=Object.prototype.hasOwnProperty,Dc=function(e){var t=this.__data__;return xc?t[e]!==void 0:Ec.call(t,e)},Oc=function(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=xc&&t===void 0?`__lodash_hash_undefined__`:t,this};function kc(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}kc.prototype.clear=Sc,kc.prototype.delete=Cc,kc.prototype.get=Tc,kc.prototype.has=Dc,kc.prototype.set=Oc;var Ac=kc,jc=function(){this.size=0,this.__data__={hash:new Ac,map:new(bc||Bs),string:new Ac}},Mc=function(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null},Nc=function(e,t){var n=e.__data__;return Mc(t)?n[typeof t==`string`?`string`:`hash`]:n.map},Pc=function(e){var t=Nc(this,e).delete(e);return this.size-=+!!t,t},Fc=function(e){return Nc(this,e).get(e)},Ic=function(e){return Nc(this,e).has(e)},Lc=function(e,t){var n=Nc(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this};function Rc(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Rc.prototype.clear=jc,Rc.prototype.delete=Pc,Rc.prototype.get=Fc,Rc.prototype.has=Ic,Rc.prototype.set=Lc;var zc=Rc,Bc=function(e,t){var n=this.__data__;if(n instanceof Bs){var r=n.__data__;if(!bc||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new zc(r)}return n.set(e,t),this.size=n.size,this};function Vc(e){var t=this.__data__=new Bs(e);this.size=t.size}Vc.prototype.clear=Vs,Vc.prototype.delete=Hs,Vc.prototype.get=Us,Vc.prototype.has=Ws,Vc.prototype.set=Bc;var Hc=Vc,Uc=function(e){return this.__data__.set(e,`__lodash_hash_undefined__`),this},Wc=function(e){return this.__data__.has(e)};function Gc(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new zc;++t<n;)this.add(e[t])}Gc.prototype.add=Gc.prototype.push=Uc,Gc.prototype.has=Wc;var Kc=Gc,qc=function(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1},Jc=function(e,t){return e.has(t)},Yc=function(e,t,n,r,i,a){var o=1&n,s=e.length,c=t.length;if(s!=c&&!(o&&c>s))return!1;var l=a.get(e),u=a.get(t);if(l&&u)return l==t&&u==e;var d=-1,f=!0,p=2&n?new Kc:void 0;for(a.set(e,t),a.set(t,e);++d<s;){var m=e[d],h=t[d];if(r)var g=o?r(h,m,d,t,e,a):r(m,h,d,e,t,a);if(g!==void 0){if(g)continue;f=!1;break}if(p){if(!qc(t,(function(e,t){if(!Jc(p,t)&&(m===e||i(m,e,n,r,a)))return p.push(t)}))){f=!1;break}}else if(m!==h&&!i(m,h,n,r,a)){f=!1;break}}return a.delete(e),a.delete(t),f},Xc=qs.Uint8Array,Zc=function(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n},Qc=function(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n},$c=Js?Js.prototype:void 0,el=$c?$c.valueOf:void 0,tl=function(e,t,n,r,i,a,o){switch(n){case`[object DataView]`:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case`[object ArrayBuffer]`:return!(e.byteLength!=t.byteLength||!a(new Xc(e),new Xc(t)));case`[object Boolean]`:case`[object Date]`:case`[object Number]`:return Ms(+e,+t);case`[object Error]`:return e.name==t.name&&e.message==t.message;case`[object RegExp]`:case`[object String]`:return e==t+``;case`[object Map]`:var s=Zc;case`[object Set]`:var c=1&r;if(s||=Qc,e.size!=t.size&&!c)return!1;var l=o.get(e);if(l)return l==t;r|=2,o.set(e,t);var u=Yc(s(e),s(t),r,i,a,o);return o.delete(e),u;case`[object Symbol]`:if(el)return el.call(e)==el.call(t)}return!1},nl=function(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e},rl=Array.isArray,il=function(e,t,n){var r=t(e);return rl(e)?r:nl(r,n(e))},al=function(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a},ol=function(){return[]},sl=Object.prototype.propertyIsEnumerable,cl=Object.getOwnPropertySymbols,ll=cl?function(e){return e==null?[]:(e=Object(e),al(cl(e),(function(t){return sl.call(e,t)})))}:ol,ul=function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r},dl=function(e){return typeof e==`object`&&!!e},fl=function(e){return dl(e)&&rc(e)==`[object Arguments]`},pl=Object.prototype,ml=pl.hasOwnProperty,hl=pl.propertyIsEnumerable,gl=fl(function(){return arguments}())?fl:function(e){return dl(e)&&ml.call(e,`callee`)&&!hl.call(e,`callee`)},_l=function(){return!1},vl=ds((function(e,t){var n=t&&!t.nodeType&&t,r=n&&e&&!e.nodeType&&e,i=r&&r.exports===n?qs.Buffer:void 0;e.exports=(i?i.isBuffer:void 0)||_l})),yl=/^(?:0|[1-9]\d*)$/,bl=function(e,t){var n=typeof e;return!!(t??=9007199254740991)&&(n==`number`||n!=`symbol`&&yl.test(e))&&e>-1&&e%1==0&&e<t},xl=function(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=9007199254740991},Sl={};Sl[`[object Float32Array]`]=Sl[`[object Float64Array]`]=Sl[`[object Int8Array]`]=Sl[`[object Int16Array]`]=Sl[`[object Int32Array]`]=Sl[`[object Uint8Array]`]=Sl[`[object Uint8ClampedArray]`]=Sl[`[object Uint16Array]`]=Sl[`[object Uint32Array]`]=!0,Sl[`[object Arguments]`]=Sl[`[object Array]`]=Sl[`[object ArrayBuffer]`]=Sl[`[object Boolean]`]=Sl[`[object DataView]`]=Sl[`[object Date]`]=Sl[`[object Error]`]=Sl[`[object Function]`]=Sl[`[object Map]`]=Sl[`[object Number]`]=Sl[`[object Object]`]=Sl[`[object RegExp]`]=Sl[`[object Set]`]=Sl[`[object String]`]=Sl[`[object WeakMap]`]=!1;var Cl=function(e){return dl(e)&&xl(e.length)&&!!Sl[rc(e)]},wl=function(e){return function(t){return e(t)}},Tl=ds((function(e,t){var n=t&&!t.nodeType&&t,r=n&&e&&!e.nodeType&&e,i=r&&r.exports===n&&Gs.process;e.exports=function(){try{return r&&r.require&&r.require(`util`).types||i&&i.binding&&i.binding(`util`)}catch{}}()})),El=Tl&&Tl.isTypedArray,Dl=El?wl(El):Cl,Ol=Object.prototype.hasOwnProperty,kl=function(e,t){var n=rl(e),r=!n&&gl(e),i=!n&&!r&&vl(e),a=!n&&!r&&!i&&Dl(e),o=n||r||i||a,s=o?ul(e.length,String):[],c=s.length;for(var l in e)!t&&!Ol.call(e,l)||o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||bl(l,c))||s.push(l);return s},Al=Object.prototype,jl=function(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||Al)},Ml=function(e,t){return function(n){return e(t(n))}}(Object.keys,Object),Nl=Object.prototype.hasOwnProperty,Pl=function(e){if(!jl(e))return Ml(e);var t=[];for(var n in Object(e))Nl.call(e,n)&&n!=`constructor`&&t.push(n);return t},Fl=function(e){return e!=null&&xl(e.length)&&!ac(e)},Il=function(e){return Fl(e)?kl(e):Pl(e)},Ll=function(e){return il(e,Il,ll)},Rl=Object.prototype.hasOwnProperty,zl=function(e,t,n,r,i,a){var o=1&n,s=Ll(e),c=s.length;if(c!=Ll(t).length&&!o)return!1;for(var l=c;l--;){var u=s[l];if(!(o?u in t:Rl.call(t,u)))return!1}var d=a.get(e),f=a.get(t);if(d&&f)return d==t&&f==e;var p=!0;a.set(e,t),a.set(t,e);for(var m=o;++l<c;){var h=e[u=s[l]],g=t[u];if(r)var _=o?r(g,h,u,t,e,a):r(h,g,u,e,t,a);if(!(_===void 0?h===g||i(h,g,n,r,a):_)){p=!1;break}m||=u==`constructor`}if(p&&!m){var v=e.constructor,y=t.constructor;v==y||!(`constructor`in e)||!(`constructor`in t)||typeof v==`function`&&v instanceof v&&typeof y==`function`&&y instanceof y||(p=!1)}return a.delete(e),a.delete(t),p},Bl=yc(qs,`DataView`),Vl=yc(qs,`Promise`),Hl=yc(qs,`Set`),Ul=yc(qs,`WeakMap`),Wl=uc(Bl),Gl=uc(bc),Kl=uc(Vl),ql=uc(Hl),Jl=uc(Ul),Yl=rc;(Bl&&Yl(new Bl(new ArrayBuffer(1)))!=`[object DataView]`||bc&&Yl(new bc)!=`[object Map]`||Vl&&Yl(Vl.resolve())!=`[object Promise]`||Hl&&Yl(new Hl)!=`[object Set]`||Ul&&Yl(new Ul)!=`[object WeakMap]`)&&(Yl=function(e){var t=rc(e),n=t==`[object Object]`?e.constructor:void 0,r=n?uc(n):``;if(r)switch(r){case Wl:return`[object DataView]`;case Gl:return`[object Map]`;case Kl:return`[object Promise]`;case ql:return`[object Set]`;case Jl:return`[object WeakMap]`}return t});var Xl=Yl,Zl=`[object Object]`,Ql=Object.prototype.hasOwnProperty,$l=function(e,t,n,r,i,a){var o=rl(e),s=rl(t),c=o?`[object Array]`:Xl(e),l=s?`[object Array]`:Xl(t),u=(c=c==`[object Arguments]`?Zl:c)==Zl,d=(l=l==`[object Arguments]`?Zl:l)==Zl,f=c==l;if(f&&vl(e)){if(!vl(t))return!1;o=!0,u=!1}if(f&&!u)return a||=new Hc,o||Dl(e)?Yc(e,t,n,r,i,a):tl(e,t,c,n,r,i,a);if(!(1&n)){var p=u&&Ql.call(e,`__wrapped__`),m=d&&Ql.call(t,`__wrapped__`);if(p||m){var h=p?e.value():e,g=m?t.value():t;return a||=new Hc,i(h,g,n,r,a)}}return!!f&&(a||=new Hc,zl(e,t,n,r,i,a))},eu=function e(t,n,r,i,a){return t===n||(t==null||n==null||!dl(t)&&!dl(n)?t!=t&&n!=n:$l(t,n,r,i,e,a))},tu=function(e,t,n,r){var i=n.length,a=i,o=!r;if(e==null)return!a;for(e=Object(e);i--;){var s=n[i];if(o&&s[2]?s[1]!==e[s[0]]:!(s[0]in e))return!1}for(;++i<a;){var c=(s=n[i])[0],l=e[c],u=s[1];if(o&&s[2]){if(l===void 0&&!(c in e))return!1}else{var d=new Hc;if(r)var f=r(l,u,c,e,t,d);if(!(f===void 0?eu(u,l,3,r,d):f))return!1}}return!0},nu=function(e){return e==e&&!ic(e)},ru=function(e){for(var t=Il(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,nu(i)]}return t},iu=function(e,t){return function(n){return n!=null&&n[e]===t&&(t!==void 0||e in Object(n))}},au=function(e){var t=ru(e);return t.length==1&&t[0][2]?iu(t[0][0],t[0][1]):function(n){return n===e||tu(n,e,t)}},ou=function(e){return typeof e==`symbol`||dl(e)&&rc(e)==`[object Symbol]`},su=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,cu=/^\w*$/,lu=function(e,t){if(rl(e))return!1;var n=typeof e;return!(n!=`number`&&n!=`symbol`&&n!=`boolean`&&e!=null&&!ou(e))||cu.test(e)||!su.test(e)||t!=null&&e in Object(t)};function uu(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(`Expected a function`);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(uu.Cache||zc),n}uu.Cache=zc;var du=uu,fu=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,pu=/\\(\\)?/g,mu=function(e){var t=du(e,(function(e){return n.size===500&&n.clear(),e})),n=t.cache;return t}((function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(fu,(function(e,n,r,i){t.push(r?i.replace(pu,`$1`):n||e)})),t})),hu=function(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i},gu=Js?Js.prototype:void 0,_u=gu?gu.toString:void 0,vu=function e(t){if(typeof t==`string`)return t;if(rl(t))return hu(t,e)+``;if(ou(t))return _u?_u.call(t):``;var n=t+``;return n==`0`&&1/t==-1/0?`-0`:n},yu=function(e){return e==null?``:vu(e)},bu=function(e,t){return rl(e)?e:lu(e,t)?[e]:mu(yu(e))},xu=function(e){if(typeof e==`string`||ou(e))return e;var t=e+``;return t==`0`&&1/e==-1/0?`-0`:t},Su=function(e,t){for(var n=0,r=(t=bu(t,e)).length;e!=null&&n<r;)e=e[xu(t[n++])];return n&&n==r?e:void 0},Cu=function(e,t,n){var r=e==null?void 0:Su(e,t);return r===void 0?n:r},wu=function(e,t){return e!=null&&t in Object(e)},Tu=function(e,t,n){for(var r=-1,i=(t=bu(t,e)).length,a=!1;++r<i;){var o=xu(t[r]);if(!(a=e!=null&&n(e,o)))break;e=e[o]}return a||++r!=i?a:!!(i=e==null?0:e.length)&&xl(i)&&bl(o,i)&&(rl(e)||gl(e))},Eu=function(e,t){return e!=null&&Tu(e,t,wu)},Du=function(e,t){return lu(e)&&nu(t)?iu(xu(e),t):function(n){var r=Cu(n,e);return r===void 0&&r===t?Eu(n,e):eu(t,r,3)}},Ou=function(e){return e},ku=function(e){return function(t){return t?.[e]}},Au=function(e){return function(t){return Su(t,e)}},ju=function(e){return lu(e)?ku(xu(e)):Au(e)},Mu=function(e){return typeof e==`function`?e:e==null?Ou:typeof e==`object`?rl(e)?Du(e[0],e[1]):au(e):ju(e)};function Nu(e){if(!e)throw Error(`change is not provided`);return bs(e)?`N${e.oldLineNumber}`:`${vs(e)?`I`:`D`}${e.lineNumber}`}As(`old`);var Pu=Es(`old`),Fu=Es(`new`);ks(`old`),ks(`new`),As(`new`),As(`old`);var Iu=function(){try{var e=yc(Object,`defineProperty`);return e({},``,{}),e}catch{}}(),Lu=function(e,t,n){t==`__proto__`&&Iu?Iu(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n},Ru=function(e){return function(t,n,r){for(var i=-1,a=Object(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(!1===n(a[c],c,a))break}return t}}(),zu=function(e,t){return e&&Ru(e,t,Il)},Bu=function(e,t){var n={};return t=Mu(t),zu(e,(function(e,r,i){Lu(n,r,t(e,r,i))})),n},Vu=[`changeKey`,`text`,`tokens`,`renderToken`],Hu=function e(t,n){var r=t.type,i=t.value,a=t.markType,o=t.properties,s=t.className,c=t.children,l=function(t){return(0,Z.jsx)(`span`,{className:t,children:i||c&&c.map(e)},n)};switch(r){case`text`:return i;case`mark`:return l(`diff-code-mark diff-code-mark-${a}`);case`edit`:return l(`diff-code-edit`);default:var u=o&&o.className;return l(fs(s||u))}};function Uu(e){if(!Array.isArray(e))return!0;if(e.length>1)return!1;if(e.length===1){var t=ns(e,1)[0];return t.type===`text`&&!t.value}return!0}function Wu(e){var t=e.changeKey,n=e.text,r=e.tokens,i=e.renderToken,a=ts(e,Vu),o=i?function(e,t){return i(e,Hu,t)}:Hu;return(0,Z.jsx)(`td`,$o($o({},a),{},{"data-change-key":t,children:r?Uu(r)?` `:r.map(o):n||` `}))}var Gu=(0,G.memo)(Wu);function Ku(e,t){return function(){var n=t===`old`?Pu(e):Fu(e);return n===-1?void 0:n}}function qu(e,t){return function(n){return e&&n?(0,Z.jsx)(`a`,{href:t?`#`+t:void 0,children:n}):n}}function Ju(e,t){return t?function(n){e(),t(n)}:e}function Yu(e,t,n,r){return(0,G.useMemo)((function(){var i=Bu(e,(function(e){return function(n){return e&&e(t,n)}}));return i.onMouseEnter=Ju(n,i.onMouseEnter),i.onMouseLeave=Ju(r,i.onMouseLeave),i}),[e,n,r,t])}function Xu(e,t,n,r,i,a,o,s,c){var l={change:t,side:r,inHoverState:s,renderDefault:Ku(t,r),wrapInAnchor:qu(i,a)};return(0,Z.jsx)(`td`,$o($o({className:e},o),{},{"data-change-key":n,children:c(l)}))}function Zu(e){var t,n,r,i=e.change,a=e.selected,o=e.tokens,s=e.className,c=e.generateLineClassName,l=e.gutterClassName,u=e.codeClassName,d=e.gutterEvents,f=e.codeEvents,p=e.hideGutter,m=e.gutterAnchor,h=e.generateAnchorID,g=e.renderToken,_=e.renderGutter,v=i.type,y=i.content,b=Nu(i),x=ns((t=ns((0,G.useState)(!1),2),n=t[0],r=t[1],[n,(0,G.useCallback)((function(){return r(!0)}),[]),(0,G.useCallback)((function(){return r(!1)}),[])]),3),S=x[0],C=x[1],w=x[2],T=(0,G.useMemo)((function(){return{change:i}}),[i]),E=Yu(d,T,C,w),D=Yu(f,T,C,w),O=h(i),k=c({changes:[i],defaultGenerate:function(){return s}}),A=fs(`diff-gutter`,`diff-gutter-${v}`,l,{"diff-gutter-selected":a}),j=fs(`diff-code`,`diff-code-${v}`,u,{"diff-code-selected":a});return(0,Z.jsxs)(`tr`,{id:O,className:fs(`diff-line`,k),children:[!p&&Xu(A,i,b,`old`,m,O,E,S,_),!p&&Xu(A,i,b,`new`,m,O,E,S,_),(0,Z.jsx)(Gu,$o({className:j,changeKey:b,text:y,tokens:o,renderToken:g},D))]})}var Qu=(0,G.memo)(Zu);function $u(e){var t=e.hideGutter,n=e.element;return(0,Z.jsx)(`tr`,{className:`diff-widget`,children:(0,Z.jsx)(`td`,{colSpan:t?1:3,className:`diff-widget-content`,children:n})})}var ed=[`hideGutter`,`selectedChanges`,`tokens`,`lineClassName`],td=[`hunk`,`widgets`,`className`];function nd(e){var t=e.hunk,n=e.widgets,r=e.className,i=ts(e,td),a=function(e,t){return e.reduce((function(e,n){var r=Nu(n);e.push([`change`,r,n]);var i=t[r];return i&&e.push([`widget`,r,i]),e}),[])}(t.changes,n);return(0,Z.jsx)(`tbody`,{className:fs(`diff-hunk`,r),children:a.map((function(e){return function(e,t){var n=ns(e,3),r=n[0],i=n[1],a=n[2],o=t.hideGutter,s=t.selectedChanges,c=t.tokens,l=t.lineClassName,u=ts(t,ed);if(r===`change`){var d=ys(a)?`old`:`new`,f=ys(a)?Pu(a):Fu(a),p=c?c[d][f-1]:null;return(0,Z.jsx)(Qu,$o({className:l,change:a,hideGutter:o,selected:s.includes(i),tokens:p},u),`change${i}`)}return r===`widget`?(0,Z.jsx)($u,{hideGutter:o,element:a},`widget${i}`):null}(e,i)}))})}var rd=0;function id(e,t,n,r){var i=(0,G.useCallback)((function(){return t(e)}),[e,t]),a=(0,G.useCallback)((function(){return t(``)}),[t]);return(0,G.useMemo)((function(){var t=Bu(r,(function(t){return function(r){return t&&t({side:e,change:n},r)}}));return t.onMouseEnter=Ju(i,t.onMouseEnter),t.onMouseLeave=Ju(a,t.onMouseLeave),t}),[n,r,i,e,a])}function ad(e){var t=e.change,n=e.side,r=e.selected,i=e.tokens,a=e.gutterClassName,o=e.codeClassName,s=e.gutterEvents,c=e.codeEvents,l=e.anchorID,u=e.gutterAnchor,d=e.gutterAnchorTarget,f=e.hideGutter,p=e.hover,m=e.renderToken,h=e.renderGutter;if(!t){var g=fs(`diff-gutter`,`diff-gutter-omit`,a),_=fs(`diff-code`,`diff-code-omit`,o);return[!f&&(0,Z.jsx)(`td`,{className:g},`gutter`),(0,Z.jsx)(`td`,{className:_},`code`)]}var v=t.type,y=t.content,b=Nu(t),x=n===rd?`old`:`new`,S=$o({id:l||void 0,className:fs(`diff-gutter`,`diff-gutter-${v}`,es({"diff-gutter-selected":r},`diff-line-hover-`+x,p),a),children:h({change:t,side:x,inHoverState:p,renderDefault:Ku(t,x),wrapInAnchor:qu(u,d)})},s),C=fs(`diff-code`,`diff-code-${v}`,es({"diff-code-selected":r},`diff-line-hover-`+x,p),o);return[!f&&(0,Z.jsx)(`td`,$o($o({},S),{},{"data-change-key":b}),`gutter`),(0,Z.jsx)(Gu,$o({className:C,changeKey:b,text:y,tokens:i,renderToken:m},c),`code`)]}function od(e){var t=e.className,n=e.oldChange,r=e.newChange,i=e.oldSelected,a=e.newSelected,o=e.oldTokens,s=e.newTokens,c=e.monotonous,l=e.gutterClassName,u=e.codeClassName,d=e.gutterEvents,f=e.codeEvents,p=e.hideGutter,m=e.generateAnchorID,h=e.generateLineClassName,g=e.gutterAnchor,_=e.renderToken,v=e.renderGutter,y=ns((0,G.useState)(``),2),b=y[0],x=y[1],S=id(`old`,x,n,d),C=id(`new`,x,r,d),w=id(`old`,x,n,f),T=id(`new`,x,r,f),E=n&&m(n),D=r&&m(r),O=h({changes:[n,r],defaultGenerate:function(){return t}}),k={monotonous:c,hideGutter:p,gutterClassName:l,codeClassName:u,gutterEvents:d,codeEvents:f,renderToken:_,renderGutter:v},A=$o($o({},k),{},{change:n,side:rd,selected:i,tokens:o,gutterEvents:S,codeEvents:w,anchorID:E,gutterAnchor:g,gutterAnchorTarget:E,hover:b===`old`}),j=$o($o({},k),{},{change:r,side:1,selected:a,tokens:s,gutterEvents:C,codeEvents:T,anchorID:n===r?null:D,gutterAnchor:g,gutterAnchorTarget:n===r?E:D,hover:b===`new`});return c?(0,Z.jsx)(`tr`,{className:fs(`diff-line`,O),children:ad(n?A:j)}):(0,Z.jsxs)(`tr`,{className:fs(`diff-line`,function(e,t){return e&&!t?`diff-line-old-only`:!e&&t?`diff-line-new-only`:e===t?`diff-line-normal`:`diff-line-compare`}(n,r),O),children:[ad(A),ad(j)]})}var sd=(0,G.memo)(od);function cd(e){var t=e.hideGutter,n=e.oldElement,r=e.newElement;return e.monotonous?(0,Z.jsx)(`tr`,{className:`diff-widget`,children:(0,Z.jsx)(`td`,{colSpan:t?1:2,className:`diff-widget-content`,children:n||r})}):n===r?(0,Z.jsx)(`tr`,{className:`diff-widget`,children:(0,Z.jsx)(`td`,{colSpan:t?2:4,className:`diff-widget-content`,children:n})}):(0,Z.jsxs)(`tr`,{className:`diff-widget`,children:[(0,Z.jsx)(`td`,{colSpan:t?1:2,className:`diff-widget-content`,children:n}),(0,Z.jsx)(`td`,{colSpan:t?1:2,className:`diff-widget-content`,children:r})]})}var ld=[`selectedChanges`,`monotonous`,`hideGutter`,`tokens`,`lineClassName`],ud=[`hunk`,`widgets`,`className`];function dd(e,t){return(e?Nu(e):`00`)+(t?Nu(t):`00`)}function fd(e){var t=e.hunk,n=e.widgets,r=e.className,i=ts(e,ud),a=function(e,t){for(var n=function(e){return e&&t[Nu(e)]||null},r=[],i=0;i<e.length;i++){var a=e[i];if(bs(a))r.push([`change`,dd(a,a),a,a]);else if(ys(a)){var o=e[i+1];o&&vs(o)?(i+=1,r.push([`change`,dd(a,o),a,o])):r.push([`change`,dd(a,null),a,null])}else r.push([`change`,dd(null,a),null,a]);var s=r[r.length-1],c=n(s[2]),l=n(s[3]);if(c||l){var u=s[1];r.push([`widget`,u,c,l])}}return r}(t.changes,n);return(0,Z.jsx)(`tbody`,{className:fs(`diff-hunk`,r),children:a.map((function(e){return function(e,t){var n=ns(e,4),r=n[0],i=n[1],a=n[2],o=n[3],s=t.selectedChanges,c=t.monotonous,l=t.hideGutter,u=t.tokens,d=t.lineClassName,f=ts(t,ld);return r===`change`?(0,Z.jsx)(sd,$o({className:d,oldChange:a,newChange:o,monotonous:c,hideGutter:l,oldSelected:!!a&&s.includes(Nu(a)),newSelected:!!o&&s.includes(Nu(o)),oldTokens:a&&u?u.old[Pu(a)-1]:null,newTokens:o&&u?u.new[Fu(o)-1]:null},f),`change${i}`):r===`widget`?(0,Z.jsx)(cd,{monotonous:c,hideGutter:l,oldElement:a,newElement:o},`widget${i}`):null}(e,i)}))})}var pd=[`gutterType`,`hunkClassName`];function md(e){var t=e.hunk,n=gs(),r=n.gutterType,i=n.hunkClassName,a=ts(n,pd),o=r===`none`,s=r===`anchor`;return(0,Z.jsx)(a.viewType===`unified`?nd:fd,$o($o({},a),{},{hunk:t,hideGutter:o,gutterAnchor:s,className:i}))}function hd(){}function gd(e,t){var n=t?`auto`:`none`;e instanceof HTMLElement&&e.style.userSelect!==n&&(e.style.userSelect=n)}function _d(e){return e.map((function(e){return(0,Z.jsx)(md,{hunk:e},function(e){return`-${e.oldStart},${e.oldLines} +${e.newStart},${e.newLines}`}(e))}))}function vd(e){var t=e.diffType,n=e.hunks,r=e.optimizeSelection,i=e.className,a=e.hunkClassName,o=a===void 0?ps.hunkClassName:a,s=e.lineClassName,c=s===void 0?ps.lineClassName:s,l=e.generateLineClassName,u=l===void 0?ps.generateLineClassName:l,d=e.gutterClassName,f=d===void 0?ps.gutterClassName:d,p=e.codeClassName,m=p===void 0?ps.codeClassName:p,h=e.gutterType,g=h===void 0?ps.gutterType:h,_=e.viewType,v=_===void 0?ps.viewType:_,y=e.gutterEvents,b=y===void 0?ps.gutterEvents:y,x=e.codeEvents,S=x===void 0?ps.codeEvents:x,C=e.generateAnchorID,w=C===void 0?ps.generateAnchorID:C,T=e.selectedChanges,E=T===void 0?ps.selectedChanges:T,D=e.widgets,O=D===void 0?ps.widgets:D,k=e.renderGutter,A=k===void 0?ps.renderGutter:k,j=e.tokens,M=e.renderToken,N=e.children,P=N===void 0?_d:N,F=(0,G.useRef)(null),I=(0,G.useCallback)((function(e){var t=e.target;if(e.button===0){var n=function(e,t){for(var n=e;n&&n!==document.documentElement&&!n.classList.contains(t);)n=n.parentElement;return n===document.documentElement?null:n}(t,`diff-code`);if(n&&n.parentElement){var r=window.getSelection();r&&r.removeAllRanges();var i=rs(n.parentElement.children).indexOf(n);if(i===1||i===3){var a,o=ls(F.current?F.current.querySelectorAll(`.diff-line`):[]);try{for(o.s();!(a=o.n()).done;){var s=a.value.children;gd(s[1],i===1),gd(s[3],i===3)}}catch(e){o.e(e)}finally{o.f()}}}}}),[]),L=g===`none`,R=t===`add`||t===`delete`,z=v===`split`&&!R&&r?I:hd,ee=(0,G.useMemo)((function(){return(0,Z.jsxs)(`colgroup`,v===`unified`?{children:[!L&&(0,Z.jsx)(`col`,{className:`diff-gutter-col`}),!L&&(0,Z.jsx)(`col`,{className:`diff-gutter-col`}),(0,Z.jsx)(`col`,{})]}:R?{children:[!L&&(0,Z.jsx)(`col`,{className:`diff-gutter-col`}),(0,Z.jsx)(`col`,{})]}:{children:[!L&&(0,Z.jsx)(`col`,{className:`diff-gutter-col`}),(0,Z.jsx)(`col`,{}),!L&&(0,Z.jsx)(`col`,{className:`diff-gutter-col`}),(0,Z.jsx)(`col`,{})]})}),[v,R,L]);return(0,Z.jsx)(hs,{value:(0,G.useMemo)((function(){return{hunkClassName:o,lineClassName:c,generateLineClassName:u,gutterClassName:f,codeClassName:m,monotonous:R,hideGutter:L,viewType:v,gutterType:g,codeEvents:S,gutterEvents:b,generateAnchorID:w,selectedChanges:E,widgets:O,renderGutter:A,tokens:j,renderToken:M}}),[m,S,w,f,b,g,L,o,c,u,R,A,M,E,j,v,O]),children:(0,Z.jsxs)(`table`,{ref:F,className:fs(`diff`,`diff-${v}`,i),onMouseDown:z,children:[ee,P(n)]})})}var yd=(0,G.memo)(vd);function bd(e){var t=e.hideGutter,n=e.monotonous,r=e.className,i=e.gutterClassName,a=e.contentClassName,o=e.children,s=fs(`diff-decoration`,r),c=fs(`diff-decoration-gutter`,i),l=fs(`diff-decoration-content`,a),u=(t?2:4)/(n?2:1),d=u-+!t;if(G.Children.count(o)===1)return(0,Z.jsx)(`tbody`,{className:s,children:(0,Z.jsx)(`tr`,{children:(0,Z.jsx)(`td`,{colSpan:u,className:l,children:o})})});var f=ns(o,2),p=f[0],m=f[1];return(0,Z.jsx)(`tbody`,{className:s,children:(0,Z.jsxs)(`tr`,{children:[!t&&(0,Z.jsx)(`td`,{className:c,children:p}),(0,Z.jsx)(`td`,{colSpan:d,className:l,children:m})]})})}function xd(e){var t=e.hideGutter,n=e.className,r=e.gutterClassName,i=e.contentClassName,a=e.children,o=fs(`diff-decoration`,n),s=fs(`diff-decoration-gutter`,r),c=fs(`diff-decoration-content`,i);if(G.Children.count(a)===1)return(0,Z.jsx)(`tbody`,{className:o,children:(0,Z.jsx)(`tr`,{children:(0,Z.jsx)(`td`,{colSpan:t?1:3,className:c,children:a})})});var l=ns(a,2),u=l[0],d=l[1];return(0,Z.jsx)(`tbody`,{className:o,children:(0,Z.jsxs)(`tr`,{children:[!t&&(0,Z.jsx)(`td`,{colSpan:2,className:s,children:u}),(0,Z.jsx)(`td`,{className:c,children:d})]})})}function Sd(e){var t=e.className,n=t===void 0?``:t,r=e.gutterClassName,i=r===void 0?``:r,a=e.contentClassName,o=a===void 0?``:a,s=e.children,c=gs(),l=c.viewType,u=c.gutterType,d=c.monotonous,f=l===`split`?bd:xd;G.Children.count(s);var p=u===`none`;return(0,Z.jsx)(f,{hideGutter:p,monotonous:d,className:n,gutterClassName:i,contentClassName:o,children:s})}(function(e,t){return function(n,r){if(n==null)return n;if(!Fl(n))return e(n,r);for(var i=n.length,a=t?i:-1,o=Object(n);(t?a--:++a<i)&&!1!==r(o[a],a,o););return n}})(zu),Js&&Js.isConcatSpreadable;var Cd=ds((function(e){var t=function(){this.Diff_Timeout=1,this.Diff_EditCost=4,this.Match_Threshold=.5,this.Match_Distance=1e3,this.Patch_DeleteThreshold=.5,this.Patch_Margin=4,this.Match_MaxBits=32};t.Diff=function(e,t){return[e,t]},t.prototype.diff_main=function(e,n,r,i){i===void 0&&(i=this.Diff_Timeout<=0?Number.MAX_VALUE:new Date().getTime()+1e3*this.Diff_Timeout);var a=i;if(e==null||n==null)throw Error(`Null input. (diff_main)`);if(e==n)return e?[new t.Diff(0,e)]:[];r===void 0&&(r=!0);var o=r,s=this.diff_commonPrefix(e,n),c=e.substring(0,s);e=e.substring(s),n=n.substring(s),s=this.diff_commonSuffix(e,n);var l=e.substring(e.length-s);e=e.substring(0,e.length-s),n=n.substring(0,n.length-s);var u=this.diff_compute_(e,n,o,a);return c&&u.unshift(new t.Diff(0,c)),l&&u.push(new t.Diff(0,l)),this.diff_cleanupMerge(u),u},t.prototype.diff_compute_=function(e,n,r,i){var a;if(!e)return[new t.Diff(1,n)];if(!n)return[new t.Diff(-1,e)];var o=e.length>n.length?e:n,s=e.length>n.length?n:e,c=o.indexOf(s);if(c!=-1)return a=[new t.Diff(1,o.substring(0,c)),new t.Diff(0,s),new t.Diff(1,o.substring(c+s.length))],e.length>n.length&&(a[0][0]=a[2][0]=-1),a;if(s.length==1)return[new t.Diff(-1,e),new t.Diff(1,n)];var l=this.diff_halfMatch_(e,n);if(l){var u=l[0],d=l[1],f=l[2],p=l[3],m=l[4],h=this.diff_main(u,f,r,i),g=this.diff_main(d,p,r,i);return h.concat([new t.Diff(0,m)],g)}return r&&e.length>100&&n.length>100?this.diff_lineMode_(e,n,i):this.diff_bisect_(e,n,i)},t.prototype.diff_lineMode_=function(e,n,r){var i=this.diff_linesToChars_(e,n);e=i.chars1,n=i.chars2;var a=i.lineArray,o=this.diff_main(e,n,!1,r);this.diff_charsToLines_(o,a),this.diff_cleanupSemantic(o),o.push(new t.Diff(0,``));for(var s=0,c=0,l=0,u=``,d=``;s<o.length;){switch(o[s][0]){case 1:l++,d+=o[s][1];break;case-1:c++,u+=o[s][1];break;case 0:if(c>=1&&l>=1){o.splice(s-c-l,c+l),s=s-c-l;for(var f=this.diff_main(u,d,!1,r),p=f.length-1;p>=0;p--)o.splice(s,0,f[p]);s+=f.length}l=0,c=0,u=``,d=``}s++}return o.pop(),o},t.prototype.diff_bisect_=function(e,n,r){for(var i=e.length,a=n.length,o=Math.ceil((i+a)/2),s=o,c=2*o,l=Array(c),u=Array(c),d=0;d<c;d++)l[d]=-1,u[d]=-1;l[s+1]=0,u[s+1]=0;for(var f=i-a,p=f%2!=0,m=0,h=0,g=0,_=0,v=0;v<o&&!(new Date().getTime()>r);v++){for(var y=-v+m;y<=v-h;y+=2){for(var b=s+y,x=(E=y==-v||y!=v&&l[b-1]<l[b+1]?l[b+1]:l[b-1]+1)-y;E<i&&x<a&&e.charAt(E)==n.charAt(x);)E++,x++;if(l[b]=E,E>i)h+=2;else if(x>a)m+=2;else if(p&&(w=s+f-y)>=0&&w<c&&u[w]!=-1&&E>=(C=i-u[w]))return this.diff_bisectSplit_(e,n,E,x,r)}for(var S=-v+g;S<=v-_;S+=2){for(var C,w=s+S,T=(C=S==-v||S!=v&&u[w-1]<u[w+1]?u[w+1]:u[w-1]+1)-S;C<i&&T<a&&e.charAt(i-C-1)==n.charAt(a-T-1);)C++,T++;if(u[w]=C,C>i)_+=2;else if(T>a)g+=2;else if(!p&&(b=s+f-S)>=0&&b<c&&l[b]!=-1){var E;if(x=s+(E=l[b])-b,E>=(C=i-C))return this.diff_bisectSplit_(e,n,E,x,r)}}}return[new t.Diff(-1,e),new t.Diff(1,n)]},t.prototype.diff_bisectSplit_=function(e,t,n,r,i){var a=e.substring(0,n),o=t.substring(0,r),s=e.substring(n),c=t.substring(r),l=this.diff_main(a,o,!1,i),u=this.diff_main(s,c,!1,i);return l.concat(u)},t.prototype.diff_linesToChars_=function(e,t){var n=[],r={};function i(e){for(var t=``,i=0,o=-1,s=n.length;o<e.length-1;){(o=e.indexOf(`
27
+ `,i))==-1&&(o=e.length-1);var c=e.substring(i,o+1);(r.hasOwnProperty?r.hasOwnProperty(c):r[c]!==void 0)?t+=String.fromCharCode(r[c]):(s==a&&(c=e.substring(i),o=e.length),t+=String.fromCharCode(s),r[c]=s,n[s++]=c),i=o+1}return t}n[0]=``;var a=4e4,o=i(e);return a=65535,{chars1:o,chars2:i(t),lineArray:n}},t.prototype.diff_charsToLines_=function(e,t){for(var n=0;n<e.length;n++){for(var r=e[n][1],i=[],a=0;a<r.length;a++)i[a]=t[r.charCodeAt(a)];e[n][1]=i.join(``)}},t.prototype.diff_commonPrefix=function(e,t){if(!e||!t||e.charAt(0)!=t.charAt(0))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,a=0;n<i;)e.substring(a,i)==t.substring(a,i)?a=n=i:r=i,i=Math.floor((r-n)/2+n);return i},t.prototype.diff_commonSuffix=function(e,t){if(!e||!t||e.charAt(e.length-1)!=t.charAt(t.length-1))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,a=0;n<i;)e.substring(e.length-i,e.length-a)==t.substring(t.length-i,t.length-a)?a=n=i:r=i,i=Math.floor((r-n)/2+n);return i},t.prototype.diff_commonOverlap_=function(e,t){var n=e.length,r=t.length;if(n==0||r==0)return 0;n>r?e=e.substring(n-r):n<r&&(t=t.substring(0,n));var i=Math.min(n,r);if(e==t)return i;for(var a=0,o=1;;){var s=e.substring(i-o),c=t.indexOf(s);if(c==-1)return a;o+=c,c!=0&&e.substring(i-o)!=t.substring(0,o)||(a=o,o++)}},t.prototype.diff_halfMatch_=function(e,t){if(this.Diff_Timeout<=0)return null;var n=e.length>t.length?e:t,r=e.length>t.length?t:e;if(n.length<4||2*r.length<n.length)return null;var i=this;function a(e,t,n){for(var r,a,o,s,c=e.substring(n,n+Math.floor(e.length/4)),l=-1,u=``;(l=t.indexOf(c,l+1))!=-1;){var d=i.diff_commonPrefix(e.substring(n),t.substring(l)),f=i.diff_commonSuffix(e.substring(0,n),t.substring(0,l));u.length<f+d&&(u=t.substring(l-f,l)+t.substring(l,l+d),r=e.substring(0,n-f),a=e.substring(n+d),o=t.substring(0,l-f),s=t.substring(l+d))}return 2*u.length>=e.length?[r,a,o,s,u]:null}var o,s,c,l,u,d=a(n,r,Math.ceil(n.length/4)),f=a(n,r,Math.ceil(n.length/2));return d||f?(o=f?d&&d[4].length>f[4].length?d:f:d,e.length>t.length?(s=o[0],c=o[1],l=o[2],u=o[3]):(l=o[0],u=o[1],s=o[2],c=o[3]),[s,c,l,u,o[4]]):null},t.prototype.diff_cleanupSemantic=function(e){for(var n=!1,r=[],i=0,a=null,o=0,s=0,c=0,l=0,u=0;o<e.length;)e[o][0]==0?(r[i++]=o,s=l,c=u,l=0,u=0,a=e[o][1]):(e[o][0]==1?l+=e[o][1].length:u+=e[o][1].length,a&&a.length<=Math.max(s,c)&&a.length<=Math.max(l,u)&&(e.splice(r[i-1],0,new t.Diff(-1,a)),e[r[i-1]+1][0]=1,i--,o=--i>0?r[i-1]:-1,s=0,c=0,l=0,u=0,a=null,n=!0)),o++;for(n&&this.diff_cleanupMerge(e),this.diff_cleanupSemanticLossless(e),o=1;o<e.length;){if(e[o-1][0]==-1&&e[o][0]==1){var d=e[o-1][1],f=e[o][1],p=this.diff_commonOverlap_(d,f),m=this.diff_commonOverlap_(f,d);p>=m?(p>=d.length/2||p>=f.length/2)&&(e.splice(o,0,new t.Diff(0,f.substring(0,p))),e[o-1][1]=d.substring(0,d.length-p),e[o+1][1]=f.substring(p),o++):(m>=d.length/2||m>=f.length/2)&&(e.splice(o,0,new t.Diff(0,d.substring(0,m))),e[o-1][0]=1,e[o-1][1]=f.substring(0,f.length-m),e[o+1][0]=-1,e[o+1][1]=d.substring(m),o++),o++}o++}},t.prototype.diff_cleanupSemanticLossless=function(e){function n(e,n){if(!e||!n)return 6;var r=e.charAt(e.length-1),i=n.charAt(0),a=r.match(t.nonAlphaNumericRegex_),o=i.match(t.nonAlphaNumericRegex_),s=a&&r.match(t.whitespaceRegex_),c=o&&i.match(t.whitespaceRegex_),l=s&&r.match(t.linebreakRegex_),u=c&&i.match(t.linebreakRegex_),d=l&&e.match(t.blanklineEndRegex_),f=u&&n.match(t.blanklineStartRegex_);return d||f?5:l||u?4:a&&!s&&c?3:s||c?2:a||o?1:0}for(var r=1;r<e.length-1;){if(e[r-1][0]==0&&e[r+1][0]==0){var i=e[r-1][1],a=e[r][1],o=e[r+1][1],s=this.diff_commonSuffix(i,a);if(s){var c=a.substring(a.length-s);i=i.substring(0,i.length-s),a=c+a.substring(0,a.length-s),o=c+o}for(var l=i,u=a,d=o,f=n(i,a)+n(a,o);a.charAt(0)===o.charAt(0);){i+=a.charAt(0),a=a.substring(1)+o.charAt(0),o=o.substring(1);var p=n(i,a)+n(a,o);p>=f&&(f=p,l=i,u=a,d=o)}e[r-1][1]!=l&&(l?e[r-1][1]=l:(e.splice(r-1,1),r--),e[r][1]=u,d?e[r+1][1]=d:(e.splice(r+1,1),r--))}r++}},t.nonAlphaNumericRegex_=/[^a-zA-Z0-9]/,t.whitespaceRegex_=/\s/,t.linebreakRegex_=/[\r\n]/,t.blanklineEndRegex_=/\n\r?\n$/,t.blanklineStartRegex_=/^\r?\n\r?\n/,t.prototype.diff_cleanupEfficiency=function(e){for(var n=!1,r=[],i=0,a=null,o=0,s=!1,c=!1,l=!1,u=!1;o<e.length;)e[o][0]==0?(e[o][1].length<this.Diff_EditCost&&(l||u)?(r[i++]=o,s=l,c=u,a=e[o][1]):(i=0,a=null),l=u=!1):(e[o][0]==-1?u=!0:l=!0,a&&(s&&c&&l&&u||a.length<this.Diff_EditCost/2&&s+c+l+u==3)&&(e.splice(r[i-1],0,new t.Diff(-1,a)),e[r[i-1]+1][0]=1,i--,a=null,s&&c?(l=u=!0,i=0):(o=--i>0?r[i-1]:-1,l=u=!1),n=!0)),o++;n&&this.diff_cleanupMerge(e)},t.prototype.diff_cleanupMerge=function(e){e.push(new t.Diff(0,``));for(var n,r=0,i=0,a=0,o=``,s=``;r<e.length;)switch(e[r][0]){case 1:a++,s+=e[r][1],r++;break;case-1:i++,o+=e[r][1],r++;break;case 0:i+a>1?(i!==0&&a!==0&&((n=this.diff_commonPrefix(s,o))!==0&&(r-i-a>0&&e[r-i-a-1][0]==0?e[r-i-a-1][1]+=s.substring(0,n):(e.splice(0,0,new t.Diff(0,s.substring(0,n))),r++),s=s.substring(n),o=o.substring(n)),(n=this.diff_commonSuffix(s,o))!==0&&(e[r][1]=s.substring(s.length-n)+e[r][1],s=s.substring(0,s.length-n),o=o.substring(0,o.length-n))),r-=i+a,e.splice(r,i+a),o.length&&(e.splice(r,0,new t.Diff(-1,o)),r++),s.length&&(e.splice(r,0,new t.Diff(1,s)),r++),r++):r!==0&&e[r-1][0]==0?(e[r-1][1]+=e[r][1],e.splice(r,1)):r++,a=0,i=0,o=``,s=``}e[e.length-1][1]===``&&e.pop();var c=!1;for(r=1;r<e.length-1;)e[r-1][0]==0&&e[r+1][0]==0&&(e[r][1].substring(e[r][1].length-e[r-1][1].length)==e[r-1][1]?(e[r][1]=e[r-1][1]+e[r][1].substring(0,e[r][1].length-e[r-1][1].length),e[r+1][1]=e[r-1][1]+e[r+1][1],e.splice(r-1,1),c=!0):e[r][1].substring(0,e[r+1][1].length)==e[r+1][1]&&(e[r-1][1]+=e[r+1][1],e[r][1]=e[r][1].substring(e[r+1][1].length)+e[r+1][1],e.splice(r+1,1),c=!0)),r++;c&&this.diff_cleanupMerge(e)},t.prototype.diff_xIndex=function(e,t){var n,r=0,i=0,a=0,o=0;for(n=0;n<e.length&&(e[n][0]!==1&&(r+=e[n][1].length),e[n][0]!==-1&&(i+=e[n][1].length),!(r>t));n++)a=r,o=i;return e.length!=n&&e[n][0]===-1?o:o+(t-a)},t.prototype.diff_prettyHtml=function(e){for(var t=[],n=/&/g,r=/</g,i=/>/g,a=/\n/g,o=0;o<e.length;o++){var s=e[o][0],c=e[o][1].replace(n,`&amp;`).replace(r,`&lt;`).replace(i,`&gt;`).replace(a,`&para;<br>`);switch(s){case 1:t[o]=`<ins style="background:#e6ffe6;">`+c+`</ins>`;break;case-1:t[o]=`<del style="background:#ffe6e6;">`+c+`</del>`;break;case 0:t[o]=`<span>`+c+`</span>`}}return t.join(``)},t.prototype.diff_text1=function(e){for(var t=[],n=0;n<e.length;n++)e[n][0]!==1&&(t[n]=e[n][1]);return t.join(``)},t.prototype.diff_text2=function(e){for(var t=[],n=0;n<e.length;n++)e[n][0]!==-1&&(t[n]=e[n][1]);return t.join(``)},t.prototype.diff_levenshtein=function(e){for(var t=0,n=0,r=0,i=0;i<e.length;i++){var a=e[i][0],o=e[i][1];switch(a){case 1:n+=o.length;break;case-1:r+=o.length;break;case 0:t+=Math.max(n,r),n=0,r=0}}return t+=Math.max(n,r)},t.prototype.diff_toDelta=function(e){for(var t=[],n=0;n<e.length;n++)switch(e[n][0]){case 1:t[n]=`+`+encodeURI(e[n][1]);break;case-1:t[n]=`-`+e[n][1].length;break;case 0:t[n]=`=`+e[n][1].length}return t.join(` `).replace(/%20/g,` `)},t.prototype.diff_fromDelta=function(e,n){for(var r=[],i=0,a=0,o=n.split(/\t/g),s=0;s<o.length;s++){var c=o[s].substring(1);switch(o[s].charAt(0)){case`+`:try{r[i++]=new t.Diff(1,decodeURI(c))}catch{throw Error(`Illegal escape in diff_fromDelta: `+c)}break;case`-`:case`=`:var l=parseInt(c,10);if(isNaN(l)||l<0)throw Error(`Invalid number in diff_fromDelta: `+c);var u=e.substring(a,a+=l);o[s].charAt(0)==`=`?r[i++]=new t.Diff(0,u):r[i++]=new t.Diff(-1,u);break;default:if(o[s])throw Error(`Invalid diff operation in diff_fromDelta: `+o[s])}}if(a!=e.length)throw Error(`Delta length (`+a+`) does not equal source text length (`+e.length+`).`);return r},t.prototype.match_main=function(e,t,n){if(e==null||t==null||n==null)throw Error(`Null input. (match_main)`);return n=Math.max(0,Math.min(n,e.length)),e==t?0:e.length?e.substring(n,n+t.length)==t?n:this.match_bitap_(e,t,n):-1},t.prototype.match_bitap_=function(e,t,n){if(t.length>this.Match_MaxBits)throw Error(`Pattern too long for this browser.`);var r=this.match_alphabet_(t),i=this;function a(e,r){var a=e/t.length,o=Math.abs(n-r);return i.Match_Distance?a+o/i.Match_Distance:o?1:a}var o=this.Match_Threshold,s=e.indexOf(t,n);s!=-1&&(o=Math.min(a(0,s),o),(s=e.lastIndexOf(t,n+t.length))!=-1&&(o=Math.min(a(0,s),o)));var c,l,u=1<<t.length-1;s=-1;for(var d,f=t.length+e.length,p=0;p<t.length;p++){for(c=0,l=f;c<l;)a(p,n+l)<=o?c=l:f=l,l=Math.floor((f-c)/2+c);f=l;var m=Math.max(1,n-l+1),h=Math.min(n+l,e.length)+t.length,g=Array(h+2);g[h+1]=(1<<p)-1;for(var _=h;_>=m;_--){var v=r[e.charAt(_-1)];if(g[_]=p===0?(g[_+1]<<1|1)&v:(g[_+1]<<1|1)&v|(d[_+1]|d[_])<<1|1|d[_+1],g[_]&u){var y=a(p,_-1);if(y<=o){if(o=y,!((s=_-1)>n))break;m=Math.max(1,2*n-s)}}}if(a(p+1,n)>o)break;d=g}return s},t.prototype.match_alphabet_=function(e){for(var t={},n=0;n<e.length;n++)t[e.charAt(n)]=0;for(n=0;n<e.length;n++)t[e.charAt(n)]|=1<<e.length-n-1;return t},t.prototype.patch_addContext_=function(e,n){if(n.length!=0){if(e.start2===null)throw Error(`patch not initialized`);for(var r=n.substring(e.start2,e.start2+e.length1),i=0;n.indexOf(r)!=n.lastIndexOf(r)&&r.length<this.Match_MaxBits-this.Patch_Margin-this.Patch_Margin;)i+=this.Patch_Margin,r=n.substring(e.start2-i,e.start2+e.length1+i);i+=this.Patch_Margin;var a=n.substring(e.start2-i,e.start2);a&&e.diffs.unshift(new t.Diff(0,a));var o=n.substring(e.start2+e.length1,e.start2+e.length1+i);o&&e.diffs.push(new t.Diff(0,o)),e.start1-=a.length,e.start2-=a.length,e.length1+=a.length+o.length,e.length2+=a.length+o.length}},t.prototype.patch_make=function(e,n,r){var i,a;if(typeof e==`string`&&typeof n==`string`&&r===void 0)i=e,(a=this.diff_main(i,n,!0)).length>2&&(this.diff_cleanupSemantic(a),this.diff_cleanupEfficiency(a));else if(e&&typeof e==`object`&&n===void 0&&r===void 0)a=e,i=this.diff_text1(a);else if(typeof e==`string`&&n&&typeof n==`object`&&r===void 0)i=e,a=n;else{if(typeof e!=`string`||typeof n!=`string`||!r||typeof r!=`object`)throw Error(`Unknown call format to patch_make.`);i=e,a=r}if(a.length===0)return[];for(var o=[],s=new t.patch_obj,c=0,l=0,u=0,d=i,f=i,p=0;p<a.length;p++){var m=a[p][0],h=a[p][1];switch(c||m===0||(s.start1=l,s.start2=u),m){case 1:s.diffs[c++]=a[p],s.length2+=h.length,f=f.substring(0,u)+h+f.substring(u);break;case-1:s.length1+=h.length,s.diffs[c++]=a[p],f=f.substring(0,u)+f.substring(u+h.length);break;case 0:h.length<=2*this.Patch_Margin&&c&&a.length!=p+1?(s.diffs[c++]=a[p],s.length1+=h.length,s.length2+=h.length):h.length>=2*this.Patch_Margin&&c&&(this.patch_addContext_(s,d),o.push(s),s=new t.patch_obj,c=0,d=f,l=u)}m!==1&&(l+=h.length),m!==-1&&(u+=h.length)}return c&&(this.patch_addContext_(s,d),o.push(s)),o},t.prototype.patch_deepCopy=function(e){for(var n=[],r=0;r<e.length;r++){var i=e[r],a=new t.patch_obj;a.diffs=[];for(var o=0;o<i.diffs.length;o++)a.diffs[o]=new t.Diff(i.diffs[o][0],i.diffs[o][1]);a.start1=i.start1,a.start2=i.start2,a.length1=i.length1,a.length2=i.length2,n[r]=a}return n},t.prototype.patch_apply=function(e,t){if(e.length==0)return[t,[]];e=this.patch_deepCopy(e);var n=this.patch_addPadding(e);t=n+t+n,this.patch_splitMax(e);for(var r=0,i=[],a=0;a<e.length;a++){var o,s,c=e[a].start2+r,l=this.diff_text1(e[a].diffs),u=-1;if(l.length>this.Match_MaxBits?(o=this.match_main(t,l.substring(0,this.Match_MaxBits),c))!=-1&&((u=this.match_main(t,l.substring(l.length-this.Match_MaxBits),c+l.length-this.Match_MaxBits))==-1||o>=u)&&(o=-1):o=this.match_main(t,l,c),o==-1)i[a]=!1,r-=e[a].length2-e[a].length1;else if(i[a]=!0,r=o-c,l==(s=u==-1?t.substring(o,o+l.length):t.substring(o,u+this.Match_MaxBits)))t=t.substring(0,o)+this.diff_text2(e[a].diffs)+t.substring(o+l.length);else{var d=this.diff_main(l,s,!1);if(l.length>this.Match_MaxBits&&this.diff_levenshtein(d)/l.length>this.Patch_DeleteThreshold)i[a]=!1;else{this.diff_cleanupSemanticLossless(d);for(var f,p=0,m=0;m<e[a].diffs.length;m++){var h=e[a].diffs[m];h[0]!==0&&(f=this.diff_xIndex(d,p)),h[0]===1?t=t.substring(0,o+f)+h[1]+t.substring(o+f):h[0]===-1&&(t=t.substring(0,o+f)+t.substring(o+this.diff_xIndex(d,p+h[1].length))),h[0]!==-1&&(p+=h[1].length)}}}}return[t=t.substring(n.length,t.length-n.length),i]},t.prototype.patch_addPadding=function(e){for(var n=this.Patch_Margin,r=``,i=1;i<=n;i++)r+=String.fromCharCode(i);for(i=0;i<e.length;i++)e[i].start1+=n,e[i].start2+=n;var a=e[0],o=a.diffs;if(o.length==0||o[0][0]!=0)o.unshift(new t.Diff(0,r)),a.start1-=n,a.start2-=n,a.length1+=n,a.length2+=n;else if(n>o[0][1].length){var s=n-o[0][1].length;o[0][1]=r.substring(o[0][1].length)+o[0][1],a.start1-=s,a.start2-=s,a.length1+=s,a.length2+=s}return(o=(a=e[e.length-1]).diffs).length==0||o[o.length-1][0]!=0?(o.push(new t.Diff(0,r)),a.length1+=n,a.length2+=n):n>o[o.length-1][1].length&&(s=n-o[o.length-1][1].length,o[o.length-1][1]+=r.substring(0,s),a.length1+=s,a.length2+=s),r},t.prototype.patch_splitMax=function(e){for(var n=this.Match_MaxBits,r=0;r<e.length;r++)if(!(e[r].length1<=n)){var i=e[r];e.splice(r--,1);for(var a=i.start1,o=i.start2,s=``;i.diffs.length!==0;){var c=new t.patch_obj,l=!0;for(c.start1=a-s.length,c.start2=o-s.length,s!==``&&(c.length1=c.length2=s.length,c.diffs.push(new t.Diff(0,s)));i.diffs.length!==0&&c.length1<n-this.Patch_Margin;){var u=i.diffs[0][0],d=i.diffs[0][1];u===1?(c.length2+=d.length,o+=d.length,c.diffs.push(i.diffs.shift()),l=!1):u===-1&&c.diffs.length==1&&c.diffs[0][0]==0&&d.length>2*n?(c.length1+=d.length,a+=d.length,l=!1,c.diffs.push(new t.Diff(u,d)),i.diffs.shift()):(d=d.substring(0,n-c.length1-this.Patch_Margin),c.length1+=d.length,a+=d.length,u===0?(c.length2+=d.length,o+=d.length):l=!1,c.diffs.push(new t.Diff(u,d)),d==i.diffs[0][1]?i.diffs.shift():i.diffs[0][1]=i.diffs[0][1].substring(d.length))}s=(s=this.diff_text2(c.diffs)).substring(s.length-this.Patch_Margin);var f=this.diff_text1(i.diffs).substring(0,this.Patch_Margin);f!==``&&(c.length1+=f.length,c.length2+=f.length,c.diffs.length!==0&&c.diffs[c.diffs.length-1][0]===0?c.diffs[c.diffs.length-1][1]+=f:c.diffs.push(new t.Diff(0,f))),l||e.splice(++r,0,c)}}},t.prototype.patch_toText=function(e){for(var t=[],n=0;n<e.length;n++)t[n]=e[n];return t.join(``)},t.prototype.patch_fromText=function(e){var n=[];if(!e)return n;for(var r=e.split(`
28
+ `),i=0,a=/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;i<r.length;){var o=r[i].match(a);if(!o)throw Error(`Invalid patch string: `+r[i]);var s=new t.patch_obj;for(n.push(s),s.start1=parseInt(o[1],10),o[2]===``?(s.start1--,s.length1=1):o[2]==`0`?s.length1=0:(s.start1--,s.length1=parseInt(o[2],10)),s.start2=parseInt(o[3],10),o[4]===``?(s.start2--,s.length2=1):o[4]==`0`?s.length2=0:(s.start2--,s.length2=parseInt(o[4],10)),i++;i<r.length;){var c=r[i].charAt(0);try{var l=decodeURI(r[i].substring(1))}catch{throw Error(`Illegal escape in patch_fromText: `+l)}if(c==`-`)s.diffs.push(new t.Diff(-1,l));else if(c==`+`)s.diffs.push(new t.Diff(1,l));else if(c==` `)s.diffs.push(new t.Diff(0,l));else{if(c==`@`)break;if(c!==``)throw Error(`Invalid patch mode "`+c+`" in: `+l)}i++}}return n},(t.patch_obj=function(){this.diffs=[],this.start1=null,this.start2=null,this.length1=0,this.length2=0}).prototype.toString=function(){for(var e,t=[`@@ -`+(this.length1===0?this.start1+`,0`:this.length1==1?this.start1+1:this.start1+1+`,`+this.length1)+` +`+(this.length2===0?this.start2+`,0`:this.length2==1?this.start2+1:this.start2+1+`,`+this.length2)+` @@
29
+ `],n=0;n<this.diffs.length;n++){switch(this.diffs[n][0]){case 1:e=`+`;break;case-1:e=`-`;break;case 0:e=` `}t[n+1]=e+encodeURI(this.diffs[n][1])+`
30
+ `}return t.join(``).replace(/%20/g,` `)},e.exports=t,e.exports.diff_match_patch=t,e.exports.DIFF_DELETE=-1,e.exports.DIFF_INSERT=1,e.exports.DIFF_EQUAL=0}));Cd.DIFF_EQUAL,Cd.DIFF_DELETE,Cd.DIFF_INSERT;var wd=800,Td=({change:e,side:t})=>{if(t===`old`)return null;let n=e.type===`normal`?e.newLineNumber:e.lineNumber;return n===void 0?null:(0,Z.jsx)(`span`,{children:n})},Ed=({change:e,side:t})=>e.type===`normal`?(0,Z.jsx)(`span`,{children:t===`old`?e.oldLineNumber:e.newLineNumber}):e.type===`insert`&&t===`new`||e.type===`delete`&&t===`old`?(0,Z.jsx)(`span`,{children:e.lineNumber}):null;function Dd({diff:e,viewType:t=`unified`,onHunkAction:n,hunkActionLabel:r,hunkActionDisabled:i}){let a=[],o=`fallback`,s=jd(e);if(s!==void 0){let e=Md(s);Nd(e)&&(a=e,o=`pi`)}if(o===`fallback`){let t=Md(e);Nd(t)&&(a=t,o=`raw`)}if(o===`fallback`&&Pd(e)){let t=Md(Ad+e.replace(/^\n+/,``));Nd(t)&&(a=t,o=`synthetic`)}if(o===`fallback`)return typeof console<`u`&&console.warn(`[DiffBlock] parseDiff produced no hunks; rendering colored fallback. Diff prefix:`,e.slice(0,200)),(0,Z.jsx)(Fd,{diff:e});let c=t===`split`?Ed:Td;return(0,Z.jsx)(`div`,{className:`pi-diff-block ${t===`split`?`pi-diff-split`:`pi-diff-unified`}`,style:{overflow:`auto`,padding:`0 8px 8px`,fontSize:`11px`},children:a.map(e=>(0,Z.jsx)(Od,{file:e,viewType:t,renderGutter:c,onHunkAction:n,hunkActionLabel:r,hunkActionDisabled:i},`${e.oldPath??``}:${e.newPath??``}`))})}function Od({file:e,viewType:t,renderGutter:n,onHunkAction:r,hunkActionLabel:i,hunkActionDisabled:a}){let[o,s]=(0,G.useState)(!1);(e.newPath??e.oldPath??``).replace(/^[ab]\//,``);let c=e.hunks.reduce((e,t)=>e+t.changes.length,0),l=c>wd&&!o,u=l?kd(e.hunks,wd):e.hunks;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(yd,{viewType:t,diffType:e.type,hunks:u,renderGutter:n,children:e=>{let t=[];return e.forEach((e,n)=>{r!==void 0&&t.push((0,Z.jsx)(Sd,{children:(0,Z.jsxs)(`div`,{style:{position:`relative`,display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:`8px`,borderBottom:`1px solid var(--border)`,borderTop:`1px solid var(--border)`,background:`var(--bg-glass)`,padding:`1px 0`,lineHeight:1.5},children:[(0,Z.jsxs)(`span`,{style:{position:`sticky`,left:0,zIndex:10,background:`var(--bg-glass)`,padding:`0 8px`,fontSize:`9px`,textTransform:`uppercase`,letterSpacing:`0.05em`,color:`var(--accent-text)`},children:[`Hunk `,n+1]}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>r(n),disabled:a===!0,style:{position:`sticky`,right:4,zIndex:10,borderRadius:`var(--radius-sm)`,border:`1px solid var(--accent-text)`,background:`var(--accent-subtle)`,padding:`2px 6px`,fontSize:`10px`,color:`var(--accent-text)`,cursor:a?`not-allowed`:`pointer`,opacity:a?.5:1},children:i??`Apply hunk`})]})},`dec-${e.content}`)),t.push((0,Z.jsx)(md,{hunk:e},e.content))}),t}}),l&&(0,Z.jsxs)(`button`,{onClick:()=>s(!0),style:{margin:`4px 0`,width:`100%`,borderRadius:`var(--radius-sm)`,border:`1px solid var(--border)`,background:`var(--bg-glass)`,padding:`4px 12px`,fontSize:`11px`,color:`var(--text-secondary)`,cursor:`pointer`},title:`Showing ~${wd} of ${c} lines — large diffs slow the renderer; click to render the rest.`,type:`button`,children:[`Show all (`,c,` lines, `,e.hunks.length,` hunks)`]})]})}function kd(e,t){let n=[],r=0;for(let i of e)if(n.length>0&&r+i.changes.length>t||(n.push(i),r+=i.changes.length,r>=t))break;return n}var Ad=`--- a/file
31
+ +++ b/file
32
+ `;function jd(e){let t=e.split(`
33
+ `),n=/^([+\- ]) *(\d+)(?: (.*))?$/,r=/^ +\.\.\.$/,i=[],a,o=0,s=()=>{a!==void 0&&a.body.length>0&&i.push(a),a=void 0};for(let e of t){if(e.length===0)continue;if(r.test(e)){s();continue}let t=n.exec(e);if(t===null)return;o+=1;let i=t[1],c=Number.parseInt(t[2]??``,10),l=t[3]??``;a===void 0&&(a={oldStart:c,newStart:c,oldCount:0,newCount:0,body:[]}),i===` `?(a.body.push(` `+l),a.oldCount+=1,a.newCount+=1):i===`-`?(a.body.push(`-`+l),a.oldCount+=1):(a.body.push(`+`+l),a.newCount+=1)}if(s(),!(o===0||i.length===0))return Ad+i.map(e=>`@@ -${e.oldStart},${e.oldCount} +${e.newStart},${e.newCount} @@\n`+e.body.join(`
34
+ `)).join(`
35
+ `)+`
36
+ `}function Md(e){try{return Ss(e)}catch{return[]}}function Nd(e){return e.length>0&&e.some(e=>e.hunks.length>0)}function Pd(e){let t=/^@@ /m.test(e),n=/^--- /m.test(e)&&/^\+\+\+ /m.test(e);return t&&!n}function Fd({diff:e}){return(0,Z.jsx)(`pre`,{style:{overflow:`auto`,padding:`0 12px 8px`,fontFamily:`monospace`,fontSize:`11px`,lineHeight:1.5},children:e.split(`
37
+ `).map((e,t)=>(0,Z.jsx)(`div`,{style:Id(e),children:e.length===0?`\xA0`:e},t))})}function Id(e){return e.startsWith(`+++`)||e.startsWith(`---`)?{color:`var(--text-dim)`}:e.startsWith(`@@`)?{background:`var(--bg-glass)`,color:`var(--accent-text)`}:e.startsWith(`+`)?{background:`rgba(52, 211, 153, 0.12)`,color:`var(--success)`}:e.startsWith(`-`)?{background:`rgba(248, 113, 113, 0.12)`,color:`var(--error)`}:{color:`var(--text-dim)`}}function Ld({files:e,sessionId:t,startIndex:n,endIndex:r,onOpen:i}){let[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)([]),[l,u]=(0,G.useState)({}),[d,p]=(0,G.useState)(!1),[m,g]=(0,G.useState)(void 0),_=t!==void 0&&n!==void 0,v=async()=>{if(!(t===void 0||n===void 0)){p(!0),g(void 0);try{let e=await Yn(t,n,r);c(e.entries)}catch(e){g(e instanceof Error?e.message:String(e))}finally{p(!1)}}};return(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`6px`,margin:`8px 0 4px`},children:[(0,Z.jsxs)(`div`,{"aria-label":`Files this turn wrote`,style:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:`6px`},children:[(0,Z.jsx)(`span`,{style:{fontSize:`10px`,textTransform:`uppercase`,letterSpacing:`0.05em`,color:`var(--text-dim)`,fontWeight:500},children:`wrote`}),e.map(e=>(0,Z.jsxs)(`button`,{type:`button`,title:e,"aria-label":`Open ${e}`,onClick:()=>i(e),style:{display:`inline-flex`,alignItems:`center`,gap:`5px`,padding:`3px 8px`,fontSize:`12px`,fontFamily:`var(--font-mono, monospace)`,color:`var(--text-primary)`,background:`var(--bg-subtle)`,border:`1px solid var(--border)`,borderRadius:`6px`,cursor:`pointer`},children:[(0,Z.jsx)(f,{size:12,style:{color:`var(--accent)`,flexShrink:0}}),(0,Z.jsx)(`span`,{style:{maxWidth:`260px`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:uo(e)})]},e)),_&&(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{let e=!a;o(e),e&&s.length===0&&m===void 0&&v()},title:a?`Hide turn diff`:`Show this turn's diff`,"aria-label":a?`Hide turn diff`:`Show this turn's diff`,style:{display:`inline-flex`,alignItems:`center`,gap:`5px`,padding:`3px 8px`,fontSize:`11px`,color:`var(--text-secondary)`,background:`none`,border:`1px solid var(--border)`,borderRadius:`6px`,cursor:`pointer`},children:[(0,Z.jsx)(h,{size:12}),a?`hide diff`:`diff`,s.length>0&&(0,Z.jsx)(`span`,{style:{fontSize:`10px`,color:`var(--text-dim)`},children:s.length})]})]}),a&&(0,Z.jsxs)(`div`,{style:{border:`1px solid var(--border)`,borderRadius:`var(--radius-sm)`,overflow:`hidden`,background:`var(--bg-glass)`},children:[m!==void 0&&(0,Z.jsxs)(`div`,{style:{padding:`6px 10px`,fontSize:`11px`,color:`var(--error)`,borderBottom:`1px solid var(--border)`},children:[`Couldn't load turn diff: `,m]}),d&&s.length===0&&(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`6px`,padding:`8px 12px`,fontSize:`11px`,color:`var(--text-dim)`},children:[(0,Z.jsx)(A,{size:12,style:{animation:`spin 1s linear infinite`}}),`Loading diff…`]}),!d&&s.length===0&&m===void 0&&(0,Z.jsx)(`div`,{style:{padding:`8px 12px`,fontSize:`11px`,fontStyle:`italic`,color:`var(--text-dim)`},children:`No file changes captured for this turn.`}),s.map(e=>{let t=l[e.file]??!1,n=uo(e.file);return(0,Z.jsxs)(`div`,{style:{borderBottom:`1px solid var(--border)`,overflow:`hidden`},children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>u(n=>({...n,[e.file]:!t})),style:{display:`flex`,width:`100%`,alignItems:`center`,justifyContent:`space-between`,gap:`8px`,padding:`6px 10px`,textAlign:`left`,cursor:`pointer`,background:`none`,border:`none`,color:`var(--text-secondary)`},title:e.file,children:[(0,Z.jsxs)(`span`,{style:{display:`flex`,minWidth:0,alignItems:`center`,gap:`8px`},children:[(0,Z.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,fontFamily:`monospace`,color:`var(--text-primary)`,fontSize:`11px`},children:n}),e.isPureAddition&&(0,Z.jsx)(`span`,{style:{borderRadius:`var(--radius-sm)`,background:`rgba(52,211,153,0.12)`,padding:`2px 6px`,fontSize:`9px`,textTransform:`uppercase`,letterSpacing:`0.05em`,color:`var(--success)`},children:`new`})]}),(0,Z.jsxs)(`span`,{style:{display:`flex`,flexShrink:0,alignItems:`baseline`,gap:`8px`,fontSize:`11px`},children:[(0,Z.jsxs)(`span`,{style:{color:`var(--success)`},children:[`+`,e.additions]}),(0,Z.jsxs)(`span`,{style:{color:`var(--error)`},children:[`−`,e.deletions]})]})]}),t&&(0,Z.jsx)(Dd,{diff:e.diff,viewType:`unified`})]},e.file)})]})]})}var Rd={overflow:{icon:`🧠`,label:`chat.autoCompacting`,description:`chat.descOverflow`},threshold:{icon:`⚙️`,label:`chat.autoCompacting`,description:`chat.descThreshold`},manual:{icon:`🗜️`,label:`chat.compacting`,description:`chat.descManual`}},zd=(0,G.memo)(function({compaction:e}){let{t}=qo(),n=e.completedAt!==void 0,r=Rd[e.reason],[i,a]=(0,G.useState)(()=>Math.floor(((e.completedAt??Date.now())-e.startedAt)/1e3));if((0,G.useEffect)(()=>{if(n)return;let t=setInterval(()=>{a(Math.floor((Date.now()-e.startedAt)/1e3))},1e3);return()=>clearInterval(t)},[e.startedAt,n]),n){let n=e.aborted?t(`chat.compaction_cancelled`):e.errorMessage?t(`chat.compaction_failed`):t(`chat.compacted`);return(0,Z.jsx)(`div`,{className:`message-row system`,children:(0,Z.jsxs)(`div`,{className:`compaction-notice compaction-notice--done`,children:[(0,Z.jsxs)(`div`,{className:`compaction-notice-header`,children:[e.aborted?(0,Z.jsx)(`span`,{className:`compaction-notice-icon`,children:`⛔`}):e.errorMessage?(0,Z.jsx)(`span`,{className:`compaction-notice-icon`,children:`⚠️`}):(0,Z.jsx)(s,{size:14,className:`compaction-notice-icon`}),(0,Z.jsx)(`span`,{className:`compaction-notice-title`,children:n})]}),e.errorMessage&&(0,Z.jsx)(`div`,{className:`compaction-notice-desc compaction-notice-desc--error`,children:e.errorMessage}),!e.aborted&&!e.errorMessage&&(0,Z.jsxs)(`div`,{className:`compaction-notice-stats`,children:[e.tokensBefore!==void 0&&(0,Z.jsxs)(`span`,{children:[`-`,e.tokensBefore.toLocaleString(),` tokens`]}),e.estimatedTokensAfter!==void 0&&(0,Z.jsxs)(`span`,{children:[`→ ~`,e.estimatedTokensAfter.toLocaleString(),` tokens`]}),(0,Z.jsx)(`span`,{className:`compaction-notice-timer`,children:i<60?`${i}s`:`${Math.floor(i/60)}m ${i%60}s`})]})]})})}return(0,Z.jsx)(`div`,{className:`message-row system`,children:(0,Z.jsxs)(`div`,{className:`compaction-notice`,children:[(0,Z.jsx)(`span`,{className:`compaction-notice-icon`,children:r.icon}),(0,Z.jsxs)(`div`,{className:`compaction-notice-body`,children:[(0,Z.jsx)(`div`,{className:`compaction-notice-title`,children:t(r.label)}),(0,Z.jsx)(`div`,{className:`compaction-notice-desc`,children:t(r.description)}),(0,Z.jsx)(`div`,{className:`compaction-notice-timer`,children:i<60?`${i}s`:`${Math.floor(i/60)}m ${i%60}s`})]}),(0,Z.jsxs)(`span`,{className:`compaction-notice-dots`,"aria-hidden":`true`,children:[(0,Z.jsx)(`span`,{children:`.`}),(0,Z.jsx)(`span`,{children:`.`}),(0,Z.jsx)(`span`,{children:`.`})]}),e.phase===`summarizing`?t(`chat.summarizing`):t(`chat.compacting`)]})})}),Bd=(0,G.createContext)({viewType:`unified`,setViewType:()=>void 0}),Vd=`pi.chat.viewType`;function Hd(){try{return localStorage.getItem(Vd)===`split`?`split`:`unified`}catch{return`unified`}}function Ud({diff:e,filename:t,adds:n,dels:r}){let{viewType:i,setViewType:a}=(0,G.useContext)(Bd);return(0,Z.jsxs)(`details`,{className:`chat-edit-diff-wrap group overflow-hidden text-xs`,children:[(0,Z.jsxs)(`summary`,{className:`chat-edit-diff-summary flex cursor-pointer items-center justify-between gap-2 px-3 py-2`,children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,Z.jsx)(`span`,{className:`chat-edit-diff-filename truncate font-mono`,children:t??`diff`}),(0,Z.jsxs)(`span`,{className:`ml-1 inline-flex items-center gap-0.5 rounded bg-emerald-950/50 px-1.5 py-0.5 text-[10px] font-medium text-emerald-400 light:bg-emerald-100 light:text-emerald-700`,children:[`+`,n]}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 rounded bg-red-950/50 px-1.5 py-0.5 text-[10px] font-medium text-red-400 light:bg-red-100 light:text-red-700`,children:[`−`,r]})]}),(0,Z.jsx)(`span`,{className:`flex shrink-0 items-center gap-1`,children:(0,Z.jsx)(`button`,{onClick:e=>{e.preventDefault(),e.stopPropagation(),a(i===`split`?`unified`:`split`)},className:`chat-edit-diff-toggle-btn rounded p-0.5`,title:i===`split`?`Switch chat diffs to unified view`:`Switch chat diffs to side-by-side view`,children:i===`split`?(0,Z.jsxs)(`svg`,{width:11,height:11,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`rect`,{x:3,y:3,width:7,height:18}),(0,Z.jsx)(`rect`,{x:14,y:3,width:7,height:18})]}):(0,Z.jsxs)(`svg`,{width:11,height:11,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`line`,{x1:3,y1:12,x2:21,y2:12}),(0,Z.jsx)(`line`,{x1:12,y1:3,x2:12,y2:21})]})})})]}),(0,Z.jsx)(Dd,{diff:e,viewType:i})]})}function Wd({children:e}){let[t,n]=(0,G.useState)(Hd);return(0,Z.jsx)(Bd.Provider,{value:{viewType:t,setViewType:e=>{n(e);try{localStorage.setItem(Vd,e)}catch{}}},children:e})}var Gd=new class{renderers=new Map;register(e,t){this.renderers.set(e,t)}get(e){return this.renderers.get(e)}has(e){return this.renderers.has(e)}},Kd=`<!DOCTYPE html>
38
+ <html>
39
+ <head><meta charset="utf-8"></head>
40
+ <body>
41
+ <script>
42
+ (function() {
43
+ var logs = [];
44
+ var orig = {};
45
+ ['log','warn','error','info','debug'].forEach(function(m) {
46
+ orig[m] = console[m];
47
+ console[m] = function() {
48
+ var args = Array.prototype.slice.call(arguments);
49
+ var text = args.map(function(a) {
50
+ if (a === null) return 'null';
51
+ if (a === undefined) return 'undefined';
52
+ if (typeof a === 'object') try { return JSON.stringify(a, null, 2); } catch(e) { return String(a); }
53
+ return String(a);
54
+ }).join(' ');
55
+ logs.push({ method: m, text: text });
56
+ orig[m].apply(console, args);
57
+ };
58
+ });
59
+
60
+ window.addEventListener('message', function(e) {
61
+ if (e.data && e.data.type === 'execute-code') {
62
+ var respond = function(result) {
63
+ try {
64
+ e.source.postMessage(result, '*');
65
+ } catch(_) {}
66
+ };
67
+ try {
68
+ var returnValue = (0, eval)(e.data.code);
69
+ var result = {
70
+ type: 'execution-result',
71
+ id: e.data.id,
72
+ success: true,
73
+ logs: logs.slice(),
74
+ returnValue: returnValue
75
+ };
76
+ logs.length = 0;
77
+ respond(result);
78
+ } catch(err) {
79
+ respond({
80
+ type: 'execution-result',
81
+ id: e.data.id,
82
+ success: false,
83
+ logs: logs.slice(),
84
+ error: { message: err.message, stack: err.stack }
85
+ });
86
+ logs.length = 0;
87
+ }
88
+ }
89
+ });
90
+
91
+ window.parent.postMessage({ type: 'sandbox-ready' }, '*');
92
+ })();
93
+ <\/script>
94
+ </body>
95
+ </html>`,qd=0;function Jd(e,t=3e4){return new Promise((n,r)=>{let i=`sb-${Date.now()}-${++qd}`,a=document.createElement(`iframe`);a.setAttribute(`sandbox`,`allow-scripts`),a.style.display=`none`,a.srcdoc=Kd;let o=!1,s=setTimeout(()=>{o||(o=!0,window.removeEventListener(`message`,c),a.remove(),n({success:!1,logs:[],error:{message:`Execution timeout`,stack:``}}))},t),c=t=>{if(t.data?.type===`sandbox-ready`&&t.source===a.contentWindow){a.contentWindow?.postMessage({type:`execute-code`,id:i,code:e},`*`);return}t.data?.type===`execution-result`&&t.data?.id===i&&(o=!0,clearTimeout(s),window.removeEventListener(`message`,c),a.remove(),n({success:t.data.success,logs:t.data.logs||[],returnValue:t.data.returnValue,error:t.data.error}))};window.addEventListener(`message`,c),document.body.appendChild(a)})}function Yd(e,t,n=`allow-scripts allow-modals`){let r=document.createElement(`iframe`);return r.setAttribute(`sandbox`,n),r.style.cssText=`width:100%;height:100%;border:none;border-radius:6px;background:white;`,r.srcdoc=t,e.innerHTML=``,e.appendChild(r),()=>{r.remove()}}function Xd({code:e,title:t,serverOutput:n,isRunning:r,isError:i}){let[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(null),p=(0,G.useRef)(0),m=(0,G.useCallback)(async()=>{let t=++p.current;u(!0),c(null),f(null);try{let n=await Jd(e);if(t!==p.current)return;n.success?c({logs:n.logs||[],returnValue:n.returnValue}):c({logs:n.logs||[],error:n.error})}catch(e){if(t!==p.current)return;f(e instanceof Error?e.message:`Execution failed`)}finally{t===p.current&&u(!1)}},[e]);return(0,Z.jsxs)(`div`,{className:`repl-sandbox`,children:[(0,Z.jsxs)(`div`,{className:`repl-sandbox-header`,children:[(0,Z.jsx)(`span`,{className:`repl-sandbox-icon`,children:r?`⏳`:i?`✖`:`▶`}),(0,Z.jsx)(`span`,{className:`repl-sandbox-title`,children:t||`JavaScript REPL`})]}),(0,Z.jsxs)(`div`,{className:`repl-sandbox-code`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`repl-sandbox-toggle`,onClick:()=>o(e=>!e),"aria-expanded":a,children:[a?`▾`:`▸`,` Code`]}),a&&(0,Z.jsx)(`pre`,{className:`repl-sandbox-code-block`,children:(0,Z.jsx)(`code`,{children:e})})]}),n&&(0,Z.jsxs)(`div`,{className:`repl-sandbox-output ${i?`error`:``}`,children:[(0,Z.jsx)(`div`,{className:`repl-sandbox-output-label`,children:`Server`}),(0,Z.jsx)(`pre`,{className:`repl-sandbox-output-text`,children:n})]}),(0,Z.jsx)(`button`,{type:`button`,className:`repl-sandbox-run-btn`,onClick:m,disabled:l,children:l?`⏳ Running…`:i?`🔄 Retry in Browser`:`▶ Run in Browser`}),s&&(0,Z.jsxs)(`div`,{className:`repl-sandbox-output`,children:[(0,Z.jsxs)(`div`,{className:`repl-sandbox-output-label`,children:[`Browser Sandbox `,s.error?`(error)`:``]}),s.logs.length>0&&(0,Z.jsx)(`div`,{className:`repl-sandbox-console`,children:s.logs.map((e,t)=>(0,Z.jsxs)(`div`,{className:`repl-sandbox-console-line ${e.method===`error`?`error`:e.method===`warn`?`warn`:``}`,children:[(0,Z.jsx)(`span`,{className:`repl-sandbox-console-method`,children:e.method}),(0,Z.jsx)(`span`,{className:`repl-sandbox-console-text`,children:e.text})]},t))}),s.returnValue!==void 0&&!s.error&&(0,Z.jsxs)(`div`,{className:`repl-sandbox-return`,children:[(0,Z.jsx)(`span`,{className:`repl-sandbox-console-method`,children:`→`}),(0,Z.jsx)(`pre`,{className:`repl-sandbox-return-value`,children:typeof s.returnValue==`object`?JSON.stringify(s.returnValue,null,2):String(s.returnValue)})]}),s.error&&(0,Z.jsxs)(`pre`,{className:`repl-sandbox-error-block`,children:[(0,Z.jsx)(`strong`,{children:`Error:`}),` `,s.error.message,`
96
+ `,s.error.stack]})]}),d&&(0,Z.jsxs)(`pre`,{className:`repl-sandbox-error-block`,children:[(0,Z.jsx)(`strong`,{children:`Sandbox Error:`}),` `,d]})]})}var Zd=[`LAUNCH READY`,`SYNC ONLINE`,`SIGNAL LIVE`],Qd={alpha:`ABCDEFGHIJKLMNOPQRSTUVWXYZ`,alphanumeric:`ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`,numeric:`0123456789`},$d=e=>typeof e==`number`?`${e}px`:e,ef=e=>e&&Qd[e]?Qd[e]:typeof e==`string`&&e.length>0?e:Qd.alphanumeric,tf=(e,t)=>String(e??``).padEnd(t,` `).slice(0,t),nf=e=>e.split(``).map(e=>({current:e,next:e,flipping:!1,tick:0})),rf=e=>e.charAt(Math.floor(Math.random()*e.length))||` `,af=(e,t,n)=>{let r=[];for(let e=0;e<t;e+=1)r.push(rf(n));return r.push(e),r},of=()=>{let[e,t]=(0,G.useState)(!1);return(0,G.useEffect)(()=>{if(typeof window>`u`||!window.matchMedia)return;let e=window.matchMedia(`(prefers-reduced-motion: reduce)`),n=()=>t(e.matches);return n(),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e},sf=({words:e=[`LAUNCH READY`,`SYNC ONLINE`,`SIGNAL LIVE`],text:t,flipDuration:n=.12,stagger:r=.06,cycleDelay:i=2400,charset:a=`alphanumeric`,flipsPerChar:o=8,tileColor:s=`var(--flap-tile, #1c1e22)`,textColor:c=`var(--flap-text, rgba(255,255,255,0.9))`,tileRadius:l=8,gap:u=6,fontSize:d=52,loop:f=!0,padTo:p=12,className:m=``,style:h={},...g})=>{let _=of(),v=(0,G.useRef)(null),y=(0,G.useRef)(null),b=(0,G.useRef)(``),x=Array.isArray(e)&&e.length>0?e:Zd,S=typeof t==`string`?t:x.map(e=>String(e??``)).join(``),C=(0,G.useMemo)(()=>S.split(``),[S]),w=(0,G.useMemo)(()=>{let e=C.reduce((e,t)=>Math.max(e,t.length),1);return Math.max(1,Math.ceil(Number(p)||0),e)},[p,C]),T=(0,G.useMemo)(()=>C.map(e=>tf(e,w)),[C,w]),[E,D]=(0,G.useState)(()=>nf(T[0]||``));(0,G.useEffect)(()=>{let e=()=>{v.current&&=(cancelAnimationFrame(v.current),null),y.current&&=(clearTimeout(y.current),null)};e();let t=T[0]||``;if(b.current=t,D(nf(t)),T.length<=1||typeof window>`u`)return e;let s=0,c=!1,l=Math.max(40,(Number(n)||.12)*1e3),u=Math.max(0,(Number(r)||0)*1e3),d=Math.max(400,Number(i)||2400),p=Math.max(0,Math.floor(Number(o)||0)),m=ef(a),h=e=>{if(_)return b.current=e,D(nf(e)),0;let t=tf(b.current,w),n=e.split(``).map((e,n)=>{let r=t[n]||` `;return r===e?null:{index:n,from:r,target:e,sequence:af(e,p,m),start:n*u,step:-1,done:!1}}).filter(e=>e!==null);if(!n.length)return b.current=e,D(nf(e)),0;let r=n.reduce((e,t)=>Math.max(e,t.start+t.sequence.length*l),0),i=performance.now(),a=e=>{D(t=>{let n=[...t];return e.forEach(e=>{let t=n[e.index];t&&(n[e.index]={current:e.current,next:e.next,flipping:!e.done,tick:t.tick+1})}),n})},o=t=>{if(c)return;let r=t-i,s=[],u=!1;n.forEach(e=>{let t=r-e.start;if(t<0){u=!0;return}let n=Math.floor(t/l);n<e.sequence.length?(u=!0,n!==e.step&&(e.step=n,s.push({index:e.index,current:n===0?e.from:e.sequence[n-1],next:e.sequence[n],done:!1}))):e.done||(e.done=!0,s.push({index:e.index,current:e.target,next:e.target,done:!0}))}),s.length>0&&a(s),u?v.current=requestAnimationFrame(o):(b.current=e,v.current=null)};return v.current=requestAnimationFrame(o),r},g=e=>{y.current=window.setTimeout(()=>{if(c)return;let e=s+1;if(e>=T.length&&!f)return;s=e%T.length;let t=h(T[s]);g(d+t)},e)};return g(d),()=>{c=!0,e()}},[T,w,f,i,n,r,o,a,_]);let O=E.map(e=>e.current).join(``).trimEnd(),k={"--split-flap-tile-color":s,"--split-flap-text-color":c,"--split-flap-radius":$d(l),"--split-flap-gap":$d(u),"--split-flap-font-size":$d(d),"--split-flap-flip-duration":`${Math.max(.04,Number(n)||.12)}s`,...h};return(0,Z.jsx)(`div`,{className:`split-flap-text ${m}`.trim(),style:k,role:`text`,"aria-label":O||void 0,...g,children:E.map((e,t)=>(0,Z.jsxs)(`span`,{className:`split-flap-text__tile`,"aria-hidden":`true`,children:[(0,Z.jsx)(`span`,{className:`split-flap-text__half split-flap-text__half--top`,children:(0,Z.jsx)(`span`,{className:`split-flap-text__char`,children:e.current===` `?`\xA0`:e.current})}),(0,Z.jsx)(`span`,{className:`split-flap-text__half split-flap-text__half--bottom`,children:(0,Z.jsx)(`span`,{className:`split-flap-text__char`,children:e.flipping?e.next:e.current})}),e.flipping&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`split-flap-text__flap split-flap-text__flap--front`,children:(0,Z.jsx)(`span`,{className:`split-flap-text__char`,children:e.current===` `?`\xA0`:e.current})},`front-${t}-${e.tick}`),(0,Z.jsx)(`span`,{className:`split-flap-text__flap split-flap-text__flap--back`,children:(0,Z.jsx)(`span`,{className:`split-flap-text__char`,children:e.next===` `?`\xA0`:e.next})},`back-${t}-${e.tick}`)]})]},`${t}-${E.length}`))})},cf=4,lf=2,uf=cf*cf,df=[[[0],[1],[2],[3],[7],[11],[15],[14],[13],[12],[8],[4],[5],[6],[10],[9]],[[0,4,8,12],[1,5,9,13],[2,6,10,14],[3,7,11,15]],[[5,6,9,10],[1,4,7,8,11,14],[0,3,12,15],[1,4,7,8,11,14],[5,6,9,10]],[[0],[1,4],[2,5,8],[3,6,9,12],[7,10,13],[11,14],[15]]];function ff({className:e=``,style:t={}}){let[n,r]=(0,G.useState)(new Set),i=(0,G.useRef)({pattern:0,step:0});return(0,G.useEffect)(()=>{let e=()=>{let e=i.current,t=df[e.pattern];t&&(r(new Set(t[e.step])),e.step+=1,e.step>=t.length&&(e.step=0,e.pattern=(e.pattern+1)%df.length))};e();let t=window.setInterval(e,120);return()=>window.clearInterval(t)},[]),(0,Z.jsx)(`div`,{"aria-hidden":!0,className:`thinking-indicator ${e}`,style:{display:`grid`,flexShrink:0,gridTemplateColumns:`repeat(${cf}, 1fr)`,gap:`${lf}px`,...t},children:Array.from({length:uf},(e,t)=>(0,Z.jsx)(`span`,{style:{borderRadius:`2px`,backgroundColor:`currentColor`,transition:`opacity 0.1s ease-in-out`,opacity:n.has(t)?1:.2}},t))})}var pf=`pi-kot/sticky-user-header`,mf=`pi-kot/fly-to-top`,hf=`pi-kot/show-token-usage`,gf=`pi-kot/compress-images`,_f=`pi-kot/show-thinking`,vf=`pi-kot/grouped-tool-display`,yf=`pi-kot/trail-default-view`,bf=`pi-kot/show-turn-files`,xf=`pi-kot/swipe-to-open-sidebar`,Sf=`pi-kot/empty-flap-enabled`,Cf=`pi-kot/empty-flap-words`,wf=[`PI-KOT 0.1.41`,`PI-SDK 0.87.1`];function Tf(){if(typeof window>`u`)return!0;try{let e=localStorage.getItem(vf);return e===null?!0:e===`true`}catch{return!0}}function Ef(){if(typeof window>`u`)return`justify`;try{let e=localStorage.getItem(yf);return e===`full`||e===`justify`?e:`justify`}catch{return`justify`}}function Df(){if(typeof window>`u`)return!0;try{let e=localStorage.getItem(pf);return e===null?!0:e===`true`}catch{return!0}}function Of(){if(typeof window>`u`)return!0;try{let e=localStorage.getItem(mf);return e===null?!0:e===`true`}catch{return!0}}function kf(){if(typeof window>`u`)return!1;try{let e=localStorage.getItem(hf);return e===null?!1:e===`true`}catch{return!1}}function Af(){if(typeof window>`u`)return!0;try{let e=localStorage.getItem(gf);return e===null?!0:e===`true`}catch{return!0}}function jf(){if(typeof window>`u`)return!1;try{let e=localStorage.getItem(_f);return e===null?!1:e===`true`}catch{return!1}}function Mf(){if(typeof window>`u`)return!0;try{let e=localStorage.getItem(bf);return e===null?!0:e===`true`}catch{return!0}}function Nf(){if(typeof window>`u`)return!0;try{let e=localStorage.getItem(xf);return e===null?!0:e===`true`}catch{return!0}}function Pf(){if(typeof window>`u`)return!0;try{let e=localStorage.getItem(Sf);return e===null?!0:e===`true`}catch{return!0}}function Ff(){if(typeof window>`u`)return wf;try{let e=localStorage.getItem(Cf);if(!e)return wf;let t=JSON.parse(e);if(!Array.isArray(t))return wf;let n=t.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).slice(0,8).map(e=>e.slice(0,32));return n.length>0?n:wf}catch{return wf}}var Q=At(e=>({stickyUserHeader:Df(),flyToTop:Of(),showTokenUsage:kf(),setStickyUserHeader:t=>{try{localStorage.setItem(pf,String(t))}catch{}e({stickyUserHeader:t})},setFlyToTop:t=>{try{localStorage.setItem(mf,String(t))}catch{}e({flyToTop:t})},setShowTokenUsage:t=>{try{localStorage.setItem(hf,String(t))}catch{}e({showTokenUsage:t})},compressImages:Af(),setCompressImages:t=>{try{localStorage.setItem(gf,String(t))}catch{}e({compressImages:t})},showThinking:jf(),groupedToolDisplay:Tf(),setShowThinking:t=>{try{localStorage.setItem(_f,String(t))}catch{}e({showThinking:t})},setGroupedToolDisplay:t=>{try{localStorage.setItem(vf,String(t))}catch{}e({groupedToolDisplay:t})},trailDefaultView:Ef(),setTrailDefaultView:t=>{let n=t===`full`?`full`:`justify`;try{localStorage.setItem(yf,n)}catch{}e({trailDefaultView:n})},showTurnFiles:Mf(),setShowTurnFiles:t=>{try{localStorage.setItem(bf,String(t))}catch{}e({showTurnFiles:t})},swipeToOpenSidebar:Nf(),emptyFlapEnabled:Pf(),emptyFlapWords:Ff(),setSwipeToOpenSidebar:t=>{try{localStorage.setItem(xf,String(t))}catch{}e({swipeToOpenSidebar:t})},setEmptyFlapEnabled:t=>{try{localStorage.setItem(Sf,String(t))}catch{}e({emptyFlapEnabled:t})},setEmptyFlapWords:t=>{let n=Array.isArray(t)?t.map(e=>String(e).trim()).filter(e=>e.length>0).slice(0,8).map(e=>e.slice(0,32)):[...wf];try{localStorage.setItem(Cf,JSON.stringify(n))}catch{}e({emptyFlapWords:n.length>0?n:wf})}})),If=new Set([`step-start`,`step_start`,`reasoning`,`thinking`,`snapshot`]);function Lf(e,t,n){let r=[],i=[],a=[],o=[],s,c,l=[],u=()=>{if(s!==void 0&&s.length>0){let e={entries:s,firstToolId:c};i.push(e),r.push({kind:`segment`,segment:e})}s=void 0,c=void 0},d=()=>{if(l.length!==0){s===void 0&&(s=[]);for(let e of l)s.push(e.type===`text`?{kind:`justification`,text:e.text}:{kind:`thinking`,text:e.text});l=[]}};for(let i of e){if(i.role!==`assistant`){u(),o.push(i),r.push({kind:`special`,message:i});continue}let e=i.content;if(!Array.isArray(e)){let t=typeof e==`string`?e:``;t.trim().length>0&&l.push({type:`text`,text:t});continue}for(let o of e){let e=o.type;if(e===`toolCall`){let e=String(o.name??`tool`),l=String(o.id??``),f=o.arguments??{};if(If.has(e.toLowerCase()))continue;if(d(),n(e)){u();let n={name:e,id:l,args:f,result:l?t(l):void 0,msgId:String(i.id??``)};a.push(n),r.push({kind:`customTool`,customTool:n})}else s===void 0&&(s=[]),!c&&l&&(c=l),s.push({kind:`tool`,block:{name:e,arguments:f,id:l},result:l?t(l):void 0})}else e===`text`&&typeof o.text==`string`&&o.text.trim()!==``?l.push({type:`text`,text:o.text}):(e===`thinking`||e===`reasoning`)&&typeof o.thinking==`string`&&o.thinking.trim()!==``&&l.push({type:`thinking`,text:o.thinking})}}let f=l;return u(),{items:r,segments:i,customTools:a,specials:o,finalParts:f}}function Rf(e){let t=e.toLowerCase(),n={edit:`Edited`,apply_patch:`Edited`,str_replace:`Edited`,multiedit:`Edited`,write:`Wrote`,create:`Wrote`,file_write:`Wrote`,read:`Read`,view:`Read`,cat:`Read`,file_read:`Read`,bash:`Shell Command`,shell:`Shell Command`,cmd:`Shell Command`,terminal:`Shell Command`,list:`Listed`,ls:`Listed`,dir:`Listed`,list_files:`Listed`,grep:`Searched`,search:`Searched`,ripgrep:`Searched`,find:`Found`,glob:`Found`,webfetch:`Fetched`,fetch:`Fetched`,fetch_content:`Fetched`,curl:`Fetched`,wget:`Fetched`,websearch:`Searched Web`,web_search:`Searched Web`,web_fetch:`Fetched`,searxng_searxng_web_search:`Searched`,codesearch:`Searched`,todowrite:`Updated Todos`,todoread:`Read Todos`,ask_user_question:`Asked`,plan_mode_question:`Asked`,task:`Delegated Task`,javascript_repl:`Repl`,process:`Background Process`};return n[t]?n[t]:t.startsWith(`ctx_`)?t.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase()):t.startsWith(`git`)?`Git `+t.slice(3).replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase()):e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function zf(e){let t=e.toLowerCase();return t===`edit`||t===`multiedit`||t===`apply_patch`||t===`str_replace`?`M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z`:t===`write`||t===`create`||t===`file_write`?`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8zM14 2v6h6M12 18v-6M9 15h6`:t===`read`||t===`view`||t===`file_read`||t===`cat`?`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8zM14 2v6h6M16 13H8M16 17H8M10 9H8`:t===`bash`||t===`shell`||t===`cmd`||t===`terminal`?`M4 17l6-6-6-6M12 19h8`:t===`list`||t===`ls`||t===`dir`||t===`list_files`?`M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z`:t===`grep`||t===`search`||t===`find`||t===`ripgrep`?`M21 21l-6-6m2-5a7 7 0 1 1-14 0 7 7 0 0 1 14 0zM10 7v3m0 0v3m0-3h3m-3 0H7`:t===`glob`?`M21 21l-6-6m2-5a7 7 0 1 1-14 0 7 7 0 0 1 14 0z`:t===`webfetch`||t===`fetch`||t===`fetch_content`||t===`curl`||t===`wget`||t.includes(`web_search`)||t.includes(`searxng`)||t===`websearch`||t===`codesearch`?`M12 2a10 10 0 1 0 0 20A10 10 0 0 0 12 2zM2 12h20M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z`:t===`todowrite`||t===`todoread`?`M9 11l3 3L22 4M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11`:t===`task`?`M12 2a10 10 0 1 0 0 20A10 10 0 0 0 12 2zM12 8v4l3 3`:t===`ask_user_question`||t===`plan_mode_question`||t.includes(`question`)?`M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20zM9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3M12 17h.01`:t.startsWith(`git`)?`M6 3v12M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM18 9a9 9 0 0 1-9 9`:`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`}function Bf(e,t){let n=e.toLowerCase();if(n===`bash`||n===`shell`||n===`cmd`||n===`terminal`){let e=t.command??t.cmd??``;return typeof e==`string`?e.split(`
97
+ `)[0].slice(0,80):``}if(n===`read`||n===`view`||n===`cat`||n===`write`||n===`create`||n===`edit`||n===`apply_patch`||n===`multiedit`){let e=t.filePath??t.file_path??t.path??t.file??``;if(typeof e==`string`&&e){let t=e.replace(/\\/g,`/`).split(`/`);return t[t.length-1]??e}}if(n===`grep`||n===`search`||n===`find`||n===`ripgrep`){let e=t.pattern??t.query??``;return typeof e==`string`?`"${e.slice(0,60)}"`:``}if(n===`glob`){let e=t.pattern??t.glob??``;return typeof e==`string`?`"${e.slice(0,60)}"`:``}if(n===`webfetch`||n===`fetch`||n===`fetch_content`||n===`curl`||n===`wget`){let e=t.url??t.URL??``;return typeof e==`string`?e.slice(0,80):``}if(n.includes(`web_search`)||n.includes(`searxng`)||n===`websearch`||n===`codesearch`){let e=t.query??t.q??``;return typeof e==`string`?`"${e.slice(0,60)}"`:``}if(n===`ask_user_question`||n===`plan_mode_question`){let e=t.questions;if(Array.isArray(e)&&e.length>0){let t=e[0];return(typeof t?.question==`string`?t.question:``).slice(0,80)}}if(n.startsWith(`ctx_`)){let e=t.queries;if(Array.isArray(e)&&e.length>0)return`"${String(e[0]).slice(0,60)}"`;let n=t.path??t.source;if(typeof n==`string`)return n.slice(0,80)}let r=t.url??t.query??t.pattern??t.path??t.filePath??``;return typeof r==`string`?r.slice(0,80):``}function Vf(e){let t=e.details,n=e.input;for(let e of[t,n])if(e!==void 0){if(typeof e.path==`string`)return e.path;if(typeof e.filename==`string`)return e.filename;if(typeof e.file==`string`)return e.file;if(typeof e.file_path==`string`)return e.file_path}}function Hf(e){let t=0,n=0;for(let r of e.split(`
98
+ `))r.startsWith(`+++`)||r.startsWith(`---`)||(r.startsWith(`+`)?t+=1:r.startsWith(`-`)&&(n+=1));return{adds:t,dels:n}}var Uf=(0,G.memo)(function({block:e,result:t,initialExpanded:n=!1,displayName:r,previewOverride:i,icon:a,suppressRunning:o=!1,isActive:s,isLastInTurn:c}){let{t:l}=qo(),[u,d]=(0,G.useState)(),[f,p]=(0,G.useState)(n),[m,h]=(0,G.useState)(!1),g=(0,G.useRef)(t===void 0),_=(0,G.useRef)(null);(0,G.useEffect)(()=>{if(g.current&&t!==void 0){h(!0);let e=setTimeout(()=>h(!1),600);return()=>clearTimeout(e)}g.current=t===void 0},[t]);let v=String(e.name??`tool`),y=e.arguments??e.input??{},b=typeof y==`string`?y:JSON.stringify(y,null,2),x=t?.isError===!0,S=t===void 0&&!o;(0,G.useEffect)(()=>{S&&f&&_.current&&(_.current.scrollTop=_.current.scrollHeight)},[S,f]);let C=(Array.isArray(t?.content)?t?.content:[]).filter(e=>{let t=e;return t.type===`text`&&typeof t.text==`string`}).map(e=>e.text).join(`
99
+ `),w=C.split(`
100
+ `).find(e=>e.trim().length>0)??``,T=i??Bf(v,y)??void 0,E=a??(0,Z.jsx)($f,{toolName:v}),D=v===`edit`&&t!==void 0?(()=>{let e=t.details?.diff;return typeof e==`string`?e:C})():void 0,O=v===`edit`&&t!==void 0?Vf(t):void 0,k=D===void 0?void 0:Hf(D),A=b.length>2||C.length>0;return(0,Z.jsxs)(`div`,{className:`tool-timeline-node ${S?` running`:x?` error`:` success`}`,children:[(0,Z.jsx)(`span`,{className:`tool-timeline-icon${S?` running`:x?` error`:` success`}${m?` just-completed`:``}`,"aria-hidden":`true`,children:E}),(0,Z.jsxs)(`div`,{className:`tool-timeline-content`,children:[(0,Z.jsxs)(`div`,{className:`tool-timeline-row ${A?`clickable`:``}`,onClick:A?()=>p(e=>!e):void 0,role:A?`button`:void 0,tabIndex:A?0:void 0,children:[(0,Z.jsx)(`span`,{className:`tool-timeline-name`,children:r??Rf(v)}),T&&(0,Z.jsx)(`span`,{className:`tool-timeline-arg`,title:T,children:T}),!S&&!f&&w.length>0&&(0,Z.jsxs)(`span`,{className:`tool-timeline-arg`,title:w,style:{color:`var(--text-ghost)`,fontStyle:`italic`},children:[`— `,x?`✖ `:`✓ `,` `,w]}),S&&(0,Z.jsx)(`span`,{className:`tool-timeline-running`,"aria-label":`running`,children:l(`chat.running`)}),A&&(0,Z.jsx)(`span`,{className:`tool-timeline-chevron-toggle ${f?`open`:``}`,children:`›`})]}),f&&(0,Z.jsxs)(`div`,{className:`tool-timeline-details`,children:[b.length>2&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`tool-timeline-section-label`,children:l(`chat.toolInput`)}),(0,Z.jsx)(`pre`,{className:`tool-timeline-code`,ref:_,children:b})]}),D!==void 0&&k!==void 0?(0,Z.jsx)(`div`,{className:`overflow-hidden px-3 pb-2`,children:(0,Z.jsx)(Ud,{diff:D,filename:O,adds:k.adds,dels:k.dels})}):C.length>0?(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`tool-timeline-section-label`,children:[x?`error`:`output`,k!==void 0&&!x&&(0,Z.jsxs)(`span`,{className:`ml-2 font-mono text-[10px]`,children:[(0,Z.jsxs)(`span`,{className:`text-emerald-400 light:text-emerald-700`,children:[`+`,k.adds]}),` `,(0,Z.jsxs)(`span`,{className:`text-red-400 light:text-red-700`,children:[`-`,k.dels]}),O!==void 0&&(0,Z.jsx)(`span`,{className:`ml-1 text-neutral-500`,children:O})]})]}),(0,Z.jsx)(`pre`,{className:`tool-timeline-code`,children:C})]}):null]})]})]})});function Wf({text:e}){let{t}=qo(),n=Q(e=>e.showThinking),[r,i]=(0,G.useState)(!1);return n?(0,Z.jsxs)(`details`,{open:r,className:`thinking-block`,children:[(0,Z.jsxs)(`summary`,{onClick:e=>{e.preventDefault(),i(e=>!e)},children:[(0,Z.jsx)(`span`,{className:`thinking-block-chevron`,children:`▶`}),(0,Z.jsx)(`span`,{className:`thinking-block-label`,children:t(`chat.thinking`)})]}),(0,Z.jsx)(`div`,{className:`thinking-block-content`,children:e})]}):null}var Gf=120;function Kf({text:e,open:t,onToggle:n}){let{t:r}=qo(),i=e.replace(/#+\s+/g,``).replace(/[*_~`]/g,``).replace(/\[([^\]]+)\]\([^)]+\)/g,`$1`).replace(/<[^>]+>/g,``).trim().replace(/\s+/g,` `),a=i.length>Gf?i.slice(0,Gf)+`…`:i;return(0,Z.jsx)(`div`,{className:`trail-justification${t?` expanded`:` collapsed`}`,children:(0,Z.jsxs)(`button`,{type:`button`,onClick:n,className:`trail-justification-header`,title:t?`Collapse this step`:`Expand this step`,"aria-expanded":t,children:[(0,Z.jsxs)(`div`,{className:`trail-justification-title-wrapper`,children:[(0,Z.jsx)(`span`,{className:`trail-justification-icon-box`,children:(0,Z.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`})})}),t?(0,Z.jsx)(`span`,{className:`trail-justification-label`,children:r(`chat.toolJustification`)}):(0,Z.jsx)(`span`,{className:`trail-justification-preview`,title:a,children:a||r(`chat.toolJustification`)})]}),(0,Z.jsx)(`span`,{className:`trail-justification-chevron`,children:(0,Z.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,Z.jsx)(`path`,{d:`m6 9 6 6 6-6`})})})]})})}var qf=3;function Jf(e,t,n,r){return n&&r===`justify`&&t>0?new Set([t-1]):e}function Yf(e){let t=[],n=null;for(let r of e)r.kind===`justification`?n&&n.just.kind===`justification`&&n.just.text===`Working...`&&!n.tools.some(e=>e.kind===`tool`)?n.just=r:(n&&t.push(n),n={just:r,tools:[]}):(n||={just:{kind:`justification`,text:`Working...`},tools:[]},n.tools.push(r));return n&&t.push(n),{leading:[],chunks:t}}function Xf(e){let t=[],n=[],r=``;for(let i of e)if(i.kind===`tool`){let e=String(i.block.name??`tool`);e===r?n.push(i):(n.length>0&&t.push(n.length===1?n[0]:n),n=[i],r=e)}else n.length>0&&(t.push(n.length===1?n[0]:n),n=[],r=``),t.push(i);return n.length>0&&t.push(n.length===1?n[0]:n),t}function Zf({entries:e,view:t,isStreaming:n,startIndex:r,renderEntry:i}){let{t:a}=qo(),[o,s]=(0,G.useState)(!1),c=n&&e.some(e=>e.kind===`tool`&&e.result===void 0),l=e.some(e=>e.kind===`tool`&&e.result?.isError===!0),u=t===`full`||o||c||l,d=e[0];if(d.kind!==`tool`)return null;let f=String(d.block.name??`tool`),p=e.length,m=Rf(f),h=c,g=l;return(0,Z.jsxs)(`div`,{className:`consecutive-tools-group`,style:{marginBottom:`2px`},children:[(0,Z.jsxs)(`div`,{className:`tool-timeline-node ${h?` running`:g?` error`:` success`}`,children:[(0,Z.jsx)(`span`,{className:`tool-timeline-icon${h?` running`:g?` error`:` success`}`,"aria-hidden":`true`,children:(0,Z.jsx)($f,{toolName:f})}),(0,Z.jsx)(`div`,{className:`tool-timeline-content`,children:(0,Z.jsxs)(`div`,{className:`tool-timeline-row clickable`,onClick:()=>s(!o),role:`button`,tabIndex:0,children:[(0,Z.jsxs)(`span`,{className:`tool-timeline-name`,style:{fontWeight:600},children:[p,` × `,m]}),!u&&(0,Z.jsx)(`div`,{className:`tool-timeline-summary`,children:(0,Z.jsx)(`span`,{className:`tool-timeline-arg`,children:a(`chat.groupedTools`)})}),h&&(0,Z.jsx)(`span`,{className:`tool-timeline-running`,"aria-label":`running`,children:a(`chat.running`)}),(0,Z.jsx)(`span`,{className:`tool-timeline-chevron-toggle ${u?`open`:``}`,children:`›`})]})})]}),u&&(0,Z.jsx)(`div`,{className:`consecutive-tools-list`,style:{paddingLeft:`10px`,borderLeft:`2px solid var(--border)`,marginLeft:`5px`,marginTop:`4px`,marginBottom:`8px`,display:`flex`,flexDirection:`column`,gap:`1px`},children:e.map((e,t)=>i(e,r+t))})]})}var Qf=(0,G.memo)(function({entries:e,isStreaming:t=!1}){let{t:n}=qo(),r=e.some(e=>e.kind===`justification`),i=Q(e=>e.trailDefaultView),[a,o]=(0,G.useState)(i),[s,c]=(0,G.useState)(()=>new Set),[l,u]=(0,G.useState)(!1),d=(0,G.useRef)(t),f=(0,G.useRef)(i),p=(0,G.useRef)(r);p.current=r,(0,G.useEffect)(()=>{if(t&&!d.current&&o(i),!t&&d.current){let e=setTimeout(()=>{o(i),c(new Set)},3e3);return d.current=t,()=>clearTimeout(e)}!t&&i!==f.current&&(o(i),i===`justify`&&c(new Set)),d.current=t,f.current=i},[t,i]);let m=t&&e.some(e=>e.kind===`tool`&&e.result===void 0),{chunks:h,leading:g}=(0,G.useMemo)(()=>Yf(e),[e]),_=h.length;(0,G.useEffect)(()=>{c(e=>Jf(e,_,t,a))},[t,a,_]);let v=e=>c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),y=()=>{a===`full`?(o(`justify`),c(new Set)):o(`full`)},b=a===`full`?`Collapse All`:`Expand All`,x=(0,G.useRef)(null);(0,G.useEffect)(()=>{if(!t||a!==`full`)return;let e=requestAnimationFrame(()=>{x.current&&(x.current.scrollTop=x.current.scrollHeight)});return()=>cancelAnimationFrame(e)},[e.length,t,a]);let S=(n,r)=>{if(n.kind===`tool`){let i=String(n.block.name??`tool`),a=n.block.arguments??{};return(0,Z.jsx)(Uf,{block:n.block,result:n.result,displayName:Rf(i),previewOverride:Bf(i,a)||void 0,icon:(0,Z.jsx)($f,{toolName:i}),suppressRunning:!t,isActive:t&&n.result===void 0,isLastInTurn:r===e.length-1},`tool-${r}-${String(n.block.id??``)}`)}return n.kind===`thinking`?(0,Z.jsx)(Wf,{text:n.text},`think-${r}`):(0,Z.jsx)(`div`,{className:`trail-full-prose`,children:(0,Z.jsx)(jo,{text:n.text.trim()})},`fullprose-${r}`)},C=(e,n,r,i)=>{let o=a===`full`||s.has(n);return h.length-1,(0,Z.jsxs)(`div`,{className:`trail-chunk${o?` open`:``}${i===0&&!T?` connects-to-header`:``}`,children:[(0,Z.jsx)(Kf,{text:e.just.text,open:o,onToggle:()=>v(n)}),(0,Z.jsx)(`div`,{className:`trail-chunk-body`,"aria-hidden":!o,children:(0,Z.jsxs)(`div`,{className:`trail-chunk-content`,children:[(0,Z.jsx)(`div`,{className:`trail-full-prose`,children:(0,Z.jsx)(jo,{text:e.just.text.trim()})}),(()=>{let n=0;return Xf(e.tools).map((e,r)=>{if(Array.isArray(e)){let i=n;return n+=e.length,(0,Z.jsx)(Zf,{entries:e,view:a,isStreaming:t,startIndex:i,renderEntry:S},`group-${r}`)}else{let t=n++;return S(e,t)}})})()]})})]},r)},w=h.length>qf,T=a!==`full`&&w&&!l,E=T?h.slice(-3):h,D=T?h.length-qf:0;return(0,Z.jsxs)(`div`,{className:`trail-group`,children:[(0,Z.jsx)(`div`,{className:`trail-header`,children:(0,Z.jsxs)(`button`,{type:`button`,className:`trail-toggle`,title:`Trail view: ${a}. Click to toggle Expand All ↔ Auto`,onClick:y,children:[(0,Z.jsx)(`span`,{className:`trail-toggle-icon`,children:m?(0,Z.jsx)(ff,{style:{width:`12px`,height:`12px`,color:`var(--accent)`,margin:`1px`}}):(0,Z.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`var(--bg-solid)`,strokeWidth:`2`,style:{stroke:`currentColor`},children:(0,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`})})}),(0,Z.jsx)(`span`,{className:`trail-toggle-label`,children:n(`chat.trail`)}),(0,Z.jsx)(`span`,{className:`trail-toggle-view`,children:b}),m&&(0,Z.jsx)(`span`,{className:`trail-running-label`,children:n(`chat.runningShort`)})]})}),(0,Z.jsx)(`div`,{className:`trail-body trail-body-justify`,ref:x,children:(0,Z.jsxs)(`div`,{className:`trail-list`,children:[T&&(0,Z.jsxs)(`button`,{type:`button`,className:`trail-earlier`,onClick:()=>u(!0),children:[`▼ `,h.length-qf,` earlier steps`]}),E.map((e,t)=>C(e,D+t,`chunk-${D+t}`,t))]})})]})});function $f({toolName:e}){return(0,Z.jsx)(`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,Z.jsx)(`path`,{d:zf(e)})})}function ep(e){if(!e)return``;let t=e.trim();if(!t)return``;if(/^[a-zA-Z]:[/\\]/.test(t)||t.startsWith(`/`)||t.includes(`\\`)||/\.(gguf|bin|safetensors|pt|onnx)$/i.test(t)||t.split(`/`).length>2){let e=t.split(/[/\\]/).filter(Boolean);e.length>0&&(t=e[e.length-1])}return t=t.replace(/\.(gguf|bin|safetensors|pt|onnx)$/i,``),t}Gd.register(`javascript_repl`,({part:e})=>(0,Z.jsx)(Xd,{code:e.args?.code??``,title:e.args?.title??``,serverOutput:e.state!==`input-available`&&e.state!==`running`?e.output??``:void 0,isRunning:e.state===`running`,isError:e.state===`error`})),Gd.register(`submit_plan`,({part:e})=>{let t=String(e.args?.filePath??`PLAN.md`),n=e.details,r=e.state===`running`||e.state===`input-available`,i=n?.approved===!0,o=n?.approved===!1,s=di(e=>e.openFileReview),c=di(e=>e.submitDecision),l=di(e=>e.submitting);return(0,Z.jsxs)(`div`,{style:{border:`1px solid var(--border)`,borderRadius:`var(--radius-md, 8px)`,background:`var(--bg-glass)`,padding:`14px 18px`,margin:`10px 0`,display:`flex`,flexDirection:`column`,gap:`10px`,boxShadow:`0 1px 3px rgba(0, 0, 0, 0.05)`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`},children:[(0,Z.jsx)(`span`,{style:{fontSize:`16px`},children:`📋`}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{style:{fontSize:`13px`,fontWeight:600,color:`var(--text-primary)`},children:`Plan Submitted for Review`}),(0,Z.jsx)(`div`,{style:{fontSize:`11px`,color:`var(--text-dim)`,fontFamily:`var(--font-mono, monospace)`},children:t})]})]}),(0,Z.jsx)(`span`,{style:{fontSize:`11px`,fontWeight:600,padding:`3px 9px`,borderRadius:`12px`,background:r?`rgba(234, 179, 8, 0.15)`:i?`rgba(34, 197, 94, 0.15)`:`rgba(239, 68, 68, 0.15)`,color:r?`#eab308`:i?`#22c55e`:`#ef4444`,border:r?`1px solid rgba(234, 179, 8, 0.3)`:i?`1px solid rgba(34, 197, 94, 0.3)`:`1px solid rgba(239, 68, 68, 0.3)`},children:r?`Awaiting Review`:i?`Plan Approved`:o?`Revisions Requested`:`Plan Saved`})]}),n?.feedback&&(0,Z.jsxs)(`div`,{style:{fontSize:`12px`,padding:`8px 12px`,borderRadius:`6px`,background:`var(--bg-glass-strong, rgba(128, 128, 128, 0.08))`,color:`var(--text-secondary)`,fontStyle:`italic`,border:`1px solid var(--border)`},children:[`“`,n.feedback,`”`]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,marginTop:`2px`},children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{s(t)},style:{display:`inline-flex`,alignItems:`center`,gap:`6px`,padding:`6px 14px`,borderRadius:`6px`,fontSize:`12px`,fontWeight:500,cursor:`pointer`,background:r?`var(--accent, #3b82f6)`:`var(--bg-glass)`,color:r?`#fff`:`var(--text-primary)`,border:r?`none`:`1px solid var(--border)`,transition:`all 0.15s ease`},children:[(0,Z.jsx)(a,{size:13}),(0,Z.jsx)(`span`,{children:r?`Review Plan in Side Panel`:`View Plan`})]}),r&&(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{c({approved:!0})},disabled:l,style:{display:`inline-flex`,alignItems:`center`,gap:`4px`,padding:`6px 14px`,borderRadius:`6px`,fontSize:`12px`,fontWeight:600,cursor:`pointer`,background:`#16a34a`,color:`#fff`,border:`none`,transition:`all 0.15s ease`},children:[(0,Z.jsx)(F,{size:13,strokeWidth:2.5}),(0,Z.jsx)(`span`,{children:`Quick Approve`})]})]})]})});var tp=`pi.toolBatch.open`,np=(0,G.createContext)({open:!1,toggle:()=>void 0});function rp({children:e}){let[t,n]=(0,G.useState)(()=>{try{return localStorage.getItem(tp)===`true`}catch{return!1}});return(0,Z.jsx)(np.Provider,{value:{open:t,toggle:()=>n(e=>{let t=!e;try{localStorage.setItem(tp,String(t))}catch{}return t})},children:e})}function ip(e){return typeof e==`string`?e:Array.isArray(e)?e.map(e=>e.type===`text`?e.text??``:``).join(``):String(e??``)}function ap(e){return Array.isArray(e)?e.filter(e=>e.type===`text`).map(e=>String(e.text??``)).join(`
101
+
102
+ `):typeof e==`string`?e:``}function op(e){return Array.isArray(e)?e.filter(e=>e.type===`image`).map(e=>({mimeType:e.mimeType??`image/png`,data:e.data??``,__blobUrl:e.__blobUrl})):[]}function sp({images:e}){return e.length===0?null:(0,Z.jsx)(`div`,{className:`user-images-row`,children:e.map((e,t)=>(0,Z.jsx)(`img`,{src:e.__blobUrl?e.data:`data:${e.mimeType};base64,${e.data}`,alt:`Attached image ${t+1}`,className:`user-image-thumb`,loading:`lazy`,onError:e=>{e.target.style.display=`none`}},t))})}var cp=(0,G.memo)(function({messages:e}){return(0,Z.jsx)(Z.Fragment,{children:e.map((e,t)=>{let n=e,r=ip(n.content),i=op(n.content),a=n.role===`user`;return(0,Z.jsx)(`div`,{style:{borderRadius:`var(--radius-sm)`,padding:`8px 10px`,fontSize:`12px`,lineHeight:`1.5`,color:a?`var(--user-bubble-text)`:`var(--text-primary)`,background:a?`var(--user-bubble)`:`transparent`,border:a?`1px solid var(--user-bubble-border)`:`none`,whiteSpace:a?`pre-wrap`:void 0},children:a?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(sp,{images:i}),pp(r)]}):(0,Z.jsx)(jo,{text:r})},t)})})});function lp({text:e}){let{t}=qo(),n=Q(e=>e.showThinking),[r,i]=(0,G.useState)(!1);return n?(0,Z.jsxs)(`details`,{open:r,className:`thinking-block`,children:[(0,Z.jsxs)(`summary`,{onClick:e=>{e.preventDefault(),i(e=>!e)},children:[(0,Z.jsx)(`span`,{className:`thinking-block-chevron`,children:`▶`}),(0,Z.jsx)(`span`,{className:`thinking-block-label`,children:t(`chat.thinking`)})]}),(0,Z.jsx)(`div`,{className:`thinking-block-content`,children:e})]}):null}var up=320;function dp({running:e}){let[t,n]=(0,G.useState)(e),[r,i]=(0,G.useState)(!1),a=(0,G.useRef)(null);return(0,G.useEffect)(()=>(e?(a.current&&clearTimeout(a.current),n(e),i(!1)):t&&(i(!0),a.current=setTimeout(()=>{n(void 0),i(!1)},up)),()=>{a.current&&clearTimeout(a.current)}),[e]),t?(0,Z.jsx)(`div`,{className:`tool-running-standalone${r?` exiting`:``}`,children:(0,Z.jsx)(Uf,{block:t.block,result:void 0,initialExpanded:!1,isActive:!0,isLastInTurn:!0})}):null}var fp=(0,G.memo)(function({entries:e}){let{open:t,toggle:n}=(0,G.useContext)(np),[r,i]=(0,G.useState)(()=>t),a=()=>{i(!r),n()},o=e.filter(e=>e.kind===`tool`),s=o.length,c=o.filter(e=>e.result!==void 0&&!e.result?.isError).length,l=o.filter(e=>e.result?.isError===!0).length,u=l>0,d=o.filter(e=>e.result===void 0).length,f=d===0&&s>0,p=[...new Set(o.map(e=>String(e.block.name??`tool`)))],m=p.slice(0,4).join(` · `)+(p.length>4?` · …`:``);return(0,Z.jsxs)(`details`,{open:r,className:`tool-timeline`,style:{marginLeft:0},onToggle:e=>e.preventDefault(),children:[(0,Z.jsxs)(`summary`,{className:`tool-timeline-header`,onClick:e=>{e.preventDefault(),a()},"aria-label":`${s} tool ${s===1?`call`:`calls`}: ${m}`,children:[(0,Z.jsx)(`span`,{className:`tool-timeline-chevron`,"aria-hidden":`true`,children:r?`▾`:`▸`}),(0,Z.jsxs)(`span`,{className:`tool-timeline-batch-label`,children:[`↳ `,s,` `,s===1?`tool`:`tools`]}),s>1&&(0,Z.jsx)(`span`,{className:`tool-timeline-batch-count`,children:f?(0,Z.jsxs)(Z.Fragment,{children:[c>0&&(0,Z.jsxs)(`span`,{className:`done`,children:[`✓ `,c]}),l>0&&(0,Z.jsxs)(`span`,{className:`tool-timeline-badge error`,children:[`✖ `,l]})]}):(0,Z.jsxs)(Z.Fragment,{children:[c>0&&(0,Z.jsxs)(`span`,{className:`done`,children:[`✓ `,c]}),l>0&&(0,Z.jsxs)(`span`,{className:`tool-timeline-badge error`,style:{marginLeft:`4px`},children:[`✖ `,l]}),d>0&&(0,Z.jsxs)(`span`,{className:`pending`,children:[` ⟳ `,d]})]})}),(0,Z.jsx)(`span`,{className:`tool-timeline-batch-preview`,children:m}),u&&s===1&&(0,Z.jsx)(`span`,{className:`tool-timeline-badge error`,"aria-label":`error`,children:`error`})]}),(0,Z.jsx)(`div`,{className:`tool-timeline-track`,children:e.map((t,n)=>t.kind===`thinking`?(0,Z.jsx)(lp,{text:t.block.thinking??``},n):(0,Z.jsx)(Uf,{block:t.block,result:t.result,isActive:!1,isLastInTurn:n===e.length-1},n))})]})});function pp(e){let t=[],n=/\[@?[^\]]+? not included: [^\]]+\]/g,r;for(n.lastIndex=0;(r=n.exec(e))!==null;)t.push({start:r.index,end:r.index+r[0].length,kind:`fail`,raw:r[0]});for(let n of so(e))t.push({start:n.start,end:n.end,kind:`ref`,raw:n.raw,ref:n});t.sort((e,t)=>e.start-t.start);let i=[];for(let e of t)i.length>0&&e.start<i[i.length-1].end||i.push(e);let a=[],o=0;return i.forEach((t,n)=>{if(t.start>o&&a.push(e.slice(o,t.start)),t.kind===`fail`){let e=t.raw.match(/\[@?(.+?)(?:#L\d+(?:-L?\d+)?)? not included: ([^\]]+)\]$/),r=e?.[1]??t.raw.replace(/^\[/,``).replace(/\]$/,``),i=e?.[2]??`not included`;a.push((0,Z.jsxs)(`span`,{className:`msg-ref-chip msg-ref-missing`,title:i,children:[(0,Z.jsx)(p,{size:12}),(0,Z.jsx)(`span`,{className:`msg-ref-name`,children:r}),(0,Z.jsx)(`span`,{className:`msg-ref-reason`,children:`not found`})]},`f${n}`))}else{let e=t.ref,r=e.startLine===void 0?``:e.endLine!==void 0&&e.endLine!==e.startLine?`:L${e.startLine}-${e.endLine}`:`:L${e.startLine}`;a.push((0,Z.jsxs)(`span`,{className:`msg-ref-chip msg-ref-ok`,children:[(0,Z.jsx)(f,{size:12}),(0,Z.jsx)(`span`,{className:`msg-ref-name`,children:e.path}),r!==``&&(0,Z.jsx)(`span`,{className:`msg-ref-range`,children:r})]},`r${n}`))}o=t.end}),o<e.length&&a.push(e.slice(o)),a}var mp=(0,G.memo)(function({text:e,isSteer:t,isFollowUp:n,images:r,animated:i}){let{t:a}=qo(),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(!1),u=(0,G.useRef)(null);return(0,G.useEffect)(()=>{let e=u.current;if(!e)return;let t=()=>{o||l(e.scrollHeight>e.clientHeight)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[e,o]),(0,Z.jsx)(`div`,{className:`message-row user${i?` msg-enter`:``}`,children:(0,Z.jsxs)(`div`,{className:`message-bubble user`,children:[t&&(0,Z.jsx)(`span`,{className:`steer-tag`,children:a(`chat.steer`)}),n&&(0,Z.jsx)(`span`,{className:`steer-tag`,children:a(`chat.followUp`)}),r!==void 0&&r.length>0&&(0,Z.jsx)(sp,{images:r}),(0,Z.jsx)(`div`,{ref:u,style:{overflow:`hidden`,transition:`max-height 0.25s ease`,maxHeight:o?`2000px`:`4em`,...o?{}:{display:`-webkit-box`,WebkitLineClamp:2,WebkitBoxOrient:`vertical`}},children:pp(e)}),c&&(0,Z.jsx)(`div`,{onClick:()=>s(e=>!e),style:{marginTop:6,fontSize:12,color:`var(--accent-text)`,cursor:`pointer`,userSelect:`none`},children:o?`▲ Show less`:`▼ Show more`})]})})});function hp({getText:e}){let[t,n]=(0,G.useState)(!1),r=()=>{let t=e();if(t.length===0)return;let r=navigator.clipboard?.writeText?.bind(navigator.clipboard);r===void 0?i(t):r(t).then(()=>{n(!0),window.setTimeout(()=>n(!1),1200)}).catch(()=>i(t))},i=e=>{try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),document.execCommand(`copy`),document.body.removeChild(t),n(!0),window.setTimeout(()=>n(!1),1200)}catch{}};return(0,Z.jsx)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),e.stopPropagation(),r()},className:`copy-msg-btn`,title:`Copy message`,"aria-label":`Copy message`,children:t?(0,Z.jsx)(F,{size:12}):(0,Z.jsx)(w,{size:12})})}var gp=`data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='60' viewBox='0 0 120 60'%3E%3Crect width='120' height='60' fill='%23262626' rx='4'/%3E%3Ctext x='50%25' y='50%25' dominant-baseline='middle' text-anchor='middle' fill='%23888888' font-size='12' font-family='sans-serif'%3EImage%3C/text%3E%3C/svg%3E`;function _p(e){let t=e.split(`,`),n=t[0].match(/:(.*?);/)?.[1]||`image/png`,r=atob(t[1]),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e);return new Blob([i],{type:n})}function vp({getText:e}){let[t,n]=(0,G.useState)(!1);return(0,Z.jsx)(`button`,{type:`button`,onClick:async e=>{if(e.preventDefault(),e.stopPropagation(),t)return;let r=e.currentTarget.closest(`.assistant-msg-footer`);if(!r)return;let i=r.parentElement;if(!i)return;let a=[],o=!1;for(let e=i.children.length-1;e>=0;e--){let t=i.children[e];if(t===r){o=!0;continue}if(o){if(t.classList.contains(`message-row`)){let e=t.querySelector(`.message-bubble.assistant`);if(e){a.push(e);break}continue}if(t.classList.contains(`message-row`)&&t.classList.contains(`user`))break}}if(a.length===0)return;n(!0);let s=null;try{let e=window.getComputedStyle(document.documentElement),t=e.getPropertyValue(`--bg-solid`).trim()||e.getPropertyValue(`--surface-background`).trim()||window.getComputedStyle(document.body).backgroundColor||`#1a1a1a`;s=document.createElement(`div`),s.style.cssText=`
103
+ padding: 40px;
104
+ background-color: ${t};
105
+ display: inline-block;
106
+ width: 680px;
107
+ `;for(let e of a){let t=window.getComputedStyle(e),n=e.cloneNode(!0);n.style.cssText=`
108
+ ${t.cssText}
109
+ transform: none;
110
+ contain: none;
111
+ overflow: visible;
112
+ scrollbar-width: none;
113
+ -ms-overflow-style: none;
114
+ `,n.querySelectorAll(`*`).forEach(e=>{e.style.scrollbarWidth=`none`;let t=e.style.backgroundImage;t&&(t.includes(`http://`)||t.includes(`https://`))&&(e.style.backgroundImage=`none`)});let r=document.createElement(`style`);r.textContent=`
115
+ .png-clone::-webkit-scrollbar,
116
+ .png-clone *::-webkit-scrollbar {
117
+ display: none;
118
+ }
119
+ `,n.classList.add(`png-clone`),n.insertBefore(r,n.firstChild),n.querySelectorAll(`pre, pre code`).forEach(e=>{e.style.whiteSpace=`pre-wrap`,e.style.wordBreak=`break-word`,e.style.overflowWrap=`break-word`,e.style.overflow=`visible`});let i=e.querySelectorAll(`img`);n.querySelectorAll(`img`).forEach((e,t)=>{let n=i[t];e.removeAttribute(`srcset`);try{if(n&&n.complete&&n.naturalWidth>0&&n.naturalHeight>0){let t=document.createElement(`canvas`);t.width=n.naturalWidth,t.height=n.naturalHeight;let r=t.getContext(`2d`);if(r){r.drawImage(n,0,0),e.src=t.toDataURL(`image/png`);return}}}catch{}e.src.startsWith(`data:`)||(e.src=gp)}),n.querySelectorAll(`.copy-msg-btn, .rewind-btn, .code-copy-btn, .tool-timeline-details-btn`).forEach(e=>{e.style.display=`none`}),s.appendChild(n)}document.body.appendChild(s);let n=(s.offsetHeight||800)>3e3?1.5:2,r=_p(await ro(s,{quality:.95,pixelRatio:n,backgroundColor:t,skipFonts:!0,imagePlaceholder:gp})),i=URL.createObjectURL(r),o=document.createElement(`a`);o.download=`message-${Date.now()}.png`,o.href=i,document.body.appendChild(o),o.click(),document.body.removeChild(o),setTimeout(()=>URL.revokeObjectURL(i),1e3)}catch(e){console.error(`Failed to save message as PNG:`,e)}finally{s&&s.parentNode&&s.parentNode.removeChild(s),n(!1)}},className:`copy-msg-btn save-png-btn`,title:`Save message as PNG`,"aria-label":`Save message as PNG`,disabled:t,children:(0,Z.jsx)(B,{size:12})})}function yp({msg:e,sessionId:t}){let[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(!1),c=e._pendingExec===!0,l=c&&e.exitCode===void 0,u=e.output.length>0,d=(0,G.useRef)(l);(0,G.useEffect)(()=>{d.current&&!l&&r(!0),d.current=l},[l]),(0,G.useEffect)(()=>{if(!i)return;let e=setTimeout(()=>{a(!1),s(!0)},3e3);return()=>clearTimeout(e)},[i]);let f,p;return e.cancelled?(f=`⛔`,p=`cancelled`):o?(f=`⚠️`,p=`cancel timed out`):i?(f=`⏳`,p=`cancelling…`):l?(f=`⟳`,p=`running`):e.exitCode===0?(f=`✅`,p=`success`):(f=`❌`,p=`exit ${e.exitCode??`?`}`),(0,Z.jsx)(`div`,{className:`message-row user`,style:{width:`100%`,margin:`8px 0`},children:(0,Z.jsxs)(`div`,{className:`message-bubble user`,style:{borderLeft:`3px solid var(--accent-text)`,maxWidth:`100%`,width:`100%`,borderRadius:`var(--radius-lg)`,whiteSpace:`normal`,boxSizing:`border-box`},children:[(0,Z.jsxs)(`div`,{role:u?`button`:void 0,tabIndex:u?0:void 0,onClick:()=>{!l&&u&&r(e=>!e)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&!l&&u&&(e.preventDefault(),r(e=>!e))},style:{display:`flex`,alignItems:`center`,gap:6,fontSize:12,cursor:u&&!l?`pointer`:`default`,userSelect:`none`},children:[u&&!l&&(0,Z.jsx)(`span`,{style:{fontSize:9,opacity:.5,width:12,textAlign:`center`,flexShrink:0},children:n?`▾`:`▸`}),(0,Z.jsxs)(`span`,{style:{fontFamily:`monospace`,fontWeight:600},children:[`$ `,e.command]}),(0,Z.jsxs)(`span`,{style:{fontSize:10,opacity:.65},children:[f,` `,p]}),e.excludeFromContext&&(0,Z.jsx)(`span`,{style:{fontSize:9,padding:`0 4px`,borderRadius:3,background:`var(--bg-subtle)`,opacity:.5},children:`local only`}),c&&l&&!i&&(0,Z.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),a(!0),Un(t)},style:{marginLeft:`auto`,background:`var(--bg-glass-active)`,border:`1px solid var(--border)`,borderRadius:`var(--radius-sm)`,padding:`1px 6px`,fontSize:10,cursor:`pointer`,color:`var(--text-secondary)`},children:`cancel`}),i&&c&&(0,Z.jsx)(`span`,{style:{fontSize:9,opacity:.5,marginLeft:`auto`},children:`cancelling…`}),u&&!n&&!l&&(0,Z.jsx)(`span`,{style:{fontSize:9,opacity:.4,marginLeft:`auto`},children:e.output.length<1024?`${e.output.length} B`:`${(e.output.length/1024).toFixed(1)} KB`})]}),l&&(0,Z.jsxs)(`pre`,{style:{fontSize:11,fontFamily:`monospace`,whiteSpace:`pre-wrap`,wordBreak:`break-all`,margin:`6px 0 0`,maxHeight:400,overflow:`auto`,opacity:.85},children:[e.output||``,(0,Z.jsx)(`span`,{style:{animation:`blink 1s step-end infinite`},children:`█`})]}),!l&&u&&n&&(0,Z.jsx)(`pre`,{style:{fontSize:11,fontFamily:`monospace`,whiteSpace:`pre-wrap`,wordBreak:`break-all`,margin:`6px 0 0`,maxHeight:400,overflow:`auto`},children:e.truncated?e.output+`
120
+ …(truncated)`:e.output})]})})}function bp({msg:e}){let t=e?.usage,n=t?.input,r=t?.output;return n==null&&r==null?null:(0,Z.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:6},children:[n!=null&&(0,Z.jsxs)(`span`,{style:{fontSize:10,color:`var(--text-secondary)`},children:[`↑`,n.toLocaleString()]}),r!=null&&(0,Z.jsxs)(`span`,{style:{fontSize:10,color:`var(--text-secondary)`},children:[`↓`,r.toLocaleString()]})]})}function xp({sessionId:e}){let[t,n]=(0,G.useState)(!1);return(0,Z.jsx)(`button`,{type:`button`,disabled:t,onClick:async t=>{t.preventDefault(),t.stopPropagation(),n(!0);try{await wr(e,`rewind`)}catch{}finally{n(!1)}},className:`copy-msg-btn rewind-btn`,title:`Rewind to checkpoint (requires pi-rewind)`,"aria-label":`Rewind`,children:(0,Z.jsx)(d,{size:12})})}function Sp({msg:e,fallbackModel:t,fallbackProvider:n}){let r=(typeof e?.model==`string`?e.model:void 0)??t,i=(typeof e?.provider==`string`?e.provider:void 0)??n;if(!r)return null;let a=ep(r);return(0,Z.jsxs)(`span`,{className:`assistant-msg-model`,title:i?`${i} / ${r}`:r,children:[i?`${i} / `:``,a]})}function Cp({label:e}){let{t}=qo();return(0,Z.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:`8px`,color:`var(--text-dim)`},children:[(0,Z.jsx)(ff,{style:{width:`16px`,height:`16px`,color:`var(--text-primary)`}}),(0,Z.jsx)(`span`,{className:`chat-shimmer`,style:{fontSize:`14px`},children:e??t(`chat.waitingForModel`)})]})}function wp({sessionId:e,modelName:t,providerName:n}){let{t:r}=qo(),i=Y(e=>e.messages),a=Y(e=>e.streamingMessage),o=Y(e=>e.isStreaming),s=Y(t=>t.compactionsBySession[e]??Oi),c=Y(e=>e.activeCompaction),l=Y(e=>e.messages),u=s,d=Y(t=>t.queuedBySession[e]),f=Y(e=>e.error),p=Y(e=>e.clearError);Y(e=>e.sendPrompt);let{rewind:m}=Li(),h=Q(e=>e.stickyUserHeader),g=Q(e=>e.flyToTop),_=Q(e=>e.showTokenUsage),v=Q(e=>e.groupedToolDisplay),y=Q(e=>e.showTurnFiles),b=Q(e=>e.emptyFlapEnabled),x=Q(e=>e.emptyFlapWords),S=e=>{let t=new Map;for(let n of e){let e=n;e.role===`toolResult`&&typeof e.toolCallId==`string`&&t.set(e.toolCallId,e)}return t},C=q(e=>e.pushArtifact),w=q(e=>e.openFileViewer),T=(0,G.useRef)(new Set);(0,G.useEffect)(()=>{T.current.clear()},[e]),(0,G.useEffect)(()=>{let t=S(i);for(let n of i){let r=n,i=r.content;if(Array.isArray(i))for(let n of i){let i=n;if(i.type===`toolCall`){let n=typeof i.id==`string`?i.id:``;if(!n||T.current.has(n))continue;let r=t.get(n);if(!r)continue;T.current.add(n);let a=ap(r.content),o=a.trim(),s,c=typeof i.name==`string`?i.name:`Tool Output`;if(/^\s*<!doctype\s+html/i.test(o)||/^\s*<html/i.test(o))s=`html`;else if(/^\s*<svg/i.test(o)&&o.includes(`</svg>`))s=`svg`;else if(/^data:image\//.test(o))s=`image`;else if(/^\s*[[{]/.test(o))try{JSON.parse(o),s=`json`}catch{}s&&C({title:c,type:s,content:a,sessionId:e})}if(i.type===`text`&&typeof i.text==`string`){let t=/```(svg|html|json|markdown|md|text|plain|txt|image)\s*\n([\s\S]*?)```/gi,n;for(;(n=t.exec(i.text))!==null;){let t=n[1].toLowerCase(),i=n[2].trim(),a=`${r.id??``}-text-${n.index}`;if(T.current.has(a))continue;T.current.add(a);let o,s;switch(t){case`svg`:o=`svg`,s=`SVG`;break;case`html`:o=`html`,s=`HTML`;break;case`json`:o=`json`,s=`JSON`;break;case`markdown`:case`md`:o=`markdown`,s=`Markdown`;break;case`text`:case`plain`:case`txt`:o=`text`,s=`Text`;break;case`image`:o=`image`,s=`Image`;break;default:o=`text`,s=`Text`}C({title:s,type:o,content:i,sessionId:e})}}}}},[i,C,e]);let E=(0,G.useRef)(null),D=(0,G.useRef)(!0),O=(0,G.useRef)(0),k=(0,G.useRef)(void 0),A=(0,G.useRef)(null),j=(0,G.useRef)(!1),[M,N]=(0,G.useState)(!1),P=(0,G.useRef)(0),[F,I]=(0,G.useState)(0),L=(0,G.useRef)(!1),R=(0,G.useRef)(0),z=(0,G.useRef)(!1),ee=()=>{let e=E.current;if(e===null)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight,n=e.scrollTop<O.current-1,r=t<=24;n&&!r?D.current=!1:!n&&r&&(D.current=!0),O.current=e.scrollTop},B=(0,G.useCallback)(()=>{let e=E.current,t=A.current;if(e===null||t===null)return;let n=t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop,r=Math.max(0,e.scrollHeight-e.clientHeight);e.scrollTo({top:Math.min(Math.max(0,n),r),behavior:`smooth`})},[]);(0,G.useEffect)(()=>{let e=E.current;if(!e||typeof ResizeObserver>`u`)return;let t=k.current!==void 0&&a===void 0;k.current=a;let n=!1,r=!0,i=new ResizeObserver(()=>{if(r){if(t&&!n){n=!0;return}D.current&&!(j.current&&P.current>0)&&(e.scrollTop=e.scrollHeight,O.current=e.scrollTop)}});i.observe(e);let o=e.firstElementChild;return o instanceof Element&&i.observe(o),()=>{r=!1,i.disconnect()}},[l,a]),(0,G.useEffect)(()=>{l.length===0&&a===void 0||(D.current=!0)},[e]),(0,G.useEffect)(()=>{z.current=!1,R.current=0,j.current=!1,N(!1),P.current=0,I(0),L.current=!1},[e]),(0,G.useLayoutEffect)(()=>{let e=R.current;if(R.current=l.length,!z.current&&(z.current=!0,l.length>0)||l.length-e>1||!g||l.length<=e)return;let t=l[l.length-1]?.role;(t===`user`||t===`user-with-attachments`)&&(j.current=!0,D.current=!1,L.current=!0,N(!0))},[l,g]),(0,G.useLayoutEffect)(()=>{if(!g||!M){P.current!==0&&(P.current=0,I(0));return}let e=E.current,t=A.current;if(e===null||t===null)return;let n=!0,r=()=>{if(!n)return;let r=t.offsetHeight,i=Math.max(0,Math.ceil(e.clientHeight-r));if(i!==P.current){let e=P.current===0&&i>0;P.current=i,e&&(L.current=!0),i===0&&(D.current=!0),I(i)}};r();let i=new ResizeObserver(r);return i.observe(e),i.observe(t),()=>{n=!1,i.disconnect()}},[g,M,l.length]),(0,G.useLayoutEffect)(()=>{L.current&&F>0&&(L.current=!1,B())},[F,B]),(0,G.useMemo)(()=>{if(!a)return;let e=a.content;if(!Array.isArray(e))return;let t=e.find(e=>e.type===`toolCall`);return t?String(t.name??`tool`):void 0},[a]);let V=(0,G.useMemo)(()=>{let e=new Map;for(let t of i){let n=t;n.role===`toolResult`&&typeof n.toolCallId==`string`&&e.set(n.toolCallId,n)}return e},[i]),H=(0,G.useRef)(new Map);(0,G.useEffect)(()=>{H.current.clear()},[e]);let U=(0,G.useMemo)(()=>{let i=[],s=new Map;for(let e of u){let t=s.get(e.insertBeforeIndex)??[];t.push(e),s.set(e.insertBeforeIndex,t)}let c=e=>(0,Z.jsx)(cp,{messages:e.archivedMessages}),d=e=>{let t=s.get(e);if(t!==void 0)for(let e of t)i.push((0,Z.jsx)(Zo,{event:e,renderArchived:()=>c(e)},`compaction-${e.id}`))},f=(u.length>0?u[u.length-1]:void 0)?.insertBeforeIndex??0,p=t=>{let n=[],i=[],a=0,o=e=>{if(i.length===0)return;let t=i.filter(e=>e.kind!==`tool`||e.result!==void 0),r=i.find(e=>e.kind===`tool`&&e.result===void 0);if(i.length=0,t.length>0){let r=t.find(e=>e.kind===`tool`)?.block?.id,i=r?`batch-id-${r}`:`batch-${e}`;n.push((0,Z.jsx)(`div`,{className:`message-row assistant`,children:(0,Z.jsx)(`div`,{className:`message-bubble assistant`,children:(0,Z.jsx)(fp,{entries:t})})},i))}n.push((0,Z.jsx)(`div`,{className:`message-row assistant`,children:(0,Z.jsx)(`div`,{className:`message-bubble assistant`,children:(0,Z.jsx)(dp,{running:r})})},`running-standalone-slot`))},s=(e,t)=>{if(t.length===0)return;o(`pretool-${e}-${a}`);let r=a++;n.push((0,Z.jsx)(`div`,{className:`message-row assistant`,children:(0,Z.jsx)(`div`,{className:`message-bubble assistant`,children:(0,Z.jsx)(`div`,{className:`assistant-blocks`,children:t.map((e,t)=>e.type===`text`?(0,Z.jsx)(jo,{text:e.text??``},t):(0,Z.jsx)(lp,{text:e.text??``},t))})})},`prose-${e}-${r}`))},c=e=>{let t=[];for(;e.length>0;){let n=e[e.length-1];if(n.type!==`thinking`)break;e.pop(),t.unshift({kind:`thinking`,block:{type:`thinking`,thinking:n.text}})}return t};for(let a of t){let t=a.role;if(t===`bashExecution`){n.push((0,Z.jsx)(yp,{msg:a,sessionId:e},`bash-${String(a.timestamp??a.command??``)}`));continue}if(t===`branchSummary`){let e=a.summary??``,t=a.fromId;n.push((0,Z.jsx)(`div`,{className:`message-row assistant`,children:(0,Z.jsx)(`div`,{className:`message-bubble assistant`,children:(0,Z.jsxs)(`div`,{className:`branch-summary-block`,children:[(0,Z.jsx)(`div`,{className:`branch-summary-label`,children:r(`chat.branchSummary`)}),(0,Z.jsx)(jo,{text:e}),t&&(0,Z.jsxs)(`div`,{className:`branch-summary-from`,title:t,children:[`from `,t.slice(0,8),`...`]})]})})},`branch-${String(a.id??``)}`));continue}if(t===`custom`){if(a.display===!1)continue;let e=a.customType??`custom`,t=a.content,i=a.details,o;o=typeof t==`string`?(0,Z.jsx)(jo,{text:t}):Array.isArray(t)?(0,Z.jsx)(`div`,{children:t.map((e,t)=>e.type===`text`?(0,Z.jsx)(jo,{text:String(e.text??``)},t):e.type===`image`?(0,Z.jsx)(`img`,{src:`data:${String(e.mimeType??`image/png`)};base64,${String(e.data??``)}`,alt:`Custom message image`,style:{maxWidth:`100%`,height:`auto`}},t):null)}):null,n.push((0,Z.jsx)(`div`,{className:`message-row assistant`,children:(0,Z.jsx)(`div`,{className:`message-bubble assistant`,children:(0,Z.jsxs)(`div`,{className:`custom-message-block`,children:[e!==`custom`&&(0,Z.jsx)(`div`,{className:`custom-message-type`,children:e}),o,i!=null&&(0,Z.jsxs)(`details`,{className:`custom-message-details`,children:[(0,Z.jsx)(`summary`,{children:r(`chat.details`)}),(0,Z.jsx)(`pre`,{children:JSON.stringify(i,null,2)})]})]})})},`custom-msg-${String(a.id??``)}`));continue}let l=a.content;if(!Array.isArray(l)){let e=typeof l==`string`?l:``;e&&s(a.id??``,[{type:`text`,text:e}]);continue}let u=[];for(let e of l){let t=e,r=t.type;if(r===`toolCall`){let e=c(u);s(a.id??``,u),u.length=0;let r=String(t.name??`tool`),l=String(t.id??``),d=t.arguments??{},f=l?V.get(l):void 0,p={type:`tool-call`,toolName:r,toolCallId:l,args:d,state:f?f.isError===!0?`error`:`success`:`running`,output:f?ap(f.content):void 0,errorText:f&&f.isError===!0?ap(f.content)||`Tool returned error`:void 0,details:f?.details},m=Gd.get(r);if(m){o(`precustom-${a.id??``}-${l}`),n.push((0,Z.jsx)(`div`,{className:`message-row assistant`,children:(0,Z.jsx)(`div`,{className:`message-bubble assistant`,children:(0,Z.jsx)(m,{part:p,messageId:a.id??``})})},`custom-${a.id??``}-${l}`));continue}i.push(...e),i.push({kind:`tool`,block:{name:r,arguments:d,id:l},result:f??void 0})}else r===`text`&&typeof t.text==`string`&&t.text.trim()!==``?u.push({type:`text`,text:t.text}):(r===`thinking`||r===`reasoning`)&&typeof t.thinking==`string`&&t.thinking.trim()!==``&&u.push({type:`thinking`,text:t.thinking})}s(String(a.id??``),u)}return o(`toolbatch-end`),n},b=e=>V.get(e),x=e=>Gd.get(e)!==void 0,S=(t,n)=>{let i=t.role;if(i===`bashExecution`)return(0,Z.jsx)(yp,{msg:t,sessionId:e},n);if(i===`branchSummary`){let e=t.summary??``,i=t.fromId;return(0,Z.jsx)(`div`,{className:`message-row assistant`,children:(0,Z.jsx)(`div`,{className:`message-bubble assistant`,children:(0,Z.jsxs)(`div`,{className:`branch-summary-block`,children:[(0,Z.jsx)(`div`,{className:`branch-summary-label`,children:r(`chat.branchSummary`)}),(0,Z.jsx)(jo,{text:e}),i&&(0,Z.jsxs)(`div`,{className:`branch-summary-from`,title:i,children:[`from `,i.slice(0,8),`...`]})]})})},n)}if(i===`custom`){if(t.display===!1)return null;let e=t.customType??`custom`,i=t.content,a=t.details,o;return o=typeof i==`string`?(0,Z.jsx)(jo,{text:i}):Array.isArray(i)?(0,Z.jsx)(`div`,{children:i.map((e,t)=>e.type===`text`?(0,Z.jsx)(jo,{text:String(e.text??``)},t):e.type===`image`?(0,Z.jsx)(`img`,{src:`data:${String(e.mimeType??`image/png`)};base64,${String(e.data??``)}`,alt:`Custom message image`,style:{maxWidth:`100%`,height:`auto`}},t):null)}):null,(0,Z.jsx)(`div`,{className:`message-row assistant`,children:(0,Z.jsx)(`div`,{className:`message-bubble assistant`,children:(0,Z.jsxs)(`div`,{className:`custom-message-block`,children:[e!==`custom`&&(0,Z.jsx)(`div`,{className:`custom-message-type`,children:e}),o,a!=null&&(0,Z.jsxs)(`details`,{className:`custom-message-details`,children:[(0,Z.jsx)(`summary`,{children:r(`chat.details`)}),(0,Z.jsx)(`pre`,{children:JSON.stringify(a,null,2)})]})]})})},n)}return null},C=(e,t,n)=>{let r=[],i=n&&o,a=(e,n)=>{if(e.entries.length===0)return;let a=e.firstToolId?`trail-${t}-${e.firstToolId}`:`trail-${t}-${n}`;r.push((0,Z.jsx)(`div`,{className:`message-row assistant`,children:(0,Z.jsx)(`div`,{className:`message-bubble assistant`,children:(0,Z.jsx)(Qf,{entries:e.entries,isStreaming:i})})},a))},s=e=>{let n=Gd.get(e.name),i={type:`tool-call`,toolName:e.name,toolCallId:e.id,args:e.args,state:e.result?e.result.isError===!0?`error`:`success`:`running`,output:e.result?ap(e.result.content):void 0,errorText:e.result&&e.result.isError===!0?ap(e.result.content)||`Tool returned error`:void 0,details:e.result?.details};n?r.push((0,Z.jsx)(`div`,{className:`message-row assistant`,children:(0,Z.jsx)(`div`,{className:`message-bubble assistant`,children:(0,Z.jsx)(n,{part:i,messageId:e.msgId??t})})},`custom-${t}-${e.id}`)):a({entries:[{kind:`tool`,block:{name:e.name,arguments:e.args,id:e.id},result:e.result}],firstToolId:e.id},r.length)};if(e.items&&e.items.length>0){let n=0;for(let i of e.items)if(i.kind===`segment`)a(i.segment,n++);else if(i.kind===`customTool`)s(i.customTool);else if(i.kind===`special`){let e=S(i.message,`special-${t}-${r.length}`);e&&r.push(e)}}else{e.segments.forEach((e,t)=>a(e,t));for(let t of e.customTools)s(t);for(let n of e.specials){let e=S(n,`special-${t}-${r.length}`);e&&r.push(e)}}let c=0;for(let n of e.finalParts)n.type===`text`?r.push((0,Z.jsx)(`div`,{className:`message-row assistant`,children:(0,Z.jsx)(`div`,{className:`message-bubble assistant`,children:(0,Z.jsx)(`div`,{className:`assistant-blocks`,children:(0,Z.jsx)(jo,{text:n.text})})})},`final-${t}-${c++}`)):r.push((0,Z.jsx)(lp,{text:n.text},`final-${t}-${c++}`));return r},T=0,E,D=[],O=-1,k=-1;for(let e=l.length-1;e>=0;e--){let t=l[e].role;if(t===`user`||t===`user-with-attachments`){k=e;break}}let j=e=>{e!==null&&(A.current=e)},N=()=>{if(E===void 0)return;let a=P,s=k>=0&&O===k,c=lo(D,e=>e===void 0?void 0:b(e)),l=typeof E.id==`string`?E.id:`turn-${T}`;T++;let u=ap(E.content),d,f;if(v){let e=new Set;for(let t of D){let n=t.content;if(Array.isArray(n))for(let t of n)t.type===`toolCall`&&typeof t.id==`string`&&e.add(t.id)}let t=[...e].filter(e=>V.has(e)).length,n=D.map(e=>String(e.id??``)).join(`,`)+`:tr${t}`,r=H.current.get(n);r===void 0&&(r=Lf(D,b,x),String(D[D.length-1]?.id??``)&&H.current.set(n,r)),d=r.finalParts.filter(e=>e.type===`text`).map(e=>e.text).join(`
121
+
122
+ `),f=C(r,l,s)}else d=D.map(e=>ap(e.content)).filter(e=>e.length>0).join(`
123
+
124
+ `),f=p(D);f.length===0&&s&&o&&f.push((0,Z.jsx)(`div`,{className:`message-row assistant streaming-row`,children:(0,Z.jsx)(`div`,{className:`message-bubble assistant streaming-bubble`,children:(0,Z.jsx)(Cp,{})})},`streaming-${l}`));let S=E.metadata?.steer===!0,A=E.metadata?.followUp===!0,N=D[D.length-1];(h||g&&s&&(o||M))&&u.length>0?i.push((0,Z.jsxs)(`div`,{style:{position:`relative`},ref:s?j:void 0,children:[(0,Z.jsxs)(`div`,{style:{position:`sticky`,top:0,zIndex:10,background:`var(--bg-solid)`,overflowAnchor:`none`},children:[(0,Z.jsx)(mp,{text:u,isSteer:S,isFollowUp:A,images:op(E.content),animated:s&&M}),u.length>0&&(0,Z.jsxs)(`div`,{className:`assistant-msg-footer user`,children:[(0,Z.jsx)(hp,{getText:()=>u}),m&&(0,Z.jsx)(xp,{sessionId:e})]})]}),N&&(0,Z.jsx)(`div`,{className:`assistant-msg-model-header`,children:(0,Z.jsx)(Sp,{msg:N,fallbackModel:t,fallbackProvider:n})}),f,d.length>0&&(0,Z.jsxs)(`div`,{className:`assistant-msg-footer`,children:[(0,Z.jsx)(hp,{getText:()=>d}),(0,Z.jsx)(vp,{getText:()=>d}),_&&(0,Z.jsx)(bp,{msg:N})]}),c.length>0&&y&&(0,Z.jsx)(Ld,{files:c,sessionId:e,startIndex:O>=0?O:void 0,endIndex:a,onOpen:e=>w(e,e.split(/[\\/]/).pop()??e)})]},`turn-${l}`)):(i.push((0,Z.jsx)(`div`,{className:`message-row user${s&&M?` msg-enter`:``}`,ref:s?j:void 0,children:(0,Z.jsxs)(`div`,{className:`message-bubble user`,children:[S&&(0,Z.jsx)(`span`,{className:`steer-tag`,children:r(`chat.steer`)}),A&&(0,Z.jsx)(`span`,{className:`steer-tag`,children:r(`chat.followUp`)}),(0,Z.jsx)(sp,{images:op(E.content)}),u]})},`user-${l}`)),u.length>0&&i.push((0,Z.jsxs)(`div`,{className:`assistant-msg-footer user`,children:[(0,Z.jsx)(hp,{getText:()=>u}),m&&(0,Z.jsx)(xp,{sessionId:e})]},`user-${l}-copy`)),N&&i.push((0,Z.jsx)(`div`,{className:`assistant-msg-model-header`,children:(0,Z.jsx)(Sp,{msg:N,fallbackModel:t,fallbackProvider:n})},`turn-${l}-model`)),D.length>0&&i.push(...f),d.length>0&&i.push((0,Z.jsxs)(`div`,{className:`assistant-msg-footer`,children:[(0,Z.jsx)(hp,{getText:()=>d}),(0,Z.jsx)(vp,{getText:()=>d}),_&&(0,Z.jsx)(bp,{msg:N})]},`turn-${l}-copy`)),c.length>0&&y&&i.push((0,Z.jsx)(Ld,{files:c,sessionId:e,startIndex:O>=0?O:void 0,endIndex:a,onOpen:e=>w(e,e.split(/[\\/]/).pop()??e)},`${l}-files`))),E=void 0,D=[]};d(0);let P=0;for(let t of l){let n=t.role,r=P++;if(n!==`compactionSummary`){if(r>=1&&r<f){N();continue}if(n===`user`||n===`user-with-attachments`)N(),E=t,O=r;else if(n===`bashExecution`)N(),i.push((0,Z.jsx)(yp,{msg:t,sessionId:e},`bash-${String(t.timestamp??`${t.command??``}-${r}`)}`));else if(n!==`toolResult`){if(n===`custom`&&t.display===!1)continue;if(E!==void 0)D.push(t);else if(v){let e=Lf([t],b,x);i.push(...C(e,`orphan-${r}`,!1))}else i.push(...p([t]))}}}a!==void 0&&E!==void 0&&o&&D.push(a),N();let F=l.length;return d(F),i},[i,V,a,o,h,u,e,m,l,v,y,M,g]);return(0,Z.jsx)(rp,{children:(0,Z.jsx)(Wd,{children:(0,Z.jsxs)(`div`,{className:`messages-container`,style:h?{paddingTop:50}:void 0,children:[f!==void 0&&(0,Z.jsxs)(`div`,{onClick:p,className:`error-banner`,children:[f,` — click to dismiss`]}),l.length===0&&!o?(0,Z.jsxs)(`div`,{className:`welcome`,children:[b?(0,Z.jsx)(sf,{words:x.map(e=>e.toUpperCase()),flipDuration:.12,stagger:.05,cycleDelay:2800,flipsPerChar:7,gap:5,tileRadius:6,charset:`ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-/`,fontSize:`min(64px, calc((100cqi - ${(Math.max(12,...x.map(e=>e.length))-1)*5}px) / ${Math.max(12,...x.map(e=>e.length))*.78}))`,className:`welcome-flap`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`welcome-icon`,children:`💬`}),(0,Z.jsx)(`div`,{className:`welcome-text`,children:r(`chat.startChatting`)})]}),(0,Z.jsx)(`div`,{className:`welcome-hint`,children:r(`chat.emptyState`)})]}):(0,Z.jsxs)(`div`,{ref:E,onScroll:ee,style:h||g?{paddingTop:0}:void 0,className:`chat-scroll`,children:[(0,Z.jsxs)(`div`,{className:`chat-message-list`,children:[U,o&&a!==void 0&&null,c!==null&&(0,Z.jsx)(zd,{compaction:c}),d!==void 0&&(d.steering.length>0||d.followUp.length>0)&&(0,Z.jsx)(`div`,{className:`queued-msgs`,children:[...d.steering.map(e=>({kind:`steer`,text:e})),...d.followUp.map(e=>({kind:`followUp`,text:e}))].map((e,t)=>(0,Z.jsxs)(`div`,{className:`queued-msg-item`,children:[(0,Z.jsx)(`span`,{className:`steer-tag`,style:{marginLeft:6},children:e.kind===`steer`?r(`chat.steer`):r(`chat.followUp`)}),(0,Z.jsx)(`span`,{className:`queued-msg-text`,title:e.text,children:e.text})]},t))})]}),F>0&&(0,Z.jsx)(`div`,{"aria-hidden":`true`,style:{height:F,flexShrink:0}})]})]})})})}function Tp(e){let t=[];for(let n of e)for(let e of n.models)t.push({value:e.id,provider:n.provider,name:e.name,hasAuth:e.hasAuth,contextWindow:e.contextWindow});return t}function Ep(e,t){let n=t.toLowerCase();if(e.name.toLowerCase().startsWith(n))return 0;if(e.provider.toLowerCase().includes(n))return 1;if(e.name.toLowerCase().includes(n))return 2;if(e.value.toLowerCase().includes(n))return 3}function Dp({sessionId:e,selected:t,onSelect:n,onError:r,compact:i}){let[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)([]),[l,u]=(0,G.useState)(void 0),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(-1),[h,g]=(0,G.useState)(void 0),_=(0,G.useRef)(null),v=(0,G.useRef)(null),y=(0,G.useRef)(null);(0,G.useEffect)(()=>{(async()=>{try{let[e,t,n]=await Promise.all([wn(),On(),Ln()]),r=n.enabledModels;if(r!==null&&r.length>0){let t=new Set(r),n=e.providers.map(e=>({...e,models:e.models.filter(n=>t.has(`${e.provider}/${n.id}`))})).filter(e=>e.models.length>0);c(n)}else c(e.providers);let i=t.defaultProvider,a=t.defaultModel;i&&a&&u({provider:i,modelId:a})}catch{}})()},[]),(0,G.useEffect)(()=>{if(!a)return;let e=e=>{_.current&&!_.current.contains(e.target)&&o(!1)};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[a]),(0,G.useEffect)(()=>{a&&(f(``),m(-1))},[a]);let b=(0,G.useMemo)(()=>Tp(s),[s]),x=(0,G.useMemo)(()=>{let e=b.filter(e=>e.hasAuth);if(d.trim().length===0)return e;let t=[];for(let n of e){let e=Ep(n,d);e!==void 0&&t.push({opt:n,score:e})}return t.sort((e,t)=>e.score-t.score),t.map(e=>e.opt)},[b,d]),S=b.find(e=>e.value===t),C=S?.name??l?.modelId??`default`,w=i?ep(C):S===void 0?l!==void 0&&l.provider.length>0&&l.modelId.length>0?`${l.provider} / ${ep(l.modelId)} (default)`:`default model`:`${S.provider} / ${ep(S.name)}`,T=t=>{if(o(!1),t===-1){e===void 0?n(``,``):(g(`default`),zn(e,l?.provider??``,l?.modelId??``).then(()=>n(``,``)).catch(e=>r(e instanceof Error?e.message:`Failed`)).finally(()=>g(void 0)));return}let i=x[t];if(i!==void 0){if(e===void 0){n(i.value,i.provider);return}g(i.value),zn(e,i.provider,i.value).then(()=>n(i.value,i.provider)).catch(e=>r(e instanceof Error?e.message:`Failed`)).finally(()=>g(void 0))}},E=(0,G.useCallback)(e=>{e.key===`ArrowDown`?(e.preventDefault(),m(e=>Math.min(e+1,x.length))):e.key===`ArrowUp`?(e.preventDefault(),m(e=>Math.max(e-1,-1))):e.key===`Enter`?(e.preventDefault(),T(p)):e.key===`Escape`&&(e.preventDefault(),o(!1))},[x,p]);return(0,G.useEffect)(()=>{!a||y.current===null||p<0||y.current.querySelector(`[data-idx="${p}"]`)?.scrollIntoView({block:`nearest`})},[a,p]),(0,Z.jsxs)(`div`,{ref:_,className:`model-dropdown`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`model-dropdown-btn`,onClick:()=>o(e=>!e),disabled:h!==void 0,title:w,style:{opacity:h===void 0?1:.6},children:[(0,Z.jsx)(`span`,{style:{flex:1,minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:h===void 0?w:`Setting...`}),(0,Z.jsx)(`span`,{className:`model-dropdown-chevron`,children:`▾`})]}),a&&(0,Z.jsxs)(`div`,{className:`model-dropdown-menu`,style:{left:`auto`,right:0,maxWidth:`calc(100vw - 32px)`},children:[(0,Z.jsx)(`input`,{ref:v,type:`text`,value:d,onChange:e=>{f(e.target.value),m(-1)},onKeyDown:E,placeholder:`Search provider or model…`,className:`model-dropdown-search`,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`none`,spellCheck:!1}),(0,Z.jsxs)(`div`,{ref:y,className:`model-dropdown-list`,children:[(0,Z.jsxs)(`button`,{"data-idx":-1,onMouseEnter:()=>m(-1),onClick:()=>T(-1),className:`model-dropdown-item ${p===-1?`model-dropdown-active`:``}`,children:[(0,Z.jsx)(`span`,{children:`Use agent default`}),l!==void 0&&l.provider.length>0&&(0,Z.jsxs)(`span`,{className:`model-dropdown-item-ctx`,children:[l.provider,` / `,l.modelId]}),t===``&&(0,Z.jsx)(`span`,{className:`text-green`,children:`●`})]}),x.length===0?(0,Z.jsx)(`div`,{className:`model-dropdown-empty`,children:d?`No models match`:`No models available`}):x.map((e,n)=>(0,Z.jsxs)(`button`,{"data-idx":n,onMouseEnter:()=>m(n),onClick:()=>T(n),className:`model-dropdown-item ${p===n?`model-dropdown-active`:``}`,style:{opacity:e.hasAuth?1:.4,cursor:e.hasAuth?`pointer`:`not-allowed`},title:e.hasAuth?void 0:`No API key for ${e.provider}`,children:[(0,Z.jsxs)(`span`,{className:`model-dropdown-item-main`,children:[(0,Z.jsx)(`span`,{className:`model-dropdown-provider`,children:e.provider}),(0,Z.jsx)(`span`,{className:`model-dropdown-name`,title:e.name,children:ep(e.name)})]}),!e.hasAuth&&(0,Z.jsx)(`span`,{className:`model-dropdown-warn`,children:`⚠`}),e.value===t&&(0,Z.jsx)(`span`,{className:`text-green`,children:`●`})]},e.value))]}),(0,Z.jsxs)(`div`,{className:`model-dropdown-footer`,children:[x.length,` of `,b.length,` models — ↑↓ move, Enter pick, Esc close`]})]})]})}var Op=At(e=>({pendingSend:void 0,sendSelection:t=>e(e=>({pendingSend:{...t,nonce:(e.pendingSend?.nonce??0)+1}})),consumeSend:()=>e({pendingSend:void 0})}));function kp({sessionId:e,showOrch:t,setShowOrch:n,selectedModel:r,onModelSelect:i,onModelError:a}){let{t:o}=qo(),s=(0,G.useRef)(null),c=Op(e=>e.pendingSend),l=Op(e=>e.consumeSend),u=Y(e=>e.streamState.isStreaming),d=Y(e=>e.streamState.activeToolName),p=di(e=>e.planModeActive),m=di(e=>!!e.activeReview?.requestId),h=Y(e=>e.sendPrompt),g=Y(e=>e.sendSteer),_=Y(e=>e.sendFollowUp),v=Y(e=>e.abort),y=Y(e=>e.reloadMessages),[b,x]=(0,G.useState)([]),[S,C]=(0,G.useState)([]),[w,T]=(0,G.useState)(!1),[E,D]=(0,G.useState)(void 0),[O,k]=(0,G.useState)([]),[A,j]=(0,G.useState)(null),M=q(e=>e.isMobile),[N,P]=(0,G.useState)(!1);(0,G.useEffect)(()=>{p&&P(!1)},[p]);let F=(0,G.useRef)(null),I=(0,G.useRef)(null),L=(0,G.useRef)(0),[R,z]=(0,G.useState)(0),[ee,B]=(0,G.useState)(!1),V=Y(e=>{if(e.activeProjectId!==void 0)return e.projects.find(t=>t.id===e.activeProjectId)}),[H,U]=(0,G.useState)(),[ne,re]=(0,G.useState)([]),[ie,oe]=(0,G.useState)(0),se=(0,G.useRef)(0),[ce,le]=(0,G.useState)([]),[ue,de]=(0,G.useState)({}),fe=(0,G.useRef)(new Set),pe=(0,G.useCallback)(()=>{let e=s.current;le(e===null?[]:so(e.value))},[]);(0,G.useEffect)(()=>{if(V===void 0)return;if(ce.length===0){de({});return}let e=!1,t=window.setTimeout(()=>{let t=[];for(let e of ce)e.path.length===0||e.path.endsWith(`/`)||fe.current.has(e.path)||t.push(e.path);if(t.length!==0){for(let e of t)de(t=>({...t,[e]:t[e]??`checking`}));Promise.all(t.map(async t=>{try{let{paths:n}=await dr(V.id,t,{limit:50}),r=t.toLowerCase(),i=n.some(e=>e.toLowerCase()===r);e||de(e=>({...e,[t]:i?`ok`:`missing`}))}catch{e||de(e=>({...e,[t]:`ok`}))}fe.current.add(t)}))}},200);return()=>{e=!0,window.clearTimeout(t)}},[ce,V]);let me=(()=>{if(u)return;let e=s.current?.value??``;if(e.startsWith(`!!`))return`local`;if(e.startsWith(`!`))return`context`})();(0,G.useEffect)(()=>{if(A===null)return;let e=setTimeout(()=>j(null),2500);return()=>clearTimeout(e)},[A]),(0,G.useEffect)(()=>{if(!e)return;let t=!1;return Cr(e).then(e=>{if(t)return;let n=e.commands.map(e=>({name:`/`+e.invocationName,description:e.description||`Extension command`,handler:async(t,n)=>{let{invokeExtensionCommand:r}=await li(async()=>{let{invokeExtensionCommand:e}=await Promise.resolve().then(()=>Mt);return{invokeExtensionCommand:e}},void 0);await r(t,e.invocationName,n||void 0)},isExtension:!0}));C(n)}).catch(()=>{}),di.getState().fetchPlanModeStatus(e),()=>{t=!0}},[e]);let he=(0,G.useCallback)(async()=>{if(!e)return;let t=!p;di.getState().setPlanModeActive(t);try{let{setPlanMode:n}=await li(async()=>{let{setPlanMode:e}=await Promise.resolve().then(()=>Mt);return{setPlanMode:e}},void 0);await n(e,t)}catch{di.getState().setPlanModeActive(p)}},[e,p]),ge=[{name:`/plan`,description:`Toggle Plan Mode on or off`,handler:async(e,t)=>{let n=di.getState().planModeActive,r=!n;di.getState().setPlanModeActive(r);try{let{setPlanMode:t}=await li(async()=>{let{setPlanMode:e}=await Promise.resolve().then(()=>Mt);return{setPlanMode:e}},void 0);await t(e,r)}catch{di.getState().setPlanModeActive(n)}}},{name:`/compact`,description:`Manually compact the session context`,handler:async(e,t)=>{try{await Y.getState().compactAndReload(e)}catch(e){if((e instanceof Error?e.message:String(e)).includes(`nothing_to_compact`)){j(`Nothing to compact`);return}throw e}}},{name:`/compact with summary`,description:`Compact and keep focus on specific areas`,handler:async(e,t)=>{try{await Y.getState().compactAndReload(e)}catch(e){if((e instanceof Error?e.message:String(e)).includes(`nothing_to_compact`)){j(`Nothing to compact`);return}throw e}}},{name:`/reload`,description:`Reload agent config and rebuild session tools`,handler:async(e,t)=>{let{reloadAgent:n}=await li(async()=>{let{reloadAgent:e}=await Promise.resolve().then(()=>Mt);return{reloadAgent:e}},void 0);await n()}},{name:`/abort`,description:`Abort the current streaming response`,handler:async(e,t)=>{Y.getState().abort()}},...S],[_e,ve]=(0,G.useState)([]),ye=(0,G.useRef)(null),be=[`image/png`,`image/jpeg`,`image/webp`,`image/gif`],xe=Q(e=>e.compressImages),Se=(0,G.useCallback)(e=>new Promise((t,n)=>{if(!xe){t(e);return}let r=new Image;r.onload=()=>{let i=2048;if(r.width<=i&&r.height<=i){URL.revokeObjectURL(r.src),t(e);return}let{width:a,height:o}=r;a>o?a>i&&(o=Math.round(o*i/a),a=i):o>i&&(a=Math.round(a*i/o),o=i);let s=document.createElement(`canvas`);s.width=a,s.height=o;let c=s.getContext(`2d`);c.fillStyle=`#fff`,c.fillRect(0,0,a,o),c.drawImage(r,0,0,a,o),URL.revokeObjectURL(r.src),s.toBlob(e=>{e?t(e):n(Error(`Canvas toBlob returned null`))},`image/jpeg`,.85)},r.onerror=()=>{URL.revokeObjectURL(r.src),n(Error(`Failed to decode image for compression`))},r.src=URL.createObjectURL(e)}),[xe]),Ce=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let e=r.result,n=e.indexOf(`,`);t(n===-1?e:e.slice(n+1))},r.onerror=()=>n(r.error),r.readAsDataURL(e)}),we=e=>{let t=[..._e];for(let n of e){if(!be.includes(n.type)||n.size>10485760)continue;if(t.length>=5)break;let e=URL.createObjectURL(n);t.push({file:n,dataUrl:e})}ve(t)},Te=e=>{let t=_e[e];t!==void 0&&URL.revokeObjectURL(t.dataUrl),ve(t=>t.filter((t,n)=>n!==e))},Ee=()=>ye.current?.click(),De=e=>{e.target.files&&we(e.target.files),e.target.value=``},Oe=e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r.type.startsWith(`image/`)){let e=r.getAsFile();e&&n.push(e)}}n.length>0&&(e.preventDefault(),we(n))},W=e=>{e.preventDefault(),e.stopPropagation()},ke=e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.files&&we(e.dataTransfer.files)};(0,G.useEffect)(()=>{let e=s.current;e!==null&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`)},[]),(0,G.useEffect)(()=>{if(c===void 0)return;let e=s.current,t=e?.value??``,n=e?.selectionStart??t.length,r=/\s/.test(c.path)?`@\"${c.path}\"#L${c.startLine}-${c.endLine}`:`@${c.path}#L${c.startLine}-${c.endLine}`,i=`${t.slice(0,n)}${r} ${t.slice(n)}`;if(e!==null){e.value=i;let t=n+r.length+1;e.setSelectionRange(t,t),e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`,e.focus(),pe()}l()},[c,pe]);let Ae=(e,t)=>{if(t<=0)return;let n=t-1;for(;n>=0;){let r=e[n];if(r===void 0)break;if(/\s/.test(r))return;if(r===`@`){let r=n===0?` `:e[n-1];return r===void 0||/\s/.test(r)?{start:n,end:t,query:e.slice(n+1,t)}:void 0}--n}};(0,G.useEffect)(()=>{if(H===void 0||V===void 0)return;let e=se.current+1;se.current=e;let t=window.setTimeout(()=>{dr(V.id,H.query,{limit:20}).then(t=>{se.current===e&&(re(t.paths),oe(0))}).catch(()=>{se.current===e&&re([])})},100);return()=>window.clearTimeout(t)},[H,V]);let je=e=>{if(H===void 0)return;let t=s.current;if(t===null)return;let n=t.value.slice(0,H.start),r=t.value.slice(H.end),i=`@"${e}"`;t.value=`${n}${i}${r}`,U(void 0),re([]);let a=H.start+i.length;t.setSelectionRange(a,a),t.style.height=`auto`,t.style.height=`${Math.min(t.scrollHeight,200)}px`,pe()},Me=()=>{U(void 0),re([])},Ne=e=>{let t=s.current;if(t===null)return;let n=`${t.value.slice(0,e.start)}${t.value.slice(e.end)}`;t.value=n;let r=Math.min(e.start,n.length);t.setSelectionRange(r,r),t.style.height=`auto`,t.style.height=`${Math.min(t.scrollHeight,200)}px`,pe(),t.focus()};(0,G.useEffect)(()=>{if(!e)return;let t=!1;return Bn(e).then(e=>{t||(D(e.thinkingLevel),k(e.availableThinkingLevels))}).catch(()=>{}),()=>{t=!0}},[e]);let Pe=(0,G.useCallback)(async()=>{if(!e||O.length===0)return;let t=E||`off`,n=O.indexOf(t),r=O[(n+1)%O.length];try{let t=await Vn(e,r);D(t.thinkingLevel),k(t.availableThinkingLevels)}catch{}},[e,E,O]),Fe=async t=>{t.preventDefault();let n=s.current;if(n===null)return;let r=n.value.trim();if(r.length===0&&_e.length===0)return;if(r.startsWith(`/`)&&!u){let t=r.trim().toLowerCase(),i=ge.filter(e=>t===e.name.toLowerCase()||t.startsWith(e.name.toLowerCase()+` `)).sort((e,t)=>t.name.length-e.name.length)[0];if(i){let t=r.trim().slice(i.name.length).trim();n.value=``,n.style.height=`auto`,x([]),ve([]),Me(),pe(),await i.handler(e,t);return}}if(!u&&/^!!?[^!]/.test(r)){let t=r.startsWith(`!!`),i=r.slice(t?2:1).trim();if(i.length===0){j("Empty bash command. Type something after the `!`.");return}n.value=``,n.style.height=`auto`,x([]),ve([]),Me(),pe();let{promise:a}=Hn(e,i,{excludeFromContext:t});try{await a,await y(e)}catch(e){let t=e instanceof Error?e.message:String(e);j(`Command failed: ${t}`)}return}let i;_e.length>0&&(i=await Promise.all(_e.map(async({file:e})=>{let t=await Se(e);return{type:`image`,data:await Ce(t),mimeType:t===e?e.type:`image/jpeg`}}))),n.value=``,n.style.height=`auto`,x([]),Me(),pe(),ve([]),u?await g(r,i):await h(r,i)},Ie=(0,G.useCallback)(()=>{F.current!==null&&(clearTimeout(F.current),F.current=null),I.current!==null&&(cancelAnimationFrame(I.current),I.current=null),z(0),B(!1)},[]),Le=(0,G.useCallback)(e=>{if(!u)return;e.preventDefault(),L.current=performance.now(),z(0),B(!1);let t=()=>{let e=performance.now()-L.current,n=Math.min(e/600,1);z(n),n<1?I.current=requestAnimationFrame(t):B(!0)};I.current=requestAnimationFrame(t),F.current=setTimeout(()=>{B(!0)},600)},[u]),Re=(0,G.useCallback)(async e=>{if(!u)return;e.preventDefault();let t=performance.now()-L.current;Ie();let n=s.current,r=n?.value.trim()??``;if(!r){v();return}if(t>=600){let e;_e.length>0&&(e=await Promise.all(_e.map(async({file:e})=>{let t=await Se(e);return{type:`image`,data:await Ce(t),mimeType:t===e?e.type:`image/jpeg`}}))),n.value=``,n.style.height=`auto`,ve([]),await _(r,e)}else{let e;_e.length>0&&(e=await Promise.all(_e.map(async({file:e})=>{let t=await Se(e);return{type:`image`,data:await Ce(t),mimeType:t===e?e.type:`image/jpeg`}}))),n.value=``,n.style.height=`auto`,ve([]),await g(r,e)}},[u,_e,_,g,v,Ie]),ze=e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&e.keyCode!==229&&(e.preventDefault(),Fe(e))},Be=(0,G.useCallback)(()=>{let e=s.current;if(e===null)return;e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`;let t=e.value;if(t.startsWith(`/`)){let e=t.trim().toLowerCase().split(/\s+/)[0]??``,n=ge.filter(t=>t.name.toLowerCase().startsWith(e));x(n)}else x([]);let n=e.selectionStart;if(n!==void 0&&!u){let e=Ae(t,n);U(e)}else Me();pe()},[S,ge,u,pe]),Ve=async t=>{let n=s.current;if(n===null)return;let r=n.value.trim(),i=r.toLowerCase().startsWith(t.name.toLowerCase())?r.slice(t.name.length).trim():``;n.value=``,n.style.height=`auto`,x([]),Me(),pe(),T(!0);try{await t.handler(e,i)}catch(e){console.error(`Slash command failed:`,e)}finally{T(!1)}};return(0,Z.jsx)(`form`,{onSubmit:Fe,onDragOver:W,onDrop:ke,className:`ti-area`,children:(0,Z.jsxs)(`div`,{className:`ti-container`,children:[A!==null&&(0,Z.jsx)(`div`,{style:{fontSize:11,color:`var(--text-dim)`,padding:`2px 0 0`,textAlign:`center`},children:A}),b.length>0&&(0,Z.jsx)(`div`,{className:`ti-slash-suggestions`,children:b.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`ti-slash-item`,onClick:()=>Ve(e),disabled:w,children:[(0,Z.jsx)(`span`,{className:`ti-slash-name`,children:e.name}),(0,Z.jsx)(`span`,{className:`ti-slash-desc`,children:e.description})]},e.name))}),H!==void 0&&ne.length>0&&(0,Z.jsxs)(`div`,{style:{position:`absolute`,bottom:`100%`,left:0,right:0,zIndex:10,marginBottom:4,overflow:`hidden`,borderRadius:`var(--radius-sm)`,border:`1px solid var(--border)`,background:`var(--bg-frosted)`},children:[(0,Z.jsx)(`div`,{style:{maxHeight:`60vh`,overflowY:`auto`,padding:`4px 0`},children:ne.map((e,t)=>(0,Z.jsx)(`button`,{onMouseDown:t=>{t.preventDefault(),je(e)},onMouseEnter:()=>oe(t),style:{display:`block`,width:`100%`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,padding:`6px 12px`,textAlign:`left`,fontFamily:`monospace`,fontSize:12,border:`none`,cursor:`pointer`,background:t===ie?`var(--accent-bg, var(--bg-glass-active))`:`transparent`,color:t===ie?`var(--text-primary)`:`var(--text-secondary)`},title:e,children:e},e))}),(0,Z.jsx)(`div`,{style:{borderTop:`1px solid var(--border)`,padding:`4px 12px`,fontSize:10,color:`var(--text-dim)`},children:`↑↓ navigate · Enter/Tab insert · Esc close`})]}),_e.length>0&&(0,Z.jsx)(`div`,{className:`ti-image-preview-row`,children:_e.map((e,t)=>(0,Z.jsxs)(`div`,{className:`ti-image-preview-item`,children:[(0,Z.jsx)(`img`,{src:e.dataUrl,alt:`Attachment ${t+1}`,className:`ti-image-thumb`}),(0,Z.jsx)(`button`,{type:`button`,className:`ti-image-remove`,onClick:()=>Te(t),"aria-label":`Remove image`,children:(0,Z.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,Z.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]},t))}),ce.length>0&&(0,Z.jsx)(`div`,{className:`ti-chips`,children:ce.map(e=>{let t=ue[e.path]??`checking`,n=e.startLine===void 0?void 0:`L${e.startLine}${e.endLine!==void 0&&e.endLine!==e.startLine?`-${e.endLine}`:``}`;return(0,Z.jsxs)(`span`,{className:`ti-chip ti-chip-${t}`,title:`${e.path}${n?` ${n}`:``}`,children:[(0,Z.jsx)(f,{size:12}),(0,Z.jsx)(`span`,{className:`ti-chip-name`,children:e.path}),n!==void 0&&(0,Z.jsx)(`span`,{className:`ti-chip-range`,children:n}),(0,Z.jsx)(`button`,{type:`button`,className:`ti-chip-x`,"aria-label":`Remove ${e.path}`,onClick:()=>Ne(e),children:(0,Z.jsx)(te,{size:11})})]},e.key)})}),p&&!N&&(0,Z.jsxs)(`div`,{className:`chat-input-plan-banner`,style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:M?`2px 8px`:`3px 12px`,minHeight:M?`22px`:`26px`,height:M?`22px`:`26px`,background:`var(--accent-glow)`,borderBottom:`1px solid color-mix(in srgb, var(--accent) 25%, transparent)`,fontSize:M?`10px`:`11px`,color:`var(--accent)`,fontWeight:500,boxSizing:`border-box`,gap:`6px`,overflow:`hidden`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`5px`,minWidth:0,overflow:`hidden`,flex:1},children:[(0,Z.jsx)(ae,{size:M?11:12,style:{color:`var(--accent)`,flexShrink:0}}),(0,Z.jsx)(`span`,{style:{fontWeight:600,whiteSpace:`nowrap`,flexShrink:0},children:m?M?`Review Ready`:`Plan Ready for Review`:M?`Plan Mode`:`Plan Mode Active`}),!M&&(0,Z.jsx)(`span`,{className:`plan-banner-desc`,style:{color:`var(--text-secondary)`,fontSize:`10.5px`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:m?`— click Approve & Execute to begin`:`— drafts plan before modifying code`})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`4px`,flexShrink:0},children:[(0,Z.jsx)(`button`,{type:`button`,className:`plan-banner-review-btn`,onClick:()=>di.getState().openFileReview(`PLAN.md`,e),title:m?`Review plan`:`View plan`,style:{background:`var(--bg-solid)`,border:`1px solid var(--accent)`,color:`var(--accent)`,fontSize:M?`9.5px`:`10.5px`,fontWeight:600,cursor:`pointer`,borderRadius:`3px`,padding:M?`1px 6px`:`2px 8px`,lineHeight:`13px`,whiteSpace:`nowrap`},children:m?M?`Review`:`Review Plan`:M?`Plan`:`View Plan`}),(0,Z.jsx)(`button`,{type:`button`,onClick:he,title:`Exit Plan Mode`,style:{background:`none`,border:`none`,color:`var(--text-secondary)`,fontSize:M?`9.5px`:`10px`,cursor:`pointer`,padding:`1px 4px`,lineHeight:`13px`,whiteSpace:`nowrap`},children:`Exit`}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>P(!0),title:`Dismiss banner (Plan Mode stays active)`,"aria-label":`Dismiss banner`,style:{background:`none`,border:`none`,color:`var(--text-dim)`,cursor:`pointer`,padding:`1px 2px`,display:`flex`,alignItems:`center`,justifyContent:`center`,lineHeight:1,borderRadius:`2px`},children:(0,Z.jsx)(te,{size:11})})]})]}),(0,Z.jsx)(`textarea`,{ref:s,className:`ti-input`,onKeyDown:ze,onPaste:Oe,onInput:Be,placeholder:w?`Compacting…`:u?`Steer the agent…`:o(`chat.placeholder`),disabled:w,rows:1}),(0,Z.jsxs)(`div`,{className:`ti-toolbar`,children:[(0,Z.jsxs)(`div`,{className:`ti-toolbar-left`,children:[me!==void 0&&(0,Z.jsx)(`span`,{style:{fontSize:10,color:me===`local`?`var(--accent-text)`:`var(--text-secondary)`,padding:`0 6px`,fontFamily:`monospace`,letterSpacing:`0.5px`,textTransform:`uppercase`,opacity:.7},title:me===`local`?`!! — bash runs locally, output stays out of LLM context`:`! — bash runs, output feeds into next LLM turn`,children:me===`local`?`!! local`:`! context`}),(0,Z.jsx)(`button`,{type:`button`,className:`ti-toolbar-btn`,onClick:Ee,title:`Attach image`,tabIndex:-1,disabled:_e.length>=5,children:(0,Z.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`}),(0,Z.jsx)(`circle`,{cx:`8.5`,cy:`8.5`,r:`1.5`}),(0,Z.jsx)(`polyline`,{points:`21 15 16 10 5 21`})]})}),(0,Z.jsx)(`input`,{ref:ye,type:`file`,accept:`image/png,image/jpeg,image/webp,image/gif`,multiple:!0,style:{display:`none`},onChange:De}),(0,Z.jsx)(`button`,{type:`button`,className:`ti-toolbar-btn`,onClick:()=>n?.(!t),title:`Subagent`,tabIndex:-1,children:(0,Z.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,Z.jsx)(`polygon`,{points:`13 2 3 14 12 14 11 22 21 10 12 10 13 2`,style:{fill:t?`currentColor`:`none`}})})}),(0,Z.jsx)(`button`,{type:`button`,className:`ti-toolbar-btn${p?` active`:``}`,onClick:()=>{p&&N?P(!1):he()},title:p?N?`Plan Mode Active (click to show banner)`:`Plan Mode Active (click to exit)`:`Toggle Plan Mode (/plan)`,tabIndex:-1,style:{color:p?`var(--accent)`:void 0,background:p?`var(--accent-glow)`:void 0,borderColor:p?`var(--accent)`:`transparent`,boxShadow:p?`0 0 12px var(--accent-glow), 0 0 3px var(--accent)`:void 0,transition:`all 0.2s ease-in-out`},children:(0,Z.jsx)(ae,{size:14,style:{color:p?`var(--accent)`:`currentColor`,filter:p?`drop-shadow(0 0 3px var(--accent))`:void 0,transition:`all 0.2s ease-in-out`}})})]}),(0,Z.jsxs)(`div`,{className:`ti-toolbar-right`,children:[i!==void 0&&(0,Z.jsx)(Dp,{sessionId:e,selected:r??``,onSelect:i,onError:a??(()=>{}),compact:!0}),e!==void 0&&O.length>0&&(0,Z.jsxs)(`button`,{type:`button`,className:`ti-thinking-btn`,onClick:Pe,tabIndex:-1,title:`Thinking: ${E||`off`} — click to cycle`,children:[(0,Z.jsxs)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:[(0,Z.jsx)(`path`,{d:`M12 2a10 10 0 1 0 10 10`}),(0,Z.jsx)(`path`,{d:`M12 6v6l4 2`})]}),(0,Z.jsx)(`span`,{className:`ti-thinking-label`,children:E||`off`})]}),(0,Z.jsxs)(`button`,{type:u?`button`:`submit`,onClick:void 0,onMouseDown:u?Le:void 0,onMouseUp:u?Re:void 0,onMouseLeave:u?Ie:void 0,onTouchStart:u?Le:void 0,onTouchEnd:u?Re:void 0,onTouchCancel:u?Ie:void 0,className:`ti-send-btn${u?` ti-send-btn-stop`:``}${u&&d&&R===0?` pulsing`:``}${ee?` ti-send-btn-followup-ready`:``}`,title:u?R>0?`Release to follow-up`:`Tap to steer · Hold to follow-up`:`Send`,tabIndex:-1,disabled:w,children:[u&&R>0&&(0,Z.jsx)(`svg`,{className:`ti-hold-ring`,viewBox:`0 0 36 36`,style:{position:`absolute`,top:0,left:0,width:`100%`,height:`100%`,transform:`rotate(-90deg)`,pointerEvents:`none`},children:(0,Z.jsx)(`circle`,{cx:`18`,cy:`18`,r:`15`,fill:`none`,stroke:ee?`var(--accent-text, #a78bfa)`:`var(--text-primary)`,strokeWidth:`2.5`,strokeDasharray:`${R*94.25} 94.25`,strokeLinecap:`round`,style:{transition:`stroke 0.15s`}})}),(0,Z.jsx)(`span`,{className:`ti-send-icon`,children:u?ee?(0,Z.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,Z.jsx)(`polyline`,{points:`12 7 12 12 15 15`})]}):(0,Z.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,Z.jsx)(`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`})}):(0,Z.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`line`,{x1:`12`,y1:`19`,x2:`12`,y2:`5`}),(0,Z.jsx)(`polyline`,{points:`5 12 12 5 19 12`})]})})]})]})]})]})})}function Ap({sessionId:e}){let t=ai(t=>t.pendingBySession[e]);return t===void 0?null:(0,Z.jsx)(jp,{pending:t},t.requestId)}function jp({pending:e}){let t=ai(e=>e.clearPending),[n,r]=(0,G.useState)(0),[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(void 0),[c,l]=(0,G.useState)(()=>e.questions.map(()=>null)),u=e.questions[n];if(u===void 0)return null;let d=n===e.questions.length-1,f=e=>{l(t=>{let r=[...t];return r[n]=e,r})},p=()=>c[n]??{},m=()=>e.questions.map((e,t)=>{let n=c[t];return n===null?{questionIndex:t,question:e.question,kind:`chat`,answer:null}:n.customText===void 0?e.multiSelect?{questionIndex:t,question:e.question,kind:`multi`,answer:null,selected:n.multiLabels??[]}:{questionIndex:t,question:e.question,kind:`option`,answer:n.selectedLabel??null}:{questionIndex:t,question:e.question,kind:`custom`,answer:n.customText}}),h=async(n=!1)=>{a(!0),s(void 0);try{let r=n?[]:m();await Xn(e.sessionId,e.requestId,r,n),t(e.sessionId,e.requestId)}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}};return(0,Z.jsxs)(`div`,{style:{border:`1px solid var(--border)`,borderRadius:12,background:`var(--bg-glass-strong)`,padding:16,margin:`8px auto`,maxWidth:800,width:`100%`,boxSizing:`border-box`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:12},children:[(0,Z.jsx)(`span`,{style:{fontSize:13,fontWeight:600,color:`var(--text-primary)`},children:u.header}),e.questions.length>1&&(0,Z.jsxs)(`span`,{style:{fontSize:11,color:`var(--text-dim)`},children:[n+1,` / `,e.questions.length]}),(0,Z.jsx)(`div`,{style:{flex:1}}),(0,Z.jsx)(`button`,{onClick:()=>void h(!0),disabled:i,style:{background:`none`,border:`none`,color:`var(--text-tertiary)`,cursor:`pointer`,fontSize:12,padding:`2px 6px`,borderRadius:4},title:`Chat about this instead`,children:`✕ Chat about it`})]}),(0,Z.jsx)(`div`,{style:{fontSize:14,color:`var(--text-primary)`,marginBottom:12,lineHeight:1.5},children:u.question}),(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6},children:[u.multiSelect?(0,Z.jsx)(Pp,{options:u.options,selected:p().multiLabels??[],onChange:e=>f({multiLabels:e})}):(0,Z.jsx)(Np,{options:u.options,selected:p().selectedLabel,onSelect:e=>f({selectedLabel:e,customText:void 0})}),!u.multiSelect&&(0,Z.jsx)(`div`,{style:{marginTop:8},children:(0,Z.jsx)(`input`,{type:`text`,placeholder:`Type something...`,value:p().customText??``,onChange:e=>f({customText:e.target.value,selectedLabel:void 0}),style:{width:`100%`,padding:`8px 12px`,borderRadius:8,border:`1px solid var(--input-border)`,background:`var(--input-bg)`,color:`var(--text-primary)`,fontSize:13,fontFamily:`inherit`,outline:`none`}})})]}),o!==void 0&&(0,Z.jsx)(`div`,{style:{fontSize:12,color:`var(--error)`,marginTop:8},children:o}),(0,Z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginTop:12,gap:8},children:[(0,Z.jsx)(`div`,{children:n>0&&(0,Z.jsx)(`button`,{onClick:()=>{r(e=>Math.max(e-1,0))},disabled:i,style:Mp,children:`← Back`})}),(0,Z.jsx)(`div`,{style:{display:`flex`,gap:6},children:d?(0,Z.jsx)(`button`,{onClick:()=>void h(!1),disabled:i,style:{...Mp,background:`var(--accent)`,color:`#fff`},children:i?`Submitting...`:`Submit`}):(0,Z.jsx)(`button`,{onClick:()=>{r(t=>Math.min(t+1,e.questions.length-1))},disabled:i,style:Mp,children:`Next →`})})]})]})}var Mp={padding:`6px 14px`,borderRadius:8,border:`1px solid var(--border)`,background:`var(--bg-glass-hover)`,color:`var(--text-primary)`,fontSize:13,cursor:`pointer`,fontFamily:`inherit`};function Np({options:e,selected:t,onSelect:n}){return(0,Z.jsx)(Z.Fragment,{children:e.map(e=>(0,Z.jsxs)(`button`,{onClick:()=>n(e.label),style:{display:`flex`,flexDirection:`column`,gap:2,padding:`8px 12px`,borderRadius:8,border:`1px solid ${t===e.label?`var(--accent)`:`var(--border)`}`,background:t===e.label?`var(--accent-subtle)`:`var(--bg-glass)`,color:`var(--text-primary)`,cursor:`pointer`,textAlign:`left`,fontSize:13,fontFamily:`inherit`,transition:`all 0.15s`},children:[(0,Z.jsx)(`span`,{style:{fontWeight:500},children:e.label}),(0,Z.jsx)(`span`,{style:{fontSize:12,color:`var(--text-secondary)`},children:e.description})]},e.label))})}function Pp({options:e,selected:t,onChange:n}){let r=e=>{t.includes(e)?n(t.filter(t=>t!==e)):n([...t,e])};return(0,Z.jsx)(Z.Fragment,{children:e.map(e=>{let n=t.includes(e.label);return(0,Z.jsxs)(`label`,{style:{display:`flex`,alignItems:`flex-start`,gap:10,padding:`8px 12px`,borderRadius:8,border:`1px solid ${n?`var(--accent)`:`var(--border)`}`,background:n?`var(--accent-subtle)`:`var(--bg-glass)`,cursor:`pointer`,fontSize:13,fontFamily:`inherit`,transition:`all 0.15s`},children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>r(e.label),style:{marginTop:2,accentColor:`var(--accent-text)`}}),(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:2},children:[(0,Z.jsx)(`span`,{style:{fontWeight:500},children:e.label}),(0,Z.jsx)(`span`,{style:{fontSize:12,color:`var(--text-secondary)`},children:e.description})]})]},e.label)})})}function Fp({variant:e=`text`,count:t=1,width:n,height:r,style:i}){let a=(0,G.useId)(),o={borderRadius:`4px`,background:`linear-gradient(90deg,
125
+ var(--text-ghost, rgba(255,255,255,0.10)) 25%,
126
+ var(--text-dim, rgba(255,255,255,0.35)) 50%,
127
+ var(--text-ghost, rgba(255,255,255,0.10)) 75%)`,backgroundSize:`200% 100%`,animation:`${a}-shimmer 1.4s ease-in-out infinite`,width:n,height:r},s=`
128
+ @keyframes ${a}-shimmer {
129
+ 0% { background-position: 200% 0; }
130
+ 100% { background-position: -200% 0; }
131
+ }`;return e===`circle`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`style`,{children:s}),(0,Z.jsx)(`div`,{style:{...o,width:n??`32px`,height:r??`32px`,borderRadius:`50%`,flexShrink:0,...i}})]}):e===`card`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`style`,{children:s}),(0,Z.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12,...i},children:Array.from({length:t},(e,t)=>(0,Z.jsxs)(`div`,{style:{padding:`14px`,borderRadius:`8px`,border:`1px solid var(--border, #444)`,background:`var(--header-bg, rgba(55,55,60,0.75))`,display:`flex`,flexDirection:`column`,gap:10},children:[(0,Z.jsx)(`div`,{style:{...o,height:`14px`,width:`55%`}}),(0,Z.jsx)(`div`,{style:{...o,height:`10px`,width:`85%`}}),(0,Z.jsx)(`div`,{style:{...o,height:`10px`,width:`40%`}})]},t))})]}):e===`tree`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`style`,{children:s}),(0,Z.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,padding:`4px 0`,...i},children:Array.from({length:t},(e,t)=>(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,paddingLeft:`${t%3*16+8}px`},children:[(0,Z.jsx)(`div`,{style:{...o,width:`14px`,height:`14px`,borderRadius:`3px`,flexShrink:0}}),(0,Z.jsx)(`div`,{style:{...o,height:`10px`,width:`${50+t%3*20}%`}})]},t))})]}):e===`list`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`style`,{children:s}),(0,Z.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8,...i},children:Array.from({length:t},(e,t)=>(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,padding:`6px 0`},children:[(0,Z.jsx)(`div`,{style:{...o,width:`24px`,height:`24px`,borderRadius:`4px`,flexShrink:0}}),(0,Z.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,gap:4},children:[(0,Z.jsx)(`div`,{style:{...o,height:`10px`,width:`${65+t%3*15}%`}}),(0,Z.jsx)(`div`,{style:{...o,height:`8px`,width:`${40+t%2*20}%`}})]})]},t))})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`style`,{children:s}),(0,Z.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8,...i},children:Array.from({length:t},(e,n)=>(0,Z.jsx)(`div`,{style:{...o,height:`10px`,width:n===t-1&&t>1?`60%`:`100%`}},n))})]})}function Ip({sessionId:e,open:t,onClose:n}){let[r,i]=(0,G.useState)(null),[a,o]=(0,G.useState)(`loading`),[s,c]=(0,G.useState)([]),[l,u]=(0,G.useState)([]),[d,f]=(0,G.useState)(0),[p,m]=(0,G.useState)(null),[h,g]=(0,G.useState)(!1),_=(0,G.useCallback)(async()=>{try{let t=await tr();if(i(t),t.available===!1)return;let n=await nr(e);if(o(n.role),n.role===`supervisor`){let[t,n]=await Promise.all([ar(e),or(e)]);c(t.workers),u(n.items),f(n.count)}}catch(e){m(e instanceof Error?e.message:String(e))}},[e]);(0,G.useEffect)(()=>{if(!t)return;_();let e=setInterval(_,4e3);return()=>clearInterval(e)},[t,_]);let v=async()=>{g(!0),m(null);try{await rr(e),await _()}catch(e){m(e instanceof Error?e.message:String(e))}g(!1)},y=async()=>{m(null);try{await ir(e),await _()}catch(e){m(e instanceof Error?e.message:String(e))}},b=async t=>{try{await lr(e,t),await _()}catch(e){m(e instanceof Error?e.message:String(e))}},x=async t=>{try{await cr(e,t),await _()}catch(e){m(e instanceof Error?e.message:String(e))}},S=async t=>{try{await ur(e,t),await _()}catch(e){m(e instanceof Error?e.message:String(e))}};if(!t)return null;if(r?.available===!1)return(0,Z.jsxs)(`div`,{style:{padding:`12px 16px`,fontSize:`12px`,color:`var(--text-dim)`,borderBottom:`1px solid var(--border-color)`},children:[`🚫 Orchestration unavailable: `,r.disabledReason??`disabled`]});let C=l.filter(e=>!e.delivered).length;return(0,Z.jsxs)(`div`,{style:{padding:`10px 16px`,fontSize:`12px`,color:`var(--text-secondary)`,borderBottom:`1px solid var(--border-color)`,background:`var(--bg-secondary)`,display:`flex`,flexDirection:`column`,gap:`8px`,maxWidth:800,margin:`0 auto`,width:`100%`,boxSizing:`border-box`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`},children:[(0,Z.jsx)(`span`,{style:{fontWeight:600,fontSize:`13px`},children:`⚡ Orchestration`}),(0,Z.jsx)(`button`,{type:`button`,onClick:n,style:{background:`none`,border:`none`,color:`var(--text-dim)`,cursor:`pointer`,fontSize:`14px`},children:`✕`})]}),a===`loading`&&(0,Z.jsx)(Fp,{variant:`list`,count:2}),a===`standalone`&&(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,alignItems:`center`},children:[(0,Z.jsx)(`span`,{children:`Session is standalone.`}),(0,Z.jsx)(`button`,{type:`button`,onClick:v,disabled:h,style:{padding:`4px 10px`,fontSize:`11px`,fontWeight:600,background:`var(--accent-bg)`,color:`var(--accent-text)`,border:`1px solid var(--accent-border)`,borderRadius:`var(--radius-sm)`,cursor:h?`wait`:`pointer`},children:h?`Enabling...`:`Enable supervisor mode`})]}),a===`supervisor`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,alignItems:`center`,flexWrap:`wrap`},children:[(0,Z.jsx)(`span`,{style:{color:`var(--accent-text)`,fontWeight:500},children:`✅ Supervisor active`}),(0,Z.jsxs)(`span`,{style:{color:`var(--text-dim)`},children:[s.length,` worker(s)`,C>0&&(0,Z.jsxs)(`span`,{style:{color:`#e5c07b`,marginLeft:`4px`},children:[`· `,C,` pending inbox`]})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:y,style:{padding:`3px 8px`,fontSize:`11px`,background:`none`,color:`var(--text-dim)`,border:`1px solid var(--border-color)`,borderRadius:`var(--radius-sm)`,cursor:`pointer`},children:`Disable`})]}),s.length>0&&(0,Z.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`4px`},children:s.map(e=>(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`6px`,fontSize:`11px`,padding:`4px 6px`,background:`var(--bg-primary)`,borderRadius:`var(--radius-sm)`},children:[(0,Z.jsx)(`span`,{style:{width:6,height:6,borderRadius:`50%`,background:e.isLive?e.state===`running`||e.state===`streaming`?`#98c379`:e.state===`awaiting_question`?`#e5c07b`:e.state===`errored`?`#e06c75`:`#56b6c2`:`#5c6370`,display:`inline-block`}}),(0,Z.jsx)(`span`,{style:{flex:1,overflow:`hidden`,textOverflow:`ellipsis`},children:e.name??e.workerId.slice(0,8)}),(0,Z.jsx)(`span`,{style:{color:`var(--text-dim)`},children:e.state}),!e.isLive&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>S(e.workerId),style:{padding:`1px 5px`,fontSize:`10px`,background:`none`,border:`1px solid var(--border-color)`,borderRadius:`var(--radius-sm)`,cursor:`pointer`},children:`Resume`}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>x(e.workerId),title:`Detach`,style:{padding:`1px 5px`,fontSize:`10px`,background:`none`,border:`1px solid var(--border-color)`,borderRadius:`var(--radius-sm)`,cursor:`pointer`},children:`Detach`}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>b(e.workerId),title:`Kill`,style:{padding:`1px 5px`,fontSize:`10px`,background:`none`,border:`1px solid #e06c75`,color:`#e06c75`,borderRadius:`var(--radius-sm)`,cursor:`pointer`},children:`Kill`})]},e.workerId))}),C>0&&(0,Z.jsxs)(`div`,{style:{fontSize:`11px`,padding:`4px 6px`,background:`var(--bg-primary)`,borderRadius:`var(--radius-sm)`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,Z.jsxs)(`span`,{children:[C,` undelivered inbox item(s)`]}),(0,Z.jsx)(`button`,{type:`button`,onClick:async()=>{await sr(e),await _()},style:{padding:`1px 5px`,fontSize:`10px`,background:`none`,border:`1px solid var(--border-color)`,borderRadius:`var(--radius-sm)`,cursor:`pointer`},children:`Clear inbox`})]})]}),a===`worker`&&(0,Z.jsx)(`span`,{children:`This session is a worker. Orchestration is managed by the supervisor.`}),p!==null&&(0,Z.jsxs)(`div`,{style:{color:`#e06c75`,fontSize:`11px`},children:[`Error: `,p]})]})}function Lp(e){let[t,n]=(0,G.useState)(null),r=(0,G.useRef)(void 0);return(0,G.useEffect)(()=>{if(e===void 0){n(null);return}let t=async()=>{try{let t=await Kt(e);n(t)}catch{n(null)}};return t(),r.current=setInterval(t,5e3),()=>{clearInterval(r.current)}},[e]),t}function Rp({data:e,onInspect:t}){let n=e?.contextUsage?.percent??null;if(n===null)return null;let r=Math.round(n);return(0,Z.jsxs)(`button`,{type:`button`,className:`ctx-pill`,onClick:()=>e!==null&&t(e),title:`Context: ${e.contextUsage.tokens?.toLocaleString()??`?`} / ${e.contextUsage.contextWindow.toLocaleString()} tokens`,children:[(0,Z.jsx)(`span`,{className:`ctx-pill-dot`}),r,`%`]})}function zp(e){return e<.001?`$0.00`:`$${e.toFixed(4)}`}function Bp({data:e,sessionId:t,onClose:n}){let r=(0,G.useRef)(null);(0,G.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[n]);let i=e.contextUsage,a=e.stats,o=i?.percent??null,s=o!==null&&o>=90?`var(--error)`:o!==null&&o>=70?`var(--warning)`:`var(--accent)`,[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(null),[f,p]=(0,G.useState)(null);return(0,Z.jsx)(`div`,{className:`settings-overlay`,onClick:n,role:`dialog`,"aria-modal":`true`,children:(0,Z.jsxs)(`div`,{ref:r,className:`settings-panel`,style:{maxWidth:`420px`},onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(`header`,{className:`settings-header`,children:[(0,Z.jsx)(`span`,{className:`settings-section-title`,style:{margin:0,textTransform:`none`,letterSpacing:0,fontSize:`13px`},children:`Context Inspector`}),(0,Z.jsx)(`button`,{type:`button`,className:`settings-close`,onClick:n,children:`✕`})]}),(0,Z.jsxs)(`div`,{className:`settings-body`,style:{padding:`12px 16px 16px`},children:[o!==null&&(0,Z.jsxs)(`div`,{className:`settings-card`,style:{marginBottom:`10px`},children:[(0,Z.jsxs)(`div`,{className:`settings-card-header`,children:[(0,Z.jsx)(`div`,{className:`ctx-modal-track`,style:{flex:1},children:(0,Z.jsx)(`div`,{className:`ctx-modal-fill`,style:{width:`${Math.min(o,100)}%`,background:s}})}),(0,Z.jsxs)(`span`,{style:{fontSize:`12px`,fontWeight:600,color:`var(--text-primary)`,fontVariantNumeric:`tabular-nums`,whiteSpace:`nowrap`},children:[Math.round(o),`%`]})]}),(0,Z.jsx)(`div`,{className:`ctx-modal-labels`,style:{padding:`0 12px 8px`},children:(0,Z.jsxs)(`span`,{children:[i.tokens?.toLocaleString()??`?`,` / `,i.contextWindow.toLocaleString(),` tokens`]})})]}),(0,Z.jsxs)(`div`,{className:`settings-card`,style:{marginBottom:`10px`},children:[(0,Z.jsx)(`div`,{className:`settings-card-header`,children:(0,Z.jsx)(`span`,{className:`settings-section-title`,style:{margin:0},children:`Tokens`})}),(0,Z.jsxs)(`div`,{style:{padding:`0 12px 8px`},children:[(0,Z.jsx)(Vp,{label:`Input`,value:a.tokens.input.toLocaleString()}),(0,Z.jsx)(Vp,{label:`Output`,value:a.tokens.output.toLocaleString()}),(0,Z.jsx)(Vp,{label:`Cache Read`,value:a.tokens.cacheRead.toLocaleString()}),(0,Z.jsx)(Vp,{label:`Cache Write`,value:a.tokens.cacheWrite.toLocaleString()}),(0,Z.jsx)(Vp,{label:`Total`,value:a.tokens.total.toLocaleString(),accent:!0})]})]}),(0,Z.jsxs)(`div`,{className:`settings-card`,style:{marginBottom:`10px`},children:[(0,Z.jsx)(`div`,{className:`settings-card-header`,children:(0,Z.jsx)(`span`,{className:`settings-section-title`,style:{margin:0},children:`Cost`})}),(0,Z.jsx)(`div`,{style:{padding:`0 12px 8px`},children:(0,Z.jsx)(Vp,{label:`Total spent`,value:zp(a.cost)})})]}),(0,Z.jsxs)(`div`,{className:`settings-card`,children:[(0,Z.jsx)(`div`,{className:`settings-card-header`,children:(0,Z.jsx)(`span`,{className:`settings-section-title`,style:{margin:0},children:`Conversation`})}),(0,Z.jsxs)(`div`,{style:{padding:`0 12px 8px`},children:[(0,Z.jsx)(Vp,{label:`User messages`,value:String(a.userMessages)}),(0,Z.jsx)(Vp,{label:`Assistant messages`,value:String(a.assistantMessages)}),(0,Z.jsx)(Vp,{label:`Tool calls`,value:String(a.toolCalls)}),(0,Z.jsx)(Vp,{label:`Tool results`,value:String(a.toolResults)})]})]}),(0,Z.jsx)(`div`,{className:`settings-card`,style:{marginTop:`10px`},children:(0,Z.jsxs)(`div`,{style:{padding:`10px 12px`},children:[(0,Z.jsx)(`button`,{type:`button`,className:`compact-ctx-btn`,onClick:async()=>{if(t!==void 0){l(!0),d(null),p(null);try{let e=await Y.getState().compactAndReload(t);p(e)}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}}},disabled:c,style:{width:`100%`,padding:`8px 12px`,border:`1px solid var(--border)`,borderRadius:`var(--radius-sm)`,background:`var(--surface-2)`,color:`var(--text-primary)`,fontSize:`12px`,fontWeight:600,cursor:c?`wait`:`pointer`,opacity:c?.6:1,display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`6px`},children:c?(0,Z.jsx)(Z.Fragment,{children:`⏳ Compacting…`}):(0,Z.jsx)(Z.Fragment,{children:`🗜️ Compact session`})}),f!==null&&(0,Z.jsxs)(`div`,{style:{marginTop:`8px`,padding:`6px 10px`,background:`color-mix(in srgb, var(--accent) 8%, transparent)`,borderRadius:`var(--radius-sm)`,fontSize:`11px`,lineHeight:1.5,color:`var(--text-primary)`,maxHeight:`120px`,overflowY:`auto`},children:[(0,Z.jsxs)(`div`,{style:{fontWeight:600,marginBottom:`2px`},children:[`✅ Compacted — context was `,f.tokensBefore.toLocaleString(),` tokens`]}),(0,Z.jsxs)(`div`,{style:{color:`var(--text-dim)`},children:[f.summary.slice(0,300),f.summary.length>300?`…`:``]})]}),u!==null&&(0,Z.jsx)(`div`,{style:{marginTop:`6px`,fontSize:`11px`,color:`var(--error)`,textAlign:`center`},children:u})]})})]})]})})}function Vp({label:e,value:t,accent:n}){return(0,Z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`3px 0`,fontSize:`12px`,color:`var(--text-secondary)`},children:[(0,Z.jsx)(`span`,{children:e}),(0,Z.jsx)(`span`,{style:{fontVariantNumeric:`tabular-nums`,color:n?`var(--accent)`:`var(--text-primary)`,fontWeight:n?600:500},children:t})]})}var Hp=3e4;function Up(e){return JSON.stringify(e)}function Wp(e,t){return e?.enabled===t.enabled&&e.connected===t.connected&&e.total===t.total}function Gp(e,t){return e!==void 0&&Up(e.status)===Up(t.status)&&Up(e.stdioTrust)===Up(t.stdioTrust)}var Kp=[],qp=!1,Jp=At((e,t)=>({settings:void 0,globalServers:{},globalStatus:Kp,byProject:{},loading:!1,error:null,pollHandle:void 0,startPolling:()=>{e({pollHandle:setInterval(async()=>{typeof document<`u`&&document.hidden||qp||await t().refreshSettings()},Hp)}),t().refreshSettings()},stopPolling:()=>{let n=t().pollHandle;n!==void 0&&(clearInterval(n),e({pollHandle:void 0}))},refreshSettings:async()=>{if(!qp){qp=!0;try{let[t,n]=await Promise.all([Er(),Or()]);e(e=>{let r=n.servers,i=n.status,a=Up(e.globalServers)!==Up(r),o=Up(e.globalStatus)!==Up(i),s=Wp(e.settings,t);return!a&&!o&&s?{loading:!1,error:null}:{settings:t,globalServers:r,globalStatus:i,loading:!1,error:null}})}catch(t){e({error:t instanceof Error?t.message:`Failed to load MCP settings`,loading:!1})}finally{qp=!1}}},refreshProject:async t=>{try{let n=await Or(t),r={status:n.status,stdioTrust:n.stdioTrust};e(e=>{let n=e.byProject[t];return Gp(n,r)?e:{byProject:{...e.byProject,[t]:r}}})}catch{}},setMcpEnabled:async t=>{let n=await Dr(t);e(e=>Wp(e.settings,n)?e:{settings:n})},upsertServer:async(e,n)=>{await kr(e,n),await t().refreshSettings()},deleteServer:async e=>{await Ar(e),await t().refreshSettings()},probeServer:async(e,n)=>{await jr(e,n),n===void 0?await t().refreshSettings():await t().refreshProject(n)},grantStdioTrust:async e=>{await Mr(e),await t().refreshProject(e)},revokeStdioTrust:async e=>{await Nr(e),await t().refreshProject(e)}}));function Yp({open:e,onClose:t,title:n,header:r,children:i,side:a=`center`,width:o,maxWidth:s,className:c=``,style:l}){let u=(0,G.useCallback)(e=>{e.key===`Escape`&&t()},[t]);return(0,G.useEffect)(()=>{if(e)return document.addEventListener(`keydown`,u),()=>document.removeEventListener(`keydown`,u)},[e,u]),e?a===`right`?(0,Z.jsx)(`div`,{className:`slide-panel-overlay`,onClick:t,role:`dialog`,"aria-modal":`true`,children:(0,Z.jsx)(`div`,{className:`slide-panel slide-panel--right ${c}`,style:{width:typeof o==`number`?`${o}px`:o,maxWidth:typeof s==`number`?`${s}px`:s,...l},onClick:e=>e.stopPropagation(),children:i})}):(0,Z.jsx)(`div`,{className:`settings-overlay`,onClick:t,role:`dialog`,"aria-modal":`true`,children:(0,Z.jsxs)(`div`,{className:`settings-panel ${c}`,style:{width:typeof o==`number`?`${o}px`:o,maxWidth:typeof s==`number`?`${s}px`:s,...l},onClick:e=>e.stopPropagation(),children:[r===void 0?(0,Z.jsxs)(`header`,{className:`settings-header`,children:[(0,Z.jsx)(`span`,{style:{fontSize:13,fontWeight:600,color:`var(--text-primary)`},children:n}),(0,Z.jsx)(`button`,{type:`button`,className:`settings-close`,onClick:t,children:`✕`})]}):r,(0,Z.jsx)(`div`,{className:`settings-body`,children:i})]})}):null}function Xp({onClose:e}){let{t}=qo(),n=Jp(e=>e.settings),r=Jp(e=>e.globalServers),i=Jp(e=>e.globalStatus),a=Jp(e=>e.loading),o=Jp(e=>e.error),s=Jp(e=>e.startPolling),c=Jp(e=>e.stopPolling),l=Jp(e=>e.setMcpEnabled),u=Jp(e=>e.deleteServer),d=Jp(e=>e.probeServer),f=Jp(e=>e.upsertServer),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(void 0),[_,v]=(0,G.useState)(null);(0,G.useEffect)(()=>(s(),()=>c()),[s,c]);let y=async e=>{v(e);try{await d(e)}finally{v(null)}},b=async(e,t)=>{let n=r[e];n!==void 0&&await f(e,{...n,enabled:t})},x=e=>{m(!1),g(e)},S=()=>{g(void 0),m(!0)},C=Object.entries(r);return(0,Z.jsx)(Yp,{open:!0,onClose:e,title:t(`settings.mcp.title`),style:{maxWidth:`520px`},children:(0,Z.jsxs)(`div`,{style:{padding:`12px 16px 16px`},children:[o!==null&&(0,Z.jsx)(`div`,{className:`mcp-error`,children:o}),a&&n===void 0?(0,Z.jsx)(`div`,{style:{padding:`20px 0`,textAlign:`center`,color:`var(--text-dim)`,fontSize:`12px`},children:t(`settings.mcp.loading`)}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`settings-card`,style:{marginBottom:`10px`},children:[(0,Z.jsxs)(`div`,{className:`settings-card-header`,children:[(0,Z.jsx)(`span`,{className:`settings-section-title`,style:{margin:0},children:t(`settings.mcp.status`)}),(0,Z.jsxs)(`label`,{className:`mcp-toggle`,style:{cursor:`pointer`},children:[(0,Z.jsx)(`span`,{className:`mcp-toggle-track`,"data-enabled":n?.enabled??!1,onClick:()=>l(!(n?.enabled??!1)),children:(0,Z.jsx)(`span`,{className:`mcp-toggle-thumb`})}),(0,Z.jsx)(`span`,{style:{fontSize:`12px`,color:`var(--text-secondary)`},children:n?.enabled?t(`settings.mcp.enabled`):t(`settings.mcp.disabled`)})]})]}),n!==void 0&&(0,Z.jsxs)(`div`,{style:{padding:`0 12px 8px`,fontSize:`12px`,color:`var(--text-dim)`},children:[n.connected,` / `,n.total,` `,t(`settings.mcp.serversConnected`)]})]}),(0,Z.jsxs)(`div`,{className:`settings-card`,style:{marginBottom:`10px`},children:[(0,Z.jsxs)(`div`,{className:`settings-card-header`,children:[(0,Z.jsx)(`span`,{className:`settings-section-title`,style:{margin:0},children:t(`settings.mcp.servers`)}),(0,Z.jsx)(`button`,{type:`button`,className:`mcp-add-btn`,onClick:()=>h===void 0?S():g(void 0),title:`Add server`,children:`+`})]}),!p&&h===void 0&&C.length===0?(0,Z.jsx)(`div`,{style:{padding:`12px`,textAlign:`center`,fontSize:`12px`,color:`var(--text-dim)`},children:`No MCP servers configured`}):(0,Z.jsxs)(`div`,{className:`mcp-server-list`,children:[p&&(0,Z.jsx)($p,{onSave:async(e,t)=>{await f(e,t),m(!1)},onCancel:()=>m(!1)}),h!==void 0&&r[h]!==void 0&&(0,Z.jsx)($p,{initialName:h,initialConfig:r[h],isEditing:!0,onSave:async(e,t)=>{await f(h,t),g(void 0)},onCancel:()=>g(void 0)},h),C.map(([e])=>{let t=i.find(t=>t.name===e);return(0,Z.jsx)(Zp,{name:e,config:r[e],status:t,probeLoading:_===e,onToggle:t=>b(e,t),onEdit:()=>x(e),onProbe:()=>y(e),onDelete:()=>u(e),isEditing:h===e},e)}),i.filter(e=>!r[e.name]).map(e=>(0,Z.jsx)(Zp,{name:e.name,config:void 0,status:e,probeLoading:_===e.name,onProbe:()=>y(e.name),onDelete:()=>u(e.name)},e.name))]})]})]})]})})}function Zp({name:e,config:t,status:n,probeLoading:r,onToggle:i,onEdit:a,onProbe:o,onDelete:s,isEditing:c}){let{t:l}=qo(),[u,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(null),[m,h]=(0,G.useState)(!1),[g,_]=(0,G.useState)(new Set),[v,y]=(0,G.useState)([]),[b,x]=(0,G.useState)(null),S=t?.enabled!==!1,C=S?n?.state??`idle`:`disabled`,w=C===`connected`?`var(--success)`:C===`connecting`?`var(--warning)`:C===`error`?`var(--error)`:C===`trust_required`?`var(--warning)`:`var(--text-dim)`,T=C===`connected`?`Connected`:C===`connecting`?`Connecting...`:C===`error`?`Error${n?.lastError?`: ${n.lastError}`:``}`:C===`disabled`?l(`settings.mcp.disabled`):C===`trust_required`?`Trust Required`:C===`idle`?`Idle`:n===void 0?`—`:n.state,E=n?.kind??`—`,D=(0,G.useCallback)(async()=>{h(!0);try{let[t,n,r]=await Promise.all([Pr(),Ir(),tn()]);x(n),y(r.projects.map(e=>({id:e.id,name:e.name})));let i=t.mcp.find(t=>t.server===e);p(i?.tools.map(e=>({name:e.name,shortName:e.shortName,description:e.description,enabled:e.enabled,globalEnabled:e.globalEnabled,projectOverride:e.projectOverride}))??[])}catch(e){console.warn(`loadTools failed:`,e),p([])}finally{h(!1)}},[e]),O=async(e,t)=>{_(t=>new Set(t).add(e));try{await Fr(`mcp`,e,t,{scope:`global`}),p(n=>n?.map(n=>n.name===e?{...n,enabled:t,globalEnabled:t}:n)??null)}finally{_(t=>{let n=new Set(t);return n.delete(e),n})}},k=async(e,t,n)=>{let r=`proj:${t}:${e}`;_(e=>new Set(e).add(r));try{n===void 0?await Lr(`mcp`,e,t):await Fr(`mcp`,e,n===`enabled`,{scope:`project`,projectId:t}),await D()}finally{_(e=>{let t=new Set(e);return t.delete(r),t})}},A=()=>{let e=!u;d(e),e&&D()},j=async()=>{h(!0);try{await o();let[t,n,r]=await Promise.all([Pr(),Ir(),tn()]);x(n),y(r.projects.map(e=>({id:e.id,name:e.name})));let i=t.mcp.find(t=>t.server===e);p(i?.tools.map(e=>({name:e.name,shortName:e.shortName,description:e.description,enabled:e.enabled,globalEnabled:e.globalEnabled,projectOverride:e.projectOverride}))??[])}catch(e){console.warn(`reload after probe failed:`,e),p([])}finally{h(!1)}},M=n!==void 0,N=C===`disabled`;return(0,Z.jsxs)(`div`,{className:`mcp-server-item`,onClick:M?A:void 0,children:[(0,Z.jsxs)(`div`,{className:`mcp-server-header`,style:c?{opacity:.5,pointerEvents:`none`}:void 0,children:[(0,Z.jsx)(`span`,{className:`mcp-server-chevron`,children:u?`▾`:`▸`}),(0,Z.jsx)(`span`,{className:`mcp-server-state-dot`,style:{background:w}}),(0,Z.jsx)(`span`,{className:`mcp-server-name`,children:e}),t!==void 0&&(0,Z.jsx)(`span`,{className:`mcp-server-badge`,style:{fontSize:`10px`,color:S?`var(--text-secondary)`:`var(--text-dim)`},children:l(S?`settings.mcp.enabled`:`settings.mcp.disabled`)}),(0,Z.jsx)(`span`,{className:`mcp-server-badge`,"data-kind":E,children:E}),n!==void 0&&(0,Z.jsxs)(`span`,{className:`mcp-server-tools`,children:[n.toolCount,` `,l(`settings.mcp.tools`)]})]}),u&&!c&&(0,Z.jsxs)(`div`,{className:`mcp-server-details`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(`div`,{className:`mcp-server-meta`,style:{fontSize:`11px`,color:`var(--text-dim)`,paddingBottom:`6px`},children:[(0,Z.jsx)(`span`,{style:{color:w,fontWeight:600},children:T}),n?.url!==void 0&&(0,Z.jsx)(`span`,{style:{marginLeft:`8px`},children:n.url}),n?.command!==void 0&&(0,Z.jsxs)(`span`,{style:{marginLeft:`8px`},children:[n.command,` `,(n.args??[]).slice(0,2).join(` `)]})]}),m?(0,Z.jsx)(`div`,{style:{fontSize:`11px`,color:`var(--text-dim)`,padding:`4px 0`},children:`Loading tools...`}):f!==null&&f.length>0?(0,Z.jsxs)(`div`,{className:`mcp-tools-list`,children:[(0,Z.jsx)(`div`,{className:`mcp-tools-header`,children:`Tools`}),f.map(e=>(0,Z.jsx)(em,{family:`mcp`,name:e.shortName,fqn:e.name,description:e.description,enabled:e.enabled,globalEnabled:e.globalEnabled,projectOverride:e.projectOverride,projectsList:v,overridesData:b,busy:g.has(e.name),onToggleGlobal:t=>O(e.name,t),onSetProjectOverride:(t,n)=>k(e.name,t,n)},e.name))]}):f===null?null:(0,Z.jsx)(`div`,{style:{fontSize:`11px`,color:`var(--text-dim)`,padding:`4px 0`},children:`No tools available`}),(0,Z.jsxs)(`div`,{className:`mcp-server-actions`,style:{marginTop:`6px`,display:`flex`,gap:`4px`,flexWrap:`wrap`},children:[i!==void 0&&(0,Z.jsx)(`button`,{type:`button`,className:`mcp-action-btn ${S?``:`mcp-action-btn-danger`}`,onClick:()=>i(!S),children:l(S?`settings.mcp.disable`:`settings.mcp.enable`)}),(0,Z.jsx)(`button`,{type:`button`,className:`mcp-action-btn`,onClick:j,disabled:r||N,children:r?`Probing...`:`Probe`}),a!==void 0&&(0,Z.jsx)(`button`,{type:`button`,className:`mcp-action-btn`,onClick:e=>{e.stopPropagation(),a()},children:`Edit`}),(0,Z.jsx)(`button`,{type:`button`,className:`mcp-action-btn mcp-action-btn-danger`,onClick:e=>{e.stopPropagation(),s()},children:`Remove`})]})]})]})}var Qp=`***REDACTED***`;function $p({initialName:e,initialConfig:t,isEditing:n,onSave:r,onCancel:i}){let{t:a}=qo(),o=t===void 0?!1:typeof t.command==`string`&&t.command.length>0,[s,c]=(0,G.useState)(e??``),[l,u]=(0,G.useState)(o?`stdio`:`remote`),[d,f]=(0,G.useState)(t?.enabled!==!1),[p,m]=(0,G.useState)(t?.url??``),[h,g]=(0,G.useState)(t?.transport??`auto`),[_,v]=(0,G.useState)(t?.command??``),[y,b]=(0,G.useState)((t?.args??[]).join(` `)),[x,S]=(0,G.useState)(t?.cwd??``),[C,w]=(0,G.useState)(Object.entries(t?.env??{}).map(([e,t])=>({key:e,value:t}))),[T,E]=(0,G.useState)(Object.entries(t?.headers??{}).map(([e,t])=>({key:e,value:t}))),[D,O]=(0,G.useState)(!1),[k,A]=(0,G.useState)(null);return(0,Z.jsxs)(`div`,{className:`mcp-form`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(`div`,{className:`mcp-form-row`,children:[(0,Z.jsx)(`label`,{className:`mcp-form-label`,children:a(`settings.mcp.name`)}),(0,Z.jsx)(`input`,{className:`mcp-form-input`,type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`my-mcp-server`,disabled:n,style:n?{opacity:.6}:void 0})]}),(0,Z.jsxs)(`div`,{className:`mcp-form-row`,children:[(0,Z.jsx)(`label`,{className:`mcp-form-label`,children:a(`settings.mcp.type`)}),(0,Z.jsxs)(`select`,{className:`mcp-form-select`,value:l,onChange:e=>u(e.target.value),disabled:n,style:n?{opacity:.6}:void 0,children:[(0,Z.jsx)(`option`,{value:`stdio`,children:`Stdio`}),(0,Z.jsx)(`option`,{value:`remote`,children:a(`settings.mcp.remoteUrl`)})]}),n&&(0,Z.jsx)(`span`,{style:{fontSize:`10px`,color:`var(--text-dim)`,marginLeft:`6px`},children:`(locked while editing)`})]}),(0,Z.jsxs)(`div`,{className:`mcp-form-row`,children:[(0,Z.jsx)(`label`,{className:`mcp-form-label`,children:a(`settings.mcp.enabled`)}),(0,Z.jsxs)(`label`,{className:`mcp-form-checkbox-label`,style:{display:`flex`,alignItems:`center`,gap:`6px`},children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:d,onChange:e=>f(e.target.checked)}),(0,Z.jsx)(`span`,{style:{fontSize:`11px`,color:`var(--text-secondary)`},children:a(`settings.mcp.disabledDesc`)})]})]}),l===`remote`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`mcp-form-row`,children:[(0,Z.jsx)(`label`,{className:`mcp-form-label`,children:a(`settings.mcp.url`)}),(0,Z.jsx)(`input`,{className:`mcp-form-input`,type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:`http://localhost:8080/mcp`})]}),(0,Z.jsxs)(`div`,{className:`mcp-form-row`,children:[(0,Z.jsx)(`label`,{className:`mcp-form-label`,children:a(`settings.mcp.transport`)}),(0,Z.jsxs)(`select`,{className:`mcp-form-select`,value:h,onChange:e=>g(e.target.value),children:[(0,Z.jsx)(`option`,{value:`auto`,children:a(`settings.mcp.auto`)}),(0,Z.jsx)(`option`,{value:`streamable-http`,children:`Streamable HTTP`}),(0,Z.jsx)(`option`,{value:`sse`,children:`SSE`})]})]}),(0,Z.jsx)(`div`,{className:`mcp-form-section-label`,children:a(`settings.mcp.headers`)}),T.map((e,t)=>(0,Z.jsxs)(`div`,{className:`mcp-form-row mcp-form-row-inline`,children:[(0,Z.jsx)(`input`,{className:`mcp-form-input mcp-form-input-half`,type:`text`,value:e.key,onChange:e=>{let n=[...T];n[t]={...n[t],key:e.target.value},E(n)},placeholder:`Authorization`}),(0,Z.jsx)(`input`,{className:`mcp-form-input mcp-form-input-half`,type:e.value===Qp?`text`:`password`,value:e.value===Qp?``:e.value,onChange:e=>{let n=[...T];n[t]={...n[t],value:e.target.value},E(n)},placeholder:e.value===Qp?`leave blank to keep stored value`:`Bearer ...`}),(0,Z.jsx)(`button`,{type:`button`,className:`mcp-action-btn`,onClick:()=>E(T.filter((e,n)=>n!==t)),children:`✕`})]},t)),(0,Z.jsx)(`button`,{type:`button`,className:`mcp-action-btn`,style:{alignSelf:`flex-start`},onClick:()=>E([...T,{key:``,value:``}]),children:a(`settings.mcp.addHeader`)})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`mcp-form-row`,children:[(0,Z.jsx)(`label`,{className:`mcp-form-label`,children:a(`settings.mcp.command`)}),(0,Z.jsx)(`input`,{className:`mcp-form-input`,type:`text`,value:_,onChange:e=>v(e.target.value),placeholder:`npx`})]}),(0,Z.jsxs)(`div`,{className:`mcp-form-row`,children:[(0,Z.jsx)(`label`,{className:`mcp-form-label`,children:a(`settings.mcp.args`)}),(0,Z.jsx)(`input`,{className:`mcp-form-input`,type:`text`,value:y,onChange:e=>b(e.target.value),placeholder:`-y @modelcontextprotocol/server-filesystem /path`})]}),(0,Z.jsxs)(`div`,{className:`mcp-form-row`,children:[(0,Z.jsx)(`label`,{className:`mcp-form-label`,children:a(`settings.mcp.workingDirectory`)}),(0,Z.jsx)(`input`,{className:`mcp-form-input`,type:`text`,value:x,onChange:e=>S(e.target.value),placeholder:`/absolute/path (optional)`})]}),(0,Z.jsx)(`div`,{className:`mcp-form-section-label`,children:a(`settings.mcp.environmentVariables`)}),C.map((e,t)=>(0,Z.jsxs)(`div`,{className:`mcp-form-row mcp-form-row-inline`,children:[(0,Z.jsx)(`input`,{className:`mcp-form-input mcp-form-input-half`,type:`text`,value:e.key,onChange:e=>{let n=[...C];n[t]={...n[t],key:e.target.value},w(n)},placeholder:`MY_VAR`}),(0,Z.jsx)(`input`,{className:`mcp-form-input mcp-form-input-half`,type:e.value===Qp?`text`:`password`,value:e.value===Qp?``:e.value,onChange:e=>{let n=[...C];n[t]={...n[t],value:e.target.value},w(n)},placeholder:e.value===Qp?`leave blank to keep stored value`:`value`}),(0,Z.jsx)(`button`,{type:`button`,className:`mcp-action-btn`,onClick:()=>w(C.filter((e,n)=>n!==t)),children:`✕`})]},t)),(0,Z.jsxs)(`button`,{type:`button`,className:`mcp-action-btn`,style:{alignSelf:`flex-start`},onClick:()=>w([...C,{key:``,value:``}]),children:[a(`settings.mcp.addEnv`),` Var`]})]}),k!==null&&(0,Z.jsx)(`div`,{className:`mcp-form-error`,children:k}),(0,Z.jsxs)(`div`,{className:`mcp-form-actions`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`mcp-action-btn`,onClick:i,children:a(`settings.mcp.cancel`)}),(0,Z.jsx)(`button`,{type:`button`,className:`mcp-action-btn mcp-action-btn-primary`,onClick:async()=>{A(null);let e=s.trim();if(e.length===0){A(`Server name is required`);return}let t={enabled:d};if(l===`remote`){if(p.trim().length===0){A(`URL is required for remote servers`);return}t.url=p.trim(),t.transport=h;let e={};for(let t of T)t.key.trim().length>0&&(e[t.key.trim()]=t.value);Object.keys(e).length>0&&(t.headers=e)}else{if(_.trim().length===0){A(`Command is required for stdio servers`);return}t.command=_.trim(),y.trim().length>0&&(t.args=y.split(` `).filter(Boolean)),x.trim().length>0&&(t.cwd=x.trim());let e={};for(let t of C)t.key.trim().length>0&&(e[t.key.trim()]=t.value);Object.keys(e).length>0&&(t.env=e)}O(!0);try{await r(e,t)}catch(e){A(e instanceof Error?e.message:`Failed to save server`)}finally{O(!1)}},disabled:D,children:a(D?`settings.mcp.saving`:n?`settings.mcp.saveChanges`:`settings.mcp.save`)})]})]})}function em({family:e,name:t,fqn:n,description:r,enabled:i,globalEnabled:a,projectOverride:o,projectsList:s,overridesData:c,busy:l,onToggleGlobal:u,onSetProjectOverride:d}){let{t:f}=qo(),[p,m]=(0,G.useState)(!1),h=c===null?[]:Object.entries(c.projects).filter(([,t])=>{let r=t[e];return r.enable.includes(n)||r.disable.includes(n)}).map(([e])=>e),g=s.filter(e=>!h.includes(e.id));return(0,Z.jsxs)(`div`,{className:`mcp-tool-row`,style:{flexDirection:`column`,alignItems:`stretch`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`6px`,width:`100%`},children:[(0,Z.jsx)(`span`,{style:{width:6,height:6,borderRadius:`50%`,background:i?`var(--success, #22c55e)`:`var(--text-dim)`,flexShrink:0}}),(0,Z.jsxs)(`div`,{className:`mcp-tool-info`,style:{flex:1,minWidth:0},children:[(0,Z.jsx)(`span`,{className:`mcp-tool-name`,children:t}),(0,Z.jsx)(`span`,{className:`mcp-tool-fqn`,children:n}),r!==``&&(0,Z.jsx)(`span`,{className:`mcp-tool-desc`,children:r})]}),(0,Z.jsx)(`button`,{type:`button`,className:`mcp-action-btn`,style:{fontSize:`10px`,padding:`2px 6px`},disabled:l,onClick:()=>u(!a),children:l?`...`:f(a?`settings.mcp.globalEnabled`:`settings.mcp.globalDisabled`)}),s.length>0&&(0,Z.jsxs)(`button`,{type:`button`,className:`mcp-action-btn`,style:{fontSize:`10px`,padding:`2px 6px`},onClick:()=>m(!p),children:[p?`▴`:`▾`,` Overrides (`,h.length,`)`]})]}),p&&(0,Z.jsxs)(`div`,{style:{paddingLeft:`20px`,paddingTop:`6px`},children:[h.map(t=>{let r=s.find(e=>e.id===t),i=c?.projects[t]?.[e],a=i?.enable.includes(n)?`enabled`:i?.disable.includes(n)?`disabled`:void 0;return(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`6px`,marginBottom:`4px`},children:[(0,Z.jsx)(`span`,{style:{fontSize:`11px`,color:`var(--text-secondary)`,minWidth:`80px`},children:r?.name??t}),(0,Z.jsx)(tm,{value:a,disabled:l,onChange:e=>d(t,e)})]},t)}),g.length>0&&(0,Z.jsx)(nm,{projects:g,busy:l,onSet:(e,t)=>d(e,t)}),h.length===0&&g.length===0&&(0,Z.jsx)(`span`,{style:{fontSize:`11px`,color:`var(--text-dim)`},children:`No projects configured`})]})]})}function tm({value:e,disabled:t,onChange:n}){let{t:r}=qo();return(0,Z.jsx)(`div`,{className:`mcp-tristate`,style:{display:`inline-flex`,borderRadius:`4px`,overflow:`hidden`,border:`1px solid var(--border, #333)`},children:[{label:`Inherit`,state:void 0},{label:r(`settings.mcp.enabled`),state:`enabled`},{label:r(`settings.mcp.disabled`),state:`disabled`}].map(r=>{let i=e===r.state,a=i&&r.state===`enabled`?`var(--success, #22c55e)`:i&&r.state===`disabled`?`var(--error, #ef4444)`:i?`var(--bg-tertiary, #333)`:`transparent`;return(0,Z.jsx)(`button`,{type:`button`,disabled:t,style:{padding:`2px 8px`,fontSize:`10px`,border:`none`,borderRight:`1px solid var(--border, #333)`,cursor:t?`default`:`pointer`,background:a,color:i?`#fff`:`var(--text-secondary)`,fontWeight:i?600:400},onClick:()=>n(r.state),children:r.label},r.label)})})}function nm({projects:e,busy:t,onSet:n}){let{t:r}=qo(),[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(e[0]?.id??``);return e.length===0?null:(0,Z.jsx)(`div`,{style:{marginTop:`4px`},children:i?(0,Z.jsxs)(`div`,{className:`mcp-override-form`,style:{display:`flex`,alignItems:`center`,gap:`4px`,flexWrap:`wrap`},children:[(0,Z.jsx)(`select`,{className:`mcp-form-select mcp-override-select`,style:{fontSize:`10px`,padding:`2px 4px`,maxWidth:`160px`},value:o,onChange:e=>s(e.target.value),children:e.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,Z.jsx)(`button`,{type:`button`,className:`mcp-action-btn`,style:{fontSize:`10px`,padding:`2px 6px`},disabled:t||o.length===0,onClick:()=>{n(o,`enabled`),a(!1)},children:`Enable here`}),(0,Z.jsx)(`button`,{type:`button`,className:`mcp-action-btn`,style:{fontSize:`10px`,padding:`2px 6px`},disabled:t||o.length===0,onClick:()=>{n(o,`disabled`),a(!1)},children:`Disable here`}),(0,Z.jsx)(`button`,{type:`button`,className:`mcp-action-btn`,style:{fontSize:`10px`,padding:`2px 6px`},onClick:()=>a(!1),children:r(`settings.mcp.cancel`)})]}):(0,Z.jsx)(`button`,{type:`button`,className:`mcp-action-btn`,style:{fontSize:`10px`,padding:`2px 6px`},onClick:()=>a(!0),children:`+ Add override for…`})})}var rm=`pi-kot/model/`;function im({sessionId:e,projectId:t,open:n,onClose:r}){let i=Y(e=>e.streamState.isStreaming),a=Y(e=>e.setActiveSession),o=Y(e=>e.loadProjectSessions);Y(e=>e.refreshSessions);let s=Y(e=>e.reloadMessages),[c,l]=(0,G.useState)(void 0),[u,d]=(0,G.useState)(!0),[f,p]=(0,G.useState)(void 0),[m,h]=(0,G.useState)(!1),[g,_]=(0,G.useState)(void 0),v=async()=>{d(!0),p(void 0);try{let t=await Kn(e);l(t)}catch(e){p(e instanceof Error?e.message:`Failed to load tree`)}finally{d(!1)}};(0,G.useEffect)(()=>{v()},[e]),(0,G.useEffect)(()=>{if(!i)return;let e=setInterval(()=>void v(),5e3);return()=>clearInterval(e)},[i,e]);let y=(0,G.useMemo)(()=>c===void 0?[]:hm(c),[c]),b=e=>{if(m||c===void 0||c.leafId===e)return;let t=c.leafId!==null&&gm(c,e);if(i||t){_({entryId:e,abandons:t,streaming:i});return}x(e,{})},x=async(t,n)=>{h(!0),p(void 0);try{await qn(e,t,n),await v(),await s(e)}catch(e){p(e instanceof Error?e.message:`Navigate failed`)}finally{h(!1)}},S=async(n,i={})=>{if(!m){h(!0),p(void 0);try{let s=await Jn(e,i.parentId!==void 0&&i.parentId!==null?i.parentId:n);try{let t=localStorage.getItem(rm+e);t!==null&&t.length>0&&localStorage.setItem(rm+s.sessionId,t)}catch{}await o(t),a(s.sessionId),r()}catch(e){p(e instanceof Error?e.message:`Fork failed`),h(!1)}}},[C,w]=(0,G.useState)(`list`);return(0,Z.jsxs)(Yp,{open:n,onClose:r,header:(0,Z.jsxs)(`header`,{className:`settings-header`,children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`},children:[(0,Z.jsx)(`span`,{style:{fontSize:`13px`,color:`var(--text-dim)`},children:`🌿`}),(0,Z.jsx)(`span`,{style:{fontSize:`13px`,fontWeight:600,color:`var(--text-primary)`},children:`Session Tree`}),m&&(0,Z.jsx)(`span`,{style:{fontSize:`11px`,color:`var(--text-dim)`},children:`working...`})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`6px`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,overflow:`hidden`,borderRadius:`var(--radius-sm)`,border:`1px solid var(--border)`},children:[(0,Z.jsx)(`button`,{onClick:()=>w(`list`),style:{padding:`2px 10px`,fontSize:`10px`,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.05em`,border:`none`,background:C===`list`?`var(--bg-glass-strong)`:`transparent`,color:C===`list`?`var(--text-primary)`:`var(--text-dim)`,cursor:`pointer`},children:`List`}),(0,Z.jsx)(`button`,{onClick:()=>w(`graph`),style:{padding:`2px 10px`,fontSize:`10px`,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.05em`,border:`none`,background:C===`graph`?`var(--bg-glass-strong)`:`transparent`,color:C===`graph`?`var(--text-primary)`:`var(--text-dim)`,cursor:`pointer`},children:`Graph`})]}),(0,Z.jsx)(`button`,{onClick:()=>void v(),disabled:u||m,className:`settings-close`,title:`Refresh`,style:{fontSize:`13px`},children:`↻`}),(0,Z.jsx)(`button`,{onClick:r,className:`settings-close`,title:`Close`,children:`✕`})]})]}),style:{width:640,maxWidth:`92vw`,maxHeight:`80vh`},children:[f!==void 0&&(0,Z.jsx)(`div`,{className:`settings-error`,children:f}),(0,Z.jsxs)(`div`,{style:{padding:`12px`},children:[u&&c===void 0&&(0,Z.jsx)(`div`,{style:{textAlign:`center`,padding:`24px`,color:`var(--text-dim)`,fontSize:`12px`},children:`Loading tree…`}),!u&&y.length===0&&(0,Z.jsx)(`div`,{style:{textAlign:`center`,padding:`24px`,color:`var(--text-dim)`,fontSize:`12px`},children:`No entries yet.`}),C===`list`&&y.length>0&&(0,Z.jsx)(`ul`,{style:{listStyle:`none`,padding:0,margin:0},children:y.map(e=>(0,Z.jsx)(mm,{node:e,disabled:m,onNavigate:()=>b(e.id),onFork:()=>S(e.id,{...e.type===`message`&&e.role===`user`?{editDraft:e.preview??``,parentId:e.parentId}:{}})},e.id))}),C===`graph`&&c!==void 0&&(0,Z.jsx)(Cm,{tree:c,disabled:m,onNavigate:e=>b(e),onForkAfterTurn:e=>S(e)})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`8px 16px`,borderTop:`1px solid var(--border)`,fontSize:`10px`,color:`var(--text-dim)`},children:[(0,Z.jsx)(`span`,{children:`Click a row to navigate · ↻ on user messages to fork`}),c!==void 0&&(0,Z.jsxs)(`span`,{children:[c.entries.length,` `,c.entries.length===1?`entry`:`entries`]})]}),g!==void 0&&(0,Z.jsx)(am,{state:g,onCancel:()=>_(void 0),onConfirm:e=>{let t=g.entryId;_(void 0),x(t,e)}})]})}function am({state:e,onCancel:t,onConfirm:n}){let[r,i]=(0,G.useState)(``),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(``);return(0,Z.jsx)(`div`,{style:{position:`fixed`,inset:0,zIndex:1100,display:`flex`,alignItems:`center`,justifyContent:`center`,background:`rgba(0,0,0,0.5)`,padding:`16px`},onClick:t,children:(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,width:e.abandons?`440px`:`360px`,borderRadius:`var(--radius)`,border:`1px solid var(--tool-border)`,background:`var(--bg-frosted)`,backdropFilter:`blur(var(--blur-heavy))`,padding:`16px`,gap:`12px`},onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`div`,{style:{fontSize:`13px`,fontWeight:600,color:`var(--text-primary)`},children:`Navigate session leaf`}),e.streaming&&(0,Z.jsx)(`div`,{style:{padding:`6px 10px`,fontSize:`11px`,borderRadius:`var(--radius-sm)`,background:`color-mix(in srgb, var(--warning, #fbbf24) 10%, transparent)`,border:`1px solid color-mix(in srgb, var(--warning, #fbbf24) 30%, transparent)`,color:`var(--warning)`},children:`The agent is currently running. Navigating will abort the in-progress turn.`}),e.abandons&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{style:{fontSize:`11px`,color:`var(--text-secondary)`,margin:0},children:`You’re leaving the current branch behind. You can bookmark or summarize it.`}),(0,Z.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:`4px`},children:[(0,Z.jsxs)(`span`,{style:{fontSize:`11px`,color:`var(--text-dim)`},children:[`Label for the abandoned branch `,(0,Z.jsx)(`span`,{style:{opacity:.5},children:`(optional)`})]}),(0,Z.jsx)(`input`,{type:`text`,value:r,onChange:e=>i(e.target.value),placeholder:`e.g. wrong-approach`,maxLength:200,style:{padding:`6px 8px`,fontSize:`11px`,borderRadius:`var(--radius-sm)`,border:`1px solid var(--border)`,background:`var(--bg-solid)`,color:`var(--text-primary)`,outline:`none`}})]}),(0,Z.jsxs)(`label`,{style:{display:`flex`,alignItems:`flex-start`,gap:`8px`,padding:`8px`,borderRadius:`var(--radius-sm)`,border:`1px solid var(--tool-border)`,background:`var(--bg-solid)`},children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked),style:{marginTop:`2px`}}),(0,Z.jsxs)(`span`,{style:{fontSize:`11px`,color:`var(--text-secondary)`,flex:1},children:[`Have pi write a `,(0,Z.jsx)(`code`,{style:{fontSize:`10px`},children:`branch_summary`}),` entry capturing what this branch did.`]})]}),a&&(0,Z.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:`4px`},children:[(0,Z.jsxs)(`span`,{style:{fontSize:`11px`,color:`var(--text-dim)`},children:[`Custom instructions `,(0,Z.jsx)(`span`,{style:{opacity:.5},children:`(optional)`})]}),(0,Z.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),rows:3,placeholder:`e.g. Focus on what files were changed`,style:{padding:`6px 8px`,fontSize:`11px`,fontFamily:`monospace`,borderRadius:`var(--radius-sm)`,border:`1px solid var(--border)`,background:`var(--bg-solid)`,color:`var(--text-primary)`,outline:`none`,resize:`vertical`}})]})]}),!e.streaming&&!e.abandons&&(0,Z.jsx)(`p`,{style:{fontSize:`11px`,color:`var(--text-secondary)`,margin:0},children:`Confirm navigation?`}),(0,Z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:`8px`,paddingTop:`4px`},children:[(0,Z.jsx)(`button`,{onClick:t,style:{padding:`6px 14px`,fontSize:`11px`,borderRadius:`var(--radius-sm)`,border:`1px solid var(--border)`,background:`transparent`,color:`var(--text-secondary)`,cursor:`pointer`},children:`Cancel`}),(0,Z.jsx)(`button`,{onClick:()=>{let e={},t=r.trim();if(t.length>0&&(e.label=t),a){e.summarize=!0;let t=s.trim();t.length>0&&(e.customInstructions=t)}n(e)},style:{padding:`6px 14px`,fontSize:`11px`,fontWeight:600,borderRadius:`var(--radius-sm)`,border:`none`,background:e.streaming?`var(--warning, #d97706)`:`var(--text-primary)`,color:e.streaming?`#fff`:`var(--bg-solid)`,cursor:`pointer`},children:e.streaming?`Abort & navigate`:`Navigate`})]})]})})}var om=4,sm=18,cm=10,lm=8,um=[`var(--accent)`,`var(--accent-text)`,`var(--warning)`,`var(--success)`,`var(--error)`,`var(--border-bright)`];function dm(e){return e<=0?`transparent`:um[(e-1)%um.length]}function fm(e){return e.type===`message`?e.role??`message`:e.type===`thinking_level_change`?`thinking`:e.type===`model_change`?`model`:e.type===`compaction`?`compact`:e.type===`branch_summary`?`branch`:e.type===`label`?`label`:e.type===`session_info`?`info`:e.type===`custom`?`custom`:e.type===`custom_message`?`extension`:e.type}function pm(e,t){return e===`user`?{background:`var(--accent-subtle)`,color:`var(--accent-text)`}:e===`assistant`?{background:`color-mix(in srgb, var(--accent) 12%, transparent)`,color:`var(--accent)`}:t===`branch_summary`?{background:`color-mix(in srgb, var(--warning, #fbbf24) 15%, transparent)`,color:`var(--warning, #fbbf24)`}:t===`compaction`?{background:`color-mix(in srgb, var(--accent) 8%, transparent)`,color:`var(--text-dim)`}:{background:`rgba(255,255,255,0.04)`,color:`var(--text-dim)`}}function mm({node:e,disabled:t,onNavigate:n,onFork:r}){let i=Math.min(e.depth,om)*sm+Math.min(e.branchLevel,lm)*cm,a=e.type===`message`&&e.role===`user`,o=!e.onActivePath,s=fm(e),c={display:`flex`,alignItems:`flex-start`,gap:`6px`,borderRadius:`var(--radius-sm)`,border:`1px solid`,padding:`6px 8px`,...e.isLeaf?{borderColor:`var(--accent)`,background:`var(--accent-subtle)`}:e.onActivePath?{borderColor:`var(--tool-border)`,background:`var(--bg-glass)`}:{borderColor:`var(--tool-border)`,background:`transparent`},opacity:o?.55:1,...e.branchLevel>0?{boxShadow:`inset 3px 0 0 ${dm(e.branchLevel)}`}:{}};return(0,Z.jsx)(`li`,{style:{paddingLeft:`${i}px`,minWidth:0},children:(0,Z.jsxs)(`div`,{style:c,children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`2px`,paddingTop:`1px`,flexShrink:0},children:[e.isLeaf?(0,Z.jsx)(`span`,{style:{display:`inline-block`,width:`18px`}}):(0,Z.jsx)(`button`,{onClick:n,disabled:t,title:`Navigate to this entry`,style:{padding:`2px`,fontSize:`11px`,border:`none`,background:`transparent`,color:`var(--text-dim)`,cursor:t?`default`:`pointer`,borderRadius:`3px`,lineHeight:1},children:`◎`}),a?(0,Z.jsx)(`button`,{onClick:r,disabled:t,title:`Fork from this message`,style:{padding:`2px`,fontSize:`11px`,border:`none`,background:`transparent`,color:`var(--text-dim)`,cursor:t?`default`:`pointer`,borderRadius:`3px`,lineHeight:1},children:`↻`}):(0,Z.jsx)(`span`,{style:{display:`inline-block`,width:`18px`}})]}),(0,Z.jsxs)(`button`,{onClick:n,disabled:t||e.isLeaf,style:{flex:1,minWidth:0,display:`flex`,flexDirection:`column`,alignItems:`flex-start`,gap:`2px`,textAlign:`left`,border:`none`,background:`transparent`,cursor:t||e.isLeaf?`default`:`pointer`,padding:0},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:`4px`},children:[(0,Z.jsx)(`span`,{style:{padding:`1px 6px`,fontSize:`9px`,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.03em`,borderRadius:`3px`,...pm(e.role,e.type)},children:s}),e.isBranchHead&&(0,Z.jsxs)(`span`,{style:{padding:`1px 6px`,fontSize:`9px`,textTransform:`uppercase`,borderRadius:`3px`,background:`${dm(e.branchLevel)}33`,color:dm(e.branchLevel)},children:[`branch `,e.branchLevel]}),e.label!==void 0&&e.label.length>0&&(0,Z.jsxs)(`span`,{style:{padding:`1px 6px`,fontSize:`9px`,borderRadius:`3px`,background:`var(--bg-glass-strong)`,color:`var(--text-secondary)`},children:[`★ `,e.label]}),e.isLeaf&&(0,Z.jsx)(`span`,{style:{padding:`1px 6px`,fontSize:`9px`,borderRadius:`3px`,background:`color-mix(in srgb, var(--success, #34d399) 15%, transparent)`,color:`var(--success, #34d399)`},children:`leaf`}),e.siblings>1&&(0,Z.jsxs)(`span`,{style:{fontSize:`9px`,color:`var(--warning)`},title:`${e.siblings} branches diverge here`,children:[`⑂ `,e.siblings]}),(0,Z.jsx)(`span`,{style:{fontSize:`9px`,color:`var(--text-ghost)`},children:new Date(e.timestamp).toLocaleString()})]}),e.preview!==void 0&&(0,Z.jsx)(`p`,{style:{width:`100%`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,margin:0,fontSize:`11px`,color:`var(--text-secondary)`},children:e.preview})]})]})})}function hm(e){let t=new Map;for(let n of e.entries){let e=t.get(n.parentId);e===void 0?t.set(n.parentId,[n]):e.push(n)}for(let e of t.values())e.sort((e,t)=>e.timestamp.localeCompare(t.timestamp));let n=new Set(e.branchIds),r=[],i=(a,o)=>{let s=t.get(a);if(s===void 0)return;let c=s.length;s.forEach((t,a)=>{let s=a===0?o:o+1,l=a>0&&s>0;r.push({...t,depth:t.type===`message`?t.role===`user`?0:t.role===`tool`?2:1:0,branchLevel:s,onActivePath:n.has(t.id),isLeaf:e.leafId===t.id,siblings:c,isBranchHead:l}),i(t.id,s)})};return i(null,0),r}function gm(e,t){if(e.leafId===null||e.leafId===t)return!1;let n=new Map(e.entries.map(e=>[e.id,e])),r=e.leafId;for(;r!==null;){if(r===t)return!1;r=n.get(r)?.parentId??null}return!0}var _m=200,vm=68,ym=48,bm=24,xm=20;function Sm(e){let t=new Map(e.entries.map(e=>[e.id,e])),n=new Map;for(let t of e.entries){let e=n.get(t.parentId);e===void 0?n.set(t.parentId,[t]):e.push(t)}for(let e of n.values())e.sort((e,t)=>e.timestamp.localeCompare(t.timestamp));let r=new Map,i=e=>{let n=r.get(e.id);if(n!==void 0)return n;if(e.type===`message`&&e.role===`user`||e.parentId===null)return r.set(e.id,e.id),e.id;let a=t.get(e.parentId);if(a===void 0)return r.set(e.id,e.id),e.id;let o=i(a);return r.set(e.id,o),o};for(let t of e.entries)i(t);let a=new Map;for(let t of e.entries){if(r.get(t.id)!==t.id)continue;let e=t.type===`message`&&t.role===`user`;a.set(t.id,{id:t.id,parentId:null,col:0,row:0,isOnActivePath:!1,isLeafTurn:!1,roleLabel:e?`user`:fm(t),preview:t.preview??``,isUserAnchor:e,anchorParentId:t.parentId,lastEntryId:t.id,timestamp:t.timestamp})}for(let n of e.entries){let e=r.get(n.id),i=a.get(e);if(i===void 0)continue;let o=t.get(i.lastEntryId);(o===void 0||n.timestamp.localeCompare(o.timestamp)>=0)&&(i.lastEntryId=n.id)}for(let e of a.values()){if(e.anchorParentId===null)continue;let t=r.get(e.anchorParentId);t===void 0||t===e.id||(e.parentId=t)}let o=new Set(e.branchIds),s=e.leafId===null?void 0:r.get(e.leafId);for(let e of a.values())e.isOnActivePath=o.has(e.id),e.isLeafTurn=s===e.id;let c=new Map;for(let e of a.values()){let t=c.get(e.parentId);t===void 0?c.set(e.parentId,[e]):t.push(e)}for(let e of c.values())e.sort((e,t)=>e.timestamp.localeCompare(t.timestamp));let l=0,u=(e,t)=>{(c.get(e)??[]).forEach((e,n)=>{let r;n===0?r=t:(r=l,l+=1),e.col=r,u(e.id,r)})};(c.get(null)??[]).forEach((e,t)=>{t===0?(e.col=0,l=Math.max(l,1)):(e.col=l,l+=1),u(e.id,e.col)});let d=new Map,f=e=>{let t=d.get(e.id);if(t!==void 0)return t;if(e.parentId===null)return d.set(e.id,0),0;let n=a.get(e.parentId);if(n===void 0)return d.set(e.id,0),0;let r=f(n)+1;return d.set(e.id,r),r};for(let e of a.values())e.row=f(e);return[...a.values()].sort((e,t)=>e.row===t.row?e.col-t.col:e.row-t.row)}function Cm({tree:e,disabled:t,onNavigate:n,onForkAfterTurn:r}){let i=(0,G.useMemo)(()=>Sm(e),[e]),a=(0,G.useMemo)(()=>{if(i.length===0)return{width:0,height:0};let e=i.reduce((e,t)=>Math.max(e,t.col),0),t=i.reduce((e,t)=>Math.max(e,t.row),0);return{width:xm*2+(e+1)*_m+e*ym,height:xm*2+(t+1)*vm+t*bm}},[i]);if(i.length===0)return(0,Z.jsx)(`div`,{style:{textAlign:`center`,padding:`24px`,color:`var(--text-dim)`,fontSize:`12px`},children:`No turns to render.`});let o=e=>xm+e*248,s=e=>xm+e*92,c=new Map(i.map(e=>[e.id,e]));return(0,Z.jsxs)(`div`,{style:{position:`relative`,width:`${a.width}px`,height:`${a.height}px`},children:[(0,Z.jsx)(`svg`,{"aria-hidden":!0,style:{position:`absolute`,left:0,top:0,pointerEvents:`none`},width:a.width,height:a.height,children:i.map(e=>{if(e.parentId===null)return null;let t=c.get(e.parentId);if(t===void 0)return null;let n=o(t.col)+_m/2,r=s(t.row)+vm,i=o(e.col)+_m/2,a=s(e.row),l=e.isOnActivePath&&t.isOnActivePath;return(0,Z.jsx)(`path`,{d:n===i?`M ${n} ${r} L ${i} ${a}`:(()=>{let e=r+(a-r)/2,t=i>n,o=t?n+6:n-6,s=t?i-6:i+6;return[`M ${n} ${r}`,`L ${n} ${e-6}`,`Q ${n} ${e} ${o} ${e}`,`L ${s} ${e}`,`Q ${i} ${e} ${i} ${e+6}`,`L ${i} ${a}`].join(` `)})(),fill:`none`,stroke:l?`#a3a3a3`:`#404040`,strokeWidth:l?1.5:1,strokeOpacity:l?.85:.5},e.id)})}),i.map(e=>(0,Z.jsx)(wm,{turn:e,x:o(e.col),y:s(e.row),disabled:t,onNavigate:()=>n(e.lastEntryId),onForkAfterTurn:()=>r(e.lastEntryId)},e.id))]})}function wm({turn:e,x:t,y:n,disabled:r,onNavigate:i,onForkAfterTurn:a}){let o=!e.isOnActivePath,s=e.isLeafTurn?`var(--accent)`:(e.isOnActivePath,`var(--tool-border)`);return(0,Z.jsxs)(`div`,{style:{position:`absolute`,left:`${t}px`,top:`${n}px`,width:`${_m}px`,height:`${vm}px`,borderRadius:`var(--radius-sm)`,border:`1px solid`,borderColor:s,background:e.isLeafTurn?`var(--accent-subtle)`:e.isOnActivePath?`var(--bg-glass)`:`var(--bg-solid)`,opacity:o?.55:1,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:[(0,Z.jsxs)(`button`,{onClick:i,disabled:r,style:{flex:1,display:`flex`,flexDirection:`column`,alignItems:`flex-start`,justifyContent:`center`,padding:`6px 8px`,gap:`2px`,textAlign:`left`,border:`none`,background:`transparent`,cursor:r?`default`:`pointer`,width:`100%`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`4px`,flexWrap:`wrap`},children:[(0,Z.jsx)(`span`,{style:{padding:`1px 5px`,fontSize:`8px`,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.03em`,borderRadius:`2px`,...pm(e.roleLabel===`user`?`user`:e.roleLabel===`assistant`?`assistant`:void 0,void 0)},children:e.roleLabel}),e.isLeafTurn&&(0,Z.jsx)(`span`,{style:{fontSize:`8px`,color:`var(--accent-text)`},children:`leaf`})]}),e.preview.length>0&&(0,Z.jsxs)(`p`,{style:{margin:0,fontSize:`10px`,color:`var(--text-secondary)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,maxWidth:`100%`},children:[e.preview.slice(0,60),e.preview.length>60?`…`:``]})]}),e.isUserAnchor&&(0,Z.jsx)(`button`,{onClick:a,disabled:r,title:`Fork from this turn`,style:{padding:`1px 6px`,fontSize:`9px`,border:`none`,borderTop:`1px solid var(--tool-border)`,background:`transparent`,color:`var(--text-dim)`,cursor:r?`default`:`pointer`,width:`100%`},children:`↻ fork`})]})}var Tm=[{id:`dark`,name:`Dark`,icon:`🌙`},{id:`dusk`,name:`Dusk`,icon:`🌆`},{id:`dark-warm`,name:`Dark Warm`,icon:`🟤`},{id:`light`,name:`Light`,icon:`☀️`},{id:`light-warm`,name:`Light Warm`,icon:`📜`}],Em={night:`dusk`,midnight:`dark`,dawn:`dark-warm`,"flexoki-dark":`dark-warm`,monokai:`dark`,dracula:`dark`,nord:`dark`,bourbon:`dark-warm`,clean:`light`,terracotta:`light-warm`,sage:`light-warm`,"flexoki-light":`light-warm`},Dm=[{id:`slate`,name:`Slate`,color:`#64748b`},{id:`blue`,name:`Blue`,color:`#2563eb`},{id:`violet`,name:`Violet`,color:`#7c3aed`},{id:`emerald`,name:`Emerald`,color:`#059669`},{id:`amber`,name:`Amber`,color:`#d97706`},{id:`rose`,name:`Rose`,color:`#e11d48`},{id:`teal`,name:`Teal`,color:`#0d9488`},{id:`orange`,name:`Orange`,color:`#ea580c`},{id:`flexoki`,name:`Flexoki`,color:`#da702c`}],Om=`pi-kot-theme`,km=`pi-kot-accent`;function Am(){return{theme:window.matchMedia?.(`(prefers-color-scheme: dark)`).matches?`dark`:`light`,accent:`blue`}}function jm(){try{let e=localStorage.getItem(Om);if(Tm.some(t=>t.id===e))return e;if(e&&e in Em){let t=Em[e];try{localStorage.setItem(Om,t)}catch{}return t}}catch{}return Am().theme}function Mm(){try{let e=localStorage.getItem(km);if(e&&Dm.some(t=>t.id===e))return e}catch{}return Am().accent}function Nm(e,t){document.documentElement.setAttribute(`data-theme`,e),t&&document.documentElement.setAttribute(`data-accent`,t);try{localStorage.setItem(Om,e),t&&localStorage.setItem(km,t)}catch{}}function Pm(e){return e instanceof Error?e.message:String(e)}function Fm({checked:e,onChange:t,disabled:n=!1,ariaLabel:r}){return(0,Z.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":r,disabled:n,onClick:()=>t(!e),className:`settings-toggle ${e?`active`:``}`,children:(0,Z.jsx)(`span`,{className:`settings-toggle-knob`})})}function Im({label:e,hint:t,children:n,alignTop:r=!1,stacked:i=!1,className:a=``}){return(0,Z.jsxs)(`div`,{className:`settings-item-row ${r?`align-top`:``} ${i?`stacked`:``} ${a}`.trim(),children:[(0,Z.jsxs)(`div`,{className:`settings-item-info`,children:[(0,Z.jsx)(`div`,{className:`settings-item-label`,children:e}),t&&(0,Z.jsx)(`div`,{className:`settings-item-desc`,children:t})]}),n&&(0,Z.jsx)(`div`,{className:`settings-item-control`,children:n})]})}function Lm({icon:e,title:t,subtitle:n,badge:r,action:i,children:a,className:o=``}){return(0,Z.jsxs)(`div`,{className:`settings-section-card ${o}`.trim(),children:[(0,Z.jsxs)(`div`,{className:`settings-section-header`,children:[(0,Z.jsxs)(`div`,{className:`settings-section-title-wrap`,children:[e&&(0,Z.jsx)(`div`,{className:`settings-section-icon`,children:e}),(0,Z.jsxs)(`div`,{className:`settings-section-text`,children:[(0,Z.jsxs)(`div`,{className:`settings-section-title`,children:[(0,Z.jsx)(`span`,{children:t}),r]}),n&&(0,Z.jsx)(`div`,{className:`settings-section-subtitle`,children:n})]})]}),i&&(0,Z.jsx)(`div`,{className:`settings-section-action`,children:i})]}),(0,Z.jsx)(`div`,{className:`settings-section-content`,children:a})]})}function Rm(){return(0,Z.jsx)(`div`,{className:`settings-item-divider`})}function zm(e,t,n){let r=document.documentElement;e?r.style.setProperty(`--user-bubble`,e):r.style.removeProperty(`--user-bubble`),t?r.style.setProperty(`--user-bubble-text`,t):r.style.removeProperty(`--user-bubble-text`),n?r.style.setProperty(`--user-bubble-border`,n):r.style.removeProperty(`--user-bubble-border`)}var Bm=`pi-kot/user-bubble-bg`,Vm=`pi-kot/user-bubble-text`,Hm=`pi-kot/user-bubble-border`;function Um(e){try{let t=localStorage.getItem(e);return t===null?null:t}catch{return null}}function Wm(e,t){try{t?localStorage.setItem(e,t):localStorage.removeItem(e)}catch{}}var Gm=[{name:`Accent`,bg:null,text:null,border:null},{name:`Blue`,bg:`#1e40af`,text:`#dbeafe`,border:`#3b82f6`},{name:`Violet`,bg:`#5b21b6`,text:`#ede9fe`,border:`#8b5cf6`},{name:`Emerald`,bg:`#065f46`,text:`#d1fae5`,border:`#10b981`},{name:`Amber`,bg:`#92400e`,text:`#fef3c7`,border:`#f59e0b`},{name:`Rose`,bg:`#9f1239`,text:`#ffe4e6`,border:`#f43f5e`},{name:`Teal`,bg:`#115e59`,text:`#ccfbf1`,border:`#14b8a8`},{name:`Orange`,bg:`#9a3412`,text:`#ffedd5`,border:`#f97316`},{name:`Slate`,bg:`#334155`,text:`#f1f5f9`,border:`#64748b`},{name:`Custom`,bg:`__custom__`,text:`__custom__`,border:`__custom__`}];function Km(){let{t:e}=qo(),[t,n]=(0,G.useState)(()=>jm()),[r,i]=(0,G.useState)(()=>Mm()),[a,s]=(0,G.useState)(!1),c=Q(e=>e.stickyUserHeader),l=Q(e=>e.showTokenUsage),u=Q(e=>e.compressImages),d=Q(e=>e.showThinking),f=Q(e=>e.groupedToolDisplay),p=Q(e=>e.trailDefaultView),m=Q(e=>e.showTurnFiles),h=Q(e=>e.swipeToOpenSidebar),g=Q(e=>e.setStickyUserHeader),_=Q(e=>e.flyToTop),v=Q(e=>e.setFlyToTop),y=Q(e=>e.setShowTokenUsage),b=Q(e=>e.setCompressImages),x=Q(e=>e.setShowThinking),S=Q(e=>e.setGroupedToolDisplay),C=Q(e=>e.setTrailDefaultView),w=Q(e=>e.setShowTurnFiles),T=Q(e=>e.setSwipeToOpenSidebar),E=Q(e=>e.emptyFlapEnabled),D=Q(e=>e.emptyFlapWords),O=Q(e=>e.setEmptyFlapEnabled),k=Q(e=>e.setEmptyFlapWords),[A,j]=(0,G.useState)(c),[P,F]=(0,G.useState)(_),[I,R]=(0,G.useState)(l),[z,ee]=(0,G.useState)(u),[B,V]=(0,G.useState)(d),[H,U]=(0,G.useState)(f),[te,ne]=(0,G.useState)(p),[re,ie]=(0,G.useState)(m),[ae,oe]=(0,G.useState)(h),[se,le]=(0,G.useState)(E),[ue,de]=(0,G.useState)(D),[fe,me]=(0,G.useState)(D.join(`, `)),[he,ge]=(0,G.useState)(()=>Um(Bm)),[_e,ve]=(0,G.useState)(()=>Um(Vm)),[ye,be]=(0,G.useState)(()=>Um(Hm)),[xe,Se]=(0,G.useState)(0),Ce=(0,G.useRef)({bg:null,text:null,border:null}),we=()=>{Ce.current={bg:he,text:_e,border:ye}};(0,G.useEffect)(()=>{let e=!1;return An().then(t=>{if(e)return;s(!0);let r=t.theme,a=r&&Em[r]?Em[r]:r,o=a&&Tm.some(e=>e.id===a)?a:jm(),c=t.accent&&Dm.some(e=>e.id===t.accent)?t.accent:Mm();n(o),i(c),Nm(o,c),(!t.theme||!t.accent)&&Te({theme:o,accent:c}),typeof t.stickyUserHeader==`boolean`&&(j(t.stickyUserHeader),g(t.stickyUserHeader)),typeof t.flyToTop==`boolean`&&(F(t.flyToTop),v(t.flyToTop)),typeof t.showTokenUsage==`boolean`&&(R(t.showTokenUsage),y(t.showTokenUsage)),typeof t.compressImages==`boolean`&&(ee(t.compressImages),b(t.compressImages)),typeof t.showThinking==`boolean`&&(V(t.showThinking),x(t.showThinking)),typeof t.groupedToolDisplay==`boolean`&&(U(t.groupedToolDisplay),S(t.groupedToolDisplay)),(t.trailDefaultView===`full`||t.trailDefaultView===`justify`)&&(ne(t.trailDefaultView),C(t.trailDefaultView)),typeof t.showTurnFiles==`boolean`&&(ie(t.showTurnFiles),w(t.showTurnFiles)),typeof t.swipeToOpenSidebar==`boolean`&&(oe(t.swipeToOpenSidebar),T(t.swipeToOpenSidebar)),typeof t.emptyFlapEnabled==`boolean`&&(le(t.emptyFlapEnabled),O(t.emptyFlapEnabled)),Array.isArray(t.emptyFlapWords)&&(de(t.emptyFlapWords),me(t.emptyFlapWords.join(`, `)),k(t.emptyFlapWords));let l=t.userBubbleColor===void 0?Um(Bm):t.userBubbleColor,u=t.userBubbleTextColor===void 0?Um(Vm):t.userBubbleTextColor,d=t.userBubbleBorderColor===void 0?Um(Hm):t.userBubbleBorderColor;ge(l),ve(u),be(d),zm(l,u,d),Wm(Bm,l),Wm(Vm,u),Wm(Hm,d);let f=Gm.findIndex(e=>e.bg===l&&e.text===u&&e.border===d);Se(f>=0?f:Gm.length-1)}).catch(()=>{}),()=>{e=!0}},[]),(0,G.useEffect)(()=>{we()});let Te=(0,G.useCallback)(e=>{jn(e).catch(()=>{})},[]),Ee=e=>{n(e),Nm(e,r),Te({theme:e,accent:r})},De=e=>{i(e),Nm(t,e),Te({accent:e,theme:t})},Oe=e=>{j(e),g(e),Te({stickyUserHeader:e})},W=e=>{F(e),v(e),Te({flyToTop:e})},ke=e=>{R(e),y(e),Te({showTokenUsage:e})},Ae=e=>{ee(e),b(e),Te({compressImages:e})},je=e=>{V(e),x(e),Te({showThinking:e})},Me=e=>{U(e),S(e),Te({groupedToolDisplay:e})},Ne=e=>{ne(e),C(e),Te({trailDefaultView:e})},Pe=e=>{ie(e),w(e),Te({showTurnFiles:e})},Fe=e=>{oe(e),T(e),Te({swipeToOpenSidebar:e})},Ie=e=>{le(e),O(e),Te({emptyFlapEnabled:e})},Le=e=>{let t=e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0).slice(0,8).map(e=>e.slice(0,32)),n=t.length>0?t:ue.length>0?ue:[`PI-KOT 0.1.41`,`PI-SDK 0.87.1`];de(n),me(n.join(`, `)),k(n),Te({emptyFlapWords:n})},Re=e=>{let t=Gm[e];Se(e),t.bg!==`__custom__`&&(ge(t.bg),ve(t.text),be(t.border),zm(t.bg,t.text,t.border),Wm(Bm,t.bg),Wm(Vm,t.text),Wm(Hm,t.border),Te({userBubbleColor:t.bg,userBubbleTextColor:t.text,userBubbleBorderColor:t.border}))},ze=(e,t)=>{let n=Ce.current,r=e===`bg`?t:n.bg,i=e===`text`?t:n.text,a=e===`border`?t:n.border;e===`bg`&&ge(t),e===`text`&&ve(t),e===`border`&&be(t),Se(Gm.length-1),zm(r,i,a),Wm(Bm,r),Wm(Vm,i),Wm(Hm,a),Te({userBubbleColor:r,userBubbleTextColor:i,userBubbleBorderColor:a})};return(0,Z.jsxs)(`div`,{className:`settings-fields`,children:[(0,Z.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`8px 12px`,borderRadius:`var(--radius-sm)`,background:`var(--bg-glass)`,border:`1px solid var(--border)`,fontSize:12},children:(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,Z.jsx)(`span`,{style:{width:8,height:8,borderRadius:`50%`,background:a?`var(--success, #34d399)`:`var(--warning, #fbbf24)`}}),(0,Z.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:e(a?`settings.appearance.preferencesSaved`:`settings.appearance.preferencesLocal`)})]})}),(0,Z.jsxs)(Lm,{icon:(0,Z.jsx)(M,{size:15}),title:`${e(`settings.appearance.theme`)} & ${e(`settings.appearance.accent`)}`,subtitle:`Customize theme modes and system accent highlights`,children:[(0,Z.jsxs)(`div`,{className:`settings-item-row stacked`,children:[(0,Z.jsxs)(`div`,{className:`settings-item-info`,children:[(0,Z.jsx)(`div`,{className:`settings-item-label`,children:e(`settings.appearance.theme`)}),(0,Z.jsx)(`div`,{className:`settings-item-desc`,children:`Select dark, light, or warm editor color palettes`})]}),(0,Z.jsx)(`div`,{className:`settings-theme-grid`,children:Tm.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`settings-theme-card ${t===e.id?`active`:``}`,onClick:()=>Ee(e.id),children:[(0,Z.jsx)(`span`,{className:`settings-theme-icon`,children:e.icon}),(0,Z.jsx)(`span`,{children:e.name})]},e.id))})]}),(0,Z.jsx)(Rm,{}),(0,Z.jsxs)(`div`,{className:`settings-item-row stacked`,children:[(0,Z.jsxs)(`div`,{className:`settings-item-info`,children:[(0,Z.jsx)(`div`,{className:`settings-item-label`,children:e(`settings.appearance.accent`)}),(0,Z.jsx)(`div`,{className:`settings-item-desc`,children:`Focus rings, active tabs, buttons, and highlighted indicators`})]}),(0,Z.jsx)(`div`,{className:`settings-accents-row`,children:Dm.map(e=>(0,Z.jsx)(`button`,{type:`button`,onClick:()=>De(e.id),title:e.name,className:`settings-accent-dot ${r===e.id?`active`:``}`,style:{backgroundColor:e.color}},e.id))})]})]}),(0,Z.jsxs)(Lm,{icon:(0,Z.jsx)(o,{size:15}),title:e(`settings.appearance.yourMessageBubble`),subtitle:`Customize the color scheme and appearance of your user prompts`,action:xe===0?void 0:(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{ge(null),ve(null),be(null),Se(0),zm(null,null,null),Wm(Bm,null),Wm(Vm,null),Wm(Hm,null),Te({userBubbleColor:null,userBubbleTextColor:null,userBubbleBorderColor:null})},className:`settings-btn settings-btn-xs`,title:e(`settings.appearance.resetDefaults`),children:[(0,Z.jsx)(L,{size:11}),(0,Z.jsx)(`span`,{children:e(`settings.appearance.resetDefaults`)})]}),children:[(0,Z.jsx)(`div`,{style:{display:`flex`,gap:`6px`,flexWrap:`wrap`},children:Gm.map((e,t)=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>Re(t),className:`providers-filter-tab ${xe===t?`active`:``}`,style:{display:`inline-flex`,alignItems:`center`,gap:6,border:`1px solid ${xe===t?`var(--accent)`:`var(--border)`}`},children:[e.bg!==`__custom__`&&e.bg!==null&&(0,Z.jsx)(`span`,{style:{width:10,height:10,borderRadius:2,background:e.bg,border:`1px solid ${e.border??`transparent`}`,flexShrink:0}}),e.name]},e.name))}),(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12,padding:12,borderRadius:`var(--radius-sm)`,background:`var(--bg-glass-strong)`,border:`1px solid var(--border)`},children:[(0,Z.jsx)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:(0,Z.jsx)(`span`,{style:{fontSize:11,fontWeight:600,color:`var(--text-dim)`,textTransform:`uppercase`,letterSpacing:`0.05em`},children:e(`settings.appearance.preview`)})}),(0,Z.jsx)(`div`,{className:`message-row user`,style:{padding:0},children:(0,Z.jsx)(`div`,{className:`message-bubble user`,children:e(`settings.appearance.previewUser`)})}),(0,Z.jsx)(`div`,{className:`message-row assistant`,style:{padding:0},children:(0,Z.jsx)(`div`,{className:`message-bubble assistant`,style:{fontSize:13,color:`var(--text-secondary)`},children:e(`settings.appearance.previewAssistant`)})}),xe===Gm.length-1&&(0,Z.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(180px, 1fr))`,gap:10,marginTop:6,paddingTop:10,borderTop:`1px solid var(--border)`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,Z.jsx)(`label`,{style:{fontSize:11,color:`var(--text-secondary)`,fontWeight:500},children:e(`settings.appearance.background`)}),(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6},children:[(0,Z.jsx)(`input`,{type:`color`,value:he??`#1e40af`,onChange:e=>ze(`bg`,e.target.value),style:{width:28,height:28,padding:0,border:`1px solid var(--border)`,borderRadius:4,cursor:`pointer`}}),(0,Z.jsx)(`input`,{type:`text`,value:he??``,onChange:e=>ze(`bg`,e.target.value||``),placeholder:`accent default`,className:`settings-input`,style:{fontSize:11,padding:`4px 8px`,fontFamily:`var(--font-mono)`}})]})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,Z.jsx)(`label`,{style:{fontSize:11,color:`var(--text-secondary)`,fontWeight:500},children:e(`settings.appearance.text`)}),(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6},children:[(0,Z.jsx)(`input`,{type:`color`,value:_e??`#ffffff`,onChange:e=>ze(`text`,e.target.value),style:{width:28,height:28,padding:0,border:`1px solid var(--border)`,borderRadius:4,cursor:`pointer`}}),(0,Z.jsx)(`input`,{type:`text`,value:_e??``,onChange:e=>ze(`text`,e.target.value||``),placeholder:`accent default`,className:`settings-input`,style:{fontSize:11,padding:`4px 8px`,fontFamily:`var(--font-mono)`}})]})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,Z.jsx)(`label`,{style:{fontSize:11,color:`var(--text-secondary)`,fontWeight:500},children:e(`settings.appearance.border`)}),(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6},children:[(0,Z.jsx)(`input`,{type:`color`,value:ye??`#3b82f6`,onChange:e=>ze(`border`,e.target.value),style:{width:28,height:28,padding:0,border:`1px solid var(--border)`,borderRadius:4,cursor:`pointer`}}),(0,Z.jsx)(`input`,{type:`text`,value:ye??``,onChange:e=>ze(`border`,e.target.value||``),placeholder:`accent default`,className:`settings-input`,style:{fontSize:11,padding:`4px 8px`,fontFamily:`var(--font-mono)`}})]})]})]})]})]}),(0,Z.jsxs)(Lm,{icon:(0,Z.jsx)(pe,{size:15}),title:e(`settings.appearance.chat`),subtitle:`Layout behavior, streaming flow, and execution trail visibility`,children:[(0,Z.jsx)(Im,{label:e(`settings.appearance.stickyUserHeader`),hint:`Pins your prompt header to the top when scrolling through long replies`,children:(0,Z.jsx)(Fm,{checked:A,onChange:Oe,ariaLabel:e(`settings.appearance.stickyUserHeader`)})}),(0,Z.jsx)(Rm,{}),(0,Z.jsx)(Im,{label:e(`settings.appearance.flyToTop`),hint:e(`settings.appearance.flyToTopDesc`),children:(0,Z.jsx)(Fm,{checked:P,onChange:W,ariaLabel:e(`settings.appearance.flyToTop`)})}),(0,Z.jsx)(Rm,{}),(0,Z.jsx)(Im,{label:e(`settings.appearance.showTokenUsage`),hint:`Show input and output token consumption chips on each turn`,children:(0,Z.jsx)(Fm,{checked:I,onChange:ke,ariaLabel:e(`settings.appearance.showTokenUsage`)})}),(0,Z.jsx)(Rm,{}),(0,Z.jsx)(Im,{label:e(`settings.appearance.showTurnFiles`),hint:e(`settings.appearance.showTurnFilesDesc`),children:(0,Z.jsx)(Fm,{checked:re,onChange:Pe,ariaLabel:e(`settings.appearance.showTurnFiles`)})}),(0,Z.jsx)(Rm,{}),(0,Z.jsx)(Im,{label:e(`settings.appearance.showThinking`),hint:`Render reasoning and thinking blocks emitted by compatible models`,children:(0,Z.jsx)(Fm,{checked:B,onChange:je,ariaLabel:e(`settings.appearance.showThinking`)})}),(0,Z.jsx)(Rm,{}),(0,Z.jsx)(Im,{label:e(`settings.appearance.groupedToolDisplay`),hint:e(`settings.appearance.groupedToolDisplayDesc`),alignTop:H,children:(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:`flex-end`,gap:8},children:[(0,Z.jsx)(Fm,{checked:H,onChange:Me,ariaLabel:e(`settings.appearance.groupedToolDisplay`)}),H&&(0,Z.jsx)(`div`,{className:`settings-segmented`,children:[`justify`,`full`].map(t=>(0,Z.jsx)(`button`,{type:`button`,className:`settings-segmented-btn ${te===t?`active`:``}`,onClick:()=>Ne(t),title:e(`settings.appearance.trailHint`),children:e(t===`justify`?`settings.appearance.trailAuto`:`settings.appearance.trailExpandAll`)},t))})]})})]}),(0,Z.jsxs)(Lm,{icon:(0,Z.jsx)(N,{size:15}),title:`Touch & Media`,subtitle:`Gestures for touchscreen navigation and media optimization`,children:[(0,Z.jsx)(Im,{label:e(`settings.appearance.compressImages`),hint:`Automatically downscale high-resolution images to conserve context tokens`,children:(0,Z.jsx)(Fm,{checked:z,onChange:Ae,ariaLabel:e(`settings.appearance.compressImages`)})}),(0,Z.jsx)(Rm,{}),(0,Z.jsx)(Im,{label:e(`settings.appearance.swipeSidebar`),hint:e(`settings.appearance.swipeSidebarHint`),children:(0,Z.jsx)(Fm,{checked:ae,onChange:Fe,ariaLabel:e(`settings.appearance.swipeSidebar`)})})]}),(0,Z.jsxs)(Lm,{icon:(0,Z.jsx)(ce,{size:15}),title:e(`settings.appearance.emptyState`),subtitle:`Interactive greeting board for newly created chat sessions`,children:[(0,Z.jsx)(Im,{label:e(`settings.appearance.splitFlap`),hint:e(`settings.appearance.splitFlapHint`),children:(0,Z.jsx)(Fm,{checked:se,onChange:Ie,ariaLabel:e(`settings.appearance.splitFlap`)})}),se&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Rm,{}),(0,Z.jsxs)(`div`,{className:`settings-item-row stacked`,children:[(0,Z.jsxs)(`div`,{className:`settings-item-info`,children:[(0,Z.jsx)(`div`,{className:`settings-item-label`,children:e(`settings.appearance.splitFlapPhrases`)}),(0,Z.jsx)(`div`,{className:`settings-item-desc`,children:e(`settings.appearance.splitFlapPhrasesHint`)})]}),(0,Z.jsx)(`input`,{value:fe,onChange:e=>me(e.target.value),onBlur:()=>Le(fe),onKeyDown:e=>{e.key===`Enter`&&Le(fe)},className:`settings-input`,placeholder:`PI-KOT 0.1.41, PI-SDK 0.87.1`})]}),(0,Z.jsx)(`div`,{style:{marginTop:4,padding:`16px 12px`,borderRadius:`var(--radius-md)`,border:`1px solid var(--border)`,background:`var(--bg-glass-strong)`,display:`flex`,justifyContent:`center`,overflow:`hidden`,maxWidth:`100%`},children:(0,Z.jsx)(sf,{words:ue,flipDuration:.12,stagger:.05,cycleDelay:2600,flipsPerChar:7,gap:4,tileRadius:6,fontSize:14})})]})]})]})}var qm=[{value:`openai-completions`,label:`OpenAI Compatible (Chat Completions)`},{value:`openai-responses`,label:`OpenAI Responses API`},{value:`anthropic-messages`,label:`Anthropic Messages API`},{value:`google-generative-ai`,label:`Google Generative AI`},{value:`mistral-conversations`,label:`Mistral Conversations`}],Jm=[{name:`ollama`,label:`Ollama`,baseUrl:`http://localhost:11434/v1`,port:`11434`,apiType:`openai-completions`},{name:`lmstudio`,label:`LM Studio`,baseUrl:`http://localhost:1234/v1`,port:`1234`,apiType:`openai-completions`},{name:`vllm`,label:`vLLM`,baseUrl:`http://localhost:8000/v1`,port:`8000`,apiType:`openai-completions`},{name:`localai`,label:`LocalAI`,baseUrl:`http://localhost:8080/v1`,port:`8080`,apiType:`openai-completions`}];function Ym({open:e,onClose:t,onError:n,onSaved:r,initialPreset:i}){let{t:a}=qo(),[o,s]=(0,G.useState)(`url`),[l,u]=(0,G.useState)(``),[d,f]=(0,G.useState)(``),[m,h]=(0,G.useState)(``),[_,y]=(0,G.useState)(`openai-completions`),[x,S]=(0,G.useState)(!1),[C,w]=(0,G.useState)(!1),[T,E]=(0,G.useState)(void 0),[D,k]=(0,G.useState)(!1),[j,M]=(0,G.useState)([]),[N,P]=(0,G.useState)(!0),[F,I]=(0,G.useState)(!1),[L,R]=(0,G.useState)(!1),z=(0,G.useRef)(null);(0,G.useEffect)(()=>{if(!e)return;s(`url`);let t=i?.baseUrl??``,r=i?.name??``,a=i?.apiKey??``,o=i?.apiType??`openai-completions`;u(t),f(r),h(a),y(o),S(!1),w(!1),E(void 0),k(!1),M([]),P(!0),I(!1),R(!1),n(void 0),t||requestAnimationFrame(()=>z.current?.focus())},[e,i,n]);let ee=(0,G.useCallback)(async()=>{if(l.trim()){k(!0),E(void 0),n(void 0);try{let e=await Pn({baseUrl:l.trim(),apiKey:m.trim()||void 0,apiType:_});E(e),e.reachable&&e.models&&e.models.length>0?(!d.trim()&&e.suggestedName&&f(e.suggestedName),M(e.models.map(e=>({id:e.id,name:e.name??e.id,contextWindow:128e3,maxTokens:4096,reasoning:!1,vision:!1,selected:!0}))),w(!0),s(`models`)):e.reachable?(w(!0),M([]),s(`models`)):w(!1)}catch(e){n(e instanceof Error?e.message:`Test connection failed`),E({reachable:!1,error:e instanceof Error?e.message:`Unknown error`})}finally{k(!1)}}},[l,m,_,d,n]),B=(0,G.useCallback)(e=>{e.key===`Enter`&&o===`url`&&l.trim()&&(e.preventDefault(),ee())},[o,l,ee]),V=(0,G.useCallback)(()=>{P(e=>{let t=!e;return M(e=>e.map(e=>({...e,selected:t}))),t})},[]),H=(0,G.useCallback)(e=>{M(t=>t.map(t=>t.id===e?{...t,selected:!t.selected}:t))},[]),ne=(0,G.useCallback)((e,t,n)=>{M(r=>r.map(r=>r.id===e?{...r,[t]:n}:r))},[]),re=(0,G.useCallback)(async()=>{if(!d.trim()||!l.trim())return;I(!0),n(void 0);let e=j.filter(e=>e.selected),i={baseUrl:l.trim(),api:_};m.trim()&&(i.apiKey=m.trim()),e.length>0&&(i.models=e.map(e=>{let t={id:e.id,name:e.name,contextWindow:e.contextWindow,maxTokens:e.maxTokens,input:e.vision?[`text`,`image`]:[`text`]};return e.reasoning&&(t.reasoning=!0),t.cost={input:0,output:0,cacheRead:0,cacheWrite:0},t}));try{await Fn(d.trim(),i),R(!0),s(`save`),r(),setTimeout(()=>{t()},2e3)}catch(e){n(e instanceof Error?e.message:`Failed to save provider`)}finally{I(!1)}},[l,d,m,_,j,r,t,n]),ie=(0,G.useCallback)(()=>{s(`url`),E(void 0),w(!1)},[]);return e?(0,Z.jsx)(`div`,{className:`settings-overlay`,onClick:t,children:(0,Z.jsxs)(`div`,{className:`settings-panel`,onClick:e=>e.stopPropagation(),style:{width:640,maxWidth:`92vw`,height:`540px`},children:[(0,Z.jsxs)(`header`,{className:`settings-header`,children:[(0,Z.jsxs)(`span`,{style:{fontSize:`14px`,fontWeight:700,color:`var(--accent-text)`,display:`flex`,alignItems:`center`,gap:8},children:[o===`url`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(le,{size:16}),` Add Custom Provider`]}),o===`testing`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(c,{size:16,className:`animate-spin`}),` Testing Connection…`]}),o===`models`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(de,{size:16}),` Configure Models`]}),o===`save`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(O,{size:16}),` Provider Added`]})]}),(0,Z.jsx)(`button`,{className:`settings-close`,onClick:t,title:`Close`,children:(0,Z.jsx)(te,{size:16})})]}),(0,Z.jsx)(`div`,{className:`add-provider-steps`,children:[`url`,`models`,`save`].map((e,t)=>(0,Z.jsxs)(`div`,{className:`add-provider-step ${o===e||o===`testing`&&e===`url`?`active`:o===`models`&&e===`url`||o===`save`&&(e===`url`||e===`models`)?`done`:``}`,children:[(0,Z.jsx)(`span`,{className:`add-provider-step-num`,children:e===`url`&&o!==`save`?`1`:e===`url`?`✓`:e===`models`?`2`:`✓`}),(0,Z.jsx)(`span`,{className:`add-provider-step-label`,children:e===`url`?`Connect`:e===`models`?`Models`:`Save`}),t<2&&(0,Z.jsx)(b,{size:14,className:`add-provider-step-arrow`})]},e))}),(0,Z.jsxs)(`div`,{className:`add-provider-body`,children:[o===`url`&&(0,Z.jsxs)(`div`,{className:`add-provider-form`,children:[(0,Z.jsxs)(`div`,{className:`add-provider-presets-row`,children:[(0,Z.jsx)(`span`,{className:`add-provider-presets-label`,children:`⚡ Local Presets:`}),(0,Z.jsx)(`div`,{className:`add-provider-presets-chips`,children:Jm.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`add-provider-preset-chip ${l===e.baseUrl?`selected`:``}`,onClick:()=>{u(e.baseUrl),f(e.name),y(e.apiType??`openai-completions`),e.apiKey&&h(e.apiKey)},children:[(0,Z.jsx)(`span`,{className:`preset-name`,children:e.label}),e.port&&(0,Z.jsxs)(`span`,{className:`preset-port`,children:[`:`,e.port]})]},e.name))})]}),(0,Z.jsxs)(`div`,{className:`add-provider-field`,children:[(0,Z.jsx)(`label`,{className:`add-provider-label`,children:`Base URL`}),(0,Z.jsxs)(`div`,{className:`add-provider-input-row`,children:[(0,Z.jsx)(g,{size:14,className:`add-provider-input-icon`}),(0,Z.jsx)(`input`,{ref:z,type:`url`,value:l,onChange:e=>u(e.target.value),onKeyDown:B,placeholder:`https://api.example.com/v1`,className:`add-provider-input`,spellCheck:!1,autoComplete:`off`})]})]}),(0,Z.jsxs)(`div`,{className:`add-provider-field`,children:[(0,Z.jsx)(`label`,{className:`add-provider-label`,children:`Provider Name`}),(0,Z.jsx)(`div`,{className:`add-provider-input-row`,children:(0,Z.jsx)(`input`,{type:`text`,value:d,onChange:e=>f(e.target.value),onKeyDown:B,placeholder:`my-local-llm`,className:`add-provider-input`,spellCheck:!1,autoComplete:`off`})}),(0,Z.jsx)(`p`,{className:`add-provider-hint`,children:`Used as the identifier in models.json. Auto-suggested from URL.`})]}),(0,Z.jsxs)(`div`,{className:`add-provider-field`,children:[(0,Z.jsxs)(`label`,{className:`add-provider-label`,children:[(0,Z.jsx)(v,{size:16}),` `,a(`settings.addProvider.apiKey`)]}),(0,Z.jsxs)(`div`,{className:`add-provider-input-row`,children:[(0,Z.jsx)(v,{size:14,className:`add-provider-input-icon`}),(0,Z.jsx)(`input`,{type:x?`text`:`password`,value:m,onChange:e=>h(e.target.value),onKeyDown:B,placeholder:`sk-... or leave blank`,className:`add-provider-input`,spellCheck:!1,autoComplete:`off`}),(0,Z.jsx)(`button`,{className:`add-provider-toggle-btn`,onClick:()=>S(e=>!e),tabIndex:-1,title:x?`Hide key`:`Show key`,children:x?`Hide`:`Show`})]})]}),(0,Z.jsxs)(`div`,{className:`add-provider-field`,children:[(0,Z.jsx)(`label`,{className:`add-provider-label`,children:`API Type`}),(0,Z.jsx)(`select`,{value:_,onChange:e=>y(e.target.value),className:`add-provider-select`,children:qm.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,Z.jsx)(`p`,{className:`add-provider-hint`,children:`Most OpenAI-compatible endpoints use "OpenAI Compatible". Auto-detected when possible.`})]}),T&&!T.reachable&&(0,Z.jsxs)(`div`,{className:`add-provider-error-row`,children:[(0,Z.jsx)(p,{size:14}),(0,Z.jsx)(`span`,{children:T.error??`Connection failed`})]}),(0,Z.jsxs)(`div`,{className:`add-provider-actions`,children:[(0,Z.jsx)(`button`,{className:`add-provider-btn-primary`,disabled:!l.trim()||D,onClick:()=>void ee(),children:D?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(c,{size:16,className:`add-provider-spin`}),` `,a(`settings.addProvider.testing`)]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(A,{size:16}),` `,a(`settings.addProvider.testConnection`)]})}),(0,Z.jsx)(`button`,{className:`add-provider-btn`,onClick:t,children:`Cancel`})]})]}),o===`testing`&&(0,Z.jsxs)(`div`,{className:`add-provider-testing`,children:[(0,Z.jsx)(c,{size:32,className:`animate-spin`,style:{color:`var(--accent-text)`}}),(0,Z.jsxs)(`p`,{children:[`Testing connection to `,l,`…`]})]}),o===`models`&&(0,Z.jsxs)(`div`,{className:`add-provider-model-review`,children:[T?.reachable&&(0,Z.jsxs)(`div`,{className:`add-provider-success-banner`,children:[(0,Z.jsx)(O,{size:14}),(0,Z.jsxs)(`span`,{children:[`Connected to `,l,` — detected API: `,(0,Z.jsx)(`strong`,{children:T.detectedApiType})]})]}),j.length>0?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`add-provider-model-toolbar`,children:(0,Z.jsxs)(`label`,{className:`add-provider-checkbox-label`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:N,onChange:V,className:`add-provider-checkbox`}),N?`Deselect all`:`Select all`,` (`,j.filter(e=>e.selected).length,`/`,j.length,`)`]})}),(0,Z.jsx)(`div`,{className:`add-provider-model-list`,children:j.map(e=>(0,Z.jsxs)(`div`,{className:`add-provider-model-card ${e.selected?``:`dimmed`}`,children:[(0,Z.jsx)(`div`,{className:`add-provider-model-header`,children:(0,Z.jsxs)(`label`,{className:`add-provider-checkbox-label`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:e.selected,onChange:()=>H(e.id),className:`add-provider-checkbox`}),(0,Z.jsx)(`span`,{className:`add-provider-model-id`,children:e.id})]})}),e.selected&&(0,Z.jsxs)(`div`,{className:`add-provider-model-fields`,children:[(0,Z.jsxs)(`div`,{className:`add-provider-model-field`,children:[(0,Z.jsx)(`label`,{children:`Name`}),(0,Z.jsx)(`input`,{type:`text`,value:e.name,onChange:t=>ne(e.id,`name`,t.target.value),className:`add-provider-small-input`})]}),(0,Z.jsxs)(`div`,{className:`add-provider-model-field`,children:[(0,Z.jsx)(`div`,{className:`model-col`,style:{width:`100px`},children:a(`settings.addProvider.context`)}),(0,Z.jsxs)(`select`,{value:e.contextWindow,onChange:t=>ne(e.id,`contextWindow`,Number(t.target.value)),className:`add-provider-small-select`,children:[(0,Z.jsx)(`option`,{value:4096,children:`4K`}),(0,Z.jsx)(`option`,{value:8192,children:`8K`}),(0,Z.jsx)(`option`,{value:16384,children:`16K`}),(0,Z.jsx)(`option`,{value:32768,children:`32K`}),(0,Z.jsx)(`option`,{value:65536,children:`64K`}),(0,Z.jsx)(`option`,{value:128e3,children:`128K`}),(0,Z.jsx)(`option`,{value:2e5,children:`200K`}),(0,Z.jsx)(`option`,{value:262144,children:`256K`}),(0,Z.jsx)(`option`,{value:524288,children:`512K`}),(0,Z.jsx)(`option`,{value:1048576,children:`1M`}),(0,Z.jsx)(`option`,{value:2097152,children:`2M`})]})]}),(0,Z.jsxs)(`div`,{className:`add-provider-model-field`,children:[(0,Z.jsx)(`label`,{children:`Max tokens`}),(0,Z.jsxs)(`select`,{value:e.maxTokens,onChange:t=>ne(e.id,`maxTokens`,Number(t.target.value)),className:`add-provider-small-select`,children:[(0,Z.jsx)(`option`,{value:2048,children:`2K`}),(0,Z.jsx)(`option`,{value:4096,children:`4K`}),(0,Z.jsx)(`option`,{value:8192,children:`8K`}),(0,Z.jsx)(`option`,{value:16384,children:`16K`}),(0,Z.jsx)(`option`,{value:32768,children:`32K`}),(0,Z.jsx)(`option`,{value:65536,children:`64K`}),(0,Z.jsx)(`option`,{value:131072,children:`128K`})]})]}),(0,Z.jsxs)(`div`,{className:`add-provider-model-field`,children:[(0,Z.jsx)(`div`,{className:`model-col`,style:{width:`80px`,textAlign:`center`},children:a(`settings.addProvider.thinking`)}),(0,Z.jsxs)(`label`,{className:`add-provider-toggle-label`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:e.reasoning,onChange:t=>ne(e.id,`reasoning`,t.target.checked),className:`add-provider-checkbox`}),`Extended thinking`]})]}),(0,Z.jsxs)(`div`,{className:`add-provider-model-field`,children:[(0,Z.jsx)(`label`,{children:`Vision`}),(0,Z.jsxs)(`label`,{className:`add-provider-toggle-label`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:e.vision,onChange:t=>ne(e.id,`vision`,t.target.checked),className:`add-provider-checkbox`}),`Image input`]})]})]})]},e.id))})]}):(0,Z.jsxs)(`div`,{className:`add-provider-empty-models`,children:[T?.reachable&&T?.detectedApiType===`anthropic-messages`?(0,Z.jsx)(`p`,{children:`Anthropic does not expose a models endpoint. Add models manually below.`}):(0,Z.jsx)(`p`,{children:`No models were discovered. You can still save the provider and add models manually to models.json.`}),(0,Z.jsxs)(`div`,{className:`add-provider-manual-model`,children:[(0,Z.jsx)(`input`,{type:`text`,placeholder:`model-id (e.g. claude-sonnet-4)`,className:`add-provider-input`,id:`manual-model-id`,style:{flex:1}}),(0,Z.jsx)(`button`,{className:`add-provider-btn-primary`,onClick:()=>{let e=document.getElementById(`manual-model-id`);e?.value.trim()&&(M(t=>[...t,{id:e.value.trim(),name:e.value.trim(),contextWindow:128e3,maxTokens:4096,reasoning:!1,vision:!1,selected:!0}]),e.value=``)},style:{whiteSpace:`nowrap`},children:`Add model`})]})]}),(0,Z.jsxs)(`div`,{className:`add-provider-actions`,style:{borderTop:`1px solid var(--border)`,paddingTop:12,marginTop:8},children:[(0,Z.jsx)(`button`,{className:`add-provider-btn-primary`,disabled:F||!l.trim(),onClick:()=>void re(),children:F?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(c,{size:16,className:`add-provider-spin`}),` `,a(`settings.addProvider.saving`)]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(U,{size:16}),` `,a(`settings.addProvider.saveProvider`)]})}),(0,Z.jsxs)(`button`,{className:`add-provider-btn`,onClick:ie,children:[(0,Z.jsx)(A,{size:14}),` Retest`]}),(0,Z.jsx)(`button`,{className:`add-provider-btn`,onClick:t,children:`Cancel`})]})]}),o===`save`&&(0,Z.jsxs)(`div`,{className:`add-provider-success`,children:[(0,Z.jsx)(O,{size:48,color:`var(--accent-green)`}),(0,Z.jsx)(`h3`,{children:a(`settings.addProvider.providerAdded`)}),(0,Z.jsx)(`p`,{children:a(`settings.addProvider.providerAddedDesc`)}),(0,Z.jsx)(`p`,{className:`add-provider-hint`,children:`Reload the page or open the model picker to use the new provider.`})]})]})]})}):null}function Xm({open:e,onClose:t,title:n,children:r,width:i,initialFocusRef:a}){let o=(0,G.useRef)(null),s=(0,G.useId)(),c=(0,G.useRef)(t),l=(0,G.useRef)(a);return(0,G.useEffect)(()=>{c.current=t}),(0,G.useEffect)(()=>{l.current=a}),(0,G.useEffect)(()=>{if(!e)return;let t=document.activeElement,n=o.current,r=e=>{if(e.key===`Escape`){e.preventDefault(),c.current();return}if(e.key===`Tab`&&o.current!==null){let t=o.current.querySelectorAll(`a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])`);if(t.length===0)return;let n=t[0],r=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())}};document.addEventListener(`keydown`,r);let i=window.setTimeout(()=>{let e=l.current?.current;if(e!=null){e.focus();return}(o.current?.querySelector(`a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])`))?.focus()},0);return()=>{document.removeEventListener(`keydown`,r),window.clearTimeout(i),t!==null&&document.contains(t)&&n!==null&&n.contains(document.activeElement)&&t.focus()}},[e]),e?(0,Z.jsx)(`div`,{className:`modal-overlay`,onClick:t,role:`dialog`,"aria-modal":`true`,"aria-labelledby":s,children:(0,Z.jsxs)(`div`,{ref:o,className:`modal-dialog`,style:i===void 0?void 0:{maxWidth:i},onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(`header`,{className:`modal-header`,children:[(0,Z.jsx)(`h2`,{id:s,className:`modal-title`,children:n}),(0,Z.jsx)(`button`,{onClick:t,className:`modal-close-btn`,title:`Close (Esc)`,"aria-label":`Close`,children:(0,Z.jsx)(te,{size:18})})]}),r]})}):null}function Zm({open:e,onClose:t,onConfirm:n,title:r,message:i,primaryLabel:a=`Confirm`,tone:o=`default`}){return(0,Z.jsx)(Xm,{open:e,onClose:t,title:r,children:(0,Z.jsxs)(`div`,{className:`modal-body`,children:[(0,Z.jsx)(`p`,{className:`confirm-message`,children:i}),(0,Z.jsxs)(`footer`,{className:`confirm-footer`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:t,className:`confirm-btn-cancel`,children:`Cancel`}),(0,Z.jsx)(`button`,{type:`button`,onClick:n,className:o===`danger`?`confirm-btn-danger`:`confirm-btn-primary`,children:a})]})]})})}var Qm=[`low`,`medium`,`high`],$m={low:`#22c55e`,medium:`#eab308`,high:`#ef4444`};function eh({value:e,onChange:t}){let{t:n}=qo(),r=e??{},i=(e,n)=>{let i={...r};n===`omit`?delete i[e]:i[e]=n,t(Object.keys(i).length?i:void 0)};return(0,Z.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:Qm.map(e=>{let t=r[e],a=e in r?t===null?`null`:`string`:`omit`,o=typeof t==`string`?t:``,s={padding:`4px 10px`,fontSize:10,border:`none`,cursor:`pointer`,fontWeight:400,background:`var(--bg-glass)`,color:`var(--text-dim)`,transition:`background 0.1s, color 0.1s`,whiteSpace:`nowrap`},c={background:`var(--accent)`,color:`#fff`,fontWeight:600},l={background:`#ef4444`,color:`#fff`,fontWeight:600};return(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`4px 0`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:5,width:64,flexShrink:0},children:[(0,Z.jsx)(`span`,{style:{width:6,height:6,borderRadius:`50%`,background:$m[e],flexShrink:0,opacity:a===`null`?.3:1}}),(0,Z.jsx)(`span`,{style:{fontSize:11,fontFamily:`var(--font-mono, monospace)`,color:a===`null`?`var(--text-dim)`:`var(--text-secondary)`,textDecoration:a===`null`?`line-through`:`none`},children:e})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,borderRadius:5,border:`1px solid var(--border)`,overflow:`hidden`},children:[(0,Z.jsx)(`button`,{onClick:()=>i(e,`omit`),style:{...s,borderRight:`1px solid var(--border)`,...a===`omit`?c:{}},children:n(`settings.providers.model.default`)}),(0,Z.jsx)(`button`,{onClick:()=>i(e,null),style:{...s,...a===`null`?l:{}},children:n(`settings.providers.model.disabled`)})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,borderRadius:5,border:`1px solid ${a===`string`?`var(--accent)`:`var(--border)`}`,overflow:`hidden`},children:[(0,Z.jsx)(`button`,{onClick:()=>i(e,o||e),style:{...s,borderRight:`1px solid var(--border)`,...a===`string`?c:{}},children:n(`settings.providers.model.custom`)}),(0,Z.jsx)(`input`,{value:o,onChange:t=>i(e,t.target.value),onFocus:()=>{a!==`string`&&i(e,o||e)},placeholder:e,maxLength:10,style:{width:`12ch`,outline:`none`,border:`none`,padding:`4px 7px`,background:a===`string`?`var(--bg-solid)`:`var(--bg-glass)`,color:a===`string`?`var(--text-primary)`:`var(--text-dim)`,fontFamily:`var(--font-mono, monospace)`,fontSize:11}})]})]},e)})})}var th={thinkingFormat:`deepseek`,requiresReasoningContentOnAssistantMessages:!0};function nh(e){return e.compat?.thinkingFormat===`deepseek`}function rh(e,t){if(t)return{...e,compat:{...e.compat??{},...th}};if(!e.compat)return e;let n={...e.compat};return delete n.thinkingFormat,delete n.requiresReasoningContentOnAssistantMessages,{...e,compat:Object.keys(n).length?n:void 0}}var ih={padding:`6px 9px`,background:`var(--bg-glass)`,border:`1px solid var(--border)`,borderRadius:5,color:`var(--text-primary)`,fontSize:12,outline:`none`,width:`100%`,boxSizing:`border-box`,fontFamily:`var(--font-mono, monospace)`};function ah({model:e,onChange:t,onDelete:n}){let{t:r}=qo(),i=(n,r)=>t({...e,[n]:r}),a=t=>e.cost?.[t]===void 0?``:String(e.cost[t]),o=(n,r)=>{let i=parseFloat(r);t({...e,cost:{...e.cost??{},[n]:isNaN(i)?void 0:i}})};return(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12,padding:`12px 0 8px`},children:[(0,Z.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:10},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:3},children:[(0,Z.jsx)(`label`,{style:{fontSize:11,color:`var(--text-secondary)`,fontWeight:500},children:r(`settings.providers.model.id`)}),(0,Z.jsx)(`input`,{value:e.id,onChange:e=>i(`id`,e.target.value),placeholder:r(`settings.providers.model.idPlaceholder`),style:ih})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:3},children:[(0,Z.jsx)(`label`,{style:{fontSize:11,color:`var(--text-secondary)`,fontWeight:500},children:r(`settings.providers.model.name`)}),(0,Z.jsx)(`input`,{value:e.name??``,onChange:e=>i(`name`,e.target.value||void 0),placeholder:r(`settings.providers.model.namePlaceholder`),style:ih})]})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:3},children:[(0,Z.jsx)(`label`,{style:{fontSize:11,color:`var(--text-secondary)`,fontWeight:500},children:r(`settings.providers.model.apiOverride`)}),(0,Z.jsxs)(`select`,{value:e.api??``,onChange:e=>i(`api`,e.target.value||void 0),style:{...ih,cursor:`pointer`},children:[(0,Z.jsx)(`option`,{value:``,children:r(`settings.providers.model.apiDefault`)}),(0,Z.jsx)(`option`,{value:`openai-completions`,children:r(`settings.providers.model.apiOpenAiCompat`)}),(0,Z.jsx)(`option`,{value:`openai-responses`,children:r(`settings.providers.model.apiOpenAiResponses`)}),(0,Z.jsx)(`option`,{value:`anthropic-messages`,children:r(`settings.providers.model.apiAnthropic`)}),(0,Z.jsx)(`option`,{value:`google-generative-ai`,children:r(`settings.providers.model.apiGoogle`)})]})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:20,flexWrap:`wrap`},children:[(0,Z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,fontSize:12,color:`var(--text-primary)`,cursor:`pointer`,userSelect:`none`},children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:e.reasoning??!1,onChange:e=>i(`reasoning`,e.target.checked||void 0),style:{accentColor:`var(--accent-text)`}}),r(`settings.providers.model.reasoning`)]}),(0,Z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,fontSize:12,color:`var(--text-primary)`,cursor:`pointer`,userSelect:`none`},children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:e.input?.includes(`image`)??!1,onChange:e=>i(`input`,e.target.checked?[`text`,`image`]:void 0),style:{accentColor:`var(--accent-text)`}}),r(`settings.providers.model.imageInput`)]})]}),e.reasoning&&(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8,padding:`8px 10px`,borderRadius:6,background:`var(--bg-glass)`,border:`1px solid var(--border)`},children:[(0,Z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,fontSize:12,color:`var(--text-primary)`,cursor:`pointer`,userSelect:`none`},children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:nh(e),onChange:n=>t(rh(e,n.target.checked)),style:{accentColor:`var(--accent-text)`}}),r(`settings.providers.model.deepSeekCompat`)]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:6},children:[(0,Z.jsx)(`span`,{style:{fontSize:11,fontWeight:600,color:`var(--text-secondary)`},children:r(`settings.providers.model.thinkingLevelMap`)}),e.thinkingLevelMap&&(0,Z.jsx)(`button`,{onClick:()=>i(`thinkingLevelMap`,void 0),style:{fontSize:10,padding:`2px 7px`,background:`none`,border:`1px solid var(--border)`,borderRadius:4,color:`var(--text-dim)`,cursor:`pointer`},children:r(`settings.providers.model.clearAll`)})]}),(0,Z.jsx)(eh,{value:e.thinkingLevelMap,onChange:e=>i(`thinkingLevelMap`,e)})]})]}),(0,Z.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:10},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:3},children:[(0,Z.jsx)(`label`,{style:{fontSize:11,color:`var(--text-secondary)`,fontWeight:500},children:r(`settings.providers.model.contextWindow`)}),(0,Z.jsx)(`input`,{value:e.contextWindow===void 0?``:String(e.contextWindow),onChange:e=>i(`contextWindow`,e.target.value?parseInt(e.target.value):void 0),placeholder:`128000`,style:ih})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:3},children:[(0,Z.jsx)(`label`,{style:{fontSize:11,color:`var(--text-secondary)`,fontWeight:500},children:r(`settings.providers.model.maxTokens`)}),(0,Z.jsx)(`input`,{value:e.maxTokens===void 0?``:String(e.maxTokens),onChange:e=>i(`maxTokens`,e.target.value?parseInt(e.target.value):void 0),placeholder:`16384`,style:ih})]})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{style:{fontSize:11,fontWeight:600,color:`var(--text-secondary)`,marginBottom:6},children:r(`settings.providers.model.cost`)}),(0,Z.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr 1fr 1fr`,gap:8},children:[`input`,`output`,`cacheRead`,`cacheWrite`].map(e=>(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:3},children:[(0,Z.jsx)(`label`,{style:{fontSize:10,color:`var(--text-dim)`},children:e}),(0,Z.jsx)(`input`,{value:a(e),onChange:t=>o(e,t.target.value),placeholder:`0`,style:ih})]},e))})]}),(0,Z.jsx)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8,borderTop:`1px solid var(--border)`,paddingTop:10},children:(0,Z.jsx)(`button`,{onClick:n,style:{padding:`6px 12px`,background:`none`,border:`1px solid rgba(239,68,68,0.3)`,borderRadius:5,color:`#ef4444`,cursor:`pointer`,fontSize:12},children:r(`settings.providers.model.removeModel`)})})]})}function oh({onError:e}){let{t}=qo(),[n,i]=(0,G.useState)(void 0),[a,o]=(0,G.useState)(void 0),[s,c]=(0,G.useState)(!1),[l,d]=(0,G.useState)(null),[f,p]=(0,G.useState)(new Set),[m,h]=(0,G.useState)(void 0),[g,_]=(0,G.useState)(void 0),[y,b]=(0,G.useState)(void 0),[x,S]=(0,G.useState)(void 0),[C,w]=(0,G.useState)(``),[E,D]=(0,G.useState)(!1),[O,k]=(0,G.useState)(!1),[j,M]=(0,G.useState)(void 0),[N,F]=(0,G.useState)(void 0),[I,L]=(0,G.useState)(``),[R,z]=(0,G.useState)(`all`),[ee,B]=(0,G.useState)(new Set),V=async()=>{e(void 0);try{let[e,t,n]=await Promise.all([wn(),Tn(),Mn()]);i(e),o(t);let r=new Set(Object.keys(n.providers));p(r),h(n)}catch(t){e(`Failed to load providers: ${Pm(t)}`)}};(0,G.useEffect)(()=>{V()},[]);let H=async t=>{if(C.trim().length!==0){D(!0);try{await En(t,C.trim()),S(void 0),w(``),await V()}catch(t){e(`Save key failed: ${Pm(t)}`)}finally{D(!1)}}},U=async t=>{if(confirm(`Remove the stored key for "${t}"?`)){D(!0);try{await Dn(t),await V()}catch(t){e(`Remove key failed: ${Pm(t)}`)}finally{D(!1)}}},ne=async()=>{if(j!==void 0){D(!0);try{await Nn(JSON.parse(j)),F(Date.now()),await V()}catch{e(`models.json: invalid JSON`)}finally{D(!1)}}},re=async()=>{try{let e=await Mn();M(JSON.stringify(e,null,2))}catch(t){e(`Load models.json failed: ${Pm(t)}`)}},[ae,se]=(0,G.useState)(void 0),le=async t=>{let n=m?.providers[t];if(!n||!n.baseUrl){e(`Cannot sync ${t}: No baseUrl configured in models.json`);return}se(t),e(void 0);try{let r=await Pn({baseUrl:n.baseUrl,apiKey:n.apiKey,apiType:n.api});if(!r.reachable){e(`Could not reach ${t} on ${n.baseUrl}. Is the runner running?`);return}if(!r.models||r.models.length===0){e(`${t} responded but returned 0 models.`);return}let i=Array.isArray(n.models)?n.models:[],a=new Map(i.map(e=>[e.id,e])),o=[...i];for(let e of r.models)a.has(e.id)||o.push({id:e.id,name:e.name??e.id});await Fn(t,{...n,models:o}),await V(),B(e=>new Set(e).add(t))}catch(n){e(`Failed to sync models for ${t}: ${Pm(n)}`)}finally{se(void 0)}},ue=e=>{B(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},de=(0,G.useMemo)(()=>!n||!a?0:n.providers.filter(e=>a.providers[e.provider]?.configured).length,[n,a]),pe=(0,G.useMemo)(()=>{if(!n)return[];let e=I.trim().toLowerCase();return n.providers.filter(t=>{let n=a?.providers[t.provider]?.configured===!0,r=f.has(t.provider);return R===`configured`&&!n||R===`custom`&&!r||R===`missing`&&n?!1:!!(!e||t.provider.toLowerCase().includes(e)||t.models.some(t=>t.id.toLowerCase().includes(e)||t.name&&t.name.toLowerCase().includes(e)))})},[n,a,f,R,I]);return n===void 0?(0,Z.jsx)(`p`,{className:`settings-hint`,children:t(`settings.providers.loading`)}):(0,Z.jsxs)(`div`,{className:`providers-tab-container`,children:[(0,Z.jsxs)(`div`,{className:`providers-header-toolbar`,children:[(0,Z.jsxs)(`div`,{className:`providers-header-top-row`,children:[(0,Z.jsxs)(`div`,{className:`providers-header-title-wrap`,children:[(0,Z.jsx)(`span`,{className:`providers-main-title`,children:`Providers`}),(0,Z.jsxs)(`div`,{className:`providers-title-badges`,children:[(0,Z.jsxs)(`span`,{className:`providers-count-pill`,children:[n.providers.length,` total`]}),(0,Z.jsxs)(`span`,{className:`providers-count-pill configured`,children:[de,` configured`]}),f.size>0&&(0,Z.jsxs)(`span`,{className:`providers-count-pill custom`,children:[f.size,` custom`]})]})]}),(0,Z.jsxs)(`div`,{className:`providers-header-actions`,children:[(0,Z.jsxs)(`button`,{onClick:()=>{d(null),c(!0)},className:`settings-btn settings-btn-primary`,title:`Add a custom or local provider`,children:[(0,Z.jsx)(fe,{size:13}),(0,Z.jsx)(`span`,{className:`providers-btn-label-desktop`,children:t(`settings.providers.addCustom`).replace(/^\+\s*/,``)}),(0,Z.jsx)(`span`,{className:`providers-btn-label-mobile`,children:`Add`})]}),(0,Z.jsxs)(`button`,{onClick:()=>{O?k(!1):(k(!0),j===void 0&&re())},className:`settings-btn ${O?`settings-btn-active`:``}`,title:`Edit models.json configuration directly`,children:[(0,Z.jsx)(u,{size:13}),(0,Z.jsx)(`span`,{className:`providers-btn-label-desktop`,children:`models.json`}),(0,Z.jsx)(`span`,{className:`providers-btn-label-mobile`,children:`JSON`})]}),(0,Z.jsx)(`button`,{onClick:()=>void V(),disabled:E,className:`settings-btn settings-btn-icon`,title:`Refresh providers and status`,children:(0,Z.jsx)(A,{size:13,className:E?`animate-spin`:``})})]})]}),(0,Z.jsx)(`p`,{className:`providers-header-sub`,children:t(`settings.providers.description`)})]}),(0,Z.jsxs)(`div`,{className:`providers-quick-local-banner`,children:[(0,Z.jsxs)(`div`,{className:`quick-local-banner-left`,children:[(0,Z.jsx)(P,{size:14,className:`quick-local-icon`}),(0,Z.jsxs)(`div`,{className:`quick-local-text`,children:[(0,Z.jsx)(`span`,{className:`quick-local-label`,children:`Quick Add Local:`}),(0,Z.jsx)(`span`,{className:`quick-local-sub`,children:`One-click connect to local runners`})]})]}),(0,Z.jsx)(`div`,{className:`quick-local-chips`,children:Jm.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`quick-local-chip`,onClick:()=>{d(e),c(!0)},title:`Connect to local ${e.label} on ${e.baseUrl}`,children:[(0,Z.jsx)(`span`,{className:`chip-name`,children:e.label}),e.port&&(0,Z.jsxs)(`span`,{className:`chip-port`,children:[`:`,e.port]})]},e.name))})]}),(0,Z.jsxs)(`div`,{className:`providers-filter-bar`,children:[(0,Z.jsxs)(`div`,{className:`providers-search-wrapper`,children:[(0,Z.jsx)(ie,{size:13,className:`providers-search-icon`}),(0,Z.jsx)(`input`,{type:`search`,value:I,onChange:e=>L(e.target.value),placeholder:`Search providers or models…`,className:`providers-search-input`}),I&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>L(``),className:`providers-search-clear`,title:`Clear search`,children:(0,Z.jsx)(te,{size:12})})]}),(0,Z.jsxs)(`div`,{className:`providers-filter-tabs`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`providers-filter-tab ${R===`all`?`active`:``}`,onClick:()=>z(`all`),children:[`All (`,n.providers.length,`)`]}),(0,Z.jsxs)(`button`,{type:`button`,className:`providers-filter-tab ${R===`configured`?`active`:``}`,onClick:()=>z(`configured`),children:[`Configured (`,de,`)`]}),f.size>0&&(0,Z.jsxs)(`button`,{type:`button`,className:`providers-filter-tab ${R===`custom`?`active`:``}`,onClick:()=>z(`custom`),children:[`Custom (`,f.size,`)`]}),(0,Z.jsxs)(`button`,{type:`button`,className:`providers-filter-tab ${R===`missing`?`active`:``}`,onClick:()=>z(`missing`),children:[`No Key (`,n.providers.length-de,`)`]})]})]}),O&&j!==void 0&&(0,Z.jsxs)(`div`,{className:`settings-raw-json-panel`,children:[(0,Z.jsxs)(`div`,{className:`settings-json-header`,children:[(0,Z.jsxs)(`span`,{className:`settings-json-title`,children:[(0,Z.jsx)(u,{size:13}),(0,Z.jsx)(`span`,{children:`models.json Raw Editor`})]}),(0,Z.jsxs)(`div`,{className:`settings-json-actions`,children:[N!==void 0&&(0,Z.jsx)(`span`,{className:`settings-json-flash`,children:t(`settings.agent.saved`)}),(0,Z.jsx)(`button`,{onClick:()=>void re(),disabled:E,className:`settings-btn settings-btn-xs`,children:t(`settings.providers.reload`)}),(0,Z.jsx)(`button`,{onClick:()=>void ne(),disabled:E,className:`settings-btn settings-btn-primary settings-btn-xs`,children:t(E?`settings.providers.saving`:`settings.providers.save`)}),(0,Z.jsx)(`button`,{onClick:()=>k(!1),className:`settings-btn settings-btn-xs`,children:`Close`})]})]}),(0,Z.jsx)(`textarea`,{value:j,onChange:e=>M(e.target.value),spellCheck:!1,rows:12,className:`settings-textarea`})]}),pe.length===0?(0,Z.jsx)(`div`,{className:`providers-empty-state`,children:(0,Z.jsx)(`p`,{className:`settings-hint italic`,children:I?`No providers match "${I}"`:t(`settings.providers.noProviders`)})}):(0,Z.jsx)(`div`,{className:`providers-card-list`,children:pe.map(n=>{let i=a?.providers[n.provider],o=i?.configured===!0,s=x===n.provider,c=f.has(n.provider),l=ee.has(n.provider);return(0,Z.jsxs)(`div`,{className:`provider-card`,children:[(0,Z.jsxs)(`div`,{className:`provider-card-header`,children:[(0,Z.jsxs)(`div`,{className:`provider-card-main-info`,children:[(0,Z.jsx)(`div`,{className:`provider-avatar ${c?`custom`:o?`configured`:`unconfigured`}`,children:c?(0,Z.jsx)(P,{size:14}):o?(0,Z.jsx)(T,{size:14}):(0,Z.jsx)(ce,{size:14})}),(0,Z.jsxs)(`div`,{className:`provider-text-meta`,children:[(0,Z.jsxs)(`div`,{className:`provider-name-row`,children:[(0,Z.jsx)(`span`,{className:`provider-name`,children:n.provider}),c&&(0,Z.jsx)(`span`,{className:`provider-badge-custom`,title:`Custom provider defined in models.json`,children:`models.json`}),i?.source!==void 0&&(0,Z.jsxs)(`span`,{className:`provider-source-tag`,children:[`via `,i.source]})]}),(0,Z.jsxs)(`div`,{className:`provider-sub-row`,children:[(0,Z.jsxs)(`span`,{className:`provider-status-badge ${o?`online`:`offline`}`,children:[(0,Z.jsx)(`span`,{className:`status-dot`}),(0,Z.jsx)(`span`,{children:t(o?`settings.providers.keySet`:`settings.providers.noKey`)})]}),(0,Z.jsx)(`span`,{className:`provider-meta-divider`,children:`•`}),(0,Z.jsxs)(`button`,{type:`button`,className:`provider-models-count-btn`,onClick:()=>ue(n.provider),children:[n.models.length,` `,n.models.length===1?`model`:t(`settings.providers.modelsCount`),(0,Z.jsx)(r,{size:11,className:`count-chevron ${l?`open`:``}`})]})]})]})]}),(0,Z.jsxs)(`div`,{className:`provider-card-actions`,children:[!s&&(0,Z.jsxs)(`button`,{onClick:()=>{S(n.provider),w(``)},className:`settings-btn ${o?`settings-btn-subtle`:`settings-btn-primary`}`,title:t(o?`settings.providers.replaceKey`:`settings.providers.addKey`),children:[(0,Z.jsx)(v,{size:12}),(0,Z.jsx)(`span`,{className:`providers-btn-label-desktop`,children:t(o?`settings.providers.replaceKey`:`settings.providers.addKey`)}),(0,Z.jsx)(`span`,{className:`providers-btn-label-mobile`,children:o?`Key`:`+ Key`})]}),o&&!s&&(0,Z.jsx)(`button`,{onClick:()=>void U(n.provider),disabled:E,className:`settings-btn-icon danger`,title:t(`settings.providers.remove`),children:(0,Z.jsx)(te,{size:13})}),c&&!s&&(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>void le(n.provider),disabled:E||ae===n.provider,className:`settings-btn settings-btn-subtle settings-btn-xs`,title:`Probe and sync models currently loaded in this runner`,children:[(0,Z.jsx)(A,{size:11,className:ae===n.provider?`animate-spin`:``}),(0,Z.jsx)(`span`,{children:`Sync`})]}),c&&!s&&(0,Z.jsx)(`button`,{onClick:()=>b(n.provider),disabled:E,className:`settings-btn-icon danger`,title:t(`settings.providers.removeFromModels`),children:(0,Z.jsx)(oe,{size:13})})]})]}),s&&(0,Z.jsx)(`div`,{className:`provider-key-editor`,children:(0,Z.jsxs)(`div`,{className:`provider-key-input-row`,children:[(0,Z.jsx)(v,{size:13,className:`provider-key-icon`}),(0,Z.jsx)(`input`,{type:`password`,value:C,onChange:e=>w(e.target.value),placeholder:t(`settings.providers.pasteKey`),autoFocus:!0,className:`provider-key-input`,onKeyDown:e=>{e.key===`Enter`&&H(n.provider),e.key===`Escape`&&(S(void 0),w(``))}}),(0,Z.jsx)(`button`,{onClick:()=>void H(n.provider),disabled:E||C.trim().length===0,className:`settings-btn settings-btn-primary`,children:t(E?`settings.providers.saving`:`settings.providers.save`)}),(0,Z.jsx)(`button`,{onClick:()=>{S(void 0),w(``)},className:`settings-btn`,children:t(`settings.providers.cancel`)})]})}),l&&(0,Z.jsxs)(`div`,{className:`provider-models-drawer`,children:[(0,Z.jsxs)(`div`,{className:`models-drawer-header`,children:[(0,Z.jsxs)(`span`,{children:[`Available Models (`,n.models.length,`)`]}),c&&(0,Z.jsx)(`span`,{className:`models-custom-note`,children:`Click a model to edit configuration`})]}),(0,Z.jsx)(`ul`,{className:`settings-model-list`,children:n.models.map((r,i)=>(0,Z.jsx)(`li`,{className:`settings-model-item`,style:{cursor:c?`pointer`:void 0},children:g?.provider===n.provider&&g?.index===i&&m?(0,Z.jsxs)(`div`,{style:{width:`100%`},children:[(0,Z.jsx)(ah,{model:m.providers[n.provider]?.models?.[i]??{id:r.id,name:r.name},onChange:e=>{h(t=>{if(!t)return t;let r={...t.providers[n.provider]??{}},a=[...r.models??[]];return a[i]=e,r.models=a,{...t,providers:{...t.providers,[n.provider]:r}}})},onDelete:()=>{_(void 0),h(e=>{if(!e)return e;let t={...e.providers[n.provider]??{}},r=[...t.models??[]];return r.splice(i,1),t.models=r.length?r:void 0,{...e,providers:{...e.providers,[n.provider]:t}}})}}),(0,Z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8,marginTop:8},children:[(0,Z.jsx)(`button`,{onClick:()=>_(void 0),className:`settings-btn`,children:t(`settings.providers.cancel`)}),(0,Z.jsx)(`button`,{onClick:async()=>{if(m){D(!0);try{await Nn(m),_(void 0),F(Date.now()),await V()}catch(t){e(`Save failed: ${Pm(t)}`)}finally{D(!1)}}},className:`settings-btn settings-btn-primary`,disabled:E,children:t(E?`settings.providers.saving`:`settings.providers.save`)})]})]}):(0,Z.jsxs)(`div`,{onClick:()=>{c&&_({provider:n.provider,index:i})},className:`model-item-row`,children:[(0,Z.jsxs)(`div`,{className:`model-item-name-col`,children:[(0,Z.jsx)(`span`,{className:`model-item-name ${r.hasAuth?``:`text-dim`}`,children:r.name||r.id}),r.name&&r.name!==r.id&&(0,Z.jsx)(`span`,{className:`model-item-id`,children:r.id})]}),(0,Z.jsxs)(`span`,{className:`model-item-ctx`,children:[`ctx `,Math.round(r.contextWindow/1e3),`k`]})]})},r.id))})]})]},n.provider)})}),(0,Z.jsx)(Ym,{open:s,initialPreset:l,onClose:()=>{c(!1),d(null),V()},onError:e,onSaved:()=>{V()}}),(0,Z.jsx)(Zm,{open:y!==void 0,onClose:()=>b(void 0),onConfirm:async()=>{let t=y;if(b(void 0),t!==void 0){D(!0);try{await In(t),await V()}catch(t){e(`Remove failed: ${Pm(t)}`)}finally{D(!1)}}},title:t(`settings.providers.deleteProvider`),message:t(`settings.providers.deleteProviderConfirm`),primaryLabel:t(`settings.providers.delete`),tone:`danger`})]})}function sh({onError:e}){let{t}=qo(),[n,r]=(0,G.useState)(void 0),[i,a]=(0,G.useState)(void 0),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(``),[u,d]=(0,G.useState)(``),[f,p]=(0,G.useState)(``),[m,h]=(0,G.useState)(``),[g,_]=(0,G.useState)(null),[v,b]=(0,G.useState)(!1),[x,S]=(0,G.useState)(null),[C,w]=(0,G.useState)(!1),[T,E]=(0,G.useState)(``),D=async()=>{e(void 0);try{let[e,t,n]=await Promise.all([On(),wn(),Ln()]);r(e),a(t);let i=n.enabledModels;_(i),b(i!==null&&!(Array.isArray(i)&&i.length===0)),S(i);let o=typeof e.defaultProvider==`string`?e.defaultProvider:``,s=typeof e.defaultModel==`string`?e.defaultModel:``;l(o),d(s),p(typeof e.orchProvider==`string`?e.orchProvider:``),h(typeof e.orchModel==`string`?e.orchModel:``)}catch(t){e(`Failed to load settings: ${Pm(t)}`)}};(0,G.useEffect)(()=>{D()},[]);let O=async t=>{s(!0);try{let e=await kn(t);r(e)}catch(t){e(`Save failed: ${Pm(t)}`)}finally{s(!1)}},k=(0,G.useMemo)(()=>{if(i)return!v||g===null||g.length===0?i:{providers:i.providers.map(e=>({...e,models:e.models.filter(t=>g.includes(`${e.provider}/${t.id}`))})).filter(e=>e.models.length>0)}},[i,v,g]),A=v?k:i,j=A?A.providers.map(e=>({value:e.provider,label:e.provider})):[],M=A?.providers.find(e=>e.provider===c),N=M?M.models.map(e=>({value:e.id,label:e.name})):[],P=A?.providers.find(e=>e.provider===f),F=P?P.models.map(e=>({value:e.id,label:e.name})):[],I=e=>{l(e),(A?.providers.find(t=>t.provider===e))?.models.some(e=>e.id===u)||d(``),O({defaultProvider:e.length===0?null:e})},L=e=>{d(e),O({defaultModel:e.length===0?null:e})},R=e=>{p(e),(A?.providers.find(t=>t.provider===e))?.models.some(e=>e.id===m)||h(``),O({orchProvider:e.length===0?null:e})},z=e=>{h(e),O({orchModel:e.length===0?null:e})},ee=async t=>{s(!0);try{await Rn(t),_(t),b(t!==null&&!(Array.isArray(t)&&t.length===0)),S(t)}catch(t){e(`Save scope failed: ${Pm(t)}`)}finally{s(!1)}},B=async e=>{if(e){let e=i?i.providers.flatMap(e=>e.models.map(t=>`${e.provider}/${t.id}`)):[];S(x??e),b(!0),w(!0)}else w(!1),await ee(null)},V=(0,G.useMemo)(()=>i?i.providers.flatMap(e=>e.models.filter(e=>e.hasAuth).map(t=>({fullId:`${e.provider}/${t.id}`,provider:e.provider,modelName:t.name,modelId:t.id,hasAuth:t.hasAuth}))):[],[i]),U=(0,G.useMemo)(()=>{if(!T)return V;let e=T.toLowerCase();return V.filter(t=>t.fullId.toLowerCase().includes(e)||t.modelName.toLowerCase().includes(e)||t.provider.toLowerCase().includes(e))},[V,T]),ne=e=>{let t=x??V.map(e=>e.fullId),n=t.includes(e)?t.filter(t=>t!==e):[...t,e],r=V.length,i=n.length===r;S(i?null:n)},re=async()=>{await ee(x)};return n===void 0?(0,Z.jsx)(`p`,{className:`settings-hint`,children:t(`settings.agent.loading`)}):(0,Z.jsxs)(`div`,{className:`settings-fields`,children:[(0,Z.jsxs)(Lm,{icon:(0,Z.jsx)(ue,{size:15}),title:`Primary Model & Reasoning`,subtitle:`Default model configuration and reasoning effort for new chats`,children:[(0,Z.jsx)(Im,{label:t(`settings.agent.defaultProvider`),hint:t(`settings.agent.defaultProviderHint`),children:(0,Z.jsxs)(`select`,{value:c,disabled:o,onChange:e=>I(e.target.value),className:`settings-select`,children:[(0,Z.jsx)(`option`,{value:``,children:`(none)`}),j.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value))]})}),(0,Z.jsx)(Rm,{}),(0,Z.jsx)(Im,{label:t(`settings.agent.defaultModel`),hint:t(`settings.agent.defaultModelHint`),children:(0,Z.jsxs)(`select`,{value:u,disabled:o||c.length===0,onChange:e=>L(e.target.value),className:`settings-select`,children:[(0,Z.jsx)(`option`,{value:``,children:`(none)`}),N.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value))]})}),(0,Z.jsx)(Rm,{}),(0,Z.jsx)(Im,{label:t(`settings.agent.thinkingLevel`),hint:t(`settings.agent.thinkingLevelHint`),children:(0,Z.jsx)(ch,{value:n&&typeof n.defaultThinkingLevel==`string`?n.defaultThinkingLevel:``,options:[``,`off`,`minimal`,`low`,`medium`,`high`,`xhigh`],onSave:e=>O({defaultThinkingLevel:e.length===0?null:e}),disabled:o})})]}),(0,Z.jsxs)(Lm,{icon:(0,Z.jsx)(y,{size:15}),title:t(`settings.agent.modelScope`),subtitle:`Filter which models appear in dropdown selectors across the app`,action:v&&!C?(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>w(!0),className:`settings-btn settings-btn-xs`,children:[(0,Z.jsx)(H,{size:11}),(0,Z.jsx)(`span`,{children:t(`settings.agent.selectModels`)})]}):void 0,children:[(0,Z.jsx)(Im,{label:t(`settings.agent.hideUnusedModels`),hint:`Only display ticked models in new session and chat model pickers`,children:(0,Z.jsx)(Fm,{checked:v,onChange:e=>void B(e),ariaLabel:t(`settings.agent.hideUnusedModels`)})}),v&&!C&&(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`10px 12px`,borderRadius:`var(--radius-sm)`,background:`var(--bg-glass-strong)`,border:`1px solid var(--border)`,marginTop:4},children:[(0,Z.jsx)(`span`,{style:{fontSize:12,color:`var(--text-secondary)`},children:x===null?t(`settings.agent.allModelsVisible`):t(`settings.agent.modelsSelected`).replace(`{n}`,String(x.length)).replace(`{m}`,String(V.length))}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>w(!0),className:`settings-btn settings-btn-xs`,children:[(0,Z.jsx)(H,{size:11}),(0,Z.jsx)(`span`,{children:t(`settings.agent.selectModels`)})]})]}),v&&C&&(0,Z.jsxs)(`div`,{className:`scope-picker-section`,style:{marginTop:6,padding:12,borderRadius:`var(--radius-sm)`,background:`var(--bg-glass-strong)`,border:`1px solid var(--border)`},children:[(0,Z.jsxs)(`div`,{className:`providers-search-wrapper`,style:{marginBottom:10},children:[(0,Z.jsx)(ie,{size:13,className:`providers-search-icon`}),(0,Z.jsx)(`input`,{type:`search`,value:T,onChange:e=>E(e.target.value),placeholder:t(`settings.agent.searchModels`),className:`providers-search-input`,autoFocus:!0}),T&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>E(``),className:`providers-search-clear`,children:(0,Z.jsx)(te,{size:12})})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:12,marginBottom:8,padding:`0 2px`},children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>S(null),style:{background:`none`,border:`none`,color:`var(--accent-text)`,fontSize:12,cursor:`pointer`,padding:0,fontWeight:500},children:t(`settings.agent.selectAll`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>S([]),style:{background:`none`,border:`none`,color:`var(--accent-text)`,fontSize:12,cursor:`pointer`,padding:0,fontWeight:500},children:t(`settings.agent.untickAll`)})]}),(0,Z.jsxs)(`div`,{className:`scope-model-list`,style:{maxHeight:240,overflowY:`auto`,border:`1px solid var(--border)`,borderRadius:`var(--radius-sm)`,padding:`6px 10px`,background:`var(--bg-glass)`},children:[U.map(e=>{let n=(x??V.map(e=>e.fullId)).includes(e.fullId);return(0,Z.jsxs)(`label`,{className:`scope-model-item`,style:{display:`flex`,alignItems:`center`,gap:8,cursor:`pointer`,padding:`6px 0`,fontSize:13,userSelect:`none`,borderBottom:`1px solid var(--border-subtle, rgba(255,255,255,0.04))`},children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>ne(e.fullId),style:{width:15,height:15,accentColor:`var(--accent)`,cursor:`pointer`,flexShrink:0}}),(0,Z.jsxs)(`span`,{style:{fontFamily:`var(--font-mono, monospace)`,fontSize:11,color:`var(--text-dim)`},children:[e.provider,`/`]}),(0,Z.jsx)(`span`,{style:{fontSize:12,fontWeight:n?500:400,color:`var(--text-primary)`},children:e.modelName}),!e.hasAuth&&(0,Z.jsx)(`span`,{className:`settings-badge settings-badge-off`,style:{marginLeft:`auto`},children:t(`settings.providers.noKey`)})]},e.fullId)}),U.length===0&&(0,Z.jsx)(`p`,{style:{fontSize:12,color:`var(--text-dim)`,padding:`12px 0`,textAlign:`center`},children:t(`settings.agent.noModelsMatch`).replace(`{search}`,T)})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:8,marginTop:12},children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>void re(),disabled:o,className:`settings-btn settings-btn-primary`,children:t(o?`settings.agent.saving`:`settings.agent.saveSelection`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{w(!1),E(``),S(g),(g===null||g.length===0)&&b(!1)},className:`settings-btn`,children:t(`settings.agent.cancel`)})]})]})]}),(0,Z.jsxs)(Lm,{icon:(0,Z.jsx)(me,{size:15}),title:t(`settings.agent.orchestrator`),subtitle:`Dedicated provider and model for supervisor & worker multi-agent runs`,children:[(0,Z.jsx)(Im,{label:t(`settings.agent.orchProvider`),hint:t(`settings.agent.orchProviderHint`),children:(0,Z.jsxs)(`select`,{value:f,disabled:o,onChange:e=>R(e.target.value),className:`settings-select`,children:[(0,Z.jsx)(`option`,{value:``,children:t(`settings.agent.useDefault`)}),j.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value))]})}),(0,Z.jsx)(Rm,{}),(0,Z.jsx)(Im,{label:t(`settings.agent.orchModel`),hint:t(`settings.agent.orchModelHint`),children:(0,Z.jsxs)(`select`,{value:m,disabled:o||f.length===0,onChange:e=>z(e.target.value),className:`settings-select`,children:[(0,Z.jsx)(`option`,{value:``,children:t(`settings.agent.useDefault`)}),F.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value))]})})]})]})}function ch({value:e,options:t,onSave:n,disabled:r}){return(0,Z.jsx)(`select`,{value:e,disabled:r,onChange:e=>void n(e.target.value),className:`settings-select`,children:t.map(e=>(0,Z.jsx)(`option`,{value:e,children:e.length===0?`(unset)`:e},e))})}function lh(){let{t:e,locale:t,setLocale:n,supportedLocales:r}=qo(),[i,a]=(0,G.useState)(void 0),[o,s]=(0,G.useState)(void 0),[c,l]=(0,G.useState)(!1);(0,G.useEffect)(()=>{Lt().then(a).catch(()=>{})},[]);let u=async()=>{l(!0),s(void 0);try{let e=await Rt();s({latestSdkVersion:e.latestSdkVersion,updateAvailable:e.updateAvailable})}catch(e){s({latestSdkVersion:`?`,updateAvailable:!1,error:Pm(e)})}finally{l(!1)}};return(0,Z.jsxs)(`div`,{className:`settings-fields`,children:[(0,Z.jsx)(Lm,{icon:(0,Z.jsx)(V,{size:15}),title:e(`settings.general.about`),subtitle:e(`settings.general.aboutDesc`),children:(0,Z.jsx)(`div`,{style:{fontSize:12,color:`var(--text-secondary)`,lineHeight:1.6},children:`pi-kot is a local-first web UI and bridge client for the pi coding agent. It embeds the @earendil-works/pi-coding-agent SDK and exposes capabilities via REST, SSE, and WebSockets.`})}),(0,Z.jsx)(Lm,{icon:(0,Z.jsx)(g,{size:15}),title:e(`settings.language`),subtitle:`Select the interface language for pi-kot`,children:(0,Z.jsx)(Im,{label:e(`settings.language`),hint:`UI labels, prompts, and dialog buttons`,children:(0,Z.jsx)(`select`,{className:`settings-select`,value:t,onChange:e=>n(e.target.value),children:r.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.label},e.id))})})}),(0,Z.jsxs)(Lm,{icon:(0,Z.jsx)(z,{size:15}),title:e(`settings.general.versions`),subtitle:`Installed server build and agent runtime SDK versions`,action:(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>void u(),disabled:c,className:`settings-btn settings-btn-xs`,children:[(0,Z.jsx)(A,{size:11,className:c?`animate-spin`:``}),(0,Z.jsx)(`span`,{children:e(c?`settings.general.checking`:o===void 0?`settings.general.checkForUpdates`:`settings.general.checkAgain`)})]}),children:[(0,Z.jsx)(Im,{label:e(`settings.general.server`),hint:`Fastify bridge server version`,children:(0,Z.jsx)(`span`,{style:{fontFamily:`var(--font-mono, monospace)`,fontWeight:600,fontSize:12},children:i?.serverVersion??`…`})}),(0,Z.jsx)(Rm,{}),(0,Z.jsx)(Im,{label:e(`settings.general.sdk`),hint:`@earendil-works/pi-coding-agent version`,children:(0,Z.jsx)(`span`,{style:{fontFamily:`var(--font-mono, monospace)`,fontWeight:600,fontSize:12},children:i?.sdkVersion??`…`})}),o!==void 0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Rm,{}),(0,Z.jsx)(Im,{label:e(`settings.general.latestSdk`),hint:o.error===void 0?o.updateAvailable?`A newer SDK is published on npm`:`You are on the latest SDK`:`Check error`,children:(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,Z.jsx)(`span`,{style:{fontFamily:`var(--font-mono, monospace)`,fontWeight:600,fontSize:12},children:o.error===void 0?o.latestSdkVersion:(0,Z.jsx)(`span`,{style:{color:`var(--danger, #e74c3c)`},children:e(`settings.general.checkFailed`)})}),o.error===void 0&&o.updateAvailable&&(0,Z.jsx)(`span`,{className:`settings-badge`,style:{background:`var(--accent-subtle)`,color:`var(--accent-text)`,border:`1px solid var(--accent)`},children:e(`settings.general.updateAvailable`)}),o.error===void 0&&!o.updateAvailable&&(0,Z.jsx)(`span`,{className:`settings-badge settings-badge-on`,children:e(`settings.general.upToDate`)})]})})]})]}),(0,Z.jsx)(Lm,{icon:(0,Z.jsx)(L,{size:15}),title:`App Session`,subtitle:`Manage current browser window session`,children:(0,Z.jsx)(Im,{label:e(`settings.general.reloadPage`),hint:`Refreshes the client and reconnects to active SSE streams`,children:(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`settings-btn`,children:[(0,Z.jsx)(L,{size:12}),(0,Z.jsx)(`span`,{children:e(`settings.general.reloadPage`)})]})})})]})}var $={section:{marginBottom:24},heading:{fontSize:13,fontWeight:600,color:`var(--text-primary)`,marginBottom:8},subheading:{fontSize:11,color:`var(--text-dim)`,marginBottom:8},card:{borderRadius:8,background:`var(--bg-glass)`,border:`1px solid var(--border-color)`,marginBottom:8,overflow:`hidden`},cardHeader:{display:`flex`,alignItems:`center`,gap:8,padding:`10px 12px`,cursor:`pointer`,userSelect:`none`},cardTitle:{fontSize:12,fontWeight:600,color:`var(--text-primary)`,flex:1,minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},badge:{fontSize:10,padding:`1px 6px`,borderRadius:4,fontWeight:500,flexShrink:0},resourceSection:{padding:`0 12px 10px`},resourceItem:{display:`flex`,alignItems:`center`,gap:6,padding:`4px 8px`,borderRadius:4,fontSize:11,color:`var(--text-secondary)`},resourceIcon:{fontSize:13,width:18,textAlign:`center`,flexShrink:0},statusDot:{width:6,height:6,borderRadius:`50%`,flexShrink:0},toggle:{fontSize:10,padding:`2px 8px`,borderRadius:4,border:`1px solid var(--border-color)`,background:`var(--bg-glass)`,color:`var(--text-secondary)`,cursor:`pointer`,flexShrink:0},empty:{fontSize:12,color:`var(--text-dim)`,textAlign:`center`,padding:40},totals:{display:`flex`,gap:16,marginBottom:16,flexWrap:`wrap`},totalItem:{fontSize:11,color:`var(--text-dim)`},totalNum:{fontWeight:600,color:`var(--text-primary)`},expandIcon:{fontSize:10,color:`var(--text-dim)`,flexShrink:0,transition:`transform 0.15s`},disabled:{opacity:.5},actionBtn:{fontSize:10,padding:`3px 10px`,borderRadius:4,border:`1px solid var(--border-color)`,background:`var(--bg-glass)`,color:`var(--text-secondary)`,cursor:`pointer`,flexShrink:0,fontWeight:500},dangerBtn:{fontSize:10,padding:`3px 10px`,borderRadius:4,border:`1px solid rgba(224, 108, 117, 0.3)`,background:`rgba(224, 108, 117, 0.08)`,color:`#e06c75`,cursor:`pointer`,flexShrink:0,fontWeight:500},installBox:{display:`flex`,gap:8,marginBottom:8,alignItems:`end`},installInput:{flex:1,padding:`6px 10px`,borderRadius:6,border:`1px solid var(--border-color)`,background:`var(--bg-glass)`,color:`var(--text-primary)`,fontSize:12,outline:`none`,fontFamily:`inherit`},label:{fontSize:10,color:`var(--text-dim)`,marginBottom:4}},uh={extension:`🧩`,skill:`🛠️`,prompt:`📝`,theme:`🎨`},dh={loaded:`var(--green, #34d399)`,disabled:`var(--text-dim, #888)`,installed:`var(--yellow, #fbbf24)`,missing:`var(--red, #ef4444)`},fh={orchestration:`🎯 Orchestration`,tools:`🛠️ Tools & Integrations`,productivity:`⚡ Productivity`,integration:`🔗 Integrations`,ui:`🎨 UI Enhancements`};function ph(e){let t=new Map;for(let n of e){let e=t.get(n.category)??[];e.push(n),t.set(n.category,e)}return Array.from(t.entries())}var mh={width:80,padding:`4px 6px`,fontSize:11,borderRadius:6,border:`1px solid var(--border-color)`,background:`var(--bg-glass)`,color:`var(--text-primary)`,outline:`none`},hh={...mh,cursor:`pointer`};function gh({ext:e,installedScope:t,installing:n,projectPath:r,onInstall:i}){let{t:a}=qo(),o=r!==void 0&&r.length>0,[s,c]=(0,G.useState)(o?`project`:`user`),l=o,u=t===s;return(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`8px 10px`,borderRadius:8,background:`var(--bg-glass)`,border:`1px solid var(--border-color)`,marginBottom:6,opacity:u?.6:1},children:[(0,Z.jsx)(`span`,{style:{fontSize:16},children:e.icon}),(0,Z.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,Z.jsxs)(`div`,{style:{fontSize:12,fontWeight:600,color:`var(--text-primary)`,display:`flex`,alignItems:`center`,gap:6},children:[e.name,e.verified&&(0,Z.jsx)(`span`,{style:{fontSize:9,padding:`1px 5px`,borderRadius:3,background:`rgba(52, 211, 153, 0.12)`,color:`#34d399`,fontWeight:500},children:`✓ Verified`})]}),(0,Z.jsx)(`div`,{style:{fontSize:10,color:`var(--text-dim)`,marginTop:2,lineHeight:1.4},children:e.description})]}),l&&!u&&(0,Z.jsx)(`div`,{style:{display:`inline-flex`,border:`1px solid var(--border-color)`,borderRadius:5,overflow:`hidden`,flexShrink:0},children:[`user`,`project`].map(e=>(0,Z.jsx)(`button`,{onClick:()=>c(e),style:{padding:`2px 8px`,fontSize:9,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.03em`,border:`none`,borderRight:e===`user`?`1px solid var(--border-color)`:`none`,background:s===e?`var(--bg-surface)`:`transparent`,color:s===e?`var(--text-primary)`:`var(--text-dim)`,cursor:`pointer`},children:e===`user`?`global`:`project`},e))}),(0,Z.jsx)(`button`,{style:{fontSize:10,padding:`4px 12px`,borderRadius:5,border:`none`,background:u?`var(--bg-surface)`:`var(--accent-bg, #3b82f6)`,color:u?`var(--text-dim)`:`white`,cursor:u?`default`:`pointer`,fontWeight:500,flexShrink:0},onClick:()=>{u||i(s)},disabled:n||u,children:a(n?`settings.packages.installing`:u?s===`project`?`settings.packages.installedProject`:`settings.packages.installedGlobal`:`settings.packages.installAction`)})]})}function _h({pkg:e,expanded:t,pkgUpdate:n,busy:r,installing:i,uninstalling:a,updating:o,onToggleExpand:s,onToggle:c,onUninstall:l,onUpdate:u}){let{t:d}=qo();`${e.scope}${e.source}`;let f=e.resources.length>0;return(0,Z.jsxs)(`div`,{style:{...$.card,...e.disabled?$.disabled:{}},children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`10px 12px 4px`,cursor:`pointer`,userSelect:`none`},onClick:s,children:[(0,Z.jsx)(`span`,{style:{...$.expandIcon,transform:t?`rotate(90deg)`:`rotate(0deg)`},children:`▶`}),(0,Z.jsx)(`span`,{style:{...$.statusDot,background:dh[e.status]??`var(--text-dim)`}}),(0,Z.jsx)(`span`,{style:$.cardTitle,children:e.packageName||e.source}),e.version&&(0,Z.jsxs)(`span`,{style:{...$.badge,background:`var(--bg-surface)`,color:`var(--text-dim)`},children:[`v`,e.version]})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6,padding:`4px 12px 10px 38px`,flexWrap:`wrap`},children:[n?.updateAvailable&&(0,Z.jsx)(`button`,{style:$.actionBtn,onClick:e=>{e.stopPropagation(),u(n.package)},disabled:o===n.package,title:`Update: ${n.installed} → ${n.latest}`,children:o===n.package?`…`:d(`settings.packages.update`)}),(0,Z.jsx)(`button`,{style:$.toggle,onClick:e=>{e.stopPropagation(),c()},disabled:r,children:e.disabled?d(`settings.packages.enable`):d(`settings.packages.disable`)}),(0,Z.jsx)(`button`,{style:$.dangerBtn,onClick:e=>{e.stopPropagation(),l()},disabled:a===e.source,children:a===e.source?`…`:d(`settings.packages.uninstall`)})]})]}),t&&(0,Z.jsxs)(`div`,{style:$.resourceSection,children:[!f&&(0,Z.jsx)(`div`,{style:{fontSize:11,color:`var(--text-dim)`,padding:`4px 8px`},children:e.status===`missing`?`Package not installed.`:`No resources loaded from this package.`}),[`extension`,`skill`,`prompt`,`theme`].map(t=>{let n=e.resources.filter(e=>e.kind===t);return n.length===0?null:(0,Z.jsxs)(`div`,{style:{marginBottom:6},children:[(0,Z.jsxs)(`div`,{style:{fontSize:10,fontWeight:600,color:`var(--text-dim)`,textTransform:`uppercase`,letterSpacing:`0.5px`,marginBottom:2,padding:`0 8px`},children:[uh[t],` `,t,`s (`,n.length,`)`]}),n.map((e,t)=>(0,Z.jsx)(`div`,{style:$.resourceItem,children:(0,Z.jsx)(`span`,{style:{color:`var(--text-dim)`,fontSize:10},children:e.relativePath})},e.path+t))]},t)})]})]})}function vh({onError:e,projectPath:t}){let{t:n}=qo(),[r,i]=(0,G.useState)(),[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(new Set),[l,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(null),[p,m]=(0,G.useState)(null),[h,g]=(0,G.useState)(null),[_,v]=(0,G.useState)(``),[y,b]=(0,G.useState)(t?`project`:`user`),[x,S]=(0,G.useState)(``),[C,w]=(0,G.useState)(void 0),[T,E]=(0,G.useState)(!1),[D,O]=(0,G.useState)(null),[k,A]=(0,G.useState)([]),[j,M]=(0,G.useState)(!1),[N,P]=(0,G.useState)(!1),[F,I]=(0,G.useState)(!1),L=(0,G.useCallback)(async()=>{try{let e=await yr(t);i(e)}catch(t){e(`Failed to load packages: ${t instanceof Error?t.message:String(t)}`)}},[e,t]),R=(0,G.useCallback)(async()=>{try{let e=await fr();o(e)}catch(t){e(`Failed to load extensions catalog: ${t instanceof Error?t.message:String(t)}`)}},[e]),z=(0,G.useCallback)(async()=>{await Promise.all([L(),R()])},[L,R]);(0,G.useEffect)(()=>{z()},[z]);let ee=a?.detected.some(e=>e.name===`pi-vision-tool`||e.package===`npm:pi-vision-tool`)??!1;(0,G.useEffect)(()=>{if(!ee){O(null);return}gr().then(O).catch(()=>{}),(async()=>{try{let e=await wn();A(e.providers)}catch{}})()},[ee]);let B=new Set;if(a){for(let e of a.recommended)if(e.verified){let t=e.package.replace(/^npm:/,``);B.add(e.package),B.add(t)}}let V=new Map;if(C)for(let e of C)V.set(e.package,e);let H=async(n,r)=>{if(!n)return;let i=r??y;f(n),e(void 0);try{let e=i===`project`&&t!==void 0;await br(n,e,e?t:void 0),v(``),await L()}catch(t){e(`Install failed: ${t instanceof Error?t.message:String(t)}`)}finally{f(null)}},U=async()=>{let e=x.trim();e&&(await H(e),S(``))},te=async r=>{if(confirm(`${n(`settings.packages.uninstallConfirm`)} "${r.packageName||r.source}"?`)){m(r.source),e(void 0);try{let e=r.scope===`project`&&t!==void 0;await xr(r.source,e,e?t:void 0),await L()}catch(t){e(`Uninstall failed: ${t instanceof Error?t.message:String(t)}`)}finally{m(null)}}},ne=async n=>{u(!0),e(void 0);try{let e=n.scope===`project`&&t!==void 0;await Sr(n.source,n.scope,!n.disabled,e?t:void 0),await L()}catch(t){e(`Toggle failed: ${t instanceof Error?t.message:String(t)}`)}finally{u(!1)}},re=async()=>{E(!0),e(void 0);try{let e=await pr();w(e)}catch(t){e(`Check updates failed: ${t instanceof Error?t.message:String(t)}`)}finally{E(!1)}},ie=async t=>{g(t),e(void 0);try{await mr(t),await L();let e=await pr();w(e)}catch(t){e(`Update failed: ${t instanceof Error?t.message:String(t)}`)}finally{g(null)}},ae=async()=>{P(!0),I(!1),e(void 0);try{await vr(),I(!0),setTimeout(()=>I(!1),2e3)}catch(t){e(`Reload failed: ${t instanceof Error?t.message:String(t)}`)}finally{P(!1)}},oe=async t=>{M(!0),e(void 0);try{await _r(t);let e=await gr();O(e)}catch(t){e(`Failed to save vision config: ${t instanceof Error?t.message:String(t)}`)}finally{M(!1)}},se=e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ce=r?r.packages.reduce((e,t)=>e+t.counts.extensions+t.counts.skills+t.counts.prompts+t.counts.themes,0):0,le=C?.some(e=>e.updateAvailable)??!1;return(0,Z.jsxs)(`div`,{style:{padding:`0 4px`},children:[r&&(0,Z.jsxs)(`div`,{style:$.totals,children:[(0,Z.jsxs)(`span`,{style:$.totalItem,children:[`Packages: `,(0,Z.jsx)(`span`,{style:$.totalNum,children:r.packages.length})]}),(0,Z.jsxs)(`span`,{style:$.totalItem,children:[`Resources: `,(0,Z.jsx)(`span`,{style:$.totalNum,children:ce})]}),[`extensions`,`skills`,`prompts`,`themes`].map(e=>{let t=e===`extensions`?`extension`:e===`skills`?`skill`:e===`prompts`?`prompt`:`theme`;return(0,Z.jsxs)(`span`,{style:$.totalItem,children:[uh[t],` `,e,`:`,` `,(0,Z.jsx)(`span`,{style:$.totalNum,children:r.totals[e]})]},e)})]}),(0,Z.jsxs)(`div`,{style:$.section,children:[(0,Z.jsx)(`div`,{style:$.heading,children:n(`settings.packages.install`)}),(0,Z.jsx)(`div`,{style:$.subheading,children:n(`settings.packages.installSubheading`)}),(0,Z.jsxs)(`div`,{style:$.installBox,children:[(0,Z.jsxs)(`div`,{style:{flex:1},children:[(0,Z.jsx)(`div`,{style:$.label,children:n(`settings.packages.packageSource`)}),(0,Z.jsx)(`input`,{style:$.installInput,placeholder:`npm:@org/package`,value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&H(_)}})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{style:$.label,children:`Scope`}),(0,Z.jsxs)(`select`,{style:{...hh,width:80},value:y,onChange:e=>b(e.target.value),children:[(0,Z.jsx)(`option`,{value:`user`,children:`global`}),(0,Z.jsx)(`option`,{value:`project`,children:`project`})]})]}),(0,Z.jsx)(`button`,{style:{...$.actionBtn,background:d?`var(--bg-glass)`:`var(--accent-bg, #3b82f6)`,color:d?`var(--text-dim)`:`white`,border:`none`,padding:`6px 14px`,fontSize:11},onClick:()=>void H(_),disabled:d!==null||!_.trim(),children:n(d?`settings.packages.installing`:`settings.packages.installAction`)})]}),(0,Z.jsxs)(`details`,{style:{fontSize:11,color:`var(--text-dim)`},children:[(0,Z.jsx)(`summary`,{style:{cursor:`pointer`,marginBottom:4},children:`Manual install (advanced)`}),(0,Z.jsxs)(`div`,{style:$.installBox,children:[(0,Z.jsxs)(`div`,{style:{flex:1},children:[(0,Z.jsx)(`div`,{style:$.label,children:`Full install spec`}),(0,Z.jsx)(`input`,{style:$.installInput,placeholder:`npm:pi-free or git:github.com/user/repo`,value:x,onChange:e=>S(e.target.value),onKeyDown:e=>{e.key===`Enter`&&U()}})]}),(0,Z.jsx)(`button`,{style:{...$.actionBtn,background:`var(--accent-bg, #3b82f6)`,color:`white`,border:`none`,padding:`6px 14px`,fontSize:11},onClick:()=>void U(),disabled:d!==null||!x.trim(),children:n(`settings.packages.piInstall`)})]})]})]}),r&&r.packages.length===0&&!a?.detected.length&&(0,Z.jsx)(`div`,{style:$.empty,children:n(`settings.packages.noPackages`)}),r&&(()=>{let e=r.packages.filter(e=>e.scope===`user`),i=r.packages.filter(e=>e.scope===`project`);return(0,Z.jsxs)(Z.Fragment,{children:[e.length>0&&(0,Z.jsxs)(`div`,{style:$.section,children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:8},children:[(0,Z.jsxs)(`div`,{style:{fontSize:13,fontWeight:600,color:`var(--text-primary)`},children:[`🌐 `,n(`settings.packages.globalScope`)]}),(0,Z.jsx)(`div`,{style:{fontSize:11,color:`var(--text-dim)`,fontFamily:`var(--font-mono)`},children:`~/.pi/agent/`})]}),e.map(e=>(0,Z.jsx)(_h,{pkg:e,expanded:s.has(`${e.scope}\0${e.source}`),pkgUpdate:V.get(e.packageName??e.source),busy:l,installing:d,uninstalling:p,updating:h,onToggleExpand:()=>se(`${e.scope}\0${e.source}`),onToggle:()=>void ne(e),onUninstall:()=>void te(e),onUpdate:e=>void ie(e)},`${e.scope}\0${e.source}`))]}),i.length>0&&(0,Z.jsxs)(`div`,{style:$.section,children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:8},children:[(0,Z.jsxs)(`div`,{style:{fontSize:13,fontWeight:600,color:`var(--text-primary)`},children:[`📁 `,n(`settings.packages.projectScope`)]}),(0,Z.jsx)(`div`,{style:{fontSize:11,color:`var(--text-dim)`,fontFamily:`var(--font-mono)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:t?.replace(/^\/[^/]+\/[^/]+/,`~`)??n(`settings.packages.unknown`)})]}),i.map(e=>(0,Z.jsx)(_h,{pkg:e,expanded:s.has(`${e.scope}\0${e.source}`),pkgUpdate:V.get(e.packageName??e.source),busy:l,installing:d,uninstalling:p,updating:h,onToggleExpand:()=>se(`${e.scope}\0${e.source}`),onToggle:()=>void ne(e),onUninstall:()=>void te(e),onUpdate:e=>void ie(e)},`${e.scope}\0${e.source}`))]})]})})(),a&&a.recommended.length>0&&(0,Z.jsxs)(`div`,{style:$.section,children:[(0,Z.jsx)(`div`,{style:$.heading,children:n(`settings.packages.recommended`)}),(0,Z.jsx)(`div`,{style:$.subheading,children:n(`settings.packages.recommendedSubheading`)}),ph(a.recommended).map(([e,n])=>(0,Z.jsxs)(`div`,{style:{marginBottom:12},children:[(0,Z.jsx)(`div`,{style:{fontSize:11,fontWeight:600,color:`var(--text-dim)`,marginBottom:6,padding:`0 4px`},children:fh[e]??e}),n.map(e=>{let n=r?.packages.find(t=>t.packageName===e.name||t.source===e.package||t.source.includes(e.name))?.scope;return(0,Z.jsx)(gh,{ext:e,installedScope:n,installing:d===e.package,projectPath:t,onInstall:t=>{H(e.package,t)}},e.id)})]},e))]}),(0,Z.jsxs)(`div`,{style:$.section,children:[(0,Z.jsx)(`div`,{style:$.heading,children:n(`settings.packages.updates`)}),(0,Z.jsx)(`button`,{style:$.actionBtn,onClick:()=>void re(),disabled:T,children:n(T?`settings.packages.checking`:`settings.packages.checkUpdates`)}),le&&(0,Z.jsxs)(`div`,{style:{marginTop:8,fontSize:11,color:`var(--text-dim)`},children:[C.filter(e=>e.updateAvailable).length,` `,n(`settings.packages.updatesAvailable`),`.`,n(`settings.packages.useUpdateButton`)]}),C&&!le&&(0,Z.jsx)(`div`,{style:{marginTop:8,fontSize:11,color:`#34d399`},children:n(`settings.packages.allUpToDate`)})]}),ee&&D?.installed&&(0,Z.jsxs)(`div`,{style:$.section,children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`},children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{style:$.heading,children:n(`settings.packages.visionTool`)}),(0,Z.jsx)(`div`,{style:$.subheading,children:n(`settings.packages.visionToolSubheading`)})]}),(0,Z.jsx)(`span`,{style:$.badge,children:n(`settings.packages.visionToolDetected`)})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:8,alignItems:`end`,marginTop:8,flexWrap:`wrap`},children:[(0,Z.jsxs)(`div`,{style:{flex:1,minWidth:120},children:[(0,Z.jsx)(`div`,{style:{fontSize:10,color:`var(--text-dim)`,marginBottom:4},children:n(`settings.packages.provider`)}),(0,Z.jsxs)(`select`,{style:{...hh,width:`100%`},value:D.provider??``,onChange:e=>void oe({provider:e.target.value||void 0}),disabled:j,children:[(0,Z.jsxs)(`option`,{value:``,children:[`— `,n(`settings.packages.auto`),` —`]}),k.map(e=>(0,Z.jsx)(`option`,{value:e.provider,children:e.provider},e.provider))]})]}),(0,Z.jsxs)(`div`,{style:{flex:1,minWidth:120},children:[(0,Z.jsx)(`div`,{style:{fontSize:10,color:`var(--text-dim)`,marginBottom:4},children:n(`settings.packages.model`)}),(0,Z.jsxs)(`select`,{style:{...hh,width:`100%`},value:D.model??``,onChange:e=>void oe({model:e.target.value||void 0}),disabled:j,children:[(0,Z.jsxs)(`option`,{value:``,children:[`— `,n(`settings.packages.auto`),` —`]}),k.find(e=>e.provider===D.provider)?.models?.filter(e=>e.input?.includes(`image`)).map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name??e.id},e.id))]})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{style:{fontSize:10,color:`var(--text-dim)`,marginBottom:4},children:n(`settings.packages.maxDimension`)}),(0,Z.jsx)(`input`,{style:mh,type:`number`,min:256,max:4096,value:D.maxDimension??1568,onChange:e=>void oe({maxDimension:parseInt(e.target.value)||void 0}),disabled:j})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{style:{fontSize:10,color:`var(--text-dim)`,marginBottom:4},children:n(`settings.packages.jpegQuality`)}),(0,Z.jsx)(`input`,{style:mh,type:`number`,min:10,max:100,value:D.jpegQuality??85,onChange:e=>void oe({jpegQuality:parseInt(e.target.value)||void 0}),disabled:j})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{style:{fontSize:10,color:`var(--text-dim)`,marginBottom:4},children:n(`settings.packages.reasoning`)}),(0,Z.jsx)(`select`,{style:hh,value:D.defaultReasoningEffort??`off`,onChange:e=>void oe({defaultReasoningEffort:e.target.value}),disabled:j,children:hr.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{style:{fontSize:10,color:`var(--text-dim)`,marginBottom:4},children:`\xA0`}),(0,Z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:4,fontSize:11,cursor:`pointer`,color:`var(--text-secondary)`},children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:D.enabled!==!1,onChange:e=>void oe({enabled:e.target.checked}),disabled:j}),n(`settings.packages.enabledStatus`)]})]})]})]}),(0,Z.jsxs)(`div`,{style:$.section,children:[(0,Z.jsx)(`div`,{style:$.heading,children:n(`settings.packages.agentReload`)}),(0,Z.jsx)(`div`,{style:$.subheading,children:n(`settings.packages.agentReloadSubheading`)}),(0,Z.jsx)(`button`,{onClick:()=>void ae(),disabled:N,style:{padding:`6px 14px`,fontSize:11,fontWeight:600,borderRadius:6,cursor:N?`default`:`pointer`,border:`1px solid var(--border-color)`,background:N?`var(--bg-glass)`:`var(--accent-bg, #3b82f6)`,color:N?`var(--text-dim)`:`white`},children:N?`Reloading…`:F?`Reloaded ✓`:`/reload`})]})]})}function yh({skill:e,onBack:t,onSaved:n,onError:r}){let{t:i}=qo(),a=(0,G.useRef)(r);a.current=r;let o=(0,G.useRef)(n);o.current=n;let[s,c]=(0,G.useState)(!0),[l,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(null);(0,G.useEffect)(()=>{let t=!1;return c(!0),v(null),Vr(e.name).then(e=>{t||(f(e.md.description??``),m(e.md.instructions))}).catch(e=>{if(t)return;let n=`Failed to load skill: ${e instanceof Error?e.message:String(e)}`;v(n),a.current(n)}).finally(()=>{t||c(!1)}),()=>{t=!0}},[e.name]);let y=(0,G.useCallback)(async()=>{u(!0);try{await Hr(e.name,{description:d,instructions:p}),o.current(),t()}catch(e){let t=`Failed to save: ${e instanceof Error?e.message:String(e)}`;v(t),a.current(t)}finally{u(!1)}},[e.name,d,p,t]);return s?(0,Z.jsx)(`div`,{style:{padding:24,textAlign:`center`,color:`var(--text-dim)`},children:i(`settings.skills.editor.loading`)}):_?(0,Z.jsxs)(`div`,{style:{padding:24},children:[(0,Z.jsx)(`p`,{style:{color:`var(--danger, #e74c3c)`,marginBottom:12},children:_}),(0,Z.jsx)(`button`,{onClick:t,className:`settings-btn`,style:{fontSize:12},children:i(`settings.skills.editor.backToSkills`)})]}):(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`,padding:`0 12px 12px`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:8,marginBottom:8,flexShrink:0},children:[(0,Z.jsx)(`button`,{onClick:t,style:{padding:`3px 8px`,fontSize:11,fontWeight:600,borderRadius:4,border:`1px solid var(--border-color)`,background:`transparent`,color:`var(--text-secondary)`,cursor:`pointer`,whiteSpace:`nowrap`,flexShrink:0},children:i(`settings.skills.editor.back`)}),(0,Z.jsxs)(`div`,{style:{minWidth:0,flex:1},children:[(0,Z.jsx)(`div`,{style:{fontSize:13,fontWeight:600,color:`var(--text-primary)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.name}),(0,Z.jsx)(`div`,{style:{fontSize:10,color:`var(--text-dim)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,marginTop:1},children:e.filePath.length>70?`…`+e.filePath.slice(-67):e.filePath})]})]}),(0,Z.jsxs)(`div`,{style:{marginBottom:6,flexShrink:0},children:[(0,Z.jsxs)(`label`,{style:{display:`block`,fontSize:11,fontWeight:600,marginBottom:4,color:`var(--text-primary)`},children:[i(`settings.skills.editor.description`),` `,(0,Z.jsx)(`span`,{style:{color:`var(--danger, #e74c3c)`},children:`*`})]}),(0,Z.jsx)(`textarea`,{value:d,onChange:e=>f(e.target.value),placeholder:i(`settings.skills.editor.descriptionPlaceholder`),rows:2,style:{width:`100%`,resize:`none`,minHeight:38,padding:`6px 10px`,fontSize:12,fontFamily:`inherit`,border:`1px solid var(--border-color)`,borderRadius:6,background:`var(--bg-glass)`,color:`var(--text-primary)`,boxSizing:`border-box`}})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,flex:1,minHeight:0},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:4,flexShrink:0},children:[(0,Z.jsx)(`label`,{style:{fontSize:11,fontWeight:600,color:`var(--text-primary)`},children:i(`settings.skills.editor.instructions`)}),(0,Z.jsx)(`button`,{onClick:()=>g(e=>!e),style:{fontSize:10,padding:`2px 8px`,borderRadius:4,border:`1px solid var(--border-color)`,background:h?`var(--accent-bg)`:`transparent`,color:h?`white`:`var(--text-dim)`,cursor:`pointer`,fontWeight:600},children:i(h?`settings.skills.editor.edit`:`settings.skills.editor.preview`)})]}),(0,Z.jsx)(`div`,{style:{flex:1,minHeight:0,border:`1px solid var(--border-color)`,borderRadius:6,overflow:`hidden`,background:`var(--bg-glass)`},children:h?(0,Z.jsx)(`div`,{style:{padding:`12px 16px`,fontSize:12,lineHeight:1.5,color:`var(--text-primary)`,overflow:`auto`,height:`100%`,whiteSpace:`pre-wrap`},dangerouslySetInnerHTML:{__html:(e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/^### (.+)$/gm,`<h3 style="margin:12px 0 4px;font-size:15px;font-weight:600">$1</h3>`).replace(/^## (.+)$/gm,`<h2 style="margin:14px 0 6px;font-size:17px;font-weight:600">$1</h2>`).replace(/^# (.+)$/gm,`<h1 style="margin:16px 0 8px;font-size:19px;font-weight:600">$1</h1>`).replace(/\*\*(.+?)\*\*/g,`<strong>$1</strong>`).replace(/\*(.+?)\*/g,`<em>$1</em>`).replace(/`(.+?)`/g,`<code style="background:var(--bg-glass);padding:1px 4px;border-radius:3px;font-family:var(--font-mono,monospace);font-size:0.9em">$1</code>`).replace(/^- (.+)$/gm,`<li style="margin-left:16px">$1</li>`).replace(/\n/g,`<br/>`))(p)}}):(0,Z.jsx)(`textarea`,{value:p,onChange:e=>m(e.target.value),placeholder:i(`settings.skills.editor.instructionsPlaceholder`),style:{width:`100%`,height:`100%`,resize:`none`,padding:`12px 16px`,fontSize:12,fontFamily:`var(--font-mono, monospace)`,border:`none`,background:`transparent`,color:`var(--text-primary)`,lineHeight:1.5,outline:`none`,boxSizing:`border-box`}})})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8,paddingTop:10,flexShrink:0,flexWrap:`wrap`},children:[(0,Z.jsx)(`button`,{onClick:t,style:{padding:`6px 14px`,fontSize:12,fontWeight:600,borderRadius:6,border:`1px solid var(--border-color)`,background:`transparent`,color:`var(--text-secondary)`,cursor:`pointer`},children:i(`settings.agent.cancel`)}),(0,Z.jsx)(`button`,{onClick:y,disabled:l||!d.trim(),style:{padding:`6px 14px`,fontSize:12,fontWeight:600,borderRadius:6,border:`none`,background:l?`var(--bg-glass)`:`var(--accent-bg, #3b82f6)`,color:`white`,cursor:l?`default`:`pointer`,opacity:l||!d.trim()?.6:1},children:i(l?`settings.agent.saving`:`settings.skills.editor.save`)})]})]})}function bh({onError:e}){let{t}=qo(),[n,r]=(0,G.useState)(void 0),[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(``),[c,l]=(0,G.useState)(`all`),[u,d]=(0,G.useState)(null),f=async()=>{e(void 0);try{let e=await Rr();r(e)}catch(t){e(`Failed to load skills: ${t instanceof Error?t.message:String(t)}`)}};(0,G.useEffect)(()=>{f()},[]);let p=async(t,n)=>{a(!0);try{await zr(t.name,n),await f()}catch(t){e(`Toggle failed: ${t instanceof Error?t.message:String(t)}`)}finally{a(!1)}},m=async()=>{if(n){a(!0);try{await Br(!!n.disableAll),await f()}catch(t){e(`Toggle all failed: ${t instanceof Error?t.message:String(t)}`)}finally{a(!1)}}},h=(0,G.useMemo)(()=>{if(!n)return[];let e=n.skills;if(o.trim()){let t=o.toLowerCase();e=e.filter(e=>e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.filePath.toLowerCase().includes(t))}return c!==`all`&&(e=e.filter(e=>e.source===c)),e},[n,o,c]),g=(0,G.useMemo)(()=>{if(!n)return{};let e={};for(let t of n.skills)e[t.source]=(e[t.source]??0)+1;return e},[n]),_=n&&n.diagnostics&&n.diagnostics.length>0;return n===void 0?(0,Z.jsx)(`p`,{className:`settings-hint`,children:t(`settings.skills.loading`)}):(0,Z.jsxs)(`div`,{style:{height:u?`100%`:void 0,display:u?`flex`:void 0,flexDirection:`column`,minHeight:0,overflow:u?`hidden`:void 0},children:[!u&&(0,Z.jsx)(`p`,{className:`settings-hint`,children:t(`settings.skills.description`)}),_&&(0,Z.jsx)(`div`,{style:{marginBottom:12},children:n.diagnostics.map((e,t)=>(0,Z.jsx)(Sh,{diagnostic:e},t))}),!u&&(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:8,alignItems:`center`,marginBottom:10,flexWrap:`wrap`},children:[(0,Z.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),placeholder:t(`settings.skills.searchPlaceholder`),className:`settings-input`,style:{flex:1,minWidth:140}}),(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:4,alignItems:`center`},children:[[`all`,`global`,`project`,`extension`].map(e=>{let r=e===`all`?n.skills.length:g[e]??0;return(0,Z.jsx)(`button`,{onClick:()=>l(e),className:`settings-tab ${c===e?`settings-tab-active`:``}`,style:{fontSize:11,padding:`2px 8px`,borderRadius:4,border:`none`,cursor:`pointer`},children:e===`all`?t(`settings.skills.allCount`).replace(`{count}`,String(r)):`${e} (${r})`},e)}),(0,Z.jsx)(`button`,{onClick:()=>void m(),disabled:i,className:`settings-tab`,style:{fontSize:11,padding:`2px 8px`,borderRadius:4,border:`1px solid var(--border, rgba(255,255,255,0.15))`,cursor:i?`not-allowed`:`pointer`,color:n.disableAll?`var(--accent, #6366f1)`:`var(--danger, #e74c3c)`,fontWeight:500},children:n.disableAll?t(`settings.skills.enableAll`):t(`settings.skills.disableAll`)})]})]}),u?(0,Z.jsx)(yh,{skill:u,onBack:()=>d(null),onSaved:()=>void f(),onError:t=>e(t)}):(0,Z.jsxs)(Z.Fragment,{children:[h.length===0&&(0,Z.jsx)(`p`,{className:`settings-hint`,style:{marginTop:16},children:o?t(`settings.skills.noSkillsMatch`).replace(`{search}`,o):t(`settings.skills.noSkillsFound`)}),(0,Z.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6},children:h.map(e=>(0,Z.jsx)(xh,{skill:e,onToggle:t=>void p(e,t),onEdit:()=>d(e),disabled:i},e.name))})]})]})}function xh({skill:e,onToggle:t,onEdit:n,disabled:r}){let{t:i}=qo(),a=e.source===`extension`?i(`settings.skills.sourceExtension`).replace(`{path}`,e.extensionPath??`unknown`):e.source===`project`?i(`settings.skills.sourceProject`):i(`settings.skills.sourceGlobal`),o=e.source===`extension`?`settings-badge settings-badge-off`:e.source===`project`?`settings-badge`:`settings-badge settings-badge-on`;return(0,Z.jsx)(`div`,{className:`settings-card`,style:{opacity:e.effective?1:.55,transition:`opacity 0.15s`},children:(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:10},children:[(0,Z.jsx)(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,cursor:r?`not-allowed`:`pointer`,flexShrink:0,marginTop:2},children:(0,Z.jsx)(`input`,{type:`checkbox`,checked:e.effective,disabled:r,onChange:e=>t(e.target.checked),style:{width:15,height:15,accentColor:`var(--accent-text)`,cursor:`inherit`}})}),(0,Z.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,Z.jsx)(`div`,{style:{display:`flex`,gap:4,justifyContent:`flex-end`,marginBottom:4},children:(0,Z.jsx)(`button`,{onClick:n,disabled:e.source===`extension`,title:e.source===`extension`?i(`settings.skills.editExtensionDisabled`):i(`settings.skills.editSkill`),style:{fontSize:10,padding:`2px 8px`,borderRadius:4,border:`1px solid var(--border-color)`,background:`transparent`,color:e.source===`extension`?`var(--text-dim)`:`var(--text-secondary)`,cursor:e.source===`extension`?`not-allowed`:`pointer`,fontWeight:600,opacity:e.source===`extension`?.5:1},children:i(`settings.skills.edit`)})}),(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,flexWrap:`wrap`},children:[(0,Z.jsx)(`span`,{style:{fontSize:13,fontWeight:600,color:`var(--text-primary)`},children:e.name}),(0,Z.jsx)(`span`,{className:o,children:e.source}),e.disableModelInvocation&&(0,Z.jsx)(`span`,{className:`settings-badge settings-badge-off`,title:i(`settings.skills.manualOnlyTitle`),children:i(`settings.skills.manualOnly`)}),e.projectOverride!==void 0&&(0,Z.jsx)(`span`,{className:e.projectOverride===`enabled`?`settings-badge settings-badge-on`:`settings-badge settings-badge-off`,title:i(`settings.skills.projectOverrideActive`),style:{fontSize:10},children:e.projectOverride===`enabled`?i(`settings.skills.projectOn`):i(`settings.skills.projectOff`)})]}),(0,Z.jsx)(`p`,{style:{fontSize:11,color:`var(--text-secondary)`,margin:`2px 0 0`,lineHeight:1.4},children:e.description}),(0,Z.jsxs)(`div`,{style:{fontSize:10,color:`var(--text-dim)`,marginTop:2,display:`flex`,gap:8,flexWrap:`wrap`,alignItems:`center`},children:[(0,Z.jsx)(`span`,{title:e.filePath,children:e.filePath.length>60?`…`+e.filePath.slice(-57):e.filePath}),(0,Z.jsx)(`span`,{children:`·`}),(0,Z.jsx)(`span`,{children:a}),!e.effective&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{children:`·`}),(0,Z.jsx)(`span`,{style:{color:`var(--danger, #e74c3c)`},children:i(`settings.skills.disabled`)})]})]})]})]})})}function Sh({diagnostic:e}){let{t}=qo(),n=e.type===`error`,r=e.type===`collision`,i=n?`rgba(231, 76, 60, 0.08)`:r?`rgba(243, 156, 18, 0.08)`:`rgba(243, 156, 18, 0.05)`,a=n?`1px solid rgba(231, 76, 60, 0.3)`:r?`1px solid rgba(243, 156, 18, 0.3)`:`1px solid rgba(243, 156, 18, 0.2)`,o=t(n?`settings.skills.diagnosticError`:r?`settings.skills.diagnosticCollision`:`settings.skills.diagnosticWarning`);return(0,Z.jsxs)(`div`,{style:{padding:`8px 10px`,borderRadius:6,background:i,border:a,marginBottom:6,fontSize:12,lineHeight:1.4},children:[(0,Z.jsx)(`strong`,{style:{fontSize:11,textTransform:`uppercase`,letterSpacing:.5},children:o}),`: `,e.message,e.path&&(0,Z.jsx)(`div`,{style:{fontSize:10,color:`var(--text-dim)`,marginTop:4},children:e.path}),e.collision&&(0,Z.jsxs)(`div`,{style:{fontSize:10,color:`var(--text-dim)`,marginTop:4},children:[t(`settings.skills.diagnosticWinner`).replace(`{path}`,e.collision.winnerPath),(0,Z.jsx)(`br`,{}),t(`settings.skills.diagnosticLoser`).replace(`{path}`,e.collision.loserPath)]})]})}var Ch={pass:`var(--accent-green, #98c379)`,fail:`var(--accent-red, #e06c75)`,warn:`var(--accent-yellow, #e5c07b)`};function wh({status:e}){return(0,Z.jsx)(`span`,{style:{width:8,height:8,borderRadius:`50%`,background:Ch[e]??`var(--text-dim)`,flexShrink:0,display:`inline-block`}})}function Th({status:e,label:t}){let n=Ch[e]??`var(--text-dim)`;return(0,Z.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:6,padding:`3px 10px`,borderRadius:4,fontSize:12,fontWeight:500,color:n,background:`color-mix(in srgb, ${n} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${n} 25%, transparent)`},children:[(0,Z.jsx)(wh,{status:e}),t]})}function Eh(e){return typeof navigator?.clipboard?.writeText==`function`?navigator.clipboard.writeText(e).catch(()=>Dh(e)):Dh(e)}function Dh(e){return new Promise((t,n)=>{try{let n=document.createElement(`textarea`);n.value=e,n.style.position=`fixed`,n.style.opacity=`0`,document.body.appendChild(n),n.select(),document.execCommand(`copy`),document.body.removeChild(n),t()}catch{n(Error(`clipboard fallback failed`))}})}function Oh({text:e}){let{t}=qo(),[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(!1);return(0,Z.jsx)(`button`,{onClick:async()=>{a(!1);try{await Eh(e),r(!0),setTimeout(()=>r(!1),1500)}catch{a(!0),setTimeout(()=>a(!1),2e3)}},style:{background:`var(--bg-glass)`,border:`1px solid var(--border)`,borderRadius:4,padding:`2px 8px`,fontSize:11,cursor:`pointer`,color:i?`var(--accent-red, #e06c75)`:n?`var(--accent-green, #98c379)`:`var(--text-dim)`,whiteSpace:`nowrap`},title:`Copy URL`,children:t(i?`settings.tunnel.failed`:n?`settings.tunnel.copied`:`settings.tunnel.copy`)})}function kh(){let{t:e}=qo(),[t,n]=(0,G.useState)(null),[r,i]=(0,G.useState)(null),[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(`idle`),[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)(!1),p=(0,G.useCallback)(async()=>{try{let[e,t,r]=await Promise.all([Ur(),Wr(),Gr()]);n(e),i(t),o(r),f(r.active)}catch(e){u(e instanceof Error?e.message:`Failed to load tunnel info`)}},[]);(0,G.useEffect)(()=>{p()},[p]);let m=async()=>{c(`starting`),u(null);try{let e=await Kr();f(!0),o({active:!0,url:e.url,mode:e.mode,provider:e.provider,providerMetadata:e.providerMetadata,localPort:e.localPort})}catch(e){u(e instanceof Error?e.message:`Failed to start tunnel`)}finally{c(`idle`)}},h=async()=>{c(`stopping`),u(null);try{await qr(),f(!1),o(e=>e?{...e,active:!1,url:null}:null)}catch(e){u(e instanceof Error?e.message:`Failed to stop tunnel`)}finally{c(`idle`)}},g=t?.available??!1;return(0,Z.jsxs)(`div`,{className:`settings-section`,style:{padding:`20px 24px`},children:[(0,Z.jsx)(`h3`,{style:{margin:`0 0 16px`,fontSize:15,fontWeight:600},children:e(`settings.tunnel.title`)}),(0,Z.jsxs)(`div`,{style:{background:`var(--bg-frosted)`,borderRadius:8,padding:16,marginBottom:16},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:8,flexWrap:`wrap`},children:[(0,Z.jsx)(`span`,{style:{fontSize:13,fontWeight:500},children:e(`settings.tunnel.status`)}),(0,Z.jsx)(Th,{status:g?`pass`:`fail`,label:e(g?`settings.tunnel.ngrokInstalled`:`settings.tunnel.ngrokNotInstalled`)})]}),t&&(0,Z.jsxs)(`div`,{style:{fontSize:12,color:`var(--text-dim)`,lineHeight:1.6},children:[t.version&&(0,Z.jsxs)(`div`,{children:[`Version: `,t.version]}),!g&&t.installCommand&&(0,Z.jsxs)(`div`,{style:{marginTop:8},children:[(0,Z.jsx)(`span`,{children:e(`settings.tunnel.install`)}),(0,Z.jsx)(`code`,{style:{background:`var(--bg-glass)`,padding:`2px 8px`,borderRadius:4,fontSize:12},children:t.installCommand}),t.installUrl&&(0,Z.jsx)(`span`,{style:{marginLeft:8},children:(0,Z.jsx)(`a`,{href:t.installUrl,target:`_blank`,rel:`noopener noreferrer`,style:{color:`var(--accent)`},children:e(`settings.tunnel.download`)})})]})]})]}),r&&(0,Z.jsxs)(`div`,{style:{background:`var(--bg-frosted)`,borderRadius:8,padding:16,marginBottom:16},children:[(0,Z.jsx)(`div`,{style:{fontSize:13,fontWeight:500,marginBottom:10},children:e(`settings.tunnel.diagnostics`)}),(0,Z.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6},children:r.providerChecks.map(e=>(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:12,flexWrap:`wrap`},children:[(0,Z.jsx)(Th,{status:e.status,label:e.label}),(0,Z.jsx)(`span`,{style:{color:`var(--text-dim)`,fontSize:11},children:e.detail})]},e.id))}),r.modes.map(t=>(0,Z.jsxs)(`div`,{style:{marginTop:10},children:[(0,Z.jsxs)(`div`,{style:{fontSize:12,fontWeight:500,marginBottom:6,textTransform:`capitalize`},children:[t.mode,` `,e(`settings.tunnel.mode`)]}),t.blockers.length>0&&(0,Z.jsxs)(`div`,{style:{fontSize:11,color:`var(--accent-red, #e06c75)`},children:[e(`settings.tunnel.blockers`),`: `,t.blockers.join(`, `)]})]},t.mode))]}),d&&a?.url&&(0,Z.jsxs)(`div`,{style:{background:`var(--bg-frosted)`,borderRadius:8,padding:16,marginBottom:16,border:`1px solid var(--accent-green, #98c379)`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:8},children:[(0,Z.jsx)(`span`,{style:{width:10,height:10,borderRadius:`50%`,background:`var(--accent-green, #98c379)`}}),(0,Z.jsx)(`span`,{style:{fontSize:13,fontWeight:500},children:e(`settings.tunnel.serverListening`)})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:13,fontFamily:`var(--font-mono, monospace)`,color:`var(--text-primary)`},children:[(0,Z.jsx)(`span`,{children:a.url}),(0,Z.jsx)(Oh,{text:a.url})]}),(0,Z.jsxs)(`div`,{style:{fontSize:11,color:`var(--text-dim)`,marginTop:4},children:[e(`settings.tunnel.provider`),`: `,a.provider,` · `,e(`settings.tunnel.mode`),`: `,a.mode]})]}),l&&(0,Z.jsx)(`div`,{style:{background:`var(--bg-frosted)`,borderRadius:8,padding:12,marginBottom:16,border:`1px solid var(--accent-red, #e06c75)`,fontSize:12,color:`var(--accent-red, #e06c75)`},children:l}),(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,Z.jsx)(`button`,{onClick:m,disabled:!g||d||s===`starting`||s===`stopping`,className:`settings-tab settings-tab-active`,style:{padding:`8px 20px`,fontSize:13,fontWeight:500,border:d?`1px solid var(--accent-green, #98c379)`:`none`,borderRadius:6,cursor:!g||d||s!==`idle`?`not-allowed`:`pointer`,opacity:!g||d||s!==`idle`?.5:1,background:d?`var(--bg-glass)`:`var(--accent)`,color:d?`var(--accent-green, #98c379)`:`#fff`},children:e(s===`starting`?`settings.tunnel.starting`:d?`settings.tunnel.active`:`settings.tunnel.start`)}),(0,Z.jsx)(`button`,{onClick:h,disabled:!d||s!==`idle`,className:`settings-tab`,style:{padding:`8px 20px`,fontSize:13,fontWeight:500,border:`1px solid var(--accent-red, #e06c75)`,borderRadius:6,cursor:!d||s!==`idle`?`not-allowed`:`pointer`,opacity:!d||s!==`idle`?.5:1,background:`var(--bg-glass)`,color:`var(--accent-red, #e06c75)`},children:e(s===`stopping`?`settings.tunnel.stopping`:`settings.tunnel.stop`)}),(0,Z.jsx)(`button`,{onClick:p,className:`settings-tab`,style:{padding:`8px 12px`,fontSize:12,border:`1px solid var(--border)`,borderRadius:6,cursor:`pointer`,background:`var(--bg-glass)`,color:`var(--text-dim)`},title:`Refresh`,children:`↻`})]})]})}function Ah({onClose:e,initialTab:t}){let{t:n}=qo(),r=[`appearance`,`providers`,`agent`,`general`,`packages`,`skills`,`tunnel`],[i,a]=(0,G.useState)(t??`appearance`),[o,s]=(0,G.useState)(void 0),[c,l]=(0,G.useState)(window.innerWidth<=600),u=Y(e=>e.activeProjectId),d=Y(e=>e.projects),f=(0,G.useMemo)(()=>{if(u!==void 0)return d.find(e=>e.id===u)?.path},[u,d]);return(0,G.useEffect)(()=>{let e=()=>l(window.innerWidth<=600);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,G.useEffect)(()=>{r.includes(i)||a(`appearance`)},[i]),(0,G.useEffect)(()=>{t!==void 0&&r.includes(t)?a(t):(t===void 0||!r.includes(t))&&a(`appearance`)},[t]),(0,Z.jsxs)(Yp,{open:!0,onClose:e,header:(0,Z.jsxs)(`header`,{className:`settings-header`,children:[(0,Z.jsx)(`div`,{className:`settings-tabs`,style:{display:`flex`,gap:2,overflowX:c?`auto`:void 0,whiteSpace:`nowrap`,flex:1,minWidth:0,msOverflowStyle:`none`,scrollbarWidth:`none`},children:r.map(e=>(0,Z.jsxs)(`button`,{onClick:()=>a(e),className:`settings-tab ${i===e?`settings-tab-active`:``}`,children:[n(`settings.tabs.${e}`),e===`packages`?` 📦`:e===`tunnel`?` 🚇`:``]},e))}),(0,Z.jsx)(`button`,{onClick:e,className:`settings-close`,title:`Close (Esc)`,style:{flexShrink:0},children:`✕`})]}),style:{width:c?`100vw`:720,maxWidth:`100vw`,height:c?`100dvh`:`85vh`,maxHeight:c?`100dvh`:void 0,borderRadius:c?0:void 0},children:[o!==void 0&&(0,Z.jsx)(`div`,{className:`settings-error`,children:o}),i===`appearance`&&(0,Z.jsx)(Km,{}),i===`providers`&&(0,Z.jsx)(oh,{onError:s}),i===`agent`&&(0,Z.jsx)(sh,{onError:s}),i===`packages`&&(0,Z.jsx)(vh,{onError:s,projectPath:f}),i===`skills`&&(0,Z.jsx)(bh,{onError:s}),i===`tunnel`&&(0,Z.jsx)(kh,{}),i===`general`&&(0,Z.jsx)(lh,{})]})}async function jh(e,t){let n=zt(),r={...t?.headers??{}};return n!==void 0&&(r.Authorization=`Bearer ${n}`),fetch(e,{...t,headers:r})}function Mh({projectId:e}){let[t,n]=(0,G.useState)(void 0),[r,i]=(0,G.useState)(),[a,o]=(0,G.useState)(),[s,c]=(0,G.useState)(),[l,u]=(0,G.useState)(),[d,f]=(0,G.useState)(!1),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(),[y,b]=(0,G.useState)(),[x,S]=(0,G.useState)(new Set),[C,w]=(0,G.useState)({}),[T,D]=(0,G.useState)({}),[O,k]=(0,G.useState)(),[A,j]=(0,G.useState)(``),[M,N]=(0,G.useState)(!1),[P,F]=(0,G.useState)(),[I,L]=(0,G.useState)(),[z,ee]=(0,G.useState)({}),[B,V]=(0,G.useState)({}),H=q(e=>e.openFileViewer),[U,te]=(0,G.useState)(),ne=(0,G.useRef)(void 0),re=()=>{ne.current!==void 0&&clearTimeout(ne.current),te(void 0)};(0,G.useEffect)(()=>()=>{ne.current!==void 0&&clearTimeout(ne.current)},[]);let ie=`pi-kot.gitPanel.viewType`,[ae,oe]=(0,G.useState)(()=>{try{return localStorage.getItem(ie)===`split`?`split`:`unified`}catch{return`unified`}}),se=()=>{let e=ae===`split`?`unified`:`split`;oe(e);try{localStorage.setItem(ie,e)}catch{}},ce=(0,G.useCallback)(async()=>{i(void 0);try{let t=new URLSearchParams({projectId:e}),r=await jh(`/api/v1/git/status?${t}`);if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.message??`status failed`)}let i=await r.json();n(i);let a=new Set(i.files.map(e=>e.path));ee(e=>{let t=!1,n={};for(let[r,i]of Object.entries(e)){let e=r.split(`|`)[0]??``;a.has(e)?n[r]=i:t=!0}return t?n:e}),Promise.all([jh(`/api/v1/git/diff?${t}`).then(e=>e.ok?e.json():{diff:``}),jh(`/api/v1/git/diff/staged?${t}`).then(e=>e.ok?e.json():{diff:``})]).then(([e,t])=>{let n=Bh(e.diff),r=Bh(t.diff),i={...n};for(let[e,t]of Object.entries(r))i[e]?(i[e].additions+=t.additions,i[e].deletions+=t.deletions):i[e]={...t};V(i)}).catch(()=>{})}catch(e){let t=e instanceof Error?e.message:`fetch failed`;i(t),n(void 0)}},[e]);(0,G.useEffect)(()=>{ce()},[ce]);let le=q(e=>e.fileChangeTick);(0,G.useEffect)(()=>{if(le===0)return;let e=setTimeout(()=>void ce(),400);return()=>clearTimeout(e)},[le,ce]),(0,G.useEffect)(()=>{d&&jh(`/api/v1/git/log?${new URLSearchParams({projectId:e,limit:`30`})}`).then(e=>e.json()).then(e=>c(e.commits)).catch(()=>c([]))},[d,e]),(0,G.useEffect)(()=>{p&&jh(`/api/v1/git/branches?${new URLSearchParams({projectId:e})}`).then(e=>e.json()).then(e=>u(e.branches)).catch(()=>u([]))},[p,e]),(0,G.useEffect)(()=>{h&&jh(`/api/v1/git/worktrees?${new URLSearchParams({projectId:e})}`).then(e=>e.json()).then(e=>v(e.worktrees)).catch(()=>v([]))},[h,e]);let ue=async(t,n)=>{let r=`${t.path}|${n?`staged`:`unstaged`}`;if(z[r]!==void 0){ee(e=>{let t={...e};return delete t[r],t});return}ee(e=>({...e,[r]:`loading`}));try{let i=new URLSearchParams({projectId:e,path:t.path});n&&i.set(`staged`,`1`);let a=await jh(`/api/v1/git/diff/file?${i}`);if(!a.ok)throw Error(`diff failed`);let o=await a.json();ee(e=>({...e,[r]:o.diff}))}catch{ee(e=>({...e,[r]:`error`}))}},de=async t=>{if(t.length!==0){N(!0),F(void 0);try{let n=await jh(`/api/v1/git/stage`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({projectId:e,paths:t})});if(!n.ok)throw Error((await n.json().catch(()=>({}))).message??`stage failed`);await ce()}catch(e){F(e instanceof Error?e.message:`stage failed`)}finally{N(!1)}}},fe=async t=>{if(t.length!==0){N(!0),F(void 0);try{if(!(await jh(`/api/v1/git/unstage`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({projectId:e,paths:t})})).ok)throw Error(`unstage failed`);await ce()}catch(e){F(e instanceof Error?e.message:`unstage failed`)}finally{N(!1)}}},pe=async t=>{if(U===t){re(),N(!0),F(void 0);try{if(!(await jh(`/api/v1/git/revert`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({projectId:e,paths:[t]})})).ok)throw Error(`revert failed`);L(`Reverted ${t}`),await ce()}catch(e){F(e instanceof Error?e.message:`revert failed`)}finally{N(!1)}}else re(),te(t),ne.current=setTimeout(()=>te(void 0),3e3)},me=async()=>{let t=A.trim();if(t){N(!0),F(void 0),L(void 0);try{let n=await jh(`/api/v1/git/commit`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({projectId:e,message:t})});if(!n.ok)throw Error((await n.json().catch(()=>({}))).error??`commit failed`);let r=await n.json();if(j(``),L(`Committed ${r.hash.slice(0,7)}`),await ce(),d){let t=await(await jh(`/api/v1/git/log?${new URLSearchParams({projectId:e,limit:`30`})}`)).json();c(t.commits)}}catch(e){F(e instanceof Error?e.message:`commit failed`)}finally{N(!1)}}},he=async()=>{N(!0),F(void 0),L(void 0);try{let t=await jh(`/api/v1/git/push`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({projectId:e})});if(!t.ok)throw Error(`push failed`);let n=await t.json();L(n.output.trim().split(`
132
+ `).pop()??`Pushed`)}catch(e){F(e instanceof Error?e.message:`push failed`)}finally{N(!1)}},ge=async()=>{N(!0),F(void 0),L(void 0);try{let t=await jh(`/api/v1/git/pull`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({projectId:e})});if(!t.ok)throw Error(`pull failed`);let n=await t.json();L(n.output.trim().split(`
133
+ `).pop()??`Pulled`),await ce()}catch(e){F(e instanceof Error?e.message:`pull failed`)}finally{N(!1)}},_e=async()=>{N(!0),F(void 0),L(void 0);try{let t=await jh(`/api/v1/git/fetch`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({projectId:e})});if(!t.ok)throw Error(`fetch failed`);let n=await t.json();L(n.output.trim().split(`
134
+ `).pop()??`Fetched`)}catch(e){F(e instanceof Error?e.message:`fetch failed`)}finally{N(!1)}},ve=async t=>{o(t),F(void 0);try{if(!(await jh(`/api/v1/git/checkout`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({projectId:e,branch:t})})).ok)throw Error(`checkout failed`);await Promise.all([ce(),ye()])}catch(e){F(e instanceof Error?e.message:`checkout failed`)}finally{o(void 0)}},ye=async()=>{let t=new URLSearchParams({projectId:e});try{let e=await(await jh(`/api/v1/git/branches?${t}`)).json();u(e.branches)}catch{}},be=async()=>{let t=new URLSearchParams({projectId:e});try{let e=await(await jh(`/api/v1/git/worktrees?${t}`)).json();v(e.worktrees)}catch{}},xe=async t=>{b(t),F(void 0),L(void 0);try{let n=await jh(`/api/v1/git/worktree/add`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({projectId:e,commitHash:t})});if(!n.ok)throw Error(`worktree creation failed`);let r=await n.json();L(`Worktree created at ${r.path}`),h&&await be()}catch(e){F(e instanceof Error?e.message:`worktree creation failed`)}finally{b(void 0)}},Se=async t=>{b(t),F(void 0),L(void 0);try{if(!(await jh(`/api/v1/git/worktree/remove`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({projectId:e,worktreePath:t})})).ok)throw Error(`worktree removal failed`);L(`Removed worktree at ${t}`),await be()}catch(e){F(e instanceof Error?e.message:`worktree removal failed`)}finally{b(void 0)}},Ce=(0,G.useCallback)(async t=>{let n=t,r=C[n];if(!(r!==void 0&&r.state===`loaded`)){w(e=>({...e,[n]:{state:`loading`}}));try{let r=await jh(`/api/v1/git/commit/files?${new URLSearchParams({projectId:e,hash:t})}`);if(!r.ok)throw Error(`commit files fetch failed`);let i=await r.json();w(e=>({...e,[n]:{state:`loaded`,value:i.files}}))}catch(e){w(t=>({...t,[n]:{state:`error`,message:e instanceof Error?e.message:`unknown error`}}))}}},[e,C]),we=(0,G.useCallback)(async(t,n)=>{let r=`${t}|${n}`,i=T[r];if(i!==void 0&&i.state===`loaded`){D(e=>{let t={...e};return delete t[r],t});return}D(e=>({...e,[r]:{state:`loading`}}));try{let i=await jh(`/api/v1/git/commit/diff?${new URLSearchParams({projectId:e,hash:t,path:n})}`);if(!i.ok)throw Error(`commit diff fetch failed`);let a=await i.json();D(e=>({...e,[r]:{state:`loaded`,value:a.diff}}))}catch(e){D(t=>({...t,[r]:{state:`error`,message:e instanceof Error?e.message:`unknown error`}}))}},[e,T]),Te=(0,G.useCallback)(e=>{S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),Ce(e)},[Ce]);if(t?.isGitRepo===!1)return(0,Z.jsxs)(`div`,{style:{padding:`24px 16px`,textAlign:`center`},children:[(0,Z.jsx)(`p`,{style:{fontSize:`12px`,color:`var(--text-dim)`,marginBottom:`12px`},children:`This project isn't a git repository.`}),(0,Z.jsx)(`button`,{onClick:async()=>{N(!0),F(void 0);try{if(!(await jh(`/api/v1/git/init`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({projectId:e})})).ok)throw Error(`init failed`);await ce()}catch(e){F(e instanceof Error?e.message:`init failed`)}finally{N(!1)}},disabled:M,style:{padding:`6px 14px`,fontSize:`12px`,fontWeight:600,background:`var(--accent-bg)`,color:`var(--accent-text)`,border:`1px solid var(--border)`,borderRadius:`var(--radius-sm)`,cursor:M?`default`:`pointer`,opacity:M?.5:1},children:M?`Initializing…`:`Initialize git repo`}),P&&(0,Z.jsx)(`p`,{style:{fontSize:`10px`,color:`var(--error)`,marginTop:`8px`},children:P})]});let Ee=t?.files.filter(e=>e.staged)??[];t?.files.filter(e=>e.unstaged&&!e.staged);let De=t?.files.filter(e=>e.unstaged)??[],Oe=t?.files.filter(e=>e.kind===`untracked`)??[];return(0,Z.jsxs)(`div`,{style:{fontSize:`13px`,color:`var(--text-secondary)`,display:`flex`,flexDirection:`column`,height:`100%`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`8px 12px`,borderBottom:`1px solid var(--border)`,background:`var(--bg-glass)`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,fontWeight:500,color:`var(--text-primary)`,fontSize:`13px`},children:[(0,Z.jsx)(`span`,{style:{fontWeight:700,display:`inline-flex`,alignItems:`center`,gap:`5px`},children:t?.branch?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{color:`var(--accent-text)`,flexShrink:0},children:[(0,Z.jsx)(`line`,{x1:`6`,y1:`3`,x2:`6`,y2:`15`}),(0,Z.jsx)(`circle`,{cx:`18`,cy:`6`,r:`3`}),(0,Z.jsx)(`circle`,{cx:`6`,cy:`18`,r:`3`}),(0,Z.jsx)(`path`,{d:`M18 9a9 9 0 0 1-9 9`})]}),(0,Z.jsx)(`span`,{children:t.branch})]}):`—`}),t&&t.files.length>0&&(0,Z.jsx)(`span`,{style:{borderRadius:`var(--radius-sm)`,background:`var(--bg-glass)`,padding:`2px 6px`,fontSize:`10px`,color:`var(--text-dim)`},children:t.files.length})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`2px`},children:[(0,Z.jsx)(`button`,{onClick:se,className:`fe-toolbar-btn`,title:ae===`split`?`Switch to unified view`:`Switch to side-by-side view`,type:`button`,children:ae===`split`?(0,Z.jsx)(R,{size:13}):(0,Z.jsx)(E,{size:13})}),(0,Z.jsx)(`button`,{onClick:ce,title:`Refresh`,className:`fe-toolbar-btn`,type:`button`,children:(0,Z.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:M?{animation:`spin 1s linear infinite`}:void 0,children:[(0,Z.jsx)(`polyline`,{points:`23 4 23 10 17 10`}),(0,Z.jsx)(`polyline`,{points:`1 20 1 14 7 14`}),(0,Z.jsx)(`path`,{d:`M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15`})]})})]})]}),(r||P)&&(0,Z.jsx)(`div`,{style:{padding:`4px 12px`,fontSize:`10px`,color:`var(--error)`,background:`rgba(248,113,113,0.08)`,borderBottom:`1px solid var(--border)`},children:P??r}),I&&(0,Z.jsx)(`div`,{style:{padding:`4px 12px`,fontSize:`10px`,color:`var(--accent-text)`,background:`rgba(152,195,121,0.08)`,borderBottom:`1px solid var(--border)`},children:I}),(0,Z.jsxs)(`div`,{style:{flex:1,overflowY:`auto`,overflowX:`hidden`,display:`flex`,flexDirection:`column`},children:[t===void 0&&(0,Z.jsx)(`div`,{style:{padding:`16px`,textAlign:`center`,color:`var(--text-dim)`,fontSize:`11px`},children:`Loading git status…`}),Ee.length>0&&(0,Z.jsx)(Nh,{label:`Staged (${Ee.length})`,files:Ee,onFileAction:e=>fe([e.path]),fileActionLabel:`Unstage`,groupActionLabel:`Unstage all`,onGroupAction:()=>fe(Ee.map(e=>e.path)),onClickFile:e=>ue(e,!0),openDiffs:z,staged:!0,viewType:ae,diffStats:B,onOpenFile:H,onToggleViewType:se}),De.length>0&&(0,Z.jsx)(Nh,{label:`Changes (${De.length})`,files:De,onFileAction:e=>de([e.path]),fileActionLabel:`Stage`,groupActionLabel:`Stage all`,onGroupAction:()=>de(De.map(e=>e.path)),onClickFile:e=>ue(e,!1),onRevert:e=>pe(e.path),pendingRevert:U,openDiffs:z,staged:!1,viewType:ae,diffStats:B,onOpenFile:H,onToggleViewType:se}),Oe.length>0&&(0,Z.jsx)(Nh,{label:`Untracked (${Oe.length})`,files:Oe,onFileAction:e=>de([e.path]),fileActionLabel:`Stage`,groupActionLabel:`Stage all`,onGroupAction:()=>de(Oe.map(e=>e.path)),onClickFile:e=>ue(e,!1),openDiffs:z,staged:!1,viewType:ae,diffStats:B,onOpenFile:H,onToggleViewType:se}),t?.files.length===0&&(0,Z.jsx)(`div`,{style:{padding:`16px`,textAlign:`center`,color:`var(--text-dim)`,fontSize:`11px`},children:`Working tree clean.`})]}),(0,Z.jsxs)(`div`,{style:{flexShrink:0,overflowY:`auto`,maxHeight:`40%`,borderTop:`1px solid var(--border)`,background:`var(--bg-subtle)`},children:[(0,Z.jsxs)(`div`,{style:{borderTop:`1px solid var(--border)`},children:[(0,Z.jsxs)(`button`,{onClick:()=>f(e=>!e),className:`git-section-toggle`,type:`button`,children:[(0,Z.jsx)(`span`,{children:`Log`}),(0,Z.jsx)(`span`,{className:`git-section-chevron${d?` open`:``}`,children:`▾`})]}),d&&(0,Z.jsx)(`div`,{style:{padding:`0 12px 8px`},children:s===void 0?(0,Z.jsx)(`div`,{style:{fontSize:`10px`,color:`var(--text-dim)`,fontStyle:`italic`},children:`Loading…`}):s.length===0?(0,Z.jsx)(`div`,{style:{fontSize:`10px`,color:`var(--text-dim)`,fontStyle:`italic`},children:`No commits yet.`}):(0,Z.jsx)(`ul`,{style:{listStyle:`none`,padding:0,margin:0,maxHeight:`180px`,overflowY:`auto`},children:s.map(e=>{let t=y===e.hash,n=x.has(e.hash),r=C[e.hash];return(0,Z.jsxs)(`li`,{style:{borderBottom:`1px solid var(--border)`,fontSize:`11px`},children:[(0,Z.jsxs)(`div`,{onClick:()=>Te(e.hash),style:{display:`flex`,gap:`6px`,alignItems:`baseline`,padding:`4px 0`,cursor:`pointer`},children:[(0,Z.jsx)(`span`,{style:{fontSize:`8px`,color:`var(--text-dim)`,width:`10px`,flexShrink:0},children:n?`▾`:`▸`}),(0,Z.jsx)(`code`,{style:{fontSize:`10px`,color:`var(--text-dim)`,fontFamily:`monospace`},children:e.hash.slice(0,7)}),(0,Z.jsx)(`span`,{style:{color:`var(--text-primary)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,flex:1},children:e.message}),(0,Z.jsx)(`button`,{onClick:t=>{t.stopPropagation(),xe(e.hash)},disabled:t,title:`Try this commit in a linked worktree`,className:`git-try-btn`,type:`button`,children:t?`…`:`Try →`})]}),(0,Z.jsxs)(`div`,{style:{fontSize:`9px`,color:`var(--text-dim)`,paddingLeft:`16px`,marginBottom:n?4:0},children:[e.author,` · `,new Date(e.date).toLocaleString()]}),n&&(0,Z.jsx)(`div`,{style:{padding:`0 0 4px 16px`},children:r===void 0||r.state===`loading`?(0,Z.jsx)(`div`,{style:{fontSize:`9px`,color:`var(--text-dim)`,fontStyle:`italic`},children:`Loading files…`}):r.state===`error`?(0,Z.jsx)(`div`,{style:{fontSize:`9px`,color:`var(--error)`},children:r.message}):r.value.length===0?(0,Z.jsx)(`div`,{style:{fontSize:`9px`,color:`var(--text-dim)`,fontStyle:`italic`},children:`(no files)`}):(0,Z.jsx)(`ul`,{style:{listStyle:`none`,padding:0,margin:0},children:r.value.map(t=>{let n=`${e.hash}|${t.path}`,r=T[n];return(0,Z.jsxs)(`li`,{style:{borderTop:`1px solid var(--border)`},children:[(0,Z.jsxs)(`div`,{onClick:()=>we(e.hash,t.path),style:{display:`flex`,alignItems:`center`,gap:`4px`,padding:`3px 4px`,cursor:`pointer`,fontSize:`10px`,fontFamily:`monospace`,background:r!==void 0&&r.state===`loaded`?`var(--accent-subtle)`:`transparent`},children:[(0,Z.jsx)(`span`,{style:{width:`14px`,flexShrink:0,textAlign:`center`,fontWeight:700,fontSize:`10px`,color:Uh(t.changeType)},children:Hh(t.changeType)}),(0,Z.jsx)(`span`,{style:{flex:1,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,color:`var(--text-primary)`},children:t.path}),(0,Z.jsx)(`span`,{style:{fontSize:`8px`,color:`var(--text-dim)`},children:r!==void 0&&r.state===`loaded`?`▾`:`▸`})]}),r!==void 0&&r.state===`loaded`&&(0,Z.jsx)(`div`,{style:{borderTop:`1px solid var(--border)`,background:`var(--bg-glass)`,padding:`4px 8px`,overflow:`hidden`},children:(0,Z.jsx)(Dd,{diff:r.value,viewType:ae})}),r!==void 0&&r.state===`loading`&&(0,Z.jsx)(`div`,{style:{fontSize:`9px`,color:`var(--text-dim)`,fontStyle:`italic`,padding:`2px 8px`},children:`Loading diff…`}),r!==void 0&&r.state===`error`&&(0,Z.jsx)(`div`,{style:{fontSize:`9px`,color:`var(--error)`,padding:`2px 8px`},children:r.message})]},t.path)})})})]},e.hash)})})})]}),(0,Z.jsxs)(`div`,{style:{borderTop:`1px solid var(--border)`},children:[(0,Z.jsxs)(`button`,{onClick:()=>g(e=>!e),className:`git-section-toggle`,type:`button`,children:[(0,Z.jsx)(`span`,{children:`Worktrees`}),(0,Z.jsx)(`span`,{className:`git-section-chevron${h?` open`:``}`,children:`▾`})]}),h&&(0,Z.jsx)(`div`,{style:{padding:`0 12px 8px`},children:_===void 0?(0,Z.jsx)(`div`,{style:{fontSize:`10px`,color:`var(--text-dim)`,fontStyle:`italic`},children:`Loading…`}):_.length===0?(0,Z.jsx)(`div`,{style:{fontSize:`10px`,color:`var(--text-dim)`,fontStyle:`italic`},children:`No worktrees.`}):(0,Z.jsx)(`ul`,{style:{listStyle:`none`,padding:0,margin:0},children:_.filter(e=>!e.current).map(e=>{let t=y===e.path,n=O===e.path;return(0,Z.jsxs)(`li`,{style:{display:`flex`,alignItems:`center`,gap:`4px`,padding:`3px 4px`,borderRadius:`var(--radius-sm)`,fontSize:`10px`,fontFamily:`monospace`,color:`var(--text-secondary)`},children:[(0,Z.jsx)(`span`,{style:{flex:1,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.path}),e.head&&(0,Z.jsx)(`span`,{style:{fontSize:`9px`,color:`var(--text-dim)`},children:e.head.slice(0,7)}),(0,Z.jsx)(`button`,{onClick:()=>{Ph(e.path),k(e.path),setTimeout(()=>k(void 0),1500)},title:`Copy path`,style:{background:`none`,border:`none`,cursor:`pointer`,fontSize:`10px`,color:n?`var(--accent-text)`:`var(--text-dim)`,padding:`2px 4px`,opacity:.8,display:`inline-flex`,alignItems:`center`},type:`button`,children:n?(0,Z.jsx)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,Z.jsx)(`polyline`,{points:`20 6 9 17 4 12`})}):(0,Z.jsxs)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`,ry:`2`}),(0,Z.jsx)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})]})}),(0,Z.jsx)(`button`,{onClick:()=>Se(e.path),disabled:t,style:{background:`none`,border:`none`,cursor:`pointer`,fontSize:`10px`,color:`var(--error)`,padding:`1px 4px`,opacity:t?.4:.7},type:`button`,children:t?`…`:`✕`})]},e.path)})})})]}),(0,Z.jsxs)(`div`,{style:{borderTop:`1px solid var(--border)`},children:[(0,Z.jsxs)(`button`,{onClick:()=>m(e=>!e),className:`git-section-toggle`,type:`button`,children:[(0,Z.jsx)(`span`,{children:`Branches`}),(0,Z.jsx)(`span`,{className:`git-section-chevron${p?` open`:``}`,children:`▾`})]}),p&&(0,Z.jsx)(`div`,{style:{padding:`0 12px 8px`},children:l===void 0?(0,Z.jsx)(`div`,{style:{fontSize:`10px`,color:`var(--text-dim)`,fontStyle:`italic`},children:`Loading…`}):l.length===0?(0,Z.jsx)(`div`,{style:{fontSize:`10px`,color:`var(--text-dim)`,fontStyle:`italic`},children:`No branches.`}):(0,Z.jsx)(`ul`,{style:{listStyle:`none`,padding:0,margin:0},children:l.map(e=>{let t=a===e.name;return(0,Z.jsxs)(`li`,{style:{display:`flex`,alignItems:`center`,gap:`4px`,padding:`3px 4px`,borderRadius:`var(--radius-sm)`,fontSize:`11px`,fontFamily:`monospace`,color:e.current?`var(--accent-text)`:`var(--text-secondary)`},children:[(0,Z.jsx)(`span`,{style:{width:`12px`,flexShrink:0},children:e.current?`✓`:``}),(0,Z.jsx)(`span`,{style:{flex:1,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.name}),e.remote&&(0,Z.jsx)(`span`,{style:{fontSize:`9px`,color:`var(--text-dim)`},children:`remote`}),!e.current&&!e.remote&&(0,Z.jsx)(`div`,{style:{display:`flex`,gap:`2px`},children:(0,Z.jsx)(`button`,{onClick:()=>ve(e.name),disabled:t,style:{background:`none`,border:`none`,cursor:`pointer`,fontSize:`10px`,color:`var(--text-dim)`,padding:`1px 4px`,opacity:t?.4:.7},type:`button`,children:`checkout`})})]},e.name)})})})]})]}),(0,Z.jsxs)(`div`,{style:{flexShrink:0,borderTop:`1px solid var(--border)`,background:`var(--bg-solid)`},children:[(0,Z.jsxs)(`div`,{style:{padding:`10px 12px 8px`},children:[(0,Z.jsx)(`textarea`,{value:A,onChange:e=>j(e.target.value),placeholder:`Commit message…`,rows:3,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&me()},style:{width:`100%`,resize:`none`,fontSize:`12px`,background:`var(--bg-glass)`,border:`1px solid var(--border)`,borderRadius:`var(--radius-sm)`,padding:`8px 10px`,color:`var(--text-primary)`,outline:`none`,fontFamily:`inherit`,lineHeight:1.5,transition:`border-color 0.12s ease`},onFocus:e=>{e.target.style.borderColor=`var(--border-bright)`},onBlur:e=>{e.target.style.borderColor=`var(--border)`}}),(0,Z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginTop:`6px`},children:[(0,Z.jsxs)(`span`,{style:{fontSize:`11px`,color:`var(--text-dim)`},children:[Ee.length>0?(0,Z.jsxs)(`span`,{style:{color:`var(--accent-text)`},children:[Ee.length,` staged`]}):(0,Z.jsx)(`span`,{children:`0 staged`}),(0,Z.jsx)(`span`,{style:{opacity:.5,marginLeft:`4px`,fontSize:`10px`},children:`⌘↵ to commit`})]}),(0,Z.jsx)(`button`,{onClick:me,disabled:M||Ee.length===0||!A.trim(),className:`git-action-btn git-commit-btn ${Ee.length>0&&A.trim()?`ready`:`disabled`}`,type:`button`,children:`Commit`})]})]}),(0,Z.jsx)(`div`,{style:{padding:`0 12px 10px`},children:(0,Z.jsxs)(`div`,{className:`git-remote-group`,children:[(0,Z.jsxs)(`button`,{onClick:_e,disabled:M,className:`git-remote-group-btn`,type:`button`,title:`Fetch from remote`,children:[(0,Z.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{marginRight:`4px`},children:[(0,Z.jsx)(`polyline`,{points:`23 4 23 10 17 10`}),(0,Z.jsx)(`polyline`,{points:`1 20 1 14 7 14`}),(0,Z.jsx)(`path`,{d:`M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15`})]}),`Fetch`]}),(0,Z.jsxs)(`button`,{onClick:ge,disabled:M,className:`git-remote-group-btn`,type:`button`,title:`Pull from remote`,children:[(0,Z.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{marginRight:`4px`},children:[(0,Z.jsx)(`line`,{x1:`12`,y1:`5`,x2:`12`,y2:`19`}),(0,Z.jsx)(`polyline`,{points:`19 12 12 19 5 12`})]}),`Pull`]}),(0,Z.jsxs)(`button`,{onClick:he,disabled:M,className:`git-remote-group-btn`,type:`button`,title:`Push to remote`,children:[(0,Z.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{marginRight:`4px`},children:[(0,Z.jsx)(`line`,{x1:`12`,y1:`19`,x2:`12`,y2:`5`}),(0,Z.jsx)(`polyline`,{points:`5 12 12 5 19 12`})]}),`Push`]})]})})]})]})}function Nh(e){return(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`8px 14px`,borderBottom:`1px solid var(--border)`,background:`var(--accent-subtle)`},children:[(0,Z.jsx)(`span`,{style:{fontSize:`11px`,fontWeight:700,textTransform:`uppercase`,letterSpacing:`0.5px`,color:`var(--text-secondary)`},children:e.label}),(0,Z.jsx)(`button`,{onClick:e.onGroupAction,className:`git-action-btn git-group-action-btn`,type:`button`,children:e.groupActionLabel})]}),(0,Z.jsx)(`ul`,{style:{listStyle:`none`,padding:0,margin:0},children:e.files.map(t=>{let n=`${t.path}|${e.staged?`staged`:`unstaged`}`,i=e.openDiffs[n],a=i!==void 0,{fileName:o,dirPath:s}=zh(t.path),c=Vh(t,e.staged,e.diffStats,e.openDiffs);return(0,Z.jsxs)(`li`,{style:{borderBottom:`1px solid var(--border)`},children:[(0,Z.jsxs)(`div`,{className:`git-file-row${a?` diff-open`:``}`,style:{display:`flex`,alignItems:`center`,gap:`8px`,padding:`6px 12px`,background:a?`var(--bg-glass-active)`:void 0},children:[(0,Z.jsx)(`span`,{style:{width:`18px`,height:`18px`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`var(--radius-xs, 3px)`,fontSize:`10px`,fontFamily:`monospace`,fontWeight:700,flexShrink:0,color:Lh(t.kind),background:Rh(t.kind)},title:t.kind,children:Ih(t.kind)}),(0,Z.jsxs)(`div`,{onClick:()=>e.onClickFile(t),style:{flex:1,minWidth:0,display:`flex`,flexDirection:`column`,gap:`1px`,cursor:`pointer`,padding:`2px 0`},role:`button`,tabIndex:0,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),e.onClickFile(t))},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`6px`,minWidth:0},children:[(0,Z.jsx)(`span`,{style:{fontWeight:600,fontSize:`12px`,color:`var(--text-primary)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:o}),c&&(c.additions>0||c.deletions>0)&&(0,Z.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:`3px`,fontSize:`10px`,fontFamily:`monospace`,flexShrink:0},children:[c.additions>0&&(0,Z.jsxs)(`span`,{style:{color:`var(--accent-text, #4ade80)`},children:[`+`,c.additions]}),c.deletions>0&&(0,Z.jsxs)(`span`,{style:{color:`var(--error, #f87171)`},children:[`-`,c.deletions]})]})]}),s&&(0,Z.jsx)(`span`,{style:{fontSize:`10px`,color:`var(--text-dim)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,fontFamily:`monospace`},title:t.path,children:s})]}),(0,Z.jsxs)(`div`,{className:`git-file-actions${e.pendingRevert===t.path?` has-pending`:``}`,children:[e.onOpenFile&&(0,Z.jsx)(`button`,{onClick:n=>{n.stopPropagation(),e.onOpenFile(t.path,o)},className:`git-icon-btn`,title:`Open in editor`,type:`button`,children:(0,Z.jsx)(f,{size:12})}),e.onRevert&&(0,Z.jsx)(`button`,{onClick:n=>{n.stopPropagation(),e.onRevert(t)},className:`git-icon-btn danger${e.pendingRevert===t.path?` pending`:``}`,title:`Discard changes`,style:e.pendingRevert===t.path?{width:`auto`,padding:`2px 6px`,fontSize:`10px`,color:`var(--error)`,fontWeight:600,background:`rgba(248, 113, 113, 0.15)`,borderColor:`rgba(248, 113, 113, 0.3)`}:void 0,type:`button`,children:e.pendingRevert===t.path?`Confirm?`:(0,Z.jsx)(L,{size:12})}),(0,Z.jsx)(`button`,{onClick:n=>{n.stopPropagation(),e.onFileAction(t)},className:`git-icon-btn`,title:e.staged?`Unstage file`:`Stage file`,type:`button`,children:e.staged?(0,Z.jsx)(S,{size:13}):(0,Z.jsx)(fe,{size:13})}),(0,Z.jsx)(`button`,{onClick:n=>{n.stopPropagation(),e.onClickFile(t)},className:`git-icon-btn`,title:a?`Collapse diff`:`Show diff`,type:`button`,children:a?(0,Z.jsx)(r,{size:13}):(0,Z.jsx)(b,{size:13})})]})]}),a&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`git-diff-header`,style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`4px 10px`,background:`var(--bg-glass-active, rgba(255, 255, 255, 0.05))`,borderTop:`1px solid var(--border)`,borderBottom:`1px solid var(--border)`,fontSize:`11px`,minWidth:0},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`6px`,minWidth:0,overflow:`hidden`},children:[(0,Z.jsx)(`span`,{style:{fontWeight:600,color:`var(--text-secondary)`,fontSize:`11px`},children:`Diff`}),(0,Z.jsx)(`span`,{style:{color:`var(--text-dim)`,fontSize:`10px`},children:`•`}),(0,Z.jsx)(`span`,{style:{color:`var(--text-primary)`,fontFamily:`monospace`,fontWeight:600,fontSize:`11px`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},title:t.path,children:o}),c&&(c.additions>0||c.deletions>0)&&(0,Z.jsxs)(`span`,{style:{fontSize:`10px`,fontFamily:`monospace`,flexShrink:0},children:[c.additions>0&&(0,Z.jsxs)(`span`,{style:{color:`var(--accent-text, #4ade80)`},children:[`+`,c.additions]}),` `,c.deletions>0&&(0,Z.jsxs)(`span`,{style:{color:`var(--error, #f87171)`},children:[`-`,c.deletions]})]})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`2px`,flexShrink:0},children:[e.onToggleViewType&&(0,Z.jsx)(`button`,{type:`button`,onClick:e.onToggleViewType,className:`fe-toolbar-btn`,title:e.viewType===`split`?`Unified view`:`Side-by-side view`,style:{padding:`3px 6px`},children:e.viewType===`split`?(0,Z.jsx)(R,{size:12}):(0,Z.jsx)(E,{size:12})}),e.onOpenFile&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>e.onOpenFile(t.path,o),className:`fe-toolbar-btn`,title:`Open file in editor`,style:{padding:`3px 6px`},children:(0,Z.jsx)(f,{size:12})}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>e.onFileAction(t),className:`fe-toolbar-btn`,title:e.staged?`Unstage this file`:`Stage this file`,style:{padding:`2px 7px`,fontSize:`10px`,fontWeight:600,borderRadius:`var(--radius-xs, 3px)`,border:`1px solid var(--border-bright)`,background:`var(--accent-subtle)`,color:`var(--accent-text)`},children:e.staged?`Unstage`:`Stage`}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>e.onClickFile(t),className:`fe-toolbar-btn`,title:`Close diff preview`,style:{padding:`3px 5px`,color:`var(--text-dim)`},children:(0,Z.jsx)(te,{size:12})})]})]}),(0,Z.jsx)(`div`,{style:{background:`var(--bg-glass)`,padding:`4px 8px`,overflow:`hidden`},children:i===`loading`?(0,Z.jsx)(`div`,{style:{fontSize:`10px`,color:`var(--text-dim)`,fontStyle:`italic`,padding:`8px`},children:`Loading diff…`}):i===`error`?(0,Z.jsx)(`div`,{style:{fontSize:`10px`,color:`var(--error)`,padding:`8px`},children:`Failed to load diff.`}):i.length===0?(0,Z.jsx)(`div`,{style:{fontSize:`10px`,color:`var(--text-dim)`,fontStyle:`italic`,padding:`8px`},children:`(no diff)`}):(0,Z.jsx)(Dd,{diff:i,viewType:e.viewType})})]})]},t.path)})})]})}function Ph(e){navigator.clipboard?.writeText===void 0?Fh(e):navigator.clipboard.writeText(e).catch(()=>{Fh(e)})}function Fh(e){let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,t.style.pointerEvents=`none`,document.body.appendChild(t),t.select();try{document.execCommand(`copy`)}catch{}document.body.removeChild(t)}function Ih(e){switch(e){case`modified`:return`M`;case`added`:return`A`;case`deleted`:return`D`;case`renamed`:return`R`;case`copied`:return`C`;case`untracked`:return`?`;case`ignored`:return`!`;case`conflicted`:return`U`;default:return`·`}}function Lh(e){switch(e){case`modified`:return`var(--accent-text, #e5c07b)`;case`added`:return`#98c379`;case`deleted`:return`var(--error, #e06c75)`;case`untracked`:return`#61afef`;case`conflicted`:return`var(--error, #e06c75)`;default:return`var(--text-dim)`}}function Rh(e){switch(e){case`modified`:return`var(--accent-subtle, rgba(229, 192, 123, 0.12))`;case`added`:return`rgba(152, 195, 121, 0.12)`;case`deleted`:return`rgba(248, 113, 113, 0.12)`;case`untracked`:return`rgba(97, 175, 239, 0.12)`;case`conflicted`:return`rgba(224, 108, 117, 0.15)`;default:return`transparent`}}function zh(e){let t=e.lastIndexOf(`/`);return t===-1?{fileName:e,dirPath:``}:{fileName:e.slice(t+1),dirPath:e.slice(0,t)}}function Bh(e){let t={};if(!e)return t;let n;for(let r of e.split(`
135
+ `))if(r.startsWith(`diff --git `)){let e=r.split(` `);n=e[e.length-1]?.replace(/^b\//,``),n&&!t[n]&&(t[n]={additions:0,deletions:0})}else n&&!r.startsWith(`+++`)&&!r.startsWith(`---`)&&(r.startsWith(`+`)?t[n].additions++:r.startsWith(`-`)&&t[n].deletions++);return t}function Vh(e,t,n,r){if(n&&n[e.path])return n[e.path];if(r){let n=r[`${e.path}|${t?`staged`:`unstaged`}`];if(typeof n==`string`&&n.length>0){let e=0,t=0;for(let r of n.split(`
136
+ `))r.startsWith(`+++`)||r.startsWith(`---`)||r.startsWith(`@@`)||(r.startsWith(`+`)?e++:r.startsWith(`-`)&&t++);return{additions:e,deletions:t}}}}function Hh(e){switch(e){case`A`:return`A`;case`M`:return`M`;case`D`:return`D`;case`R`:return`R`;case`C`:return`C`;default:return`·`}}function Uh(e){switch(e){case`M`:return`var(--accent-text)`;case`A`:return`#98c379`;case`D`:return`var(--error)`;default:return`var(--text-dim)`}}var Wh=2e4;function Gh({projectId:e}){let[t,n]=(0,G.useState)(``),[r,i]=(0,G.useState)(``),[a,o]=(0,G.useState)(!0),[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(),d=new Blob([t]).size,f=d>Wh,p=t!==r;(0,G.useEffect)(()=>{let t=!1;return o(!0),u(void 0),on(e).then(({addendum:e})=>{t||(n(e),i(e))}).catch(e=>{t||u(e instanceof Error?e.message:`Failed to load`)}).finally(()=>{t||o(!1)}),()=>{t=!0}},[e]);let m=(0,G.useCallback)(async()=>{if(!(!p||f)){c(!0),u(void 0);try{await sn(e,t),i(t)}catch(e){u(e instanceof Error?e.message:`Failed to save`)}finally{c(!1)}}},[p,f,t,e]);return(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`,background:`transparent`,fontSize:`13px`,color:`var(--text-primary)`},children:[(0,Z.jsxs)(`p`,{style:{margin:`12px 16px 8px`,fontSize:`12px`,lineHeight:1.6,color:`var(--text-dim)`,flexShrink:0},children:[`Appended to the agent's base system prompt for every session in this project.`,(0,Z.jsxs)(`span`,{style:{display:`block`,marginTop:`2px`,color:f?`var(--error)`:`var(--text-ghost)`,fontSize:`11px`},children:[d.toLocaleString(),` / `,Wh.toLocaleString(),` B used`]})]}),l!==void 0&&(0,Z.jsx)(`div`,{style:{margin:`0 16px 8px`,padding:`6px 10px`,borderRadius:`var(--radius-sm)`,background:`color-mix(in srgb, var(--error) 12%, transparent)`,color:`var(--error)`,fontSize:`12px`,flexShrink:0},children:l}),(0,Z.jsx)(`div`,{style:{flex:1,padding:`0 16px 8px`,display:`flex`,flexDirection:`column`,minHeight:0},children:a?(0,Z.jsx)(`div`,{style:{flex:1,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`var(--text-dim)`,fontSize:`12px`},children:`Loading…`}):(0,Z.jsx)(`textarea`,{value:t,onChange:e=>n(e.target.value),placeholder:`e.g. Always run tests before telling the user the code is ready.`,style:{flex:1,width:`100%`,resize:`none`,outline:`none`,background:`var(--input-bg)`,color:`var(--text-primary)`,border:`1px solid var(--border)`,borderRadius:`var(--radius-sm)`,padding:`12px 14px`,fontSize:`13px`,lineHeight:1.7,fontFamily:`'SF Mono', 'Fira Code', 'Cascadia Code', monospace`,transition:`border-color 0.12s ease`},onFocus:e=>{e.target.style.borderColor=`var(--border-bright)`},onBlur:e=>{e.target.style.borderColor=`var(--border)`}})}),(0,Z.jsxs)(`div`,{style:{padding:`8px 16px 14px`,display:`flex`,gap:`8px`,alignItems:`center`,flexShrink:0,justifyContent:`space-between`,borderTop:`1px solid var(--border)`},children:[(0,Z.jsx)(`span`,{style:{fontSize:`11px`,color:`var(--text-dim)`},children:p?`• Unsaved changes`:`All changes saved`}),(0,Z.jsx)(`button`,{onClick:m,disabled:!p||s||f,style:{padding:`7px 20px`,fontSize:`13px`,fontWeight:600,border:`none`,borderRadius:`var(--radius-sm)`,cursor:`pointer`,background:p&&!f?`var(--accent)`:`var(--bg-glass-strong)`,color:p&&!f?`white`:`var(--text-dim)`,opacity:!p||s?.6:1,transition:`all 0.12s ease`},type:`button`,children:s?`Saving…`:`Save`})]})]})}function Kh(e,t=13){let n=e.split(`.`).pop()?.toLowerCase()??``;return n===`html`||n===`htm`?(0,Z.jsxs)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`#ea580c`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:[(0,Z.jsx)(`polyline`,{points:`16 18 22 12 16 6`}),(0,Z.jsx)(`polyline`,{points:`8 6 2 12 8 18`})]}):n===`ts`||n===`tsx`?(0,Z.jsxs)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`#38bdf8`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:[(0,Z.jsx)(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`}),(0,Z.jsx)(`polyline`,{points:`14 2 14 8 20 8`})]}):n===`js`||n===`jsx`||n===`mjs`||n===`cjs`?(0,Z.jsxs)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`#facc15`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:[(0,Z.jsx)(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`}),(0,Z.jsx)(`polyline`,{points:`14 2 14 8 20 8`})]}):n===`json`?(0,Z.jsxs)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`#10b981`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:[(0,Z.jsx)(`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5a2 2 0 0 0 2 2h1`}),(0,Z.jsx)(`path`,{d:`M16 3h1a2 2 0 0 1 2 2v5a2 2 0 0 0 2 2 2 2 0 0 0-2 2v5a2 2 0 0 1-2 2h-1`})]}):n===`css`||n===`scss`||n===`less`?(0,Z.jsxs)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`#06b6d4`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:[(0,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,Z.jsx)(`path`,{d:`m4.93 4.93 14.14 14.14`})]}):n===`md`||n===`markdown`||n===`mdx`?(0,Z.jsxs)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`#a855f7`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:[(0,Z.jsx)(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`}),(0,Z.jsx)(`polyline`,{points:`14 2 14 8 20 8`}),(0,Z.jsx)(`line`,{x1:`9`,y1:`15`,x2:`15`,y2:`15`})]}):n===`svg`||n===`png`||n===`jpg`||n===`jpeg`||n===`webp`||n===`gif`||n===`ico`?(0,Z.jsxs)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`#ec4899`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:[(0,Z.jsx)(`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`}),(0,Z.jsx)(`circle`,{cx:`9`,cy:`9`,r:`2`}),(0,Z.jsx)(`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`})]}):n===`py`?(0,Z.jsxs)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`#3b82f6`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:[(0,Z.jsx)(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`}),(0,Z.jsx)(`polyline`,{points:`14 2 14 8 20 8`})]}):n===`sh`||n===`bash`||n===`zsh`?(0,Z.jsxs)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`#22c55e`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:[(0,Z.jsx)(`polyline`,{points:`4 17 10 11 4 5`}),(0,Z.jsx)(`line`,{x1:`12`,y1:`19`,x2:`20`,y2:`19`})]}):n===`yaml`||n===`yml`||n===`toml`||n===`env`||n===`ini`?(0,Z.jsxs)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`#f59e0b`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:[(0,Z.jsx)(`line`,{x1:`4`,y1:`21`,x2:`4`,y2:`14`}),(0,Z.jsx)(`line`,{x1:`4`,y1:`10`,x2:`4`,y2:`3`}),(0,Z.jsx)(`line`,{x1:`12`,y1:`21`,x2:`12`,y2:`12`}),(0,Z.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`3`}),(0,Z.jsx)(`line`,{x1:`20`,y1:`21`,x2:`20`,y2:`16`}),(0,Z.jsx)(`line`,{x1:`20`,y1:`12`,x2:`20`,y2:`3`}),(0,Z.jsx)(`line`,{x1:`1`,y1:`14`,x2:`7`,y2:`14`}),(0,Z.jsx)(`line`,{x1:`9`,y1:`8`,x2:`15`,y2:`8`}),(0,Z.jsx)(`line`,{x1:`17`,y1:`16`,x2:`23`,y2:`16`})]}):n===`lock`||e.includes(`.lock`)?(0,Z.jsxs)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`#94a3b8`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:[(0,Z.jsx)(`rect`,{x:`3`,y:`11`,width:`18`,height:`11`,rx:`2`,ry:`2`}),(0,Z.jsx)(`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`})]}):(0,Z.jsxs)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0,opacity:.6},children:[(0,Z.jsx)(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`}),(0,Z.jsx)(`polyline`,{points:`14 2 14 8 20 8`})]})}function qh(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Jh(e,t){let n=new Date(e),r=new Date().getTime()-n.getTime(),i=Math.floor(r/6e4);if(i<1)return t(`artifacts.justNow`);if(i<60)return`${i}${t(`artifacts.mAgo`)}`;let a=Math.floor(i/60);return a<24?`${a}${t(`artifacts.hAgo`)}`:`${Math.floor(a/24)}${t(`artifacts.dAgo`)}`}function Yh(){let{t:e}=qo(),t=q(e=>e.artifactItems),n=q(e=>e.artifactActiveId),r=q(e=>e.setArtifactActiveId),i=q(e=>e.openArtifactViewer),a=q(e=>e.setExplorerTab),o=q(e=>e.isMobile),s=Y(e=>e.activeSessionId),c=t.filter(e=>e.sessionId===s),[l,u]=(0,G.useState)([]),[d,f]=(0,G.useState)(!1),[p,m]=(0,G.useState)(null),h=Y(e=>e.activeProjectId),g=Y(e=>e.projects).find(e=>e.id===h)?.path,_=(0,G.useCallback)(async()=>{f(!0),m(null);try{let e=await Jr(g);u(e.files)}catch(e){m(e instanceof Error?e.message:`Failed to load`)}finally{f(!1)}},[g]);(0,G.useEffect)(()=>{_()},[_]);let v=e=>{let t=g?`?cwd=${encodeURIComponent(g)}`:``,n=e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`);window.open(`/api/v1/artifacts/${n}${t}`,`_blank`)};return(0,Z.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0,overflow:`hidden`,background:`var(--bg-primary)`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6,padding:`8px 10px`,borderBottom:`1px solid var(--border)`,background:`var(--bg-glass-strong)`,flexShrink:0},children:[(0,Z.jsxs)(`span`,{style:{fontSize:13,fontWeight:600,color:`var(--text-primary)`,flex:1},children:[`📡 `,e(`artifacts.stream`)]}),(0,Z.jsx)(`span`,{style:{fontSize:11,color:`var(--text-tertiary)`,background:`var(--bg-glass)`,padding:`1px 6px`,borderRadius:10},children:c.length})]}),(0,Z.jsx)(`div`,{style:{flex:1,overflowY:`auto`,padding:`4px 0`,borderBottom:`1px solid var(--border)`},children:c.length===0?(0,Z.jsx)(`div`,{style:{padding:`16px 12px`,textAlign:`center`,color:`var(--text-tertiary)`,fontSize:12},children:e(`artifacts.noStream`)}):c.map(e=>{let t=e.id===n;return(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{r(e.id),i(e.id,e.title,e.type),o&&a(void 0)},style:{display:`flex`,alignItems:`center`,gap:`8px`,width:`100%`,padding:`6px 12px`,border:`none`,background:t?`var(--accent-subtle)`:`transparent`,color:t?`var(--accent-text)`:`var(--text-primary)`,cursor:`pointer`,fontSize:12,textAlign:`left`,borderRadius:0,borderLeft:t?`3px solid var(--accent-text)`:`3px solid transparent`},title:e.title,children:[(0,Z.jsx)(`span`,{style:{flexShrink:0,display:`inline-flex`,alignItems:`center`},children:Kh(e.title||e.type,14)}),(0,Z.jsx)(`span`,{style:{flex:1,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.title}),(0,Z.jsx)(`span`,{style:{fontSize:10,color:`var(--text-tertiary)`,flexShrink:0,textTransform:`uppercase`,letterSpacing:`0.5px`},children:e.type})]},e.id)})}),(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6,padding:`8px 10px`,borderBottom:`1px solid var(--border)`,background:`var(--bg-glass-strong)`,flexShrink:0},children:[(0,Z.jsxs)(`span`,{style:{fontSize:13,fontWeight:600,color:`var(--text-primary)`,flex:1},children:[`💾 `,e(`artifacts.saved`)]}),(0,Z.jsx)(`button`,{onClick:_,disabled:d,style:{fontSize:11,color:`var(--text-tertiary)`,background:`var(--bg-glass)`,border:`none`,padding:`2px 8px`,borderRadius:10,cursor:d?`wait`:`pointer`,opacity:d?.5:1},title:e(`artifacts.refreshSaved`),children:d?`⏳`:`🔄`}),(0,Z.jsx)(`span`,{style:{fontSize:11,color:`var(--text-tertiary)`,background:`var(--bg-glass)`,padding:`1px 6px`,borderRadius:10},children:l.length})]}),(0,Z.jsx)(`div`,{style:{flex:1,overflowY:`auto`,padding:`4px 0`},children:p?(0,Z.jsx)(`div`,{style:{padding:`16px 12px`,textAlign:`center`,color:`var(--error-text, #ff4444)`,fontSize:12},children:p}):l.length===0?(0,Z.jsxs)(`div`,{style:{padding:`16px 12px`,textAlign:`center`,color:`var(--text-tertiary)`,fontSize:12},children:[e(`artifacts.noSaved`),(0,Z.jsx)(`br`,{}),(0,Z.jsx)(`span`,{style:{fontSize:11},children:e(g?`artifacts.agentCreated`:`artifacts.selectProject`)})]}):l.map(t=>{let n=t.name.lastIndexOf(`/`),r=n===-1?``:t.name.slice(0,n+1),i=n===-1?t.name:t.name.slice(n+1);return(0,Z.jsxs)(`div`,{onClick:()=>v(t.name),style:{display:`flex`,alignItems:`center`,gap:`8px`,padding:`6px 12px`,borderBottom:`1px solid var(--border-subtle, transparent)`,cursor:`pointer`,transition:`background 0.15s ease`},onMouseEnter:e=>e.currentTarget.style.background=`var(--bg-glass-strong, rgba(255,255,255,0.05))`,onMouseLeave:e=>e.currentTarget.style.background=`transparent`,children:[(0,Z.jsx)(`span`,{style:{flexShrink:0,display:`inline-flex`,alignItems:`center`},children:Kh(t.name??t.type,14)}),(0,Z.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,Z.jsxs)(`div`,{style:{fontSize:12,color:`var(--text-primary)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},title:t.name,children:[r&&(0,Z.jsx)(`span`,{style:{color:`var(--text-tertiary)`,opacity:.8},children:r}),(0,Z.jsx)(`span`,{children:i})]}),(0,Z.jsxs)(`div`,{style:{fontSize:10,color:`var(--text-tertiary)`,display:`flex`,gap:8},children:[(0,Z.jsx)(`span`,{children:qh(t.size)}),(0,Z.jsx)(`span`,{children:Jh(t.modified,e)})]})]}),(0,Z.jsx)(`div`,{style:{display:`flex`,gap:4,flexShrink:0},children:(0,Z.jsx)(`button`,{onClick:e=>{e.stopPropagation(),v(t.name)},style:{fontSize:11,color:`var(--accent-text)`,background:`var(--accent-subtle)`,border:`none`,padding:`2px 6px`,borderRadius:4,cursor:`pointer`},title:e(`artifacts.openNewTab`),children:`↗`})})]},t.name)})})]})}function Xh(e,t){let n=Math.max(0,Math.floor(((t??Date.now())-e)/1e3));return n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`}function Zh({sessionId:e}){let t=J(t=>e?Ei(t,e):Ti),n=J(e=>e.setProcesses),[i,a]=(0,G.useState)(null),[o,s]=(0,G.useState)({}),[c,l]=(0,G.useState)({}),[u,d]=(0,G.useState)({}),[f,p]=(0,G.useState)(!1),[h,g]=(0,G.useState)(Date.now());(0,G.useEffect)(()=>{if(!t.some(e=>wi.has(e.status)))return;let e=setInterval(()=>g(Date.now()),1e3);return()=>clearInterval(e)},[t]),(0,G.useEffect)(()=>{e&&Yr(e).then(t=>{n(e,t.processes)}).catch(()=>{})},[e,n]),(0,G.useEffect)(()=>{if(!e||!i)return;let n=()=>{Qr(e,i).then(e=>{s(t=>({...t,[i]:{stdout:e.stdout,stderr:e.stderr}}))}).catch(()=>{})};if(n(),t.find(e=>e.id===i&&wi.has(e.status))){let e=setInterval(n,2e3);return()=>clearInterval(e)}},[e,i,t]);let{runningList:_,finishedList:v}=(0,G.useMemo)(()=>{let e=[],n=[];for(let r of t)wi.has(r.status)?e.push(r):n.push(r);return{runningList:e,finishedList:n}},[t]),y=async t=>{if(e){d(e=>({...e,[t]:!0}));try{await Xr(e,t);let r=await Yr(e);n(e,r.processes)}catch{}finally{d(e=>({...e,[t]:!1}))}}},x=async()=>{if(e){p(!0);try{await Zr(e);let t=await Yr(e);n(e,t.processes)}catch{}finally{p(!1)}}},S=async t=>{if(!e)return;let n=c[t];if(!(!n||n.trim()===``))try{await $r(e,t,n.endsWith(`
137
+ `)?n:n+`
138
+ `),l(e=>({...e,[t]:``}));let r=await Qr(e,t);s(e=>({...e,[t]:{stdout:r.stdout,stderr:r.stderr}}))}catch{}};return e?(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`,overflow:`hidden`,background:`var(--bg-panel, var(--bg))`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`10px 14px`,borderBottom:`1px solid var(--border)`,background:`var(--bg-glass)`,flexShrink:0},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`},children:[(0,Z.jsx)(`span`,{style:{fontSize:`13px`,fontWeight:600,color:`var(--text-primary)`},children:`Processes`}),_.length>0&&(0,Z.jsxs)(`span`,{style:{fontSize:`11px`,fontWeight:600,padding:`2px 7px`,borderRadius:`10px`,background:`rgba(16, 185, 129, 0.15)`,color:`#10b981`,border:`1px solid rgba(16, 185, 129, 0.3)`},children:[_.length,` running`]})]}),v.length>0&&(0,Z.jsxs)(`button`,{onClick:x,disabled:f,type:`button`,title:`Clear finished processes`,style:{display:`inline-flex`,alignItems:`center`,gap:`4px`,padding:`4px 8px`,fontSize:`11px`,borderRadius:`6px`,border:`1px solid var(--border)`,background:`transparent`,color:`var(--text-secondary)`,cursor:`pointer`},children:[(0,Z.jsx)(oe,{size:12}),(0,Z.jsx)(`span`,{children:`Clear finished`})]})]}),(0,Z.jsx)(`div`,{style:{flex:1,overflowY:`auto`,padding:`12px`,display:`flex`,flexDirection:`column`,gap:`10px`},children:t.length===0?(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,padding:`40px 16px`,color:`var(--text-muted, var(--text-secondary))`,textAlign:`center`,gap:`8px`},children:[(0,Z.jsx)(z,{size:32,strokeWidth:1.5,style:{opacity:.5}}),(0,Z.jsx)(`div`,{style:{fontSize:`13px`,fontWeight:500},children:`No background processes`}),(0,Z.jsx)(`div`,{style:{fontSize:`12px`,opacity:.8,maxWidth:`260px`},children:`Ask the agent to start long-running commands, dev servers, or watchers in the background.`})]}):(0,Z.jsxs)(Z.Fragment,{children:[_.map(t=>{let n=i===t.id,d=o[t.id],f=u[t.id];return(0,Z.jsxs)(`div`,{style:{borderRadius:`8px`,border:`1px solid rgba(16, 185, 129, 0.3)`,background:`var(--bg-card, rgba(255,255,255,0.03))`,overflow:`hidden`,boxShadow:`0 1px 3px rgba(0,0,0,0.1)`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`8px 12px`,cursor:`pointer`,gap:`8px`},onClick:()=>a(n?null:t.id),children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,minWidth:0},children:[(0,Z.jsx)(`span`,{style:{width:`8px`,height:`8px`,borderRadius:`50%`,background:`#10b981`,boxShadow:`0 0 6px #10b981`,flexShrink:0}}),(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,minWidth:0},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`6px`},children:[(0,Z.jsx)(`span`,{style:{fontSize:`13px`,fontWeight:600,color:`var(--text-primary)`},children:t.name}),(0,Z.jsxs)(`span`,{style:{fontSize:`10px`,padding:`1px 5px`,borderRadius:`4px`,background:`rgba(255,255,255,0.06)`,color:`var(--text-secondary)`},children:[`PID `,t.pid]})]}),(0,Z.jsx)(`span`,{style:{fontSize:`11px`,fontFamily:`monospace`,color:`var(--text-secondary)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:t.command})]})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,flexShrink:0},children:[(0,Z.jsxs)(`span`,{style:{fontSize:`11px`,color:`var(--text-secondary)`,display:`inline-flex`,alignItems:`center`,gap:`3px`},children:[(0,Z.jsx)(m,{size:11}),Xh(t.startTime,null)]}),(0,Z.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),y(t.id)},disabled:f,type:`button`,style:{display:`inline-flex`,alignItems:`center`,gap:`4px`,padding:`3px 8px`,fontSize:`11px`,fontWeight:500,borderRadius:`4px`,border:`1px solid rgba(239, 68, 68, 0.4)`,background:`rgba(239, 68, 68, 0.1)`,color:`#ef4444`,cursor:f?`default`:`pointer`},children:[(0,Z.jsx)(re,{size:10,fill:`#ef4444`}),(0,Z.jsx)(`span`,{children:f?`Stopping...`:`Kill`})]}),n?(0,Z.jsx)(r,{size:14}):(0,Z.jsx)(b,{size:14})]})]}),n&&(0,Z.jsxs)(`div`,{style:{borderTop:`1px solid var(--border)`,padding:`10px`,background:`rgba(0,0,0,0.25)`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:`6px`},children:[(0,Z.jsx)(`span`,{style:{fontSize:`11px`,color:`var(--text-secondary)`,fontWeight:500},children:`Live Log Output:`}),(0,Z.jsxs)(`button`,{onClick:()=>{Qr(e,t.id).then(e=>{s(n=>({...n,[t.id]:{stdout:e.stdout,stderr:e.stderr}}))})},type:`button`,style:{background:`transparent`,border:`none`,color:`var(--text-secondary)`,cursor:`pointer`,display:`inline-flex`,alignItems:`center`,gap:`4px`,fontSize:`11px`},children:[(0,Z.jsx)(A,{size:11}),` Refresh`]})]}),(0,Z.jsx)(`div`,{style:{fontFamily:`monospace`,fontSize:`11px`,lineHeight:`1.4`,maxHeight:`180px`,overflowY:`auto`,padding:`8px`,borderRadius:`4px`,background:`#0d0d0d`,color:`#e5e5e5`,whiteSpace:`pre-wrap`,wordBreak:`break-all`},children:!d||d.stdout.length===0&&d.stderr.length===0?(0,Z.jsx)(`span`,{style:{color:`#666`},children:`(waiting for output...)`}):(0,Z.jsxs)(Z.Fragment,{children:[d.stdout.map((e,t)=>(0,Z.jsx)(`div`,{children:e},`out-`+t)),d.stderr.map((e,t)=>(0,Z.jsx)(`div`,{style:{color:`#f87171`},children:e},`err-`+t))]})}),(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:`6px`,marginTop:`8px`},children:[(0,Z.jsx)(`input`,{type:`text`,placeholder:`Send input to stdin...`,value:c[t.id]??``,onChange:e=>l(n=>({...n,[t.id]:e.target.value})),onKeyDown:e=>{e.key===`Enter`&&S(t.id)},style:{flex:1,fontSize:`11px`,fontFamily:`monospace`,padding:`4px 8px`,borderRadius:`4px`,border:`1px solid var(--border)`,background:`rgba(255,255,255,0.05)`,color:`var(--text-primary)`,outline:`none`}}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>void S(t.id),style:{padding:`4px 8px`,fontSize:`11px`,borderRadius:`4px`,border:`1px solid var(--border)`,background:`var(--accent)`,color:`#fff`,cursor:`pointer`,display:`inline-flex`,alignItems:`center`,gap:`4px`},children:(0,Z.jsx)(I,{size:11})})]})]})]},t.id)}),v.map(e=>{let t=i===e.id,n=o[e.id];return(0,Z.jsxs)(`div`,{style:{borderRadius:`8px`,border:`1px solid var(--border)`,background:`var(--bg-card, rgba(255,255,255,0.02))`,overflow:`hidden`,opacity:.85},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`8px 12px`,cursor:`pointer`,gap:`8px`},onClick:()=>a(t?null:e.id),children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,minWidth:0},children:[e.success?(0,Z.jsx)(O,{size:14,color:`#10b981`}):(0,Z.jsx)(D,{size:14,color:e.status===`killed`?`#9ca3af`:`#ef4444`}),(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,minWidth:0},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`6px`},children:[(0,Z.jsx)(`span`,{style:{fontSize:`13px`,fontWeight:500,color:`var(--text-primary)`},children:e.name}),(0,Z.jsxs)(`span`,{style:{fontSize:`10px`,padding:`1px 5px`,borderRadius:`4px`,background:`rgba(255,255,255,0.06)`,color:`var(--text-secondary)`},children:[e.status,` (exit `,e.exitCode??`?`,`)`]})]}),(0,Z.jsx)(`span`,{style:{fontSize:`11px`,fontFamily:`monospace`,color:`var(--text-secondary)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.command})]})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,flexShrink:0},children:[(0,Z.jsxs)(`span`,{style:{fontSize:`11px`,color:`var(--text-secondary)`,display:`inline-flex`,alignItems:`center`,gap:`3px`},children:[(0,Z.jsx)(m,{size:11}),Xh(e.startTime,e.endTime)]}),t?(0,Z.jsx)(r,{size:14}):(0,Z.jsx)(b,{size:14})]})]}),t&&(0,Z.jsx)(`div`,{style:{borderTop:`1px solid var(--border)`,padding:`10px`,background:`rgba(0,0,0,0.25)`},children:(0,Z.jsx)(`div`,{style:{fontFamily:`monospace`,fontSize:`11px`,lineHeight:`1.4`,maxHeight:`160px`,overflowY:`auto`,padding:`8px`,borderRadius:`4px`,background:`#0d0d0d`,color:`#e5e5e5`,whiteSpace:`pre-wrap`,wordBreak:`break-all`},children:!n||n.stdout.length===0&&n.stderr.length===0?(0,Z.jsx)(`span`,{style:{color:`#666`},children:`(no log lines captured)`}):(0,Z.jsxs)(Z.Fragment,{children:[n.stdout.map((e,t)=>(0,Z.jsx)(`div`,{children:e},`out-`+t)),n.stderr.map((e,t)=>(0,Z.jsx)(`div`,{style:{color:`#f87171`},children:e},`err-`+t))]})})})]},e.id)})]})})]}):(0,Z.jsx)(`div`,{style:{padding:`16px`,color:`var(--text-secondary)`,textAlign:`center`},children:`No active session.`})}function Qh(e){return e.webkitGetAsEntry?.()??null}function $h(e,t){let n=e;return n.uploadRelativePath=t,n}async function eg(e,t,n){if(e.isFile){let r=await new Promise((t,n)=>{e.file(t,n)});n.push($h(r,t));return}if(!e.isDirectory)return;let r=e.createReader(),i=await new Promise(e=>{r.readEntries(e)});await Promise.all(i.map(e=>eg(e,`${t}/${e.name}`,n)))}async function tg(e){let t=Array.from(e.items).map(e=>Qh(e)).filter(e=>e!==null);if(t.length===0)return Array.from(e.files).map(e=>$h(e,e.name));let n=[];for(let e of t)await eg(e,e.name,n);return n}var ng=360,rg=220,ig=800,ag=!0,og=300,sg=3;function cg(e){let t=new Map;for(let n of e){let e=t.get(n.path);e===void 0?t.set(n.path,[n]):e.push(n)}return Array.from(t.entries())}function lg({projectId:e,open:t,onClose:n,initialTab:r,flexLayout:i=ag}){let[a,o]=(0,G.useState)([]),[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(),[d,f]=(0,G.useState)(new Set),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)(),[_,v]=(0,G.useState)(``),[y,b]=(0,G.useState)(),[x,S]=(0,G.useState)(``),[C,w]=(0,G.useState)(``),[T,E]=(0,G.useState)(),[D,O]=(0,G.useState)(r??`files`),k=Y(e=>e.activeSessionId),A=J(e=>Di(e,k)),[j,M]=(0,G.useState)(new Set),[N,P]=(0,G.useState)(null),[F,I]=(0,G.useState)(!1),[L,R]=(0,G.useState)(!1),[z,ee]=(0,G.useState)(!1),[B,V]=(0,G.useState)(!1);(0,G.useEffect)(()=>{M(new Set),P(null),I(!1)},[e]);let H=q(e=>e.openFileViewer);(0,G.useEffect)(()=>{r!==void 0&&r!==D&&O(r)},[r]);let[U,te]=(0,G.useState)(null),ne=(0,G.useRef)(null),re=(0,G.useRef)(void 0),ie=(0,G.useRef)({x:0,y:0}),ae=(0,G.useRef)(null),oe=(0,G.useRef)(null),[se,ce]=(0,G.useState)(!1),[le,ue]=(0,G.useState)(void 0),de=(0,G.useRef)(void 0),fe=Y(t=>t.projects.find(t=>t.id===e)?.path??``),[pe,me]=(0,G.useState)(ng),he=(0,G.useRef)(void 0),ge=(0,G.useCallback)(e=>{e.preventDefault(),he.current={startX:e.clientX,startW:pe};let t=e=>{if(he.current===void 0)return;let t=e.clientX-he.current.startX,n=Math.min(ig,Math.max(rg,he.current.startW-t));me(n)},n=()=>{he.current=void 0,document.removeEventListener(`mousemove`,t),document.removeEventListener(`mouseup`,n)};document.addEventListener(`mousemove`,t),document.addEventListener(`mouseup`,n)},[pe]),[_e,ve]=(0,G.useState)(void 0),[ye,be]=(0,G.useState)(!1),[xe,Se]=(0,G.useState)(),[Ce,we]=(0,G.useState)(new Set);(0,G.useEffect)(()=>{if(D!==`files`||!t){ve(void 0);return}let n=p.trim();if(n.length<sg){ve(void 0),Se(void 0),be(!1);return}be(!0),Se(void 0);let r=setTimeout(async()=>{try{let t=await xn(e,n);ve(t);let r=cg(t.matches);we(new Set(r.slice(0,5).map(([e])=>e)))}catch(e){Se(e instanceof Error?e.message:`search failed`),ve(void 0)}finally{be(!1)}},og);return()=>clearTimeout(r)},[p,D,t,e]),(0,G.useEffect)(()=>{if(!U)return;let e=e=>{ne.current&&!ne.current.contains(e.target)&&te(null)},t=e=>{e.key===`Escape`&&te(null)},n=requestAnimationFrame(()=>{document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t)});return()=>{cancelAnimationFrame(n),document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[U]);let Te=(0,G.useCallback)(async(e,t)=>{try{await navigator.clipboard.writeText(e),u(void 0)}catch{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),document.execCommand(`copy`),document.body.removeChild(t)}},[]),Ee=(0,G.useCallback)(e=>{Te(e,`Relative path`),te(null)},[Te]),De=(0,G.useCallback)(e=>{let t=fe?`${fe}/${e}`.replace(/\/$/,``):e;Te(t,`Absolute path`),te(null)},[fe,Te]),Oe=(0,G.useCallback)((e,t)=>{let n=document.querySelector(`.file-explorer-panel`);if(!n)return;let r=n.getBoundingClientRect(),i=Math.min(e.clientX-r.left,r.width-180),a=Math.min(e.clientY-r.top,r.height-120);te({x:Math.max(4,i),y:Math.max(4,a),node:t})},[]),W=(0,G.useCallback)((e,t)=>{e.preventDefault(),e.stopPropagation(),j.has(t.path)||(M(new Set([t.path])),P(t.path)),Oe(e,t)},[Oe,j]),ke=(0,G.useCallback)((e,t)=>{let n=e.touches[0];ie.current={x:n.clientX,y:n.clientY},re.current=setTimeout(()=>{re.current=void 0,Oe({clientX:n.clientX,clientY:n.clientY},t)},500)},[Oe]),Ae=(0,G.useCallback)(()=>{re.current&&=(clearTimeout(re.current),void 0)},[]),je=(0,G.useCallback)(()=>{re.current&&=(clearTimeout(re.current),void 0)},[]),Me=(0,G.useRef)(null),Ne=(0,G.useRef)(null),Pe=(0,G.useCallback)(async()=>{c(!0),u(void 0);try{let t=await un(e);o(t.children??[])}catch(e){u(e instanceof Error?e.message:`load failed`)}finally{c(!1)}},[e]),Fe=(0,G.useCallback)(async(t,n)=>{if(!(!t||t.length===0)){ce(!0),u(void 0);try{let r=Array.from(t);await Sn(e,n??``,r),await Pe()}catch(e){u(e instanceof Error?e.message:`upload failed`)}finally{ce(!1)}}},[e,Pe]);(0,G.useEffect)(()=>{Pe()},[Pe]),(0,G.useEffect)(()=>{y&&Ne.current?.focus()},[y]),(0,G.useEffect)(()=>{h!==void 0&&Me.current?.focus()},[h]);let Ie=(0,G.useCallback)(async e=>{let t=e.split(`/`).pop()||e;H(e,t),i||n()},[H,i,n]),Le=e=>{f(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Re=async t=>{let n=_.trim();if(!n||n===t.split(`/`).pop()){g(void 0);return}try{await pn(e,t,n),g(void 0),await Pe()}catch(e){u(e instanceof Error?e.message:`rename failed`),g(void 0)}},ze=async()=>{let t=C.trim();if(!t){b(void 0);return}try{y===`folder`?await mn(e,x||`/`,t):await fn(e,x?`${x}/${t}`:`/${t}`,``),b(void 0),w(``),await Pe()}catch(e){u(e instanceof Error?e.message:`create failed`),b(void 0)}},Be=async t=>{try{await _n(e,t,{recursive:!0}),E(void 0),await Pe()}catch(e){u(e instanceof Error?e.message:`delete failed`),E(void 0)}},Ve=(0,G.useMemo)(()=>{if(!p)return a;let e=p.toLowerCase(),t=n=>n.filter(n=>{let r=n.name.toLowerCase().includes(e);if(n.type===`directory`&&n.children){let e=t(n.children);return r||e.length>0}return r});return t(a)},[a,p]),He=(0,G.useMemo)(()=>{let e=[],t=n=>{for(let r of n)e.push(r),r.type===`directory`&&d.has(r.path)&&r.children&&t(r.children)};return t(Ve),e},[Ve,d]),Ue=(0,G.useCallback)((e,t,n)=>{M(n=>{let r=new Set(n);if(t&&N){let t=He.findIndex(e=>e.path===N),n=He.findIndex(t=>t.path===e);if(t!==-1&&n!==-1){let e=Math.min(t,n),i=Math.max(t,n);for(let t=e;t<=i;t++)r.add(He[t].path);return r}}return r.has(e)?(r.delete(e),N===e&&P(null)):(r.add(e),P(e)),r})},[He,N]),We=(0,G.useCallback)(()=>{M(new Set(He.map(e=>e.path)))},[He]),Ge=(0,G.useCallback)(()=>{M(new Set),P(null)},[]),Ke=async()=>{if(j.size!==0){ee(!0),u(void 0);try{let t=await vn(e,Array.from(j),{recursive:!0});if(M(new Set),P(null),R(!1),await Pe(),t.errors&&Object.keys(t.errors).length>0){let e=Object.entries(t.errors).map(([e,t])=>`${e}: ${t}`).join(`, `);u(`Deleted ${t.deleted.length} items. Errors: ${e}`)}}catch(e){u(e instanceof Error?e.message:`batch delete failed`)}finally{ee(!1)}}},qe=(0,G.useCallback)(async()=>{if(j.size!==0){V(!0),u(void 0);try{await gn(e,Array.from(j))}catch(e){u(e instanceof Error?e.message:`batch download failed`)}finally{V(!1)}}},[e,j]),Je=(0,G.useCallback)(async(t,n)=>{let r=[];for(let e of t){if(e===n||n&&(n===e||n.startsWith(`${e}/`))||(e.includes(`/`)?e.slice(0,e.lastIndexOf(`/`)):``)===n)continue;let t=e.split(`/`).pop()??``,i=n?`${n}/${t}`:t;e!==i&&r.push({src:e,dest:i})}if(r.length!==0){u(void 0);try{let t;try{t=(await yn(e,r)).errors}catch{let n=await Promise.allSettled(r.map(t=>bn(e,t.src,t.dest))),i={};n.forEach((e,t)=>{e.status===`rejected`&&(i[r[t].src]=e.reason instanceof Error?e.reason.message:`Move failed`)}),Object.keys(i).length>0&&(t=i)}if(t&&Object.keys(t).length>0){let e=Object.entries(t).map(([e,t])=>`${e}: ${t}`).join(`, `);u(`Moved with errors: ${e}`)}M(new Set),P(null),await Pe()}catch(e){u(e instanceof Error?e.message:`Move failed`)}}},[e,Pe]);(0,G.useEffect)(()=>{if(D!==`files`||!t)return;let e=e=>{let t=e.target;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable)||(e.key===`Delete`||e.key===`Backspace`?j.size>0&&(e.preventDefault(),R(!0)):(e.ctrlKey||e.metaKey)&&(e.key===`a`||e.key===`A`)?(e.preventDefault(),We()):e.key===`Escape`&&(L?R(!1):j.size>0&&Ge()))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[D,t,j,L,We,Ge]);let Ye=(e,t)=>{let n=d.has(e.path),r=e.type===`directory`,i=h===e.path,a=r&&le===e.path,o=j.has(e.path),s=F||j.size>0;return(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{onContextMenu:t=>W(t,e),onTouchStart:t=>ke(t,e),onTouchEnd:Ae,onTouchMove:je,onClick:t=>{i||(t.ctrlKey||t.metaKey?Ue(e.path,!1,!0):t.shiftKey?Ue(e.path,!0,!1):F&&Ue(e.path,!1,!0))},onDragStart:t=>{t.stopPropagation();let n=j.has(e.path)&&j.size>0?Array.from(j):[e.path];if(t.dataTransfer.setData(`application/x-pi-paths`,JSON.stringify(n)),t.dataTransfer.setData(`application/x-pi-path`,e.path),t.dataTransfer.effectAllowed=`move`,n.length>1){let e=document.createElement(`div`);e.style.position=`absolute`,e.style.top=`-9999px`,e.style.left=`-9999px`,e.style.background=`var(--accent, #6366f1)`,e.style.color=`#ffffff`,e.style.padding=`4px 10px`,e.style.borderRadius=`12px`,e.style.fontSize=`12px`,e.style.fontWeight=`600`,e.style.boxShadow=`0 4px 12px rgba(0,0,0,0.3)`,e.style.pointerEvents=`none`,e.textContent=`Moving ${n.length} items`,document.body.appendChild(e),t.dataTransfer.setDragImage(e,20,15),setTimeout(()=>{document.body.contains(e)&&document.body.removeChild(e)},0)}},onDragOver:r?t=>{t.preventDefault(),t.stopPropagation();let n=t.dataTransfer.types.includes(`application/x-pi-path`)||t.dataTransfer.types.includes(`application/x-pi-paths`);t.dataTransfer.dropEffect=n?`move`:`copy`,de.current=e.path,ue(e.path)}:void 0,onDragLeave:r?()=>{de.current===e.path&&(de.current=void 0,ue(void 0))}:void 0,onDrop:r?async t=>{t.preventDefault(),t.stopPropagation(),ue(void 0),de.current=void 0;let n=t.dataTransfer.getData(`application/x-pi-paths`),r=t.dataTransfer.getData(`application/x-pi-path`),i=[];if(n)try{i=JSON.parse(n)}catch{i=r?[r]:[]}else r&&(i=[r]);if(i.length>0){await Je(i,e.path);return}let a=await tg(t.dataTransfer);a.length>0&&await Fe(a,e.path)}:void 0,style:{display:`flex`,alignItems:`center`,gap:`2px`,padding:`2px 0`,paddingLeft:`${8+t*16}px`,position:`relative`,outline:a?`1px solid var(--accent)`:void 0,outlineOffset:`-1px`,borderRadius:`2px`},className:`file-tree-row${o?` file-tree-row-selected`:``}${U?.node.path===e.path?` file-tree-row-active`:``}${a?` file-tree-row-drop-target`:``}`,draggable:!0,children:[s&&(0,Z.jsx)(`input`,{type:`checkbox`,checked:o,onChange:t=>{t.stopPropagation(),Ue(e.path,!1,!0)},onClick:e=>e.stopPropagation(),className:`file-tree-checkbox`,title:`Select`}),r?(0,Z.jsx)(`button`,{onClick:t=>{t.stopPropagation(),Le(e.path)},style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,background:`none`,border:`none`,cursor:`pointer`,padding:`2px`,width:`20px`,height:`20px`,flexShrink:0,color:`var(--accent)`},type:`button`,children:(0,Z.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,Z.jsx)(`path`,{d:`M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z`})})}):(0,Z.jsx)(`span`,{style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`20px`,height:`20px`,flexShrink:0},children:Kh(e.name,15)}),i?(0,Z.jsx)(`input`,{ref:Me,value:_,onChange:e=>v(e.target.value),onBlur:()=>Re(e.path),onKeyDown:t=>{t.key===`Enter`&&Re(e.path),t.key===`Escape`&&g(void 0)},onClick:e=>e.stopPropagation(),style:{flex:1,background:`var(--bg-solid)`,border:`1px solid var(--border-bright)`,borderRadius:`var(--radius-sm)`,padding:`1px 4px`,fontSize:`12px`,color:`var(--text-primary)`,outline:`none`,minWidth:0}}):(0,Z.jsx)(`button`,{onClick:t=>{t.ctrlKey||t.metaKey?(t.stopPropagation(),Ue(e.path,!1,!0)):t.shiftKey?(t.stopPropagation(),Ue(e.path,!0,!1)):F?(t.stopPropagation(),Ue(e.path,!1,!0)):(j.size>0&&Ge(),r?Le(e.path):Ie(e.path))},style:{flex:1,background:`none`,border:`none`,color:`var(--text-primary)`,cursor:`pointer`,fontSize:`12px`,textAlign:`left`,padding:`1px 4px`,borderRadius:`var(--radius-sm)`,minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},title:e.path,type:`button`,children:e.name}),!i&&(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:`1px`,flexShrink:0},className:`file-row-actions`,children:[r&&(0,Z.jsx)(`button`,{onClick:t=>{t.stopPropagation(),S(e.path),b(`file`),w(``)},title:`New file in this folder`,style:{background:`none`,border:`none`,cursor:`pointer`,padding:`1px 3px`,fontSize:`11px`,color:`var(--text-dim)`},type:`button`,children:`+`}),(0,Z.jsx)(`button`,{onClick:t=>{t.stopPropagation(),g(e.path),v(e.name),setTimeout(()=>Me.current?.focus(),50)},title:`Rename`,style:{background:`none`,border:`none`,cursor:`pointer`,padding:`1px 3px`,fontSize:`11px`,color:`var(--text-dim)`},type:`button`,children:`✏️`}),(0,Z.jsx)(`button`,{onClick:t=>{t.stopPropagation(),E(e.path)},title:`Delete`,style:{background:`none`,border:`none`,cursor:`pointer`,padding:`1px 3px`,fontSize:`11px`,color:`var(--text-dim)`},type:`button`,children:`🗑`})]})]}),r&&n&&e.children&&(0,Z.jsx)(`div`,{children:e.children.map(e=>Ye(e,t+1))})]},e.path)};return(0,Z.jsxs)(`div`,{className:`file-explorer-panel`,style:i?{display:`flex`,flexDirection:`column`,height:`100%`,width:t?pe:0,minWidth:t?rg:0,flexShrink:0,overflow:`hidden`,background:`var(--bg-solid)`,borderLeft:t?`1px solid var(--border)`:`none`,transition:`width 0.2s cubic-bezier(0.16, 1, 0.3, 1), min-width 0.2s cubic-bezier(0.16, 1, 0.3, 1)`,willChange:`width`,userSelect:he.current===void 0?void 0:`none`,position:`relative`,paddingTop:`50px`}:{position:`fixed`,top:50,right:0,bottom:0,zIndex:120,background:`var(--bg-solid)`,borderLeft:`1px solid var(--border)`,display:`flex`,flexDirection:`column`,width:pe,transform:t?`translateX(0)`:`translateX(100%)`,transition:`transform 0.18s ease`,willChange:`transform`,userSelect:he.current===void 0?void 0:`none`},onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`div`,{onMouseDown:ge,className:`file-explorer-resize-handle`,style:{position:`absolute`,left:0,top:0,bottom:0,width:`5px`,cursor:`col-resize`,zIndex:10,background:`transparent`,transition:`background 0.15s ease`}}),(0,Z.jsxs)(`div`,{className:`fe-tab-bar`,style:{display:`flex`,borderBottom:`1px solid var(--border)`,background:`var(--bg-glass)`,flexShrink:0,alignItems:`center`,padding:`0 6px`,gap:`2px`,height:`38px`,minHeight:`38px`,boxSizing:`border-box`},children:[[{key:`files`,label:`Files`,icon:(0,Z.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,Z.jsx)(`path`,{d:`M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z`})}),onClick:()=>{O(`files`)}},{key:`git`,label:`Git`,icon:(0,Z.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`circle`,{cx:`18`,cy:`18`,r:`3`}),(0,Z.jsx)(`circle`,{cx:`6`,cy:`6`,r:`3`}),(0,Z.jsx)(`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`}),(0,Z.jsx)(`line`,{x1:`6`,y1:`9`,x2:`6`,y2:`21`})]}),onClick:()=>O(`git`)},{key:`artifacts`,label:`Artifacts`,icon:(0,Z.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`rect`,{x:`3`,y:`3`,width:`7`,height:`7`}),(0,Z.jsx)(`rect`,{x:`14`,y:`3`,width:`7`,height:`7`}),(0,Z.jsx)(`rect`,{x:`14`,y:`14`,width:`7`,height:`7`}),(0,Z.jsx)(`rect`,{x:`3`,y:`14`,width:`7`,height:`7`})]}),onClick:()=>O(`artifacts`)},{key:`processes`,label:`Processes`,badge:A>0?A:void 0,icon:(0,Z.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`polyline`,{points:`4 17 10 11 4 5`}),(0,Z.jsx)(`line`,{x1:`12`,y1:`19`,x2:`20`,y2:`19`})]}),onClick:()=>O(`processes`)}].map(({key:e,label:t,badge:n,icon:r,onClick:i})=>(0,Z.jsxs)(`button`,{onClick:i,title:t,type:`button`,className:`fe-tab-btn${D===e?` active`:``}`,children:[r,(0,Z.jsx)(`span`,{className:`fe-tab-label`,children:t}),n!==void 0&&(0,Z.jsx)(`span`,{style:{fontSize:`10px`,padding:`0 5px`,borderRadius:`8px`,background:`rgba(16, 185, 129, 0.2)`,color:`#10b981`,fontWeight:600,marginLeft:`2px`},children:n})]},e)),D===`files`&&(0,Z.jsxs)(`div`,{style:{marginLeft:`auto`,display:`flex`,alignItems:`center`,gap:`1px`,flexShrink:0},children:[(0,Z.jsx)(`button`,{onClick:()=>{let e=!F;I(e),e||Ge()},title:F?`Exit selection mode`:`Select multiple files`,className:`fe-toolbar-btn${F?` fe-toolbar-btn-active`:``}`,style:F?{color:`var(--accent)`,background:`var(--accent-subtle)`}:void 0,type:`button`,children:(0,Z.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`polyline`,{points:`9 11 12 14 22 4`}),(0,Z.jsx)(`path`,{d:`M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11`})]})}),(0,Z.jsx)(`button`,{onClick:()=>ae.current?.click(),title:`Upload files`,disabled:se,className:`fe-toolbar-btn`,type:`button`,children:(0,Z.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,Z.jsx)(`polyline`,{points:`17 8 12 3 7 8`}),(0,Z.jsx)(`line`,{x1:`12`,y1:`3`,x2:`12`,y2:`15`})]})}),(0,Z.jsx)(`button`,{onClick:()=>oe.current?.click(),title:`Upload folder`,disabled:se,className:`fe-toolbar-btn`,type:`button`,children:(0,Z.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`path`,{d:`M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z`}),(0,Z.jsx)(`polyline`,{points:`12 11 12 17`}),(0,Z.jsx)(`polyline`,{points:`9 14 12 11 15 14`})]})}),(0,Z.jsx)(`button`,{onClick:()=>{S(``),b(`file`),w(``)},title:`New file`,className:`fe-toolbar-btn`,type:`button`,children:(0,Z.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`}),(0,Z.jsx)(`polyline`,{points:`14 2 14 8 20 8`}),(0,Z.jsx)(`line`,{x1:`12`,y1:`18`,x2:`12`,y2:`12`}),(0,Z.jsx)(`line`,{x1:`9`,y1:`15`,x2:`15`,y2:`15`})]})}),(0,Z.jsx)(`button`,{onClick:()=>{S(``),b(`folder`),w(``)},title:`New folder`,className:`fe-toolbar-btn`,type:`button`,children:(0,Z.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`path`,{d:`M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z`}),(0,Z.jsx)(`line`,{x1:`12`,y1:`11`,x2:`12`,y2:`17`}),(0,Z.jsx)(`line`,{x1:`9`,y1:`14`,x2:`15`,y2:`14`})]})}),(0,Z.jsx)(`button`,{onClick:Pe,title:`Refresh`,className:`fe-toolbar-btn`,type:`button`,children:(0,Z.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:s?{animation:`spin 1s linear infinite`}:void 0,children:[(0,Z.jsx)(`polyline`,{points:`23 4 23 10 17 10`}),(0,Z.jsx)(`polyline`,{points:`1 20 1 14 7 14`}),(0,Z.jsx)(`path`,{d:`M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15`})]})}),(0,Z.jsx)(`span`,{style:{width:`1px`,height:`14px`,background:`var(--border)`,margin:`0 2px 0 3px`,flexShrink:0}})]}),n&&(0,Z.jsx)(`button`,{onClick:n,title:`Close panel`,type:`button`,className:`fe-tab-close`,style:{marginLeft:D===`files`?`0`:`auto`},children:(0,Z.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,Z.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]}),D===`git`&&(0,Z.jsx)(Mh,{projectId:e}),D===`system-prompt`&&(0,Z.jsx)(Gh,{projectId:e}),D===`artifacts`&&(0,Z.jsx)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,height:`100%`,overflow:`hidden`},children:(0,Z.jsx)(Yh,{})}),D===`processes`&&(0,Z.jsx)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,height:`100%`,overflow:`hidden`},children:(0,Z.jsx)(Zh,{sessionId:k})}),D===`files`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`input`,{ref:ae,type:`file`,multiple:!0,style:{display:`none`},onChange:e=>{Fe(e.target.files?Array.from(e.target.files):null),e.target.value=``}}),(0,Z.jsx)(`input`,{ref:oe,type:`file`,webkitdirectory:`true`,style:{display:`none`},onChange:e=>{Fe(e.target.files?Array.from(e.target.files):null),e.target.value=``}}),l&&(0,Z.jsx)(`div`,{style:{padding:`4px 12px`,fontSize:`10px`,color:`var(--error)`,background:`rgba(248,113,113,0.08)`,borderBottom:`1px solid var(--tool-border)`},children:l}),(0,Z.jsx)(`div`,{style:{padding:`6px 10px`},children:(0,Z.jsxs)(`div`,{style:{position:`relative`,display:`flex`,alignItems:`center`},children:[(0,Z.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{position:`absolute`,left:`8px`,color:`var(--text-dim)`,pointerEvents:`none`},children:[(0,Z.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,Z.jsx)(`path`,{d:`m21 21-4.35-4.35`})]}),(0,Z.jsx)(`input`,{value:p,onChange:e=>m(e.target.value),placeholder:`Search files...`,style:{width:`100%`,background:`var(--bg-glass)`,border:`1px solid var(--border)`,borderRadius:`var(--radius-sm)`,padding:`4px 8px 4px 26px`,fontSize:`12px`,color:`var(--text-primary)`,outline:`none`}}),p&&(0,Z.jsx)(`button`,{onClick:()=>m(``),type:`button`,style:{position:`absolute`,right:`6px`,background:`none`,border:`none`,color:`var(--text-dim)`,cursor:`pointer`,padding:`2px`,lineHeight:1},title:`Clear search`,children:(0,Z.jsxs)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,Z.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]})}),y&&(0,Z.jsxs)(`div`,{style:{padding:`4px 10px 6px`,borderBottom:`1px solid var(--border)`,display:`flex`,gap:`4px`,alignItems:`center`,fontSize:`11px`},children:[(0,Z.jsx)(`span`,{style:{color:`var(--text-dim)`,flexShrink:0},children:y===`file`?(0,Z.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`path`,{d:`M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z`}),(0,Z.jsx)(`polyline`,{points:`13 2 13 9 20 9`})]}):(0,Z.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,Z.jsx)(`path`,{d:`M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z`})})}),(0,Z.jsx)(`input`,{ref:Ne,value:C,onChange:e=>w(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ze(),e.key===`Escape`&&b(void 0)},placeholder:y===`file`?`name.ts`:`folder-name`,style:{flex:1,background:`var(--bg-solid)`,border:`1px solid var(--border-bright)`,borderRadius:`var(--radius-sm)`,padding:`2px 5px`,fontSize:`11px`,color:`var(--text-primary)`,outline:`none`}}),(0,Z.jsx)(`button`,{onClick:ze,style:{padding:`2px 6px`,fontSize:`10px`,border:`1px solid var(--border)`,borderRadius:`var(--radius-sm)`,background:`var(--accent-bg)`,color:`var(--accent-text)`,cursor:`pointer`},type:`button`,children:`Create`}),(0,Z.jsx)(`button`,{onClick:()=>b(void 0),style:{padding:`2px 6px`,fontSize:`10px`,border:`none`,background:`none`,color:`var(--text-dim)`,cursor:`pointer`},type:`button`,children:`Cancel`})]}),T&&(0,Z.jsxs)(`div`,{style:{padding:`4px 10px`,borderBottom:`1px solid var(--border)`,display:`flex`,gap:`6px`,alignItems:`center`,fontSize:`11px`,background:`rgba(248,113,113,0.06)`},children:[(0,Z.jsxs)(`span`,{style:{color:`var(--error)`},children:[`Delete `,T.split(`/`).pop(),`?`]}),(0,Z.jsx)(`button`,{onClick:()=>Be(T),style:{padding:`2px 6px`,fontSize:`10px`,border:`1px solid var(--error)`,borderRadius:`var(--radius-sm)`,background:`transparent`,color:`var(--error)`,cursor:`pointer`},type:`button`,children:`Delete`}),(0,Z.jsx)(`button`,{onClick:()=>E(void 0),style:{padding:`2px 6px`,fontSize:`10px`,border:`none`,background:`none`,color:`var(--text-dim)`,cursor:`pointer`},type:`button`,children:`Cancel`})]}),se&&(0,Z.jsx)(`div`,{style:{position:`absolute`,inset:0,zIndex:10,display:`flex`,alignItems:`center`,justifyContent:`center`,background:`var(--bg-glass)`,fontSize:`13px`,color:`var(--accent-text)`},children:`Uploading…`}),(0,Z.jsxs)(`div`,{style:{flex:1,overflowY:`auto`,padding:`4px 0`,fontSize:`12px`,position:`relative`},onDragOver:e=>{e.preventDefault();let t=e.dataTransfer.types.includes(`application/x-pi-path`)||e.dataTransfer.types.includes(`application/x-pi-paths`);e.dataTransfer.dropEffect=t?`move`:`copy`},onDrop:async e=>{e.preventDefault(),ue(void 0);let t=e.dataTransfer.getData(`application/x-pi-paths`),n=e.dataTransfer.getData(`application/x-pi-path`),r=[];if(t)try{r=JSON.parse(t)}catch{r=n?[n]:[]}else n&&(r=[n]);if(r.length>0){await Je(r,``),de.current=void 0;return}let i=await tg(e.dataTransfer);i.length>0&&(await Fe(i,``),de.current=void 0)},children:[s&&a.length===0&&(0,Z.jsx)(`div`,{style:{padding:`8px 12px`},children:(0,Z.jsx)(Fp,{variant:`tree`,count:8})}),ye&&(0,Z.jsx)(`div`,{style:{padding:`4px 12px 2px`,fontSize:`11px`,color:`var(--text-dim)`},children:`Searching file contents…`}),xe!==void 0&&(0,Z.jsx)(`div`,{style:{padding:`2px 12px`,fontSize:`10px`,color:`var(--error)`},children:xe}),!ye&&_e!==void 0&&_e.matches.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{style:{padding:`3px 12px`,fontSize:`10px`,color:`var(--text-dim)`,borderBottom:`1px solid var(--border)`,display:`flex`,gap:`8px`,alignItems:`center`},children:[(0,Z.jsxs)(`span`,{children:[_e.matches.length,` match`,_e.matches.length===1?``:`es`,` in `,cg(_e.matches).length,` file`,cg(_e.matches).length===1?``:`s`]}),_e.truncated&&(0,Z.jsx)(`span`,{style:{color:`var(--accent-bg)`},children:`truncated`}),_e.engine===`node`&&(0,Z.jsx)(`span`,{style:{fontSize:`8px`,fontWeight:600,textTransform:`uppercase`,background:`rgba(229,188,96,0.15)`,color:`var(--accent-bg)`,padding:`1px 5px`,borderRadius:`var(--radius-sm)`},children:`fallback`})]}),cg(_e.matches).map(([e,t])=>{let n=Ce.has(e);return(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{onClick:()=>we(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),style:{display:`flex`,alignItems:`center`,gap:`4px`,padding:`3px 10px`,cursor:`pointer`,color:`var(--text-secondary)`,fontSize:`11px`,fontFamily:`monospace`},children:[(0,Z.jsx)(`span`,{style:{fontSize:`10px`,width:`12px`,flexShrink:0},children:n?`▾`:`▸`}),(0,Z.jsx)(`span`,{style:{flex:1,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e}),(0,Z.jsx)(`span`,{style:{fontSize:`10px`,color:`var(--text-dim)`,flexShrink:0},children:t.length})]}),n&&t.map((t,n)=>(0,Z.jsxs)(`div`,{onClick:()=>Ie(e),title:`${e}:${t.line}:${t.column}`,style:{display:`flex`,gap:`8px`,padding:`1px 10px 1px 24px`,cursor:`pointer`,fontSize:`11px`,fontFamily:`monospace`,color:`var(--text-dim)`},className:`search-match-row`,children:[(0,Z.jsx)(`span`,{style:{color:`var(--text-dim)`,width:`36px`,flexShrink:0,textAlign:`right`,fontSize:`10px`},children:t.line}),(0,Z.jsx)(`span`,{style:{flex:1,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:(()=>{let e=t.column-1,n=t.length,r=t.lineSnippet,i=r.slice(0,e),a=r.slice(e,e+n),o=r.slice(e+n);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{children:i}),(0,Z.jsx)(`span`,{style:{background:`rgba(229,188,96,0.35)`,color:`var(--text-primary)`,borderRadius:`2px`},children:a}),(0,Z.jsx)(`span`,{children:o})]})})()})]},`${e}-${t.line}-${t.column}-${n}`))]},`cs-${e}`)})]}),Ve.length===0&&!s&&(0,Z.jsx)(`div`,{style:{padding:`16px`,textAlign:`center`,color:`var(--text-dim)`,fontSize:`12px`},children:p?`No files match`:`No files`}),Ve.map(e=>Ye(e,0))]}),(j.size>0||F)&&(0,Z.jsxs)(`div`,{className:`file-tree-batch-bar`,children:[(0,Z.jsxs)(`div`,{className:`file-tree-batch-info`,children:[(0,Z.jsx)(`span`,{className:`file-tree-batch-count`,children:j.size}),(0,Z.jsx)(`span`,{children:`selected`})]}),(0,Z.jsxs)(`div`,{className:`file-tree-batch-actions`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`file-tree-batch-btn select-all`,onClick:()=>{j.size===He.length&&He.length>0?Ge():We()},title:j.size===He.length&&He.length>0?`Deselect all`:`Select all`,children:j.size===He.length&&He.length>0?`Deselect all`:`Select all`}),j.size>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`button`,{type:`button`,className:`file-tree-batch-btn download`,onClick:qe,disabled:B,title:`Download ${j.size} selected item${j.size===1?``:`s`} as Zip`,children:[(0,Z.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,Z.jsx)(`polyline`,{points:`7 10 12 15 17 10`}),(0,Z.jsx)(`line`,{x1:`12`,y1:`15`,x2:`12`,y2:`3`})]}),(0,Z.jsx)(`span`,{children:B?`Zipping…`:`Zip (${j.size})`})]}),(0,Z.jsxs)(`button`,{type:`button`,className:`file-tree-batch-btn delete`,onClick:()=>R(!0),disabled:z||B,title:`Delete selected files`,children:[(0,Z.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`polyline`,{points:`3 6 5 6 21 6`}),(0,Z.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`})]}),(0,Z.jsxs)(`span`,{children:[`Delete (`,j.size,`)`]})]})]}),(0,Z.jsx)(`button`,{type:`button`,className:`file-tree-batch-btn close`,onClick:()=>{Ge(),I(!1)},title:`Close / Exit selection mode`,children:`✕`})]})]})]}),U&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{style:{position:`fixed`,inset:0,zIndex:999,background:`transparent`},onClick:()=>te(null)}),(0,Z.jsxs)(`div`,{ref:ne,style:{position:`absolute`,left:U.x,top:U.y,zIndex:1e3,minWidth:`180px`,background:`var(--bg-solid)`,border:`1px solid var(--border-bright)`,borderRadius:`var(--radius-sm)`,padding:`4px 0`,fontSize:`12px`,userSelect:`none`},onClick:()=>te(null),children:[(0,Z.jsxs)(`div`,{style:{padding:`4px 12px 6px`,borderBottom:`1px solid var(--border)`,color:`var(--text-primary)`,fontWeight:600,fontSize:`11px`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,maxWidth:`220px`},children:[U.node.type===`directory`?(0,Z.jsx)(`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,Z.jsx)(`path`,{d:`M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z`})}):Kh(U.node.name,13),` `,U.node.name]}),(0,Z.jsxs)(`div`,{className:`context-menu-item`,onClick:e=>{e.stopPropagation(),Ee(U.node.path)},style:ug,children:[(0,Z.jsx)(`span`,{style:{width:`16px`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0},children:(0,Z.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`,ry:`2`}),(0,Z.jsx)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})]})}),(0,Z.jsx)(`span`,{children:`Copy Relative Path`})]}),(0,Z.jsxs)(`div`,{className:`context-menu-item`,onClick:e=>{e.stopPropagation(),De(U.node.path)},style:ug,children:[(0,Z.jsx)(`span`,{style:{width:`16px`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0},children:(0,Z.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`}),(0,Z.jsx)(`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`})]})}),(0,Z.jsx)(`span`,{children:`Copy Absolute Path`})]}),(0,Z.jsxs)(`div`,{className:`context-menu-item`,onClick:async t=>{t.stopPropagation(),te(null);try{j.size>1&&j.has(U.node.path)?await gn(e,Array.from(j)):await hn(e,U.node.path)}catch(e){u(e instanceof Error?e.message:`download failed`)}},style:ug,children:[(0,Z.jsx)(`span`,{style:{width:`16px`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0},children:(0,Z.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,Z.jsx)(`polyline`,{points:`7 10 12 15 17 10`}),(0,Z.jsx)(`line`,{x1:`12`,y1:`15`,x2:`12`,y2:`3`})]})}),(0,Z.jsx)(`span`,{children:j.size>1&&j.has(U.node.path)?`Download ${j.size} items as Zip`:U.node.type===`directory`?`Download as Zip`:`Download`})]}),(0,Z.jsx)(`div`,{style:{height:`1px`,background:`var(--border)`,margin:`4px 0`}}),U.node.type===`directory`&&(0,Z.jsxs)(`div`,{className:`context-menu-item`,onClick:e=>{e.stopPropagation(),te(null),S(U.node.path),b(`file`),w(``)},style:ug,children:[(0,Z.jsx)(`span`,{style:{width:`16px`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0},children:(0,Z.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`}),(0,Z.jsx)(`polyline`,{points:`14 2 14 8 20 8`}),(0,Z.jsx)(`line`,{x1:`12`,y1:`18`,x2:`12`,y2:`12`}),(0,Z.jsx)(`line`,{x1:`9`,y1:`15`,x2:`15`,y2:`15`})]})}),(0,Z.jsx)(`span`,{children:`New File`})]}),U.node.type===`directory`&&(0,Z.jsxs)(`div`,{className:`context-menu-item`,onClick:e=>{e.stopPropagation(),te(null),S(U.node.path),b(`folder`),w(``)},style:ug,children:[(0,Z.jsx)(`span`,{style:{width:`16px`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0},children:(0,Z.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`path`,{d:`M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z`}),(0,Z.jsx)(`line`,{x1:`12`,y1:`11`,x2:`12`,y2:`17`}),(0,Z.jsx)(`line`,{x1:`9`,y1:`14`,x2:`15`,y2:`14`})]})}),(0,Z.jsx)(`span`,{children:`New Folder`})]}),(0,Z.jsxs)(`div`,{className:`context-menu-item`,onClick:e=>{e.stopPropagation(),te(null),g(U.node.path),v(U.node.name),setTimeout(()=>Me.current?.focus(),50)},style:ug,children:[(0,Z.jsx)(`span`,{style:{width:`16px`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0},children:(0,Z.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,Z.jsx)(`path`,{d:`M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z`})})}),(0,Z.jsx)(`span`,{children:`Rename`})]}),(0,Z.jsxs)(`div`,{className:`context-menu-item`,onClick:e=>{e.stopPropagation(),te(null),j.size>1&&j.has(U.node.path)?R(!0):E(U.node.path)},style:{...ug,color:`var(--error)`},children:[(0,Z.jsx)(`span`,{style:{width:`16px`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0},children:(0,Z.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`polyline`,{points:`3 6 5 6 21 6`}),(0,Z.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`})]})}),(0,Z.jsx)(`span`,{children:j.size>1&&j.has(U.node.path)?`Delete ${j.size} items`:`Delete`})]})]})]}),L&&(0,Z.jsx)(`div`,{className:`file-confirm-modal-overlay`,onClick:()=>!z&&R(!1),children:(0,Z.jsxs)(`div`,{className:`file-confirm-modal`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(`div`,{className:`file-confirm-modal-title`,children:[`Delete `,j.size,` `,j.size===1?`item`:`items`,`?`]}),(0,Z.jsx)(`div`,{className:`file-confirm-modal-desc`,children:`Are you sure you want to permanently delete these items? This action cannot be undone.`}),(0,Z.jsxs)(`div`,{className:`file-confirm-modal-list`,children:[Array.from(j).slice(0,50).map(e=>(0,Z.jsxs)(`div`,{className:`file-confirm-item`,children:[`• `,e]},e)),j.size>50&&(0,Z.jsxs)(`div`,{className:`file-confirm-item-more`,children:[`...and `,j.size-50,` more items`]})]}),(0,Z.jsxs)(`div`,{className:`file-confirm-modal-actions`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`file-confirm-btn cancel`,onClick:()=>R(!1),disabled:z,children:`Cancel`}),(0,Z.jsx)(`button`,{type:`button`,className:`file-confirm-btn danger`,onClick:Ke,disabled:z,children:z?`Deleting…`:`Delete ${j.size} ${j.size===1?`item`:`items`}`})]})]})})]})}var ug={display:`flex`,alignItems:`center`,gap:`8px`,padding:`6px 12px`,cursor:`pointer`,color:`var(--text-secondary)`,transition:`background 0.1s ease`},dg={ts:`typescript`,tsx:`tsx`,js:`javascript`,jsx:`jsx`,mjs:`javascript`,mts:`typescript`,cjs:`javascript`,json:`json`,css:`css`,scss:`css`,less:`css`,html:`html`,htm:`html`,xhtml:`html`,svg:`html`,xml:`xml`,xsl:`xml`,xslt:`xml`,md:`markdown`,mdx:`markdown`,py:`python`,pyw:`python`,rs:`rust`,go:`go`,sh:`shell`,bash:`shell`,zsh:`shell`,fish:`shell`,yaml:`yaml`,yml:`yaml`,toml:`toml`,sql:`sql`,cpp:`cpp`,c:`cpp`,h:`cpp`,hpp:`cpp`,cc:`cpp`,cxx:`cpp`,java:`java`,class:`java`,jar:`java`,rb:`ruby`,rake:`ruby`,gemspec:`ruby`,kt:`kotlin`,kts:`kotlin`,ktm:`kotlin`,scala:`scala`,sc:`scala`,swift:`swift`,groovy:`groovy`,gvy:`groovy`,gsh:`groovy`,cs:`csharp`,csx:`csharp`,lua:`lua`,pl:`perl`,pm:`perl`,t:`perl`,r:`r`,rmd:`r`,ps1:`powershell`,psm1:`powershell`,psd1:`powershell`,clj:`clojure`,cljs:`clojure`,cljc:`clojure`,edn:`clojure`,hs:`haskell`,lhs:`haskell`,ml:`ocaml`,mli:`ocaml`,proto:`protobuf`,cmake:`cmake`,nginx:`nginx`,nginxconf:`nginx`,Dockerfile:`dockerfile`,dockerfile:`dockerfile`,ini:`properties`,cfg:`properties`,conf:`properties`,env:`properties`,jinja:`jinja2`,jinja2:`jinja2`,j2:`jinja2`,Makefile:`makefile`,mk:`makefile`,mak:`makefile`,diff:`diff`,patch:`diff`};function fg(e){switch(dg[e.split(`.`).pop()?.toLowerCase()??``]){case`typescript`:return Me({typescript:!0});case`tsx`:return Me({jsx:!0,typescript:!0});case`javascript`:return Me();case`jsx`:return Me({jsx:!0});case`python`:return ze();case`rust`:return Le();case`markdown`:return Oe();case`json`:return nt();case`html`:return tt();case`css`:return Ie();case`cpp`:return Re();case`yaml`:return Ae();case`java`:return je();case`shell`:return Be.define(pt);case`toml`:return Be.define(ke);case`dockerfile`:return Be.define(Ve);case`properties`:return Be.define(mt);case`lua`:return Be.define(Je);case`perl`:return Be.define(ht);case`r`:return Be.define(ft);case`powershell`:return Be.define(Ke);case`ruby`:return Be.define(Qe);case`go`:return Be.define($e);case`swift`:return Be.define(it);case`kotlin`:return Be.define(Ze);case`scala`:return Be.define(st);case`groovy`:return Be.define(dt);case`csharp`:return Be.define(Xe);case`xml`:return Be.define(rt);case`jinja2`:return Be.define(He);case`sql`:return Be.define(Ye);case`diff`:return Be.define(lt);case`clojure`:return Be.define(ot);case`haskell`:return Be.define(qe);case`ocaml`:return Be.define(et);case`protobuf`:return Be.define(ct);case`cmake`:return Be.define(at);case`nginx`:return Be.define(ut);case`makefile`:return Be.define(pt);default:return}}var pg=Fe.define([{tag:W.keyword,color:`var(--cm-keyword, var(--accent-text))`,fontWeight:`bold`},{tag:W.operator,color:`var(--cm-operator, var(--text-secondary))`},{tag:W.string,color:`var(--cm-string, #98c379)`},{tag:W.number,color:`var(--cm-number, #d19a66)`},{tag:W.bool,color:`var(--cm-bool, #d19a66)`},{tag:W.null,color:`var(--cm-null, #d19a66)`},{tag:W.comment,color:`var(--cm-comment, #5c6370)`,fontStyle:`italic`},{tag:W.lineComment,color:`var(--cm-comment, #5c6370)`,fontStyle:`italic`},{tag:W.blockComment,color:`var(--cm-comment, #5c6370)`,fontStyle:`italic`},{tag:W.function(W.variableName),color:`var(--cm-function, #61afef)`},{tag:W.function(W.propertyName),color:`var(--cm-function, #61afef)`},{tag:W.className,color:`var(--cm-class, #e5c07b)`},{tag:W.typeName,color:`var(--cm-type, #e5c07b)`},{tag:W.propertyName,color:`var(--cm-property, var(--text-primary))`},{tag:W.variableName,color:`var(--cm-variable, var(--text-primary))`},{tag:W.attributeName,color:`var(--cm-attr-name, #98c379)`},{tag:W.attributeValue,color:`var(--cm-attr-value, #98c379)`},{tag:W.tagName,color:`var(--cm-tag, var(--accent-text))`},{tag:W.punctuation,color:`var(--cm-punctuation, var(--text-dim))`},{tag:W.bracket,color:`var(--cm-bracket, var(--text-dim))`},{tag:W.regexp,color:`var(--cm-regex, #c678dd)`},{tag:W.escape,color:`var(--cm-escape, #c678dd)`},{tag:W.link,color:`var(--cm-link, #61afef)`,textDecoration:`underline`},{tag:W.heading,color:`var(--cm-heading, var(--accent-text))`,fontWeight:`bold`},{tag:W.strong,fontWeight:`bold`},{tag:W.emphasis,fontStyle:`italic`},{tag:W.inserted,color:`var(--cm-inserted, #98c379)`},{tag:W.deleted,color:`var(--cm-deleted, #e06c75)`},{tag:W.changed,color:`var(--cm-changed, #d19a66)`},{tag:W.meta,color:`var(--cm-meta, var(--text-dim))`}]);function mg({value:e,onChange:t,onSave:n,fileName:r,wordWrap:i=!1,onSelectionChange:a}){let o=(0,G.useRef)(null),s=(0,G.useRef)(null),c=(0,G.useRef)(new Ue),l=(0,G.useRef)(t),u=(0,G.useRef)(n),d=(0,G.useRef)(a);l.current=t,u.current=n,d.current=a;let f=(0,G.useMemo)(()=>fg(r),[r]);return(0,G.useEffect)(()=>{if(!o.current)return;let t=We.updateListener.of(e=>{if(e.docChanged&&l.current(e.state.doc.toString()),e.selectionSet){let t=d.current;if(t!==void 0){let n=e.state.selection.main;if(n.empty)t(null);else{let r=e.state.doc.lineAt(n.from).number,i=e.state.doc.lineAt(n.to).number;t({startLine:Math.min(r,i),endLine:Math.max(r,i)})}}}}),n=Ne.of([{key:`Mod-s`,run:()=>(u.current?.(),!0)}]),r=We.theme({"&":{fontSize:`13px`,height:`100%`},".cm-scroller":{overflow:`auto`},".cm-content":{fontFamily:`var(--font-mono, 'JetBrains Mono', 'Fira Code', monospace)`,padding:`8px 0`},".cm-gutters":{zIndex:1,borderRight:`1px solid var(--border)`,background:`var(--bg-solid)`,color:`var(--text-dim)`},".cm-activeLineGutter":{background:`var(--bg-glass-hover)`},".cm-activeLine":{background:`var(--bg-glass-hover)`},"&.cm-focused .cm-cursor":{borderLeftColor:`var(--accent-text)`},".cm-selectionBackground":{background:`var(--selection-bg, rgba(255,255,255,0.1))`},"&.cm-focused .cm-selectionBackground":{background:`var(--selection-bg-focused, rgba(255,255,255,0.15))`},".cm-matchingBracket":{background:`rgba(255,255,255,0.08)`,outline:`1px solid var(--text-dim)`},".cm-foldPlaceholder":{background:`var(--bg-glass)`,border:`1px solid var(--border)`,color:`var(--text-dim)`}}),a=new We({state:Ge.create({doc:e,extensions:[Pe,gt(pg,{fallback:!0}),...f===void 0?[]:[f],r,t,n,c.current.of(i?We.lineWrapping:[])]}),parent:o.current});return s.current=a,()=>{a.destroy(),s.current=null}},[(0,G.useMemo)(()=>r,[r])]),(0,G.useEffect)(()=>{let t=s.current;if(!t)return;let n=t.state.doc.toString();n!==e&&t.dispatch({changes:{from:0,to:n.length,insert:e}})},[e]),(0,G.useEffect)(()=>{let e=s.current;e&&e.dispatch({effects:c.current.reconfigure(i?We.lineWrapping:[])})},[i]),(0,Z.jsx)(`div`,{ref:o,style:{flex:1,minHeight:0,minWidth:0,background:`var(--bg-solid)`}})}var hg=/^light|clean|terracotta|sage$/i;function gg(){let[e,t]=(0,G.useState)(()=>{if(typeof window>`u`)return!1;try{let e=document.documentElement.getAttribute(`data-theme`);if(e&&hg.test(e))return!0}catch{}return window.matchMedia?.(`(prefers-color-scheme: light)`)?.matches??!1});return(0,G.useEffect)(()=>{let e=document.documentElement,n=()=>{let n=e.getAttribute(`data-theme`);t(!!(n&&hg.test(n)))};n();let r=window.matchMedia?.(`(prefers-color-scheme: dark)`),i=()=>n();r?.addEventListener?.(`change`,i);let a=new MutationObserver(i);return e&&a.observe(e,{attributes:!0,attributeFilter:[`data-theme`]}),()=>{r?.removeEventListener?.(`change`,i),a.disconnect()}},[]),e}var _g={ts:`typescript`,tsx:`tsx`,js:`javascript`,jsx:`jsx`,json:`json`,css:`css`,html:`markup`,md:`markdown`,py:`python`,rs:`rust`,go:`go`,sh:`bash`,bash:`bash`,yaml:`yaml`,yml:`yaml`,toml:`toml`,sql:`sql`,cpp:`cpp`,c:`cpp`,h:`cpp`,hpp:`cpp`,java:`java`,xml:`markup`,svg:`markup`,kt:`kotlin`,dart:`dart`,rb:`ruby`,php:`php`,r:`r`,scala:`scala`,swift:`swift`};function vg({code:e,language:t}){let n=gg(),r=_g[t]??`bash`;return(0,Z.jsx)(ve,{theme:n?_e.vsLight:_e.vsDark,code:e.trimEnd(),language:r,children:({className:e,style:t,tokens:n,getLineProps:r,getTokenProps:i})=>(0,Z.jsx)(`pre`,{className:e,style:{...t,margin:0,padding:`12px 14px`,fontSize:`12px`,lineHeight:1.6,overflowX:`auto`,borderRadius:`6px`,background:`var(--bg-glass-strong)`},children:(0,Z.jsx)(`code`,{children:n.map((e,t)=>{let{key:n,...a}=r({line:e,key:t});return(0,Z.jsxs)(`div`,{...a,children:[(0,Z.jsx)(`span`,{style:{display:`inline-block`,width:`2ch`,textAlign:`right`,marginRight:`12px`,userSelect:`none`,opacity:.35,fontSize:`11px`},children:t+1}),e.map((e,t)=>{let{key:n,...r}=i({token:e,key:t});return(0,Z.jsx)(`span`,{...r},t)})]},t)})})})})}function yg(e){let t=e.split(`.`).pop()?.toLowerCase()??``;return t===`md`||t===`mdx`||t===`markdown`}function bg({content:e,fileName:t}){let n=t.split(`.`).pop()?.toLowerCase()??``;return yg(t)?(0,Z.jsx)(`div`,{className:`markdown-preview`,style:{padding:`16px 20px`,fontSize:`14px`,lineHeight:1.7,color:`var(--text-primary)`,overflowY:`auto`,height:`100%`},children:(0,Z.jsx)(Te,{remarkPlugins:[Se],rehypePlugins:[Ce],components:{code({className:e,children:t,...n}){let r=/language-(\w+)/.exec(e??``),i=String(t).replace(/\n$/,``);return r?(0,Z.jsx)(vg,{code:i,language:r[1]}):(0,Z.jsx)(`code`,{style:{background:`var(--bg-glass-strong)`,padding:`2px 5px`,borderRadius:`3px`,fontSize:`0.9em`,color:`var(--accent-text)`},...n,children:t})},pre({children:e}){return(0,Z.jsx)(Z.Fragment,{children:e})},a({href:e,children:t}){return(0,Z.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,style:{color:`var(--accent-text)`},children:t})},img({src:e,alt:t}){return(0,Z.jsx)(`img`,{src:e,alt:t??``,style:{maxWidth:`100%`,height:`auto`,borderRadius:4,boxShadow:`0 1px 4px rgba(0,0,0,0.1)`}})},table({children:e}){return(0,Z.jsx)(`div`,{className:`table-wrapper`,children:(0,Z.jsx)(`table`,{className:`md-table`,children:e})})},th({children:e}){return(0,Z.jsx)(`th`,{className:`md-th`,children:e})},td({children:e}){return(0,Z.jsx)(`td`,{className:`md-td`,children:e})},blockquote({children:e}){return(0,Z.jsx)(`blockquote`,{style:{borderLeft:`3px solid var(--accent-bg)`,margin:`12px 0`,padding:`4px 14px`,background:`var(--bg-glass)`,color:`var(--text-secondary)`},children:e})},h1({children:e}){return(0,Z.jsx)(`h1`,{style:{fontSize:`20px`,fontWeight:700,margin:`20px 0 10px`,color:`var(--text-primary)`,borderBottom:`1px solid var(--border)`,paddingBottom:`6px`},children:e})},h2({children:e}){return(0,Z.jsx)(`h2`,{style:{fontSize:`17px`,fontWeight:600,margin:`18px 0 8px`,color:`var(--text-primary)`,borderBottom:`1px solid var(--border)`,paddingBottom:`4px`},children:e})},h3({children:e}){return(0,Z.jsx)(`h3`,{style:{fontSize:`15px`,fontWeight:600,margin:`14px 0 6px`,color:`var(--text-primary)`},children:e})},hr(){return(0,Z.jsx)(`hr`,{style:{border:`none`,borderTop:`1px solid var(--border)`,margin:`16px 0`}})}},children:e})}):(0,Z.jsx)(`div`,{style:{padding:`16px 0`,fontSize:`13px`,overflowY:`auto`,height:`100%`},children:(0,Z.jsx)(vg,{code:e,language:n})})}var xg=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`bmp`,`ico`,`avif`]),Sg=new Set([`mp3`,`wav`,`ogg`,`oga`,`opus`,`m4a`,`aac`,`flac`,`weba`,`webm`]),Cg=new Set([`pdf`,`docx`]);function wg(e){return e.replace(/\\/g,`/`).split(`/`).pop()?.toLowerCase().split(`.`).pop()??``}function Tg(e){return xg.has(wg(e))}function Eg(e){return Sg.has(wg(e))}function Dg(e){return Cg.has(wg(e))}function Og(e){let t=wg(e);return t===`html`||t===`htm`}function kg(e){let t=wg(e);return t===`md`||t===`mdx`||t===`markdown`}function Ag(e){return wg(e)===`svg`}function jg(e){let t=wg(e);return t===`md`||t===`mdx`||t===`markdown`||t===`html`||t===`htm`||t===`svg`}function Mg(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Ng(e){return wg(e)}var Pg=(0,G.memo)(function({path:e,fileName:t,content:n,language:r,saving:i,dirty:a,onChange:o,onSave:s,savedAt:c,error:l,showToolbar:u=!0,size:d,onSendSelection:f}){let[p,m]=(0,G.useState)(`raw`),[h,g]=(0,G.useState)(!0),[_,v]=(0,G.useState)(null),y=Og(e);kg(e);let b=Ag(e),x=jg(e);(0,G.useEffect)(()=>{!x&&p===`rendered`&&m(`raw`)},[e,x,p]);let{pathDir:S,pathBase:C}=(0,G.useMemo)(()=>{let t=e.replace(/\\/g,`/`),n=t.lastIndexOf(`/`);return n===-1?{pathDir:``,pathBase:t}:{pathDir:t.slice(0,n),pathBase:t.slice(n+1)}},[e]);return(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,flex:1,minHeight:0},children:[u&&(0,Z.jsxs)(`div`,{className:`file-editor-toolbar`,style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:`10px`,padding:`4px 10px`,fontSize:`11px`,borderBottom:`1px solid var(--border)`,background:`var(--bg-glass, rgba(0,0,0,0.02))`,flexShrink:0,minHeight:`34px`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,minWidth:0,flex:1},children:[S?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{style:{display:`inline-flex`,alignItems:`center`,gap:`4px`,minWidth:0,color:`var(--text-dim)`,fontSize:`11px`},title:e,children:(0,Z.jsxs)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,opacity:.7},children:[S,` /`]})}),x&&(0,Z.jsx)(`span`,{style:{width:`1px`,height:`14px`,background:`var(--border)`,flexShrink:0,margin:`0 2px`}})]}):null,x&&(0,Z.jsxs)(`div`,{className:`file-editor-mode-toggle`,style:{display:`inline-flex`,alignItems:`center`,background:`var(--bg-glass-hover, rgba(255, 255, 255, 0.06))`,border:`1px solid var(--border)`,borderRadius:`6px`,padding:`2px`,gap:`2px`,flexShrink:0},children:[(0,Z.jsxs)(`button`,{onClick:()=>m(`raw`),type:`button`,className:`file-mode-btn${p===`raw`?` active`:``}`,style:{display:`inline-flex`,alignItems:`center`,gap:`4px`,background:p===`raw`?`var(--bg-solid, #232730)`:`transparent`,color:p===`raw`?`var(--text-primary)`:`var(--text-dim)`,border:`none`,borderRadius:`4px`,padding:`2px 8px`,fontSize:`11px`,fontWeight:p===`raw`?600:500,cursor:`pointer`,boxShadow:p===`raw`?`0 1px 3px rgba(0,0,0,0.2)`:`none`,transition:`all 0.15s ease`},title:`View / edit raw code`,children:[(0,Z.jsxs)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`polyline`,{points:`16 18 22 12 16 6`}),(0,Z.jsx)(`polyline`,{points:`8 6 2 12 8 18`})]}),(0,Z.jsx)(`span`,{children:`Raw`})]}),(0,Z.jsxs)(`button`,{onClick:()=>m(`rendered`),type:`button`,className:`file-mode-btn${p===`rendered`?` active`:``}`,style:{display:`inline-flex`,alignItems:`center`,gap:`4px`,background:p===`rendered`?`var(--bg-solid, #232730)`:`transparent`,color:p===`rendered`?`var(--text-primary)`:`var(--text-dim)`,border:`none`,borderRadius:`4px`,padding:`2px 8px`,fontSize:`11px`,fontWeight:p===`rendered`?600:500,cursor:`pointer`,boxShadow:p===`rendered`?`0 1px 3px rgba(0,0,0,0.2)`:`none`,transition:`all 0.15s ease`},title:`View rendered preview`,children:[(0,Z.jsxs)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`path`,{d:`M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z`}),(0,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]}),(0,Z.jsx)(`span`,{children:`Rendered`})]})]})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`6px`,flexShrink:0},children:[p===`raw`&&(0,Z.jsxs)(`button`,{onClick:()=>g(e=>!e),type:`button`,className:`file-editor-btn${h?` active`:``}`,style:{display:`inline-flex`,alignItems:`center`,gap:`4px`,padding:`2px 8px`,fontSize:`11px`,fontWeight:500,borderRadius:`5px`,border:`1px solid`,background:h?`var(--accent-subtle, rgba(99,102,241,0.12))`:`transparent`,color:h?`var(--accent-text, #818cf8)`:`var(--text-dim)`,borderColor:h?`var(--accent-subtle-border, rgba(99,102,241,0.25))`:`var(--border)`,cursor:`pointer`,transition:`all 0.15s ease`},title:h?`Word wrap enabled (click to disable)`:`Word wrap disabled (click to enable)`,children:[(0,Z.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`polyline`,{points:`9 10 4 15 9 20`}),(0,Z.jsx)(`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`})]}),(0,Z.jsx)(`span`,{children:`Wrap`})]}),p===`raw`&&f!==void 0&&(0,Z.jsxs)(`button`,{onClick:()=>{_!==null&&f(_)},disabled:_===null||i,type:`button`,className:`file-editor-btn send-selection${_===null?``:` active`}`,style:{display:`inline-flex`,alignItems:`center`,gap:`5px`,padding:`2px 10px`,fontSize:`11px`,fontWeight:500,borderRadius:`5px`,border:_===null?`1px solid var(--border)`:`1px solid var(--accent)`,background:_===null?`transparent`:`var(--accent-bg, rgba(99,102,241,0.15))`,color:_===null?`var(--text-dim)`:`var(--accent-text, #a5b4fc)`,cursor:_===null?`default`:`pointer`,opacity:_===null?.6:1,transition:`all 0.15s ease`},title:_===null?`Select lines in editor to send to chat`:`Send lines ${_.startLine}–${_.endLine} to chat`,children:[(0,Z.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`}),(0,Z.jsx)(`polyline`,{points:`10 9 14 12 10 15`})]}),(0,Z.jsx)(`span`,{children:_===null?`Send selection ⇢ chat`:`Send L${_.startLine}–${_.endLine} ⇢ chat`})]})]})]}),(y||b)&&p===`rendered`?(0,Z.jsx)(`div`,{style:{flex:1,minHeight:0,background:`var(--bg)`,display:`flex`,alignItems:`center`,justifyContent:`center`,overflow:`auto`},children:b?(0,Z.jsx)(`div`,{style:{width:`100%`,height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`20px`},dangerouslySetInnerHTML:{__html:n}}):(0,Z.jsx)(`iframe`,{srcDoc:n,sandbox:`allow-scripts`,style:{width:`100%`,height:`100%`,border:`none`,background:`var(--bg)`},title:`Preview ${t}`})}):p===`raw`?(0,Z.jsx)(mg,{value:n,onChange:o,onSave:s,fileName:t,wordWrap:h,onSelectionChange:v},`editor-${e}`):(0,Z.jsx)(bg,{content:n,fileName:t}),(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:`8px`,padding:`2px 10px`,fontSize:`10px`,color:`var(--text-dim)`,borderTop:`1px solid var(--border)`,background:`var(--bg-glass)`,flexShrink:0},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`},children:[r&&(0,Z.jsx)(`span`,{style:{fontFamily:`var(--font-mono, monospace)`,fontSize:`10px`,color:`var(--text-dim)`},children:r}),typeof d==`number`&&d>0&&(0,Z.jsx)(`span`,{style:{fontSize:`10px`,color:`var(--text-dim)`},children:Mg(d)})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`},children:[i?(0,Z.jsx)(`span`,{style:{color:`var(--text-dim)`,fontStyle:`italic`},children:`Saving…`}):l?(0,Z.jsx)(`span`,{style:{color:`var(--error, #e06c75)`},children:`Save failed`}):a?(0,Z.jsx)(`span`,{style:{color:`var(--accent-text, #d19a66)`},children:`Unsaved changes`}):c?(0,Z.jsxs)(`span`,{style:{color:`#98c379`},children:[`Saved `,c.toLocaleTimeString()]}):(0,Z.jsx)(`span`,{children:`Up to date`}),(0,Z.jsx)(`button`,{onClick:s,disabled:!a||i,style:{display:`inline-flex`,alignItems:`center`,gap:`3px`,padding:`2px 8px`,fontSize:`10px`,fontWeight:600,border:`1px solid var(--border)`,borderRadius:`var(--radius-sm)`,background:a?`var(--accent-bg)`:`transparent`,color:a?`var(--accent-text)`:`var(--text-dim)`,cursor:a&&!i?`pointer`:`default`,opacity:a?1:.5},type:`button`,children:i?`Saving…`:a?`Save`:`Saved`})]})]})]})});function Fg(e){return e.replace(/\\/g,`/`).split(`/`).pop()??e}function Ig(e,t){return Fg(e)}function Lg(e,t,n){let r=new URLSearchParams({projectId:e,path:t});return n!==void 0&&n>0&&r.set(`v`,String(n)),`/api/v1/files/read?${r.toString()}`}function Rg(e,t){return`/api/v1/files/download?${new URLSearchParams({projectId:e,path:t}).toString()}`}function zg(e){if(!Number.isFinite(e))return``;let t=Math.round(e),n=Math.floor(t/60),r=t%60;return`${n}:${String(r).padStart(2,`0`)}`}function Bg({projectId:e,filePath:t}){return(0,Z.jsx)(`a`,{href:Rg(e,t),download:Fg(t),title:`Download file`,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,height:20,padding:`0 5px`,background:`var(--bg-panel)`,border:`1px solid var(--border)`,borderRadius:4,color:`var(--text-muted)`,cursor:`pointer`,flexShrink:0,textDecoration:`none`},children:(0,Z.jsxs)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,Z.jsx)(`polyline`,{points:`7 10 12 15 17 10`}),(0,Z.jsx)(`line`,{x1:`12`,y1:`15`,x2:`12`,y2:`3`})]})})}function Vg({watching:e}){return(0,Z.jsxs)(`span`,{title:e?`Live sync active`:`Not watching`,style:{display:`flex`,alignItems:`center`,gap:4,color:e?`#4ade80`:`var(--text-dim)`},children:[(0,Z.jsx)(`span`,{style:{width:7,height:7,borderRadius:`50%`,background:e?`#4ade80`:`var(--border)`,display:`inline-block`,boxShadow:e?`0 0 4px #4ade80`:`none`}}),e?`live`:`static`]})}function Hg({filePath:e,projectId:t,children:n,watching:r}){return(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,padding:`4px 16px`,borderBottom:`1px solid var(--border)`,fontSize:11,color:`var(--text-dim)`,background:`var(--bg)`,flexShrink:0},children:[(0,Z.jsx)(`span`,{style:{fontFamily:`var(--font-mono, monospace)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},title:e,children:Ig(e,t)}),(0,Z.jsx)(`span`,{style:{marginLeft:`auto`},children:n}),(0,Z.jsx)(Vg,{watching:r}),(0,Z.jsx)(Bg,{projectId:t,filePath:e})]})}function Ug({projectId:e,filePath:t}){let[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(0),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(null),[u,d]=(0,G.useState)(null),f=(0,G.useRef)(null),p=Ng(t)||`image`;(0,G.useEffect)(()=>{a(0),s(null),l(null),d(null),r(!1),f.current&&=(f.current.close(),null)},[t]),(0,G.useEffect)(()=>{let n=`/api/v1/files/watch?projectId=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`,i=new EventSource(n);return f.current=i,i.addEventListener(`connected`,()=>r(!0)),i.addEventListener(`change`,e=>{try{let t=JSON.parse(e.data);typeof t.size==`number`&&s(t.size)}catch{}a(e=>e+1)}),i.addEventListener(`error`,()=>r(!1)),i.onerror=()=>r(!1),()=>{i.close(),f.current=null}},[e,t]);let m=Lg(e,t,i),h=o==null?null:Mg(o);return(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`,overflow:`hidden`},children:[(0,Z.jsxs)(Hg,{filePath:t,projectId:e,watching:n,children:[(0,Z.jsx)(`span`,{children:p||`image`}),c&&(0,Z.jsxs)(`span`,{children:[c.w,` × `,c.h]}),h&&(0,Z.jsx)(`span`,{children:h})]}),(0,Z.jsx)(`div`,{style:{flex:1,overflow:`auto`,background:`var(--bg-panel)`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:16,backgroundImage:`linear-gradient(45deg, var(--bg) 25%, transparent 25%), linear-gradient(-45deg, var(--bg) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--bg) 75%), linear-gradient(-45deg, transparent 75%, var(--bg) 75%)`,backgroundSize:`16px 16px`,backgroundPosition:`0 0, 0 8px, 8px -8px, -8px 0px`},children:u?(0,Z.jsx)(`div`,{style:{color:`#f87171`,fontSize:13},children:u}):(0,Z.jsx)(`img`,{src:m,alt:t,onLoad:e=>{let t=e.currentTarget;l({w:t.naturalWidth,h:t.naturalHeight})},onError:()=>d(`Failed to load image`),style:{maxWidth:`100%`,maxHeight:`100%`,objectFit:`contain`,boxShadow:`0 2px 8px rgba(0,0,0,0.15)`}})})]})}function Wg({projectId:e,filePath:t}){let[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(0),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(null),[u,d]=(0,G.useState)(null),f=(0,G.useRef)(null),p=Ng(t)||`audio`;(0,G.useEffect)(()=>{a(0),s(null),l(null),d(null),r(!1),f.current&&=(f.current.close(),null)},[t]),(0,G.useEffect)(()=>{let n=`/api/v1/files/watch?projectId=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`,i=new EventSource(n);return f.current=i,i.addEventListener(`connected`,()=>r(!0)),i.addEventListener(`change`,e=>{try{let t=JSON.parse(e.data);typeof t.size==`number`&&s(t.size)}catch{}l(null),d(null),a(e=>e+1)}),i.addEventListener(`error`,()=>r(!1)),i.onerror=()=>r(!1),()=>{i.close(),f.current=null}},[e,t]);let m=Lg(e,t,i);return(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`,overflow:`hidden`},children:[(0,Z.jsxs)(Hg,{filePath:t,projectId:e,watching:n,children:[(0,Z.jsx)(`span`,{children:p||`audio`}),c!=null&&(0,Z.jsx)(`span`,{children:zg(c)}),o!=null&&(0,Z.jsx)(`span`,{children:Mg(o)})]}),(0,Z.jsx)(`div`,{style:{flex:1,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:24,background:`var(--bg-panel)`},children:(0,Z.jsxs)(`div`,{style:{width:`min(680px, 100%)`},children:[u&&(0,Z.jsx)(`div`,{style:{color:`#f87171`,fontSize:13,marginBottom:12,textAlign:`center`},children:u}),(0,Z.jsx)(`audio`,{controls:!0,preload:`metadata`,src:m,onLoadedMetadata:e=>l(e.currentTarget.duration),onError:()=>d(`Failed to load audio`),style:{width:`100%`}},m)]})})]})}function Gg({projectId:e,filePath:t}){let[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(0),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(null),u=(0,G.useRef)(null),d=Ng(t),f=d===`pdf`,p=Lg(e,t,i);return(0,G.useEffect)(()=>{a(0),s(null),l(null),r(!1),u.current&&=(u.current.close(),null)},[t]),(0,G.useEffect)(()=>{fetch(Lg(e,t),{method:`HEAD`}).then(e=>{let t=e.headers.get(`content-length`);if(t){let e=Number(t);s(e),!f&&e>10485760&&l(`DOCX too large for preview (>10MB)`)}}).catch(()=>{});let n=`/api/v1/files/watch?projectId=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`,i=new EventSource(n);return u.current=i,i.addEventListener(`connected`,()=>r(!0)),i.addEventListener(`change`,e=>{try{let t=JSON.parse(e.data);if(typeof t.size==`number`&&(s(t.size),!f&&t.size>10485760)){l(`DOCX too large for preview (>10MB)`);return}}catch{}l(null),a(e=>e+1)}),i.addEventListener(`error`,()=>r(!1)),i.onerror=()=>r(!1),()=>{i.close(),u.current=null}},[e,t,f]),(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`,overflow:`hidden`},children:[(0,Z.jsxs)(Hg,{filePath:t,projectId:e,watching:n,children:[(0,Z.jsx)(`span`,{children:d===`docx`?`docx preview`:`pdf`}),o!=null&&(0,Z.jsx)(`span`,{children:Mg(o)})]}),(0,Z.jsx)(`div`,{style:{flex:1,minHeight:0,background:`var(--bg-panel)`},children:c?(0,Z.jsx)(`div`,{style:{height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:24,color:`#f87171`,fontSize:13,textAlign:`center`},children:c}):(0,Z.jsx)(`iframe`,{src:p,sandbox:f?void 0:``,title:`Preview ${Fg(t)}`,style:{width:`100%`,height:`100%`,border:`none`,background:f?`var(--bg)`:`#eef1f5`}},p)})]})}function Kg(e,t){let n=e.length,r=t.length,i=n+r,a=Array(2*i+1).fill(0),o=[];for(let s=0;s<=i;s++){o.push([...a]);for(let c=-s;c<=s;c+=2){let l;l=c===-s||c!==s&&a[c-1+i]<a[c+1+i]?a[c+1+i]:a[c-1+i]+1;let u=l-c;for(;l<n&&u<r&&e[l]===t[u];)l++,u++;if(a[c+i]=l,l>=n&&u>=r){let a=[],c=n,l=r;for(let n=s;n>0;n--){let r=o[n-1],s=c-l,u=s===-n||s!==n&&r[s-1+i]<r[s+1+i]?s+1:s-1,d=r[u+i],f=d-u;for(;c>d&&l>f;)c--,l--,a.unshift({type:`unchanged`,text:e[c],lineNo:c+1});n>0&&(c>d?(c--,a.unshift({type:`removed`,text:e[c],lineNo:c+1})):(l--,a.unshift({type:`added`,text:t[l],lineNo:l+1})))}for(;c>0&&l>0;)c--,l--,a.unshift({type:`unchanged`,text:e[c],lineNo:c+1});return a}}}return[...e.map((e,t)=>({type:`removed`,text:e,lineNo:t+1})),...t.map((e,t)=>({type:`added`,text:e,lineNo:t+1}))]}function qg({oldContent:e,newContent:t}){let n=(0,G.useMemo)(()=>Kg(e.split(`
139
+ `),t.split(`
140
+ `)),[e,t]);if(!n.some(e=>e.type!==`unchanged`))return(0,Z.jsx)(`div`,{style:{padding:`12px 16px`,fontSize:12,color:`var(--text-dim)`,fontFamily:`var(--font-mono, monospace)`},children:`No changes`});let r=new Set(n.flatMap((e,t)=>e.type===`unchanged`?[]:[t])),i=new Set;for(let e of r)for(let t=Math.max(0,e-3);t<=Math.min(n.length-1,e+3);t++)i.add(t);let a=[],o=0;for(;o<n.length;)if(i.has(o)){let e=[];for(;o<n.length&&i.has(o);)e.push(n[o]),o++;a.push({hidden:!1,lines:e})}else{let e=0;for(;o<n.length&&!i.has(o);)e++,o++;a.push({hidden:!0,count:e})}let s=[],c=1;for(let e of n)e.type===`removed`?s.push(0):s.push(c++);let l=0;return(0,Z.jsx)(`div`,{style:{fontFamily:`var(--font-mono, monospace)`,fontSize:13,lineHeight:1.6},children:a.map((e,t)=>{if(e.hidden){let n=(0,Z.jsxs)(`div`,{style:{padding:`2px 16px`,color:`var(--text-dim)`,background:`var(--bg-panel)`,fontSize:11,borderTop:`1px solid var(--border)`,borderBottom:`1px solid var(--border)`},children:[`... `,e.count,` unchanged lines ...`]},t);return l+=e.count,n}let n=e.lines.map((e,t)=>{let n=l+t,r=s[n],i=e.type===`added`?`rgba(0,200,80,0.12)`:e.type===`removed`?`rgba(240,60,60,0.14)`:`transparent`,a=e.type===`added`?`+`:e.type===`removed`?`-`:` `,o=e.type===`added`?`#4ade80`:e.type===`removed`?`#f87171`:`var(--text-dim)`;return(0,Z.jsxs)(`div`,{style:{display:`flex`,background:i,borderLeft:e.type===`added`?`3px solid #4ade80`:e.type===`removed`?`3px solid #f87171`:`3px solid transparent`},children:[(0,Z.jsx)(`span`,{style:{minWidth:44,padding:`0 8px 0 16px`,textAlign:`right`,color:`var(--text-dim)`,userSelect:`none`,fontSize:11,lineHeight:1.6,borderRight:`1px solid var(--border)`,background:`var(--bg-panel)`,flexShrink:0},children:e.type===`removed`?e.lineNo:r||``}),(0,Z.jsx)(`span`,{style:{minWidth:16,padding:`0 6px`,color:o,userSelect:`none`,flexShrink:0,fontWeight:600},children:a}),(0,Z.jsx)(`span`,{style:{flex:1,padding:`0 8px 0 0`,whiteSpace:`pre`,color:`var(--text)`,overflowX:`auto`},children:e.text||`\xA0`})]},t)});return l+=e.lines.length,(0,Z.jsx)(`div`,{children:n},t)})})}function Jg({projectId:e,filePath:t,isDark:n,previousContent:r}){let[i,a]=(0,G.useState)(null),[o,s]=(0,G.useState)(!0),[c,l]=(0,G.useState)(null),[u,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(`source`),[m,h]=(0,G.useState)(!1),[g,_]=(0,G.useState)(!1),[v,y]=(0,G.useState)(0),b=(0,G.useRef)(null),x=i?.language===`html`,S=i?.language===`markdown`,C=r!==void 0&&r!==(i?.content??``),w=i?.content.split(`
141
+ `)??[],T=(0,G.useCallback)((n=!1)=>{let r=new URLSearchParams({projectId:e,path:t});fetch(`/api/v1/files/read?${r.toString()}`).then(e=>e.json()).then(e=>{if(e.error){l(e.error);return}a(e),n&&y(e=>e+1)}).catch(e=>l(String(e))).finally(()=>s(!1))},[e,t]);return(0,G.useEffect)(()=>{s(!0),l(null),a(null),d(!1),p(`source`),h(!1),y(0),_(!1),b.current&&=(b.current.close(),null),T();let n=`/api/v1/files/watch?projectId=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`,r=new EventSource(n);return b.current=r,r.addEventListener(`connected`,()=>_(!0)),r.addEventListener(`change`,()=>T(!0)),r.addEventListener(`error`,()=>_(!1)),r.onerror=()=>_(!1),()=>{r.close(),b.current=null}},[e,t,T]),o?(0,Z.jsx)(`div`,{style:{height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`var(--text-muted)`,fontSize:13},children:`Loading...`}):c?(0,Z.jsx)(`div`,{style:{height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`#f87171`,fontSize:13},children:c}):i?(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`,overflow:`hidden`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,padding:`4px 16px`,borderBottom:`1px solid var(--border)`,fontSize:11,color:`var(--text-dim)`,background:`var(--bg)`,flexShrink:0},children:[(0,Z.jsx)(`span`,{style:{fontFamily:`var(--font-mono, monospace)`},title:t,children:Ig(t,e)}),(0,Z.jsx)(`span`,{style:{marginLeft:`auto`},children:i.language}),f===`source`&&(0,Z.jsxs)(`span`,{children:[w.length,` lines`]}),(0,Z.jsx)(`span`,{children:Mg(i.size)}),(0,Z.jsx)(Vg,{watching:g}),C&&(0,Z.jsxs)(`div`,{style:{display:`flex`,borderRadius:5,overflow:`hidden`,border:`1px solid var(--border)`},children:[(0,Z.jsx)(`button`,{onClick:()=>p(`source`),style:{padding:`2px 8px`,fontSize:11,border:`none`,cursor:`pointer`,background:f===`source`?`var(--bg-selected)`:`var(--bg-hover)`,color:f===`source`?`var(--text)`:`var(--text-muted)`,fontWeight:f===`source`?600:400},children:`Source`}),(0,Z.jsx)(`button`,{onClick:()=>p(`diff`),style:{padding:`2px 8px`,fontSize:11,border:`none`,borderLeft:`1px solid var(--border)`,cursor:`pointer`,background:f===`diff`?`var(--bg-selected)`:`var(--bg-hover)`,color:f===`diff`?`var(--text)`:`var(--text-muted)`,fontWeight:f===`diff`?600:400},children:`Diff`})]}),f===`source`&&!u&&(0,Z.jsx)(`button`,{onClick:()=>h(e=>!e),title:m?`Disable word wrap`:`Enable word wrap`,style:{padding:`2px 8px`,fontSize:11,cursor:`pointer`,background:m?`var(--bg-selected)`:`var(--bg-hover)`,color:m?`var(--text)`:`var(--text-muted)`,border:`1px solid var(--border)`,borderRadius:5,fontWeight:m?600:400},children:`wrap`}),x&&f===`source`&&(0,Z.jsxs)(`div`,{style:{display:`flex`,borderRadius:5,overflow:`hidden`,border:`1px solid var(--border)`},children:[(0,Z.jsx)(`button`,{onClick:()=>d(!1),style:{padding:`2px 8px`,fontSize:11,border:`none`,cursor:`pointer`,background:u?`var(--bg-hover)`:`var(--bg-selected)`,color:u?`var(--text-muted)`:`var(--text)`,fontWeight:u?400:600},children:`Code`}),(0,Z.jsx)(`button`,{onClick:()=>d(!0),style:{padding:`2px 8px`,fontSize:11,border:`none`,borderLeft:`1px solid var(--border)`,cursor:`pointer`,background:u?`var(--bg-selected)`:`var(--bg-hover)`,color:u?`var(--text)`:`var(--text-muted)`,fontWeight:u?600:400},children:`Preview`})]}),S&&f===`source`&&(0,Z.jsxs)(`div`,{style:{display:`flex`,borderRadius:5,overflow:`hidden`,border:`1px solid var(--border)`},children:[(0,Z.jsx)(`button`,{onClick:()=>d(!0),style:{padding:`2px 8px`,fontSize:11,border:`none`,cursor:`pointer`,background:u?`var(--bg-selected)`:`var(--bg-hover)`,color:u?`var(--text)`:`var(--text-muted)`,fontWeight:u?600:400},children:`Preview`}),(0,Z.jsx)(`button`,{onClick:()=>d(!1),style:{padding:`2px 8px`,fontSize:11,border:`none`,borderLeft:`1px solid var(--border)`,cursor:`pointer`,background:u?`var(--bg-hover)`:`var(--bg-selected)`,color:u?`var(--text-muted)`:`var(--text)`,fontWeight:u?400:600},children:`Raw`})]}),(0,Z.jsx)(Bg,{projectId:e,filePath:t})]}),(0,Z.jsx)(`div`,{style:{flex:1,overflow:`auto`,background:`var(--bg)`},children:f===`diff`&&C&&r!==void 0?(0,Z.jsx)(qg,{oldContent:r,newContent:i.content}):x&&u?(0,Z.jsx)(`iframe`,{srcDoc:i.content,sandbox:`allow-scripts`,style:{width:`100%`,height:`100%`,border:`none`,background:`var(--bg)`},title:`HTML preview`}):S&&u?(0,Z.jsx)(`div`,{style:{padding:`24px 32px`,color:`var(--text)`},children:(0,Z.jsx)(`pre`,{style:{fontFamily:`var(--font-mono, monospace)`,fontSize:13,lineHeight:1.6,whiteSpace:`pre-wrap`},children:i.content})}):(0,Z.jsx)(`div`,{style:{margin:0,padding:`12px 0`,background:`var(--bg)`,fontSize:13,lineHeight:1.6,fontFamily:`var(--font-mono, monospace)`,minHeight:`100%`},children:(0,Z.jsx)(ve,{theme:n?_e.vsDark:_e.vsLight,code:i.content,language:i.language===`text`?`plaintext`:i.language,children:({tokens:e,getLineProps:t,getTokenProps:n,style:r})=>(0,Z.jsx)(`pre`,{style:{margin:0,padding:0,...r,background:`transparent`},children:e.map((e,r)=>{let{key:i,...a}=t({line:e,key:r});return(0,Z.jsxs)(`div`,{...a,style:{display:`flex`},children:[(0,Z.jsx)(`span`,{style:{minWidth:`3em`,padding:`0 1em 0 0`,textAlign:`right`,color:`var(--text-dim)`,userSelect:`none`,borderRight:`1px solid var(--border)`,background:`var(--bg-panel)`,flexShrink:0},children:r+1}),(0,Z.jsx)(`span`,{style:{flex:1,paddingLeft:8},children:e.map((e,t)=>{let{key:r,...i}=n({token:e,key:t});return(0,Z.jsx)(`span`,{...i},t)})})]},r)})})})})})]}):null}function Yg({projectId:e,filePath:t,watchUrl:n,previousContent:r,isDark:i,onOpenFile:a}){return Tg(t)?(0,Z.jsx)(Ug,{projectId:e,filePath:t}):Eg(t)?(0,Z.jsx)(Wg,{projectId:e,filePath:t}):Dg(t)?(0,Z.jsx)(Gg,{projectId:e,filePath:t}):(0,Z.jsx)(Jg,{projectId:e,filePath:t,previousContent:r,isDark:i})}function Xg({projectId:e,onClose:t,fullWidth:n}){let r=q(e=>e.viewerTabs),i=q(e=>e.viewerActivePath),a=q(e=>e.viewerWidth),o=q(e=>e.setViewerActivePath),s=Op(e=>e.sendSelection),c=q(e=>e.closeFileViewerTab),l=q(e=>e.closeAllViewerTabs),u=q(e=>e.setViewerWidth),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)(``),[_,v]=(0,G.useState)(),[y,b]=(0,G.useState)(),[x,S]=(0,G.useState)(),[C,w]=(0,G.useState)(!1),[T,E]=(0,G.useState)(),[D,O]=(0,G.useState)(!1),[k,A]=(0,G.useState)(void 0),j=(0,G.useRef)(void 0),[M,N]=(0,G.useState)(!1),P=r.find(e=>e.path===i),F=d!==p,I=P!==void 0&&(Tg(P.path)||Eg(P.path)||Dg(P.path)),L=q(e=>P?e.fileRev[P.path]:void 0),R=(0,G.useRef)(void 0),z=(0,G.useRef)(0),[ee,B]=(0,G.useState)(!1);(0,G.useEffect)(()=>{if(!P){f(``),m(``),E(void 0),B(!1),R.current=void 0,z.current=0;return}if(R.current=P.path,z.current=L??0,B(!1),I){f(``),m(``),v(void 0),g(P.name),b(void 0),S(void 0),w(!1);return}let t=!1;return w(!0),E(void 0),dn(e,P.path).then(e=>{if(t)return;let n=e.content??``,r=n===``||n.endsWith(`
142
+ `)?n:n+`
143
+ `;f(r),m(r),v(e.language),g(P.name),b(e.size),S(void 0)}).catch(e=>{t||(E(e instanceof Error?e.message:`read failed`),f(``),m(``))}).finally(()=>{t||w(!1)}),()=>{t=!0}},[P?.path,e,I]);let V=(0,G.useCallback)(async()=>{if(P){w(!0),E(void 0),B(!1);try{let t=await dn(e,P.path),n=t.content??``,r=n===``||n.endsWith(`
144
+ `)?n:n+`
145
+ `;f(r),m(r),v(t.language),g(P.name),b(t.size),S(void 0)}catch(e){E(e instanceof Error?e.message:`read failed`)}finally{w(!1)}}},[P,e]);(0,G.useEffect)(()=>{if(!P||P.path!==R.current)return;let e=L??0;e>z.current&&(F?B(!0):V()),z.current=e},[L,P?.path,F,V]);let H=(0,G.useCallback)(async()=>{if(!(!P||!F||D)){O(!0),E(void 0);try{await fn(e,P.path,d),m(d),S(new Date)}catch(e){E(e instanceof Error?e.message:`save failed`)}finally{O(!1)}}},[P,d,F,D,e]),U=(0,G.useCallback)(e=>{f(e)},[]);(0,G.useEffect)(()=>{let e=!1;return An().then(t=>{if(e)return;let n=t.viewerWidth;typeof n==`number`&&n>0&&u(n)}).catch(()=>{}),()=>{e=!0}},[u]);let te=(0,G.useCallback)(e=>{e.preventDefault(),N(!0),j.current={startX:e.clientX,startW:a};let t=e=>{if(!j.current)return;let t=e.clientX-j.current.startX;u(j.current.startW-t)},n=()=>{N(!1),j.current=void 0,document.removeEventListener(`mousemove`,t),document.removeEventListener(`mouseup`,n);let e=q.getState().viewerWidth;jn({viewerWidth:e}).catch(()=>{})};document.addEventListener(`mousemove`,t),document.addEventListener(`mouseup`,n)},[a,u]);(0,G.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key===`s`&&(e.preventDefault(),H())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[H]);let ne=r.length>0;return(0,Z.jsxs)(`div`,{className:`file-viewer-wrapper`,style:{display:`flex`,flexDirection:`column`,height:`100%`,width:ne?a:0,minWidth:ne?280:0,overflow:`hidden`,flexShrink:0,position:`relative`,borderLeft:ne?`1px solid var(--border)`:`none`,background:`var(--bg-solid)`,transition:M?`none`:`width 0.2s cubic-bezier(0.16, 1, 0.3, 1), min-width 0.2s cubic-bezier(0.16, 1, 0.3, 1)`,willChange:`width`,paddingTop:`50px`},children:[ne&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{onMouseDown:te,style:{position:`absolute`,left:0,top:0,bottom:0,width:`4px`,cursor:`col-resize`,zIndex:10,background:`transparent`,transition:`background 0.15s ease`},className:`viewer-resize-handle`}),(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`4px`,padding:`0 8px`,borderBottom:`1px solid var(--border)`,background:`var(--bg-glass)`,flexShrink:0,overflowX:`auto`,minHeight:`38px`,height:`38px`,boxSizing:`border-box`},children:[t&&(0,Z.jsx)(`button`,{onClick:t,title:`Close viewer`,className:`viewer-back-btn`,type:`button`,children:(0,Z.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,Z.jsx)(`path`,{d:`m15 18-6-6 6-6`})})}),r.length>1&&(0,Z.jsx)(`button`,{onClick:()=>{if(F){A({kind:`close-all`});return}l()},title:`Close all tabs`,className:`viewer-close-all-btn`,type:`button`,children:(0,Z.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`rect`,{x:`3`,y:`3`,width:`13`,height:`13`,rx:`2`}),(0,Z.jsx)(`path`,{d:`m7 7 5 5m0-5-5 5`}),(0,Z.jsx)(`path`,{d:`M7 19h12a2 2 0 0 0 2-2V7`})]})}),r.map(e=>{let t=e.path===i;return(0,Z.jsxs)(`div`,{onClick:()=>o(e.path),className:`viewer-tab-item${t?` active`:``}`,title:e.path,children:[Kh(e.name),t&&F&&(0,Z.jsx)(`span`,{style:{display:`inline-block`,width:`6px`,height:`6px`,borderRadius:`50%`,background:`var(--accent-text, #e8a838)`,flexShrink:0},"aria-label":`Unsaved changes`,title:`Unsaved changes`}),(0,Z.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,maxWidth:`180px`},children:e.name}),(0,Z.jsx)(`button`,{onClick:n=>{if(n.stopPropagation(),t&&F){A({kind:`close-tab`,path:e.path,name:e.name});return}c(e.path)},title:`Close tab`,className:`viewer-tab-close`,type:`button`,children:(0,Z.jsxs)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,Z.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]},e.path)})]}),T&&(0,Z.jsx)(`div`,{style:{padding:`4px 12px`,fontSize:`10px`,color:`var(--error)`,background:`rgba(248,113,113,0.08)`,borderBottom:`1px solid var(--border)`},children:T}),ee&&P&&!I&&(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,padding:`4px 12px`,fontSize:`11px`,color:`var(--text-secondary)`,background:`var(--warning-bg, rgba(240,204,21,0.10))`,borderBottom:`1px solid var(--border)`},children:[(0,Z.jsx)(`span`,{style:{flex:1,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:F?`File changed on disk — reloading will discard unsaved edits`:`File changed on disk`}),(0,Z.jsx)(`button`,{onClick:()=>{F?A({kind:`reload`}):V()},title:`Reload file from disk`,style:{background:`none`,border:`1px solid var(--border-bright)`,color:`var(--accent-text)`,cursor:`pointer`,padding:`2px 8px`,fontSize:`11px`,borderRadius:`var(--radius-xs)`,flexShrink:0},type:`button`,children:`↻ Reload`})]}),(0,Z.jsx)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0},children:C?(0,Z.jsx)(`div`,{style:{padding:`12px`},children:(0,Z.jsx)(Fp,{variant:`card`,count:3})}):P?(0,Z.jsx)(Z.Fragment,{children:I?(0,Z.jsx)(Yg,{projectId:e,filePath:P.path}):(0,Z.jsx)(Pg,{path:P.path,fileName:P.name,content:d,language:_,saving:D,dirty:F,onChange:U,onSave:H,savedAt:x,error:T,size:y,onSendSelection:e=>s({path:P.path,...e})})}):null})]}),(0,Z.jsx)(Zm,{open:k!==void 0,onClose:()=>A(void 0),onConfirm:()=>{k?.kind===`close-tab`?c(k.path):k?.kind===`close-all`?l():k?.kind===`reload`&&V(),A(void 0)},title:k?.kind===`reload`?`Reload file`:`Unsaved changes`,message:k?.kind===`close-tab`?`Close “${k.name}”? Unsaved changes will be lost.`:k?.kind===`close-all`?`Close all ${r.length} tabs? Unsaved changes in the active tab will be lost.`:`Reload this file from disk? Unsaved edits will be lost.`,primaryLabel:k?.kind===`reload`?`Reload`:`Discard & close`,tone:`danger`})]})}function Zg({item:e}){let t=(0,G.useRef)(null);return(0,G.useEffect)(()=>{let n=t.current;if(n)return Yd(n,e.type===`svg`?`<!DOCTYPE html><html><head><meta charset="utf-8">
146
+ <style>body{margin:0;display:flex;align-items:center;justify-content:center;min-height:100vh;background:#fff}</style>
147
+ </head><body>${e.content}</body></html>`:e.content)},[e]),(0,Z.jsx)(`div`,{ref:t,style:{flex:1,minHeight:0,overflow:`hidden`}})}function Qg({content:e}){let t;try{t=JSON.stringify(JSON.parse(e),null,2)}catch{t=e}return(0,Z.jsx)(ve,{theme:_e.nightOwl,code:t,language:`json`,children:({tokens:e,getLineProps:t,getTokenProps:n})=>(0,Z.jsx)(`pre`,{style:{margin:0,padding:`12px 16px`,fontSize:13,overflow:`auto`,flex:1},children:e.map((e,r)=>(0,Z.jsx)(`div`,{...t({line:e}),children:e.map((e,t)=>(0,Z.jsx)(`span`,{...n({token:e})},t))},r))})})}function $g({content:e}){return(0,Z.jsx)(`pre`,{style:{margin:0,padding:`12px 16px`,fontSize:12,fontFamily:`'Fira Code', 'Cascadia Code', 'JetBrains Mono', monospace`,overflow:`auto`,flex:1,whiteSpace:`pre-wrap`,wordBreak:`break-word`,color:`var(--text-primary)`,lineHeight:1.5},children:e})}function e_({content:e}){return(0,Z.jsx)(`div`,{style:{flex:1,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:16,overflow:`auto`},children:(0,Z.jsx)(`img`,{src:/^data:image\//.test(e)?e:`data:image/png;base64,${e}`,alt:`artifact`,style:{maxWidth:`100%`,maxHeight:`100%`,borderRadius:8,boxShadow:`0 4px 24px rgba(0,0,0,0.15)`}})})}function t_({item:e}){switch(e.type){case`html`:case`svg`:return(0,Z.jsx)(Zg,{item:e});case`markdown`:return(0,Z.jsx)(`div`,{style:{flex:1,overflow:`auto`,padding:`16px 20px`,background:`var(--bg-primary)`},children:(0,Z.jsx)(jo,{text:e.content})});case`json`:return(0,Z.jsx)(Qg,{content:e.content});case`image`:return(0,Z.jsx)(e_,{content:e.content});default:return(0,Z.jsx)($g,{content:e.content})}}var n_={html:`◈`,svg:`◇`,markdown:`📝`,json:`{}`,text:`¶`,image:`🖼`};function r_(){let e=q(e=>e.isMobile),t=q(e=>e.artifactItems),n=q(e=>e.artifactViewerTabs),r=q(e=>e.artifactViewerActiveId),i=q(e=>e.artifactViewerWidth),a=q(e=>e.setArtifactViewerActiveId),o=q(e=>e.closeArtifactViewerTab),s=q(e=>e.closeAllArtifactViewerTabs),c=q(e=>e.setArtifactViewerWidth),l=(0,G.useRef)(void 0),[u,d]=(0,G.useState)(!1),f=n.find(e=>e.id===r)??n[n.length-1],p=f?t.find(e=>e.id===f.id):void 0,m=n.length>0;(0,G.useEffect)(()=>{let e=!1;return An().then(t=>{if(e)return;let n=t.artifactViewerWidth;typeof n==`number`&&n>0&&c(n)}).catch(()=>{}),()=>{e=!0}},[c]);let h=(0,G.useCallback)(e=>{e.preventDefault(),d(!0),l.current={startX:e.clientX,startW:i};let t=e=>{if(!l.current)return;let t=e.clientX-l.current.startX;c(l.current.startW-t)},n=()=>{d(!1),l.current=void 0,document.removeEventListener(`mousemove`,t),document.removeEventListener(`mouseup`,n);let e=q.getState().artifactViewerWidth;jn({artifactViewerWidth:e}).catch(()=>{})};document.addEventListener(`mousemove`,t),document.addEventListener(`mouseup`,n)},[i,c]);return(0,Z.jsx)(`div`,{style:e?{position:`fixed`,top:50,left:0,right:0,bottom:0,zIndex:130,background:`var(--bg-solid)`,display:`flex`,flexDirection:`column`,transform:m?`translateX(0)`:`translateX(100%)`,transition:`transform 0.18s ease`,willChange:`transform`,overflow:`hidden`}:{display:`flex`,flexDirection:`column`,height:`100%`,width:m?i:0,minWidth:m?280:0,overflow:`hidden`,flexShrink:0,position:`relative`,borderLeft:m?`1px solid var(--border)`:`none`,background:`var(--bg-solid)`,transition:u?`none`:`width 0.2s cubic-bezier(0.16, 1, 0.3, 1), min-width 0.2s cubic-bezier(0.16, 1, 0.3, 1)`,willChange:`width`,paddingTop:`50px`},children:m&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{onMouseDown:h,className:`artifact-viewer-resize-handle`,style:{position:`absolute`,left:0,top:0,bottom:0,width:`4px`,cursor:`col-resize`,zIndex:10,background:`transparent`,transition:`background 0.15s ease`}}),(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`2px`,padding:`4px 8px`,borderBottom:`1px solid var(--border)`,background:`var(--bg-glass)`,flexShrink:0,overflowX:`auto`,minHeight:`38px`},children:[n.length>1&&(0,Z.jsx)(`button`,{onClick:()=>s(),title:`Close all artifact tabs`,style:{background:`none`,border:`none`,color:`var(--text-dim)`,cursor:`pointer`,padding:`2px 6px`,fontSize:`11px`,borderRadius:`var(--radius-xs)`,flexShrink:0},type:`button`,children:`✕✕`}),n.map(e=>{let t=e.id===r;return(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`4px`,padding:`3px 8px`,fontSize:`12px`,fontWeight:t?600:400,whiteSpace:`nowrap`,borderRadius:`var(--radius-xs)`,background:t?`var(--accent-subtle)`:`transparent`,color:t?`var(--accent-text)`:`var(--text-secondary)`,cursor:`default`,minWidth:0,flexShrink:0,borderBottom:t?`2px solid var(--accent-text)`:`2px solid transparent`,transition:`all 0.12s ease`},children:[(0,Z.jsxs)(`button`,{onClick:()=>a(e.id),style:{background:`none`,border:`none`,color:`inherit`,cursor:`pointer`,padding:0,fontSize:`12px`,fontWeight:`inherit`,overflow:`hidden`,textOverflow:`ellipsis`},type:`button`,title:e.title,children:[n_[e.type]??`◈`,` `,e.title]}),(0,Z.jsx)(`button`,{onClick:t=>{t.stopPropagation(),o(e.id)},title:`Close`,style:{background:`none`,border:`none`,color:`var(--text-dim)`,cursor:`pointer`,padding:`1px 3px`,fontSize:`10px`,lineHeight:1,opacity:.5,borderRadius:`2px`},type:`button`,className:`artifact-viewer-tab-close`,children:`✕`})]},e.id)})]}),(0,Z.jsx)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0},children:p?(0,Z.jsx)(t_,{item:p},p.id):(0,Z.jsx)(`div`,{style:{flex:1,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`var(--text-tertiary)`,fontSize:13},children:`Artifact not found`})})]})})}var i_=({onClose:e})=>{let t=di(e=>e.isOpen),n=di(e=>e.activeReview),r=di(e=>e.viewMode),i=di(e=>e.editedContent),a=di(e=>e.submitting),s=di(e=>e.error),c=di(e=>e.planModeActive),l=di(e=>e.setViewMode),u=di(e=>e.setEditedContent),d=di(e=>e.closeReview),f=di(e=>e.submitDecision),p=di(e=>e.savePlanContent),m=di(e=>e.exitPlanMode),[h,g]=(0,G.useState)(()=>{try{let e=localStorage.getItem(`pi.planReview.width`);return e?Number.parseInt(e,10):580}catch{return 580}}),[_,v]=(0,G.useState)(!1),[y,b]=(0,G.useState)(``),[S,w]=(0,G.useState)(!1),[T,E]=(0,G.useState)(``),[D,O]=(0,G.useState)(!1),k=q(e=>e.isMobile),[A,j]=(0,G.useState)(()=>typeof window<`u`&&window.innerWidth<=640);(0,G.useEffect)(()=>{let e=()=>j(window.innerWidth<=640);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let M=k||A,N=(0,G.useRef)(void 0),[P,I]=(0,G.useState)(!1),R=(0,G.useCallback)(e=>{M||(e.preventDefault(),N.current={startX:e.clientX,startW:h},I(!0))},[h,M]);(0,G.useEffect)(()=>{if(!P)return;let e=e=>{if(!N.current)return;let t=N.current.startX-e.clientX,n=Math.max(280,Math.min(window.innerWidth*.85,N.current.startW+t));g(n)},t=()=>{I(!1),N.current=void 0;try{localStorage.setItem(`pi.planReview.width`,String(h))}catch{}};return window.addEventListener(`mousemove`,e),window.addEventListener(`mouseup`,t),()=>{window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,t)}},[P,h]);let z=(0,G.useMemo)(()=>{let e=Y.getState().messages;for(let t of e){let e=t;if(e?.role===`assistant`&&Array.isArray(e?.content))for(let t of e.content){let e=t;if(e?.type===`toolCall`&&(e.name===`write`||e.name===`edit`)){let t=e.arguments,n=t?.path??t?.filePath;if(typeof n==`string`&&!/\.(?:md|mdx)$/i.test(n))return!0}}}return!1},[n]);if(!t||!n)return null;let ee=!!n.requestId,B=!ee&&z,V=c&&!ee&&!B,H=ee||V,ne=i.trim()!==n.planContent.trim(),re=async()=>{try{await f({approved:!0}),e?.()}catch{}},ie=async()=>{if(y.trim())try{await f({approved:!0,feedback:y.trim()}),v(!1),b(``),e?.()}catch{}},ae=async()=>{if(T.trim())try{await f({approved:!1,feedback:T.trim()}),w(!1),E(``),e?.()}catch{}},oe=async()=>{try{await p(),O(!0),setTimeout(()=>O(!1),2e3)}catch{}},se=async()=>{try{await m()}catch{}},ce=()=>{d(),e?.()};return(0,Z.jsxs)(`aside`,{className:`plan-review-panel`,style:{width:M?`100%`:`${h}px`,flexBasis:M?`100%`:`${h}px`,maxWidth:M?`100vw`:void 0,flexShrink:0,display:`flex`,flexDirection:`column`,height:M?`calc(100dvh - 50px)`:`100%`,borderLeft:M?`none`:`1px solid var(--border)`,background:`var(--bg-solid)`,color:`var(--text-primary)`,position:M?`fixed`:`relative`,top:M?50:void 0,left:M?0:void 0,right:M?0:void 0,bottom:M?0:void 0,zIndex:M?125:20,paddingTop:M?0:`50px`,boxSizing:`border-box`},children:[!M&&(0,Z.jsx)(`div`,{className:`fv-resize-handle`,onMouseDown:R,style:{position:`absolute`,left:-3,top:0,bottom:0,width:6,cursor:`col-resize`,zIndex:30}}),(0,Z.jsxs)(`header`,{className:`plan-review-header`,style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:M?`8px 12px`:`10px 16px`,borderBottom:`1px solid var(--border)`,background:`var(--bg-glass)`,flexShrink:0,gap:`8px`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,minWidth:0,flex:1},children:[(0,Z.jsx)(`span`,{style:{fontSize:`16px`,flexShrink:0},children:`📋`}),(0,Z.jsxs)(`div`,{style:{minWidth:0,flex:1},children:[(0,Z.jsx)(`div`,{className:`plan-review-header-title`,style:{fontSize:`13px`,fontWeight:600,color:`var(--text-primary)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,maxWidth:M?`140px`:void 0},title:n.planFilePath,children:n.planFilePath}),(0,Z.jsx)(`div`,{style:{fontSize:`11px`,color:ee?`var(--accent, #3b82f6)`:V?`#eab308`:`#22c55e`,fontWeight:500,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:ee?`Awaiting Your Review`:V?`📝 Plan Draft (In Progress)`:B?`✓ Plan Completed`:`✓ Plan Approved & Saved`})]})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`6px`,flexShrink:0},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,borderRadius:`6px`,background:`var(--bg-glass-strong, rgba(128, 128, 128, 0.12))`,padding:`2px`,border:`1px solid var(--border)`},children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>l(`preview`),style:{display:`inline-flex`,alignItems:`center`,gap:`4px`,padding:M?`4px 8px`:`4px 10px`,fontSize:`12px`,fontWeight:r===`preview`?600:500,border:`none`,borderRadius:`4px`,cursor:`pointer`,background:r===`preview`?`var(--accent, #3b82f6)`:`transparent`,color:r===`preview`?`#fff`:`var(--text-secondary)`,transition:`all 0.12s ease`},title:`Preview plan`,children:[(0,Z.jsx)(x,{size:13}),!M&&(0,Z.jsx)(`span`,{children:`Preview`})]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>l(`edit`),style:{display:`inline-flex`,alignItems:`center`,gap:`4px`,padding:M?`4px 8px`:`4px 10px`,fontSize:`12px`,fontWeight:r===`edit`?600:500,border:`none`,borderRadius:`4px`,cursor:`pointer`,background:r===`edit`?`var(--accent, #3b82f6)`:`transparent`,color:r===`edit`?`#fff`:`var(--text-secondary)`,transition:`all 0.12s ease`},title:`Edit plan`,children:[(0,Z.jsx)(he,{size:13}),!M&&(0,Z.jsx)(`span`,{children:`Edit`})]})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:ce,title:`Close plan review`,"aria-label":`Close plan review`,style:{background:`none`,border:`none`,color:`var(--text-dim)`,cursor:`pointer`,padding:`6px`,minWidth:`32px`,minHeight:`32px`,borderRadius:`4px`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,Z.jsx)(te,{size:18})})]})]}),s&&(0,Z.jsx)(`div`,{style:{padding:`8px 16px`,background:`rgba(239, 68, 68, 0.12)`,color:`#ef4444`,fontSize:`12px`,borderBottom:`1px solid rgba(239, 68, 68, 0.25)`},children:s}),(0,Z.jsx)(`div`,{className:`plan-review-body`,style:{flex:1,overflowY:`auto`,overflowX:`hidden`,padding:M?`12px 14px`:`16px 20px`,minHeight:0,background:`var(--bg-solid)`,color:`var(--text-primary)`,wordBreak:`break-word`,overflowWrap:`break-word`},children:r===`preview`?(0,Z.jsx)(`div`,{className:`plan-preview-content`,style:{fontSize:`14px`,lineHeight:1.65,color:`var(--text-primary)`},children:(0,Z.jsx)(jo,{text:i})}):(0,Z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`,gap:`8px`},children:[(0,Z.jsxs)(`div`,{style:{fontSize:`12px`,color:`var(--text-secondary)`,display:`flex`,alignItems:`center`,justifyContent:`space-between`},children:[(0,Z.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:`6px`},children:[(0,Z.jsx)(`span`,{children:`✏️`}),(0,Z.jsx)(`span`,{children:`Edit plan in-place:`})]}),ne&&(0,Z.jsx)(`span`,{style:{color:`#eab308`,fontSize:`11px`,fontWeight:600},children:`● Unsaved edits`})]}),(0,Z.jsx)(`textarea`,{value:i,onChange:e=>u(e.target.value),placeholder:`Edit your markdown plan here...`,spellCheck:!1,style:{flex:1,width:`100%`,background:`var(--bg-glass-strong, rgba(128, 128, 128, 0.05))`,color:`var(--text-primary)`,fontFamily:`var(--font-mono, monospace)`,fontSize:`13px`,lineHeight:1.55,padding:`14px`,borderRadius:`6px`,border:`1px solid var(--border)`,resize:`none`,outline:`none`,boxSizing:`border-box`}})]})}),_&&(0,Z.jsxs)(`div`,{style:{padding:`12px 16px`,background:`var(--bg-glass)`,borderTop:`1px solid var(--border)`,display:`flex`,flexDirection:`column`,gap:`8px`},children:[(0,Z.jsx)(`div`,{style:{fontSize:`12px`,fontWeight:600,color:`var(--text-primary)`},children:`Implementation Guidance Notes:`}),(0,Z.jsx)(`textarea`,{value:y,onChange:e=>b(e.target.value),placeholder:`Add guidance or constraints for implementation...`,rows:2,style:{width:`100%`,background:`var(--bg-solid)`,color:`var(--text-primary)`,fontSize:`12px`,padding:`8px 10px`,borderRadius:`4px`,border:`1px solid var(--border)`,resize:`none`,outline:`none`,boxSizing:`border-box`}}),(0,Z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:`8px`},children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>v(!1),style:{padding:`4px 10px`,fontSize:`12px`,background:`transparent`,color:`var(--text-secondary)`,border:`none`,cursor:`pointer`},children:`Cancel`}),(0,Z.jsx)(`button`,{type:`button`,onClick:ie,disabled:a||!y.trim(),style:{padding:`5px 12px`,fontSize:`12px`,fontWeight:500,background:`var(--accent, #3b82f6)`,color:`#fff`,border:`none`,borderRadius:`4px`,cursor:`pointer`},children:`Approve with Notes`})]})]}),S&&(0,Z.jsxs)(`div`,{style:{padding:`12px 16px`,background:`rgba(239, 68, 68, 0.08)`,borderTop:`1px solid rgba(239, 68, 68, 0.25)`,display:`flex`,flexDirection:`column`,gap:`8px`},children:[(0,Z.jsx)(`div`,{style:{fontSize:`12px`,fontWeight:600,color:`#ef4444`},children:`Request Plan Revisions:`}),(0,Z.jsx)(`textarea`,{value:T,onChange:e=>E(e.target.value),placeholder:`Tell the agent what to revise in the plan...`,rows:3,style:{width:`100%`,background:`var(--bg-solid)`,color:`var(--text-primary)`,fontSize:`12px`,padding:`8px 10px`,borderRadius:`4px`,border:`1px solid rgba(239, 68, 68, 0.4)`,resize:`none`,outline:`none`,boxSizing:`border-box`}}),(0,Z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:`8px`},children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>w(!1),style:{padding:`4px 10px`,fontSize:`12px`,background:`transparent`,color:`var(--text-secondary)`,border:`none`,cursor:`pointer`},children:`Cancel`}),(0,Z.jsx)(`button`,{type:`button`,onClick:ae,disabled:a||!T.trim(),style:{padding:`5px 12px`,fontSize:`12px`,fontWeight:500,background:`#dc2626`,color:`#fff`,border:`none`,borderRadius:`4px`,cursor:`pointer`},children:`Send Revision Feedback`})]})]}),(0,Z.jsx)(`footer`,{className:`plan-review-footer`,style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,flexWrap:`wrap`,gap:`8px`,padding:M?`10px 12px`:`12px 16px`,borderTop:`1px solid var(--border)`,background:`var(--bg-glass)`,flexShrink:0},children:H?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`plan-review-footer-group`,style:{display:`flex`,gap:`8px`,flexWrap:`wrap`,flex:M?`1 1 100%`:`0 1 auto`},children:[(0,Z.jsxs)(`button`,{type:`button`,className:`plan-review-footer-btn`,onClick:()=>{w(!S),v(!1)},disabled:a,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,gap:`4px`,padding:`7px 12px`,fontSize:`12px`,fontWeight:500,background:`transparent`,color:`#ef4444`,border:`1px solid rgba(239, 68, 68, 0.35)`,borderRadius:`6px`,cursor:`pointer`,transition:`all 0.15s ease`,flex:M?`1 1 auto`:void 0},children:[(0,Z.jsx)(L,{size:13}),`Request Changes`]}),(0,Z.jsxs)(`button`,{type:`button`,className:`plan-review-footer-btn`,onClick:()=>{v(!_),w(!1)},disabled:a,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,gap:`4px`,padding:`7px 12px`,fontSize:`12px`,fontWeight:500,background:`var(--bg-glass)`,color:`var(--text-secondary)`,border:`1px solid var(--border)`,borderRadius:`6px`,cursor:`pointer`,flex:M?`1 1 auto`:void 0},children:[(0,Z.jsx)(o,{size:13}),`Approve with Notes...`]}),c&&(0,Z.jsxs)(`button`,{type:`button`,className:`plan-review-footer-btn`,onClick:se,title:`Unlock code file editing for the agent`,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,gap:`4px`,padding:`7px 12px`,fontSize:`12px`,fontWeight:500,background:`rgba(234, 179, 8, 0.15)`,color:`#eab308`,border:`1px solid rgba(234, 179, 8, 0.35)`,borderRadius:`6px`,cursor:`pointer`,flex:M?`1 1 auto`:void 0},children:[(0,Z.jsx)(C,{size:13}),`Exit Plan Mode`]})]}),(0,Z.jsxs)(`div`,{className:`plan-review-footer-group`,style:{display:`flex`,alignItems:`center`,gap:`8px`,flexWrap:`wrap`,flex:M?`1 1 100%`:`0 1 auto`,justifyContent:M?`stretch`:`flex-end`},children:[D&&(0,Z.jsx)(`span`,{style:{fontSize:`11px`,color:`#22c55e`,fontWeight:600,width:M?`100%`:void 0,textAlign:M?`center`:void 0},children:`✓ Saved to disk`}),ne&&(0,Z.jsxs)(`button`,{type:`button`,className:`plan-review-footer-btn`,onClick:oe,disabled:a,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,gap:`5px`,padding:`7px 16px`,fontSize:`12px`,fontWeight:600,background:`var(--accent, #3b82f6)`,color:`#fff`,border:`none`,borderRadius:`6px`,cursor:`pointer`,flex:M?`1 1 auto`:void 0},children:[(0,Z.jsx)(U,{size:13}),`Save Edits`]}),(0,Z.jsxs)(`button`,{type:`button`,className:`plan-review-footer-btn`,onClick:re,disabled:a,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,gap:`6px`,padding:`8px 18px`,fontSize:`13px`,fontWeight:600,background:`#16a34a`,color:`#fff`,border:`none`,borderRadius:`6px`,cursor:`pointer`,boxShadow:`0 1px 3px rgba(0, 0, 0, 0.15)`,flex:M?`1 1 100%`:void 0,width:M?`100%`:void 0},children:[(0,Z.jsx)(F,{size:15,strokeWidth:2.5}),a?`Approving...`:ee?`Approve & Execute`:`Execute Plan`]}),(0,Z.jsx)(`button`,{type:`button`,className:`plan-review-footer-btn`,onClick:ce,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,padding:`7px 14px`,fontSize:`12px`,fontWeight:500,background:`var(--bg-glass)`,color:`var(--text-secondary)`,border:`1px solid var(--border)`,borderRadius:`6px`,cursor:`pointer`,flex:M?`1 1 auto`:void 0},children:`Close`})]})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`plan-review-footer-group`,style:{display:`flex`,alignItems:`center`,gap:`8px`,flexWrap:`wrap`,flex:M?`1 1 100%`:`0 1 auto`},children:[(0,Z.jsxs)(`button`,{type:`button`,className:`plan-review-footer-btn`,onClick:()=>{w(!S),v(!1)},disabled:a,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,gap:`4px`,padding:`6px 12px`,fontSize:`12px`,fontWeight:500,background:`transparent`,color:`var(--text-secondary)`,border:`1px solid var(--border)`,borderRadius:`6px`,cursor:`pointer`,flex:M?`1 1 auto`:void 0},children:[(0,Z.jsx)(L,{size:13}),`Request Revisions`]}),c&&(0,Z.jsxs)(`button`,{type:`button`,className:`plan-review-footer-btn`,onClick:se,title:`Exit Plan Mode`,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,gap:`4px`,padding:`6px 12px`,fontSize:`12px`,fontWeight:500,background:`rgba(234, 179, 8, 0.15)`,color:`#eab308`,border:`1px solid rgba(234, 179, 8, 0.35)`,borderRadius:`6px`,cursor:`pointer`,flex:M?`1 1 auto`:void 0},children:[(0,Z.jsx)(C,{size:13}),`Exit Plan Mode`]})]}),(0,Z.jsxs)(`div`,{className:`plan-review-footer-group`,style:{display:`flex`,alignItems:`center`,gap:`8px`,flexWrap:`wrap`,flex:M?`1 1 100%`:`0 1 auto`,justifyContent:M?`stretch`:`flex-end`},children:[D&&(0,Z.jsx)(`span`,{style:{fontSize:`11px`,color:`#22c55e`,fontWeight:600,width:M?`100%`:void 0,textAlign:M?`center`:void 0},children:`✓ Saved to disk`}),ne?(0,Z.jsxs)(`button`,{type:`button`,className:`plan-review-footer-btn`,onClick:oe,disabled:a,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,gap:`5px`,padding:`7px 16px`,fontSize:`12px`,fontWeight:600,background:`var(--accent, #3b82f6)`,color:`#fff`,border:`none`,borderRadius:`6px`,cursor:`pointer`,flex:M?`1 1 auto`:void 0},children:[(0,Z.jsx)(U,{size:13}),`Save Edits`]}):(0,Z.jsxs)(`span`,{className:`plan-review-footer-btn`,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,gap:`5px`,padding:`6px 12px`,fontSize:`12px`,fontWeight:600,color:`#22c55e`,background:`rgba(34, 197, 94, 0.12)`,borderRadius:`6px`,flex:M?`1 1 auto`:void 0},children:[(0,Z.jsx)(F,{size:14,strokeWidth:2.5}),B?`Plan Completed`:`Plan Approved`]}),(0,Z.jsx)(`button`,{type:`button`,className:`plan-review-footer-btn`,onClick:ce,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,padding:`7px 14px`,fontSize:`12px`,fontWeight:500,background:`var(--bg-glass)`,color:`var(--text-secondary)`,border:`1px solid var(--border)`,borderRadius:`6px`,cursor:`pointer`,flex:M?`1 1 auto`:void 0},children:`Close`})]})]})})]})},a_=`pi-kot.terminal.tabs.v1`;function o_(){try{let e=sessionStorage.getItem(a_);if(e===null)return{tabs:[],activeTabId:void 0};let t=JSON.parse(e);if(typeof t!=`object`||!t||!Array.isArray(t.tabs))return{tabs:[],activeTabId:void 0};let n=[];for(let e of t.tabs)typeof e==`object`&&e&&typeof e.id==`string`&&typeof e.projectId==`string`&&typeof e.label==`string`&&typeof e.createdAt==`number`&&n.push(e);let r=t.activeTabId,i=typeof r==`string`?r:void 0;return{tabs:n,activeTabId:n.some(e=>e.id===i)?i:n[0]?.id}}catch{return{tabs:[],activeTabId:void 0}}}function s_(e){try{sessionStorage.setItem(a_,JSON.stringify(e))}catch{}}var c_=0,l_=()=>`term-${Date.now().toString(36)}-${(c_++).toString(36)}`,u_=o_(),d_=At(e=>({tabs:u_.tabs,activeTabId:u_.activeTabId,openTab:t=>{let n=l_();return e(e=>{let r=e.tabs.filter(e=>e.projectId===t),i={id:n,projectId:t,label:`Terminal ${r.length+1}`,createdAt:Date.now()},a={tabs:[...e.tabs,i],activeTabId:n};return s_(a),a}),n},closeTab:t=>{e(e=>{let n=e.tabs.findIndex(e=>e.id===t);if(n===-1)return{};let r=e.tabs.slice(0,n).concat(e.tabs.slice(n+1)),i={tabs:r,activeTabId:e.activeTabId===t?(r[n]??r[n-1]??r[0])?.id:e.activeTabId};return s_(i),i})},setActiveTab:t=>e(e=>(s_({tabs:{...e,activeTabId:t}.tabs,activeTabId:t}),{activeTabId:t})),closeProjectTabs:t=>{e(e=>{let n=e.tabs.filter(e=>e.projectId!==t),r={tabs:n,activeTabId:n.some(t=>t.id===e.activeTabId)?e.activeTabId:n[0]?.id};return s_(r),r})}})),f_=new Map;function p_(e){let t=e.querySelector(`textarea`);t!==null&&(t.setAttribute(`autocomplete`,`off`),t.setAttribute(`autocorrect`,`off`),t.setAttribute(`autocapitalize`,`none`),t.setAttribute(`spellcheck`,`false`))}function m_(e,t=!1){let n=e.term.cols,r=e.term.rows;!t&&n===e.lastSize.cols&&r===e.lastSize.rows||(e.lastSize={cols:n,rows:r},e.ws.readyState===WebSocket.OPEN&&e.ws.send(JSON.stringify({type:`resize`,cols:n,rows:r})))}function h_(e,t=!1){e.fit.fit(),m_(e,t)}function g_(e){let t=[1,2,4,8,16,30];return(t[Math.min(e,t.length-1)]??30)*1e3}function __(e){return e===1e3||e===4401||e===4404}function v_({open:e,onClose:t}){let n=Y(e=>e.activeProjectId),r=d_(e=>e.tabs),i=d_(e=>e.activeTabId),a=d_(e=>e.openTab),o=d_(e=>e.closeTab),s=d_(e=>e.setActiveTab),[c,l]=(0,G.useState)(0),[u,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(!1);(0,G.useEffect)(()=>{let e=()=>d(window.innerWidth<=600);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,G.useEffect)(()=>{let e=window.visualViewport;if(!e)return;let t=()=>{let t=Math.max(0,window.innerHeight-e.height);l(t)};return e.addEventListener(`resize`,t),()=>e.removeEventListener(`resize`,t)},[]);let m=r.filter(e=>e.projectId===n),h=m.find(e=>e.id===i)??m[0],g=()=>{n!==void 0&&a(n)},_=e=>{x_(e),o(e)},v=u&&e,y=e=>{if(!i)return;let t=f_.get(i);t&&t.ws.readyState===WebSocket.OPEN&&(t.ws.send(JSON.stringify({type:`input`,data:e})),t.term.focus())},b=(0,G.useCallback)(()=>{navigator.clipboard.readText().then(e=>{if(!i)return;let t=f_.get(i);t&&t.ws.readyState===WebSocket.OPEN&&(t.ws.send(JSON.stringify({type:`input`,data:e})),t.term.focus())}).catch(()=>{})},[i]);return(0,Z.jsxs)(`div`,{className:`terminal-panel-root`,style:{display:e?`flex`:`none`,position:`fixed`,zIndex:v?300:100,flexDirection:`column`,background:`var(--bg-solid, #1e1e2e)`,overscrollBehavior:`none`,transition:`bottom 0.15s ease`,...v?{inset:`0 0 ${c}px 0`,paddingTop:`env(safe-area-inset-top, 0px)`,paddingBottom:c===0?`env(safe-area-inset-bottom, 0px)`:0}:{bottom:c,left:0,right:0,height:`35vh`,minHeight:180,borderTop:`1px solid var(--border-color, #313244)`}},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`0 8px`,height:32,fontSize:12,color:`var(--text-dim, #6c7086)`,userSelect:`none`,flexShrink:0,borderBottom:`1px solid var(--border-color, #313244)`,background:`var(--bg-glass, rgba(255,255,255,0.04))`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:2,overflow:`hidden`},children:[m.length===0&&(0,Z.jsx)(`span`,{style:{padding:`0 8px`,fontSize:11,fontStyle:`italic`,color:`var(--text-dim)`},children:`No terminals open.`}),m.map(e=>{let t=e.id===h?.id;return(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:4,borderRadius:4,padding:`2px 8px`,fontSize:11,cursor:`default`,background:t?`var(--bg-glass-active, rgba(255,255,255,0.08))`:`transparent`,color:t?`var(--text-primary, #fff)`:`var(--text-dim, #6c7086)`},children:[(0,Z.jsxs)(`span`,{onClick:()=>s(e.id),style:{cursor:`pointer`,display:`flex`,alignItems:`center`,gap:4,whiteSpace:`nowrap`},children:[(0,Z.jsxs)(`span`,{style:{fontSize:10},children:[`>`,`_`]}),e.label]}),(0,Z.jsx)(`button`,{onClick:()=>_(e.id),style:{all:`unset`,cursor:`pointer`,padding:`1px 3px`,borderRadius:3,fontSize:10,lineHeight:1,color:`var(--text-dim, #6c7086)`,opacity:.6},title:`Close terminal (kills the PTY)`,children:`✕`})]},e.id)}),(0,Z.jsx)(`button`,{onClick:g,style:{all:`unset`,cursor:`pointer`,padding:`2px 6px`,borderRadius:4,fontSize:11,color:`var(--text-dim, #6c7086)`,marginLeft:4,whiteSpace:`nowrap`},title:`New terminal`,children:`+ New`})]}),(0,Z.jsx)(`button`,{onClick:t,style:{all:`unset`,cursor:`pointer`,padding:`2px 6px`,borderRadius:4,fontSize:13,color:`var(--text-dim, #6c7086)`,lineHeight:1},title:`Close terminal panel`,children:`✕`})]}),(0,Z.jsxs)(`div`,{style:{position:`relative`,flex:1,overflow:`hidden`},children:[m.length===0&&(0,Z.jsx)(`div`,{style:{height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`,fontSize:12,fontStyle:`italic`,color:`var(--text-dim, #6c7086)`},children:`Click "New" to open a terminal.`}),r.map(e=>(0,Z.jsx)(y_,{tab:e,visible:e.projectId===n&&e.id===h?.id,ctrlActive:e.id===h?.id?f:!1,setCtrlActive:p},e.id))]}),v&&(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:4,padding:`4px 8px`,background:`var(--bg-frosted, rgba(33, 33, 33, 0.85))`,borderTop:`1px solid var(--border-color, #313244)`,overflowX:`auto`,WebkitOverflowScrolling:`touch`,flexShrink:0,scrollbarWidth:`none`},children:[(0,Z.jsx)(`style`,{children:`
148
+ .terminal-quick-key {
149
+ all: unset;
150
+ display: flex;
151
+ align-items: center;
152
+ justify-content: center;
153
+ min-width: 40px;
154
+ height: 32px;
155
+ border-radius: 4px;
156
+ background: var(--bg-glass, rgba(255, 255, 255, 0.04));
157
+ color: var(--text-primary, #cdd6f4);
158
+ font-size: 13px;
159
+ font-family: ui-monospace, SFMono-Regular, monospace;
160
+ cursor: pointer;
161
+ }
162
+ .terminal-quick-key:active {
163
+ background: var(--bg-glass-active, rgba(255, 255, 255, 0.08));
164
+ }
165
+ .terminal-quick-key.active {
166
+ background: var(--accent, #89b4fa);
167
+ color: #11111b;
168
+ font-weight: bold;
169
+ }
170
+ `}),(0,Z.jsx)(`button`,{className:`terminal-quick-key ${f?`active`:``}`,onPointerDown:e=>{e.preventDefault(),p(e=>!e)},children:`CTRL`}),(0,Z.jsx)(`button`,{className:`terminal-quick-key`,onPointerDown:e=>{e.preventDefault(),y(``)},children:`^C`}),(0,Z.jsx)(`button`,{className:`terminal-quick-key`,onPointerDown:e=>{e.preventDefault(),y(`\x1B`)},children:`ESC`}),(0,Z.jsx)(`button`,{className:`terminal-quick-key`,onPointerDown:e=>{e.preventDefault(),y(` `)},children:`TAB`}),(0,Z.jsx)(`button`,{className:`terminal-quick-key`,onPointerDown:e=>{e.preventDefault(),b()},children:`📋`}),(0,Z.jsx)(`div`,{style:{width:1,height:20,background:`var(--border-color, #313244)`,margin:`0 4px`}}),(0,Z.jsx)(`button`,{className:`terminal-quick-key`,onPointerDown:e=>{e.preventDefault(),y(`\x1B[A`)},children:`↑`}),(0,Z.jsx)(`button`,{className:`terminal-quick-key`,onPointerDown:e=>{e.preventDefault(),y(`\x1B[B`)},children:`↓`}),(0,Z.jsx)(`button`,{className:`terminal-quick-key`,onPointerDown:e=>{e.preventDefault(),y(`\x1B[D`)},children:`←`}),(0,Z.jsx)(`button`,{className:`terminal-quick-key`,onPointerDown:e=>{e.preventDefault(),y(`\x1B[C`)},children:`→`})]})]})}function y_({tab:e,visible:t,ctrlActive:n,setCtrlActive:r}){let i=(0,G.useRef)(null),[a,o]=(0,G.useState)(!1),s=(0,G.useRef)(n);return(0,G.useEffect)(()=>{s.current=n},[n]),(0,G.useEffect)(()=>{if(i.current===null)return;let t=i.current,n=f_.get(e.id);if(n!==void 0){try{let e=n.term.element;e!==void 0&&e.parentNode!==t?t.appendChild(e):n.term.open(t),p_(t),h_(n,!0)}catch{}let e=new ResizeObserver(()=>{try{h_(n)}catch{}});e.observe(t);try{n.observer.disconnect()}catch{}return n.observer=e,requestAnimationFrame(()=>{try{h_(n),n.term.focus()}catch{}}),()=>{try{e.disconnect()}catch{}}}let a=window.innerWidth<=600,c=new _t({theme:{background:S_(`--bg-solid`,`#1e1e2e`),foreground:S_(`--text-primary`,`#cdd6f4`),cursor:S_(`--accent-text`,`#89b4fa`),selectionBackground:S_(`--accent`,`#89b4fa`),black:S_(`--ansi-black`,`#45475a`),red:S_(`--ansi-red`,`#f38ba8`),green:S_(`--ansi-green`,`#a6e3a1`),yellow:S_(`--ansi-yellow`,`#f9e2af`),blue:S_(`--ansi-blue`,`#89b4fa`),magenta:S_(`--ansi-magenta`,`#f5c2e7`),cyan:S_(`--ansi-cyan`,`#94e2d5`),white:S_(`--ansi-white`,`#bac2de`),brightBlack:S_(`--ansi-bright-black`,`#585b70`),brightRed:S_(`--ansi-bright-red`,`#f38ba8`),brightGreen:S_(`--ansi-bright-green`,`#a6e3a1`),brightYellow:S_(`--ansi-bright-yellow`,`#f9e2af`),brightBlue:S_(`--ansi-bright-blue`,`#89b4fa`),brightMagenta:S_(`--ansi-bright-magenta`,`#f5c2e7`),brightCyan:S_(`--ansi-bright-cyan`,`#94e2d5`),brightWhite:S_(`--ansi-bright-white`,`#a6adc8`)},fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace`,fontSize:a?12:13,cursorBlink:!0,scrollback:5e3,allowTransparency:!0}),l=new vt;c.loadAddon(l),c.open(t),p_(t),l.fit();let u={cols:c.cols,rows:c.rows},d=b_(e.id,e.projectId,c,u,!1);c.onData(t=>{let n=f_.get(e.id)?.ws;if(n?.readyState===WebSocket.OPEN)if(s.current&&t.length===1){let e=t.charCodeAt(0),i=t;e>=97&&e<=122?i=String.fromCharCode(e-96):e>=65&&e<=90&&(i=String.fromCharCode(e-64)),n.send(JSON.stringify({type:`input`,data:i})),r(!1)}else n.send(JSON.stringify({type:`input`,data:t}))}),c.onSelectionChange(()=>{o(c.hasSelection())});let f=new ResizeObserver(()=>{try{let t=f_.get(e.id);if(t===void 0)return;h_(t)}catch{}});f.observe(t);let p=null,m=0,h=e=>{e.touches.length===2&&(p=(e.touches[0].clientY+e.touches[1].clientY)/2,m=0)},g=e=>{if(e.touches.length===2&&p!==null){e.preventDefault(),e.stopPropagation();let t=(e.touches[0].clientY+e.touches[1].clientY)/2,n=p-t;if(p=t,Math.abs(n)<1)return;let r=m+n,i=Math.trunc(r/16);m=r-i*16,i!==0&&c.scrollLines(i)}},_=e=>{p=null},v=()=>{p=null};t.addEventListener(`touchstart`,h,{passive:!1}),t.addEventListener(`touchmove`,g,{passive:!1}),t.addEventListener(`touchend`,_),t.addEventListener(`touchcancel`,v);let y=e=>{e.preventDefault()};return t.addEventListener(`contextmenu`,y),f_.set(e.id,{term:c,fit:l,ws:d,observer:f,lastSize:u,reconnectAttempt:0,reconnectTimer:void 0,disposed:!1,ctrlActive:!1}),()=>{try{f.disconnect(),t.removeEventListener(`touchstart`,h),t.removeEventListener(`touchmove`,g),t.removeEventListener(`touchend`,_),t.removeEventListener(`touchcancel`,v),t.removeEventListener(`contextmenu`,y)}catch{}}},[e.id]),(0,G.useEffect)(()=>{if(!t)return;let n=f_.get(e.id);n!==void 0&&requestAnimationFrame(()=>{try{h_(n),n.term.focus()}catch{}})},[t,e.id]),(0,Z.jsx)(`div`,{ref:i,onClick:()=>{f_.get(e.id)?.term.focus()},className:`terminal-host`,style:{position:`absolute`,inset:0,visibility:t?`visible`:`hidden`,pointerEvents:t?`auto`:`none`,zIndex:+!!t,padding:`2px 4px 8px 4px`,touchAction:`none`},children:a&&(0,Z.jsx)(`div`,{style:{position:`absolute`,bottom:12,right:12,zIndex:20,display:`flex`,gap:6},children:(0,Z.jsx)(`button`,{onClick:()=>{let t=f_.get(e.id);t?.term.hasSelection()&&(navigator.clipboard.writeText(t.term.getSelection()),t.term.clearSelection(),o(!1))},style:{all:`unset`,padding:`6px 14px`,borderRadius:6,background:`var(--accent, #89b4fa)`,color:`#11111b`,fontSize:12,fontWeight:600,cursor:`pointer`,boxShadow:`0 2px 8px rgba(0,0,0,0.3)`},children:`📋 Copy`})})})}function b_(e,t,n,r,i){let a=window.location.protocol===`https:`?`wss`:`ws`,o=zt(),s=o===void 0?``:`&token=${encodeURIComponent(o)}`,c=`${a}://${window.location.host}/api/v1/terminal?projectId=${encodeURIComponent(t)}&tabId=${encodeURIComponent(e)}${s}`,l=new WebSocket(c);return l.binaryType=`arraybuffer`,l.onopen=()=>{let t=f_.get(e),n=t===void 0?r:{cols:t.term.cols,rows:t.term.rows};l.send(JSON.stringify({type:`resize`,cols:n.cols,rows:n.rows})),t!==void 0&&(t.lastSize=n,t.reconnectAttempt=0)},l.onmessage=e=>{if(typeof e.data==`string`)try{let t=JSON.parse(e.data);if(t.type===`open`){n.writeln(`\r\n\x1b[32mTerminal opened at ${t.cwd}\x1b[0m`);return}if(t.type===`exit`){n.writeln(`\r\n\x1b[31mProcess exited with code ${t.code}\x1b[0m`);return}if(t.type===`error`){n.writeln(`\r\n\x1b[31mError: ${t.message}\x1b[0m`);return}}catch{n.write(e.data)}else e.data instanceof ArrayBuffer&&n.write(new Uint8Array(e.data))},l.onclose=r=>{let i=f_.get(e);if(i===void 0||i.disposed)return;if(__(r.code)){let e=`[connection closed: ${String(r.code)}]`;r.code===4401?e=`[connection closed (4401): session expired — refresh the page after logging back in]`:r.code===4404&&(e=`[connection closed (4404): project no longer exists]`),n.write(`\r\n${e}\r\n`);return}let a=i.reconnectAttempt+1;i.reconnectAttempt=a;let o=g_(a);n.write(`\r\n[connection lost (${String(r.code)}) — reconnecting in ${String(o/1e3)}s, attempt ${String(a)}]\r\n`),i.reconnectTimer=setTimeout(()=>{let r=f_.get(e);r===void 0||r.disposed||(r.reconnectTimer=void 0,r.ws=b_(e,t,n,r.lastSize,!0))},o)},l}function x_(e){let t=f_.get(e);if(t!==void 0){t.disposed=!0,t.reconnectTimer!==void 0&&clearTimeout(t.reconnectTimer),f_.delete(e);try{t.observer.disconnect()}catch{}try{(t.ws.readyState===WebSocket.OPEN||t.ws.readyState===WebSocket.CONNECTING)&&t.ws.close(1e3,`tab_closed`)}catch{}try{t.term.dispose()}catch{}}}function S_(e,t){return typeof document>`u`?t:getComputedStyle(document.documentElement).getPropertyValue(e).trim()||t}function C_({sessionId:e}){let t=pi(e=>e.activeInteraction);pi(e=>e.clearInteraction);let n=pi(e=>e.cancelCommand),r=pi(e=>e.commandRunning),[i,a]=(0,G.useState)(``),[o,s]=(0,G.useState)(0),c=(0,G.useCallback)(()=>{let t=pi.getState().activeInteraction;if(t&&`requestId`in t){let n=t.requestId;Tr(e,n,``).catch(()=>{})}n()},[e,n]);if((0,G.useEffect)(()=>{a(``),s(0)},[t?.type]),t===void 0&&!r||!r&&t===void 0)return null;let l=t?.type??``;if(l===`extension_ui_select`){let n=t;return(0,Z.jsx)(`div`,{className:`settings-overlay`,onClick:c,children:(0,Z.jsxs)(`div`,{className:`settings-panel rewind-panel`,onClick:e=>e.stopPropagation(),style:{width:520,maxWidth:`92vw`,height:`auto`,maxHeight:`80vh`,display:`flex`,flexDirection:`column`},children:[(0,Z.jsxs)(`header`,{className:`settings-header`,children:[(0,Z.jsx)(`span`,{style:{fontSize:14,fontWeight:600},children:n.title}),(0,Z.jsx)(`button`,{onClick:c,className:`settings-close`,title:`Cancel`,children:`✕`})]}),(0,Z.jsx)(`div`,{className:`settings-body`,style:{padding:`12px 16px`,overflowY:`auto`,flex:1},children:(0,Z.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:3},children:n.options.map((t,r)=>{let i=t.split(`
171
+ `).filter(Boolean),a=i[0]??t,c=i.slice(1).join(` `).trim().replace(/\u001b\[[0-9;]*m/g,``);return(0,Z.jsxs)(`button`,{onClick:async r=>{r.stopPropagation();try{await Tr(e,n.requestId,t)}catch(e){console.error(`Extension UI respond failed:`,e)}},onMouseEnter:()=>s(r),style:{display:`flex`,width:`100%`,alignItems:`flex-start`,gap:10,padding:`8px 10px`,borderRadius:6,border:r===o?`1px solid var(--accent-border)`:`1px solid transparent`,background:r===o?`var(--accent-subtle)`:`none`,cursor:`pointer`,textAlign:`left`,fontSize:11,fontFamily:`inherit`,color:`var(--text-primary)`,transition:`background 0.15s`},children:[(0,Z.jsx)(`span`,{style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:22,height:22,borderRadius:`50%`,background:`var(--bg-glass-hover)`,color:`var(--text-dim)`,fontSize:10,fontWeight:700,flexShrink:0,marginTop:1},children:r+1}),(0,Z.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,Z.jsx)(`div`,{style:{fontSize:11,fontWeight:500,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:a}),c&&(0,Z.jsx)(`div`,{style:{fontSize:10,color:`var(--text-dim)`,marginTop:2,fontFamily:`monospace`},children:c})]})]},r)})})}),(0,Z.jsx)(`div`,{style:{padding:`8px 16px`,borderTop:`1px solid var(--border-color)`,fontSize:10,color:`var(--text-dim)`,textAlign:`center`},children:`Select an option above`})]})})}if(l===`extension_ui_confirm`){let n=t;return(0,Z.jsx)(`div`,{className:`settings-overlay`,onClick:c,children:(0,Z.jsxs)(`div`,{className:`settings-panel rewind-panel`,onClick:e=>e.stopPropagation(),style:{width:420,maxWidth:`92vw`,height:`auto`,minHeight:0},children:[(0,Z.jsxs)(`header`,{className:`settings-header`,children:[(0,Z.jsx)(`span`,{style:{fontSize:14,fontWeight:600},children:n.title}),(0,Z.jsx)(`button`,{onClick:c,className:`settings-close`,title:`Cancel`,children:`✕`})]}),(0,Z.jsxs)(`div`,{className:`settings-body`,style:{padding:`16px`},children:[(0,Z.jsx)(`p`,{style:{fontSize:13,color:`var(--text-secondary)`,marginBottom:20,lineHeight:1.5},children:n.message}),(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:8,justifyContent:`flex-end`},children:[(0,Z.jsx)(`button`,{onClick:async t=>{t.stopPropagation();try{await Tr(e,n.requestId,!1)}catch(e){console.error(e)}},className:`settings-tab`,style:{padding:`6px 14px`,fontSize:12},children:`No`}),(0,Z.jsx)(`button`,{onClick:async t=>{t.stopPropagation();try{await Tr(e,n.requestId,!0)}catch(e){console.error(e)}},className:`settings-tab settings-tab-active`,style:{padding:`6px 14px`,fontSize:12},children:`Yes`})]})]})]})})}if(l===`extension_ui_input`){let n=t;return(0,Z.jsx)(`div`,{className:`settings-overlay`,onClick:c,children:(0,Z.jsxs)(`div`,{className:`settings-panel rewind-panel`,onClick:e=>e.stopPropagation(),style:{width:420,maxWidth:`92vw`,height:`auto`,minHeight:0},children:[(0,Z.jsxs)(`header`,{className:`settings-header`,children:[(0,Z.jsx)(`span`,{style:{fontSize:14,fontWeight:600},children:n.title}),(0,Z.jsx)(`button`,{onClick:c,className:`settings-close`,title:`Cancel`,children:`✕`})]}),(0,Z.jsxs)(`div`,{className:`settings-body`,style:{padding:`16px`},children:[(0,Z.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:n.placeholder,autoFocus:!0,style:{width:`100%`,padding:`8px 10px`,fontSize:12,borderRadius:6,border:`1px solid var(--border-color)`,background:`var(--bg-glass)`,color:`var(--text-primary)`,outline:`none`,fontFamily:`inherit`,boxSizing:`border-box`,marginBottom:12},onKeyDown:async t=>{if(t.key===`Enter`){t.stopPropagation();try{await Tr(e,n.requestId,i)}catch(e){console.error(e)}}t.key===`Escape`&&c()}}),(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:8,justifyContent:`flex-end`},children:[(0,Z.jsx)(`button`,{onClick:c,className:`settings-tab`,style:{padding:`6px 14px`,fontSize:12},children:`Cancel`}),(0,Z.jsx)(`button`,{onClick:async t=>{t.stopPropagation();try{await Tr(e,n.requestId,i)}catch(e){console.error(e)}},className:`settings-tab settings-tab-active`,style:{padding:`6px 14px`,fontSize:12},children:`OK`})]})]})]})})}return r&&t===void 0?(0,Z.jsx)(`div`,{className:`settings-overlay`,children:(0,Z.jsx)(`div`,{className:`settings-panel rewind-panel`,onClick:e=>e.stopPropagation(),style:{width:300,maxWidth:`92vw`,height:`auto`,minHeight:0,textAlign:`center`},children:(0,Z.jsx)(`div`,{className:`settings-body`,style:{padding:`20px`},children:(0,Z.jsx)(`div`,{style:{fontSize:12,color:`var(--text-dim)`},children:`Extension command running…`})})})}):null}function w_(){let e=pi(e=>e.notifications),t=pi(e=>e.dismissNotification),[n,r]=(0,G.useState)(null),[i,a]=(0,G.useState)(``),[o,s]=(0,G.useState)(`info`),[c,l]=(0,G.useState)(!1),u=e[e.length-1];(0,G.useEffect)(()=>{if(u&&u.id!==n){r(u.id),a(u.message),s(u.type),l(!0);let e=setTimeout(()=>{l(!1),setTimeout(()=>t(u.id),300)},15e3);return()=>clearTimeout(e)}},[u,n,t]);let d=()=>{n&&(l(!1),setTimeout(()=>{t(n),r(null)},250))};return!n||!i?null:(0,Z.jsx)(`div`,{className:`toast-overlay`,onClick:d,children:(0,Z.jsxs)(`div`,{className:`toast-card ${c?`toast-card-enter`:`toast-card-exit`}`,onClick:e=>e.stopPropagation(),role:`alert`,children:[(0,Z.jsxs)(`header`,{className:`toast-card-header`,children:[(0,Z.jsxs)(`span`,{className:`toast-card-title`,children:[o===`info`&&`ℹ️`,o===`warning`&&`⚠️`,o===`error`&&`❌`,(0,Z.jsxs)(`span`,{style:{marginLeft:6},children:[o===`info`&&`Context Mode`,o===`warning`&&`Warning`,o===`error`&&`Error`]})]}),(0,Z.jsx)(`button`,{className:`toast-card-close`,onClick:d,"aria-label":`Dismiss`,children:`✕`})]}),(0,Z.jsx)(`div`,{className:`toast-card-body`,children:(0,Z.jsx)(`pre`,{className:`toast-card-content`,children:i})})]})})}var T_=8,E_=0;function D_(e){if(!e)return``;let t=new Date(e),n=Date.now()-t.getTime();if(Number.isNaN(n)||n<0)return``;let r=Math.floor(n/1e3);if(r<60)return`just now`;let i=Math.floor(r/60);if(i<60)return`${i}m`;let a=Math.floor(i/60);if(a<24)return`${a}h`;let o=Math.floor(a/24);if(o===1)return`1d`;if(o<7)return`${o}d`;let s=Math.floor(o/7);return s<4?`${s}w`:`${Math.floor(o/30)}mo`}function O_({projectId:e,sessions:t,activeSessionId:n,isStreaming:i,renamingSessionId:a,renameValue:o,renameInputRef:s,expandedWorkerGroups:c,onSelect:l,onRenameStart:u,onRenameChange:d,onRenameCommit:f,onRenameCancel:p,onToggleWorkerGroup:m,onNewSession:h}){let{t:g}=qo(),[_,v]=(0,G.useState)(``),[y,x]=(0,G.useState)(!1),[S,C]=(0,G.useState)(!1),w=(0,G.useMemo)(()=>t.filter(e=>!e.supervisorId),[t]),T=(0,G.useMemo)(()=>t.filter(e=>e.supervisorId),[t]),E=(0,G.useMemo)(()=>T.filter(e=>!w.some(t=>t.sessionId===e.supervisorId)),[T,w]),D=_.trim().toLowerCase(),O=(0,G.useMemo)(()=>D?w.filter(e=>(e.name??`Session ${e.sessionId.slice(0,8)}`).toLowerCase().includes(D)):w,[w,D]),{favorites:k,toggle:A,isFavorite:M,unfavorite:N}=Ci(),{favSupervisors:P,nonFavSupervisors:F}=(0,G.useMemo)(()=>{let e=[],t=[];for(let n of O)M(n.sessionId)?e.push(n):t.push(n);return{favSupervisors:e,nonFavSupervisors:t}},[O,M,k]),I=!y&&!D&&F.length>T_,L=I?F.slice(0,T_).includes(F.find(e=>e.sessionId===n)??F[0])?F.slice(0,T_):[...F.slice(0,T_-1),F.find(e=>e.sessionId===n)??F[T_-1]].filter(Boolean):F,R=F.length-L.length,z=t.length>=E_,ee=e=>{let t=T.filter(t=>t.supervisorId===e.sessionId),h=c.has(e.sessionId),g=n===e.sessionId,_=e.name??`Session ${e.sessionId.slice(0,8)}`,v=M(e.sessionId),y=D_(e.lastActivityAt||e.createdAt);return(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{onClick:t=>{a!==e.sessionId&&(t.stopPropagation(),l(e.sessionId))},className:`session-item${g?` active`:``}`,onDoubleClick:t=>{t.stopPropagation(),u(e.sessionId,_)},children:[t.length>0&&(0,Z.jsx)(`span`,{className:`project-chevron`,onClick:t=>{t.stopPropagation(),m(e.sessionId)},style:{cursor:`pointer`,marginRight:`4px`,display:`inline-flex`,alignItems:`center`},children:h?(0,Z.jsx)(r,{size:11}):(0,Z.jsx)(b,{size:11})}),a===e.sessionId?(0,Z.jsx)(`input`,{ref:s,className:`session-rename-input`,value:o,onChange:e=>d(e.target.value),onBlur:()=>f(e.sessionId,_),onKeyDown:e=>{e.key===`Enter`?e.currentTarget.blur():e.key===`Escape`&&p()},onClick:e=>e.stopPropagation()}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`session-name`,title:_,children:_}),(0,Z.jsxs)(`div`,{className:`session-item-meta`,children:[v&&(0,Z.jsx)(`span`,{className:`session-fav-indicator`,title:`Favorited`,children:(0,Z.jsx)(j,{size:11,fill:`currentColor`})}),y&&(0,Z.jsx)(`span`,{className:`session-time`,children:y}),(0,Z.jsxs)(`div`,{className:`session-actions`,children:[(0,Z.jsx)(`button`,{className:`session-action-btn session-fav-btn${v?` favorited`:``}`,onClick:t=>{t.stopPropagation(),A(e.sessionId)},title:v?`Remove from favorites`:`Add to favorites`,children:(0,Z.jsx)(j,{size:12,fill:v?`currentColor`:`none`})}),(0,Z.jsx)(`button`,{className:`session-action-btn session-archive-btn`,title:`Archive session`,onClick:t=>{t.stopPropagation(),confirm(`Archive "${_}"?`)&&(N(e.sessionId),Y.getState().archiveSession(e.sessionId))},children:(0,Z.jsx)(se,{size:12})})]})]})]})]}),t.length>0&&h&&(0,Z.jsx)(`div`,{className:`session-children`,children:t.map(e=>(0,Z.jsx)(k_,{worker:e,isActive:n===e.sessionId,isStreaming:i&&n===e.sessionId,onSelect:l},e.sessionId))})]},e.sessionId)};return(0,Z.jsxs)(`div`,{className:`session-list project-sublist`,children:[z&&(0,Z.jsxs)(`div`,{className:`session-search-box`,children:[(0,Z.jsx)(ie,{size:12,className:`session-search-icon`}),(0,Z.jsx)(`input`,{value:_,onChange:e=>{v(e.target.value),x(!1)},placeholder:`Search sessions…`,className:`session-search-input`,type:`search`})]}),w.length===0&&T.length===0&&(0,Z.jsx)(`div`,{style:{padding:`6px 12px 2px`,fontSize:`11px`,color:`var(--text-dim)`,fontStyle:`italic`},children:g(`sidebar.noSessions`)}),D&&O.length===0&&(0,Z.jsx)(`div`,{style:{padding:`6px 12px 2px`,fontSize:`11px`,color:`var(--text-dim)`,fontStyle:`italic`},children:g(`sidebar.noMatches`,{query:_})}),P.length>0&&!D&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`favorites-section-header clickable`,onClick:()=>C(e=>!e),title:S?`Expand favorites`:`Collapse favorites`,children:[(0,Z.jsx)(`span`,{className:`favorites-chevron`,children:S?(0,Z.jsx)(b,{size:10}):(0,Z.jsx)(r,{size:10})}),(0,Z.jsx)(`span`,{children:g(`sidebar.favorites`)}),(0,Z.jsx)(`span`,{className:`favorites-count-badge`,children:P.length})]}),!S&&P.map(ee),L.length>0&&(0,Z.jsx)(`div`,{className:`favorites-section-divider`})]}),D?O.map(ee):L.map(ee),I&&R>0&&(0,Z.jsx)(`button`,{className:`session-show-more-btn`,onClick:()=>x(!0),type:`button`,children:g(R===1?`sidebar.showMore`:`sidebar.showMorePlural`,{count:R})}),y&&F.length>T_&&(0,Z.jsx)(`button`,{className:`session-show-more-btn`,onClick:()=>x(!1),type:`button`,children:g(`sidebar.showLess`)}),E.map(e=>(0,Z.jsx)(k_,{worker:e,isActive:n===e.sessionId,isStreaming:i&&n===e.sessionId,onSelect:l},e.sessionId)),(0,Z.jsxs)(`button`,{className:`new-session-row`,onClick:e=>{e.stopPropagation(),h()},type:`button`,children:[(0,Z.jsx)(fe,{size:13,strokeWidth:2.2}),(0,Z.jsx)(`span`,{children:g(`sidebar.newSession`)})]})]})}function k_({worker:e,isActive:t,isStreaming:n,onSelect:r}){let i=D_(e.lastActivityAt||e.createdAt);return(0,Z.jsxs)(`div`,{onClick:t=>{t.stopPropagation(),r(e.sessionId)},className:`session-item session-worker-item${t?` active`:``}`,children:[(0,Z.jsx)(`span`,{className:`session-worker-dot${n?` active`:``}`,style:{background:e.isLive&&!n?`#98c379`:e.isLive?void 0:`#56b6c2`}}),(0,Z.jsx)(`span`,{className:`session-worker-name`,children:e.name??`Session ${e.sessionId.slice(0,8)}`}),i&&(0,Z.jsx)(`span`,{className:`session-time session-worker-time`,children:i})]})}function A_(e,t){return e===`~`?t:e.startsWith(`~/`)?t+e.slice(1):e}function j_(e){if(e.endsWith(`/`))return e;let t=e.lastIndexOf(`/`);return t>=0?e.slice(0,t+1):e}function M_(e){if(e.endsWith(`/`))return``;let t=e.lastIndexOf(`/`);return t>=0?e.slice(t+1):e}function N_(e){try{let t=e.replace(/\.git$/,``).split(`/`).filter(Boolean).pop()||``;return t.split(`:`).filter(Boolean).pop()||t}catch{return``}}function P_({open:e,onClose:t}){let[n,r]=(0,G.useState)(``),[i,a]=(0,G.useState)(`~/`),[o,s]=(0,G.useState)([]),[c,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(),[p,m]=(0,G.useState)(0),[h,v]=(0,G.useState)(!1),[y,S]=(0,G.useState)(!1),[C,w]=(0,G.useState)(``),[T,E]=(0,G.useState)(!1),[D,O]=(0,G.useState)(!1),[k,A]=(0,G.useState)(!1),j=(0,G.useRef)(null),M=Y(e=>e.loadProjects),N=Y(e=>e.setActiveProject);(0,G.useEffect)(()=>{if(!e)return;let t=!1;return a(`~/`),w(``),S(!1),v(!1),m(0),f(void 0),A(!1),O(!1),cn().then(e=>{t||(r(e),requestAnimationFrame(()=>j.current?.focus()))}).catch(()=>{t||(r(`/`),requestAnimationFrame(()=>j.current?.focus()))}),()=>{t=!0}},[e]);let P=(0,G.useMemo)(()=>n?A_(j_(i),n):``,[i,n]);(0,G.useEffect)(()=>{if(!e||!P){s([]);return}let t=!1;return u(!0),f(void 0),ln(P).then(e=>{t||s(e)}).catch(e=>{t||(s([]),f(e instanceof Error?e.message:`Failed to load directory`))}).finally(()=>{t||u(!1)}),()=>{t=!0}},[e,P]);let F=M_(i),I=(0,G.useMemo)(()=>{let e=F.toLowerCase(),t=h||F.startsWith(`.`);return o.filter(n=>n.isDirectory&&(t||!n.name.startsWith(`.`))&&n.name.toLowerCase().startsWith(e))},[o,F,h]);(0,G.useEffect)(()=>{m(0)},[I.length]);let L=i!==`~/`&&i!==`/`,R=(0,G.useMemo)(()=>n?A_(i.replace(/\/+$/,``),n):``,[i,n]),z=(0,G.useCallback)(e=>{let t=e.startsWith(n)?`~`+e.slice(n.length):e;a(t+`/`)},[n]),ee=(0,G.useCallback)(()=>{let e=j_(i.replace(/\/+$/,``)).replace(/\/+$/,``);if(e===`~`||e===``){let e=n&&n.split(`/`).slice(0,-1).join(`/`)||`/`,t=e===`/`?`/`:`~`+e.slice(n.lastIndexOf(`/`));a(t.endsWith(`/`)?t:t+`/`);return}let t=e.lastIndexOf(`/`),r=t>=0?e.slice(0,t+1):`/`;a(r)},[i,n]),B=(0,G.useCallback)(async e=>{try{await nn(e.split(`/`).filter(Boolean).pop()||`unnamed`,e),await M();let n=Y.getState(),r=n.projects[n.projects.length-1];r&&N(r.id),t()}catch(e){f(e instanceof Error?e.message:`Failed to add project`)}},[M,N,t]),V=(0,G.useCallback)(async()=>{if(!(!R||k)){A(!0),f(void 0);try{await nn(R.split(`/`).filter(Boolean).pop()||`unnamed`,R),await M();let e=Y.getState(),n=e.projects[e.projects.length-1];n&&N(n.id),t()}catch(e){f(e instanceof Error?e.message:`Failed to add project`)}finally{A(!1)}}},[R,k,M,N,t]),H=(0,G.useCallback)(()=>{if(!C.trim()||!R||D)return;O(!0),f(void 0);let e=N_(C.trim())||`repo`,n={url:C.trim(),folderName:e,projectName:e};T&&(n.targetPath=R.replace(/\/+$/,``)+`/`+e),Cn(n,e=>{switch(e.type){case`done`:M().then(()=>{let e=Y.getState(),n=e.projects[e.projects.length-1];n&&N(n.id),t()}),O(!1);break;case`error`:f(e.message),O(!1);break}},e=>{f(e.message),O(!1)})},[C,R,T,D,M,N,t]),U=(0,G.useCallback)(e=>{if(e.key===`ArrowDown`)e.preventDefault(),m(e=>Math.min(I.length-1,e+1));else if(e.key===`ArrowUp`)e.preventDefault(),m(e=>Math.max(0,e-1));else if(e.key===`Enter`){if(e.preventDefault(),I.length>0&&p>=0){let e=I[p];F&&!e.name.startsWith(F)?a(j_(i)+e.name+`/`):z(e.path)}}else e.key===`Backspace`&&!i&&(e.preventDefault(),t())},[I,p,F,i,z,t]);return e?(0,Z.jsx)(`div`,{className:`settings-overlay`,onClick:t,children:(0,Z.jsxs)(`div`,{className:`settings-panel add-project-settings-panel`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(`header`,{className:`settings-header`,children:[(0,Z.jsx)(`span`,{style:{fontSize:`14px`,fontWeight:700,color:`var(--accent-text)`},children:`Add Project`}),(0,Z.jsx)(`button`,{className:`settings-close`,onClick:t,title:`Close`,children:(0,Z.jsx)(te,{size:16})})]}),(0,Z.jsxs)(`div`,{className:`add-project-dialog-body`,children:[(0,Z.jsxs)(`div`,{className:`add-project-dialog-bar`,children:[(0,Z.jsxs)(`button`,{className:`add-project-dialog-tab`+(y?``:` active`),onClick:()=>S(!1),children:[(0,Z.jsx)(l,{size:14}),`Browse`]}),(0,Z.jsxs)(`button`,{className:`add-project-dialog-tab`+(y?` active`:``),onClick:()=>S(!0),children:[(0,Z.jsx)(_,{size:14}),`Clone`]})]}),y&&(0,Z.jsxs)(`div`,{className:`add-project-dialog-clone-row`,children:[(0,Z.jsx)(g,{size:14,className:`add-project-dialog-icon`}),(0,Z.jsx)(`input`,{type:`text`,value:C,onChange:e=>w(e.target.value),placeholder:`https://github.com/user/repo.git`,className:`add-project-dialog-input`,style:{paddingLeft:`30px`},spellCheck:!1})]}),y&&(0,Z.jsx)(`div`,{className:`add-project-dialog-clone-dest`,children:(0,Z.jsxs)(`label`,{className:`add-project-dialog-toggle`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:T,onChange:e=>E(e.target.checked)}),(0,Z.jsx)(`span`,{className:`add-project-dialog-toggle-track`,children:(0,Z.jsx)(`span`,{className:`add-project-dialog-toggle-knob`})}),(0,Z.jsx)(`span`,{className:`add-project-dialog-toggle-label`,children:T?`Clone to custom path`:`Clone to workspace`})]})}),(0,Z.jsxs)(`div`,{className:`add-project-dialog-path-row`,children:[(0,Z.jsx)(l,{size:14,className:`add-project-dialog-icon`}),(0,Z.jsx)(`input`,{ref:j,type:`text`,value:i,onChange:e=>a(e.target.value.replace(/\\/g,`/`)),onKeyDown:U,placeholder:`~/`,className:`add-project-dialog-input`,spellCheck:!1}),(0,Z.jsx)(`button`,{className:`add-project-dialog-btn`,disabled:y?!C.trim()||!R||D:!R||k,onClick:y?H:V,children:y?D?`Cloning…`:`Clone & Add`:k?`Adding…`:`Add`})]}),(0,Z.jsxs)(`div`,{className:`add-project-dialog-tools`,children:[(0,Z.jsxs)(`button`,{className:`add-project-dialog-tool`,onClick:ee,disabled:!L,title:`Go up`,children:[(0,Z.jsx)(ne,{size:14}),(0,Z.jsx)(`span`,{children:`..`})]}),(0,Z.jsxs)(`button`,{className:`add-project-dialog-tool`,onClick:()=>v(e=>!e),title:h?`Hide hidden files`:`Show hidden files`,children:[h?(0,Z.jsx)(ge,{size:14}):(0,Z.jsx)(x,{size:14}),(0,Z.jsx)(`span`,{children:h?`Hide hidden`:`Show hidden`})]}),(0,Z.jsx)(`span`,{className:`add-project-dialog-path-display`,children:R})]}),d&&(0,Z.jsx)(`div`,{className:`add-project-dialog-error`,children:d}),(0,Z.jsx)(`div`,{className:`add-project-dialog-list`,children:c?(0,Z.jsx)(`div`,{className:`add-project-dialog-empty`,children:`Loading…`}):I.length===0?(0,Z.jsx)(`div`,{className:`add-project-dialog-empty`,children:F?`No matching directories`:`Empty directory`}):I.map((e,t)=>(0,Z.jsxs)(`div`,{className:`add-project-dialog-entry`+(t===p?` highlighted`:``),onMouseEnter:()=>m(t),onClick:()=>z(e.path),children:[(0,Z.jsx)(b,{size:14,className:`add-project-dialog-entry-arrow`}),(0,Z.jsx)(l,{size:14,className:`add-project-dialog-entry-folder`}),(0,Z.jsx)(`span`,{className:`add-project-dialog-entry-name`,children:e.name}),(0,Z.jsx)(`button`,{className:`add-project-dialog-entry-add`,onClick:t=>{t.stopPropagation(),B(e.path)},title:`Add as project`,children:(0,Z.jsx)(fe,{size:14})})]},e.path))})]}),(0,Z.jsx)(`div`,{className:`add-project-dialog-footer`,children:`↑↓ Navigate · Enter browse · + quick-add`})]})}):null}var F_=class extends G.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[ErrorBoundary${this.props.label?`:${this.props.label}`:``}]`,e,t.componentStack)}handleRetry=()=>{this.setState({error:null})};render(){if(this.state.error===null)return this.props.children;let{error:e}=this.state,{compact:t}=this.props;return t?(0,Z.jsxs)(`div`,{style:{padding:`12px`,margin:`8px`,borderRadius:`6px`,background:`var(--bg-glass, rgba(220,80,80,0.08))`,border:`1px solid var(--accent-red, #e06c75)`,fontSize:`12px`,color:`var(--text-secondary, #999)`,lineHeight:1.4},children:[(0,Z.jsxs)(`div`,{style:{fontWeight:600,color:`var(--accent-red, #e06c75)`,marginBottom:4},children:[`⚠️ `,e.name??`Error`]}),(0,Z.jsx)(`div`,{style:{marginBottom:8,wordBreak:`break-word`},children:e.message}),(0,Z.jsx)(`button`,{onClick:this.handleRetry,style:{padding:`4px 10px`,fontSize:`11px`,borderRadius:`4px`,border:`1px solid var(--border, #444)`,background:`var(--bg-surface, #1e1e1e)`,color:`var(--text-primary, #ddd)`,cursor:`pointer`},children:`Retry`})]}):(0,Z.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,padding:`40px 24px`,height:`100%`,boxSizing:`border-box`},children:(0,Z.jsxs)(`div`,{style:{maxWidth:480,width:`100%`,padding:`24px`,borderRadius:`8px`,background:`var(--bg-surface, #1e1e1e)`,border:`1px solid var(--border, #444)`},children:[(0,Z.jsx)(`div`,{style:{fontSize:14,fontWeight:600,color:`var(--accent-red, #e06c75)`,marginBottom:8},children:`Something went wrong`}),(0,Z.jsx)(`div`,{style:{fontSize:12,color:`var(--text-secondary, #999)`,marginBottom:4,fontFamily:`monospace`},children:e.name}),(0,Z.jsx)(`div`,{style:{fontSize:13,color:`var(--text-primary, #ddd)`,marginBottom:20,lineHeight:1.5,wordBreak:`break-word`},children:e.message}),(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,Z.jsx)(`button`,{onClick:this.handleRetry,style:{padding:`6px 16px`,fontSize:12,borderRadius:`6px`,border:`none`,background:`var(--accent-primary, #569cd6)`,color:`#fff`,cursor:`pointer`},children:`Retry`}),(0,Z.jsx)(`button`,{onClick:()=>{this.setState({error:null}),window.location.reload()},style:{padding:`6px 16px`,fontSize:12,borderRadius:`6px`,border:`1px solid var(--border, #444)`,background:`transparent`,color:`var(--text-secondary, #999)`,cursor:`pointer`},children:`Reload page`})]})]})})}};function I_(e){let t=(0,G.useRef)(null),n=(0,G.useRef)(!1),r=e.threshold||60,i=e.enabled!==!1;(0,G.useEffect)(()=>{if(!i)return;let a=e=>{t.current={x:e.touches[0].clientX,y:e.touches[0].clientY},n.current=!1},o=e=>{if(!t.current)return;let r=e.touches[0].clientY-t.current.y;Math.abs(r)>L_&&(n.current=!0)},s=i=>{if(!t.current)return;let a=t.current.x-i.changedTouches[0].clientX,o=t.current.y-i.changedTouches[0].clientY;n.current||Math.abs(a)>Math.abs(o)*R_&&Math.abs(a)>r&&(a>0&&e.onSwipeLeft?e.onSwipeLeft():a<0&&e.onSwipeRight&&e.onSwipeRight()),t.current=null,n.current=!1};return window.addEventListener(`touchstart`,a,{passive:!0}),window.addEventListener(`touchmove`,o,{passive:!0}),window.addEventListener(`touchend`,s,{passive:!0}),()=>{window.removeEventListener(`touchstart`,a),window.removeEventListener(`touchmove`,o),window.removeEventListener(`touchend`,s)}},[e.onSwipeLeft,e.onSwipeRight,r,i])}var L_=16,R_=1.5,z_=`pi-kot/user-bubble-bg`,B_=`pi-kot/user-bubble-text`,V_=`pi-kot/user-bubble-border`;function H_(e){try{let t=localStorage.getItem(e);return t===null?null:t}catch{return null}}function U_(e){if(!e)return;let t=typeof e.theme==`string`?e.theme:void 0,n=t&&Em[t]?Em[t]:t,r=typeof e.accent==`string`?e.accent:void 0;(n||r)&&Nm(n??jm(),r??Mm());let{setState:i}=Q;if(typeof e.stickyUserHeader==`boolean`&&i({stickyUserHeader:e.stickyUserHeader}),typeof e.flyToTop==`boolean`&&i({flyToTop:e.flyToTop}),typeof e.showTokenUsage==`boolean`&&i({showTokenUsage:e.showTokenUsage}),typeof e.compressImages==`boolean`&&i({compressImages:e.compressImages}),typeof e.showThinking==`boolean`&&i({showThinking:e.showThinking}),Array.isArray(e.favoriteSessions)){let t=`pi-kot/favorite-sessions-migrated`,n=!1;try{n=!!localStorage.getItem(t)}catch{}let r=Ci.getState().favorites;!n&&r.length>0&&e.favoriteSessions.length===0?Ci.getState().setFavorites(r,!0):Ci.getState().setFavorites(e.favoriteSessions,!1);try{localStorage.setItem(t,`1`)}catch{}}let a=e.userBubbleColor===void 0?H_(z_):e.userBubbleColor,o=e.userBubbleTextColor===void 0?H_(B_):e.userBubbleTextColor,s=e.userBubbleBorderColor===void 0?H_(V_):e.userBubbleBorderColor;a&&document.documentElement.style.setProperty(`--user-bubble`,a),o&&document.documentElement.style.setProperty(`--user-bubble-text`,o),s&&document.documentElement.style.setProperty(`--user-bubble-border`,s)}async function W_(){try{let e={};try{let t=localStorage.getItem(`pi-kot/auth-token`);t&&(e.Authorization=`Bearer ${t}`)}catch{}let t=await fetch(`/api/v1/config/ui-settings`,{headers:e});if(!t.ok)return;U_(await t.json())}catch{}}var G_=new Set,K_=!1,q_=[`var(--accent)`,`#d19a66`,`#56b6c2`,`#c678dd`,`#e5c07b`,`#98c379`,`#e06c75`,`#61afef`];function J_(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return q_[Math.abs(t)%q_.length]}function Y_(){let{t:e}=qo(),t=Y(e=>e.activeSessionId),n=Y(e=>e.activeProjectId),r=Y(e=>e.sessions),i=Y(e=>e.projects),a=Y(e=>e.projectSessions),o=Y(e=>e.loadProjects),s=Y(e=>e.setActiveProject),c=Y(e=>e.createAndActivate),l=Y(e=>e.setActiveSession);Y(e=>e.refreshSessions);let u=Y(e=>e.reorderProjects),d=Y(e=>e.moveProject),f=Y(e=>e.streamState.isStreaming),p=Y(e=>e.connectionState),[m,h]=(0,G.useState)(),[g,_]=(0,G.useState)(),[v,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(``),[S,C]=(0,G.useState)(),[w,T]=(0,G.useState)(!0),[E,D]=(0,G.useState)(``),[O,k]=(0,G.useState)(``),[A,j]=(0,G.useState)([]),[M,N]=(0,G.useState)(),[P,F]=(0,G.useState)(new Set),[I,L]=(0,G.useState)(),[R,z]=(0,G.useState)(``),[ee,B]=(0,G.useState)(),[V,H]=(0,G.useState)(),[U,te]=(0,G.useState)(void 0),[ne,re]=(0,G.useState)(new Set),[ie,ae]=(0,G.useState)(!1),oe=(0,G.useRef)(null),se=(0,G.useCallback)(()=>{h(void 0),_(void 0)},[]),ce=(0,G.useCallback)(async e=>{let t=m;if(se(),t===void 0||t===e)return;let n=i.findIndex(e=>e.id===t),r=i.findIndex(t=>t.id===e);if(n===-1||r===-1)return;let a=i.map(e=>e.id),[o]=a.splice(n,1);if(o!==void 0){a.splice(r,0,o);try{await u(a)}catch{}}},[m,i,u,se]),le=Lp(t),ue=J(e=>Di(e,t)),{sidebarCollapsed:de,showTreePanel:fe,showSettings:pe,showOrch:me,showMCP:he,showTerminal:ge,showAddProjectDialog:_e,explorerTab:ve,isMobile:ye,toggleSidebar:be,setSidebarCollapsed:xe,closeSidebarOnMobile:Se,setShowTreePanel:Ce,setShowSettings:we,setShowOrch:Te,setShowMCP:Ee,setShowTerminal:De,setShowAddProjectDialog:Oe,setExplorerTab:W,toggleExplorerTab:ke,setIsMobile:Ae}=q(),je=q(e=>e.viewerTabs),Me=Q(e=>e.swipeToOpenSidebar),[Ne,Pe]=(0,G.useState)(!1),Fe=je.length>0&&!Ne;(0,G.useEffect)(()=>{je.length>0&&Pe(!1)},[je.length]),(0,G.useEffect)(()=>{let e=()=>Ae(window.innerWidth<=600);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),I_({onSwipeLeft:()=>xe(!0),onSwipeRight:()=>xe(!1),threshold:60,enabled:Me}),(0,G.useEffect)(()=>{(async()=>{try{let{authEnabled:e}=await Vt();if(e&&(typeof localStorage<`u`?localStorage.getItem(`pi-kot/auth-token`):null)===null){y(!0),T(!1);return}await o(),W_()}catch{}try{let e=await wn();j(e.providers);let t=e.providers.flatMap(e=>e.models),n=!1;try{let e=localStorage.getItem(`pi-kot-model`);if(e){let r=JSON.parse(e),i=t.find(e=>e.id===r.modelId&&e.hasAuth);i&&(D(i.id),k(r.provider),n=!0)}}catch{}if(!n){let n=t.find(e=>e.hasAuth);n?(D(n.id),k(e.providers.find(e=>e.models.some(e=>e.id===n.id))?.provider??``)):t.length>0&&(D(t[0].id),k(e.providers[0]?.provider??``))}}catch{}T(!1)})()},[]),(0,G.useEffect)(()=>{n!==void 0&&F(e=>new Set(e).add(n))},[n]),(0,G.useEffect)(()=>{if(w||v||i.length===0||n===void 0)return;let e=a[n];if(e!==void 0&&!K_){if(K_=!0,t!==void 0){if(!e.some(e=>e.sessionId===t)){try{localStorage.removeItem(`pi-kot/active-session-id`)}catch{}Y.setState({activeSessionId:void 0});return}Y.getState().sseClient===void 0&&l(t);return}e.length>0?l(e[0].sessionId):G_.has(n)||(G_.add(n),c(n))}},[w,v,n,a,t]),(0,G.useEffect)(()=>{t&&(async()=>{try{let e=await Bn(t);if(e.provider&&e.modelId){D(e.modelId),k(e.provider);try{localStorage.setItem(`pi-kot-model`,JSON.stringify({modelId:e.modelId,provider:e.provider}))}catch{}}}catch{}})()},[t]),(0,G.useEffect)(()=>{let e=n,r=t,i;i=e&&r?`#/project/${e}/session/${r}`:e?`#/project/${e}`:`#`,window.location.hash!==i&&history.replaceState(null,``,i)},[n,t]),(0,G.useEffect)(()=>{let e=()=>{let e=window.location.hash.match(/^#\/project\/([^/]+)(?:\/session\/([^/]+))?$/);if(!e)return;let t=e[1],n=e[2]??void 0,r=Y.getState();n&&n!==r.activeSessionId&&Object.values(r.projectSessions).some(e=>e.some(e=>e.sessionId===n))&&(t===r.activeProjectId?r.setActiveSession(n):r.setActiveProject(t).then(()=>{r.setActiveSession(n)}))};return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),(0,G.useEffect)(()=>Ft(()=>{x(``),C(void 0),y(!0)}),[]);let Ie=(0,G.useCallback)(()=>{Bt(),x(``),C(void 0),y(!0)},[]);(0,G.useEffect)(()=>{let e=Object.values(a).flat(),t=new Set(ne);e.filter(e=>e.supervisorId&&e.isLive).forEach(e=>t.add(e.supervisorId)),re(t)},[a]);let Le=async()=>{try{await Ht(b),C(void 0),y(!1),await o(),W_()}catch{C(`Invalid password`)}},Re=(0,G.useCallback)((e,t)=>{D(e),k(t),N(void 0);try{localStorage.setItem(`pi-kot-model`,JSON.stringify({modelId:e,provider:t}))}catch{}},[]),ze=(0,G.useCallback)(e=>{N(e)},[]),Be=e=>{F(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return w?(0,Z.jsx)(`div`,{className:`centered`,children:(0,Z.jsxs)(`div`,{style:{width:`100%`,maxWidth:400,display:`flex`,flexDirection:`column`,gap:24},children:[(0,Z.jsx)(Fp,{variant:`card`,count:2}),(0,Z.jsx)(Fp,{variant:`list`,count:4})]})}):v?(0,Z.jsx)(`div`,{className:`centered`,children:(0,Z.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),Le()},className:`login-form`,children:[(0,Z.jsx)(`h2`,{className:`login-title`,children:`pi-kot`}),(0,Z.jsx)(`input`,{type:`password`,value:b,onChange:e=>{x(e.target.value),C(void 0)},placeholder:`Enter password`,autoFocus:!0,autoComplete:`new-password`,className:`login-input${S?` login-input-error`:``}`}),S&&(0,Z.jsx)(`div`,{className:`login-error`,children:S}),(0,Z.jsx)(`button`,{type:`submit`,className:`login-btn`,children:`Login`}),(0,Z.jsx)(`button`,{type:`button`,onClick:Ie,className:`login-btn`,style:{background:`none`,border:`1px solid var(--border-color, #444)`,color:`var(--text-dim, #888)`,fontSize:`11px`,marginTop:`4px`},children:`Clear stored token`})]})}):(0,Z.jsxs)(`div`,{className:`app-layout`,children:[!de&&(0,Z.jsx)(`div`,{className:`sidebar-backdrop`,onClick:()=>xe(!0),"aria-hidden":`true`}),(0,Z.jsxs)(`div`,{className:`sidebar${de?` collapsed`:``}`,children:[(0,Z.jsxs)(`div`,{className:`sidebar-header`,children:[(0,Z.jsxs)(`span`,{style:{fontSize:`14px`,fontWeight:700,color:`var(--accent-text)`,display:`flex`,alignItems:`center`,gap:`6px`},children:[(0,Z.jsx)(`span`,{title:p===`connected`?`Connected`:p===`connecting`?`Connecting…`:p===`error`?`Connection error`:`Disconnected`,style:{display:`inline-block`,width:8,height:8,borderRadius:`50%`,background:p===`connected`?`#4caf50`:p===`connecting`?`#f0c040`:p===`error`?`#e06c75`:`#666`,transition:`all 0.3s`,animation:p===`connecting`?`connection-pulse 1.2s ease-in-out infinite`:`none`}}),`pi-kot`]}),(0,Z.jsx)(`button`,{onClick:()=>Oe(!0),title:`Add project`,className:`sidebar-add-project`,"aria-label":`Add project`,children:(0,Z.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`line`,{x1:`12`,y1:`5`,x2:`12`,y2:`19`}),(0,Z.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`})]})})]}),(0,Z.jsx)(`div`,{className:`project-list`,children:i.map(e=>{let r=e.id===n,o=P.has(e.id),u=a[e.id]??[],p=m===e.id,v=g===e.id;return(0,Z.jsxs)(`div`,{className:`project-group${r?` active`:``}`,draggable:!0,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e.id),h(e.id)},onDragEnter:t=>{t.preventDefault(),m!==void 0&&m!==e.id&&_(e.id)},onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},onDragEnd:se,onDrop:t=>{t.preventDefault(),ce(e.id)},style:{opacity:p?.6:1},children:[(0,Z.jsxs)(`div`,{className:`project-row${r?` active`:``}${v?` drag-over`:``}`,onClick:()=>{r?Be(e.id):s(e.id)},role:`button`,tabIndex:0,children:[(0,Z.jsx)(`span`,{className:`project-drag-handle`,title:`Drag to reorder projects`,style:{display:`flex`,alignItems:`center`,cursor:`grab`,color:`var(--text-ghost)`,marginRight:`2px`},children:(0,Z.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`circle`,{cx:`9`,cy:`5`,r:`1`}),(0,Z.jsx)(`circle`,{cx:`15`,cy:`5`,r:`1`}),(0,Z.jsx)(`circle`,{cx:`9`,cy:`12`,r:`1`}),(0,Z.jsx)(`circle`,{cx:`15`,cy:`12`,r:`1`}),(0,Z.jsx)(`circle`,{cx:`9`,cy:`19`,r:`1`}),(0,Z.jsx)(`circle`,{cx:`15`,cy:`19`,r:`1`})]})}),(0,Z.jsxs)(`span`,{className:`project-icon`,children:[(0,Z.jsx)(`svg`,{className:`project-icon-folder`,width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{color:J_(e.id)},children:(0,Z.jsx)(`path`,{d:`M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z`})}),(0,Z.jsx)(`svg`,{className:`project-icon-arrow`,width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,Z.jsx)(`path`,{d:`M9 18l6-6-6-6`})})]}),(0,Z.jsx)(`span`,{className:`project-name`,children:e.name.toLowerCase()}),!o&&u.length>0&&(0,Z.jsx)(`span`,{className:`project-session-count`,children:u.length}),(0,Z.jsxs)(`div`,{className:`project-actions-left`,children:[(0,Z.jsx)(`button`,{onClick:t=>{t.stopPropagation(),d(e.id,`up`)},className:`project-action-btn mobile-reorder-btn`,title:`Move up`,disabled:i.indexOf(e)===0,children:(0,Z.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,Z.jsx)(`polyline`,{points:`18 15 12 9 6 15`})})}),(0,Z.jsx)(`button`,{onClick:t=>{t.stopPropagation(),d(e.id,`down`)},className:`project-action-btn mobile-reorder-btn`,title:`Move down`,disabled:i.indexOf(e)===i.length-1,children:(0,Z.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,Z.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})}),e.name!==`Default`&&(0,Z.jsx)(`button`,{onClick:t=>{t.stopPropagation(),H(e.id)},className:`project-action-btn`,title:`Remove from sidebar`,children:(0,Z.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`polygon`,{points:`5 14 12 5 19 14`}),(0,Z.jsx)(`line`,{x1:`4`,y1:`19`,x2:`20`,y2:`19`})]})})]}),(0,Z.jsx)(`div`,{className:`project-actions-right`,children:(0,Z.jsx)(`button`,{onClick:t=>{t.stopPropagation(),c(e.id)},className:`project-action-btn`,title:`New draft session`,children:(0,Z.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`line`,{x1:`12`,y1:`5`,x2:`12`,y2:`19`}),(0,Z.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`})]})})})]}),o&&(0,Z.jsx)(O_,{projectId:e.id,sessions:u,activeSessionId:t,isStreaming:f,renamingSessionId:I,renameValue:R,renameInputRef:oe,expandedWorkerGroups:ne,onSelect:e=>{l(e),Se()},onRenameStart:(e,t)=>{L(e),z(t),setTimeout(()=>oe.current?.focus(),50)},onRenameChange:z,onRenameCommit:(e,t)=>{let n=R.trim();n.length>0&&n!==t&&Y.getState().renameSession(e,n),L(void 0)},onRenameCancel:()=>L(void 0),onToggleWorkerGroup:e=>{re(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},onNewSession:()=>{c(e.id),Se()}})]},e.id)})}),n!==void 0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`archived-toggle`,title:`Archived sessions are automatically deleted after 30 days if not restored`,onClick:()=>{let e=ee===n?void 0:n;e!==void 0&&Y.getState().loadArchivedSessions(n),B(e)},children:[(0,Z.jsx)(`span`,{className:`project-chevron`,children:ee===n?`▾`:`▸`}),(0,Z.jsx)(`span`,{className:`project-name`,style:{fontSize:`12px`},children:`Archive`}),(0,Z.jsx)(`span`,{style:{fontSize:`9px`,marginLeft:`auto`,opacity:.6,textTransform:`none`,letterSpacing:`normal`},children:`30d auto-delete`})]}),ee===n&&(()=>{let t=Y.getState().archivedSessions[n];return t===void 0?(0,Z.jsx)(`div`,{className:`archived-status`,children:(0,Z.jsx)(Fp,{variant:`list`,count:2})}):(0,Z.jsx)(`div`,{className:`sidebar-section-content`,style:{marginTop:4},children:t.length===0?(0,Z.jsx)(`div`,{className:`archived-status`,children:e(`app.noArchived`)}):(0,Z.jsx)(`div`,{className:`session-list project-sublist archived-list`,children:t.map(e=>{let t=e.name??`Session ${e.sessionId.slice(0,8)}`,r=typeof e.expiresInDays==`number`&&e.expiresInDays<=3;return(0,Z.jsxs)(`div`,{className:`session-item archived`,children:[(0,Z.jsx)(`span`,{className:`session-name`,title:t,children:t}),e.expiresInDays!==void 0&&(0,Z.jsxs)(`span`,{className:`session-expiry-badge${r?` expiring-soon`:``}`,title:`Auto-deletes in ${e.expiresInDays} day${e.expiresInDays===1?``:`s`} if not restored`,children:[e.expiresInDays,`d left`]}),(0,Z.jsxs)(`div`,{className:`archived-actions`,children:[(0,Z.jsx)(`button`,{className:`session-restore-btn`,title:`Restore session to active list`,onClick:t=>{t.stopPropagation(),Y.getState().unarchiveSession(e.sessionId,n)},children:`↻`}),(0,Z.jsx)(`button`,{className:`session-permanent-delete-btn`,title:`Permanently delete session now`,onClick:r=>{r.stopPropagation(),confirm(`Permanently delete "${t}" now? This cannot be undone.`)&&Y.getState().deleteArchivedSession(e.sessionId,n)},children:`✕`})]})]},e.sessionId)})})})})()]}),(0,Z.jsx)(`div`,{className:`sidebar-footer`,children:(0,Z.jsxs)(`div`,{className:`sidebar-nav-items`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{Ee(!0),xe(!0)},className:`sidebar-nav-btn`,children:[(0,Z.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`sidebar-nav-icon`,children:[(0,Z.jsx)(`path`,{d:`M12 2L2 7l10 5 10-5-10-5z`}),(0,Z.jsx)(`path`,{d:`M2 17l10 5 10-5`}),(0,Z.jsx)(`path`,{d:`M2 12l10 5 10-5`})]}),(0,Z.jsx)(`span`,{children:e(`sidebar.nav.mcp`)})]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{we(!0),xe(!0)},className:`sidebar-nav-btn`,children:[(0,Z.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`sidebar-nav-icon`,children:[(0,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,Z.jsx)(`path`,{d:`M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z`})]}),(0,Z.jsx)(`span`,{children:e(`sidebar.nav.settings`)})]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{Ie(),xe(!0)},className:`sidebar-nav-btn sidebar-nav-btn-muted`,children:[(0,Z.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`sidebar-nav-icon`,children:[(0,Z.jsx)(`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`}),(0,Z.jsx)(`polyline`,{points:`16 17 21 12 16 7`}),(0,Z.jsx)(`line`,{x1:`21`,y1:`12`,x2:`9`,y2:`12`})]}),(0,Z.jsx)(`span`,{children:e(`sidebar.nav.signOut`)})]})]})})]}),(0,Z.jsxs)(`div`,{className:`main-area`,children:[(0,Z.jsxs)(`div`,{className:`header`,children:[(0,Z.jsxs)(`div`,{className:`header-left`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:be,className:`sidebar-toggle`,title:de?`Show sidebar`:`Hide sidebar`,children:de?(0,Z.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`}),(0,Z.jsx)(`path`,{d:`M9 3v18`}),(0,Z.jsx)(`path`,{d:`m14 9 3 3-3 3`})]}):(0,Z.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`}),(0,Z.jsx)(`path`,{d:`M9 3v18`}),(0,Z.jsx)(`path`,{d:`m16 15-3-3 3-3`})]})}),t!==void 0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{style:{fontSize:`13px`,fontWeight:500,color:`var(--text-secondary)`,marginLeft:`8px`},children:[n!==void 0&&i.find(e=>e.id===n)?.name?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{style:{color:`var(--text-dim)`},children:i.find(e=>e.id===n).name.toLowerCase()}),(0,Z.jsx)(`span`,{style:{color:`var(--text-ghost)`,margin:`0 4px`},children:`/`})]}):null,r.find(e=>e.sessionId===t)?.name??`session ${t.slice(0,8)}`]}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>Ce(!0),title:`Session tree (branching history)`,className:`header-btn`,children:(0,Z.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`line`,{x1:`6`,y1:`3`,x2:`6`,y2:`15`}),(0,Z.jsx)(`circle`,{cx:`18`,cy:`6`,r:`3`}),(0,Z.jsx)(`circle`,{cx:`6`,cy:`18`,r:`3`}),(0,Z.jsx)(`path`,{d:`M18 9a9 9 0 0 1-9 9`})]})}),n!==void 0&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>ae(e=>!e),title:`System prompt for this project`,className:`header-btn${ie?` active`:``}`,children:(0,Z.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,Z.jsx)(`path`,{d:`m12 3-1.9 5.8a2 2 0 0 1-1.3 1.3L3 12l5.8 1.9a2 2 0 0 1 1.3 1.3L12 21l1.9-5.8a2 2 0 0 1 1.3-1.3L21 12l-5.8-1.9a2 2 0 0 1-1.3-1.3L12 3Z`})})})]})]}),(0,Z.jsxs)(`div`,{className:`header-right`,children:[(0,Z.jsx)(Rp,{data:le,onInspect:e=>te(e)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>ke(`files`),title:`File explorer`,className:`header-btn${ve===`files`?` active`:``}`,children:(0,Z.jsx)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,Z.jsx)(`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`})})}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{De(!0),xe(!0)},title:`Terminal`,className:`header-btn${ge?` active`:``}`,children:(0,Z.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`polyline`,{points:`4 17 10 11 4 5`}),(0,Z.jsx)(`line`,{x1:`12`,y1:`19`,x2:`20`,y2:`19`})]})}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>ke(`processes`),title:ue>0?`${ue} background process(es) running`:`Background processes`,className:`header-btn${ve===`processes`?` active`:``}`,style:{position:`relative`},children:[(0,Z.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`polyline`,{points:`4 17 10 11 4 5`}),(0,Z.jsx)(`line`,{x1:`12`,y1:`19`,x2:`20`,y2:`19`})]}),ue>0&&(0,Z.jsx)(`span`,{style:{position:`absolute`,top:`5px`,right:`5px`,width:`7px`,height:`7px`,borderRadius:`50%`,background:`#10b981`,boxShadow:`0 0 6px #10b981`}})]}),(0,Z.jsxs)(`div`,{className:`header-overflow desktop-only`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>Ee(!0),title:e(`sidebar.nav.mcp`),className:`header-btn${he?` active`:``}`,children:(0,Z.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`path`,{d:`M12 2L2 7l10 5 10-5-10-5z`}),(0,Z.jsx)(`path`,{d:`M2 17l10 5 10-5`}),(0,Z.jsx)(`path`,{d:`M2 12l10 5 10-5`})]})}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>we(!0),title:e(`sidebar.nav.settings`),className:`header-btn${pe?` active`:``}`,children:(0,Z.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,Z.jsx)(`path`,{d:`M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z`})]})}),(0,Z.jsx)(`button`,{type:`button`,onClick:Ie,title:e(`sidebar.nav.signOut`),className:`header-btn`,children:(0,Z.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`}),(0,Z.jsx)(`polyline`,{points:`16 17 21 12 16 7`}),(0,Z.jsx)(`line`,{x1:`21`,y1:`12`,x2:`9`,y2:`12`})]})})]})]})]}),M!==void 0&&(0,Z.jsxs)(`div`,{onClick:()=>N(void 0),className:`error-banner`,style:{position:`absolute`,top:`52px`,left:`16px`,right:`16px`,zIndex:9,cursor:`pointer`},children:[M,` — click to dismiss`]}),(0,Z.jsxs)(`div`,{className:`main-content-row${Fe?` viewer-active`:``}`,style:{flex:1,display:`flex`,flexDirection:`row`,minHeight:0,overflow:`hidden`,position:`relative`},children:[(0,Z.jsx)(`div`,{className:`chat-column`,style:{flex:1,display:`flex`,flexDirection:`column`,minWidth:0,overflow:`hidden`},children:t===void 0?(0,Z.jsx)(`div`,{className:`centered`,style:{height:`100%`},children:(0,Z.jsxs)(`div`,{className:`welcome-message`,style:{margin:`auto`},children:[(0,Z.jsx)(`div`,{className:`welcome-icon`,children:`⌨️`}),(0,Z.jsx)(`div`,{className:`welcome-text`,children:e(`app.selectSession`)}),(0,Z.jsx)(`div`,{className:`welcome-hint`,children:e(`app.startChatting`)})]})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(F_,{label:`ChatView`,compact:!0,children:(0,Z.jsx)(wp,{sessionId:t,modelName:E||void 0,providerName:O||void 0})}),(0,Z.jsx)(F_,{label:`OrchestrationPanel`,compact:!0,children:(0,Z.jsx)(Ip,{sessionId:t,open:me,onClose:()=>Te(!1)})}),(0,Z.jsx)(Ap,{sessionId:t}),(0,Z.jsx)(kp,{sessionId:t,showOrch:me,setShowOrch:Te,selectedModel:E,onModelSelect:Re,onModelError:ze})]})}),n!==void 0&&(0,Z.jsx)(Xg,{projectId:n,onClose:()=>Pe(!0)}),n!==void 0&&(0,Z.jsx)(r_,{}),(0,Z.jsx)(i_,{}),n!==void 0&&!ye&&(0,Z.jsx)(F_,{label:`FileExplorer`,compact:!0,children:(0,Z.jsx)(lg,{projectId:n,open:ve!==void 0,onClose:()=>W(void 0),initialTab:ve,flexLayout:!0})})]})]}),n!==void 0&&ye&&(0,Z.jsx)(F_,{label:`FileExplorer`,compact:!0,children:(0,Z.jsx)(lg,{projectId:n,open:ve!==void 0,onClose:()=>W(void 0),initialTab:ve,flexLayout:!1})}),(0,Z.jsx)(`style`,{children:`
172
+ /* On mobile, viewer fills the whole width when active */
173
+ @media (max-width: 600px) {
174
+ .main-content-row.viewer-active .chat-column {
175
+ display: none;
176
+ }
177
+ .main-content-row.viewer-active .file-viewer-wrapper {
178
+ width: 100% !important;
179
+ min-width: 0 !important;
180
+ }
181
+ }
182
+
183
+ /* Hide back button on desktop (side panel doesn't need it) */
184
+ @media (min-width: 601px) {
185
+ .viewer-back-btn {
186
+ display: none;
187
+ }
188
+ }
189
+
190
+ /* Collapse the viewer when minimized (tabs exist but hidden) or empty */
191
+ .main-content-row:not(.viewer-active) .file-viewer-wrapper {
192
+ width: 0 !important;
193
+ min-width: 0 !important;
194
+ }
195
+ `}),t!==void 0&&n!==void 0&&(0,Z.jsx)(F_,{label:`SessionTreePanel`,compact:!0,children:(0,Z.jsx)(im,{sessionId:t,projectId:n,open:fe,onClose:()=>Ce(!1)})}),V!==void 0&&(0,Z.jsx)(`div`,{className:`settings-overlay`,onClick:()=>H(void 0),children:(0,Z.jsxs)(`div`,{className:`settings-panel rewind-panel`,onClick:e=>e.stopPropagation(),style:{width:420,maxWidth:`90vw`,height:`auto`,minHeight:0},children:[(0,Z.jsxs)(`header`,{className:`settings-header`,children:[(0,Z.jsx)(`span`,{style:{fontSize:14,fontWeight:600},children:e(`app.removeProject`)}),(0,Z.jsx)(`button`,{onClick:()=>H(void 0),className:`settings-close`,title:`Close`,children:`✕`})]}),(0,Z.jsxs)(`div`,{className:`settings-body`,style:{padding:`16px`},children:[(0,Z.jsxs)(`p`,{style:{fontSize:13,color:`var(--text-secondary)`,marginBottom:20,lineHeight:1.5},children:[`This removes `,(0,Z.jsx)(`strong`,{children:i.find(e=>e.id===V)?.name??V}),` from the sidebar — all sessions stay safely on disk. You can add it back anytime.`]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:8,justifyContent:`flex-end`},children:[(0,Z.jsx)(`button`,{onClick:()=>H(void 0),className:`settings-tab`,style:{padding:`6px 14px`,fontSize:12},children:`Cancel`}),(0,Z.jsx)(`button`,{onClick:()=>{Y.getState().deleteProject(V),H(void 0)},className:`settings-tab settings-tab-active`,style:{padding:`6px 14px`,fontSize:12,background:`var(--accent-red, #e06c75)`,color:`#fff`,border:`none`},children:`Remove`})]})]})]})}),pe&&(0,Z.jsx)(F_,{label:`SettingsPanel`,compact:!0,children:(0,Z.jsx)(Ah,{onClose:()=>we(!1)})}),U!==void 0&&(0,Z.jsx)(Bp,{data:U,onClose:()=>te(void 0),sessionId:t}),ie&&n!==void 0&&(0,Z.jsx)(`div`,{className:`prompt-popup-overlay`,onClick:()=>ae(!1),children:(0,Z.jsxs)(`div`,{className:`prompt-popup`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(`div`,{className:`prompt-popup-header`,children:[(0,Z.jsx)(`span`,{className:`prompt-popup-title`,children:`System Prompt`}),(0,Z.jsx)(`span`,{style:{color:`var(--text-dim)`,fontSize:`13px`},children:`·`}),(0,Z.jsx)(`span`,{className:`prompt-popup-project`,children:i.find(e=>e.id===n)?.name.toLowerCase()??n}),(0,Z.jsx)(`button`,{className:`prompt-popup-close`,onClick:()=>ae(!1),type:`button`,title:`Close`,children:(0,Z.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,Z.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]}),(0,Z.jsx)(`div`,{className:`prompt-popup-body`,children:(0,Z.jsx)(Gh,{projectId:n})})]})}),(0,Z.jsx)(F_,{label:`TerminalPanel`,compact:!0,children:(0,Z.jsx)(v_,{open:ge,onClose:()=>De(!1)})}),he&&(0,Z.jsx)(F_,{label:`MCPPanel`,compact:!0,children:(0,Z.jsx)(Xp,{onClose:()=>Ee(!1)})}),t!==void 0&&(0,Z.jsx)(C_,{sessionId:t}),(0,Z.jsx)(w_,{}),_e&&(0,Z.jsx)(P_,{open:_e,onClose:()=>Oe(!1)})]})}Nm(jm(),Mm()),W_();var X_=document.getElementById(`root`);if(X_===null)throw Error(`root element not found`);(0,jt.createRoot)(X_).render((0,Z.jsx)(G.StrictMode,{children:(0,Z.jsx)(Ko,{children:(0,Z.jsx)(Y_,{})})}));
196
+ //# sourceMappingURL=index-CBtH0h8n.js.map