@hienlh/ppm 0.8.68 → 0.8.70

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 (30) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/web/assets/{browser-tab-CtCbYDuw.js → browser-tab-sn8vZniz.js} +1 -1
  3. package/dist/web/assets/chat-tab-CVN2falD.js +8 -0
  4. package/dist/web/assets/{code-editor-B1u2B_S9.js → code-editor-BNAZzdyF.js} +1 -1
  5. package/dist/web/assets/{database-viewer-D9fH7muY.js → database-viewer-BOnawWoi.js} +1 -1
  6. package/dist/web/assets/{diff-viewer-CdAqWeV-.js → diff-viewer-CYSw0YBG.js} +1 -1
  7. package/dist/web/assets/{git-graph-BDUvkX0f.js → git-graph-BNTU6kmo.js} +1 -1
  8. package/dist/web/assets/{index-DtlqB_mF.js → index-ButO-DnP.js} +8 -8
  9. package/dist/web/assets/index-DJ1Bqwo4.css +2 -0
  10. package/dist/web/assets/keybindings-store-BxDBTcFM.js +1 -0
  11. package/dist/web/assets/{markdown-renderer-Bwac0-W_.js → markdown-renderer-CW2c3h_9.js} +1 -1
  12. package/dist/web/assets/{postgres-viewer-CqT43D2z.js → postgres-viewer-D95__akI.js} +1 -1
  13. package/dist/web/assets/{settings-tab-G59ZwloQ.js → settings-tab-CwLkeZaa.js} +1 -1
  14. package/dist/web/assets/{sqlite-viewer-D6sxS0bk.js → sqlite-viewer-J18kIhk2.js} +1 -1
  15. package/dist/web/assets/{terminal-tab-IkfhM5s1.js → terminal-tab-BKETi9uD.js} +1 -1
  16. package/dist/web/assets/{use-monaco-theme-gi_EBBX3.js → use-monaco-theme-Dsn8sLad.js} +1 -1
  17. package/dist/web/index.html +2 -2
  18. package/dist/web/sw.js +1 -1
  19. package/package.json +1 -1
  20. package/src/providers/claude-agent-sdk.ts +51 -8
  21. package/src/server/routes/chat.ts +17 -0
  22. package/src/server/ws/chat.ts +2 -2
  23. package/src/types/chat.ts +2 -1
  24. package/src/web/components/chat/chat-history-bar.tsx +34 -1
  25. package/src/web/components/chat/message-list.tsx +7 -0
  26. package/src/web/components/layout/editor-panel.tsx +96 -17
  27. package/src/web/hooks/use-chat.ts +11 -0
  28. package/dist/web/assets/chat-tab-Bx_6S_UY.js +0 -7
  29. package/dist/web/assets/index-DPI-YVJI.css +0 -2
  30. package/dist/web/assets/keybindings-store-DiM6OAOI.js +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/api-settings-D21InCnR.js","assets/chunk-CFjPhJqf.js","assets/api-client-BfBM3I7n.js","assets/terminal-tab-IkfhM5s1.js","assets/utils-BNytJOb1.js","assets/jsx-runtime-BRW_vwa9.js","assets/react-nm2Ru1Pt.js","assets/terminal-tab-BrP-ENHg.css","assets/chat-tab-Bx_6S_UY.js","assets/preload-helper-uTix4PVD.js","assets/dist-CSJdAyA9.js","assets/dist-lF8CoYII.js","assets/react-dom-Bpkvzu3U.js","assets/chunk-PU5JKC2W-Dw8ClWch.js","assets/src-BqX54PbV.js","assets/chunk-GEFDOKGD-BbQkJu8C.js","assets/math-069Z4SuC.js","assets/chunk-7R4GIKGN-BbIFzsIv.js","assets/isArrayLikeObject-B_v2FtYn.js","assets/input-BglMT33g.js","assets/arrow-up--LjUXLEt.js","assets/chevron-right-DeV0ehiG.js","assets/markdown-renderer-Bwac0-W_.js","assets/isEmpty-bnrF3Qbc.js","assets/tab-store-BCfMgMKM.js","assets/react-ER-4DN55.js","assets/chunk-GLR3WWYH-CzYx4w-r.js","assets/chunk-KYZI473N-BcUZNnwd.js","assets/chunk-PQ6SQG4A-D6BTbCQw.js","assets/chunk-YBOYWFTD-CeU4Q-xC.js","assets/rough.esm-JX0wREDd.js","assets/chunk-O4XLMI2P-JC6EGoUz.js","assets/line-B78g-52T.js","assets/path-6uRLdFF7.js","assets/array-B9UHiPd-.js","assets/chunk-MX3YWQON-BpS_PtKp.js","assets/chunk-HHEYEP7N-HRhYy3kG.js","assets/chunk-XPW4576I-BPQQBakK.js","assets/columns-2-DpsNbZOc.js","assets/tag-CCtdV063.js","assets/code-editor-B1u2B_S9.js","assets/use-monaco-theme-gi_EBBX3.js","assets/table-C7X5UAEI.js","assets/database-viewer-D9fH7muY.js","assets/dist-DylI9XxN.js","assets/lib-BQ34Db2e.js","assets/sqlite-viewer-D6sxS0bk.js","assets/postgres-viewer-CqT43D2z.js","assets/git-graph-BDUvkX0f.js","assets/diff-viewer-CdAqWeV-.js","assets/settings-tab-G59ZwloQ.js","assets/browser-tab-CtCbYDuw.js","assets/keybindings-store-DiM6OAOI.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/api-settings-D21InCnR.js","assets/chunk-CFjPhJqf.js","assets/api-client-BfBM3I7n.js","assets/terminal-tab-BKETi9uD.js","assets/utils-BNytJOb1.js","assets/jsx-runtime-BRW_vwa9.js","assets/react-nm2Ru1Pt.js","assets/terminal-tab-BrP-ENHg.css","assets/chat-tab-CVN2falD.js","assets/preload-helper-uTix4PVD.js","assets/dist-CSJdAyA9.js","assets/dist-lF8CoYII.js","assets/react-dom-Bpkvzu3U.js","assets/chunk-PU5JKC2W-Dw8ClWch.js","assets/src-BqX54PbV.js","assets/chunk-GEFDOKGD-BbQkJu8C.js","assets/math-069Z4SuC.js","assets/chunk-7R4GIKGN-BbIFzsIv.js","assets/isArrayLikeObject-B_v2FtYn.js","assets/input-BglMT33g.js","assets/arrow-up--LjUXLEt.js","assets/chevron-right-DeV0ehiG.js","assets/markdown-renderer-CW2c3h_9.js","assets/isEmpty-bnrF3Qbc.js","assets/tab-store-BCfMgMKM.js","assets/react-ER-4DN55.js","assets/chunk-GLR3WWYH-CzYx4w-r.js","assets/chunk-KYZI473N-BcUZNnwd.js","assets/chunk-PQ6SQG4A-D6BTbCQw.js","assets/chunk-YBOYWFTD-CeU4Q-xC.js","assets/rough.esm-JX0wREDd.js","assets/chunk-O4XLMI2P-JC6EGoUz.js","assets/line-B78g-52T.js","assets/path-6uRLdFF7.js","assets/array-B9UHiPd-.js","assets/chunk-MX3YWQON-BpS_PtKp.js","assets/chunk-HHEYEP7N-HRhYy3kG.js","assets/chunk-XPW4576I-BPQQBakK.js","assets/columns-2-DpsNbZOc.js","assets/tag-CCtdV063.js","assets/code-editor-BNAZzdyF.js","assets/use-monaco-theme-Dsn8sLad.js","assets/table-C7X5UAEI.js","assets/database-viewer-BOnawWoi.js","assets/dist-DylI9XxN.js","assets/lib-BQ34Db2e.js","assets/sqlite-viewer-J18kIhk2.js","assets/postgres-viewer-D95__akI.js","assets/git-graph-BNTU6kmo.js","assets/diff-viewer-CYSw0YBG.js","assets/settings-tab-CwLkeZaa.js","assets/browser-tab-sn8vZniz.js","assets/keybindings-store-BxDBTcFM.js"])))=>i.map(i=>d[i]);
2
2
  import{o as e,t}from"./chunk-CFjPhJqf.js";import{t as n}from"./react-nm2Ru1Pt.js";import{t as r}from"./react-dom-Bpkvzu3U.js";import{n as i,t as a}from"./jsx-runtime-BRW_vwa9.js";import{a as o,i as s,n as c,r as l,t as u}from"./input-BglMT33g.js";import{t as d}from"./chevron-right-DeV0ehiG.js";import{a as f,i as p,n as m,o as h,r as g,t as _}from"./tab-store-BCfMgMKM.js";import{t as v}from"./react-ER-4DN55.js";import{t as y}from"./preload-helper-uTix4PVD.js";import{C as b,D as x,E as S,O as C,S as w,_ as T,a as E,b as D,c as O,d as ee,f as k,g as A,h as j,i as te,k as M,l as N,m as P,n as ne,o as re,p as F,r as ie,s as ae,t as I,u as oe,v as se,w as ce,x as le,y as L}from"./dist-lF8CoYII.js";import{n as R,t as ue}from"./utils-BNytJOb1.js";import{a as de,i as fe,r as pe,t as z}from"./api-client-BfBM3I7n.js";import{f as me,i as he,l as ge,p as _e}from"./api-settings-D21InCnR.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 ve=t((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&&A(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&&A(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 ee=new MessageChannel,k=ee.port2;ee.port1.onmessage=D,O=function(){k.postMessage(null)}}else O=function(){_(D,0)};function A(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,A(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}}}})),ye=t(((e,t)=>{t.exports=ve()})),be=t((e=>{var t=ye(),i=n(),a=r();function o(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 s(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function c(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 l(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 u(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 d(e){if(c(e)!==e)throw Error(o(188))}function f(e){var t=e.alternate;if(!t){if(t=c(e),t===null)throw Error(o(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var a=i.alternate;if(a===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===a.child){for(a=i.child;a;){if(a===n)return d(i),e;if(a===r)return d(i),t;a=a.sibling}throw Error(o(188))}if(n.return!==r.return)n=i,r=a;else{for(var s=!1,l=i.child;l;){if(l===n){s=!0,n=i,r=a;break}if(l===r){s=!0,r=i,n=a;break}l=l.sibling}if(!s){for(l=a.child;l;){if(l===n){s=!0,n=a,r=i;break}if(l===r){s=!0,r=a,n=i;break}l=l.sibling}if(!s)throw Error(o(189))}}if(n.alternate!==r)throw Error(o(190))}if(n.tag!==3)throw Error(o(188));return n.stateNode.current===n?e:t}function p(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=p(e),t!==null)return t;e=e.sibling}return null}var m=Object.assign,h=Symbol.for(`react.element`),g=Symbol.for(`react.transitional.element`),_=Symbol.for(`react.portal`),v=Symbol.for(`react.fragment`),y=Symbol.for(`react.strict_mode`),b=Symbol.for(`react.profiler`),x=Symbol.for(`react.consumer`),S=Symbol.for(`react.context`),C=Symbol.for(`react.forward_ref`),w=Symbol.for(`react.suspense`),T=Symbol.for(`react.suspense_list`),E=Symbol.for(`react.memo`),D=Symbol.for(`react.lazy`),O=Symbol.for(`react.activity`),ee=Symbol.for(`react.memo_cache_sentinel`),k=Symbol.iterator;function A(e){return typeof e!=`object`||!e?null:(e=k&&e[k]||e[`@@iterator`],typeof e==`function`?e:null)}var j=Symbol.for(`react.client.reference`);function te(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===j?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case v:return`Fragment`;case b:return`Profiler`;case y:return`StrictMode`;case w:return`Suspense`;case T:return`SuspenseList`;case O:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case _:return`Portal`;case S:return e.displayName||`Context`;case x:return(e._context.displayName||`Context`)+`.Consumer`;case C:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case E:return t=e.displayName||null,t===null?te(e.type)||`Memo`:t;case D:t=e._payload,e=e._init;try{return te(e(t))}catch{}}return null}var M=Array.isArray,N=i.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P=a.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ne={pending:!1,data:null,method:null,action:null},re=[],F=-1;function ie(e){return{current:e}}function ae(e){0>F||(e.current=re[F],re[F]=null,F--)}function I(e,t){F++,re[F]=e.current,e.current=t}var oe=ie(null),se=ie(null),ce=ie(null),le=ie(null);function L(e,t){switch(I(ce,t),I(se,e),I(oe,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}ae(oe),I(oe,e)}function R(){ae(oe),ae(se),ae(ce)}function ue(e){e.memoizedState!==null&&I(le,e);var t=oe.current,n=Hd(t,e.type);t!==n&&(I(se,e),I(oe,n))}function de(e){se.current===e&&(ae(oe),ae(se)),le.current===e&&(ae(le),Qf._currentValue=ne)}var fe,pe;function z(e){if(fe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);fe=t&&t[1]||``,pe=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+fe+e+pe}var me=!1;function he(e,t){if(!e||me)return``;me=!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(`
@@ -11,12 +11,12 @@ Error generating stack: `+e.message+`
11
11
 
12
12
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
13
13
 
14
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return B.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},gr=`DialogDescriptionWarning`,_r=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${mr(gr).contentName}}.`;return B.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},vr=Un,yr=Yn,br=Zn,xr=tr,Sr=or,Cr=cr,wr=ur;function Tr(e){let t=B.useRef({value:e,previous:e});return B.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Er=`rovingFocusGroup.onEntryFocus`,Dr={bubbles:!1,cancelable:!0},Or=`RovingFocusGroup`,[kr,Ar,jr]=D(Or),[Mr,Nr]=w(Or,[jr]),[Pr,Fr]=Mr(Or),Ir=B.forwardRef((e,t)=>(0,H.jsx)(kr.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,H.jsx)(kr.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,H.jsx)(Lr,{...e,ref:t})})}));Ir.displayName=Or;var Lr=B.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=B.useRef(null),p=M(t,f),m=P(a),[h,g]=T({prop:o,defaultProp:s??null,onChange:c,caller:Or}),[_,v]=B.useState(!1),y=F(l),x=Ar(n),S=B.useRef(!1),[C,w]=B.useState(0);return B.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(Er,y),()=>e.removeEventListener(Er,y)},[y]),(0,H.jsx)(Pr,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:B.useCallback(e=>g(e),[g]),onItemShiftTab:B.useCallback(()=>v(!0),[]),onFocusableItemAdd:B.useCallback(()=>w(e=>e+1),[]),onFocusableItemRemove:B.useCallback(()=>w(e=>e-1),[]),children:(0,H.jsx)(b.div,{tabIndex:_||C===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:L(e.onMouseDown,()=>{S.current=!0}),onFocus:L(e.onFocus,e=>{let t=!S.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(Er,Dr);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=x().filter(e=>e.focusable);Ur([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}S.current=!1}),onBlur:L(e.onBlur,()=>v(!1))})})}),Rr=`RovingFocusGroupItem`,zr=B.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=j(),l=a||c,u=Fr(Rr,n),d=u.currentTabStopId===l,f=Ar(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return B.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,H.jsx)(kr.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,H.jsx)(b.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:L(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:L(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:L(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=Hr(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?Wr(n,r+1):n.slice(r+1)}setTimeout(()=>Ur(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});zr.displayName=Rr;var Br={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function Vr(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function Hr(e,t,n){let r=Vr(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return Br[r]}function Ur(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Wr(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Gr=Ir,Kr=zr,qr=[`Enter`,` `],Jr=[`ArrowDown`,`PageUp`,`Home`],Yr=[`ArrowUp`,`PageDown`,`End`],Xr=[...Jr,...Yr],Zr={ltr:[...qr,`ArrowRight`],rtl:[...qr,`ArrowLeft`]},Qr={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},$r=`Menu`,[ei,ti,ni]=D($r),[ri,ii]=w($r,[ni,E,Nr]),ai=E(),oi=Nr(),[si,ci]=ri($r),[li,ui]=ri($r),di=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=ai(t),[c,l]=B.useState(null),u=B.useRef(!1),d=F(a),f=P(i);return B.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),(0,H.jsx)(te,{...s,children:(0,H.jsx)(si,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,H.jsx)(li,{scope:t,onClose:B.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};di.displayName=$r;var fi=`MenuAnchor`,pi=B.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=ai(n);return(0,H.jsx)(I,{...i,...r,ref:t})});pi.displayName=fi;var mi=`MenuPortal`,[hi,gi]=ri(mi,{forceMount:void 0}),_i=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=ci(mi,t);return(0,H.jsx)(hi,{scope:t,forceMount:n,children:(0,H.jsx)(A,{present:n||a.open,children:(0,H.jsx)(oe,{asChild:!0,container:i,children:r})})})};_i.displayName=mi;var vi=`MenuContent`,[yi,bi]=ri(vi),xi=B.forwardRef((e,t)=>{let n=gi(vi,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=ci(vi,e.__scopeMenu),o=ui(vi,e.__scopeMenu);return(0,H.jsx)(ei.Provider,{scope:e.__scopeMenu,children:(0,H.jsx)(A,{present:r||a.open,children:(0,H.jsx)(ei.Slot,{scope:e.__scopeMenu,children:o.modal?(0,H.jsx)(Si,{...i,ref:t}):(0,H.jsx)(Ci,{...i,ref:t})})})})}),Si=B.forwardRef((e,t)=>{let n=ci(vi,e.__scopeMenu),r=B.useRef(null),i=M(t,r);return B.useEffect(()=>{let e=r.current;if(e)return ae(e)},[]),(0,H.jsx)(Ti,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:L(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Ci=B.forwardRef((e,t)=>{let n=ci(vi,e.__scopeMenu);return(0,H.jsx)(Ti,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),wi=S(`MenuContent.ScrollLock`),Ti=B.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=ci(vi,n),_=ui(vi,n),v=ai(n),y=oi(n),b=ti(n),[x,S]=B.useState(null),C=B.useRef(null),w=M(t,C,g.onContentChange),T=B.useRef(0),E=B.useRef(``),D=B.useRef(0),A=B.useRef(null),j=B.useRef(`right`),te=B.useRef(0),P=m?O:B.Fragment,ne=m?{as:wi,allowPinchZoom:!0}:void 0,re=e=>{let t=E.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=ca(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){E.current=t,window.clearTimeout(T.current),t!==``&&(T.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};B.useEffect(()=>()=>window.clearTimeout(T.current),[]),N();let F=B.useCallback(e=>j.current===A.current?.side&&ua(e,A.current?.area),[]);return(0,H.jsx)(yi,{scope:n,searchRef:E,onItemEnter:B.useCallback(e=>{F(e)&&e.preventDefault()},[F]),onItemLeave:B.useCallback(e=>{F(e)||(C.current?.focus(),S(null))},[F]),onTriggerLeave:B.useCallback(e=>{F(e)&&e.preventDefault()},[F]),pointerGraceTimerRef:D,onPointerGraceIntentChange:B.useCallback(e=>{A.current=e},[]),children:(0,H.jsx)(P,{...ne,children:(0,H.jsx)(ee,{asChild:!0,trapped:i,onMountAutoFocus:L(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,H.jsx)(k,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,H.jsx)(Gr,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:L(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,H.jsx)(ie,{role:`menu`,"aria-orientation":`vertical`,"data-state":ra(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:w,style:{outline:`none`,...h.style},onKeyDown:L(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&re(e.key));let i=C.current;if(e.target!==i||!Xr.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);Yr.includes(e.key)&&a.reverse(),oa(a)}),onBlur:L(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(T.current),E.current=``)}),onPointerMove:L(e.onPointerMove,da(e=>{let t=e.target,n=te.current!==e.clientX;e.currentTarget.contains(t)&&n&&(j.current=e.clientX>te.current?`right`:`left`,te.current=e.clientX)}))})})})})})})});xi.displayName=vi;var Ei=`MenuGroup`,Di=B.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,H.jsx)(b.div,{role:`group`,...r,ref:t})});Di.displayName=Ei;var Oi=`MenuLabel`,ki=B.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,H.jsx)(b.div,{...r,ref:t})});ki.displayName=Oi;var Ai=`MenuItem`,U=`menu.itemSelect`,ji=B.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=B.useRef(null),o=ui(Ai,e.__scopeMenu),s=bi(Ai,e.__scopeMenu),c=M(t,a),l=B.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(U,{bubbles:!0,cancelable:!0});e.addEventListener(U,e=>r?.(e),{once:!0}),ce(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,H.jsx)(Mi,{...i,ref:c,disabled:n,onClick:L(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:L(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:L(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||qr.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});ji.displayName=Ai;var Mi=B.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=bi(Ai,n),s=oi(n),c=B.useRef(null),l=M(t,c),[u,d]=B.useState(!1),[f,p]=B.useState(``);return B.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,H.jsx)(ei.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,H.jsx)(Kr,{asChild:!0,...s,focusable:!r,children:(0,H.jsx)(b.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:L(e.onPointerMove,da(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:L(e.onPointerLeave,da(e=>o.onItemLeave(e))),onFocus:L(e.onFocus,()=>d(!0)),onBlur:L(e.onBlur,()=>d(!1))})})})}),Ni=`MenuCheckboxItem`,Pi=B.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,H.jsx)(Hi,{scope:e.__scopeMenu,checked:n,children:(0,H.jsx)(ji,{role:`menuitemcheckbox`,"aria-checked":ia(n)?`mixed`:n,...i,ref:t,"data-state":aa(n),onSelect:L(i.onSelect,()=>r?.(ia(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Pi.displayName=Ni;var Fi=`MenuRadioGroup`,[Ii,Li]=ri(Fi,{value:void 0,onValueChange:()=>{}}),Ri=B.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=F(r);return(0,H.jsx)(Ii,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,H.jsx)(Di,{...i,ref:t})})});Ri.displayName=Fi;var zi=`MenuRadioItem`,Bi=B.forwardRef((e,t)=>{let{value:n,...r}=e,i=Li(zi,e.__scopeMenu),a=n===i.value;return(0,H.jsx)(Hi,{scope:e.__scopeMenu,checked:a,children:(0,H.jsx)(ji,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":aa(a),onSelect:L(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});Bi.displayName=zi;var Vi=`MenuItemIndicator`,[Hi,Ui]=ri(Vi,{checked:!1}),Wi=B.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=Ui(Vi,n);return(0,H.jsx)(A,{present:r||ia(a.checked)||a.checked===!0,children:(0,H.jsx)(b.span,{...i,ref:t,"data-state":aa(a.checked)})})});Wi.displayName=Vi;var Gi=`MenuSeparator`,Ki=B.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,H.jsx)(b.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});Ki.displayName=Gi;var qi=`MenuArrow`,Ji=B.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=ai(n);return(0,H.jsx)(ne,{...i,...r,ref:t})});Ji.displayName=qi;var Yi=`MenuSub`,[Xi,Zi]=ri(Yi),Qi=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=ci(Yi,t),o=ai(t),[s,c]=B.useState(null),[l,u]=B.useState(null),d=F(i);return B.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,H.jsx)(te,{...o,children:(0,H.jsx)(si,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,H.jsx)(Xi,{scope:t,contentId:j(),triggerId:j(),trigger:s,onTriggerChange:c,children:n})})})};Qi.displayName=Yi;var $i=`MenuSubTrigger`,ea=B.forwardRef((e,t)=>{let n=ci($i,e.__scopeMenu),r=ui($i,e.__scopeMenu),i=Zi($i,e.__scopeMenu),a=bi($i,e.__scopeMenu),o=B.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=B.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return B.useEffect(()=>u,[u]),B.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]),(0,H.jsx)(pi,{asChild:!0,...l,children:(0,H.jsx)(Mi,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":ra(n.open),...e,ref:C(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:L(e.onPointerMove,da(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:L(e.onPointerLeave,da(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:L(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||Zr[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});ea.displayName=$i;var ta=`MenuSubContent`,na=B.forwardRef((e,t)=>{let n=gi(vi,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=ci(vi,e.__scopeMenu),o=ui(vi,e.__scopeMenu),s=Zi(ta,e.__scopeMenu),c=B.useRef(null),l=M(t,c);return(0,H.jsx)(ei.Provider,{scope:e.__scopeMenu,children:(0,H.jsx)(A,{present:r||a.open,children:(0,H.jsx)(ei.Slot,{scope:e.__scopeMenu,children:(0,H.jsx)(Ti,{id:s.contentId,"aria-labelledby":s.triggerId,...i,ref:l,align:`start`,side:o.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{o.isUsingKeyboardRef.current&&c.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:L(e.onFocusOutside,e=>{e.target!==s.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:L(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:L(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=Qr[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});na.displayName=ta;function ra(e){return e?`open`:`closed`}function ia(e){return e===`indeterminate`}function aa(e){return ia(e)?`indeterminate`:e?`checked`:`unchecked`}function oa(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function sa(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function ca(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=sa(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function la(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function ua(e,t){return t?la({x:e.clientX,y:e.clientY},t):!1}function da(e){return t=>t.pointerType===`mouse`?e(t):void 0}var fa=di,pa=pi,ma=_i,ha=xi,ga=Di,_a=ki,va=ji,ya=Pi,ba=Ri,xa=Bi,Sa=Wi,Ca=Ki,wa=Ji,Ta=Qi,Ea=ea,Da=na,Oa=`ContextMenu`,[ka,Aa]=w(Oa,[ii]),ja=ii(),[Ma,Na]=ka(Oa),Pa=e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,dir:i,modal:a=!0}=e,[o,s]=B.useState(!1),c=ja(t),l=F(r),u=B.useCallback(e=>{s(e),l(e)},[l]);return(0,H.jsx)(Ma,{scope:t,open:o,onOpenChange:u,modal:a,children:(0,H.jsx)(fa,{...c,dir:i,open:o,onOpenChange:u,modal:a,children:n})})};Pa.displayName=Oa;var Fa=`ContextMenuTrigger`,Ia=B.forwardRef((e,t)=>{let{__scopeContextMenu:n,disabled:r=!1,...i}=e,a=Na(Fa,n),o=ja(n),s=B.useRef({x:0,y:0}),c=B.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...s.current})}),l=B.useRef(0),u=B.useCallback(()=>window.clearTimeout(l.current),[]),d=e=>{s.current={x:e.clientX,y:e.clientY},a.onOpenChange(!0)};return B.useEffect(()=>u,[u]),B.useEffect(()=>void(r&&u()),[r,u]),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(pa,{...o,virtualRef:c}),(0,H.jsx)(b.span,{"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,...i,ref:t,style:{WebkitTouchCallout:`none`,...e.style},onContextMenu:r?e.onContextMenu:L(e.onContextMenu,e=>{u(),d(e),e.preventDefault()}),onPointerDown:r?e.onPointerDown:L(e.onPointerDown,uo(e=>{u(),l.current=window.setTimeout(()=>d(e),700)})),onPointerMove:r?e.onPointerMove:L(e.onPointerMove,uo(u)),onPointerCancel:r?e.onPointerCancel:L(e.onPointerCancel,uo(u)),onPointerUp:r?e.onPointerUp:L(e.onPointerUp,uo(u))})]})});Ia.displayName=Fa;var La=`ContextMenuPortal`,Ra=e=>{let{__scopeContextMenu:t,...n}=e,r=ja(t);return(0,H.jsx)(ma,{...r,...n})};Ra.displayName=La;var za=`ContextMenuContent`,Ba=B.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=Na(za,n),a=ja(n),o=B.useRef(!1);return(0,H.jsx)(ha,{...a,...r,ref:t,side:`right`,sideOffset:2,align:`start`,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),!t.defaultPrevented&&o.current&&t.preventDefault(),o.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),!t.defaultPrevented&&!i.modal&&(o.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Ba.displayName=za;var Va=`ContextMenuGroup`,Ha=B.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ja(n);return(0,H.jsx)(ga,{...i,...r,ref:t})});Ha.displayName=Va;var Ua=`ContextMenuLabel`,Wa=B.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ja(n);return(0,H.jsx)(_a,{...i,...r,ref:t})});Wa.displayName=Ua;var Ga=`ContextMenuItem`,Ka=B.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ja(n);return(0,H.jsx)(va,{...i,...r,ref:t})});Ka.displayName=Ga;var qa=`ContextMenuCheckboxItem`,Ja=B.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ja(n);return(0,H.jsx)(ya,{...i,...r,ref:t})});Ja.displayName=qa;var Ya=`ContextMenuRadioGroup`,Xa=B.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ja(n);return(0,H.jsx)(ba,{...i,...r,ref:t})});Xa.displayName=Ya;var Za=`ContextMenuRadioItem`,Qa=B.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ja(n);return(0,H.jsx)(xa,{...i,...r,ref:t})});Qa.displayName=Za;var $a=`ContextMenuItemIndicator`,eo=B.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ja(n);return(0,H.jsx)(Sa,{...i,...r,ref:t})});eo.displayName=$a;var to=`ContextMenuSeparator`,no=B.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ja(n);return(0,H.jsx)(Ca,{...i,...r,ref:t})});no.displayName=to;var ro=`ContextMenuArrow`,io=B.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ja(n);return(0,H.jsx)(wa,{...i,...r,ref:t})});io.displayName=ro;var ao=`ContextMenuSub`,oo=e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,open:i,defaultOpen:a}=e,o=ja(t),[s,c]=T({prop:i,defaultProp:a??!1,onChange:r,caller:ao});return(0,H.jsx)(Ta,{...o,open:s,onOpenChange:c,children:n})};oo.displayName=ao;var so=`ContextMenuSubTrigger`,co=B.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ja(n);return(0,H.jsx)(Ea,{...i,...r,ref:t})});co.displayName=so;var W=`ContextMenuSubContent`,lo=B.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ja(n);return(0,H.jsx)(Da,{...i,...r,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});lo.displayName=W;function uo(e){return t=>t.pointerType===`mouse`?void 0:e(t)}var fo=Pa,po=Ia,mo=Ra,ho=Ba,go=Ka,_o=no,vo=`DropdownMenu`,[yo,bo]=w(vo,[ii]),xo=ii(),[So,Co]=yo(vo),wo=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=xo(t),l=B.useRef(null),[u,d]=T({prop:i,defaultProp:a??!1,onChange:o,caller:vo});return(0,H.jsx)(So,{scope:t,triggerId:j(),triggerRef:l,contentId:j(),open:u,onOpenChange:d,onOpenToggle:B.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,H.jsx)(fa,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};wo.displayName=vo;var To=`DropdownMenuTrigger`,Eo=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=Co(To,n),o=xo(n);return(0,H.jsx)(pa,{asChild:!0,...o,children:(0,H.jsx)(b.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:C(t,a.triggerRef),onPointerDown:L(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:L(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});Eo.displayName=To;var Do=`DropdownMenuPortal`,Oo=e=>{let{__scopeDropdownMenu:t,...n}=e,r=xo(t);return(0,H.jsx)(ma,{...r,...n})};Oo.displayName=Do;var ko=`DropdownMenuContent`,Ao=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Co(ko,n),a=xo(n),o=B.useRef(!1);return(0,H.jsx)(ha,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:L(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:L(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Ao.displayName=ko;var jo=`DropdownMenuGroup`,Mo=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=xo(n);return(0,H.jsx)(ga,{...i,...r,ref:t})});Mo.displayName=jo;var No=`DropdownMenuLabel`,Po=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=xo(n);return(0,H.jsx)(_a,{...i,...r,ref:t})});Po.displayName=No;var Fo=`DropdownMenuItem`,Io=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=xo(n);return(0,H.jsx)(va,{...i,...r,ref:t})});Io.displayName=Fo;var Lo=`DropdownMenuCheckboxItem`,Ro=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=xo(n);return(0,H.jsx)(ya,{...i,...r,ref:t})});Ro.displayName=Lo;var zo=`DropdownMenuRadioGroup`,Bo=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=xo(n);return(0,H.jsx)(ba,{...i,...r,ref:t})});Bo.displayName=zo;var Vo=`DropdownMenuRadioItem`,Ho=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=xo(n);return(0,H.jsx)(xa,{...i,...r,ref:t})});Ho.displayName=Vo;var Uo=`DropdownMenuItemIndicator`,Wo=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=xo(n);return(0,H.jsx)(Sa,{...i,...r,ref:t})});Wo.displayName=Uo;var Go=`DropdownMenuSeparator`,Ko=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=xo(n);return(0,H.jsx)(Ca,{...i,...r,ref:t})});Ko.displayName=Go;var qo=`DropdownMenuArrow`,Jo=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=xo(n);return(0,H.jsx)(wa,{...i,...r,ref:t})});Jo.displayName=qo;var Yo=e=>{let{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:a}=e,o=xo(t),[s,c]=T({prop:r,defaultProp:a??!1,onChange:i,caller:`DropdownMenuSub`});return(0,H.jsx)(Ta,{...o,open:s,onOpenChange:c,children:n})},Xo=`DropdownMenuSubTrigger`,Zo=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=xo(n);return(0,H.jsx)(Ea,{...i,...r,ref:t})});Zo.displayName=Xo;var Qo=`DropdownMenuSubContent`,$o=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=xo(n);return(0,H.jsx)(Da,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});$o.displayName=Qo;var es=wo,ts=Eo,ns=Oo,rs=Ao,is=Io,as=Yo,os=Zo,ss=$o,cs=`Label`,ls=B.forwardRef((e,t)=>(0,H.jsx)(b.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));ls.displayName=cs;var us=ls;function ds(e,[t,n]){return Math.min(n,Math.max(t,e))}function fs(e,t){return B.useReducer((e,n)=>t[e][n]??e,e)}var ps=`ScrollArea`,[ms,hs]=w(ps),[gs,_s]=ms(ps),vs=B.forwardRef((e,t)=>{let{__scopeScrollArea:n,type:r=`hover`,dir:i,scrollHideDelay:a=600,...o}=e,[s,c]=B.useState(null),[l,u]=B.useState(null),[d,f]=B.useState(null),[p,m]=B.useState(null),[h,g]=B.useState(null),[_,v]=B.useState(0),[y,x]=B.useState(0),[S,C]=B.useState(!1),[w,T]=B.useState(!1),E=M(t,e=>c(e)),D=P(i);return(0,H.jsx)(gs,{scope:n,type:r,dir:D,scrollHideDelay:a,scrollArea:s,viewport:l,onViewportChange:u,content:d,onContentChange:f,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:S,onScrollbarXEnabledChange:C,scrollbarY:h,onScrollbarYChange:g,scrollbarYEnabled:w,onScrollbarYEnabledChange:T,onCornerWidthChange:v,onCornerHeightChange:x,children:(0,H.jsx)(b.div,{dir:D,...o,ref:E,style:{position:`relative`,"--radix-scroll-area-corner-width":_+`px`,"--radix-scroll-area-corner-height":y+`px`,...e.style}})})});vs.displayName=ps;var ys=`ScrollAreaViewport`,bs=B.forwardRef((e,t)=>{let{__scopeScrollArea:n,children:r,nonce:i,...a}=e,o=_s(ys,n),s=M(t,B.useRef(null),o.onViewportChange);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}`},nonce:i}),(0,H.jsx)(b.div,{"data-radix-scroll-area-viewport":``,...a,ref:s,style:{overflowX:o.scrollbarXEnabled?`scroll`:`hidden`,overflowY:o.scrollbarYEnabled?`scroll`:`hidden`,...e.style},children:(0,H.jsx)(`div`,{ref:o.onContentChange,style:{minWidth:`100%`,display:`table`},children:r})})]})});bs.displayName=ys;var xs=`ScrollAreaScrollbar`,Ss=B.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=_s(xs,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=i,s=e.orientation===`horizontal`;return B.useEffect(()=>(s?a(!0):o(!0),()=>{s?a(!1):o(!1)}),[s,a,o]),i.type===`hover`?(0,H.jsx)(Cs,{...r,ref:t,forceMount:n}):i.type===`scroll`?(0,H.jsx)(ws,{...r,ref:t,forceMount:n}):i.type===`auto`?(0,H.jsx)(Ts,{...r,ref:t,forceMount:n}):i.type===`always`?(0,H.jsx)(Es,{...r,ref:t}):null});Ss.displayName=xs;var Cs=B.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=_s(xs,e.__scopeScrollArea),[a,o]=B.useState(!1);return B.useEffect(()=>{let e=i.scrollArea,t=0;if(e){let n=()=>{window.clearTimeout(t),o(!0)},r=()=>{t=window.setTimeout(()=>o(!1),i.scrollHideDelay)};return e.addEventListener(`pointerenter`,n),e.addEventListener(`pointerleave`,r),()=>{window.clearTimeout(t),e.removeEventListener(`pointerenter`,n),e.removeEventListener(`pointerleave`,r)}}},[i.scrollArea,i.scrollHideDelay]),(0,H.jsx)(A,{present:n||a,children:(0,H.jsx)(Ts,{"data-state":a?`visible`:`hidden`,...r,ref:t})})}),ws=B.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=_s(xs,e.__scopeScrollArea),a=e.orientation===`horizontal`,o=Ks(()=>c(`SCROLL_END`),100),[s,c]=fs(`hidden`,{hidden:{SCROLL:`scrolling`},scrolling:{SCROLL_END:`idle`,POINTER_ENTER:`interacting`},interacting:{SCROLL:`interacting`,POINTER_LEAVE:`idle`},idle:{HIDE:`hidden`,SCROLL:`scrolling`,POINTER_ENTER:`interacting`}});return B.useEffect(()=>{if(s===`idle`){let e=window.setTimeout(()=>c(`HIDE`),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[s,i.scrollHideDelay,c]),B.useEffect(()=>{let e=i.viewport,t=a?`scrollLeft`:`scrollTop`;if(e){let n=e[t],r=()=>{let r=e[t];n!==r&&(c(`SCROLL`),o()),n=r};return e.addEventListener(`scroll`,r),()=>e.removeEventListener(`scroll`,r)}},[i.viewport,a,c,o]),(0,H.jsx)(A,{present:n||s!==`hidden`,children:(0,H.jsx)(Es,{"data-state":s===`hidden`?`hidden`:`visible`,...r,ref:t,onPointerEnter:L(e.onPointerEnter,()=>c(`POINTER_ENTER`)),onPointerLeave:L(e.onPointerLeave,()=>c(`POINTER_LEAVE`))})})}),Ts=B.forwardRef((e,t)=>{let n=_s(xs,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,o]=B.useState(!1),s=e.orientation===`horizontal`,c=Ks(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(s?e:t)}},10);return qs(n.viewport,c),qs(n.content,c),(0,H.jsx)(A,{present:r||a,children:(0,H.jsx)(Es,{"data-state":a?`visible`:`hidden`,...i,ref:t})})}),Es=B.forwardRef((e,t)=>{let{orientation:n=`vertical`,...r}=e,i=_s(xs,e.__scopeScrollArea),a=B.useRef(null),o=B.useRef(0),[s,c]=B.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=zs(s.viewport,s.content),u={...r,sizes:s,onSizesChange:c,hasThumb:l>0&&l<1,onThumbChange:e=>a.current=e,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:e=>o.current=e};function d(e,t){return Vs(e,o.current,s,t)}return n===`horizontal`?(0,H.jsx)(Ds,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=Hs(e,s,i.dir);a.current.style.transform=`translate3d(${t}px, 0, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollLeft=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollLeft=d(e,i.dir))}}):n===`vertical`?(0,H.jsx)(Os,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=Hs(e,s);a.current.style.transform=`translate3d(0, ${t}px, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollTop=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollTop=d(e))}}):null}),Ds=B.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=_s(xs,e.__scopeScrollArea),[o,s]=B.useState(),c=B.useRef(null),l=M(t,c,a.onScrollbarXChange);return B.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,H.jsx)(js,{"data-orientation":`horizontal`,...i,ref:l,sizes:n,style:{bottom:0,left:a.dir===`rtl`?`var(--radix-scroll-area-corner-width)`:0,right:a.dir===`ltr`?`var(--radix-scroll-area-corner-width)`:0,"--radix-scroll-area-thumb-width":Bs(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),Ws(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Rs(o.paddingLeft),paddingEnd:Rs(o.paddingRight)}})}})}),Os=B.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=_s(xs,e.__scopeScrollArea),[o,s]=B.useState(),c=B.useRef(null),l=M(t,c,a.onScrollbarYChange);return B.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,H.jsx)(js,{"data-orientation":`vertical`,...i,ref:l,sizes:n,style:{top:0,right:a.dir===`ltr`?0:void 0,left:a.dir===`rtl`?0:void 0,bottom:`var(--radix-scroll-area-corner-height)`,"--radix-scroll-area-thumb-height":Bs(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),Ws(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Rs(o.paddingTop),paddingEnd:Rs(o.paddingBottom)}})}})}),[ks,As]=ms(xs),js=B.forwardRef((e,t)=>{let{__scopeScrollArea:n,sizes:r,hasThumb:i,onThumbChange:a,onThumbPointerUp:o,onThumbPointerDown:s,onThumbPositionChange:c,onDragScroll:l,onWheelScroll:u,onResize:d,...f}=e,p=_s(xs,n),[m,h]=B.useState(null),g=M(t,e=>h(e)),_=B.useRef(null),v=B.useRef(``),y=p.viewport,x=r.content-r.viewport,S=F(u),C=F(c),w=Ks(d,10);function T(e){_.current&&l({x:e.clientX-_.current.left,y:e.clientY-_.current.top})}return B.useEffect(()=>{let e=e=>{let t=e.target;m?.contains(t)&&S(e,x)};return document.addEventListener(`wheel`,e,{passive:!1}),()=>document.removeEventListener(`wheel`,e,{passive:!1})},[y,m,x,S]),B.useEffect(C,[r,C]),qs(m,w),qs(p.content,w),(0,H.jsx)(ks,{scope:n,scrollbar:m,hasThumb:i,onThumbChange:F(a),onThumbPointerUp:F(o),onThumbPositionChange:C,onThumbPointerDown:F(s),children:(0,H.jsx)(b.div,{...f,ref:g,style:{position:`absolute`,...f.style},onPointerDown:L(e.onPointerDown,e=>{e.button===0&&(e.target.setPointerCapture(e.pointerId),_.current=m.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect=`none`,p.viewport&&(p.viewport.style.scrollBehavior=`auto`),T(e))}),onPointerMove:L(e.onPointerMove,T),onPointerUp:L(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=v.current,p.viewport&&(p.viewport.style.scrollBehavior=``),_.current=null})})})}),Ms=`ScrollAreaThumb`,Ns=B.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=As(Ms,e.__scopeScrollArea);return(0,H.jsx)(A,{present:n||i.hasThumb,children:(0,H.jsx)(Ps,{ref:t,...r})})}),Ps=B.forwardRef((e,t)=>{let{__scopeScrollArea:n,style:r,...i}=e,a=_s(Ms,n),o=As(Ms,n),{onThumbPositionChange:s}=o,c=M(t,e=>o.onThumbChange(e)),l=B.useRef(void 0),u=Ks(()=>{l.current&&=(l.current(),void 0)},100);return B.useEffect(()=>{let e=a.viewport;if(e){let t=()=>{u(),l.current||(l.current=Gs(e,s),s())};return s(),e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)}},[a.viewport,u,s]),(0,H.jsx)(b.div,{"data-state":o.hasThumb?`visible`:`hidden`,...i,ref:c,style:{width:`var(--radix-scroll-area-thumb-width)`,height:`var(--radix-scroll-area-thumb-height)`,...r},onPointerDownCapture:L(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;o.onThumbPointerDown({x:n,y:r})}),onPointerUp:L(e.onPointerUp,o.onThumbPointerUp)})});Ns.displayName=Ms;var Fs=`ScrollAreaCorner`,Is=B.forwardRef((e,t)=>{let n=_s(Fs,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,H.jsx)(Ls,{...e,ref:t}):null});Is.displayName=Fs;var Ls=B.forwardRef((e,t)=>{let{__scopeScrollArea:n,...r}=e,i=_s(Fs,n),[a,o]=B.useState(0),[s,c]=B.useState(0),l=!!(a&&s);return qs(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),c(e)}),qs(i.scrollbarY,()=>{let e=i.scrollbarY?.offsetWidth||0;i.onCornerWidthChange(e),o(e)}),l?(0,H.jsx)(b.div,{...r,ref:t,style:{width:a,height:s,position:`absolute`,right:i.dir===`ltr`?0:void 0,left:i.dir===`rtl`?0:void 0,bottom:0,...e.style}}):null});function Rs(e){return e?parseInt(e,10):0}function zs(e,t){let n=e/t;return isNaN(n)?0:n}function Bs(e){let t=zs(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Vs(e,t,n,r=`ltr`){let i=Bs(n),a=i/2,o=t||a,s=i-o,c=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-s,u=n.content-n.viewport,d=r===`ltr`?[0,u]:[u*-1,0];return Us([c,l],d)(e)}function Hs(e,t,n=`ltr`){let r=Bs(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=ds(e,n===`ltr`?[0,o]:[o*-1,0]);return Us([0,o],[0,s])(c)}function Us(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Ws(e,t){return e>0&&e<t}var Gs=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return(function i(){let a={left:e.scrollLeft,top:e.scrollTop},o=n.left!==a.left,s=n.top!==a.top;(o||s)&&t(),n=a,r=window.requestAnimationFrame(i)})(),()=>window.cancelAnimationFrame(r)};function Ks(e,t){let n=F(e),r=B.useRef(0);return B.useEffect(()=>()=>window.clearTimeout(r.current),[]),B.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function qs(e,t){let n=F(t);se(()=>{let t=0;if(e){let r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}var Js=vs,Ys=bs,Xs=Is,Zs=[` `,`Enter`,`ArrowUp`,`ArrowDown`],Qs=[` `,`Enter`],$s=`Select`,[ec,tc,nc]=D($s),[rc,ic]=w($s,[nc,E]),ac=E(),[oc,sc]=rc($s),[cc,lc]=rc($s),uc=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m}=e,h=ac(t),[g,_]=B.useState(null),[v,y]=B.useState(null),[b,x]=B.useState(!1),S=P(l),[C,w]=T({prop:r,defaultProp:i??!1,onChange:a,caller:$s}),[E,D]=T({prop:o,defaultProp:s,onChange:c,caller:$s}),O=B.useRef(null),ee=g?m||!!g.closest(`form`):!0,[k,A]=B.useState(new Set),M=Array.from(k).map(e=>e.props.value).join(`;`);return(0,H.jsx)(te,{...h,children:(0,H.jsxs)(oc,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:x,contentId:j(),value:E,onValueChange:D,open:C,onOpenChange:w,dir:S,triggerPointerDownPosRef:O,disabled:f,children:[(0,H.jsx)(ec.Provider,{scope:t,children:(0,H.jsx)(cc,{scope:e.__scopeSelect,onNativeOptionAdd:B.useCallback(e=>{A(t=>new Set(t).add(e))},[]),onNativeOptionRemove:B.useCallback(e=>{A(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),ee?(0,H.jsxs)(al,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:E,onChange:e=>D(e.target.value),disabled:f,form:m,children:[E===void 0?(0,H.jsx)(`option`,{value:``}):null,Array.from(k)]},M):null]})})};uc.displayName=$s;var dc=`SelectTrigger`,fc=B.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=ac(n),o=sc(dc,n),s=o.disabled||r,c=M(t,o.onTriggerChange),l=tc(n),u=B.useRef(`touch`),[d,f,p]=sl(e=>{let t=l().filter(e=>!e.disabled),n=cl(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,H.jsx)(I,{asChild:!0,...a,children:(0,H.jsx)(b.button,{type:`button`,role:`combobox`,"aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":ol(o.value)?``:void 0,...i,ref:c,onClick:L(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:L(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:L(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&Zs.includes(e.key)&&(m(),e.preventDefault())})})})});fc.displayName=dc;var pc=`SelectValue`,mc=B.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=sc(pc,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=M(t,c.onValueNodeChange);return se(()=>{l(u)},[l,u]),(0,H.jsx)(b.span,{...s,ref:d,style:{pointerEvents:`none`},children:ol(c.value)?(0,H.jsx)(H.Fragment,{children:o}):a})});mc.displayName=pc;var hc=`SelectIcon`,gc=B.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,H.jsx)(b.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});gc.displayName=hc;var _c=`SelectPortal`,vc=e=>(0,H.jsx)(oe,{asChild:!0,...e});vc.displayName=_c;var yc=`SelectContent`,bc=B.forwardRef((e,t)=>{let n=sc(yc,e.__scopeSelect),[r,i]=B.useState();if(se(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?Yt.createPortal((0,H.jsx)(Sc,{scope:e.__scopeSelect,children:(0,H.jsx)(ec.Slot,{scope:e.__scopeSelect,children:(0,H.jsx)(`div`,{children:e.children})})}),t):null}return(0,H.jsx)(Ec,{...e,ref:t})});bc.displayName=yc;var xc=10,[Sc,Cc]=rc(yc),wc=`SelectContentImpl`,Tc=S(`SelectContent.RemoveScroll`),Ec=B.forwardRef((e,t)=>{let{__scopeSelect:n,position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=sc(yc,n),[y,b]=B.useState(null),[x,S]=B.useState(null),C=M(t,e=>b(e)),[w,T]=B.useState(null),[E,D]=B.useState(null),A=tc(n),[j,te]=B.useState(!1),P=B.useRef(!1);B.useEffect(()=>{if(y)return ae(y)},[y]),N();let ne=B.useCallback(e=>{let[t,...n]=A().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[A,x]),re=B.useCallback(()=>ne([w,y]),[ne,w,y]);B.useEffect(()=>{j&&re()},[j,re]);let{onOpenChange:F,triggerPointerDownPosRef:ie}=v;B.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(ie.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(ie.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():y.contains(n.target)||F(!1),document.removeEventListener(`pointermove`,t),ie.current=null};return ie.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,F,ie]),B.useEffect(()=>{let e=()=>F(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[F]);let[I,oe]=sl(e=>{let t=A().filter(e=>!e.disabled),n=cl(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),se=B.useCallback((e,t,n)=>{let r=!P.current&&!n;(v.value!==void 0&&v.value===t||r)&&(T(e),r&&(P.current=!0))},[v.value]),ce=B.useCallback(()=>y?.focus(),[y]),le=B.useCallback((e,t,n)=>{let r=!P.current&&!n;(v.value!==void 0&&v.value===t||r)&&D(e)},[v.value]),R=r===`popper`?Ac:Oc,ue=R===Ac?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,H.jsx)(Sc,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:se,selectedItem:w,onItemLeave:ce,itemTextRefCallback:le,focusSelectedItem:re,selectedItemText:E,position:r,isPositioned:j,searchRef:I,children:(0,H.jsx)(O,{as:Tc,allowPinchZoom:!0,children:(0,H.jsx)(ee,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:L(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,H.jsx)(k,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,H.jsx)(R,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...ue,onPlaced:()=>te(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:L(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&oe(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=A().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>ne(t)),e.preventDefault()}})})})})})})});Ec.displayName=wc;var Dc=`SelectItemAlignedPosition`,Oc=B.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=sc(yc,n),o=Cc(yc,n),[s,c]=B.useState(null),[l,u]=B.useState(null),d=M(t,e=>u(e)),f=tc(n),p=B.useRef(!1),m=B.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=B.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-xc,d=ds(a,[xc,Math.max(xc,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-xc,d=ds(a,[xc,Math.max(xc,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-xc*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-xc,D=c-E,O=g.offsetHeight/2,ee=g.offsetTop+O,k=m+v+ee,A=x-k;if(k<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=k+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+A;s.style.height=t+`px`,h.scrollTop=k-E+h.offsetTop}s.style.margin=`${xc}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);se(()=>y(),[y]);let[x,S]=B.useState();return se(()=>{l&&S(window.getComputedStyle(l).zIndex)},[l]),(0,H.jsx)(jc,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:B.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]),children:(0,H.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:x},children:(0,H.jsx)(b.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});Oc.displayName=Dc;var kc=`SelectPopperPosition`,Ac=B.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=xc,...a}=e,o=ac(n);return(0,H.jsx)(ie,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});Ac.displayName=kc;var[jc,Mc]=rc(yc,{}),Nc=`SelectViewport`,Pc=B.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=Cc(Nc,n),o=Mc(Nc,n),s=M(t,a.onViewportChange),c=B.useRef(0);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,H.jsx)(ec.Slot,{scope:n,children:(0,H.jsx)(b.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:L(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-xc*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});Pc.displayName=Nc;var Fc=`SelectGroup`,[Ic,Lc]=rc(Fc),Rc=B.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=j();return(0,H.jsx)(Ic,{scope:n,id:i,children:(0,H.jsx)(b.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});Rc.displayName=Fc;var zc=`SelectLabel`,Bc=B.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Lc(zc,n);return(0,H.jsx)(b.div,{id:i.id,...r,ref:t})});Bc.displayName=zc;var Vc=`SelectItem`,[Hc,Uc]=rc(Vc),Wc=B.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=sc(Vc,n),c=Cc(Vc,n),l=s.value===r,[u,d]=B.useState(a??``),[f,p]=B.useState(!1),m=M(t,e=>c.itemRefCallback?.(e,r,i)),h=j(),g=B.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};if(r===``)throw Error(`A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,H.jsx)(Hc,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:B.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,H.jsx)(ec.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,H.jsx)(b.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:L(o.onFocus,()=>p(!0)),onBlur:L(o.onBlur,()=>p(!1)),onClick:L(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:L(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:L(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:L(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:L(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:L(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(Qs.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});Wc.displayName=Vc;var Gc=`SelectItemText`,Kc=B.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=sc(Gc,n),s=Cc(Gc,n),c=Uc(Gc,n),l=lc(Gc,n),[u,d]=B.useState(null),f=M(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=B.useMemo(()=>(0,H.jsx)(`option`,{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:g}=l;return se(()=>(h(m),()=>g(m)),[h,g,m]),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(b.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Yt.createPortal(a.children,o.valueNode):null]})});Kc.displayName=Gc;var qc=`SelectItemIndicator`,Jc=B.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return Uc(qc,n).isSelected?(0,H.jsx)(b.span,{"aria-hidden":!0,...r,ref:t}):null});Jc.displayName=qc;var Yc=`SelectScrollUpButton`,Xc=B.forwardRef((e,t)=>{let n=Cc(Yc,e.__scopeSelect),r=Mc(Yc,e.__scopeSelect),[i,a]=B.useState(!1),o=M(t,r.onScrollButtonChange);return se(()=>{if(n.viewport&&n.isPositioned){let e=function(){a(t.scrollTop>0)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,H.jsx)($c,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});Xc.displayName=Yc;var Zc=`SelectScrollDownButton`,Qc=B.forwardRef((e,t)=>{let n=Cc(Zc,e.__scopeSelect),r=Mc(Zc,e.__scopeSelect),[i,a]=B.useState(!1),o=M(t,r.onScrollButtonChange);return se(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight;a(Math.ceil(t.scrollTop)<e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,H.jsx)($c,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});Qc.displayName=Zc;var $c=B.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=Cc(`SelectScrollButton`,n),o=B.useRef(null),s=tc(n),c=B.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return B.useEffect(()=>()=>c(),[c]),se(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,H.jsx)(b.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:L(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:L(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:L(i.onPointerLeave,()=>{c()})})}),el=`SelectSeparator`,tl=B.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,H.jsx)(b.div,{"aria-hidden":!0,...r,ref:t})});tl.displayName=el;var nl=`SelectArrow`,rl=B.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=ac(n),a=sc(nl,n),o=Cc(nl,n);return a.open&&o.position===`popper`?(0,H.jsx)(ne,{...i,...r,ref:t}):null});rl.displayName=nl;var il=`SelectBubbleInput`,al=B.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=B.useRef(null),a=M(r,i),o=Tr(t);return B.useEffect(()=>{let e=i.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(o!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[o,t]),(0,H.jsx)(b.select,{...n,style:{...Pn,...n.style},ref:a,defaultValue:t})});al.displayName=il;function ol(e){return e===``||e===void 0}function sl(e){let t=F(e),n=B.useRef(``),r=B.useRef(0),i=B.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=B.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return B.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function cl(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=ll(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function ll(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var ul=uc,dl=fc,fl=mc,pl=gc,ml=vc,hl=bc,gl=Pc,_l=Wc,vl=Kc,yl=Jc,bl=Xc,xl=Qc,Sl=`Separator`,Cl=`horizontal`,wl=[`horizontal`,`vertical`],Tl=B.forwardRef((e,t)=>{let{decorative:n,orientation:r=Cl,...i}=e,a=El(r)?r:Cl,o=a===`vertical`?a:void 0,s=n?{role:`none`}:{"aria-orientation":o,role:`separator`};return(0,H.jsx)(b.div,{"data-orientation":a,...s,...i,ref:t})});Tl.displayName=Sl;function El(e){return wl.includes(e)}var Dl=Tl,Ol=`Switch`,[kl,Al]=w(Ol),[jl,Ml]=kl(Ol),Nl=B.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c=`on`,onCheckedChange:l,form:u,...d}=e,[f,p]=B.useState(null),m=M(t,e=>p(e)),h=B.useRef(!1),g=f?u||!!f.closest(`form`):!0,[_,v]=T({prop:i,defaultProp:a??!1,onChange:l,caller:Ol});return(0,H.jsxs)(jl,{scope:n,checked:_,disabled:s,children:[(0,H.jsx)(b.button,{type:`button`,role:`switch`,"aria-checked":_,"aria-required":o,"data-state":Rl(_),"data-disabled":s?``:void 0,disabled:s,value:c,...d,ref:m,onClick:L(e.onClick,e=>{v(e=>!e),g&&(h.current=e.isPropagationStopped(),h.current||e.stopPropagation())})}),g&&(0,H.jsx)(Ll,{control:f,bubbles:!h.current,name:r,value:c,checked:_,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`}})]})});Nl.displayName=Ol;var Pl=`SwitchThumb`,Fl=B.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=Ml(Pl,n);return(0,H.jsx)(b.span,{"data-state":Rl(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});Fl.displayName=Pl;var Il=`SwitchBubbleInput`,Ll=B.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=B.useRef(null),s=M(o,a),c=Tr(n),l=re(t);return B.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(c!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[c,n,r]),(0,H.jsx)(`input`,{type:`checkbox`,"aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...l,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});Ll.displayName=Il;function Rl(e){return e?`checked`:`unchecked`}var zl=Nl,G=Fl,[K,q]=w(`Tooltip`,[E]),J=E(),Y=`TooltipProvider`,Bl=700,Vl=`tooltip.open`,[Hl,Ul]=K(Y),Wl=e=>{let{__scopeTooltip:t,delayDuration:n=Bl,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=B.useRef(!0),s=B.useRef(!1),c=B.useRef(0);return B.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,H.jsx)(Hl,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:B.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:B.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:B.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};Wl.displayName=Y;var Gl=`Tooltip`,[Kl,ql]=K(Gl),Jl=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=Ul(Gl,e.__scopeTooltip),l=J(t),[u,d]=B.useState(null),f=j(),p=B.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=B.useRef(!1),[_,v]=T({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(Vl))):c.onClose(),a?.(e)},caller:Gl}),y=B.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=B.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=B.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=B.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return B.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,H.jsx)(te,{...l,children:(0,H.jsx)(Kl,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:B.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:B.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};Jl.displayName=Gl;var Yl=`TooltipTrigger`,Xl=B.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=ql(Yl,n),a=Ul(Yl,n),o=J(n),s=M(t,B.useRef(null),i.onTriggerChange),c=B.useRef(!1),l=B.useRef(!1),u=B.useCallback(()=>c.current=!1,[]);return B.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,H.jsx)(I,{asChild:!0,...o,children:(0,H.jsx)(b.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:L(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:L(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:L(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:L(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:L(e.onBlur,i.onClose),onClick:L(e.onClick,i.onClose)})})});Xl.displayName=Yl;var Zl=`TooltipPortal`,[Ql,$l]=K(Zl,{forceMount:void 0}),eu=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=ql(Zl,t);return(0,H.jsx)(Ql,{scope:t,forceMount:n,children:(0,H.jsx)(A,{present:n||a.open,children:(0,H.jsx)(oe,{asChild:!0,container:i,children:r})})})};eu.displayName=Zl;var tu=`TooltipContent`,nu=B.forwardRef((e,t)=>{let n=$l(tu,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=ql(tu,e.__scopeTooltip);return(0,H.jsx)(A,{present:r||o.open,children:o.disableHoverableContent?(0,H.jsx)(su,{side:i,...a,ref:t}):(0,H.jsx)(ru,{side:i,...a,ref:t})})}),ru=B.forwardRef((e,t)=>{let n=ql(tu,e.__scopeTooltip),r=Ul(tu,e.__scopeTooltip),i=B.useRef(null),a=M(t,i),[o,s]=B.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=B.useCallback(()=>{s(null),d(!1)},[d]),p=B.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=du(r,uu(r,n.getBoundingClientRect())),a=fu(t.getBoundingClientRect());s(mu([...i,...a])),d(!0)},[d]);return B.useEffect(()=>()=>f(),[f]),B.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),B.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!pu(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,H.jsx)(su,{...e,ref:a})}),[iu,au]=K(Gl,{isInside:!1}),ou=x(`TooltipContent`),su=B.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=ql(tu,n),l=J(n),{onClose:u}=c;return B.useEffect(()=>(document.addEventListener(Vl,u),()=>document.removeEventListener(Vl,u)),[u]),B.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,H.jsx)(k,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,H.jsxs)(ie,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,H.jsx)(ou,{children:r}),(0,H.jsx)(iu,{scope:n,isInside:!0,children:(0,H.jsx)(Ln,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});nu.displayName=tu;var cu=`TooltipArrow`,lu=B.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=J(n);return au(cu,n).isInside?null:(0,H.jsx)(ne,{...i,...r,ref:t})});lu.displayName=cu;function uu(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function du(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function fu(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function pu(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function mu(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0),hu(t)}function hu(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var gu=Wl,_u=Jl,vu=Xl,yu=eu,bu=nu,xu=lu;function Su({delayDuration:e=0,...t}){return(0,H.jsx)(gu,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Cu({...e}){return(0,H.jsx)(_u,{"data-slot":`tooltip`,...e})}function wu({...e}){return(0,H.jsx)(vu,{"data-slot":`tooltip-trigger`,...e})}function Tu({className:e,sideOffset:t=0,children:n,...r}){return(0,H.jsx)(yu,{children:(0,H.jsxs)(bu,{"data-slot":`tooltip-content`,sideOffset:t,className:R(`z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-foreground px-3 py-1.5 text-xs text-balance text-background fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95`,e),...r,children:[n,(0,H.jsx)(xu,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground`})]})})}function Eu(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function Du(e,t){let n=getComputedStyle(e.ownerDocument.body);return t*parseFloat(n.fontSize)}function Ou(e){return e/100*window.innerHeight}function ku(e){return e/100*window.innerWidth}function Au(e){switch(typeof e){case`number`:return[e,`px`];case`string`:{let t=parseFloat(e);return e.endsWith(`%`)?[t,`%`]:e.endsWith(`px`)?[t,`px`]:e.endsWith(`rem`)?[t,`rem`]:e.endsWith(`em`)?[t,`em`]:e.endsWith(`vh`)?[t,`vh`]:e.endsWith(`vw`)?[t,`vw`]:[t,`%`]}}}function ju({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=Au(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=Du(t,i);break;case`em`:r=Eu(t,i);break;case`vh`:r=Ou(i);break;case`vw`:r=ku(i);break}return r}function Mu(e){return parseFloat(e.toFixed(3))}function Nu({group:e}){let{orientation:t,panels:n}=e;return n.reduce((e,n)=>(e+=t===`horizontal`?n.element.offsetWidth:n.element.offsetHeight,e),0)}function Pu(e){let{panels:t}=e,n=Nu({group:e});return n===0?t.map(e=>({groupResizeBehavior:e.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:e.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:e.panelConstraints.disabled,minSize:0,maxSize:100,panelId:e.id})):t.map(e=>{let{element:t,panelConstraints:r}=e,i=0;r.collapsedSize!==void 0&&(i=Mu(ju({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=Mu(ju({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=Mu(ju({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=Mu(ju({groupSize:n,panelElement:t,styleProp:r.maxSize})/n*100)),{groupResizeBehavior:r.groupResizeBehavior,collapsedSize:i,collapsible:r.collapsible===!0,defaultSize:a,disabled:r.disabled,minSize:o,maxSize:s,panelId:e.id}})}function X(e,t=`Assertion error`){if(!e)throw Error(t)}function Fu(e,t){return Array.from(t).sort(e===`horizontal`?Iu:Lu)}function Iu(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function Lu(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function Ru(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function zu(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function Bu({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},i,a=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=zu(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return X(i,`No rect found`),i}var Vu;function Hu(){return Vu===void 0&&(Vu=typeof matchMedia==`function`?!!matchMedia(`(pointer:coarse)`).matches:!1),Vu}function Uu(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=Fu(n,Array.from(t.children).filter(Ru).map(e=>({element:e}))).map(({element:e})=>e),o=[],s=!1,c=!1,l=-1,u=-1,d=0,f,p=[];{let e=-1;for(let t of a)t.hasAttribute(`data-panel`)&&(e++,t.ariaDisabled===null&&(d++,l===-1&&(l=e),u=e))}if(d>1){let t=-1;for(let d of a)if(d.hasAttribute(`data-panel`)){t++;let i=r.find(e=>e.element===d);if(i){if(f){let r=f.element.getBoundingClientRect(),a=d.getBoundingClientRect(),m;if(c){let e=n===`horizontal`?new DOMRect(r.right,r.top,0,r.height):new DOMRect(r.left,r.bottom,r.width,0),t=n===`horizontal`?new DOMRect(a.left,a.top,0,a.height):new DOMRect(a.left,a.top,a.width,0);switch(p.length){case 0:m=[e,t];break;case 1:{let i=p[0];m=[i,Bu({orientation:n,rects:[r,a],targetRect:i.element.getBoundingClientRect()})===r?t:e];break}default:m=p;break}}else m=p.length?p:[n===`horizontal`?new DOMRect(r.right,a.top,a.left-r.right,a.height):new DOMRect(a.left,r.bottom,a.width,a.top-r.bottom)];for(let n of m){let r=`width`in n?n:n.element.getBoundingClientRect(),a=Hu()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(r.width<a){let e=a-r.width;r=new DOMRect(r.x-e/2,r.y,r.width+e,r.height)}if(r.height<a){let e=a-r.height;r=new DOMRect(r.x,r.y-e/2,r.width,r.height+e)}!s&&!(t<=l||t>u)&&o.push({group:e,groupSize:Nu({group:e}),panels:[f,i],separator:`width`in n?void 0:n,rect:r}),s=!1}}c=!1,f=i,p=[]}}else if(d.hasAttribute(`data-separator`)){d.ariaDisabled!==null&&(s=!0);let e=i.find(e=>e.element===d);e?p.push(e):(f=void 0,p=[])}else c=!0}return o}var Wu=class{#e={};addListener(e,t){let n=this.#e[e];return n===void 0?this.#e[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#e[e];if(n!==void 0)if(n.length===1)n[0].call(null,t);else{let e=!1,r=null,i=Array.from(n);for(let n=0;n<i.length;n++){let a=i[n];try{a.call(null,t)}catch(t){r===null&&(e=!0,r=t)}}if(e)throw r}}removeAllListeners(){this.#e={}}removeListener(e,t){let n=this.#e[e];if(n!==void 0){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}},Z=new Map,Gu=new Wu;function Ku(e){Z=new Map(Z),Z.delete(e)}function qu(e,t){for(let[t]of Z)if(t.id===e)return t}function Ju(e,t){for(let[t,n]of Z)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Yu(){return Z}function Xu(e,t){return Gu.addListener(`groupChange`,n=>{n.group.id===e&&t(n)})}function Zu(e,t){let n=Z.get(e);Z=new Map(Z),Z.set(e,t),Gu.emit(`groupChange`,{group:e,prev:n,next:t})}function Qu(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=zu(n,a.rect);switch(e){case`horizontal`:t.x<=i.x&&(r=a,i=t);break;case`vertical`:t.y<=i.y&&(r=a,i=t);break}}return r?{distance:i,hitRegion:r}:void 0}function $u(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function ed(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:od(e),b:od(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();X(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:ad(id(n.a)),b:ad(id(n.b))};if(i.a===i.b){let e=r.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let n=e[i];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(i.a-i.b)}var td=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function nd(e){let t=getComputedStyle(sd(e)??e).display;return t===`flex`||t===`inline-flex`}function rd(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||nd(e))||+t.opacity<1||`transform`in t&&t.transform!==`none`||`webkitTransform`in t&&t.webkitTransform!==`none`||`mixBlendMode`in t&&t.mixBlendMode!==`normal`||`filter`in t&&t.filter!==`none`||`webkitFilter`in t&&t.webkitFilter!==`none`||`isolation`in t&&t.isolation===`isolate`||td.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function id(e){let t=e.length;for(;t--;){let n=e[t];if(X(n,`Missing node`),rd(n))return n}return null}function ad(e){return e&&Number(getComputedStyle(e).zIndex)||0}function od(e){let t=[];for(;e;)t.push(e),e=sd(e);return t}function sd(e){let{parentNode:t}=e;return $u(t)?t.host:t}function cd(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function ld({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!Ru(n)||n.contains(e)||e.contains(n))return!0;if(ed(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(cd(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function ud(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=Uu(r),a=Qu(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&ld({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function dd(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function fd(e,t,n=0){return Math.abs(Mu(e)-Mu(t))<=n}function pd(e,t){return fd(e,t)?0:e>t?1:-1}function md({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){let{collapsedSize:i=0,collapsible:a,disabled:o,maxSize:s=100,minSize:c=0}=t;if(o&&!e)return n;if(pd(r,c)<0)if(a){let e=(i+c)/2;r=pd(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=Mu(r),r}function hd({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(fd(e,0))return t;let o=a===`imperative-api`,s=Object.values(t),c=Object.values(i),l=[...s],[u,d]=r;X(u!=null,`Invalid first pivot index`),X(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];X(r,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(X(n!=null,`Previous layout not found for panel index ${t}`),fd(n,i)){let t=o-n;pd(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];X(r,`No panel constraints found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(X(n!=null,`Previous layout not found for panel index ${t}`),fd(n,o)){let t=n-i;pd(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];X(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsible:a,collapsedSize:o,minSize:c}=r;if(a&&pd(i,c)<0)if(e>0){let t=c-o,n=t/2;pd(i+e,c)<0&&(e=pd(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;pd(i-e,c)<0&&(e=pd(100+e,n)>0?0:-t)}break}}{let t=e<0?1:-1,r=e<0?d:u,i=0;for(;;){let e=s[r];X(e!=null,`Previous layout not found for panel index ${r}`);let a=md({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:e,size:100})-e;if(i+=a,r+=t,r<0||r>=n.length)break}let a=Math.min(Math.abs(e),Math.abs(i));e=e<0?0-a:a}{let t=e<0?u:d;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(f),i=s[t];X(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=md({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!fd(i,c)&&(f+=i-c,l[t]=c,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(dd(c,l))return i;{let t=e<0?d:u,r=s[t];X(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=md({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!fd(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];X(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=md({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(fd(i,s)||(t-=s-i,l[r]=s),fd(t,0))break;e>0?r--:r++}}}if(!fd(Object.values(l).reduce((e,t)=>t+e,0),100,.1))return i;let p=Object.keys(i);return l.reduce((e,t,n)=>(e[p[n]]=t,e),{})}function gd(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||pd(e[n],t[n])!==0)return!1;return!0}function _d({layout:e,panelConstraints:t}){let n=Object.values(e),r=[...n],i=r.reduce((e,t)=>e+t,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(e=>`${e}%`).join(`, `)}`);if(!fd(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];X(t!=null,`No layout data found for index ${e}`),r[e]=100/i*t}let a=0;for(let e=0;e<t.length;e++){let i=n[e];X(i!=null,`No layout data found for index ${e}`);let o=r[e];X(o!=null,`No layout data found for index ${e}`);let s=md({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!fd(a,0))for(let e=0;e<t.length;e++){let n=r[e];X(n!=null,`No layout data found for index ${e}`);let i=n+a,o=md({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,fd(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function vd({groupId:e,panelId:t}){let n=()=>{let t=Yu();for(let[n,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:a,groupSize:o,separatorToPanels:s}]of t)if(n.id===e)return{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:n,groupSize:o,layout:a,separatorToPanels:s};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedPanelConstraints.find(e=>e.panelId===t);if(e!==void 0)return e;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{let e=n().group.panels.find(e=>e.id===t);if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},a=()=>{let e=n().layout[t];if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},o=e=>{let r=a();if(e===r)return;let{defaultLayoutDeferred:i,derivedPanelConstraints:o,group:s,groupSize:c,layout:l,separatorToPanels:u}=n(),d=s.panels.findIndex(e=>e.id===t),f=d===s.panels.length-1,p=_d({layout:hd({delta:f?r-e:e-r,initialLayout:l,panelConstraints:o,pivotIndices:f?[d-1,d]:[d,d+1],prevLayout:l,trigger:`imperative-api`}),panelConstraints:o});gd(l,p)||Zu(s,{defaultLayoutDeferred:i,derivedPanelConstraints:o,groupSize:c,layout:p,separatorToPanels:u})};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=i(),s=a();e&&s!==t&&(n.expandToSize=s,o(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:s}=i(),c=a();if(e&&c===t){let e=s.expandToSize??n;e===0&&(e=1),o(e)}},getSize:()=>{let{group:e}=n(),t=a(),{element:r}=i();return{asPercentage:t,inPixels:e.orientation===`horizontal`?r.offsetWidth:r.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=a();return e&&fd(t,n)},resize:e=>{let{group:t}=n(),{element:r}=i(),a=Nu({group:t});o(Mu(ju({groupSize:a,panelElement:r,styleProp:e})/a*100))}}}function yd(e){e.defaultPrevented||ud(e,Yu()).forEach(t=>{if(t.separator){let n=t.panels.find(e=>e.panelConstraints.defaultSize!==void 0);if(n){let r=n.panelConstraints.defaultSize,i=vd({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function Q(e){let t=Yu();for(let[n]of t)if(n.separators.some(t=>t.element===e))return n;throw Error(`Could not find parent Group for separator element`)}function bd({groupId:e}){let t=()=>{let t=Yu();for(let[n,r]of t)if(n.id===e)return{group:n,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{defaultLayoutDeferred:n,derivedPanelConstraints:r,group:i,groupSize:a,layout:o,separatorToPanels:s}=t(),c=_d({layout:e,panelConstraints:r});return n?o:(gd(o,c)||Zu(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:s}),c)}}}function xd(e,t){let n=Q(e),r=Ju(n.id,!0),i=n.separators.find(t=>t.element===e);X(i,`Matching separator not found`);let a=r.separatorToPanels.get(i);X(a,`Matching panels not found`);let o=a.map(e=>n.panels.indexOf(e)),s=bd({groupId:n.id}).getLayout(),c=_d({layout:hd({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});gd(s,c)||Zu(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels})}function Sd(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=Q(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&xd(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&xd(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&xd(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&xd(t,-5);break;case`End`:e.preventDefault(),xd(t,100);break;case`Enter`:{e.preventDefault();let n=Q(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=Ju(n.id,!0),o=n.separators.find(e=>e.element===t);X(o,`Matching separator not found`);let s=a.get(o);X(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.panelId===c.id);if(X(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];xd(t,(l.collapsedSize===e?n.mutableState.expandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=Q(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);X(r!==null,`Index not found`),n[e.shiftKey?r>0?r-1:n.length-1:r+1<n.length?r+1:0].focus({preventScroll:!0});break}case`Home`:e.preventDefault(),xd(t,-100);break}}var Cd={cursorFlags:0,state:`inactive`},wd=new Wu;function Td(){return Cd}function Ed(e){return wd.addListener(`change`,e)}function Dd(e){let t=Cd,n={...Cd};n.cursorFlags=e,Cd=n,wd.emit(`change`,{prev:t,next:n})}function Od(e){let t=Cd;Cd=e,wd.emit(`change`,{prev:t,next:e})}function kd(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=Yu(),n=ud(e,t),r=new Map,i=!1;n.forEach(e=>{e.separator&&(i||(i=!0,e.separator.element.focus({preventScroll:!0})));let n=t.get(e.group);n&&r.set(e.group,n.layout)}),Od({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}),n.length&&e.preventDefault()}var Ad=e=>e,jd=()=>{},Md=1,$=2,Nd=4,Pd=8,Fd=3,Id=12,Ld;function Rd(){return Ld===void 0&&(Ld=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(Ld=!0)),Ld}function zd({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case`active`:case`hover`:t.forEach(e=>{if(!e.mutableState.disableCursor)switch(e.orientation){case`horizontal`:r++;break;case`vertical`:i++;break}})}if(!(r===0&&i===0)){switch(n){case`active`:if(e&&Rd()){let t=(e&Md)!==0,n=(e&$)!==0,r=(e&Nd)!==0,i=(e&Pd)!==0;if(t)return r?`se-resize`:i?`ne-resize`:`e-resize`;if(n)return r?`sw-resize`:i?`nw-resize`:`w-resize`;if(r)return`s-resize`;if(i)return`n-resize`}break}return Rd()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var Bd=new WeakMap;function Vd(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=Bd.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(n));let r=Td();switch(r.state){case`active`:case`hover`:{let e=zd({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(e=>e.group),state:r.state}),i=`*, *:hover {cursor: ${e} !important; }`;if(t===i)return;t=i,e?n.cssRules.length===0?n.insertRule(i):n.replaceSync(i):n.cssRules.length===1&&n.deleteRule(0);break}case`inactive`:t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}Bd.set(e,{prevStyle:t,styleSheet:n})}function Hd({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:a,prevCursorFlags:o}){let s=0;n.forEach(e=>{let{group:n,groupSize:o}=e,{orientation:c,panels:l}=n,{disableCursor:u}=n.mutableState,d=0;d=a?c===`horizontal`?(t.clientX-a.x)/o*100:(t.clientY-a.y)/o*100:c===`horizontal`?t.clientX<0?-100:100:t.clientY<0?-100:100;let f=r.get(n),p=i.get(n);if(!f||!p)return;let{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:_,separatorToPanels:v}=p;if(h&&_&&v){let t=hd({delta:d,initialLayout:f,panelConstraints:h,pivotIndices:e.panels.map(e=>l.indexOf(e)),prevLayout:_,trigger:`mouse-or-touch`});if(gd(t,_)){if(d!==0&&!u)switch(c){case`horizontal`:s|=d<0?Md:$;break;case`vertical`:s|=d<0?Nd:Pd;break}}else Zu(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:t,separatorToPanels:v})}});let c=0;t.movementX===0?c|=o&Fd:c|=s&Fd,t.movementY===0?c|=o&Id:c|=s&Id,Dd(c),Vd(e)}function Ud(e){let t=Yu(),n=Td();switch(n.state){case`active`:Hd({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function Wd(e){if(e.defaultPrevented)return;let t=Td(),n=Yu();switch(t.state){case`active`:if(e.buttons===0){Od({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{let t=Ju(e.group.id,!0);Zu(e.group,t)});return}Hd({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=ud(e,n);r.length===0?t.state!==`inactive`&&Od({cursorFlags:0,state:`inactive`}):Od({cursorFlags:0,hitRegions:r,state:`hover`}),Vd(e.currentTarget);break}}}function Gd(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(Td().state){case`hover`:Od({cursorFlags:0,state:`inactive`})}}function Kd(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=Td();switch(t.state){case`active`:Od({cursorFlags:0,state:`inactive`}),t.hitRegions.length>0&&(Vd(e.currentTarget),t.hitRegions.forEach(e=>{let t=Ju(e.group.id,!0);Zu(e.group,t)}),e.preventDefault())}}function qd(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=Mu(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=Mu((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function Jd(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=Nu({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:Mu(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function Yd(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function Xd({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,a=0,o=!1,s=new Map,c=[];for(let l of e.panels){let e=r[l.id]??0;switch(l.panelConstraints.groupResizeBehavior){case`preserve-pixel-size`:{o=!0;let r=Mu(e/100*n/t*100);s.set(l.id,r),i+=r;break}default:c.push(l.id),a+=e;break}}if(!o||c.length===0)return r;let l=100-i,u={...r};if(s.forEach((e,t)=>{u[t]=e}),a>0)for(let e of c)u[e]=Mu((r[e]??0)/a*l);else{let e=Mu(l/c.length);for(let t of c)u[t]=e}return u}function Zd(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}var Qd=new Map;function $d(e){let t=!0;X(e.element.ownerDocument.defaultView,`Cannot register an unmounted Group`);let n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,a=new n(n=>{for(let r of n){let{borderBoxSize:n,target:i}=r;if(i===e.element){if(t){let t=Nu({group:e});if(t===0)return;let n=Ju(e.id);if(!n)return;let r=Pu(e),i=n.defaultLayoutDeferred?qd(r):n.layout,a=_d({layout:Xd({group:e,nextGroupSize:t,prevGroupSize:n.groupSize,prevLayout:i}),panelConstraints:r});if(!n.defaultLayoutDeferred&&gd(n.layout,a)&&Yd(n.derivedPanelConstraints,r)&&n.groupSize===t)return;Zu(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:t,layout:a,separatorToPanels:n.separatorToPanels})}}else Jd(e,i,n)}});a.observe(e.element),e.panels.forEach(e=>{X(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&a.observe(e.element)});let o=Nu({group:e}),s=Pu(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.mutableState.defaultLayout;l&&(Zd(e.panels,l)||(l=void 0));let u=_d({layout:e.mutableState.layouts[c]??l??qd(s),panelConstraints:s}),d=e.element.ownerDocument;Qd.set(d,(Qd.get(d)??0)+1);let f=new Map;return Uu(e).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),Zu(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:s,groupSize:o,layout:u,separatorToPanels:f}),e.separators.forEach(e=>{X(!i.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),i.add(e.id),e.element.addEventListener(`keydown`,Sd)}),Qd.get(d)===1&&(d.addEventListener(`dblclick`,yd,!0),d.addEventListener(`pointerdown`,kd,!0),d.addEventListener(`pointerleave`,Ud),d.addEventListener(`pointermove`,Wd),d.addEventListener(`pointerout`,Gd),d.addEventListener(`pointerup`,Kd,!0)),function(){t=!1,Qd.set(d,Math.max(0,(Qd.get(d)??0)-1)),Ku(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,Sd)}),Qd.get(d)||(d.removeEventListener(`dblclick`,yd,!0),d.removeEventListener(`pointerdown`,kd,!0),d.removeEventListener(`pointerleave`,Ud),d.removeEventListener(`pointermove`,Wd),d.removeEventListener(`pointerout`,Gd),d.removeEventListener(`pointerup`,Kd,!0)),a.disconnect()}}function ef(){let[e,t]=(0,B.useState)({});return[e,(0,B.useCallback)(()=>t({}),[])]}function tf(e){let t=(0,B.useId)();return`${e??t}`}var nf=typeof window<`u`?B.useLayoutEffect:B.useEffect;function rf(e){let t=(0,B.useRef)(e);return nf(()=>{t.current=e},[e]),(0,B.useCallback)((...e)=>t.current?.(...e),[t])}function af(...e){return rf(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function of(e){let t=(0,B.useRef)({...e});return nf(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var sf=(0,B.createContext)(null);function cf(e,t){let n=(0,B.useRef)({getLayout:()=>({}),setLayout:Ad});(0,B.useImperativeHandle)(t,()=>n.current,[]),nf(()=>{Object.assign(n.current,bd({groupId:e}))})}function lf({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:o,id:s,onLayoutChange:c,onLayoutChanged:l,orientation:u=`horizontal`,resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){let m=(0,B.useRef)({onLayoutChange:{},onLayoutChanged:{}}),h=rf(e=>{gd(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=rf(e=>{gd(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e))}),_=tf(s),v=(0,B.useRef)(null),[y,b]=ef(),x=(0,B.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=af(v,a);cf(_,o);let C=rf((e,t)=>{let r=Td(),i=qu(e),a=Ju(e);if(a){let e=!1;switch(r.state){case`active`:e=r.hitRegions.some(e=>e.group===i);break}return{flexGrow:a.layout[t]??1,pointerEvents:e?`none`:void 0}}return{flexGrow:n?.[t]??1}}),w=of({defaultLayout:n,disableCursor:r}),T=(0,B.useMemo)(()=>({get disableCursor(){return!!w.disableCursor},getPanelStyles:C,id:_,orientation:u,registerPanel:e=>{let t=x.current;return t.panels=Fu(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=Fu(u,[...t.separators,e]),b(),()=>{t.separators=t.separators.filter(t=>t!==e),b()}},togglePanelDisabled:(e,t)=>{let n=x.current.panels.find(t=>t.id===e);n&&(n.panelConstraints.disabled=t);let r=qu(_),i=Ju(_);r&&i&&Zu(r,{...i,derivedPanelConstraints:Pu(r)})},toggleSeparatorDisabled:(e,t)=>{let n=x.current.separators.find(t=>t.id===e);n&&(n.disabled=t)}}),[C,_,b,u,w]),E=(0,B.useRef)(null);return nf(()=>{let e=v.current;if(e===null)return;let t=x.current,n;if(w.defaultLayout!==void 0&&Object.keys(w.defaultLayout).length===t.panels.length){n={};for(let e of t.panels){let t=w.defaultLayout[e.id];t!==void 0&&(n[e.id]=t)}}let r={disabled:!!i,element:e,id:_,mutableState:{defaultLayout:n,disableCursor:!!w.disableCursor,expandedPanelSizes:x.current.lastExpandedPanelSizes,layouts:x.current.layouts},orientation:u,panels:t.panels,resizeTargetMinimumSize:t.resizeTargetMinimumSize,separators:t.separators};E.current=r;let a=$d(r),{defaultLayoutDeferred:o,derivedPanelConstraints:s,layout:c}=Ju(r.id,!0);!o&&s.length>0&&(h(c),g(c));let l=Xu(_,e=>{let{defaultLayoutDeferred:t,derivedPanelConstraints:n,layout:i}=e.next;if(t||n.length===0)return;let a=r.panels.map(({id:e})=>e).join(`,`);r.mutableState.layouts[a]=i,n.forEach(t=>{if(t.collapsible){let{layout:n}=e.prev??{};if(n){let e=fd(t.collapsedSize,i[t.panelId]),a=fd(t.collapsedSize,n[t.panelId]);e&&!a&&(r.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let o=Td().state!==`active`;h(i),o&&g(i)});return()=>{E.current=null,a(),l()}},[i,_,g,h,u,y,w]),(0,B.useEffect)(()=>{let e=E.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,H.jsx)(sf.Provider,{value:T,children:(0,H.jsx)(`div`,{...p,className:t,"data-group":!0,"data-testid":_,id:_,ref:S,style:{height:`100%`,width:`100%`,overflow:`hidden`,...f,display:`flex`,flexDirection:u===`horizontal`?`row`:`column`,flexWrap:`nowrap`,touchAction:u===`horizontal`?`pan-y`:`pan-x`},children:e})})}lf.displayName=`Group`;function uf(){let e=(0,B.useContext)(sf);return X(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function df(e,t){let{id:n}=uf(),r=(0,B.useRef)({collapse:jd,expand:jd,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:jd});(0,B.useImperativeHandle)(t,()=>r.current,[]),nf(()=>{Object.assign(r.current,vd({groupId:n,panelId:e}))})}function ff({children:e,className:t,collapsedSize:n=`0%`,collapsible:r=!1,defaultSize:i,disabled:a,elementRef:o,groupResizeBehavior:s=`preserve-relative-size`,id:c,maxSize:l=`100%`,minSize:u=`0%`,onResize:d,panelRef:f,style:p,...m}){let h=!!c,g=tf(c),_=of({disabled:a}),v=(0,B.useRef)(null),y=af(v,o),{getPanelStyles:b,id:x,orientation:S,registerPanel:C,togglePanelDisabled:w}=uf(),T=d!==null,E=rf((e,t,n)=>{d?.(e,c,n)});nf(()=>{let e=v.current;if(e!==null)return C({element:e,id:g,idIsStable:h,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:T?E:void 0,panelConstraints:{groupResizeBehavior:s,collapsedSize:n,collapsible:r,defaultSize:i,disabled:_.disabled,maxSize:l,minSize:u}})},[s,n,r,i,T,g,h,l,u,E,C,_]),(0,B.useEffect)(()=>{w(g,!!a)},[a,g,w]),df(g,f);let D=(0,B.useSyncExternalStore)(e=>Xu(x,e),()=>JSON.stringify(b(x,g)),()=>JSON.stringify(b(x,g)));return(0,H.jsx)(`div`,{...m,"aria-disabled":a||void 0,"data-panel":!0,"data-testid":g,id:g,ref:y,style:{...pf,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...JSON.parse(D)},children:(0,H.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...p,touchAction:S===`horizontal`?`pan-y`:`pan-x`},children:e})})}ff.displayName=`Panel`;var pf={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function mf({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,a,o=e[n],s=t.find(e=>e.panelId===n);if(s){let c=s.maxSize,l=s.collapsible?s.collapsedSize:s.minSize,u=[r,r+1];a=_d({layout:hd({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=_d({layout:hd({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function hf({children:e,className:t,disabled:n,elementRef:r,id:i,style:a,...o}){let s=tf(i),c=of({disabled:n}),[l,u]=(0,B.useState)({}),[d,f]=(0,B.useState)(`inactive`),p=(0,B.useRef)(null),m=af(p,r),{disableCursor:h,id:g,orientation:_,registerSeparator:v,toggleSeparatorDisabled:y}=uf(),b=_===`horizontal`?`vertical`:`horizontal`;nf(()=>{let e=p.current;if(e!==null){let t={disabled:c.disabled,element:e,id:s},n=v(t),r=Ed(e=>{f(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===t)?e.next.state:`inactive`)}),i=Xu(g,e=>{let{derivedPanelConstraints:n,layout:r,separatorToPanels:i}=e.next,a=i.get(t);if(a){let e=a[0],t=a.indexOf(e);u(mf({layout:r,panelConstraints:n,panelId:e.id,panelIndex:t}))}});return()=>{r(),i(),n()}}},[g,s,v,c]),(0,B.useEffect)(()=>{y(s,!!n)},[n,s,y]);let x;return n&&!h&&(x=`not-allowed`),(0,H.jsx)(`div`,{...o,"aria-controls":l.valueControls,"aria-disabled":n||void 0,"aria-orientation":b,"aria-valuemax":l.valueMax,"aria-valuemin":l.valueMin,"aria-valuenow":l.valueNow,children:e,className:t,"data-separator":n?`disabled`:d,"data-testid":s,id:s,ref:m,role:`separator`,style:{flexBasis:`auto`,cursor:x,...a,flexGrow:0,flexShrink:0,touchAction:`none`},tabIndex:n?void 0:0})}hf.displayName=`Separator`;var gf=`ppm-custom-order`;function _f(){try{let e=localStorage.getItem(gf);return e?JSON.parse(e):null}catch{return null}}function vf(e){try{localStorage.setItem(gf,JSON.stringify(e))}catch{}}function yf(e,t){if(!t)return[...e];let n=new Map(t.map((e,t)=>[e,t]));return[...e].sort((e,t)=>(n.get(e.name)??1/0)-(n.get(t.name)??1/0))}var bf=v((e,t)=>({projects:[],activeProject:null,customOrder:_f(),loading:!1,error:null,fetchProjects:async()=>{e({loading:!0,error:null});try{e({projects:await z.get(`/api/projects`),loading:!1})}catch(t){e({error:t instanceof Error?t.message:`Failed to fetch projects`,loading:!1})}},setActiveProject:t=>{e({activeProject:t})},addProject:async(n,r)=>{let i=await z.post(`/api/projects`,{path:n,name:r});await t().fetchProjects();let a=t().projects.find(e=>e.name===(r??i.name)||e.path===n);return a&&e({activeProject:a}),i},setProjectColor:async(e,n)=>{await z.patch(`/api/projects/${encodeURIComponent(e)}/color`,{color:n}),await t().fetchProjects()},moveProject:async(n,r)=>{let{projects:i,customOrder:a}=t(),o=yf(i,a),s=o.findIndex(e=>e.name===n);if(s===-1)return;let c=r===`up`?s-1:s+1;if(c<0||c>=o.length)return;let l=o.map(e=>e.name);[l[s],l[c]]=[l[c],l[s]],vf(l),await z.patch(`/api/projects/reorder`,{order:l}),e({customOrder:l})},reorderProjects:async t=>{vf(t),e({customOrder:t}),await z.patch(`/api/projects/reorder`,{order:t}).catch(()=>{})},renameProject:async(e,n)=>{await z.patch(`/api/projects/${encodeURIComponent(e)}`,{name:n}),await t().fetchProjects()},deleteProject:async t=>{await z.del(`/api/projects/${encodeURIComponent(t)}`),e(e=>{let n=e.projects.filter(e=>e.name!==t),r=e.customOrder?e.customOrder.filter(e=>e!==t):null;return r&&vf(r),{projects:n,customOrder:r,activeProject:e.activeProject?.name===t?n[0]??null:e.activeProject}})}})),xf=`application/ppm-tab`,Sf=!1,Cf=new Set;function wf(e){Sf!==e&&(Sf=e,Cf.forEach(e=>e()))}function Tf(){return(0,B.useSyncExternalStore)(e=>(Cf.add(e),()=>Cf.delete(e)),()=>Sf)}function Ef(){wf(!1)}function Df(e){let[t,n]=(0,B.useState)(null),r=(0,B.useRef)(null);return{dropIndex:t,handleDragStart:(0,B.useCallback)((t,n)=>{let r={tabId:n,panelId:e};t.dataTransfer.setData(xf,JSON.stringify(r)),t.dataTransfer.effectAllowed=`move`,requestAnimationFrame(()=>wf(!0))},[e]),handleDragOver:(0,B.useCallback)((e,t,i)=>{if(!e.dataTransfer.types.includes(`application/ppm-tab`)||(e.preventDefault(),e.dataTransfer.dropEffect=`move`,r.current===t))return;r.current=t;let a=e.currentTarget.getBoundingClientRect(),o=a.left+a.width/2;n(e.clientX<o?i:i+1)},[]),handleDragOverBar:(0,B.useCallback)(e=>{e.dataTransfer.types.includes(`application/ppm-tab`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`)},[]),handleDrop:(0,B.useCallback)(i=>{i.preventDefault(),wf(!1);let a=i.dataTransfer.getData(xf);if(a){try{let n=JSON.parse(a),r=m.getState();n.panelId===e?t!==null&&r.reorderTab(n.tabId,e,t):r.moveTab(n.tabId,n.panelId,e,t??void 0)}catch{}n(null),r.current=null}},[e,t]),handleDragEnd:(0,B.useCallback)(()=>{wf(!1),n(null),r.current=null},[])}}var Of=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.userAgent),kf=[{id:`command-palette`,label:`Command Palette`,category:`general`,defaultKey:`F1`,note:`Shift+Shift also opens (not customizable)`},{id:`toggle-sidebar`,label:`Toggle Sidebar`,category:`general`,defaultKey:`Mod+B`},{id:`save-prevent`,label:`Prevent Save Dialog`,category:`general`,defaultKey:`Mod+S`,locked:!0,note:`Always active — prevents browser save`},{id:`next-tab`,label:`Next Tab`,category:`tabs`,defaultKey:`Alt+]`},{id:`prev-tab`,label:`Previous Tab`,category:`tabs`,defaultKey:`Alt+[`},{id:`open-chat`,label:`Open Chat`,category:`tabs`,defaultKey:`Mod+L`},{id:`open-terminal`,label:`Open Terminal`,category:`tabs`,defaultKey:`Mod+'`},{id:`open-settings`,label:`Open Settings`,category:`tabs`,defaultKey:`Mod+,`},{id:`open-git-graph`,label:`Git Graph`,category:`tabs`,defaultKey:`Mod+G`},{id:`open-git-status`,label:`Git Status (sidebar)`,category:`tabs`,defaultKey:`Mod+Shift+E`},{id:`open-search`,label:`Search Files (sidebar)`,category:`tabs`,defaultKey:`Mod+Shift+F`},{id:`voice-input`,label:`Voice Input`,category:`general`,defaultKey:`Mod+Shift+V`,note:`Toggle speech-to-text in chat`},...Array.from({length:9},(e,t)=>({id:`switch-project-${t+1}`,label:`Switch to Project ${t+1}`,category:`projects`,defaultKey:`Mod+${t+1}`}))],Af=new Map(kf.map(e=>[e.id,e.defaultKey]));function jf(e){let t=e.split(`+`),n={ctrl:!1,meta:!1,alt:!1,shift:!1,key:``};for(let e of t){let t=e.trim();switch(t){case`Mod`:Of?n.meta=!0:n.ctrl=!0;break;case`Ctrl`:n.ctrl=!0;break;case`Meta`:case`Cmd`:n.meta=!0;break;case`Alt`:n.alt=!0;break;case`Shift`:n.shift=!0;break;default:n.key=t.toLowerCase();break}}return n}function Mf(e,t){return e.ctrlKey!==t.ctrl||e.metaKey!==t.meta||e.altKey!==t.alt||e.shiftKey!==t.shift?!1:e.key.toLowerCase()===t.key}function Nf(e){return e.replace(/Mod/g,Of?`⌘`:`Ctrl`).replace(/Shift/g,Of?`⇧`:`Shift`).replace(/Alt/g,Of?`⌥`:`Alt`).replace(/Meta|Cmd/g,`⌘`).replace(/Ctrl/g,Of?`⌃`:`Ctrl`)}function Pf(e){if([`Control`,`Meta`,`Alt`,`Shift`].includes(e.key))return null;let t=[];e.ctrlKey&&!e.metaKey&&t.push(Of?`Ctrl`:`Mod`),e.metaKey&&t.push(Of?`Mod`:`Meta`),e.altKey&&t.push(`Alt`),e.shiftKey&&t.push(`Shift`);let n=e.key;return n===` `?n=`Space`:n.length===1&&(n=n.toUpperCase()),t.push(n),t.join(`+`)}var Ff=v((e,t)=>({overrides:{},loaded:!1,getBinding:e=>t().overrides[e]??Af.get(e)??``,matchesEvent:(e,n)=>{let r=t().getBinding(n);return r?Mf(e,jf(r)):!1},setBinding:(n,r)=>{e({overrides:{...t().overrides,[n]:r}}),z.put(`/api/settings/keybindings`,{[n]:r}).catch(()=>{})},resetBinding:n=>{let r={...t().overrides};delete r[n],e({overrides:r}),z.put(`/api/settings/keybindings`,{[n]:null}).catch(()=>{})},resetAll:()=>{e({overrides:{}});let n={};for(let e of Object.keys(t().overrides))n[e]=null;Object.keys(n).length>0&&z.put(`/api/settings/keybindings`,n).catch(()=>{})},loadFromServer:async()=>{try{e({overrides:await z.get(`/api/settings/keybindings`),loaded:!0})}catch{e({loaded:!0})}}}));function If(e){window.dispatchEvent(new CustomEvent(`open-command-palette`,{detail:e}))}function Lf(){let[e,t]=(0,B.useState)(!1),[n,r]=(0,B.useState)(``);return(0,B.useEffect)(()=>{let e=0,{matchesEvent:n}=Ff.getState(),i=!1;function a(){i=!0}function o(){i=!1}function s(n){if(n.type===`keyup`&&n.key===`Shift`&&!n.ctrlKey&&!n.metaKey&&!n.altKey&&!i&&!n.isComposing){let n=Date.now();if(n-e<400){e=0,r(``),t(!0);return}e=n;return}if(n.type!==`keydown`||i||n.isComposing)return;let{matchesEvent:a}=Ff.getState();if(a(n,`save-prevent`)){n.preventDefault();return}if(a(n,`command-palette`)){n.preventDefault(),r(``),t(!0);return}if(a(n,`toggle-sidebar`)){n.preventDefault(),V.getState().toggleSidebar();return}if(a(n,`next-tab`)||a(n,`prev-tab`)){n.preventDefault();let{tabs:e,activeTabId:t,setActiveTab:r}=_.getState();if(e.length<2)return;let i=e.findIndex(e=>e.id===t);r(e[a(n,`next-tab`)?(i+1)%e.length:(i-1+e.length)%e.length].id);return}for(let e of[{action:`open-chat`,type:`chat`,title:`AI Chat`},{action:`open-terminal`,type:`terminal`,title:`Terminal`},{action:`open-git-graph`,type:`git-graph`,title:`Git Graph`}])if(a(n,e.action)){n.preventDefault();let t=bf.getState().activeProject;_.getState().openTab({type:e.type,title:e.title,projectId:t?.name??null,metadata:t?{projectName:t.name}:void 0,closable:!0});return}if(a(n,`open-settings`)){n.preventDefault();let e=V.getState();e.sidebarCollapsed&&e.toggleSidebar(),e.setSidebarActiveTab(`settings`);return}if(a(n,`open-git-status`)){n.preventDefault();let e=V.getState();e.sidebarCollapsed&&e.toggleSidebar(),e.setSidebarActiveTab(`git`);return}if(a(n,`voice-input`)){n.preventDefault(),window.dispatchEvent(new CustomEvent(`toggle-voice-input`));return}if(a(n,`open-search`)){n.preventDefault();let e=V.getState();e.sidebarCollapsed&&e.toggleSidebar(),e.setSidebarActiveTab(`search`);return}for(let e=1;e<=9;e++)if(a(n,`switch-project-${e}`)){n.preventDefault();let t=bf.getState().projects[e-1];t&&(bf.getState().setActiveProject(t),_.getState().switchProject(t.name));return}}function c(e){let n=e.detail;r(typeof n==`string`?n:``),t(!0)}return window.addEventListener(`keydown`,s),window.addEventListener(`keyup`,s),window.addEventListener(`compositionstart`,a),window.addEventListener(`compositionend`,o),window.addEventListener(`open-command-palette`,c),()=>{window.removeEventListener(`keydown`,s),window.removeEventListener(`keyup`,s),window.removeEventListener(`compositionstart`,a),window.removeEventListener(`compositionend`,o),window.removeEventListener(`open-command-palette`,c)}},[]),{paletteOpen:e,paletteInitialQuery:n,closePalette:(0,B.useCallback)(()=>{t(!1),r(``)},[])}}var Rf={approval_request:`bg-red-500`,question:`bg-amber-500`,done:`bg-blue-500`},zf={done:0,question:1,approval_request:2};function Bf(e){return e&&Rf[e]||`bg-red-500`}var Vf=v()(e=>({notifications:new Map,addNotification:(t,n,r)=>{e(e=>{let i=new Map(e.notifications),a=i.get(t);return i.set(t,{count:(a?.count??0)+1,type:n,projectName:r}),{notifications:i}})},clearForSession:t=>{e(e=>{if(!e.notifications.has(t))return e;let n=new Map(e.notifications);return n.delete(t),{notifications:n}})},clearAll:()=>e({notifications:new Map})}));function Hf(e){let t=0;for(let[,n]of e.notifications)t+=n.count;return t}function Uf(e){return t=>{let n=null,r=-1;for(let[,i]of t.notifications){if(i.projectName!==e)continue;let t=zf[i.type]??0;t>r&&(r=t,n=i.type)}return n}}function Wf(e){let[t,n]=(0,B.useState)(!1),[r,i]=(0,B.useState)(!1),a=(0,B.useCallback)(()=>{let t=e.current;t&&(n(t.scrollLeft>1),i(t.scrollLeft+t.clientWidth<t.scrollWidth-1))},[e]);return(0,B.useEffect)(()=>{let t=e.current;if(!t)return;a(),t.addEventListener(`scroll`,a,{passive:!0});let n=new ResizeObserver(a);n.observe(t);let r=new MutationObserver(a);return r.observe(t,{childList:!0,subtree:!0}),()=>{t.removeEventListener(`scroll`,a),n.disconnect(),r.disconnect()}},[e,a]),{canScrollLeft:t,canScrollRight:r,scrollLeft:(0,B.useCallback)(()=>{e.current?.scrollBy({left:-150,behavior:`smooth`})},[e]),scrollRight:(0,B.useCallback)(()=>{e.current?.scrollBy({left:150,behavior:`smooth`})},[e])}}var Gf={done:0,question:1,approval_request:2};function Kf(e,t,n,r){if(!e)return{left:null,right:null};let i=e.scrollLeft,a=i+e.clientWidth,o=null,s=-1,c=null,l=-1,u=e.getBoundingClientRect();for(let d of n){if(d.type!==`chat`)continue;let n=d.metadata?.sessionId,f=n?r.get(n):void 0;if(!f||f.count===0)continue;let p=t.get(d.id);if(!p)continue;let m=p.getBoundingClientRect(),h=m.left-u.left+e.scrollLeft,g=h+m.width,_=Gf[f.type]??0;g<=i&&_>s&&(s=_,o=f.type),h>=a&&_>l&&(l=_,c=f.type)}return{left:o,right:c}}function qf(e){let t=/^#([0-9a-fA-F]{6})$/.exec(e.trim());if(!t)return null;let n=parseInt(t[1],16);return{r:n>>16&255,g:n>>8&255,b:n&255}}function Jf(e,t,n){let[r,i,a]=[e,t,n].map(e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4});return .2126*r+.7152*i+.0722*a}function Yf(e){let t=qf(e);return t?Jf(t.r,t.g,t.b)<.4:!1}function Xf({tab:e,isActive:t,icon:n,showDropBefore:r,notificationType:i,onSelect:a,onClose:o,onDragStart:s,onDragOver:c,onDragEnd:l,tabRef:u,onRename:d}){let[f,p]=(0,B.useState)(!1),[m,h]=(0,B.useState)(e.title),g=(0,B.useRef)(null);(0,B.useEffect)(()=>{f&&(h(e.title),setTimeout(()=>g.current?.select(),0))},[f]);let _=()=>{p(!1);let t=m.trim();t&&t!==e.title&&d&&d(t)},v=e.metadata?.connectionColor,y=v?{backgroundColor:t?v:`${v}33`,color:t&&Yf(v)?`#fff`:void 0}:void 0;return(0,H.jsxs)(`div`,{className:`relative flex items-center`,children:[r&&(0,H.jsx)(`div`,{className:`absolute left-0 top-1 bottom-1 w-0.5 bg-primary rounded-full z-10`}),(0,H.jsxs)(`button`,{ref:u,"data-tab-item":!0,draggable:!f,onClick:a,onAuxClick:t=>{t.button===1&&e.closable&&(t.preventDefault(),o())},onDragStart:s,onDragOver:c,onDragEnd:l,style:y,className:R(`group flex items-center gap-1 px-3 h-10 whitespace-nowrap text-xs transition-colors`,`border-b-2 -mb-px cursor-grab active:cursor-grabbing`,!y&&(t?`border-primary text-primary`:`border-transparent text-text-secondary hover:text-foreground`),y&&`border-transparent`),children:[(0,H.jsxs)(`span`,{className:`relative`,children:[(0,H.jsx)(n,{className:`size-4`}),i&&!t&&(0,H.jsx)(`span`,{className:R(`absolute -top-1 -right-1 size-2 rounded-full`,Bf(i))})]}),f?(0,H.jsx)(`input`,{ref:g,value:m,onChange:e=>h(e.target.value),onBlur:_,onKeyDown:e=>{e.key===`Enter`&&_(),e.key===`Escape`&&p(!1),e.stopPropagation()},onClick:e=>e.stopPropagation(),className:`max-w-[120px] bg-surface-elevated text-xs px-1 py-0.5 rounded border border-border outline-none focus:border-primary`,autoFocus:!0}):(0,H.jsx)(`span`,{className:`max-w-[120px] truncate`,onDoubleClick:e=>{d&&(e.stopPropagation(),p(!0))},children:e.title}),e.closable&&!f&&(0,H.jsx)(`span`,{role:`button`,tabIndex:0,onClick:e=>{e.stopPropagation(),o()},onKeyDown:e=>{e.key===`Enter`&&(e.stopPropagation(),o())},className:`ml-1 opacity-0 group-hover:opacity-100 rounded-sm hover:bg-surface-elevated p-0.5 transition-opacity`,children:(0,H.jsx)(Gt,{className:`size-3`})})]})]})}var Zf={terminal:Rt,chat:_t,editor:Je,database:He,sqlite:He,postgres:He,"git-graph":nt,"git-diff":Ye,settings:Pt,browser:it};function Qf({panelId:e}){bf(e=>e.activeProject);let t=(0,B.useRef)(new Map),n=(0,B.useRef)(null),r=(0,B.useRef)(0),i=m(t=>e?t.panels[e]:t.panels[t.focusedPanelId]),a=i?.tabs??[],o=i?.activeTabId??null,s=i?.id??m.getState().focusedPanelId,{dropIndex:c,handleDragStart:l,handleDragOver:u,handleDragOverBar:f,handleDrop:p,handleDragEnd:h}=Df(s),g=Vf(e=>e.notifications),{canScrollLeft:v,canScrollRight:y,scrollLeft:b,scrollRight:x}=Wf(n),S=Kf(n.current,t.current,a,g);(0,B.useEffect)(()=>{if(a.length>r.current&&o){let e=t.current.get(o);e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`,inline:`nearest`})}r.current=a.length},[a.length,o]);let C=(0,B.useCallback)((e,t)=>{_.getState().updateTab(e.id,{title:t});let n=e.metadata?.projectName,r=e.metadata?.sessionId;n&&r&&z.patch(`${fe(n)}/chat/sessions/${r}`,{title:t}).catch(()=>{})},[]);function w(e){e.target.closest(`[data-tab-item]`)||If()}function T(e){e.target.closest(`[data-tab-item]`)||(e.preventDefault(),If())}return(0,H.jsxs)(`div`,{className:`hidden md:flex items-center h-10 border-b border-border bg-background relative`,onDragOver:f,onDrop:p,onDoubleClick:w,onContextMenu:T,children:[v&&(0,H.jsx)(`button`,{onClick:b,className:`absolute left-0 z-10 flex items-center justify-center size-8 bg-gradient-to-r from-background via-background to-transparent`,children:(0,H.jsxs)(`span`,{className:`relative`,children:[(0,H.jsx)(Me,{className:`size-4 text-text-secondary`}),S.left&&(0,H.jsx)(`span`,{className:R(`absolute -top-1 -right-0.5 size-2 rounded-full`,Bf(S.left))})]})}),(0,H.jsx)(`div`,{ref:n,className:`flex-1 overflow-x-auto overflow-y-hidden min-w-0 scrollbar-none`,children:(0,H.jsxs)(`div`,{className:`flex items-center h-10`,children:[a.map((e,n)=>{let r=e.type===`chat`?e.metadata?.sessionId:void 0,i=r?g.get(r):void 0,a=i&&i.count>0?i.type:null;return(0,H.jsx)(Xf,{tab:e,isActive:e.id===o,icon:Zf[e.type],showDropBefore:c===n,notificationType:a,onSelect:()=>{m.getState().setActiveTab(e.id,s),r&&Vf.getState().clearForSession(r)},onClose:()=>m.getState().closeTab(e.id,s),onDragStart:t=>l(t,e.id),onDragOver:t=>u(t,e.id,n),onDragEnd:h,tabRef:n=>{n?t.current.set(e.id,n):t.current.delete(e.id)},onRename:e.type===`chat`?t=>C(e,t):void 0},e.id)}),c!==null&&c>=a.length&&(0,H.jsx)(`div`,{className:`w-0.5 h-6 bg-primary rounded-full`}),(0,H.jsx)(`button`,{onClick:()=>If(),title:`Open command palette (Shift+Shift)`,className:`flex items-center justify-center size-10 shrink-0 sticky right-0 border-b-2 border-transparent text-text-secondary hover:text-foreground transition-colors bg-background`,children:(0,H.jsx)(Ot,{className:`size-4`})})]})}),y&&(0,H.jsx)(`button`,{onClick:x,className:`absolute right-10 z-10 flex items-center justify-center size-8 bg-gradient-to-l from-background via-background to-transparent`,children:(0,H.jsxs)(`span`,{className:`relative`,children:[(0,H.jsx)(d,{className:`size-4 text-text-secondary`}),S.right&&(0,H.jsx)(`span`,{className:R(`absolute -top-1 -left-0.5 size-2 rounded-full`,Bf(S.right))})]})})]})}function $f({panelId:e}){let[t,n]=(0,B.useState)(null),r=Tf(),i=m(e=>e.grid),a=m(e=>e.isMobile()),o=p(i,e),s=!a&&i.length<3,c=o?!a&&(i[o.row]?.length??0)<f(!1):!1,l=(0,B.useCallback)(e=>{let t=e.currentTarget.getBoundingClientRect(),n=(e.clientX-t.left)/t.width,r=(e.clientY-t.top)/t.height,i=.25;return n<i&&c?`left`:n>1-i&&c?`right`:r<i&&s?`top`:r>1-i&&s?`bottom`:`center`},[c,s]),u=(0,B.useCallback)(e=>{e.dataTransfer.types.includes(`application/ppm-tab`)&&(e.preventDefault(),e.stopPropagation(),n(l(e)))},[l]),d=(0,B.useCallback)(e=>{e.currentTarget.contains(e.relatedTarget)||n(null)},[]),h=(0,B.useCallback)(t=>{t.preventDefault(),t.stopPropagation();let r=l(t);if(n(null),Ef(),!r)return;let i=t.dataTransfer.getData(xf);if(i)try{let t=JSON.parse(i),n=m.getState();if(r===`center`)t.panelId!==e&&n.moveTab(t.tabId,t.panelId,e);else{let i=r===`top`?`up`:r===`bottom`?`down`:r;n.splitPanel(i,t.tabId,t.panelId,e)}}catch{}},[l,e]);return r?(0,H.jsxs)(`div`,{className:`absolute inset-0 z-20`,onDragOver:u,onDragLeave:d,onDrop:h,children:[t===`left`&&(0,H.jsx)(`div`,{className:`absolute inset-y-0 left-0 w-1/3 bg-primary/10 border-2 border-primary/30 rounded-l-md`}),t===`right`&&(0,H.jsx)(`div`,{className:`absolute inset-y-0 right-0 w-1/3 bg-primary/10 border-2 border-primary/30 rounded-r-md`}),t===`top`&&(0,H.jsx)(`div`,{className:`absolute inset-x-0 top-0 h-1/3 bg-primary/10 border-2 border-primary/30 rounded-t-md`}),t===`bottom`&&(0,H.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 h-1/3 bg-primary/10 border-2 border-primary/30 rounded-b-md`}),t===`center`&&(0,H.jsx)(`div`,{className:`absolute inset-0 bg-primary/5 border-2 border-dashed border-primary/30 rounded-md`})]}):null}var ep=[{type:`terminal`,label:`Terminal`,icon:Rt},{type:`chat`,label:`AI Chat`,icon:_t},{type:`git-graph`,label:`Git Graph`,icon:nt}],tp={terminal:(0,B.lazy)(()=>y(()=>import(`./terminal-tab-IkfhM5s1.js`).then(e=>({default:e.TerminalTab})),__vite__mapDeps([3,1,4,5,6,7]))),chat:(0,B.lazy)(()=>y(()=>import(`./chat-tab-Bx_6S_UY.js`).then(e=>({default:e.ChatTab})),__vite__mapDeps([8,1,9,10,11,5,6,12,13,14,15,16,17,18,19,4,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,2,38,39,0]))),editor:(0,B.lazy)(()=>y(()=>import(`./code-editor-B1u2B_S9.js`).then(e=>({default:e.CodeEditor})),__vite__mapDeps([40,1,9,10,11,5,6,12,13,14,15,16,17,18,41,4,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,2,42]))),database:(0,B.lazy)(()=>y(()=>import(`./database-viewer-D9fH7muY.js`).then(e=>({default:e.DatabaseViewer})),__vite__mapDeps([43,1,44,5,6,45,21,2]))),sqlite:(0,B.lazy)(()=>y(()=>import(`./sqlite-viewer-D6sxS0bk.js`).then(e=>({default:e.SqliteViewer})),__vite__mapDeps([46,1,44,5,6,45,21,42,2]))),postgres:(0,B.lazy)(()=>y(()=>import(`./postgres-viewer-CqT43D2z.js`).then(e=>({default:e.PostgresViewer})),__vite__mapDeps([47,1,44,5,6,45,21,42,2]))),"git-graph":(0,B.lazy)(()=>y(()=>import(`./git-graph-BDUvkX0f.js`).then(e=>({default:e.GitGraph})),__vite__mapDeps([48,1,11,5,6,12,19,4,24,25,39,2]))),"git-diff":(0,B.lazy)(()=>y(()=>import(`./diff-viewer-CdAqWeV-.js`).then(e=>({default:e.DiffViewer})),__vite__mapDeps([49,1,41,5,6,38,2]))),settings:(0,B.lazy)(()=>y(()=>import(`./settings-tab-G59ZwloQ.js`).then(e=>({default:e.SettingsTab})),__vite__mapDeps([50,11,1,5,6,12,19,4,2,0]))),browser:(0,B.lazy)(()=>y(()=>import(`./browser-tab-CtCbYDuw.js`).then(e=>({default:e.BrowserTab})),__vite__mapDeps([51,1,5,6,24,4,25,2])))};function np({panelId:e,projectName:t}){let n=m(t=>t.panels[e]),r=m(t=>t.focusedPanelId===e),i=m(e=>(e.currentProject===t?e.grid:e.projectGrids[t]??[[]]).flat().length);return n?(0,H.jsxs)(`div`,{className:R(`flex flex-col h-full overflow-hidden`,i>1&&`border border-transparent`,i>1&&r&&`border-primary/30`),onMouseDown:()=>{m.getState().focusedPanelId!==e&&m.getState().setFocusedPanel(e)},children:[(0,H.jsx)(Qf,{panelId:e}),(0,H.jsxs)(`div`,{className:`flex-1 overflow-hidden relative`,children:[n.tabs.length===0?(0,H.jsx)(rp,{panelId:e}):n.tabs.map(e=>{let t=tp[e.type];return(0,H.jsx)(`div`,{className:e.id===n.activeTabId?`h-full w-full`:`hidden`,children:(0,H.jsx)(B.Suspense,{fallback:(0,H.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,H.jsx)(pt,{className:`size-6 animate-spin text-primary`})}),children:(0,H.jsx)(t,{metadata:e.metadata,tabId:e.id})})},e.id)}),(0,H.jsx)($f,{panelId:e})]})]}):null}function rp({panelId:e}){let t=bf(e=>e.activeProject);function n(n){let r=n!==`settings`&&t?{projectName:t.name}:void 0;m.getState().openTab({type:n,title:ep.find(e=>e.type===n)?.label??n,metadata:r,projectId:t?.name??null,closable:!0},e)}return(0,H.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4 text-text-secondary`,children:[(0,H.jsx)(`p`,{className:`text-sm`,children:`Open a tab to get started`}),(0,H.jsx)(`div`,{className:`flex flex-col md:flex-row flex-wrap justify-center gap-2`,children:ep.map(e=>{let t=e.icon;return(0,H.jsxs)(`button`,{onClick:()=>n(e.type),className:`flex items-center gap-2 px-4 py-2 rounded-md border border-border bg-surface hover:bg-surface-elevated text-sm text-foreground transition-colors`,children:[(0,H.jsx)(t,{className:`size-4`}),e.label]},e.type)})})]})}function ip({projectName:e}){let t=m(t=>t.currentProject===e?t.grid:t.projectGrids[e]??[[]]),n=t.flat().length;return(0,B.useEffect)(()=>{if(n===0){let e=g();m.setState(t=>({panels:{...t.panels,[e.id]:e},grid:[[e.id]],focusedPanelId:e.id}))}},[n]),n===0?null:n===1&&t[0]?.[0]?(0,H.jsx)(np,{panelId:t[0][0],projectName:e}):(0,H.jsx)(lf,{orientation:`vertical`,style:{height:`100%`},children:t.map((n,r)=>(0,H.jsx)(ap,{row:n,rowIdx:r,totalRows:t.length,projectName:e},`row-${r}`))})}function ap({row:e,rowIdx:t,totalRows:n,projectName:r}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ff,{minSize:`15%`,defaultSize:`${Math.round(100/n)}%`,children:e.length===1?(0,H.jsx)(np,{panelId:e[0],projectName:r}):(0,H.jsx)(lf,{orientation:`horizontal`,children:e.map((t,n)=>(0,H.jsx)(op,{panelId:t,colIdx:n,totalCols:e.length,projectName:r},t))})}),t<n-1&&(0,H.jsx)(sp,{orientation:`horizontal`})]})}function op({panelId:e,colIdx:t,totalCols:n,projectName:r}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ff,{minSize:`15%`,defaultSize:`${Math.round(100/n)}%`,children:(0,H.jsx)(np,{panelId:e,projectName:r})}),t<n-1&&(0,H.jsx)(sp,{orientation:`vertical`})]})}function sp({orientation:e}){let t=e===`vertical`;return(0,H.jsx)(hf,{className:`
14
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return B.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},gr=`DialogDescriptionWarning`,_r=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${mr(gr).contentName}}.`;return B.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},vr=Un,yr=Yn,br=Zn,xr=tr,Sr=or,Cr=cr,wr=ur;function Tr(e){let t=B.useRef({value:e,previous:e});return B.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Er=`rovingFocusGroup.onEntryFocus`,Dr={bubbles:!1,cancelable:!0},Or=`RovingFocusGroup`,[kr,Ar,jr]=D(Or),[Mr,Nr]=w(Or,[jr]),[Pr,Fr]=Mr(Or),Ir=B.forwardRef((e,t)=>(0,H.jsx)(kr.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,H.jsx)(kr.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,H.jsx)(Lr,{...e,ref:t})})}));Ir.displayName=Or;var Lr=B.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=B.useRef(null),p=M(t,f),m=P(a),[h,g]=T({prop:o,defaultProp:s??null,onChange:c,caller:Or}),[_,v]=B.useState(!1),y=F(l),x=Ar(n),S=B.useRef(!1),[C,w]=B.useState(0);return B.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(Er,y),()=>e.removeEventListener(Er,y)},[y]),(0,H.jsx)(Pr,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:B.useCallback(e=>g(e),[g]),onItemShiftTab:B.useCallback(()=>v(!0),[]),onFocusableItemAdd:B.useCallback(()=>w(e=>e+1),[]),onFocusableItemRemove:B.useCallback(()=>w(e=>e-1),[]),children:(0,H.jsx)(b.div,{tabIndex:_||C===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:L(e.onMouseDown,()=>{S.current=!0}),onFocus:L(e.onFocus,e=>{let t=!S.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(Er,Dr);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=x().filter(e=>e.focusable);Ur([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}S.current=!1}),onBlur:L(e.onBlur,()=>v(!1))})})}),Rr=`RovingFocusGroupItem`,zr=B.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=j(),l=a||c,u=Fr(Rr,n),d=u.currentTabStopId===l,f=Ar(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return B.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,H.jsx)(kr.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,H.jsx)(b.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:L(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:L(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:L(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=Hr(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?Wr(n,r+1):n.slice(r+1)}setTimeout(()=>Ur(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});zr.displayName=Rr;var Br={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function Vr(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function Hr(e,t,n){let r=Vr(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return Br[r]}function Ur(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Wr(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Gr=Ir,Kr=zr,qr=[`Enter`,` `],Jr=[`ArrowDown`,`PageUp`,`Home`],Yr=[`ArrowUp`,`PageDown`,`End`],Xr=[...Jr,...Yr],Zr={ltr:[...qr,`ArrowRight`],rtl:[...qr,`ArrowLeft`]},Qr={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},$r=`Menu`,[ei,ti,ni]=D($r),[ri,ii]=w($r,[ni,E,Nr]),ai=E(),oi=Nr(),[si,ci]=ri($r),[li,ui]=ri($r),di=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=ai(t),[c,l]=B.useState(null),u=B.useRef(!1),d=F(a),f=P(i);return B.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),(0,H.jsx)(te,{...s,children:(0,H.jsx)(si,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,H.jsx)(li,{scope:t,onClose:B.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};di.displayName=$r;var fi=`MenuAnchor`,pi=B.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=ai(n);return(0,H.jsx)(I,{...i,...r,ref:t})});pi.displayName=fi;var mi=`MenuPortal`,[hi,gi]=ri(mi,{forceMount:void 0}),_i=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=ci(mi,t);return(0,H.jsx)(hi,{scope:t,forceMount:n,children:(0,H.jsx)(A,{present:n||a.open,children:(0,H.jsx)(oe,{asChild:!0,container:i,children:r})})})};_i.displayName=mi;var vi=`MenuContent`,[yi,bi]=ri(vi),xi=B.forwardRef((e,t)=>{let n=gi(vi,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=ci(vi,e.__scopeMenu),o=ui(vi,e.__scopeMenu);return(0,H.jsx)(ei.Provider,{scope:e.__scopeMenu,children:(0,H.jsx)(A,{present:r||a.open,children:(0,H.jsx)(ei.Slot,{scope:e.__scopeMenu,children:o.modal?(0,H.jsx)(Si,{...i,ref:t}):(0,H.jsx)(Ci,{...i,ref:t})})})})}),Si=B.forwardRef((e,t)=>{let n=ci(vi,e.__scopeMenu),r=B.useRef(null),i=M(t,r);return B.useEffect(()=>{let e=r.current;if(e)return ae(e)},[]),(0,H.jsx)(Ti,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:L(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Ci=B.forwardRef((e,t)=>{let n=ci(vi,e.__scopeMenu);return(0,H.jsx)(Ti,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),wi=S(`MenuContent.ScrollLock`),Ti=B.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=ci(vi,n),_=ui(vi,n),v=ai(n),y=oi(n),b=ti(n),[x,S]=B.useState(null),C=B.useRef(null),w=M(t,C,g.onContentChange),T=B.useRef(0),E=B.useRef(``),D=B.useRef(0),A=B.useRef(null),j=B.useRef(`right`),te=B.useRef(0),P=m?O:B.Fragment,ne=m?{as:wi,allowPinchZoom:!0}:void 0,re=e=>{let t=E.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=ca(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){E.current=t,window.clearTimeout(T.current),t!==``&&(T.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};B.useEffect(()=>()=>window.clearTimeout(T.current),[]),N();let F=B.useCallback(e=>j.current===A.current?.side&&ua(e,A.current?.area),[]);return(0,H.jsx)(yi,{scope:n,searchRef:E,onItemEnter:B.useCallback(e=>{F(e)&&e.preventDefault()},[F]),onItemLeave:B.useCallback(e=>{F(e)||(C.current?.focus(),S(null))},[F]),onTriggerLeave:B.useCallback(e=>{F(e)&&e.preventDefault()},[F]),pointerGraceTimerRef:D,onPointerGraceIntentChange:B.useCallback(e=>{A.current=e},[]),children:(0,H.jsx)(P,{...ne,children:(0,H.jsx)(ee,{asChild:!0,trapped:i,onMountAutoFocus:L(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,H.jsx)(k,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,H.jsx)(Gr,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:L(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,H.jsx)(ie,{role:`menu`,"aria-orientation":`vertical`,"data-state":ra(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:w,style:{outline:`none`,...h.style},onKeyDown:L(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&re(e.key));let i=C.current;if(e.target!==i||!Xr.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);Yr.includes(e.key)&&a.reverse(),oa(a)}),onBlur:L(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(T.current),E.current=``)}),onPointerMove:L(e.onPointerMove,da(e=>{let t=e.target,n=te.current!==e.clientX;e.currentTarget.contains(t)&&n&&(j.current=e.clientX>te.current?`right`:`left`,te.current=e.clientX)}))})})})})})})});xi.displayName=vi;var Ei=`MenuGroup`,Di=B.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,H.jsx)(b.div,{role:`group`,...r,ref:t})});Di.displayName=Ei;var Oi=`MenuLabel`,ki=B.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,H.jsx)(b.div,{...r,ref:t})});ki.displayName=Oi;var Ai=`MenuItem`,U=`menu.itemSelect`,ji=B.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=B.useRef(null),o=ui(Ai,e.__scopeMenu),s=bi(Ai,e.__scopeMenu),c=M(t,a),l=B.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(U,{bubbles:!0,cancelable:!0});e.addEventListener(U,e=>r?.(e),{once:!0}),ce(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,H.jsx)(Mi,{...i,ref:c,disabled:n,onClick:L(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:L(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:L(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||qr.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});ji.displayName=Ai;var Mi=B.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=bi(Ai,n),s=oi(n),c=B.useRef(null),l=M(t,c),[u,d]=B.useState(!1),[f,p]=B.useState(``);return B.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,H.jsx)(ei.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,H.jsx)(Kr,{asChild:!0,...s,focusable:!r,children:(0,H.jsx)(b.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:L(e.onPointerMove,da(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:L(e.onPointerLeave,da(e=>o.onItemLeave(e))),onFocus:L(e.onFocus,()=>d(!0)),onBlur:L(e.onBlur,()=>d(!1))})})})}),Ni=`MenuCheckboxItem`,Pi=B.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,H.jsx)(Hi,{scope:e.__scopeMenu,checked:n,children:(0,H.jsx)(ji,{role:`menuitemcheckbox`,"aria-checked":ia(n)?`mixed`:n,...i,ref:t,"data-state":aa(n),onSelect:L(i.onSelect,()=>r?.(ia(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Pi.displayName=Ni;var Fi=`MenuRadioGroup`,[Ii,Li]=ri(Fi,{value:void 0,onValueChange:()=>{}}),Ri=B.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=F(r);return(0,H.jsx)(Ii,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,H.jsx)(Di,{...i,ref:t})})});Ri.displayName=Fi;var zi=`MenuRadioItem`,Bi=B.forwardRef((e,t)=>{let{value:n,...r}=e,i=Li(zi,e.__scopeMenu),a=n===i.value;return(0,H.jsx)(Hi,{scope:e.__scopeMenu,checked:a,children:(0,H.jsx)(ji,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":aa(a),onSelect:L(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});Bi.displayName=zi;var Vi=`MenuItemIndicator`,[Hi,Ui]=ri(Vi,{checked:!1}),Wi=B.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=Ui(Vi,n);return(0,H.jsx)(A,{present:r||ia(a.checked)||a.checked===!0,children:(0,H.jsx)(b.span,{...i,ref:t,"data-state":aa(a.checked)})})});Wi.displayName=Vi;var Gi=`MenuSeparator`,Ki=B.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,H.jsx)(b.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});Ki.displayName=Gi;var qi=`MenuArrow`,Ji=B.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=ai(n);return(0,H.jsx)(ne,{...i,...r,ref:t})});Ji.displayName=qi;var Yi=`MenuSub`,[Xi,Zi]=ri(Yi),Qi=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=ci(Yi,t),o=ai(t),[s,c]=B.useState(null),[l,u]=B.useState(null),d=F(i);return B.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,H.jsx)(te,{...o,children:(0,H.jsx)(si,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,H.jsx)(Xi,{scope:t,contentId:j(),triggerId:j(),trigger:s,onTriggerChange:c,children:n})})})};Qi.displayName=Yi;var $i=`MenuSubTrigger`,ea=B.forwardRef((e,t)=>{let n=ci($i,e.__scopeMenu),r=ui($i,e.__scopeMenu),i=Zi($i,e.__scopeMenu),a=bi($i,e.__scopeMenu),o=B.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=B.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return B.useEffect(()=>u,[u]),B.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]),(0,H.jsx)(pi,{asChild:!0,...l,children:(0,H.jsx)(Mi,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":ra(n.open),...e,ref:C(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:L(e.onPointerMove,da(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:L(e.onPointerLeave,da(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:L(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||Zr[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});ea.displayName=$i;var ta=`MenuSubContent`,na=B.forwardRef((e,t)=>{let n=gi(vi,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=ci(vi,e.__scopeMenu),o=ui(vi,e.__scopeMenu),s=Zi(ta,e.__scopeMenu),c=B.useRef(null),l=M(t,c);return(0,H.jsx)(ei.Provider,{scope:e.__scopeMenu,children:(0,H.jsx)(A,{present:r||a.open,children:(0,H.jsx)(ei.Slot,{scope:e.__scopeMenu,children:(0,H.jsx)(Ti,{id:s.contentId,"aria-labelledby":s.triggerId,...i,ref:l,align:`start`,side:o.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{o.isUsingKeyboardRef.current&&c.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:L(e.onFocusOutside,e=>{e.target!==s.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:L(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:L(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=Qr[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});na.displayName=ta;function ra(e){return e?`open`:`closed`}function ia(e){return e===`indeterminate`}function aa(e){return ia(e)?`indeterminate`:e?`checked`:`unchecked`}function oa(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function sa(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function ca(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=sa(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function la(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function ua(e,t){return t?la({x:e.clientX,y:e.clientY},t):!1}function da(e){return t=>t.pointerType===`mouse`?e(t):void 0}var fa=di,pa=pi,ma=_i,ha=xi,ga=Di,_a=ki,va=ji,ya=Pi,ba=Ri,xa=Bi,Sa=Wi,Ca=Ki,wa=Ji,Ta=Qi,Ea=ea,Da=na,Oa=`ContextMenu`,[ka,Aa]=w(Oa,[ii]),ja=ii(),[Ma,Na]=ka(Oa),Pa=e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,dir:i,modal:a=!0}=e,[o,s]=B.useState(!1),c=ja(t),l=F(r),u=B.useCallback(e=>{s(e),l(e)},[l]);return(0,H.jsx)(Ma,{scope:t,open:o,onOpenChange:u,modal:a,children:(0,H.jsx)(fa,{...c,dir:i,open:o,onOpenChange:u,modal:a,children:n})})};Pa.displayName=Oa;var Fa=`ContextMenuTrigger`,Ia=B.forwardRef((e,t)=>{let{__scopeContextMenu:n,disabled:r=!1,...i}=e,a=Na(Fa,n),o=ja(n),s=B.useRef({x:0,y:0}),c=B.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...s.current})}),l=B.useRef(0),u=B.useCallback(()=>window.clearTimeout(l.current),[]),d=e=>{s.current={x:e.clientX,y:e.clientY},a.onOpenChange(!0)};return B.useEffect(()=>u,[u]),B.useEffect(()=>void(r&&u()),[r,u]),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(pa,{...o,virtualRef:c}),(0,H.jsx)(b.span,{"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,...i,ref:t,style:{WebkitTouchCallout:`none`,...e.style},onContextMenu:r?e.onContextMenu:L(e.onContextMenu,e=>{u(),d(e),e.preventDefault()}),onPointerDown:r?e.onPointerDown:L(e.onPointerDown,uo(e=>{u(),l.current=window.setTimeout(()=>d(e),700)})),onPointerMove:r?e.onPointerMove:L(e.onPointerMove,uo(u)),onPointerCancel:r?e.onPointerCancel:L(e.onPointerCancel,uo(u)),onPointerUp:r?e.onPointerUp:L(e.onPointerUp,uo(u))})]})});Ia.displayName=Fa;var La=`ContextMenuPortal`,Ra=e=>{let{__scopeContextMenu:t,...n}=e,r=ja(t);return(0,H.jsx)(ma,{...r,...n})};Ra.displayName=La;var za=`ContextMenuContent`,Ba=B.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=Na(za,n),a=ja(n),o=B.useRef(!1);return(0,H.jsx)(ha,{...a,...r,ref:t,side:`right`,sideOffset:2,align:`start`,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),!t.defaultPrevented&&o.current&&t.preventDefault(),o.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),!t.defaultPrevented&&!i.modal&&(o.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Ba.displayName=za;var Va=`ContextMenuGroup`,Ha=B.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ja(n);return(0,H.jsx)(ga,{...i,...r,ref:t})});Ha.displayName=Va;var Ua=`ContextMenuLabel`,Wa=B.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ja(n);return(0,H.jsx)(_a,{...i,...r,ref:t})});Wa.displayName=Ua;var Ga=`ContextMenuItem`,Ka=B.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ja(n);return(0,H.jsx)(va,{...i,...r,ref:t})});Ka.displayName=Ga;var qa=`ContextMenuCheckboxItem`,Ja=B.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ja(n);return(0,H.jsx)(ya,{...i,...r,ref:t})});Ja.displayName=qa;var Ya=`ContextMenuRadioGroup`,Xa=B.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ja(n);return(0,H.jsx)(ba,{...i,...r,ref:t})});Xa.displayName=Ya;var Za=`ContextMenuRadioItem`,Qa=B.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ja(n);return(0,H.jsx)(xa,{...i,...r,ref:t})});Qa.displayName=Za;var $a=`ContextMenuItemIndicator`,eo=B.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ja(n);return(0,H.jsx)(Sa,{...i,...r,ref:t})});eo.displayName=$a;var to=`ContextMenuSeparator`,no=B.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ja(n);return(0,H.jsx)(Ca,{...i,...r,ref:t})});no.displayName=to;var ro=`ContextMenuArrow`,io=B.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ja(n);return(0,H.jsx)(wa,{...i,...r,ref:t})});io.displayName=ro;var ao=`ContextMenuSub`,oo=e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,open:i,defaultOpen:a}=e,o=ja(t),[s,c]=T({prop:i,defaultProp:a??!1,onChange:r,caller:ao});return(0,H.jsx)(Ta,{...o,open:s,onOpenChange:c,children:n})};oo.displayName=ao;var so=`ContextMenuSubTrigger`,co=B.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ja(n);return(0,H.jsx)(Ea,{...i,...r,ref:t})});co.displayName=so;var W=`ContextMenuSubContent`,lo=B.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ja(n);return(0,H.jsx)(Da,{...i,...r,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});lo.displayName=W;function uo(e){return t=>t.pointerType===`mouse`?void 0:e(t)}var fo=Pa,po=Ia,mo=Ra,ho=Ba,go=Ka,_o=no,vo=`DropdownMenu`,[yo,bo]=w(vo,[ii]),xo=ii(),[So,Co]=yo(vo),wo=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=xo(t),l=B.useRef(null),[u,d]=T({prop:i,defaultProp:a??!1,onChange:o,caller:vo});return(0,H.jsx)(So,{scope:t,triggerId:j(),triggerRef:l,contentId:j(),open:u,onOpenChange:d,onOpenToggle:B.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,H.jsx)(fa,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};wo.displayName=vo;var To=`DropdownMenuTrigger`,Eo=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=Co(To,n),o=xo(n);return(0,H.jsx)(pa,{asChild:!0,...o,children:(0,H.jsx)(b.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:C(t,a.triggerRef),onPointerDown:L(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:L(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});Eo.displayName=To;var Do=`DropdownMenuPortal`,Oo=e=>{let{__scopeDropdownMenu:t,...n}=e,r=xo(t);return(0,H.jsx)(ma,{...r,...n})};Oo.displayName=Do;var ko=`DropdownMenuContent`,Ao=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Co(ko,n),a=xo(n),o=B.useRef(!1);return(0,H.jsx)(ha,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:L(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:L(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Ao.displayName=ko;var jo=`DropdownMenuGroup`,Mo=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=xo(n);return(0,H.jsx)(ga,{...i,...r,ref:t})});Mo.displayName=jo;var No=`DropdownMenuLabel`,Po=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=xo(n);return(0,H.jsx)(_a,{...i,...r,ref:t})});Po.displayName=No;var Fo=`DropdownMenuItem`,Io=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=xo(n);return(0,H.jsx)(va,{...i,...r,ref:t})});Io.displayName=Fo;var Lo=`DropdownMenuCheckboxItem`,Ro=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=xo(n);return(0,H.jsx)(ya,{...i,...r,ref:t})});Ro.displayName=Lo;var zo=`DropdownMenuRadioGroup`,Bo=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=xo(n);return(0,H.jsx)(ba,{...i,...r,ref:t})});Bo.displayName=zo;var Vo=`DropdownMenuRadioItem`,Ho=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=xo(n);return(0,H.jsx)(xa,{...i,...r,ref:t})});Ho.displayName=Vo;var Uo=`DropdownMenuItemIndicator`,Wo=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=xo(n);return(0,H.jsx)(Sa,{...i,...r,ref:t})});Wo.displayName=Uo;var Go=`DropdownMenuSeparator`,Ko=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=xo(n);return(0,H.jsx)(Ca,{...i,...r,ref:t})});Ko.displayName=Go;var qo=`DropdownMenuArrow`,Jo=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=xo(n);return(0,H.jsx)(wa,{...i,...r,ref:t})});Jo.displayName=qo;var Yo=e=>{let{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:a}=e,o=xo(t),[s,c]=T({prop:r,defaultProp:a??!1,onChange:i,caller:`DropdownMenuSub`});return(0,H.jsx)(Ta,{...o,open:s,onOpenChange:c,children:n})},Xo=`DropdownMenuSubTrigger`,Zo=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=xo(n);return(0,H.jsx)(Ea,{...i,...r,ref:t})});Zo.displayName=Xo;var Qo=`DropdownMenuSubContent`,$o=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=xo(n);return(0,H.jsx)(Da,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});$o.displayName=Qo;var es=wo,ts=Eo,ns=Oo,rs=Ao,is=Io,as=Yo,os=Zo,ss=$o,cs=`Label`,ls=B.forwardRef((e,t)=>(0,H.jsx)(b.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));ls.displayName=cs;var us=ls;function ds(e,[t,n]){return Math.min(n,Math.max(t,e))}function fs(e,t){return B.useReducer((e,n)=>t[e][n]??e,e)}var ps=`ScrollArea`,[ms,hs]=w(ps),[gs,_s]=ms(ps),vs=B.forwardRef((e,t)=>{let{__scopeScrollArea:n,type:r=`hover`,dir:i,scrollHideDelay:a=600,...o}=e,[s,c]=B.useState(null),[l,u]=B.useState(null),[d,f]=B.useState(null),[p,m]=B.useState(null),[h,g]=B.useState(null),[_,v]=B.useState(0),[y,x]=B.useState(0),[S,C]=B.useState(!1),[w,T]=B.useState(!1),E=M(t,e=>c(e)),D=P(i);return(0,H.jsx)(gs,{scope:n,type:r,dir:D,scrollHideDelay:a,scrollArea:s,viewport:l,onViewportChange:u,content:d,onContentChange:f,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:S,onScrollbarXEnabledChange:C,scrollbarY:h,onScrollbarYChange:g,scrollbarYEnabled:w,onScrollbarYEnabledChange:T,onCornerWidthChange:v,onCornerHeightChange:x,children:(0,H.jsx)(b.div,{dir:D,...o,ref:E,style:{position:`relative`,"--radix-scroll-area-corner-width":_+`px`,"--radix-scroll-area-corner-height":y+`px`,...e.style}})})});vs.displayName=ps;var ys=`ScrollAreaViewport`,bs=B.forwardRef((e,t)=>{let{__scopeScrollArea:n,children:r,nonce:i,...a}=e,o=_s(ys,n),s=M(t,B.useRef(null),o.onViewportChange);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}`},nonce:i}),(0,H.jsx)(b.div,{"data-radix-scroll-area-viewport":``,...a,ref:s,style:{overflowX:o.scrollbarXEnabled?`scroll`:`hidden`,overflowY:o.scrollbarYEnabled?`scroll`:`hidden`,...e.style},children:(0,H.jsx)(`div`,{ref:o.onContentChange,style:{minWidth:`100%`,display:`table`},children:r})})]})});bs.displayName=ys;var xs=`ScrollAreaScrollbar`,Ss=B.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=_s(xs,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=i,s=e.orientation===`horizontal`;return B.useEffect(()=>(s?a(!0):o(!0),()=>{s?a(!1):o(!1)}),[s,a,o]),i.type===`hover`?(0,H.jsx)(Cs,{...r,ref:t,forceMount:n}):i.type===`scroll`?(0,H.jsx)(ws,{...r,ref:t,forceMount:n}):i.type===`auto`?(0,H.jsx)(Ts,{...r,ref:t,forceMount:n}):i.type===`always`?(0,H.jsx)(Es,{...r,ref:t}):null});Ss.displayName=xs;var Cs=B.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=_s(xs,e.__scopeScrollArea),[a,o]=B.useState(!1);return B.useEffect(()=>{let e=i.scrollArea,t=0;if(e){let n=()=>{window.clearTimeout(t),o(!0)},r=()=>{t=window.setTimeout(()=>o(!1),i.scrollHideDelay)};return e.addEventListener(`pointerenter`,n),e.addEventListener(`pointerleave`,r),()=>{window.clearTimeout(t),e.removeEventListener(`pointerenter`,n),e.removeEventListener(`pointerleave`,r)}}},[i.scrollArea,i.scrollHideDelay]),(0,H.jsx)(A,{present:n||a,children:(0,H.jsx)(Ts,{"data-state":a?`visible`:`hidden`,...r,ref:t})})}),ws=B.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=_s(xs,e.__scopeScrollArea),a=e.orientation===`horizontal`,o=Ks(()=>c(`SCROLL_END`),100),[s,c]=fs(`hidden`,{hidden:{SCROLL:`scrolling`},scrolling:{SCROLL_END:`idle`,POINTER_ENTER:`interacting`},interacting:{SCROLL:`interacting`,POINTER_LEAVE:`idle`},idle:{HIDE:`hidden`,SCROLL:`scrolling`,POINTER_ENTER:`interacting`}});return B.useEffect(()=>{if(s===`idle`){let e=window.setTimeout(()=>c(`HIDE`),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[s,i.scrollHideDelay,c]),B.useEffect(()=>{let e=i.viewport,t=a?`scrollLeft`:`scrollTop`;if(e){let n=e[t],r=()=>{let r=e[t];n!==r&&(c(`SCROLL`),o()),n=r};return e.addEventListener(`scroll`,r),()=>e.removeEventListener(`scroll`,r)}},[i.viewport,a,c,o]),(0,H.jsx)(A,{present:n||s!==`hidden`,children:(0,H.jsx)(Es,{"data-state":s===`hidden`?`hidden`:`visible`,...r,ref:t,onPointerEnter:L(e.onPointerEnter,()=>c(`POINTER_ENTER`)),onPointerLeave:L(e.onPointerLeave,()=>c(`POINTER_LEAVE`))})})}),Ts=B.forwardRef((e,t)=>{let n=_s(xs,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,o]=B.useState(!1),s=e.orientation===`horizontal`,c=Ks(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(s?e:t)}},10);return qs(n.viewport,c),qs(n.content,c),(0,H.jsx)(A,{present:r||a,children:(0,H.jsx)(Es,{"data-state":a?`visible`:`hidden`,...i,ref:t})})}),Es=B.forwardRef((e,t)=>{let{orientation:n=`vertical`,...r}=e,i=_s(xs,e.__scopeScrollArea),a=B.useRef(null),o=B.useRef(0),[s,c]=B.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=zs(s.viewport,s.content),u={...r,sizes:s,onSizesChange:c,hasThumb:l>0&&l<1,onThumbChange:e=>a.current=e,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:e=>o.current=e};function d(e,t){return Vs(e,o.current,s,t)}return n===`horizontal`?(0,H.jsx)(Ds,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=Hs(e,s,i.dir);a.current.style.transform=`translate3d(${t}px, 0, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollLeft=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollLeft=d(e,i.dir))}}):n===`vertical`?(0,H.jsx)(Os,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=Hs(e,s);a.current.style.transform=`translate3d(0, ${t}px, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollTop=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollTop=d(e))}}):null}),Ds=B.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=_s(xs,e.__scopeScrollArea),[o,s]=B.useState(),c=B.useRef(null),l=M(t,c,a.onScrollbarXChange);return B.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,H.jsx)(js,{"data-orientation":`horizontal`,...i,ref:l,sizes:n,style:{bottom:0,left:a.dir===`rtl`?`var(--radix-scroll-area-corner-width)`:0,right:a.dir===`ltr`?`var(--radix-scroll-area-corner-width)`:0,"--radix-scroll-area-thumb-width":Bs(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),Ws(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Rs(o.paddingLeft),paddingEnd:Rs(o.paddingRight)}})}})}),Os=B.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=_s(xs,e.__scopeScrollArea),[o,s]=B.useState(),c=B.useRef(null),l=M(t,c,a.onScrollbarYChange);return B.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,H.jsx)(js,{"data-orientation":`vertical`,...i,ref:l,sizes:n,style:{top:0,right:a.dir===`ltr`?0:void 0,left:a.dir===`rtl`?0:void 0,bottom:`var(--radix-scroll-area-corner-height)`,"--radix-scroll-area-thumb-height":Bs(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),Ws(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Rs(o.paddingTop),paddingEnd:Rs(o.paddingBottom)}})}})}),[ks,As]=ms(xs),js=B.forwardRef((e,t)=>{let{__scopeScrollArea:n,sizes:r,hasThumb:i,onThumbChange:a,onThumbPointerUp:o,onThumbPointerDown:s,onThumbPositionChange:c,onDragScroll:l,onWheelScroll:u,onResize:d,...f}=e,p=_s(xs,n),[m,h]=B.useState(null),g=M(t,e=>h(e)),_=B.useRef(null),v=B.useRef(``),y=p.viewport,x=r.content-r.viewport,S=F(u),C=F(c),w=Ks(d,10);function T(e){_.current&&l({x:e.clientX-_.current.left,y:e.clientY-_.current.top})}return B.useEffect(()=>{let e=e=>{let t=e.target;m?.contains(t)&&S(e,x)};return document.addEventListener(`wheel`,e,{passive:!1}),()=>document.removeEventListener(`wheel`,e,{passive:!1})},[y,m,x,S]),B.useEffect(C,[r,C]),qs(m,w),qs(p.content,w),(0,H.jsx)(ks,{scope:n,scrollbar:m,hasThumb:i,onThumbChange:F(a),onThumbPointerUp:F(o),onThumbPositionChange:C,onThumbPointerDown:F(s),children:(0,H.jsx)(b.div,{...f,ref:g,style:{position:`absolute`,...f.style},onPointerDown:L(e.onPointerDown,e=>{e.button===0&&(e.target.setPointerCapture(e.pointerId),_.current=m.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect=`none`,p.viewport&&(p.viewport.style.scrollBehavior=`auto`),T(e))}),onPointerMove:L(e.onPointerMove,T),onPointerUp:L(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=v.current,p.viewport&&(p.viewport.style.scrollBehavior=``),_.current=null})})})}),Ms=`ScrollAreaThumb`,Ns=B.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=As(Ms,e.__scopeScrollArea);return(0,H.jsx)(A,{present:n||i.hasThumb,children:(0,H.jsx)(Ps,{ref:t,...r})})}),Ps=B.forwardRef((e,t)=>{let{__scopeScrollArea:n,style:r,...i}=e,a=_s(Ms,n),o=As(Ms,n),{onThumbPositionChange:s}=o,c=M(t,e=>o.onThumbChange(e)),l=B.useRef(void 0),u=Ks(()=>{l.current&&=(l.current(),void 0)},100);return B.useEffect(()=>{let e=a.viewport;if(e){let t=()=>{u(),l.current||(l.current=Gs(e,s),s())};return s(),e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)}},[a.viewport,u,s]),(0,H.jsx)(b.div,{"data-state":o.hasThumb?`visible`:`hidden`,...i,ref:c,style:{width:`var(--radix-scroll-area-thumb-width)`,height:`var(--radix-scroll-area-thumb-height)`,...r},onPointerDownCapture:L(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;o.onThumbPointerDown({x:n,y:r})}),onPointerUp:L(e.onPointerUp,o.onThumbPointerUp)})});Ns.displayName=Ms;var Fs=`ScrollAreaCorner`,Is=B.forwardRef((e,t)=>{let n=_s(Fs,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,H.jsx)(Ls,{...e,ref:t}):null});Is.displayName=Fs;var Ls=B.forwardRef((e,t)=>{let{__scopeScrollArea:n,...r}=e,i=_s(Fs,n),[a,o]=B.useState(0),[s,c]=B.useState(0),l=!!(a&&s);return qs(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),c(e)}),qs(i.scrollbarY,()=>{let e=i.scrollbarY?.offsetWidth||0;i.onCornerWidthChange(e),o(e)}),l?(0,H.jsx)(b.div,{...r,ref:t,style:{width:a,height:s,position:`absolute`,right:i.dir===`ltr`?0:void 0,left:i.dir===`rtl`?0:void 0,bottom:0,...e.style}}):null});function Rs(e){return e?parseInt(e,10):0}function zs(e,t){let n=e/t;return isNaN(n)?0:n}function Bs(e){let t=zs(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Vs(e,t,n,r=`ltr`){let i=Bs(n),a=i/2,o=t||a,s=i-o,c=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-s,u=n.content-n.viewport,d=r===`ltr`?[0,u]:[u*-1,0];return Us([c,l],d)(e)}function Hs(e,t,n=`ltr`){let r=Bs(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=ds(e,n===`ltr`?[0,o]:[o*-1,0]);return Us([0,o],[0,s])(c)}function Us(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Ws(e,t){return e>0&&e<t}var Gs=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return(function i(){let a={left:e.scrollLeft,top:e.scrollTop},o=n.left!==a.left,s=n.top!==a.top;(o||s)&&t(),n=a,r=window.requestAnimationFrame(i)})(),()=>window.cancelAnimationFrame(r)};function Ks(e,t){let n=F(e),r=B.useRef(0);return B.useEffect(()=>()=>window.clearTimeout(r.current),[]),B.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function qs(e,t){let n=F(t);se(()=>{let t=0;if(e){let r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}var Js=vs,Ys=bs,Xs=Is,Zs=[` `,`Enter`,`ArrowUp`,`ArrowDown`],Qs=[` `,`Enter`],$s=`Select`,[ec,tc,nc]=D($s),[rc,ic]=w($s,[nc,E]),ac=E(),[oc,sc]=rc($s),[cc,lc]=rc($s),uc=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m}=e,h=ac(t),[g,_]=B.useState(null),[v,y]=B.useState(null),[b,x]=B.useState(!1),S=P(l),[C,w]=T({prop:r,defaultProp:i??!1,onChange:a,caller:$s}),[E,D]=T({prop:o,defaultProp:s,onChange:c,caller:$s}),O=B.useRef(null),ee=g?m||!!g.closest(`form`):!0,[k,A]=B.useState(new Set),M=Array.from(k).map(e=>e.props.value).join(`;`);return(0,H.jsx)(te,{...h,children:(0,H.jsxs)(oc,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:x,contentId:j(),value:E,onValueChange:D,open:C,onOpenChange:w,dir:S,triggerPointerDownPosRef:O,disabled:f,children:[(0,H.jsx)(ec.Provider,{scope:t,children:(0,H.jsx)(cc,{scope:e.__scopeSelect,onNativeOptionAdd:B.useCallback(e=>{A(t=>new Set(t).add(e))},[]),onNativeOptionRemove:B.useCallback(e=>{A(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),ee?(0,H.jsxs)(al,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:E,onChange:e=>D(e.target.value),disabled:f,form:m,children:[E===void 0?(0,H.jsx)(`option`,{value:``}):null,Array.from(k)]},M):null]})})};uc.displayName=$s;var dc=`SelectTrigger`,fc=B.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=ac(n),o=sc(dc,n),s=o.disabled||r,c=M(t,o.onTriggerChange),l=tc(n),u=B.useRef(`touch`),[d,f,p]=sl(e=>{let t=l().filter(e=>!e.disabled),n=cl(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,H.jsx)(I,{asChild:!0,...a,children:(0,H.jsx)(b.button,{type:`button`,role:`combobox`,"aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":ol(o.value)?``:void 0,...i,ref:c,onClick:L(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:L(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:L(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&Zs.includes(e.key)&&(m(),e.preventDefault())})})})});fc.displayName=dc;var pc=`SelectValue`,mc=B.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=sc(pc,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=M(t,c.onValueNodeChange);return se(()=>{l(u)},[l,u]),(0,H.jsx)(b.span,{...s,ref:d,style:{pointerEvents:`none`},children:ol(c.value)?(0,H.jsx)(H.Fragment,{children:o}):a})});mc.displayName=pc;var hc=`SelectIcon`,gc=B.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,H.jsx)(b.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});gc.displayName=hc;var _c=`SelectPortal`,vc=e=>(0,H.jsx)(oe,{asChild:!0,...e});vc.displayName=_c;var yc=`SelectContent`,bc=B.forwardRef((e,t)=>{let n=sc(yc,e.__scopeSelect),[r,i]=B.useState();if(se(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?Yt.createPortal((0,H.jsx)(Sc,{scope:e.__scopeSelect,children:(0,H.jsx)(ec.Slot,{scope:e.__scopeSelect,children:(0,H.jsx)(`div`,{children:e.children})})}),t):null}return(0,H.jsx)(Ec,{...e,ref:t})});bc.displayName=yc;var xc=10,[Sc,Cc]=rc(yc),wc=`SelectContentImpl`,Tc=S(`SelectContent.RemoveScroll`),Ec=B.forwardRef((e,t)=>{let{__scopeSelect:n,position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=sc(yc,n),[y,b]=B.useState(null),[x,S]=B.useState(null),C=M(t,e=>b(e)),[w,T]=B.useState(null),[E,D]=B.useState(null),A=tc(n),[j,te]=B.useState(!1),P=B.useRef(!1);B.useEffect(()=>{if(y)return ae(y)},[y]),N();let ne=B.useCallback(e=>{let[t,...n]=A().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[A,x]),re=B.useCallback(()=>ne([w,y]),[ne,w,y]);B.useEffect(()=>{j&&re()},[j,re]);let{onOpenChange:F,triggerPointerDownPosRef:ie}=v;B.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(ie.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(ie.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():y.contains(n.target)||F(!1),document.removeEventListener(`pointermove`,t),ie.current=null};return ie.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,F,ie]),B.useEffect(()=>{let e=()=>F(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[F]);let[I,oe]=sl(e=>{let t=A().filter(e=>!e.disabled),n=cl(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),se=B.useCallback((e,t,n)=>{let r=!P.current&&!n;(v.value!==void 0&&v.value===t||r)&&(T(e),r&&(P.current=!0))},[v.value]),ce=B.useCallback(()=>y?.focus(),[y]),le=B.useCallback((e,t,n)=>{let r=!P.current&&!n;(v.value!==void 0&&v.value===t||r)&&D(e)},[v.value]),R=r===`popper`?Ac:Oc,ue=R===Ac?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,H.jsx)(Sc,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:se,selectedItem:w,onItemLeave:ce,itemTextRefCallback:le,focusSelectedItem:re,selectedItemText:E,position:r,isPositioned:j,searchRef:I,children:(0,H.jsx)(O,{as:Tc,allowPinchZoom:!0,children:(0,H.jsx)(ee,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:L(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,H.jsx)(k,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,H.jsx)(R,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...ue,onPlaced:()=>te(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:L(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&oe(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=A().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>ne(t)),e.preventDefault()}})})})})})})});Ec.displayName=wc;var Dc=`SelectItemAlignedPosition`,Oc=B.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=sc(yc,n),o=Cc(yc,n),[s,c]=B.useState(null),[l,u]=B.useState(null),d=M(t,e=>u(e)),f=tc(n),p=B.useRef(!1),m=B.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=B.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-xc,d=ds(a,[xc,Math.max(xc,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-xc,d=ds(a,[xc,Math.max(xc,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-xc*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-xc,D=c-E,O=g.offsetHeight/2,ee=g.offsetTop+O,k=m+v+ee,A=x-k;if(k<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=k+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+A;s.style.height=t+`px`,h.scrollTop=k-E+h.offsetTop}s.style.margin=`${xc}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);se(()=>y(),[y]);let[x,S]=B.useState();return se(()=>{l&&S(window.getComputedStyle(l).zIndex)},[l]),(0,H.jsx)(jc,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:B.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]),children:(0,H.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:x},children:(0,H.jsx)(b.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});Oc.displayName=Dc;var kc=`SelectPopperPosition`,Ac=B.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=xc,...a}=e,o=ac(n);return(0,H.jsx)(ie,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});Ac.displayName=kc;var[jc,Mc]=rc(yc,{}),Nc=`SelectViewport`,Pc=B.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=Cc(Nc,n),o=Mc(Nc,n),s=M(t,a.onViewportChange),c=B.useRef(0);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,H.jsx)(ec.Slot,{scope:n,children:(0,H.jsx)(b.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:L(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-xc*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});Pc.displayName=Nc;var Fc=`SelectGroup`,[Ic,Lc]=rc(Fc),Rc=B.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=j();return(0,H.jsx)(Ic,{scope:n,id:i,children:(0,H.jsx)(b.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});Rc.displayName=Fc;var zc=`SelectLabel`,Bc=B.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Lc(zc,n);return(0,H.jsx)(b.div,{id:i.id,...r,ref:t})});Bc.displayName=zc;var Vc=`SelectItem`,[Hc,Uc]=rc(Vc),Wc=B.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=sc(Vc,n),c=Cc(Vc,n),l=s.value===r,[u,d]=B.useState(a??``),[f,p]=B.useState(!1),m=M(t,e=>c.itemRefCallback?.(e,r,i)),h=j(),g=B.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};if(r===``)throw Error(`A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,H.jsx)(Hc,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:B.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,H.jsx)(ec.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,H.jsx)(b.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:L(o.onFocus,()=>p(!0)),onBlur:L(o.onBlur,()=>p(!1)),onClick:L(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:L(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:L(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:L(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:L(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:L(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(Qs.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});Wc.displayName=Vc;var Gc=`SelectItemText`,Kc=B.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=sc(Gc,n),s=Cc(Gc,n),c=Uc(Gc,n),l=lc(Gc,n),[u,d]=B.useState(null),f=M(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=B.useMemo(()=>(0,H.jsx)(`option`,{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:g}=l;return se(()=>(h(m),()=>g(m)),[h,g,m]),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(b.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Yt.createPortal(a.children,o.valueNode):null]})});Kc.displayName=Gc;var qc=`SelectItemIndicator`,Jc=B.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return Uc(qc,n).isSelected?(0,H.jsx)(b.span,{"aria-hidden":!0,...r,ref:t}):null});Jc.displayName=qc;var Yc=`SelectScrollUpButton`,Xc=B.forwardRef((e,t)=>{let n=Cc(Yc,e.__scopeSelect),r=Mc(Yc,e.__scopeSelect),[i,a]=B.useState(!1),o=M(t,r.onScrollButtonChange);return se(()=>{if(n.viewport&&n.isPositioned){let e=function(){a(t.scrollTop>0)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,H.jsx)($c,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});Xc.displayName=Yc;var Zc=`SelectScrollDownButton`,Qc=B.forwardRef((e,t)=>{let n=Cc(Zc,e.__scopeSelect),r=Mc(Zc,e.__scopeSelect),[i,a]=B.useState(!1),o=M(t,r.onScrollButtonChange);return se(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight;a(Math.ceil(t.scrollTop)<e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,H.jsx)($c,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});Qc.displayName=Zc;var $c=B.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=Cc(`SelectScrollButton`,n),o=B.useRef(null),s=tc(n),c=B.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return B.useEffect(()=>()=>c(),[c]),se(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,H.jsx)(b.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:L(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:L(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:L(i.onPointerLeave,()=>{c()})})}),el=`SelectSeparator`,tl=B.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,H.jsx)(b.div,{"aria-hidden":!0,...r,ref:t})});tl.displayName=el;var nl=`SelectArrow`,rl=B.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=ac(n),a=sc(nl,n),o=Cc(nl,n);return a.open&&o.position===`popper`?(0,H.jsx)(ne,{...i,...r,ref:t}):null});rl.displayName=nl;var il=`SelectBubbleInput`,al=B.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=B.useRef(null),a=M(r,i),o=Tr(t);return B.useEffect(()=>{let e=i.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(o!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[o,t]),(0,H.jsx)(b.select,{...n,style:{...Pn,...n.style},ref:a,defaultValue:t})});al.displayName=il;function ol(e){return e===``||e===void 0}function sl(e){let t=F(e),n=B.useRef(``),r=B.useRef(0),i=B.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=B.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return B.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function cl(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=ll(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function ll(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var ul=uc,dl=fc,fl=mc,pl=gc,ml=vc,hl=bc,gl=Pc,_l=Wc,vl=Kc,yl=Jc,bl=Xc,xl=Qc,Sl=`Separator`,Cl=`horizontal`,wl=[`horizontal`,`vertical`],Tl=B.forwardRef((e,t)=>{let{decorative:n,orientation:r=Cl,...i}=e,a=El(r)?r:Cl,o=a===`vertical`?a:void 0,s=n?{role:`none`}:{"aria-orientation":o,role:`separator`};return(0,H.jsx)(b.div,{"data-orientation":a,...s,...i,ref:t})});Tl.displayName=Sl;function El(e){return wl.includes(e)}var Dl=Tl,Ol=`Switch`,[kl,Al]=w(Ol),[jl,Ml]=kl(Ol),Nl=B.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c=`on`,onCheckedChange:l,form:u,...d}=e,[f,p]=B.useState(null),m=M(t,e=>p(e)),h=B.useRef(!1),g=f?u||!!f.closest(`form`):!0,[_,v]=T({prop:i,defaultProp:a??!1,onChange:l,caller:Ol});return(0,H.jsxs)(jl,{scope:n,checked:_,disabled:s,children:[(0,H.jsx)(b.button,{type:`button`,role:`switch`,"aria-checked":_,"aria-required":o,"data-state":Rl(_),"data-disabled":s?``:void 0,disabled:s,value:c,...d,ref:m,onClick:L(e.onClick,e=>{v(e=>!e),g&&(h.current=e.isPropagationStopped(),h.current||e.stopPropagation())})}),g&&(0,H.jsx)(Ll,{control:f,bubbles:!h.current,name:r,value:c,checked:_,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`}})]})});Nl.displayName=Ol;var Pl=`SwitchThumb`,Fl=B.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=Ml(Pl,n);return(0,H.jsx)(b.span,{"data-state":Rl(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});Fl.displayName=Pl;var Il=`SwitchBubbleInput`,Ll=B.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=B.useRef(null),s=M(o,a),c=Tr(n),l=re(t);return B.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(c!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[c,n,r]),(0,H.jsx)(`input`,{type:`checkbox`,"aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...l,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});Ll.displayName=Il;function Rl(e){return e?`checked`:`unchecked`}var zl=Nl,G=Fl,[K,q]=w(`Tooltip`,[E]),J=E(),Y=`TooltipProvider`,Bl=700,Vl=`tooltip.open`,[Hl,Ul]=K(Y),Wl=e=>{let{__scopeTooltip:t,delayDuration:n=Bl,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=B.useRef(!0),s=B.useRef(!1),c=B.useRef(0);return B.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,H.jsx)(Hl,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:B.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:B.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:B.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};Wl.displayName=Y;var Gl=`Tooltip`,[Kl,ql]=K(Gl),Jl=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=Ul(Gl,e.__scopeTooltip),l=J(t),[u,d]=B.useState(null),f=j(),p=B.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=B.useRef(!1),[_,v]=T({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(Vl))):c.onClose(),a?.(e)},caller:Gl}),y=B.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=B.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=B.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=B.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return B.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,H.jsx)(te,{...l,children:(0,H.jsx)(Kl,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:B.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:B.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};Jl.displayName=Gl;var Yl=`TooltipTrigger`,Xl=B.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=ql(Yl,n),a=Ul(Yl,n),o=J(n),s=M(t,B.useRef(null),i.onTriggerChange),c=B.useRef(!1),l=B.useRef(!1),u=B.useCallback(()=>c.current=!1,[]);return B.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,H.jsx)(I,{asChild:!0,...o,children:(0,H.jsx)(b.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:L(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:L(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:L(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:L(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:L(e.onBlur,i.onClose),onClick:L(e.onClick,i.onClose)})})});Xl.displayName=Yl;var Zl=`TooltipPortal`,[Ql,$l]=K(Zl,{forceMount:void 0}),eu=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=ql(Zl,t);return(0,H.jsx)(Ql,{scope:t,forceMount:n,children:(0,H.jsx)(A,{present:n||a.open,children:(0,H.jsx)(oe,{asChild:!0,container:i,children:r})})})};eu.displayName=Zl;var tu=`TooltipContent`,nu=B.forwardRef((e,t)=>{let n=$l(tu,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=ql(tu,e.__scopeTooltip);return(0,H.jsx)(A,{present:r||o.open,children:o.disableHoverableContent?(0,H.jsx)(su,{side:i,...a,ref:t}):(0,H.jsx)(ru,{side:i,...a,ref:t})})}),ru=B.forwardRef((e,t)=>{let n=ql(tu,e.__scopeTooltip),r=Ul(tu,e.__scopeTooltip),i=B.useRef(null),a=M(t,i),[o,s]=B.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=B.useCallback(()=>{s(null),d(!1)},[d]),p=B.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=du(r,uu(r,n.getBoundingClientRect())),a=fu(t.getBoundingClientRect());s(mu([...i,...a])),d(!0)},[d]);return B.useEffect(()=>()=>f(),[f]),B.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),B.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!pu(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,H.jsx)(su,{...e,ref:a})}),[iu,au]=K(Gl,{isInside:!1}),ou=x(`TooltipContent`),su=B.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=ql(tu,n),l=J(n),{onClose:u}=c;return B.useEffect(()=>(document.addEventListener(Vl,u),()=>document.removeEventListener(Vl,u)),[u]),B.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,H.jsx)(k,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,H.jsxs)(ie,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,H.jsx)(ou,{children:r}),(0,H.jsx)(iu,{scope:n,isInside:!0,children:(0,H.jsx)(Ln,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});nu.displayName=tu;var cu=`TooltipArrow`,lu=B.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=J(n);return au(cu,n).isInside?null:(0,H.jsx)(ne,{...i,...r,ref:t})});lu.displayName=cu;function uu(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function du(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function fu(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function pu(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function mu(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0),hu(t)}function hu(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var gu=Wl,_u=Jl,vu=Xl,yu=eu,bu=nu,xu=lu;function Su({delayDuration:e=0,...t}){return(0,H.jsx)(gu,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Cu({...e}){return(0,H.jsx)(_u,{"data-slot":`tooltip`,...e})}function wu({...e}){return(0,H.jsx)(vu,{"data-slot":`tooltip-trigger`,...e})}function Tu({className:e,sideOffset:t=0,children:n,...r}){return(0,H.jsx)(yu,{children:(0,H.jsxs)(bu,{"data-slot":`tooltip-content`,sideOffset:t,className:R(`z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-foreground px-3 py-1.5 text-xs text-balance text-background fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95`,e),...r,children:[n,(0,H.jsx)(xu,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground`})]})})}function Eu(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function Du(e,t){let n=getComputedStyle(e.ownerDocument.body);return t*parseFloat(n.fontSize)}function Ou(e){return e/100*window.innerHeight}function ku(e){return e/100*window.innerWidth}function Au(e){switch(typeof e){case`number`:return[e,`px`];case`string`:{let t=parseFloat(e);return e.endsWith(`%`)?[t,`%`]:e.endsWith(`px`)?[t,`px`]:e.endsWith(`rem`)?[t,`rem`]:e.endsWith(`em`)?[t,`em`]:e.endsWith(`vh`)?[t,`vh`]:e.endsWith(`vw`)?[t,`vw`]:[t,`%`]}}}function ju({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=Au(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=Du(t,i);break;case`em`:r=Eu(t,i);break;case`vh`:r=Ou(i);break;case`vw`:r=ku(i);break}return r}function Mu(e){return parseFloat(e.toFixed(3))}function Nu({group:e}){let{orientation:t,panels:n}=e;return n.reduce((e,n)=>(e+=t===`horizontal`?n.element.offsetWidth:n.element.offsetHeight,e),0)}function Pu(e){let{panels:t}=e,n=Nu({group:e});return n===0?t.map(e=>({groupResizeBehavior:e.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:e.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:e.panelConstraints.disabled,minSize:0,maxSize:100,panelId:e.id})):t.map(e=>{let{element:t,panelConstraints:r}=e,i=0;r.collapsedSize!==void 0&&(i=Mu(ju({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=Mu(ju({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=Mu(ju({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=Mu(ju({groupSize:n,panelElement:t,styleProp:r.maxSize})/n*100)),{groupResizeBehavior:r.groupResizeBehavior,collapsedSize:i,collapsible:r.collapsible===!0,defaultSize:a,disabled:r.disabled,minSize:o,maxSize:s,panelId:e.id}})}function X(e,t=`Assertion error`){if(!e)throw Error(t)}function Fu(e,t){return Array.from(t).sort(e===`horizontal`?Iu:Lu)}function Iu(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function Lu(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function Ru(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function zu(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function Bu({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},i,a=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=zu(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return X(i,`No rect found`),i}var Vu;function Hu(){return Vu===void 0&&(Vu=typeof matchMedia==`function`?!!matchMedia(`(pointer:coarse)`).matches:!1),Vu}function Uu(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=Fu(n,Array.from(t.children).filter(Ru).map(e=>({element:e}))).map(({element:e})=>e),o=[],s=!1,c=!1,l=-1,u=-1,d=0,f,p=[];{let e=-1;for(let t of a)t.hasAttribute(`data-panel`)&&(e++,t.ariaDisabled===null&&(d++,l===-1&&(l=e),u=e))}if(d>1){let t=-1;for(let d of a)if(d.hasAttribute(`data-panel`)){t++;let i=r.find(e=>e.element===d);if(i){if(f){let r=f.element.getBoundingClientRect(),a=d.getBoundingClientRect(),m;if(c){let e=n===`horizontal`?new DOMRect(r.right,r.top,0,r.height):new DOMRect(r.left,r.bottom,r.width,0),t=n===`horizontal`?new DOMRect(a.left,a.top,0,a.height):new DOMRect(a.left,a.top,a.width,0);switch(p.length){case 0:m=[e,t];break;case 1:{let i=p[0];m=[i,Bu({orientation:n,rects:[r,a],targetRect:i.element.getBoundingClientRect()})===r?t:e];break}default:m=p;break}}else m=p.length?p:[n===`horizontal`?new DOMRect(r.right,a.top,a.left-r.right,a.height):new DOMRect(a.left,r.bottom,a.width,a.top-r.bottom)];for(let n of m){let r=`width`in n?n:n.element.getBoundingClientRect(),a=Hu()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(r.width<a){let e=a-r.width;r=new DOMRect(r.x-e/2,r.y,r.width+e,r.height)}if(r.height<a){let e=a-r.height;r=new DOMRect(r.x,r.y-e/2,r.width,r.height+e)}!s&&!(t<=l||t>u)&&o.push({group:e,groupSize:Nu({group:e}),panels:[f,i],separator:`width`in n?void 0:n,rect:r}),s=!1}}c=!1,f=i,p=[]}}else if(d.hasAttribute(`data-separator`)){d.ariaDisabled!==null&&(s=!0);let e=i.find(e=>e.element===d);e?p.push(e):(f=void 0,p=[])}else c=!0}return o}var Wu=class{#e={};addListener(e,t){let n=this.#e[e];return n===void 0?this.#e[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#e[e];if(n!==void 0)if(n.length===1)n[0].call(null,t);else{let e=!1,r=null,i=Array.from(n);for(let n=0;n<i.length;n++){let a=i[n];try{a.call(null,t)}catch(t){r===null&&(e=!0,r=t)}}if(e)throw r}}removeAllListeners(){this.#e={}}removeListener(e,t){let n=this.#e[e];if(n!==void 0){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}},Z=new Map,Gu=new Wu;function Ku(e){Z=new Map(Z),Z.delete(e)}function qu(e,t){for(let[t]of Z)if(t.id===e)return t}function Ju(e,t){for(let[t,n]of Z)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Yu(){return Z}function Xu(e,t){return Gu.addListener(`groupChange`,n=>{n.group.id===e&&t(n)})}function Zu(e,t){let n=Z.get(e);Z=new Map(Z),Z.set(e,t),Gu.emit(`groupChange`,{group:e,prev:n,next:t})}function Qu(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=zu(n,a.rect);switch(e){case`horizontal`:t.x<=i.x&&(r=a,i=t);break;case`vertical`:t.y<=i.y&&(r=a,i=t);break}}return r?{distance:i,hitRegion:r}:void 0}function $u(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function ed(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:od(e),b:od(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();X(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:ad(id(n.a)),b:ad(id(n.b))};if(i.a===i.b){let e=r.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let n=e[i];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(i.a-i.b)}var td=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function nd(e){let t=getComputedStyle(sd(e)??e).display;return t===`flex`||t===`inline-flex`}function rd(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||nd(e))||+t.opacity<1||`transform`in t&&t.transform!==`none`||`webkitTransform`in t&&t.webkitTransform!==`none`||`mixBlendMode`in t&&t.mixBlendMode!==`normal`||`filter`in t&&t.filter!==`none`||`webkitFilter`in t&&t.webkitFilter!==`none`||`isolation`in t&&t.isolation===`isolate`||td.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function id(e){let t=e.length;for(;t--;){let n=e[t];if(X(n,`Missing node`),rd(n))return n}return null}function ad(e){return e&&Number(getComputedStyle(e).zIndex)||0}function od(e){let t=[];for(;e;)t.push(e),e=sd(e);return t}function sd(e){let{parentNode:t}=e;return $u(t)?t.host:t}function cd(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function ld({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!Ru(n)||n.contains(e)||e.contains(n))return!0;if(ed(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(cd(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function ud(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=Uu(r),a=Qu(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&ld({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function dd(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function fd(e,t,n=0){return Math.abs(Mu(e)-Mu(t))<=n}function pd(e,t){return fd(e,t)?0:e>t?1:-1}function md({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){let{collapsedSize:i=0,collapsible:a,disabled:o,maxSize:s=100,minSize:c=0}=t;if(o&&!e)return n;if(pd(r,c)<0)if(a){let e=(i+c)/2;r=pd(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=Mu(r),r}function hd({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(fd(e,0))return t;let o=a===`imperative-api`,s=Object.values(t),c=Object.values(i),l=[...s],[u,d]=r;X(u!=null,`Invalid first pivot index`),X(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];X(r,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(X(n!=null,`Previous layout not found for panel index ${t}`),fd(n,i)){let t=o-n;pd(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];X(r,`No panel constraints found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(X(n!=null,`Previous layout not found for panel index ${t}`),fd(n,o)){let t=n-i;pd(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];X(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsible:a,collapsedSize:o,minSize:c}=r;if(a&&pd(i,c)<0)if(e>0){let t=c-o,n=t/2;pd(i+e,c)<0&&(e=pd(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;pd(i-e,c)<0&&(e=pd(100+e,n)>0?0:-t)}break}}{let t=e<0?1:-1,r=e<0?d:u,i=0;for(;;){let e=s[r];X(e!=null,`Previous layout not found for panel index ${r}`);let a=md({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:e,size:100})-e;if(i+=a,r+=t,r<0||r>=n.length)break}let a=Math.min(Math.abs(e),Math.abs(i));e=e<0?0-a:a}{let t=e<0?u:d;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(f),i=s[t];X(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=md({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!fd(i,c)&&(f+=i-c,l[t]=c,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(dd(c,l))return i;{let t=e<0?d:u,r=s[t];X(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=md({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!fd(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];X(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=md({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(fd(i,s)||(t-=s-i,l[r]=s),fd(t,0))break;e>0?r--:r++}}}if(!fd(Object.values(l).reduce((e,t)=>t+e,0),100,.1))return i;let p=Object.keys(i);return l.reduce((e,t,n)=>(e[p[n]]=t,e),{})}function gd(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||pd(e[n],t[n])!==0)return!1;return!0}function _d({layout:e,panelConstraints:t}){let n=Object.values(e),r=[...n],i=r.reduce((e,t)=>e+t,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(e=>`${e}%`).join(`, `)}`);if(!fd(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];X(t!=null,`No layout data found for index ${e}`),r[e]=100/i*t}let a=0;for(let e=0;e<t.length;e++){let i=n[e];X(i!=null,`No layout data found for index ${e}`);let o=r[e];X(o!=null,`No layout data found for index ${e}`);let s=md({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!fd(a,0))for(let e=0;e<t.length;e++){let n=r[e];X(n!=null,`No layout data found for index ${e}`);let i=n+a,o=md({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,fd(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function vd({groupId:e,panelId:t}){let n=()=>{let t=Yu();for(let[n,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:a,groupSize:o,separatorToPanels:s}]of t)if(n.id===e)return{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:n,groupSize:o,layout:a,separatorToPanels:s};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedPanelConstraints.find(e=>e.panelId===t);if(e!==void 0)return e;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{let e=n().group.panels.find(e=>e.id===t);if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},a=()=>{let e=n().layout[t];if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},o=e=>{let r=a();if(e===r)return;let{defaultLayoutDeferred:i,derivedPanelConstraints:o,group:s,groupSize:c,layout:l,separatorToPanels:u}=n(),d=s.panels.findIndex(e=>e.id===t),f=d===s.panels.length-1,p=_d({layout:hd({delta:f?r-e:e-r,initialLayout:l,panelConstraints:o,pivotIndices:f?[d-1,d]:[d,d+1],prevLayout:l,trigger:`imperative-api`}),panelConstraints:o});gd(l,p)||Zu(s,{defaultLayoutDeferred:i,derivedPanelConstraints:o,groupSize:c,layout:p,separatorToPanels:u})};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=i(),s=a();e&&s!==t&&(n.expandToSize=s,o(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:s}=i(),c=a();if(e&&c===t){let e=s.expandToSize??n;e===0&&(e=1),o(e)}},getSize:()=>{let{group:e}=n(),t=a(),{element:r}=i();return{asPercentage:t,inPixels:e.orientation===`horizontal`?r.offsetWidth:r.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=a();return e&&fd(t,n)},resize:e=>{let{group:t}=n(),{element:r}=i(),a=Nu({group:t});o(Mu(ju({groupSize:a,panelElement:r,styleProp:e})/a*100))}}}function yd(e){e.defaultPrevented||ud(e,Yu()).forEach(t=>{if(t.separator){let n=t.panels.find(e=>e.panelConstraints.defaultSize!==void 0);if(n){let r=n.panelConstraints.defaultSize,i=vd({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function Q(e){let t=Yu();for(let[n]of t)if(n.separators.some(t=>t.element===e))return n;throw Error(`Could not find parent Group for separator element`)}function bd({groupId:e}){let t=()=>{let t=Yu();for(let[n,r]of t)if(n.id===e)return{group:n,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{defaultLayoutDeferred:n,derivedPanelConstraints:r,group:i,groupSize:a,layout:o,separatorToPanels:s}=t(),c=_d({layout:e,panelConstraints:r});return n?o:(gd(o,c)||Zu(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:s}),c)}}}function xd(e,t){let n=Q(e),r=Ju(n.id,!0),i=n.separators.find(t=>t.element===e);X(i,`Matching separator not found`);let a=r.separatorToPanels.get(i);X(a,`Matching panels not found`);let o=a.map(e=>n.panels.indexOf(e)),s=bd({groupId:n.id}).getLayout(),c=_d({layout:hd({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});gd(s,c)||Zu(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels})}function Sd(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=Q(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&xd(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&xd(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&xd(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&xd(t,-5);break;case`End`:e.preventDefault(),xd(t,100);break;case`Enter`:{e.preventDefault();let n=Q(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=Ju(n.id,!0),o=n.separators.find(e=>e.element===t);X(o,`Matching separator not found`);let s=a.get(o);X(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.panelId===c.id);if(X(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];xd(t,(l.collapsedSize===e?n.mutableState.expandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=Q(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);X(r!==null,`Index not found`),n[e.shiftKey?r>0?r-1:n.length-1:r+1<n.length?r+1:0].focus({preventScroll:!0});break}case`Home`:e.preventDefault(),xd(t,-100);break}}var Cd={cursorFlags:0,state:`inactive`},wd=new Wu;function Td(){return Cd}function Ed(e){return wd.addListener(`change`,e)}function Dd(e){let t=Cd,n={...Cd};n.cursorFlags=e,Cd=n,wd.emit(`change`,{prev:t,next:n})}function Od(e){let t=Cd;Cd=e,wd.emit(`change`,{prev:t,next:e})}function kd(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=Yu(),n=ud(e,t),r=new Map,i=!1;n.forEach(e=>{e.separator&&(i||(i=!0,e.separator.element.focus({preventScroll:!0})));let n=t.get(e.group);n&&r.set(e.group,n.layout)}),Od({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}),n.length&&e.preventDefault()}var Ad=e=>e,jd=()=>{},Md=1,$=2,Nd=4,Pd=8,Fd=3,Id=12,Ld;function Rd(){return Ld===void 0&&(Ld=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(Ld=!0)),Ld}function zd({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case`active`:case`hover`:t.forEach(e=>{if(!e.mutableState.disableCursor)switch(e.orientation){case`horizontal`:r++;break;case`vertical`:i++;break}})}if(!(r===0&&i===0)){switch(n){case`active`:if(e&&Rd()){let t=(e&Md)!==0,n=(e&$)!==0,r=(e&Nd)!==0,i=(e&Pd)!==0;if(t)return r?`se-resize`:i?`ne-resize`:`e-resize`;if(n)return r?`sw-resize`:i?`nw-resize`:`w-resize`;if(r)return`s-resize`;if(i)return`n-resize`}break}return Rd()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var Bd=new WeakMap;function Vd(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=Bd.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(n));let r=Td();switch(r.state){case`active`:case`hover`:{let e=zd({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(e=>e.group),state:r.state}),i=`*, *:hover {cursor: ${e} !important; }`;if(t===i)return;t=i,e?n.cssRules.length===0?n.insertRule(i):n.replaceSync(i):n.cssRules.length===1&&n.deleteRule(0);break}case`inactive`:t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}Bd.set(e,{prevStyle:t,styleSheet:n})}function Hd({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:a,prevCursorFlags:o}){let s=0;n.forEach(e=>{let{group:n,groupSize:o}=e,{orientation:c,panels:l}=n,{disableCursor:u}=n.mutableState,d=0;d=a?c===`horizontal`?(t.clientX-a.x)/o*100:(t.clientY-a.y)/o*100:c===`horizontal`?t.clientX<0?-100:100:t.clientY<0?-100:100;let f=r.get(n),p=i.get(n);if(!f||!p)return;let{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:_,separatorToPanels:v}=p;if(h&&_&&v){let t=hd({delta:d,initialLayout:f,panelConstraints:h,pivotIndices:e.panels.map(e=>l.indexOf(e)),prevLayout:_,trigger:`mouse-or-touch`});if(gd(t,_)){if(d!==0&&!u)switch(c){case`horizontal`:s|=d<0?Md:$;break;case`vertical`:s|=d<0?Nd:Pd;break}}else Zu(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:t,separatorToPanels:v})}});let c=0;t.movementX===0?c|=o&Fd:c|=s&Fd,t.movementY===0?c|=o&Id:c|=s&Id,Dd(c),Vd(e)}function Ud(e){let t=Yu(),n=Td();switch(n.state){case`active`:Hd({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function Wd(e){if(e.defaultPrevented)return;let t=Td(),n=Yu();switch(t.state){case`active`:if(e.buttons===0){Od({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{let t=Ju(e.group.id,!0);Zu(e.group,t)});return}Hd({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=ud(e,n);r.length===0?t.state!==`inactive`&&Od({cursorFlags:0,state:`inactive`}):Od({cursorFlags:0,hitRegions:r,state:`hover`}),Vd(e.currentTarget);break}}}function Gd(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(Td().state){case`hover`:Od({cursorFlags:0,state:`inactive`})}}function Kd(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=Td();switch(t.state){case`active`:Od({cursorFlags:0,state:`inactive`}),t.hitRegions.length>0&&(Vd(e.currentTarget),t.hitRegions.forEach(e=>{let t=Ju(e.group.id,!0);Zu(e.group,t)}),e.preventDefault())}}function qd(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=Mu(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=Mu((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function Jd(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=Nu({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:Mu(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function Yd(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function Xd({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,a=0,o=!1,s=new Map,c=[];for(let l of e.panels){let e=r[l.id]??0;switch(l.panelConstraints.groupResizeBehavior){case`preserve-pixel-size`:{o=!0;let r=Mu(e/100*n/t*100);s.set(l.id,r),i+=r;break}default:c.push(l.id),a+=e;break}}if(!o||c.length===0)return r;let l=100-i,u={...r};if(s.forEach((e,t)=>{u[t]=e}),a>0)for(let e of c)u[e]=Mu((r[e]??0)/a*l);else{let e=Mu(l/c.length);for(let t of c)u[t]=e}return u}function Zd(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}var Qd=new Map;function $d(e){let t=!0;X(e.element.ownerDocument.defaultView,`Cannot register an unmounted Group`);let n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,a=new n(n=>{for(let r of n){let{borderBoxSize:n,target:i}=r;if(i===e.element){if(t){let t=Nu({group:e});if(t===0)return;let n=Ju(e.id);if(!n)return;let r=Pu(e),i=n.defaultLayoutDeferred?qd(r):n.layout,a=_d({layout:Xd({group:e,nextGroupSize:t,prevGroupSize:n.groupSize,prevLayout:i}),panelConstraints:r});if(!n.defaultLayoutDeferred&&gd(n.layout,a)&&Yd(n.derivedPanelConstraints,r)&&n.groupSize===t)return;Zu(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:t,layout:a,separatorToPanels:n.separatorToPanels})}}else Jd(e,i,n)}});a.observe(e.element),e.panels.forEach(e=>{X(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&a.observe(e.element)});let o=Nu({group:e}),s=Pu(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.mutableState.defaultLayout;l&&(Zd(e.panels,l)||(l=void 0));let u=_d({layout:e.mutableState.layouts[c]??l??qd(s),panelConstraints:s}),d=e.element.ownerDocument;Qd.set(d,(Qd.get(d)??0)+1);let f=new Map;return Uu(e).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),Zu(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:s,groupSize:o,layout:u,separatorToPanels:f}),e.separators.forEach(e=>{X(!i.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),i.add(e.id),e.element.addEventListener(`keydown`,Sd)}),Qd.get(d)===1&&(d.addEventListener(`dblclick`,yd,!0),d.addEventListener(`pointerdown`,kd,!0),d.addEventListener(`pointerleave`,Ud),d.addEventListener(`pointermove`,Wd),d.addEventListener(`pointerout`,Gd),d.addEventListener(`pointerup`,Kd,!0)),function(){t=!1,Qd.set(d,Math.max(0,(Qd.get(d)??0)-1)),Ku(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,Sd)}),Qd.get(d)||(d.removeEventListener(`dblclick`,yd,!0),d.removeEventListener(`pointerdown`,kd,!0),d.removeEventListener(`pointerleave`,Ud),d.removeEventListener(`pointermove`,Wd),d.removeEventListener(`pointerout`,Gd),d.removeEventListener(`pointerup`,Kd,!0)),a.disconnect()}}function ef(){let[e,t]=(0,B.useState)({});return[e,(0,B.useCallback)(()=>t({}),[])]}function tf(e){let t=(0,B.useId)();return`${e??t}`}var nf=typeof window<`u`?B.useLayoutEffect:B.useEffect;function rf(e){let t=(0,B.useRef)(e);return nf(()=>{t.current=e},[e]),(0,B.useCallback)((...e)=>t.current?.(...e),[t])}function af(...e){return rf(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function of(e){let t=(0,B.useRef)({...e});return nf(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var sf=(0,B.createContext)(null);function cf(e,t){let n=(0,B.useRef)({getLayout:()=>({}),setLayout:Ad});(0,B.useImperativeHandle)(t,()=>n.current,[]),nf(()=>{Object.assign(n.current,bd({groupId:e}))})}function lf({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:o,id:s,onLayoutChange:c,onLayoutChanged:l,orientation:u=`horizontal`,resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){let m=(0,B.useRef)({onLayoutChange:{},onLayoutChanged:{}}),h=rf(e=>{gd(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=rf(e=>{gd(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e))}),_=tf(s),v=(0,B.useRef)(null),[y,b]=ef(),x=(0,B.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=af(v,a);cf(_,o);let C=rf((e,t)=>{let r=Td(),i=qu(e),a=Ju(e);if(a){let e=!1;switch(r.state){case`active`:e=r.hitRegions.some(e=>e.group===i);break}return{flexGrow:a.layout[t]??1,pointerEvents:e?`none`:void 0}}return{flexGrow:n?.[t]??1}}),w=of({defaultLayout:n,disableCursor:r}),T=(0,B.useMemo)(()=>({get disableCursor(){return!!w.disableCursor},getPanelStyles:C,id:_,orientation:u,registerPanel:e=>{let t=x.current;return t.panels=Fu(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=Fu(u,[...t.separators,e]),b(),()=>{t.separators=t.separators.filter(t=>t!==e),b()}},togglePanelDisabled:(e,t)=>{let n=x.current.panels.find(t=>t.id===e);n&&(n.panelConstraints.disabled=t);let r=qu(_),i=Ju(_);r&&i&&Zu(r,{...i,derivedPanelConstraints:Pu(r)})},toggleSeparatorDisabled:(e,t)=>{let n=x.current.separators.find(t=>t.id===e);n&&(n.disabled=t)}}),[C,_,b,u,w]),E=(0,B.useRef)(null);return nf(()=>{let e=v.current;if(e===null)return;let t=x.current,n;if(w.defaultLayout!==void 0&&Object.keys(w.defaultLayout).length===t.panels.length){n={};for(let e of t.panels){let t=w.defaultLayout[e.id];t!==void 0&&(n[e.id]=t)}}let r={disabled:!!i,element:e,id:_,mutableState:{defaultLayout:n,disableCursor:!!w.disableCursor,expandedPanelSizes:x.current.lastExpandedPanelSizes,layouts:x.current.layouts},orientation:u,panels:t.panels,resizeTargetMinimumSize:t.resizeTargetMinimumSize,separators:t.separators};E.current=r;let a=$d(r),{defaultLayoutDeferred:o,derivedPanelConstraints:s,layout:c}=Ju(r.id,!0);!o&&s.length>0&&(h(c),g(c));let l=Xu(_,e=>{let{defaultLayoutDeferred:t,derivedPanelConstraints:n,layout:i}=e.next;if(t||n.length===0)return;let a=r.panels.map(({id:e})=>e).join(`,`);r.mutableState.layouts[a]=i,n.forEach(t=>{if(t.collapsible){let{layout:n}=e.prev??{};if(n){let e=fd(t.collapsedSize,i[t.panelId]),a=fd(t.collapsedSize,n[t.panelId]);e&&!a&&(r.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let o=Td().state!==`active`;h(i),o&&g(i)});return()=>{E.current=null,a(),l()}},[i,_,g,h,u,y,w]),(0,B.useEffect)(()=>{let e=E.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,H.jsx)(sf.Provider,{value:T,children:(0,H.jsx)(`div`,{...p,className:t,"data-group":!0,"data-testid":_,id:_,ref:S,style:{height:`100%`,width:`100%`,overflow:`hidden`,...f,display:`flex`,flexDirection:u===`horizontal`?`row`:`column`,flexWrap:`nowrap`,touchAction:u===`horizontal`?`pan-y`:`pan-x`},children:e})})}lf.displayName=`Group`;function uf(){let e=(0,B.useContext)(sf);return X(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function df(e,t){let{id:n}=uf(),r=(0,B.useRef)({collapse:jd,expand:jd,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:jd});(0,B.useImperativeHandle)(t,()=>r.current,[]),nf(()=>{Object.assign(r.current,vd({groupId:n,panelId:e}))})}function ff({children:e,className:t,collapsedSize:n=`0%`,collapsible:r=!1,defaultSize:i,disabled:a,elementRef:o,groupResizeBehavior:s=`preserve-relative-size`,id:c,maxSize:l=`100%`,minSize:u=`0%`,onResize:d,panelRef:f,style:p,...m}){let h=!!c,g=tf(c),_=of({disabled:a}),v=(0,B.useRef)(null),y=af(v,o),{getPanelStyles:b,id:x,orientation:S,registerPanel:C,togglePanelDisabled:w}=uf(),T=d!==null,E=rf((e,t,n)=>{d?.(e,c,n)});nf(()=>{let e=v.current;if(e!==null)return C({element:e,id:g,idIsStable:h,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:T?E:void 0,panelConstraints:{groupResizeBehavior:s,collapsedSize:n,collapsible:r,defaultSize:i,disabled:_.disabled,maxSize:l,minSize:u}})},[s,n,r,i,T,g,h,l,u,E,C,_]),(0,B.useEffect)(()=>{w(g,!!a)},[a,g,w]),df(g,f);let D=(0,B.useSyncExternalStore)(e=>Xu(x,e),()=>JSON.stringify(b(x,g)),()=>JSON.stringify(b(x,g)));return(0,H.jsx)(`div`,{...m,"aria-disabled":a||void 0,"data-panel":!0,"data-testid":g,id:g,ref:y,style:{...pf,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...JSON.parse(D)},children:(0,H.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...p,touchAction:S===`horizontal`?`pan-y`:`pan-x`},children:e})})}ff.displayName=`Panel`;var pf={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function mf({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,a,o=e[n],s=t.find(e=>e.panelId===n);if(s){let c=s.maxSize,l=s.collapsible?s.collapsedSize:s.minSize,u=[r,r+1];a=_d({layout:hd({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=_d({layout:hd({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function hf({children:e,className:t,disabled:n,elementRef:r,id:i,style:a,...o}){let s=tf(i),c=of({disabled:n}),[l,u]=(0,B.useState)({}),[d,f]=(0,B.useState)(`inactive`),p=(0,B.useRef)(null),m=af(p,r),{disableCursor:h,id:g,orientation:_,registerSeparator:v,toggleSeparatorDisabled:y}=uf(),b=_===`horizontal`?`vertical`:`horizontal`;nf(()=>{let e=p.current;if(e!==null){let t={disabled:c.disabled,element:e,id:s},n=v(t),r=Ed(e=>{f(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===t)?e.next.state:`inactive`)}),i=Xu(g,e=>{let{derivedPanelConstraints:n,layout:r,separatorToPanels:i}=e.next,a=i.get(t);if(a){let e=a[0],t=a.indexOf(e);u(mf({layout:r,panelConstraints:n,panelId:e.id,panelIndex:t}))}});return()=>{r(),i(),n()}}},[g,s,v,c]),(0,B.useEffect)(()=>{y(s,!!n)},[n,s,y]);let x;return n&&!h&&(x=`not-allowed`),(0,H.jsx)(`div`,{...o,"aria-controls":l.valueControls,"aria-disabled":n||void 0,"aria-orientation":b,"aria-valuemax":l.valueMax,"aria-valuemin":l.valueMin,"aria-valuenow":l.valueNow,children:e,className:t,"data-separator":n?`disabled`:d,"data-testid":s,id:s,ref:m,role:`separator`,style:{flexBasis:`auto`,cursor:x,...a,flexGrow:0,flexShrink:0,touchAction:`none`},tabIndex:n?void 0:0})}hf.displayName=`Separator`;var gf=`ppm-custom-order`;function _f(){try{let e=localStorage.getItem(gf);return e?JSON.parse(e):null}catch{return null}}function vf(e){try{localStorage.setItem(gf,JSON.stringify(e))}catch{}}function yf(e,t){if(!t)return[...e];let n=new Map(t.map((e,t)=>[e,t]));return[...e].sort((e,t)=>(n.get(e.name)??1/0)-(n.get(t.name)??1/0))}var bf=v((e,t)=>({projects:[],activeProject:null,customOrder:_f(),loading:!1,error:null,fetchProjects:async()=>{e({loading:!0,error:null});try{e({projects:await z.get(`/api/projects`),loading:!1})}catch(t){e({error:t instanceof Error?t.message:`Failed to fetch projects`,loading:!1})}},setActiveProject:t=>{e({activeProject:t})},addProject:async(n,r)=>{let i=await z.post(`/api/projects`,{path:n,name:r});await t().fetchProjects();let a=t().projects.find(e=>e.name===(r??i.name)||e.path===n);return a&&e({activeProject:a}),i},setProjectColor:async(e,n)=>{await z.patch(`/api/projects/${encodeURIComponent(e)}/color`,{color:n}),await t().fetchProjects()},moveProject:async(n,r)=>{let{projects:i,customOrder:a}=t(),o=yf(i,a),s=o.findIndex(e=>e.name===n);if(s===-1)return;let c=r===`up`?s-1:s+1;if(c<0||c>=o.length)return;let l=o.map(e=>e.name);[l[s],l[c]]=[l[c],l[s]],vf(l),await z.patch(`/api/projects/reorder`,{order:l}),e({customOrder:l})},reorderProjects:async t=>{vf(t),e({customOrder:t}),await z.patch(`/api/projects/reorder`,{order:t}).catch(()=>{})},renameProject:async(e,n)=>{await z.patch(`/api/projects/${encodeURIComponent(e)}`,{name:n}),await t().fetchProjects()},deleteProject:async t=>{await z.del(`/api/projects/${encodeURIComponent(t)}`),e(e=>{let n=e.projects.filter(e=>e.name!==t),r=e.customOrder?e.customOrder.filter(e=>e!==t):null;return r&&vf(r),{projects:n,customOrder:r,activeProject:e.activeProject?.name===t?n[0]??null:e.activeProject}})}})),xf=`application/ppm-tab`,Sf=!1,Cf=new Set;function wf(e){Sf!==e&&(Sf=e,Cf.forEach(e=>e()))}function Tf(){return(0,B.useSyncExternalStore)(e=>(Cf.add(e),()=>Cf.delete(e)),()=>Sf)}function Ef(){wf(!1)}function Df(e){let[t,n]=(0,B.useState)(null),r=(0,B.useRef)(null);return{dropIndex:t,handleDragStart:(0,B.useCallback)((t,n)=>{let r={tabId:n,panelId:e};t.dataTransfer.setData(xf,JSON.stringify(r)),t.dataTransfer.effectAllowed=`move`,requestAnimationFrame(()=>wf(!0))},[e]),handleDragOver:(0,B.useCallback)((e,t,i)=>{if(!e.dataTransfer.types.includes(`application/ppm-tab`)||(e.preventDefault(),e.dataTransfer.dropEffect=`move`,r.current===t))return;r.current=t;let a=e.currentTarget.getBoundingClientRect(),o=a.left+a.width/2;n(e.clientX<o?i:i+1)},[]),handleDragOverBar:(0,B.useCallback)(e=>{e.dataTransfer.types.includes(`application/ppm-tab`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`)},[]),handleDrop:(0,B.useCallback)(i=>{i.preventDefault(),wf(!1);let a=i.dataTransfer.getData(xf);if(a){try{let n=JSON.parse(a),r=m.getState();n.panelId===e?t!==null&&r.reorderTab(n.tabId,e,t):r.moveTab(n.tabId,n.panelId,e,t??void 0)}catch{}n(null),r.current=null}},[e,t]),handleDragEnd:(0,B.useCallback)(()=>{wf(!1),n(null),r.current=null},[])}}var Of=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.userAgent),kf=[{id:`command-palette`,label:`Command Palette`,category:`general`,defaultKey:`F1`,note:`Shift+Shift also opens (not customizable)`},{id:`toggle-sidebar`,label:`Toggle Sidebar`,category:`general`,defaultKey:`Mod+B`},{id:`save-prevent`,label:`Prevent Save Dialog`,category:`general`,defaultKey:`Mod+S`,locked:!0,note:`Always active — prevents browser save`},{id:`next-tab`,label:`Next Tab`,category:`tabs`,defaultKey:`Alt+]`},{id:`prev-tab`,label:`Previous Tab`,category:`tabs`,defaultKey:`Alt+[`},{id:`open-chat`,label:`Open Chat`,category:`tabs`,defaultKey:`Mod+L`},{id:`open-terminal`,label:`Open Terminal`,category:`tabs`,defaultKey:`Mod+'`},{id:`open-settings`,label:`Open Settings`,category:`tabs`,defaultKey:`Mod+,`},{id:`open-git-graph`,label:`Git Graph`,category:`tabs`,defaultKey:`Mod+G`},{id:`open-git-status`,label:`Git Status (sidebar)`,category:`tabs`,defaultKey:`Mod+Shift+E`},{id:`open-search`,label:`Search Files (sidebar)`,category:`tabs`,defaultKey:`Mod+Shift+F`},{id:`voice-input`,label:`Voice Input`,category:`general`,defaultKey:`Mod+Shift+V`,note:`Toggle speech-to-text in chat`},...Array.from({length:9},(e,t)=>({id:`switch-project-${t+1}`,label:`Switch to Project ${t+1}`,category:`projects`,defaultKey:`Mod+${t+1}`}))],Af=new Map(kf.map(e=>[e.id,e.defaultKey]));function jf(e){let t=e.split(`+`),n={ctrl:!1,meta:!1,alt:!1,shift:!1,key:``};for(let e of t){let t=e.trim();switch(t){case`Mod`:Of?n.meta=!0:n.ctrl=!0;break;case`Ctrl`:n.ctrl=!0;break;case`Meta`:case`Cmd`:n.meta=!0;break;case`Alt`:n.alt=!0;break;case`Shift`:n.shift=!0;break;default:n.key=t.toLowerCase();break}}return n}function Mf(e,t){return e.ctrlKey!==t.ctrl||e.metaKey!==t.meta||e.altKey!==t.alt||e.shiftKey!==t.shift?!1:e.key.toLowerCase()===t.key}function Nf(e){return e.replace(/Mod/g,Of?`⌘`:`Ctrl`).replace(/Shift/g,Of?`⇧`:`Shift`).replace(/Alt/g,Of?`⌥`:`Alt`).replace(/Meta|Cmd/g,`⌘`).replace(/Ctrl/g,Of?`⌃`:`Ctrl`)}function Pf(e){if([`Control`,`Meta`,`Alt`,`Shift`].includes(e.key))return null;let t=[];e.ctrlKey&&!e.metaKey&&t.push(Of?`Ctrl`:`Mod`),e.metaKey&&t.push(Of?`Mod`:`Meta`),e.altKey&&t.push(`Alt`),e.shiftKey&&t.push(`Shift`);let n=e.key;return n===` `?n=`Space`:n.length===1&&(n=n.toUpperCase()),t.push(n),t.join(`+`)}var Ff=v((e,t)=>({overrides:{},loaded:!1,getBinding:e=>t().overrides[e]??Af.get(e)??``,matchesEvent:(e,n)=>{let r=t().getBinding(n);return r?Mf(e,jf(r)):!1},setBinding:(n,r)=>{e({overrides:{...t().overrides,[n]:r}}),z.put(`/api/settings/keybindings`,{[n]:r}).catch(()=>{})},resetBinding:n=>{let r={...t().overrides};delete r[n],e({overrides:r}),z.put(`/api/settings/keybindings`,{[n]:null}).catch(()=>{})},resetAll:()=>{e({overrides:{}});let n={};for(let e of Object.keys(t().overrides))n[e]=null;Object.keys(n).length>0&&z.put(`/api/settings/keybindings`,n).catch(()=>{})},loadFromServer:async()=>{try{e({overrides:await z.get(`/api/settings/keybindings`),loaded:!0})}catch{e({loaded:!0})}}}));function If(e){window.dispatchEvent(new CustomEvent(`open-command-palette`,{detail:e}))}function Lf(){let[e,t]=(0,B.useState)(!1),[n,r]=(0,B.useState)(``);return(0,B.useEffect)(()=>{let e=0,{matchesEvent:n}=Ff.getState(),i=!1;function a(){i=!0}function o(){i=!1}function s(n){if(n.type===`keyup`&&n.key===`Shift`&&!n.ctrlKey&&!n.metaKey&&!n.altKey&&!i&&!n.isComposing){let n=Date.now();if(n-e<400){e=0,r(``),t(!0);return}e=n;return}if(n.type!==`keydown`||i||n.isComposing)return;let{matchesEvent:a}=Ff.getState();if(a(n,`save-prevent`)){n.preventDefault();return}if(a(n,`command-palette`)){n.preventDefault(),r(``),t(!0);return}if(a(n,`toggle-sidebar`)){n.preventDefault(),V.getState().toggleSidebar();return}if(a(n,`next-tab`)||a(n,`prev-tab`)){n.preventDefault();let{tabs:e,activeTabId:t,setActiveTab:r}=_.getState();if(e.length<2)return;let i=e.findIndex(e=>e.id===t);r(e[a(n,`next-tab`)?(i+1)%e.length:(i-1+e.length)%e.length].id);return}for(let e of[{action:`open-chat`,type:`chat`,title:`AI Chat`},{action:`open-terminal`,type:`terminal`,title:`Terminal`},{action:`open-git-graph`,type:`git-graph`,title:`Git Graph`}])if(a(n,e.action)){n.preventDefault();let t=bf.getState().activeProject;_.getState().openTab({type:e.type,title:e.title,projectId:t?.name??null,metadata:t?{projectName:t.name}:void 0,closable:!0});return}if(a(n,`open-settings`)){n.preventDefault();let e=V.getState();e.sidebarCollapsed&&e.toggleSidebar(),e.setSidebarActiveTab(`settings`);return}if(a(n,`open-git-status`)){n.preventDefault();let e=V.getState();e.sidebarCollapsed&&e.toggleSidebar(),e.setSidebarActiveTab(`git`);return}if(a(n,`voice-input`)){n.preventDefault(),window.dispatchEvent(new CustomEvent(`toggle-voice-input`));return}if(a(n,`open-search`)){n.preventDefault();let e=V.getState();e.sidebarCollapsed&&e.toggleSidebar(),e.setSidebarActiveTab(`search`);return}for(let e=1;e<=9;e++)if(a(n,`switch-project-${e}`)){n.preventDefault();let t=bf.getState().projects[e-1];t&&(bf.getState().setActiveProject(t),_.getState().switchProject(t.name));return}}function c(e){let n=e.detail;r(typeof n==`string`?n:``),t(!0)}return window.addEventListener(`keydown`,s),window.addEventListener(`keyup`,s),window.addEventListener(`compositionstart`,a),window.addEventListener(`compositionend`,o),window.addEventListener(`open-command-palette`,c),()=>{window.removeEventListener(`keydown`,s),window.removeEventListener(`keyup`,s),window.removeEventListener(`compositionstart`,a),window.removeEventListener(`compositionend`,o),window.removeEventListener(`open-command-palette`,c)}},[]),{paletteOpen:e,paletteInitialQuery:n,closePalette:(0,B.useCallback)(()=>{t(!1),r(``)},[])}}var Rf={approval_request:`bg-red-500`,question:`bg-amber-500`,done:`bg-blue-500`},zf={done:0,question:1,approval_request:2};function Bf(e){return e&&Rf[e]||`bg-red-500`}var Vf=v()(e=>({notifications:new Map,addNotification:(t,n,r)=>{e(e=>{let i=new Map(e.notifications),a=i.get(t);return i.set(t,{count:(a?.count??0)+1,type:n,projectName:r}),{notifications:i}})},clearForSession:t=>{e(e=>{if(!e.notifications.has(t))return e;let n=new Map(e.notifications);return n.delete(t),{notifications:n}})},clearAll:()=>e({notifications:new Map})}));function Hf(e){let t=0;for(let[,n]of e.notifications)t+=n.count;return t}function Uf(e){return t=>{let n=null,r=-1;for(let[,i]of t.notifications){if(i.projectName!==e)continue;let t=zf[i.type]??0;t>r&&(r=t,n=i.type)}return n}}function Wf(e){let[t,n]=(0,B.useState)(!1),[r,i]=(0,B.useState)(!1),a=(0,B.useCallback)(()=>{let t=e.current;t&&(n(t.scrollLeft>1),i(t.scrollLeft+t.clientWidth<t.scrollWidth-1))},[e]);return(0,B.useEffect)(()=>{let t=e.current;if(!t)return;a(),t.addEventListener(`scroll`,a,{passive:!0});let n=new ResizeObserver(a);n.observe(t);let r=new MutationObserver(a);return r.observe(t,{childList:!0,subtree:!0}),()=>{t.removeEventListener(`scroll`,a),n.disconnect(),r.disconnect()}},[e,a]),{canScrollLeft:t,canScrollRight:r,scrollLeft:(0,B.useCallback)(()=>{e.current?.scrollBy({left:-150,behavior:`smooth`})},[e]),scrollRight:(0,B.useCallback)(()=>{e.current?.scrollBy({left:150,behavior:`smooth`})},[e])}}var Gf={done:0,question:1,approval_request:2};function Kf(e,t,n,r){if(!e)return{left:null,right:null};let i=e.scrollLeft,a=i+e.clientWidth,o=null,s=-1,c=null,l=-1,u=e.getBoundingClientRect();for(let d of n){if(d.type!==`chat`)continue;let n=d.metadata?.sessionId,f=n?r.get(n):void 0;if(!f||f.count===0)continue;let p=t.get(d.id);if(!p)continue;let m=p.getBoundingClientRect(),h=m.left-u.left+e.scrollLeft,g=h+m.width,_=Gf[f.type]??0;g<=i&&_>s&&(s=_,o=f.type),h>=a&&_>l&&(l=_,c=f.type)}return{left:o,right:c}}function qf(e){let t=/^#([0-9a-fA-F]{6})$/.exec(e.trim());if(!t)return null;let n=parseInt(t[1],16);return{r:n>>16&255,g:n>>8&255,b:n&255}}function Jf(e,t,n){let[r,i,a]=[e,t,n].map(e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4});return .2126*r+.7152*i+.0722*a}function Yf(e){let t=qf(e);return t?Jf(t.r,t.g,t.b)<.4:!1}function Xf({tab:e,isActive:t,icon:n,showDropBefore:r,notificationType:i,onSelect:a,onClose:o,onDragStart:s,onDragOver:c,onDragEnd:l,tabRef:u,onRename:d}){let[f,p]=(0,B.useState)(!1),[m,h]=(0,B.useState)(e.title),g=(0,B.useRef)(null);(0,B.useEffect)(()=>{f&&(h(e.title),setTimeout(()=>g.current?.select(),0))},[f]);let _=()=>{p(!1);let t=m.trim();t&&t!==e.title&&d&&d(t)},v=e.metadata?.connectionColor,y=v?{backgroundColor:t?v:`${v}33`,color:t&&Yf(v)?`#fff`:void 0}:void 0;return(0,H.jsxs)(`div`,{className:`relative flex items-center`,children:[r&&(0,H.jsx)(`div`,{className:`absolute left-0 top-1 bottom-1 w-0.5 bg-primary rounded-full z-10`}),(0,H.jsxs)(`button`,{ref:u,"data-tab-item":!0,draggable:!f,onClick:a,onAuxClick:t=>{t.button===1&&e.closable&&(t.preventDefault(),o())},onDragStart:s,onDragOver:c,onDragEnd:l,style:y,className:R(`group flex items-center gap-1 px-3 h-10 whitespace-nowrap text-xs transition-colors`,`border-b-2 -mb-px cursor-grab active:cursor-grabbing`,!y&&(t?`border-primary text-primary`:`border-transparent text-text-secondary hover:text-foreground`),y&&`border-transparent`),children:[(0,H.jsxs)(`span`,{className:`relative`,children:[(0,H.jsx)(n,{className:`size-4`}),i&&!t&&(0,H.jsx)(`span`,{className:R(`absolute -top-1 -right-1 size-2 rounded-full`,Bf(i))})]}),f?(0,H.jsx)(`input`,{ref:g,value:m,onChange:e=>h(e.target.value),onBlur:_,onKeyDown:e=>{e.key===`Enter`&&_(),e.key===`Escape`&&p(!1),e.stopPropagation()},onClick:e=>e.stopPropagation(),className:`max-w-[120px] bg-surface-elevated text-xs px-1 py-0.5 rounded border border-border outline-none focus:border-primary`,autoFocus:!0}):(0,H.jsx)(`span`,{className:`max-w-[120px] truncate`,onDoubleClick:e=>{d&&(e.stopPropagation(),p(!0))},children:e.title}),e.closable&&!f&&(0,H.jsx)(`span`,{role:`button`,tabIndex:0,onClick:e=>{e.stopPropagation(),o()},onKeyDown:e=>{e.key===`Enter`&&(e.stopPropagation(),o())},className:`ml-1 opacity-0 group-hover:opacity-100 rounded-sm hover:bg-surface-elevated p-0.5 transition-opacity`,children:(0,H.jsx)(Gt,{className:`size-3`})})]})]})}var Zf={terminal:Rt,chat:_t,editor:Je,database:He,sqlite:He,postgres:He,"git-graph":nt,"git-diff":Ye,settings:Pt,browser:it};function Qf({panelId:e}){bf(e=>e.activeProject);let t=(0,B.useRef)(new Map),n=(0,B.useRef)(null),r=(0,B.useRef)(0),i=m(t=>e?t.panels[e]:t.panels[t.focusedPanelId]),a=i?.tabs??[],o=i?.activeTabId??null,s=i?.id??m.getState().focusedPanelId,{dropIndex:c,handleDragStart:l,handleDragOver:u,handleDragOverBar:f,handleDrop:p,handleDragEnd:h}=Df(s),g=Vf(e=>e.notifications),{canScrollLeft:v,canScrollRight:y,scrollLeft:b,scrollRight:x}=Wf(n),S=Kf(n.current,t.current,a,g);(0,B.useEffect)(()=>{if(a.length>r.current&&o){let e=t.current.get(o);e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`,inline:`nearest`})}r.current=a.length},[a.length,o]);let C=(0,B.useCallback)((e,t)=>{_.getState().updateTab(e.id,{title:t});let n=e.metadata?.projectName,r=e.metadata?.sessionId;n&&r&&z.patch(`${fe(n)}/chat/sessions/${r}`,{title:t}).catch(()=>{})},[]);function w(e){e.target.closest(`[data-tab-item]`)||If()}function T(e){e.target.closest(`[data-tab-item]`)||(e.preventDefault(),If())}return(0,H.jsxs)(`div`,{className:`hidden md:flex items-center h-10 border-b border-border bg-background relative`,onDragOver:f,onDrop:p,onDoubleClick:w,onContextMenu:T,children:[v&&(0,H.jsx)(`button`,{onClick:b,className:`absolute left-0 z-10 flex items-center justify-center size-8 bg-gradient-to-r from-background via-background to-transparent`,children:(0,H.jsxs)(`span`,{className:`relative`,children:[(0,H.jsx)(Me,{className:`size-4 text-text-secondary`}),S.left&&(0,H.jsx)(`span`,{className:R(`absolute -top-1 -right-0.5 size-2 rounded-full`,Bf(S.left))})]})}),(0,H.jsx)(`div`,{ref:n,className:`flex-1 overflow-x-auto overflow-y-hidden min-w-0 scrollbar-none`,children:(0,H.jsxs)(`div`,{className:`flex items-center h-10`,children:[a.map((e,n)=>{let r=e.type===`chat`?e.metadata?.sessionId:void 0,i=r?g.get(r):void 0,a=i&&i.count>0?i.type:null;return(0,H.jsx)(Xf,{tab:e,isActive:e.id===o,icon:Zf[e.type],showDropBefore:c===n,notificationType:a,onSelect:()=>{m.getState().setActiveTab(e.id,s),r&&Vf.getState().clearForSession(r)},onClose:()=>m.getState().closeTab(e.id,s),onDragStart:t=>l(t,e.id),onDragOver:t=>u(t,e.id,n),onDragEnd:h,tabRef:n=>{n?t.current.set(e.id,n):t.current.delete(e.id)},onRename:e.type===`chat`?t=>C(e,t):void 0},e.id)}),c!==null&&c>=a.length&&(0,H.jsx)(`div`,{className:`w-0.5 h-6 bg-primary rounded-full`}),(0,H.jsx)(`button`,{onClick:()=>If(),title:`Open command palette (Shift+Shift)`,className:`flex items-center justify-center size-10 shrink-0 sticky right-0 border-b-2 border-transparent text-text-secondary hover:text-foreground transition-colors bg-background`,children:(0,H.jsx)(Ot,{className:`size-4`})})]})}),y&&(0,H.jsx)(`button`,{onClick:x,className:`absolute right-10 z-10 flex items-center justify-center size-8 bg-gradient-to-l from-background via-background to-transparent`,children:(0,H.jsxs)(`span`,{className:`relative`,children:[(0,H.jsx)(d,{className:`size-4 text-text-secondary`}),S.right&&(0,H.jsx)(`span`,{className:R(`absolute -top-1 -left-0.5 size-2 rounded-full`,Bf(S.right))})]})})]})}function $f({panelId:e}){let[t,n]=(0,B.useState)(null),r=Tf(),i=m(e=>e.grid),a=m(e=>e.isMobile()),o=p(i,e),s=!a&&i.length<3,c=o?!a&&(i[o.row]?.length??0)<f(!1):!1,l=(0,B.useCallback)(e=>{let t=e.currentTarget.getBoundingClientRect(),n=(e.clientX-t.left)/t.width,r=(e.clientY-t.top)/t.height,i=.25;return n<i&&c?`left`:n>1-i&&c?`right`:r<i&&s?`top`:r>1-i&&s?`bottom`:`center`},[c,s]),u=(0,B.useCallback)(e=>{e.dataTransfer.types.includes(`application/ppm-tab`)&&(e.preventDefault(),e.stopPropagation(),n(l(e)))},[l]),d=(0,B.useCallback)(e=>{e.currentTarget.contains(e.relatedTarget)||n(null)},[]),h=(0,B.useCallback)(t=>{t.preventDefault(),t.stopPropagation();let r=l(t);if(n(null),Ef(),!r)return;let i=t.dataTransfer.getData(xf);if(i)try{let t=JSON.parse(i),n=m.getState();if(r===`center`)t.panelId!==e&&n.moveTab(t.tabId,t.panelId,e);else{let i=r===`top`?`up`:r===`bottom`?`down`:r;n.splitPanel(i,t.tabId,t.panelId,e)}}catch{}},[l,e]);return r?(0,H.jsxs)(`div`,{className:`absolute inset-0 z-20`,onDragOver:u,onDragLeave:d,onDrop:h,children:[t===`left`&&(0,H.jsx)(`div`,{className:`absolute inset-y-0 left-0 w-1/3 bg-primary/10 border-2 border-primary/30 rounded-l-md`}),t===`right`&&(0,H.jsx)(`div`,{className:`absolute inset-y-0 right-0 w-1/3 bg-primary/10 border-2 border-primary/30 rounded-r-md`}),t===`top`&&(0,H.jsx)(`div`,{className:`absolute inset-x-0 top-0 h-1/3 bg-primary/10 border-2 border-primary/30 rounded-t-md`}),t===`bottom`&&(0,H.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 h-1/3 bg-primary/10 border-2 border-primary/30 rounded-b-md`}),t===`center`&&(0,H.jsx)(`div`,{className:`absolute inset-0 bg-primary/5 border-2 border-dashed border-primary/30 rounded-md`})]}):null}var ep=[{type:`terminal`,label:`Terminal`,icon:Rt},{type:`chat`,label:`AI Chat`,icon:_t},{type:`git-graph`,label:`Git Graph`,icon:nt}],tp={terminal:(0,B.lazy)(()=>y(()=>import(`./terminal-tab-BKETi9uD.js`).then(e=>({default:e.TerminalTab})),__vite__mapDeps([3,1,4,5,6,7]))),chat:(0,B.lazy)(()=>y(()=>import(`./chat-tab-CVN2falD.js`).then(e=>({default:e.ChatTab})),__vite__mapDeps([8,1,9,10,11,5,6,12,13,14,15,16,17,18,19,4,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,2,38,39,0]))),editor:(0,B.lazy)(()=>y(()=>import(`./code-editor-BNAZzdyF.js`).then(e=>({default:e.CodeEditor})),__vite__mapDeps([40,1,9,10,11,5,6,12,13,14,15,16,17,18,41,4,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,2,42]))),database:(0,B.lazy)(()=>y(()=>import(`./database-viewer-BOnawWoi.js`).then(e=>({default:e.DatabaseViewer})),__vite__mapDeps([43,1,44,5,6,45,21,2]))),sqlite:(0,B.lazy)(()=>y(()=>import(`./sqlite-viewer-J18kIhk2.js`).then(e=>({default:e.SqliteViewer})),__vite__mapDeps([46,1,44,5,6,45,21,42,2]))),postgres:(0,B.lazy)(()=>y(()=>import(`./postgres-viewer-D95__akI.js`).then(e=>({default:e.PostgresViewer})),__vite__mapDeps([47,1,44,5,6,45,21,42,2]))),"git-graph":(0,B.lazy)(()=>y(()=>import(`./git-graph-BNTU6kmo.js`).then(e=>({default:e.GitGraph})),__vite__mapDeps([48,1,11,5,6,12,19,4,24,25,39,2]))),"git-diff":(0,B.lazy)(()=>y(()=>import(`./diff-viewer-CYSw0YBG.js`).then(e=>({default:e.DiffViewer})),__vite__mapDeps([49,1,41,5,6,38,2]))),settings:(0,B.lazy)(()=>y(()=>import(`./settings-tab-CwLkeZaa.js`).then(e=>({default:e.SettingsTab})),__vite__mapDeps([50,11,1,5,6,12,19,4,2,0]))),browser:(0,B.lazy)(()=>y(()=>import(`./browser-tab-sn8vZniz.js`).then(e=>({default:e.BrowserTab})),__vite__mapDeps([51,1,5,6,24,4,25,2])))};function np({panelId:e,projectName:t}){let n=m(t=>t.panels[e]),r=m(t=>t.focusedPanelId===e),i=m(e=>(e.currentProject===t?e.grid:e.projectGrids[t]??[[]]).flat().length);return n?(0,H.jsxs)(`div`,{className:R(`flex flex-col h-full overflow-hidden`,i>1&&`border border-transparent`,i>1&&r&&`border-primary/30`),onMouseDown:()=>{m.getState().focusedPanelId!==e&&m.getState().setFocusedPanel(e)},children:[(0,H.jsx)(Qf,{panelId:e}),(0,H.jsxs)(`div`,{className:`flex-1 overflow-hidden relative`,children:[n.tabs.length===0?(0,H.jsx)(ap,{panelId:e}):n.tabs.map(e=>{let t=tp[e.type];return(0,H.jsx)(`div`,{className:e.id===n.activeTabId?`h-full w-full`:`hidden`,children:(0,H.jsx)(B.Suspense,{fallback:(0,H.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,H.jsx)(pt,{className:`size-6 animate-spin text-primary`})}),children:(0,H.jsx)(t,{metadata:e.metadata,tabId:e.id})})},e.id)}),(0,H.jsx)($f,{panelId:e})]})]}):null}function rp(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`Just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}catch{return``}}var ip=5;function ap({panelId:e}){let t=bf(e=>e.activeProject),[n,r]=(0,B.useState)([]),[i,a]=(0,B.useState)(!1),o=(0,B.useCallback)(async()=>{if(t?.name){a(!0);try{r((await z.get(`${fe(t.name)}/chat/sessions`)).slice(0,ip))}catch{}finally{a(!1)}}},[t?.name]);(0,B.useEffect)(()=>{o()},[o]);function s(n){let r=n!==`settings`&&t?{projectName:t.name}:void 0;m.getState().openTab({type:n,title:ep.find(e=>e.type===n)?.label??n,metadata:r,projectId:t?.name??null,closable:!0},e)}function c(n){m.getState().openTab({type:`chat`,title:n.title||`Chat`,projectId:t?.name??null,metadata:{projectName:t?.name,sessionId:n.id,providerId:n.providerId},closable:!0},e)}return(0,H.jsx)(`div`,{className:`flex flex-col h-full overflow-y-auto text-text-secondary`,children:(0,H.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-6 px-4 flex-1`,children:[(0,H.jsx)(`p`,{className:`text-sm`,children:`Open a tab to get started`}),(0,H.jsx)(`div`,{className:`grid grid-cols-3 gap-2 w-full max-w-sm`,children:ep.map(e=>{let t=e.icon;return(0,H.jsxs)(`button`,{onClick:()=>s(e.type),className:`flex flex-col items-center justify-center gap-1.5 px-2 py-3 rounded-md border border-border bg-surface hover:bg-surface-elevated active:bg-surface-elevated text-xs text-foreground transition-colors`,children:[(0,H.jsx)(t,{className:`size-5`}),e.label]},e.type)})}),t&&!i&&n.length>0&&(0,H.jsxs)(`div`,{className:`flex flex-col gap-2 w-full max-w-sm`,children:[(0,H.jsx)(`p`,{className:`text-xs text-text-subtle text-center`,children:`Recent chats`}),(0,H.jsx)(`div`,{className:`w-full rounded-md border border-border bg-surface overflow-hidden`,children:n.map(e=>(0,H.jsxs)(`button`,{onClick:()=>c(e),className:`flex items-center gap-2.5 w-full px-3 py-2.5 text-left hover:bg-surface-elevated active:bg-surface-elevated transition-colors border-b border-border/50 last:border-0`,children:[(0,H.jsx)(_t,{className:`size-3.5 shrink-0 text-text-subtle`}),(0,H.jsx)(`span`,{className:`flex-1 min-w-0 text-xs font-medium truncate text-text-primary`,children:e.title||`Untitled`}),e.updatedAt&&(0,H.jsx)(`span`,{className:`text-[10px] text-text-subtle shrink-0`,children:rp(e.updatedAt)})]},e.id))})]})]})})}function op({projectName:e}){let t=m(t=>t.currentProject===e?t.grid:t.projectGrids[e]??[[]]),n=t.flat().length;return(0,B.useEffect)(()=>{if(n===0){let e=g();m.setState(t=>({panels:{...t.panels,[e.id]:e},grid:[[e.id]],focusedPanelId:e.id}))}},[n]),n===0?null:n===1&&t[0]?.[0]?(0,H.jsx)(np,{panelId:t[0][0],projectName:e}):(0,H.jsx)(lf,{orientation:`vertical`,style:{height:`100%`},children:t.map((n,r)=>(0,H.jsx)(sp,{row:n,rowIdx:r,totalRows:t.length,projectName:e},`row-${r}`))})}function sp({row:e,rowIdx:t,totalRows:n,projectName:r}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ff,{minSize:`15%`,defaultSize:`${Math.round(100/n)}%`,children:e.length===1?(0,H.jsx)(np,{panelId:e[0],projectName:r}):(0,H.jsx)(lf,{orientation:`horizontal`,children:e.map((t,n)=>(0,H.jsx)(cp,{panelId:t,colIdx:n,totalCols:e.length,projectName:r},t))})}),t<n-1&&(0,H.jsx)(lp,{orientation:`horizontal`})]})}function cp({panelId:e,colIdx:t,totalCols:n,projectName:r}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ff,{minSize:`15%`,defaultSize:`${Math.round(100/n)}%`,children:(0,H.jsx)(np,{panelId:e,projectName:r})}),t<n-1&&(0,H.jsx)(lp,{orientation:`vertical`})]})}function lp({orientation:e}){let t=e===`vertical`;return(0,H.jsx)(hf,{className:`
15
15
  group/handle relative flex items-center justify-center
16
16
  ${t?`w-1 cursor-col-resize`:`h-1 cursor-row-resize`}
17
17
  bg-border/30 hover:bg-primary/30 active:bg-primary/50
18
18
  transition-colors duration-150
19
- `,children:(0,H.jsx)(`div`,{className:`absolute opacity-0 group-hover/handle:opacity-70 transition-opacity text-foreground/50`,children:t?(0,H.jsx)(ot,{className:`size-3`}):(0,H.jsx)(at,{className:`size-3`})})})}var cp=v((e,t)=>({tree:[],loading:!1,error:null,expandedPaths:new Set,selectedFiles:[],fetchTree:async t=>{e({loading:!0,error:null});try{e({tree:await z.get(`${fe(t)}/files/tree?depth=3`),loading:!1})}catch(t){e({error:t instanceof Error?t.message:`Failed to load files`,loading:!1})}},toggleExpand:n=>{let r=new Set(t().expandedPaths);r.has(n)?r.delete(n):r.add(n),e({expandedPaths:r})},setExpanded:(n,r)=>{let i=new Set(t().expandedPaths);r?i.add(n):i.delete(n),e({expandedPaths:i})},toggleFileSelect:n=>{let r=t().selectedFiles;r.indexOf(n)>=0?e({selectedFiles:r.filter(e=>e!==n)}):e({selectedFiles:r.length>=2?[r[1],n]:[...r,n]})},clearSelection:()=>e({selectedFiles:[]}),reset:()=>e({tree:[],expandedPaths:new Set,error:null,selectedFiles:[]})}));function lp({className:e,children:t,...n}){return(0,H.jsxs)(Js,{"data-slot":`scroll-area`,className:R(`relative`,e),...n,children:[(0,H.jsx)(Ys,{"data-slot":`scroll-area-viewport`,className:`size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 [&>div]:!block`,children:t}),(0,H.jsx)(up,{}),(0,H.jsx)(Xs,{})]})}function up({className:e,orientation:t=`vertical`,...n}){return(0,H.jsx)(Ss,{"data-slot":`scroll-area-scrollbar`,orientation:t,className:R(`flex touch-none p-px transition-colors select-none`,t===`vertical`&&`h-full w-1.5 border-l border-l-transparent`,t===`horizontal`&&`h-1.5 flex-col border-t border-t-transparent`,e),...n,children:(0,H.jsx)(Ns,{"data-slot":`scroll-area-thumb`,className:`relative flex-1 rounded-full bg-border`})})}function dp({...e}){return(0,H.jsx)(fo,{"data-slot":`context-menu`,...e})}function fp({...e}){return(0,H.jsx)(po,{"data-slot":`context-menu-trigger`,...e})}function pp({className:e,...t}){return(0,H.jsx)(mo,{children:(0,H.jsx)(ho,{"data-slot":`context-menu-content`,className:R(`z-50 max-h-(--radix-context-menu-content-available-height) min-w-[8rem] origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,e),...t})})}function mp({className:e,inset:t,variant:n=`default`,...r}){return(0,H.jsx)(go,{"data-slot":`context-menu-item`,"data-inset":t,"data-variant":n,className:R(`relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive!`,e),...r})}function hp({className:e,...t}){return(0,H.jsx)(_o,{"data-slot":`context-menu-separator`,className:R(`-mx-1 my-1 h-px bg-border`,e),...t})}function gp({...e}){return(0,H.jsx)(vr,{"data-slot":`dialog`,...e})}function _p({...e}){return(0,H.jsx)(yr,{"data-slot":`dialog-portal`,...e})}function vp({className:e,...t}){return(0,H.jsx)(br,{"data-slot":`dialog-overlay`,className:R(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function yp({className:e,children:t,showCloseButton:n=!0,...r}){return(0,H.jsxs)(_p,{"data-slot":`dialog-portal`,children:[(0,H.jsx)(vp,{}),(0,H.jsxs)(xr,{"data-slot":`dialog-content`,className:R(`fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background text-foreground p-6 shadow-lg duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg`,e),...r,children:[t,n&&(0,H.jsxs)(wr,{"data-slot":`dialog-close`,className:`absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,H.jsx)(Gt,{}),(0,H.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function bp({className:e,...t}){return(0,H.jsx)(`div`,{"data-slot":`dialog-header`,className:R(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function xp({className:e,showCloseButton:t=!1,children:n,...r}){return(0,H.jsxs)(`div`,{"data-slot":`dialog-footer`,className:R(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...r,children:[n,t&&(0,H.jsx)(wr,{asChild:!0,children:(0,H.jsx)(c,{variant:`outline`,children:`Close`})})]})}function Sp({className:e,...t}){return(0,H.jsx)(Sr,{"data-slot":`dialog-title`,className:R(`text-lg leading-none font-semibold`,e),...t})}function Cp({className:e,...t}){return(0,H.jsx)(Cr,{"data-slot":`dialog-description`,className:R(`text-sm text-muted-foreground`,e),...t})}function wp({action:e,node:t,projectName:n,onClose:r,onRefresh:i}){let[a,o]=(0,B.useState)(``),[s,l]=(0,B.useState)(!1),[d,f]=(0,B.useState)(null),p=(0,B.useRef)(null);(0,B.useEffect)(()=>{o(e===`rename`?t.name:``)},[e,t.name]),(0,B.useEffect)(()=>{let e=setTimeout(()=>p.current?.focus(),100);return()=>clearTimeout(e)},[]);async function m(e){if(a.trim()){l(!0),f(null);try{let o=t.type===`directory`?t.path:t.path.split(`/`).slice(0,-1).join(`/`),s=o?`${o}/${a.trim()}`:a.trim();await z.post(`${fe(n)}/files/create`,{path:s,type:e}),i(),r()}catch(e){f(e instanceof Error?e.message:`Failed to create`)}finally{l(!1)}}}async function h(){if(!a.trim()||a.trim()===t.name){r();return}l(!0),f(null);try{let e=t.path.split(`/`).slice(0,-1).join(`/`),o=e?`${e}/${a.trim()}`:a.trim();await z.post(`${fe(n)}/files/rename`,{oldPath:t.path,newPath:o}),i(),r()}catch(e){f(e instanceof Error?e.message:`Failed to rename`)}finally{l(!1)}}async function g(){l(!0),f(null);try{await z.del(`${fe(n)}/files/delete`,{path:t.path}),i(),r()}catch(e){f(e instanceof Error?e.message:`Failed to delete`)}finally{l(!1)}}function _(t){t.key===`Enter`&&(e===`new-file`?m(`file`):e===`new-folder`?m(`directory`):e===`rename`&&h()),t.key===`Escape`&&r()}if(e===`delete`)return(0,H.jsx)(gp,{open:!0,onOpenChange:e=>!e&&r(),children:(0,H.jsxs)(yp,{children:[(0,H.jsxs)(bp,{children:[(0,H.jsxs)(Sp,{children:[`Delete `,t.type===`directory`?`Folder`:`File`]}),(0,H.jsxs)(Cp,{children:[`Are you sure you want to delete`,` `,(0,H.jsx)(`span`,{className:`font-mono font-semibold`,children:t.name}),`?`,t.type===`directory`&&` This will delete all contents.`]})]}),d&&(0,H.jsx)(`p`,{className:`text-sm text-error`,children:d}),(0,H.jsxs)(xp,{children:[(0,H.jsx)(c,{variant:`outline`,onClick:r,disabled:s,children:`Cancel`}),(0,H.jsx)(c,{variant:`destructive`,onClick:g,disabled:s,children:s?`Deleting...`:`Delete`})]})]})});let v=e===`new-file`?`New File`:e===`new-folder`?`New Folder`:`Rename`,y=e===`rename`?t.name:e===`new-file`?`filename.ts`:`folder-name`;return(0,H.jsx)(gp,{open:!0,onOpenChange:e=>!e&&r(),children:(0,H.jsxs)(yp,{children:[(0,H.jsxs)(bp,{children:[(0,H.jsx)(Sp,{children:v}),(0,H.jsx)(Cp,{children:e===`rename`?`Rename "${t.name}" to:`:`Create in ${t.type===`directory`?t.path||`/`:t.path.split(`/`).slice(0,-1).join(`/`)||`/`}`})]}),(0,H.jsx)(u,{ref:p,value:a,onChange:e=>o(e.target.value),onKeyDown:_,placeholder:y,disabled:s}),d&&(0,H.jsx)(`p`,{className:`text-sm text-error`,children:d}),(0,H.jsxs)(xp,{children:[(0,H.jsx)(c,{variant:`outline`,onClick:r,disabled:s,children:`Cancel`}),(0,H.jsx)(c,{onClick:()=>{e===`new-file`?m(`file`):e===`new-folder`?m(`directory`):h()},disabled:s||!a.trim(),children:s?`Saving...`:e===`rename`?`Rename`:`Create`})]})]})})}var Tp={ts:Je,tsx:Je,js:Je,jsx:Je,py:Je,rs:Je,go:Je,json:qe,md:Xe,txt:Xe,yaml:Ze,yml:Ze,html:Je,css:Je,scss:Je};function Ep(e){return Tp[e.split(`.`).pop()?.toLowerCase()??``]??Qe}function Dp({node:e,depth:t,projectName:n,onAction:r,onFileOpen:i}){let{expandedPaths:a,toggleExpand:o,selectedFiles:c,toggleFileSelect:l}=cp(),u=_(e=>e.openTab),f=a.has(e.path),p=e.type===`directory`,m=c.includes(e.path),h=e.ignored===!0;function g(t){if(p){o(e.path);return}if(t.metaKey||t.ctrlKey){l(e.path);return}let r=e.name.split(`.`).pop()?.toLowerCase()??``;u({type:r===`db`||r===`sqlite`||r===`sqlite3`?`sqlite`:`editor`,title:e.name,metadata:{filePath:e.path,projectName:n},projectId:n,closable:!0}),i?.()}let v=p?f?$e:tt:Ep(e.name),y=e.children?[...e.children].sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1):[];return(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(dp,{children:[(0,H.jsx)(fp,{asChild:!0,children:(0,H.jsxs)(`button`,{onClick:g,className:R(`flex items-center w-full gap-1.5 px-2 py-1 rounded-sm text-sm`,`min-h-[32px] hover:bg-surface-elevated transition-colors text-left`,`select-none`,h&&`opacity-40`,m&&`bg-primary/15 ring-1 ring-primary/40`),style:{paddingLeft:`${t*16+8}px`},children:[p?f?(0,H.jsx)(s,{className:`size-3.5 shrink-0 text-text-subtle`}):(0,H.jsx)(d,{className:`size-3.5 shrink-0 text-text-subtle`}):(0,H.jsx)(`span`,{className:`w-3.5 shrink-0`}),(0,H.jsx)(v,{className:R(`size-4 shrink-0`,p?`text-primary`:`text-text-secondary`)}),(0,H.jsx)(`span`,{className:`truncate`,children:e.name})]})}),(0,H.jsxs)(pp,{children:[p&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(mp,{onClick:()=>r(`new-file`,e),children:`New File`}),(0,H.jsx)(mp,{onClick:()=>r(`new-folder`,e),children:`New Folder`}),(0,H.jsx)(hp,{})]}),(0,H.jsx)(mp,{onClick:()=>r(`rename`,e),children:`Rename`}),(0,H.jsx)(mp,{variant:`destructive`,onClick:()=>r(`delete`,e),children:`Delete`}),(0,H.jsx)(hp,{}),(0,H.jsx)(mp,{onClick:()=>r(`copy-path`,e),children:`Copy Path`}),!p&&c.length===2&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(hp,{}),(0,H.jsx)(mp,{onClick:()=>r(`compare-selected`,e),children:`Compare Selected`})]})]})]}),p&&f&&y.map(e=>(0,H.jsx)(Dp,{node:e,depth:t+1,projectName:n,onAction:r,onFileOpen:i},e.path))]})}function Op({onFileOpen:e}={}){let{tree:t,loading:n,error:r,fetchTree:i,reset:a,selectedFiles:o,clearSelection:s}=cp(),c=bf(e=>e.activeProject),l=_(e=>e.openTab),[u,d]=(0,B.useState)(null),f=(0,B.useCallback)(()=>{c&&i(c.name)},[c,i]);(0,B.useEffect)(()=>{c&&(a(),f())},[c?.name]),(0,B.useEffect)(()=>{let e=()=>{c&&i(c.name)};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[c,i]);function p(e,t){if(e===`copy-path`){navigator.clipboard.writeText(t.path).catch(()=>{});return}if(e===`compare-selected`&&o.length===2){let e=o[0],t=o[1];l({type:`git-diff`,title:`Compare ${ue(e)} vs ${ue(t)}`,closable:!0,metadata:{projectName:c.name,file1:e,file2:t},projectId:c.name}),s();return}d({action:e,node:t})}if(!c)return(0,H.jsx)(`div`,{className:`p-3 text-xs text-text-subtle`,children:`Select a project to browse files.`});if(n&&t.length===0)return(0,H.jsxs)(`div`,{className:`flex items-center gap-2 p-3 text-xs text-text-secondary`,children:[(0,H.jsx)(pt,{className:`size-3 animate-spin`}),`Loading files...`]});if(r)return(0,H.jsxs)(`div`,{className:`p-3 text-xs text-error`,children:[r,(0,H.jsx)(`button`,{onClick:f,className:`block mt-1 text-primary underline`,children:`Retry`})]});let m=[...t].sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(lp,{className:`flex-1`,children:(0,H.jsxs)(`div`,{className:`py-1`,children:[m.map(t=>(0,H.jsx)(Dp,{node:t,depth:0,projectName:c.name,onAction:p,onFileOpen:e},t.path)),m.length===0&&(0,H.jsx)(`p`,{className:`p-3 text-xs text-text-subtle`,children:`Empty project.`})]})}),u&&(0,H.jsx)(wp,{action:u.action,node:u.node,projectName:c.name,onClose:()=>d(null),onRefresh:f})]})}function kp({...e}){return(0,H.jsx)(es,{"data-slot":`dropdown-menu`,...e})}function Ap({...e}){return(0,H.jsx)(ts,{"data-slot":`dropdown-menu-trigger`,...e})}function jp({className:e,sideOffset:t=4,...n}){return(0,H.jsx)(ns,{children:(0,H.jsx)(rs,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:R(`z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,e),...n})})}function Mp({className:e,inset:t,variant:n=`default`,...r}){return(0,H.jsx)(is,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:R(`relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive!`,e),...r})}function Np({...e}){return(0,H.jsx)(as,{"data-slot":`dropdown-menu-sub`,...e})}function Pp({className:e,inset:t,children:n,...r}){return(0,H.jsxs)(os,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":t,className:R(`flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[inset]:pl-8 data-[state=open]:bg-accent data-[state=open]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,H.jsx)(d,{className:`ml-auto size-4`})]})}function Fp({className:e,...t}){return(0,H.jsx)(ss,{"data-slot":`dropdown-menu-sub-content`,className:R(`z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,e),...t})}var Ip={M:`text-yellow-500`,A:`text-green-500`,D:`text-red-500`,R:`text-blue-500`,C:`text-purple-500`,"?":`text-gray-400`};function Lp(e){let t=[];for(let n of e){let e=n.path.split(`/`),r=t;for(let t=0;t<e.length;t++){let i=e[t],a=e.slice(0,t+1).join(`/`),o=t===e.length-1,s=r.find(e=>e.name===i);s||(s={name:i,fullPath:a,file:o?n:void 0,children:[]},r.push(s)),o&&(s.file=n),r=s.children}}return t}function Rp(e){let t=[];e.file&&t.push(e.file);for(let n of e.children)t.push(...Rp(n));return t}function zp({metadata:e,tabId:t,onNavigate:n}){let r=e?.projectName,[i,a]=(0,B.useState)(null),[o,s]=(0,B.useState)(!0),[l,u]=(0,B.useState)(null),[d,f]=(0,B.useState)(``),[p,m]=(0,B.useState)(!1),[h,g]=(0,B.useState)(null),{openTab:v}=_(),y=V(e=>e.gitStatusViewMode),b=V(e=>e.setGitStatusViewMode),x=(0,B.useCallback)(async()=>{if(r)try{s(!0),a(await z.get(`${fe(r)}/git/status`)),u(null)}catch(e){u(e instanceof Error?e.message:`Failed to fetch status`)}finally{s(!1)}},[r]);(0,B.useEffect)(()=>{x();let e=setInterval(x,5e3);return()=>clearInterval(e)},[x]);let S=async e=>{if(r){m(!0);try{await z.post(`${fe(r)}/git/stage`,{files:e}),await x()}catch(e){u(e instanceof Error?e.message:`Stage failed`)}finally{m(!1)}}},C=async e=>{if(r){m(!0);try{await z.post(`${fe(r)}/git/unstage`,{files:e}),await x()}catch(e){u(e instanceof Error?e.message:`Unstage failed`)}finally{m(!1)}}},w=async e=>{if(r){m(!0);try{await z.post(`${fe(r)}/git/discard`,{files:e}),await x()}catch(e){u(e instanceof Error?e.message:`Discard failed`)}finally{m(!1)}}},T=async()=>{h&&(await w(h.files),g(null))},E=async()=>{if(!(!r||!d.trim()||!i?.staged.length)){m(!0);try{await z.post(`${fe(r)}/git/commit`,{message:d.trim()}),f(``),await x()}catch(e){u(e instanceof Error?e.message:`Commit failed`)}finally{m(!1)}}},D=async()=>{if(r){m(!0);try{await z.post(`${fe(r)}/git/push`,{}),await x()}catch(e){u(e instanceof Error?e.message:`Push failed`)}finally{m(!1)}}},O=async()=>{if(r){m(!0);try{await z.post(`${fe(r)}/git/pull`,{}),await x()}catch(e){u(e instanceof Error?e.message:`Pull failed`)}finally{m(!1)}}},ee=e=>{v({type:`git-diff`,title:ue(e.path),closable:!0,metadata:{projectName:r,filePath:e.path},projectId:r??null}),n?.()},k=e=>{v({type:`editor`,title:ue(e.path),closable:!0,metadata:{projectName:r,filePath:e.path},projectId:r??null}),n?.()},A=(0,B.useMemo)(()=>[...i?.unstaged??[],...i?.untracked.map(e=>({path:e,status:`?`}))??[]],[i]);return r?o&&!i?(0,H.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,H.jsx)(pt,{className:`size-5 animate-spin`}),(0,H.jsx)(`span`,{className:`text-sm`,children:`Loading git status...`})]}):l&&!i?(0,H.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-2 text-destructive text-sm`,children:[(0,H.jsx)(`p`,{children:l}),(0,H.jsx)(c,{variant:`outline`,size:`sm`,onClick:x,children:`Retry`})]}):(0,H.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b shrink-0`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:i?.current?`On: ${i.current}`:`Git Status`}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(c,{variant:y===`flat`?`secondary`:`ghost`,size:`icon-xs`,onClick:()=>b(`flat`),title:`Flat view`,children:(0,H.jsx)(ft,{className:`size-3.5`})}),(0,H.jsx)(c,{variant:y===`tree`?`secondary`:`ghost`,size:`icon-xs`,onClick:()=>b(`tree`),title:`Tree view`,children:(0,H.jsx)(et,{className:`size-3.5`})}),(0,H.jsx)(c,{variant:`ghost`,size:`icon-xs`,onClick:x,disabled:p,children:(0,H.jsx)(kt,{className:o?`animate-spin`:``})})]})]}),l&&(0,H.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-destructive bg-destructive/10 shrink-0`,children:l}),(0,H.jsx)(lp,{className:`flex-1 overflow-hidden`,children:(0,H.jsxs)(`div`,{className:`p-1.5 space-y-2 overflow-hidden`,children:[(0,H.jsx)(Vp,{title:`Staged Changes`,count:i?.staged.length??0,files:i?.staged??[],viewMode:y,actionIcon:(0,H.jsx)(yt,{className:`size-3`}),actionAllIcon:(0,H.jsx)(yt,{className:`size-3`}),actionTitle:`Unstage`,onAction:e=>C([e.path]),onActionAll:i?.staged.length?()=>C(i.staged.map(e=>e.path)):void 0,actionAllLabel:`Unstage All`,onFolderAction:e=>C(e.map(e=>e.path)),onClickFile:ee,onOpenFile:k,disabled:p}),(0,H.jsx)(Vp,{title:`Changes`,count:A.length,files:A,viewMode:y,actionIcon:(0,H.jsx)(Ot,{className:`size-3`}),actionAllIcon:(0,H.jsx)(Ot,{className:`size-3`}),actionTitle:`Stage`,onAction:e=>S([e.path]),onActionAll:A.length?()=>S(A.map(e=>e.path)):void 0,actionAllLabel:`Stage All`,onFolderAction:e=>S(e.map(e=>e.path)),onClickFile:ee,onOpenFile:k,disabled:p,showRevert:!0,onRevert:e=>g({label:e.path,files:[e.path]}),onFolderRevert:(e,t)=>g({label:`${t}/ (${e.length} files)`,files:e.map(e=>e.path)})})]})}),(0,H.jsxs)(`div`,{className:`border-t p-2 space-y-2 shrink-0`,children:[(0,H.jsx)(`textarea`,{className:`w-full h-16 px-3 py-2 text-base md:text-sm text-foreground bg-surface border border-border rounded-lg resize-none focus:outline-none focus:border-ring placeholder:text-muted-foreground`,placeholder:`Commit message...`,value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&E()}}),(0,H.jsx)(c,{size:`sm`,className:`w-full`,disabled:p||!d.trim()||!i?.staged.length,onClick:E,children:p?(0,H.jsx)(pt,{className:`size-3 animate-spin`}):`Commit (${i?.staged.length??0})`}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsxs)(c,{variant:`outline`,size:`sm`,className:`flex-1`,disabled:p,onClick:D,children:[(0,H.jsx)(Te,{className:`size-3`}),`Push`]}),(0,H.jsxs)(c,{variant:`outline`,size:`sm`,className:`flex-1`,disabled:p,onClick:O,children:[(0,H.jsx)(Se,{className:`size-3`}),`Pull`]})]})]}),(0,H.jsx)(gp,{open:!!h,onOpenChange:e=>!e&&g(null),children:(0,H.jsxs)(yp,{showCloseButton:!1,children:[(0,H.jsxs)(bp,{children:[(0,H.jsx)(Sp,{children:`Discard Changes`}),(0,H.jsxs)(Cp,{children:[`Are you sure you want to discard all changes to`,` `,(0,H.jsx)(`code`,{className:`px-1 py-0.5 rounded bg-muted text-sm font-mono`,children:h?.label}),`? This action cannot be undone.`]})]}),(0,H.jsxs)(xp,{children:[(0,H.jsx)(c,{variant:`outline`,onClick:()=>g(null),children:`Cancel`}),(0,H.jsx)(c,{variant:`destructive`,onClick:T,disabled:p,children:p?(0,H.jsx)(pt,{className:`size-3 animate-spin`}):`Discard`})]})]})})]}):(0,H.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`No project selected.`})}function Bp({showRevert:e,onRevert:t,onAction:n,onOpenFile:r,actionIcon:i,actionTitle:a,disabled:o}){return(0,H.jsxs)(`div`,{className:`hidden md:flex absolute right-0 top-0 bottom-0 items-center gap-0.5 pl-6 pr-1 bg-gradient-to-l from-background from-70% to-transparent opacity-0 group-hover:opacity-100 transition-opacity`,children:[r&&(0,H.jsx)(`button`,{type:`button`,className:`flex items-center justify-center size-5 rounded text-muted-foreground hover:text-primary active:scale-95 transition-colors`,onClick:e=>{e.stopPropagation(),r()},disabled:o,title:`Open file`,children:(0,H.jsx)(Xe,{className:`size-3`})}),e&&t&&(0,H.jsx)(`button`,{type:`button`,className:`flex items-center justify-center size-5 rounded text-muted-foreground hover:text-destructive active:scale-95 transition-colors`,onClick:e=>{e.stopPropagation(),t()},disabled:o,title:`Discard changes`,children:(0,H.jsx)(Vt,{className:`size-3`})}),(0,H.jsx)(`button`,{type:`button`,className:`flex items-center justify-center size-5 rounded text-muted-foreground hover:text-accent-foreground active:scale-95 transition-colors`,onClick:e=>{e.stopPropagation(),n()},disabled:o,title:a,children:i})]})}function Vp({title:e,count:t,files:n,viewMode:r,actionIcon:i,actionAllIcon:a,actionTitle:o,onAction:s,onActionAll:c,actionAllLabel:l,onFolderAction:u,onClickFile:d,onOpenFile:f,disabled:p,showRevert:m,onRevert:h,onFolderRevert:g}){return(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between mb-0.5`,children:[(0,H.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase`,children:[e,` (`,t,`)`]}),c&&t>0&&(0,H.jsx)(`button`,{type:`button`,className:`flex items-center justify-center size-5 rounded text-muted-foreground hover:text-accent-foreground active:scale-95 transition-colors`,onClick:c,disabled:p,title:l,children:a})]}),n.length===0?(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground px-1`,children:`No changes`}):r===`flat`?(0,H.jsx)(`div`,{className:`w-full overflow-hidden`,children:n.map(e=>(0,H.jsx)(Up,{file:e,actionIcon:i,actionTitle:o,onAction:s,onClickFile:d,onOpenFile:f,disabled:p,showRevert:m,onRevert:h},e.path))}):(0,H.jsx)(Wp,{files:n,actionIcon:i,actionTitle:o,onAction:s,onFolderAction:u,onClickFile:d,onOpenFile:f,disabled:p,showRevert:m,onRevert:h,onFolderRevert:g})]})}function Hp(e,t,n=400){let r=(0,B.useRef)(null),i=(0,B.useRef)(!1),a=(0,B.useRef)(!1),o=(0,B.useCallback)(()=>{r.current&&=(clearTimeout(r.current),null)},[]);return{onTouchStart:(0,B.useCallback)(t=>{i.current=!1,a.current=!1,r.current=setTimeout(()=>{a.current=!0,e()},n)},[e,n]),onTouchMove:(0,B.useCallback)(()=>{i.current=!0,o()},[o]),onTouchEnd:(0,B.useCallback)(e=>{o(),!i.current&&!a.current&&(e.preventDefault(),t())},[o,t])}}function Up({file:e,actionIcon:t,actionTitle:n,onAction:r,onClickFile:i,onOpenFile:a,disabled:o,showRevert:s,onRevert:c,displayName:l}){let[u,d]=(0,B.useState)(!1),f=Hp((0,B.useCallback)(()=>d(!0),[]),(0,B.useCallback)(()=>i(e),[i,e])),p=(0,H.jsxs)(`div`,{className:`group relative flex items-center gap-1 hover:bg-muted/50 rounded pl-1 py-px w-full min-w-0`,children:[(0,H.jsx)(`span`,{className:`text-xs font-mono w-4 text-center shrink-0 ${Ip[e.status]??``}`,children:e.status}),(0,H.jsx)(`button`,{type:`button`,className:`hidden md:block flex-1 text-left text-xs font-mono truncate hover:underline min-w-0`,onClick:()=>i(e),title:e.path,children:l??e.path}),(0,H.jsx)(`span`,{className:`md:hidden flex-1 text-left text-xs font-mono truncate min-w-0 select-none`,children:l??e.path}),(0,H.jsx)(Bp,{showRevert:s,onRevert:c?()=>c(e):void 0,onOpenFile:a?()=>a(e):void 0,onAction:()=>r(e),actionIcon:t,actionTitle:n,disabled:o})]});return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`hidden md:block`,children:p}),(0,H.jsx)(`div`,{className:`md:hidden select-none`,...f,children:(0,H.jsxs)(kp,{open:u,onOpenChange:d,children:[(0,H.jsx)(Ap,{asChild:!0,children:p}),(0,H.jsxs)(jp,{align:`start`,className:`min-w-40`,children:[(0,H.jsx)(Mp,{onClick:()=>i(e),children:`View Diff`}),a&&(0,H.jsx)(Mp,{onClick:()=>a(e),children:`Open File`}),(0,H.jsx)(Mp,{onClick:()=>r(e),disabled:o,children:n}),s&&c&&(0,H.jsx)(Mp,{className:`text-destructive focus:text-destructive`,onClick:()=>c(e),disabled:o,children:`Discard Changes`})]})]})})]})}function Wp({files:e,actionIcon:t,actionTitle:n,onAction:r,onFolderAction:i,onClickFile:a,onOpenFile:o,disabled:s,showRevert:c,onRevert:l,onFolderRevert:u}){let d=(0,B.useMemo)(()=>Lp(e),[e]);return(0,H.jsx)(`div`,{children:d.map((e,f)=>(0,H.jsx)(Gp,{node:e,depth:0,isLast:f===d.length-1,actionIcon:t,actionTitle:n,onAction:r,onFolderAction:i,onClickFile:a,onOpenFile:o,disabled:s,showRevert:c,onRevert:l,onFolderRevert:u},e.fullPath))})}function Gp({node:e,depth:t,isLast:n,actionIcon:r,actionTitle:i,onAction:a,onFolderAction:o,onClickFile:c,onOpenFile:l,disabled:u,showRevert:f,onRevert:p,onFolderRevert:m}){let[h,g]=(0,B.useState)(!0),_=e.children.length>0&&!e.file,v=t*12-6,y=`absolute border-dashed border-border`;if(e.file)return(0,H.jsxs)(`div`,{className:`relative`,style:{paddingLeft:t*12},children:[t>0&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`${y} border-l`,style:{left:v,top:0,bottom:n?`50%`:0}}),(0,H.jsx)(`div`,{className:`${y} border-t`,style:{left:v,top:`50%`,width:6}})]}),(0,H.jsx)(Up,{file:e.file,displayName:e.name,actionIcon:r,actionTitle:i,onAction:a,onClickFile:c,onOpenFile:l,disabled:u,showRevert:f,onRevert:p})]});if(_){let _=Rp(e);return(0,H.jsxs)(`div`,{className:`relative`,children:[t>0&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`${y} border-l`,style:{left:v,top:0,...n?{height:13}:{bottom:0}}}),(0,H.jsx)(`div`,{className:`${y} border-t`,style:{left:v,top:13,width:8}})]}),(()=>{let n=(0,H.jsxs)(`div`,{className:`group relative flex items-center hover:bg-muted/50 rounded py-0.5`,style:{paddingLeft:t*12+2},children:[(0,H.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 flex-1 min-w-0 text-xs font-mono text-muted-foreground`,onClick:()=>g(!h),children:[h?(0,H.jsx)(s,{className:`size-3.5 shrink-0`}):(0,H.jsx)(d,{className:`size-3.5 shrink-0`}),(0,H.jsx)(`span`,{className:`truncate font-semibold`,children:e.name}),(0,H.jsxs)(`span`,{className:`text-[10px] opacity-60 shrink-0`,children:[`(`,_.length,`)`]})]}),(0,H.jsx)(Bp,{showRevert:f,onRevert:m?()=>m(_,e.fullPath):void 0,onAction:()=>o?.(_),actionIcon:r,actionTitle:`${i} ${e.name}/`,disabled:u})]});return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`hidden md:block`,children:n}),(0,H.jsx)(`div`,{className:`md:hidden`,children:(0,H.jsxs)(kp,{children:[(0,H.jsx)(Ap,{asChild:!0,children:n}),(0,H.jsxs)(jp,{align:`start`,className:`min-w-40`,children:[(0,H.jsxs)(Mp,{onClick:()=>o?.(_),disabled:u,children:[i,` `,e.name,`/`]}),m&&(0,H.jsx)(Mp,{className:`text-destructive focus:text-destructive`,onClick:()=>m(_,e.fullPath),disabled:u,children:`Discard Changes`})]})]})})]})})(),h&&(0,H.jsx)(`div`,{children:e.children.map((n,s)=>(0,H.jsx)(Gp,{node:n,depth:t+1,isLast:s===e.children.length-1,actionIcon:r,actionTitle:i,onAction:a,onFolderAction:o,onClickFile:c,onOpenFile:l,disabled:u,showRevert:f,onRevert:p,onFolderRevert:m},n.fullPath))})]})}return null}function Kp({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,H.jsx)(Dl,{"data-slot":`separator`,decorative:n,orientation:t,className:R(`shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px`,e),...r})}function qp({className:e,...t}){return(0,H.jsx)(us,{"data-slot":`label`,className:R(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}function Jp({...e}){return(0,H.jsx)(ul,{"data-slot":`select`,...e})}function Yp({...e}){return(0,H.jsx)(fl,{"data-slot":`select-value`,...e})}function Xp({className:e,size:t=`default`,children:n,...r}){return(0,H.jsxs)(dl,{"data-slot":`select-trigger`,"data-size":t,className:R(`flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,H.jsx)(pl,{asChild:!0,children:(0,H.jsx)(s,{className:`size-4 opacity-50`})})]})}function Zp({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,H.jsx)(ml,{children:(0,H.jsxs)(hl,{"data-slot":`select-content`,className:R(`relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...i,children:[(0,H.jsx)($p,{}),(0,H.jsx)(gl,{className:R(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,H.jsx)(em,{})]})})}function Qp({className:e,children:t,...n}){return(0,H.jsxs)(_l,{"data-slot":`select-item`,className:R(`relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,H.jsx)(`span`,{"data-slot":`select-item-indicator`,className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,H.jsx)(yl,{children:(0,H.jsx)(o,{className:`size-4`})})}),(0,H.jsx)(vl,{children:t})]})}function $p({className:e,...t}){return(0,H.jsx)(bl,{"data-slot":`select-scroll-up-button`,className:R(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,H.jsx)(Ne,{className:`size-4`})})}function em({className:e,...t}){return(0,H.jsx)(xl,{"data-slot":`select-scroll-down-button`,className:R(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,H.jsx)(s,{className:`size-4`})})}var tm=[{value:`claude-sonnet-4-6`,label:`Claude Sonnet 4.6`},{value:`claude-opus-4-6`,label:`Claude Opus 4.6`},{value:`claude-haiku-4-5`,label:`Claude Haiku 4.5`}],nm=[{value:`low`,label:`Low`},{value:`medium`,label:`Medium`},{value:`high`,label:`High`}],rm=[{value:`bypassPermissions`,label:`Bypass permissions (default)`},{value:`default`,label:`Ask before edits`},{value:`acceptEdits`,label:`Edit automatically`},{value:`plan`,label:`Plan mode`}];function im({compact:e}={}){let[t,n]=(0,B.useState)(null),[r,i]=(0,B.useState)(!1),[a,o]=(0,B.useState)(null),[s,c]=(0,B.useState)(0);(0,B.useEffect)(()=>{he().then(n).catch(e=>o(e.message))},[]);let l=t?.default_provider??`claude`,d=t?.providers[l],f=async(e,r)=>{if(t){i(!0),o(null);try{n(await me({providers:{[l]:{[e]:r}}})),c(e=>e+1)}catch(e){o(e.message)}finally{i(!1)}}},p=e?`text-[11px]`:`text-sm`,m=e?`text-xs`:`text-sm`,h=e?`space-y-2`:`space-y-4`,g=e?`space-y-1.5`:`space-y-3`,_=e?`space-y-1`:`space-y-1.5`;return t?(0,H.jsxs)(`div`,{className:h,children:[(0,H.jsx)(`h3`,{className:`${m} font-medium text-text-secondary`,children:`AI Provider`}),(0,H.jsxs)(`div`,{className:g,children:[(0,H.jsxs)(`div`,{className:_,children:[(0,H.jsx)(qp,{htmlFor:`ai-model`,className:e?p:void 0,children:`Model`}),(0,H.jsxs)(Jp,{value:d?.model??`claude-sonnet-4-6`,onValueChange:e=>f(`model`,e),children:[(0,H.jsx)(Xp,{id:`ai-model`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,H.jsx)(Yp,{})}),(0,H.jsx)(Zp,{children:tm.map(e=>(0,H.jsx)(Qp,{value:e.value,children:e.label},e.value))})]})]}),(0,H.jsxs)(`div`,{className:_,children:[(0,H.jsx)(qp,{htmlFor:`ai-base-url`,className:e?p:void 0,children:`Base URL`}),(0,H.jsx)(u,{id:`ai-base-url`,type:`url`,defaultValue:d?.base_url??``,placeholder:`https://api.anthropic.com (default)`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{f(`base_url`,e.target.value.trim()||void 0)}},`baseurl-${s}`)]}),(0,H.jsxs)(`div`,{className:_,children:[(0,H.jsx)(qp,{htmlFor:`ai-api-key`,className:e?p:void 0,children:`API Key / Token`}),(0,H.jsx)(u,{id:`ai-api-key`,type:`password`,defaultValue:d?.api_key??``,placeholder:`sk-ant-... (optional, overrides accounts)`,className:e?`h-7 text-[11px] font-mono`:`font-mono`,onBlur:e=>{let t=e.target.value.trim();t.startsWith(`••••`)||f(`api_key`,t||void 0)}},`apikey-${s}`),(0,H.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Direct API key or OAuth token. Leave empty to use connected accounts.`})]}),(0,H.jsxs)(`div`,{className:_,children:[(0,H.jsx)(qp,{htmlFor:`ai-effort`,className:e?p:void 0,children:`Effort`}),(0,H.jsxs)(Jp,{value:d?.effort??`high`,onValueChange:e=>f(`effort`,e),children:[(0,H.jsx)(Xp,{id:`ai-effort`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,H.jsx)(Yp,{})}),(0,H.jsx)(Zp,{children:nm.map(e=>(0,H.jsx)(Qp,{value:e.value,children:e.label},e.value))})]})]}),(0,H.jsxs)(`div`,{className:_,children:[(0,H.jsx)(qp,{htmlFor:`ai-max-turns`,className:e?p:void 0,children:`Max Turns (1-500)`}),(0,H.jsx)(u,{id:`ai-max-turns`,type:`number`,min:1,max:500,defaultValue:d?.max_turns??100,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseInt(e.target.value);isNaN(t)||f(`max_turns`,t)}},`turns-${s}`)]}),(0,H.jsxs)(`div`,{className:_,children:[(0,H.jsx)(qp,{htmlFor:`ai-budget`,className:e?p:void 0,children:`Max Budget (USD)`}),(0,H.jsx)(u,{id:`ai-budget`,type:`number`,step:.1,min:.01,max:50,defaultValue:d?.max_budget_usd??``,placeholder:`No limit`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseFloat(e.target.value);f(`max_budget_usd`,isNaN(t)?void 0:t)}},`budget-${s}`)]}),(0,H.jsxs)(`div`,{className:_,children:[(0,H.jsx)(qp,{htmlFor:`ai-thinking`,className:e?p:void 0,children:`Thinking Budget (tokens)`}),(0,H.jsx)(u,{id:`ai-thinking`,type:`number`,min:0,defaultValue:d?.thinking_budget_tokens??``,placeholder:`Disabled`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseInt(e.target.value);f(`thinking_budget_tokens`,isNaN(t)?void 0:t)}},`thinking-${s}`)]}),(0,H.jsxs)(`div`,{className:_,children:[(0,H.jsx)(qp,{htmlFor:`ai-permission-mode`,className:e?p:void 0,children:`Default Permission Mode`}),(0,H.jsxs)(Jp,{value:d?.permission_mode??`bypassPermissions`,onValueChange:e=>f(`permission_mode`,e),children:[(0,H.jsx)(Xp,{id:`ai-permission-mode`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,H.jsx)(Yp,{})}),(0,H.jsx)(Zp,{children:rm.map(e=>(0,H.jsx)(Qp,{value:e.value,children:e.label},e.value))})]})]}),(0,H.jsxs)(`div`,{className:_,children:[(0,H.jsx)(qp,{htmlFor:`ai-system-prompt`,className:e?p:void 0,children:`Additional Instructions`}),(0,H.jsx)(`textarea`,{id:`ai-system-prompt`,rows:4,defaultValue:d?.system_prompt??``,placeholder:`Enter additional instructions for Claude...`,className:`w-full rounded-md border border-input bg-background px-3 py-2 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${e?`text-[11px]`:`text-sm`}`,onBlur:e=>{f(`system_prompt`,e.target.value.trim()||void 0)}},`sysprompt-${s}`)]})]}),r&&(0,H.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`Saving...`}),a&&(0,H.jsx)(`p`,{className:`text-xs text-red-500`,children:a})]}):(0,H.jsxs)(`div`,{className:g,children:[(0,H.jsx)(`h3`,{className:`${m} font-medium text-text-secondary`,children:`AI Provider`}),(0,H.jsx)(`p`,{className:`${p} text-text-subtle`,children:a?`Error: ${a}`:`Loading...`})]})}var am=[{key:`general`,label:`General`},{key:`tabs`,label:`Tabs`},{key:`projects`,label:`Projects`}],om=[`Ctrl+T`,`Ctrl+W`,`Ctrl+N`,`Ctrl+Tab`,`Ctrl+L`,`Ctrl+H`,`Ctrl+J`,`F5`,`Ctrl+R`,`Ctrl+Shift+I`,`Ctrl+Shift+J`];function sm({actionId:e,combo:t,locked:n}){let[r,i]=(0,B.useState)(!1),a=Ff(e=>e.setBinding),o=(0,B.useRef)(null),s=(0,B.useCallback)(t=>{if(t.preventDefault(),t.stopPropagation(),t.key===`Escape`){i(!1);return}let n=Pf(t);n&&(a(e,n),i(!1))},[e,a]);return(0,B.useEffect)(()=>{if(r)return document.addEventListener(`keydown`,s,!0),()=>document.removeEventListener(`keydown`,s,!0)},[r,s]),(0,B.useEffect)(()=>{if(!r)return;let e=e=>{o.current&&!o.current.contains(e.target)&&i(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[r]),n?(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-border bg-muted px-2 py-0.5 text-[11px] font-mono text-muted-foreground`,children:[(0,H.jsx)(mt,{className:`size-2.5`}),Nf(t)]}):r?(0,H.jsx)(`button`,{ref:o,className:`inline-flex items-center rounded border-2 border-primary bg-primary/10 px-2 py-0.5 text-[11px] font-mono text-primary animate-pulse`,children:`Press keys...`}):(0,H.jsx)(`button`,{ref:o,onClick:()=>i(!0),className:`inline-flex items-center rounded border border-border bg-surface px-2 py-0.5 text-[11px] font-mono text-foreground hover:border-primary hover:bg-primary/5 transition-colors cursor-pointer`,title:`Click to change shortcut`,children:Nf(t)})}function cm(){let{getBinding:e,resetBinding:t,resetAll:n,overrides:r}=Ff();return(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(`h3`,{className:`text-xs font-medium text-text-secondary`,children:`Keyboard Shortcuts`}),Object.keys(r).length>0&&(0,H.jsxs)(c,{variant:`ghost`,size:`sm`,className:`h-6 text-[10px] text-muted-foreground`,onClick:n,children:[(0,H.jsx)(l,{className:`size-3 mr-1`}),`Reset all`]})]}),(0,H.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-amber-500/30 bg-amber-500/5 px-2.5 py-2`,children:[(0,H.jsx)(Bt,{className:`size-3.5 text-amber-500 shrink-0 mt-0.5`}),(0,H.jsxs)(`p`,{className:`text-[10px] text-muted-foreground leading-relaxed`,children:[`Some shortcuts (`,om.slice(0,4).join(`, `),`...) are reserved by the browser and cannot be overridden.`]})]}),am.map(n=>{let i=kf.filter(e=>e.category===n.key);return i.length===0?null:(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wide`,children:n.label}),(0,H.jsx)(`div`,{className:`space-y-0.5`,children:i.map(n=>{let i=e(n.id),a=n.id in r;return(0,H.jsxs)(`div`,{className:`flex items-center justify-between py-1 px-1 rounded hover:bg-surface-elevated/50 transition-colors`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,H.jsx)(`span`,{className:`text-xs text-foreground`,children:n.label}),n.note&&(0,H.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n.note})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0 ml-2`,children:[(0,H.jsx)(sm,{actionId:n.id,combo:i,locked:n.locked}),a&&!n.locked&&(0,H.jsx)(`button`,{onClick:()=>t(n.id),className:`flex items-center justify-center size-5 rounded text-muted-foreground hover:text-foreground hover:bg-surface-elevated transition-colors`,title:`Reset to default`,children:(0,H.jsx)(l,{className:`size-3`})})]})]},n.id)})})]},n.key)})]})}function lm(){let[e,t]=(0,B.useState)({bot_token:``,chat_id:``}),[n,r]=(0,B.useState)(``),[i,a]=(0,B.useState)(``),[o,s]=(0,B.useState)(!1),[l,d]=(0,B.useState)(!1),[f,p]=(0,B.useState)(null);(0,B.useEffect)(()=>{z.get(`/api/settings/telegram`).then(e=>{t(e),a(e.chat_id)}).catch(()=>{})},[]);let m=async()=>{s(!0),p(null);try{let e={chat_id:i};n&&(e.bot_token=n),t(await z.put(`/api/settings/telegram`,e)),r(``),p({type:`ok`,msg:`Saved`})}catch(e){p({type:`err`,msg:e.message})}finally{s(!1)}},h=async()=>{d(!0),p(null);try{await z.post(`/api/settings/telegram/test`,{...n?{bot_token:n}:{},...i?{chat_id:i}:{}}),p({type:`ok`,msg:`Test message sent!`})}catch(e){p({type:`err`,msg:e.message})}finally{d(!1)}},g=!!e.bot_token;return(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(`label`,{className:`text-[11px] text-text-subtle`,children:`Bot Token`}),(0,H.jsx)(u,{type:`password`,placeholder:g?`•••••• (saved)`:`123456:ABC-DEF...`,value:n,onChange:e=>r(e.target.value),className:`h-7 text-xs`})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(`label`,{className:`text-[11px] text-text-subtle`,children:`Chat ID`}),(0,H.jsx)(u,{placeholder:`-1001234567890`,value:i,onChange:e=>a(e.target.value),className:`h-7 text-xs`}),(0,H.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:`Personal or group chat ID`})]}),(0,H.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,H.jsx)(c,{variant:`default`,size:`sm`,className:`h-7 text-xs flex-1`,disabled:o||!n&&!i,onClick:m,children:o?`...`:`Save`}),(0,H.jsxs)(c,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:l||!g,onClick:h,children:[(0,H.jsx)(Nt,{className:`size-3`}),l?`...`:`Test`]})]}),f&&(0,H.jsx)(`p`,{className:`text-[11px] ${f.type===`ok`?`text-green-600 dark:text-green-400`:`text-destructive`}`,children:f.msg})]})}var um=B.forwardRef(({className:e,...t},n)=>(0,H.jsx)(zl,{className:R(`peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input`,e),...t,ref:n,children:(0,H.jsx)(G,{className:R(`pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0`)})}));um.displayName=zl.displayName;function dm(){let[e,t]=(0,B.useState)(null),[n,r]=(0,B.useState)(!0),[i,a]=(0,B.useState)(!1),[o,s]=(0,B.useState)(null),[l,d]=(0,B.useState)(null);(0,B.useEffect)(()=>{r(!0),ge().then(t).catch(e=>s(e.message)).finally(()=>r(!1))},[]);let f=async e=>{a(!0),s(null);try{t(await _e(e))}catch(e){s(e.message)}finally{a(!1)}},p=(e,t)=>{navigator.clipboard.writeText(e),d(t),setTimeout(()=>d(null),2e3)};if(n||!e)return(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(`h3`,{className:`text-xs font-medium text-text-secondary`,children:`API Proxy`}),(0,H.jsx)(`p`,{className:`text-[11px] text-text-subtle`,children:o?`Error: ${o}`:`Loading...`})]});let m=!!e.authKey,h=!!e.tunnelUrl;return(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsx)(`div`,{className:`space-y-1.5`,children:(0,H.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Expose your Claude accounts as an Anthropic-compatible API endpoint. External tools (OpenCode, Cursor, etc.) can use your accounts via this proxy.`})}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,H.jsx)(qp,{className:`text-xs`,children:`Enable Proxy`}),(0,H.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Accept API requests on /proxy/v1/messages`})]}),(0,H.jsx)(um,{checked:e.enabled,onCheckedChange:e=>f({enabled:e}),disabled:i})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(qp,{className:`text-[11px]`,children:`Auth Key`}),m?(0,H.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,H.jsx)(u,{readOnly:!0,value:e.authKey,className:`h-7 text-[11px] font-mono flex-1`}),(0,H.jsx)(c,{variant:`outline`,size:`sm`,className:`h-7 px-2 cursor-pointer shrink-0`,onClick:()=>p(e.authKey,`key`),children:l===`key`?`Copied!`:(0,H.jsx)(Ve,{className:`size-3`})}),(0,H.jsx)(c,{variant:`outline`,size:`sm`,className:`h-7 px-2 cursor-pointer shrink-0`,onClick:()=>f({generateKey:!0}),disabled:i,children:(0,H.jsx)(kt,{className:`size-3`})})]}):(0,H.jsx)(c,{variant:`outline`,size:`sm`,className:`h-7 text-xs cursor-pointer`,onClick:()=>f({generateKey:!0}),disabled:i,children:`Generate Auth Key`}),(0,H.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Use as Bearer token or x-api-key when calling the proxy.`})]}),e.enabled&&m&&(0,H.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3 bg-muted/30`,children:[(0,H.jsx)(`h4`,{className:`text-[11px] font-medium`,children:`Connection Info`}),(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(qp,{className:`text-[10px] text-muted-foreground`,children:`Local Endpoint`}),(0,H.jsxs)(`div`,{className:`flex gap-1.5 items-center`,children:[(0,H.jsx)(`code`,{className:`text-[10px] font-mono bg-muted px-1.5 py-0.5 rounded flex-1 truncate`,children:`${window.location.origin}/proxy/v1/messages`}),(0,H.jsx)(c,{variant:`ghost`,size:`sm`,className:`h-6 px-1.5 cursor-pointer shrink-0`,onClick:()=>p(`${window.location.origin}/proxy/v1/messages`,`local`),children:l===`local`?`Copied!`:(0,H.jsx)(Ve,{className:`size-3`})})]})]}),h&&e.proxyEndpoint&&(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(qp,{className:`text-[10px] text-muted-foreground`,children:`Public Endpoint (Tunnel)`}),(0,H.jsxs)(`div`,{className:`flex gap-1.5 items-center`,children:[(0,H.jsx)(`code`,{className:`text-[10px] font-mono bg-muted px-1.5 py-0.5 rounded flex-1 truncate`,children:e.proxyEndpoint}),(0,H.jsx)(c,{variant:`ghost`,size:`sm`,className:`h-6 px-1.5 cursor-pointer shrink-0`,onClick:()=>p(e.proxyEndpoint,`tunnel`),children:l===`tunnel`?`Copied!`:(0,H.jsx)(Ve,{className:`size-3`})})]})]}),!h&&(0,H.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Start a Cloudflare tunnel (Share) to get a public URL.`}),(0,H.jsxs)(`div`,{className:`space-y-1 pt-1`,children:[(0,H.jsx)(qp,{className:`text-[10px] text-muted-foreground`,children:`Usage Example`}),(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(`pre`,{className:`text-[9px] font-mono bg-muted p-2 rounded overflow-x-auto whitespace-pre`,children:`# Set as base URL in your tool
19
+ `,children:(0,H.jsx)(`div`,{className:`absolute opacity-0 group-hover/handle:opacity-70 transition-opacity text-foreground/50`,children:t?(0,H.jsx)(ot,{className:`size-3`}):(0,H.jsx)(at,{className:`size-3`})})})}var up=v((e,t)=>({tree:[],loading:!1,error:null,expandedPaths:new Set,selectedFiles:[],fetchTree:async t=>{e({loading:!0,error:null});try{e({tree:await z.get(`${fe(t)}/files/tree?depth=3`),loading:!1})}catch(t){e({error:t instanceof Error?t.message:`Failed to load files`,loading:!1})}},toggleExpand:n=>{let r=new Set(t().expandedPaths);r.has(n)?r.delete(n):r.add(n),e({expandedPaths:r})},setExpanded:(n,r)=>{let i=new Set(t().expandedPaths);r?i.add(n):i.delete(n),e({expandedPaths:i})},toggleFileSelect:n=>{let r=t().selectedFiles;r.indexOf(n)>=0?e({selectedFiles:r.filter(e=>e!==n)}):e({selectedFiles:r.length>=2?[r[1],n]:[...r,n]})},clearSelection:()=>e({selectedFiles:[]}),reset:()=>e({tree:[],expandedPaths:new Set,error:null,selectedFiles:[]})}));function dp({className:e,children:t,...n}){return(0,H.jsxs)(Js,{"data-slot":`scroll-area`,className:R(`relative`,e),...n,children:[(0,H.jsx)(Ys,{"data-slot":`scroll-area-viewport`,className:`size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 [&>div]:!block`,children:t}),(0,H.jsx)(fp,{}),(0,H.jsx)(Xs,{})]})}function fp({className:e,orientation:t=`vertical`,...n}){return(0,H.jsx)(Ss,{"data-slot":`scroll-area-scrollbar`,orientation:t,className:R(`flex touch-none p-px transition-colors select-none`,t===`vertical`&&`h-full w-1.5 border-l border-l-transparent`,t===`horizontal`&&`h-1.5 flex-col border-t border-t-transparent`,e),...n,children:(0,H.jsx)(Ns,{"data-slot":`scroll-area-thumb`,className:`relative flex-1 rounded-full bg-border`})})}function pp({...e}){return(0,H.jsx)(fo,{"data-slot":`context-menu`,...e})}function mp({...e}){return(0,H.jsx)(po,{"data-slot":`context-menu-trigger`,...e})}function hp({className:e,...t}){return(0,H.jsx)(mo,{children:(0,H.jsx)(ho,{"data-slot":`context-menu-content`,className:R(`z-50 max-h-(--radix-context-menu-content-available-height) min-w-[8rem] origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,e),...t})})}function gp({className:e,inset:t,variant:n=`default`,...r}){return(0,H.jsx)(go,{"data-slot":`context-menu-item`,"data-inset":t,"data-variant":n,className:R(`relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive!`,e),...r})}function _p({className:e,...t}){return(0,H.jsx)(_o,{"data-slot":`context-menu-separator`,className:R(`-mx-1 my-1 h-px bg-border`,e),...t})}function vp({...e}){return(0,H.jsx)(vr,{"data-slot":`dialog`,...e})}function yp({...e}){return(0,H.jsx)(yr,{"data-slot":`dialog-portal`,...e})}function bp({className:e,...t}){return(0,H.jsx)(br,{"data-slot":`dialog-overlay`,className:R(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function xp({className:e,children:t,showCloseButton:n=!0,...r}){return(0,H.jsxs)(yp,{"data-slot":`dialog-portal`,children:[(0,H.jsx)(bp,{}),(0,H.jsxs)(xr,{"data-slot":`dialog-content`,className:R(`fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background text-foreground p-6 shadow-lg duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg`,e),...r,children:[t,n&&(0,H.jsxs)(wr,{"data-slot":`dialog-close`,className:`absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,H.jsx)(Gt,{}),(0,H.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function Sp({className:e,...t}){return(0,H.jsx)(`div`,{"data-slot":`dialog-header`,className:R(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function Cp({className:e,showCloseButton:t=!1,children:n,...r}){return(0,H.jsxs)(`div`,{"data-slot":`dialog-footer`,className:R(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...r,children:[n,t&&(0,H.jsx)(wr,{asChild:!0,children:(0,H.jsx)(c,{variant:`outline`,children:`Close`})})]})}function wp({className:e,...t}){return(0,H.jsx)(Sr,{"data-slot":`dialog-title`,className:R(`text-lg leading-none font-semibold`,e),...t})}function Tp({className:e,...t}){return(0,H.jsx)(Cr,{"data-slot":`dialog-description`,className:R(`text-sm text-muted-foreground`,e),...t})}function Ep({action:e,node:t,projectName:n,onClose:r,onRefresh:i}){let[a,o]=(0,B.useState)(``),[s,l]=(0,B.useState)(!1),[d,f]=(0,B.useState)(null),p=(0,B.useRef)(null);(0,B.useEffect)(()=>{o(e===`rename`?t.name:``)},[e,t.name]),(0,B.useEffect)(()=>{let e=setTimeout(()=>p.current?.focus(),100);return()=>clearTimeout(e)},[]);async function m(e){if(a.trim()){l(!0),f(null);try{let o=t.type===`directory`?t.path:t.path.split(`/`).slice(0,-1).join(`/`),s=o?`${o}/${a.trim()}`:a.trim();await z.post(`${fe(n)}/files/create`,{path:s,type:e}),i(),r()}catch(e){f(e instanceof Error?e.message:`Failed to create`)}finally{l(!1)}}}async function h(){if(!a.trim()||a.trim()===t.name){r();return}l(!0),f(null);try{let e=t.path.split(`/`).slice(0,-1).join(`/`),o=e?`${e}/${a.trim()}`:a.trim();await z.post(`${fe(n)}/files/rename`,{oldPath:t.path,newPath:o}),i(),r()}catch(e){f(e instanceof Error?e.message:`Failed to rename`)}finally{l(!1)}}async function g(){l(!0),f(null);try{await z.del(`${fe(n)}/files/delete`,{path:t.path}),i(),r()}catch(e){f(e instanceof Error?e.message:`Failed to delete`)}finally{l(!1)}}function _(t){t.key===`Enter`&&(e===`new-file`?m(`file`):e===`new-folder`?m(`directory`):e===`rename`&&h()),t.key===`Escape`&&r()}if(e===`delete`)return(0,H.jsx)(vp,{open:!0,onOpenChange:e=>!e&&r(),children:(0,H.jsxs)(xp,{children:[(0,H.jsxs)(Sp,{children:[(0,H.jsxs)(wp,{children:[`Delete `,t.type===`directory`?`Folder`:`File`]}),(0,H.jsxs)(Tp,{children:[`Are you sure you want to delete`,` `,(0,H.jsx)(`span`,{className:`font-mono font-semibold`,children:t.name}),`?`,t.type===`directory`&&` This will delete all contents.`]})]}),d&&(0,H.jsx)(`p`,{className:`text-sm text-error`,children:d}),(0,H.jsxs)(Cp,{children:[(0,H.jsx)(c,{variant:`outline`,onClick:r,disabled:s,children:`Cancel`}),(0,H.jsx)(c,{variant:`destructive`,onClick:g,disabled:s,children:s?`Deleting...`:`Delete`})]})]})});let v=e===`new-file`?`New File`:e===`new-folder`?`New Folder`:`Rename`,y=e===`rename`?t.name:e===`new-file`?`filename.ts`:`folder-name`;return(0,H.jsx)(vp,{open:!0,onOpenChange:e=>!e&&r(),children:(0,H.jsxs)(xp,{children:[(0,H.jsxs)(Sp,{children:[(0,H.jsx)(wp,{children:v}),(0,H.jsx)(Tp,{children:e===`rename`?`Rename "${t.name}" to:`:`Create in ${t.type===`directory`?t.path||`/`:t.path.split(`/`).slice(0,-1).join(`/`)||`/`}`})]}),(0,H.jsx)(u,{ref:p,value:a,onChange:e=>o(e.target.value),onKeyDown:_,placeholder:y,disabled:s}),d&&(0,H.jsx)(`p`,{className:`text-sm text-error`,children:d}),(0,H.jsxs)(Cp,{children:[(0,H.jsx)(c,{variant:`outline`,onClick:r,disabled:s,children:`Cancel`}),(0,H.jsx)(c,{onClick:()=>{e===`new-file`?m(`file`):e===`new-folder`?m(`directory`):h()},disabled:s||!a.trim(),children:s?`Saving...`:e===`rename`?`Rename`:`Create`})]})]})})}var Dp={ts:Je,tsx:Je,js:Je,jsx:Je,py:Je,rs:Je,go:Je,json:qe,md:Xe,txt:Xe,yaml:Ze,yml:Ze,html:Je,css:Je,scss:Je};function Op(e){return Dp[e.split(`.`).pop()?.toLowerCase()??``]??Qe}function kp({node:e,depth:t,projectName:n,onAction:r,onFileOpen:i}){let{expandedPaths:a,toggleExpand:o,selectedFiles:c,toggleFileSelect:l}=up(),u=_(e=>e.openTab),f=a.has(e.path),p=e.type===`directory`,m=c.includes(e.path),h=e.ignored===!0;function g(t){if(p){o(e.path);return}if(t.metaKey||t.ctrlKey){l(e.path);return}let r=e.name.split(`.`).pop()?.toLowerCase()??``;u({type:r===`db`||r===`sqlite`||r===`sqlite3`?`sqlite`:`editor`,title:e.name,metadata:{filePath:e.path,projectName:n},projectId:n,closable:!0}),i?.()}let v=p?f?$e:tt:Op(e.name),y=e.children?[...e.children].sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1):[];return(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(pp,{children:[(0,H.jsx)(mp,{asChild:!0,children:(0,H.jsxs)(`button`,{onClick:g,className:R(`flex items-center w-full gap-1.5 px-2 py-1 rounded-sm text-sm`,`min-h-[32px] hover:bg-surface-elevated transition-colors text-left`,`select-none`,h&&`opacity-40`,m&&`bg-primary/15 ring-1 ring-primary/40`),style:{paddingLeft:`${t*16+8}px`},children:[p?f?(0,H.jsx)(s,{className:`size-3.5 shrink-0 text-text-subtle`}):(0,H.jsx)(d,{className:`size-3.5 shrink-0 text-text-subtle`}):(0,H.jsx)(`span`,{className:`w-3.5 shrink-0`}),(0,H.jsx)(v,{className:R(`size-4 shrink-0`,p?`text-primary`:`text-text-secondary`)}),(0,H.jsx)(`span`,{className:`truncate`,children:e.name})]})}),(0,H.jsxs)(hp,{children:[p&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(gp,{onClick:()=>r(`new-file`,e),children:`New File`}),(0,H.jsx)(gp,{onClick:()=>r(`new-folder`,e),children:`New Folder`}),(0,H.jsx)(_p,{})]}),(0,H.jsx)(gp,{onClick:()=>r(`rename`,e),children:`Rename`}),(0,H.jsx)(gp,{variant:`destructive`,onClick:()=>r(`delete`,e),children:`Delete`}),(0,H.jsx)(_p,{}),(0,H.jsx)(gp,{onClick:()=>r(`copy-path`,e),children:`Copy Path`}),!p&&c.length===2&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(_p,{}),(0,H.jsx)(gp,{onClick:()=>r(`compare-selected`,e),children:`Compare Selected`})]})]})]}),p&&f&&y.map(e=>(0,H.jsx)(kp,{node:e,depth:t+1,projectName:n,onAction:r,onFileOpen:i},e.path))]})}function Ap({onFileOpen:e}={}){let{tree:t,loading:n,error:r,fetchTree:i,reset:a,selectedFiles:o,clearSelection:s}=up(),c=bf(e=>e.activeProject),l=_(e=>e.openTab),[u,d]=(0,B.useState)(null),f=(0,B.useCallback)(()=>{c&&i(c.name)},[c,i]);(0,B.useEffect)(()=>{c&&(a(),f())},[c?.name]),(0,B.useEffect)(()=>{let e=()=>{c&&i(c.name)};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[c,i]);function p(e,t){if(e===`copy-path`){navigator.clipboard.writeText(t.path).catch(()=>{});return}if(e===`compare-selected`&&o.length===2){let e=o[0],t=o[1];l({type:`git-diff`,title:`Compare ${ue(e)} vs ${ue(t)}`,closable:!0,metadata:{projectName:c.name,file1:e,file2:t},projectId:c.name}),s();return}d({action:e,node:t})}if(!c)return(0,H.jsx)(`div`,{className:`p-3 text-xs text-text-subtle`,children:`Select a project to browse files.`});if(n&&t.length===0)return(0,H.jsxs)(`div`,{className:`flex items-center gap-2 p-3 text-xs text-text-secondary`,children:[(0,H.jsx)(pt,{className:`size-3 animate-spin`}),`Loading files...`]});if(r)return(0,H.jsxs)(`div`,{className:`p-3 text-xs text-error`,children:[r,(0,H.jsx)(`button`,{onClick:f,className:`block mt-1 text-primary underline`,children:`Retry`})]});let m=[...t].sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(dp,{className:`flex-1`,children:(0,H.jsxs)(`div`,{className:`py-1`,children:[m.map(t=>(0,H.jsx)(kp,{node:t,depth:0,projectName:c.name,onAction:p,onFileOpen:e},t.path)),m.length===0&&(0,H.jsx)(`p`,{className:`p-3 text-xs text-text-subtle`,children:`Empty project.`})]})}),u&&(0,H.jsx)(Ep,{action:u.action,node:u.node,projectName:c.name,onClose:()=>d(null),onRefresh:f})]})}function jp({...e}){return(0,H.jsx)(es,{"data-slot":`dropdown-menu`,...e})}function Mp({...e}){return(0,H.jsx)(ts,{"data-slot":`dropdown-menu-trigger`,...e})}function Np({className:e,sideOffset:t=4,...n}){return(0,H.jsx)(ns,{children:(0,H.jsx)(rs,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:R(`z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,e),...n})})}function Pp({className:e,inset:t,variant:n=`default`,...r}){return(0,H.jsx)(is,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:R(`relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive!`,e),...r})}function Fp({...e}){return(0,H.jsx)(as,{"data-slot":`dropdown-menu-sub`,...e})}function Ip({className:e,inset:t,children:n,...r}){return(0,H.jsxs)(os,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":t,className:R(`flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[inset]:pl-8 data-[state=open]:bg-accent data-[state=open]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,H.jsx)(d,{className:`ml-auto size-4`})]})}function Lp({className:e,...t}){return(0,H.jsx)(ss,{"data-slot":`dropdown-menu-sub-content`,className:R(`z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,e),...t})}var Rp={M:`text-yellow-500`,A:`text-green-500`,D:`text-red-500`,R:`text-blue-500`,C:`text-purple-500`,"?":`text-gray-400`};function zp(e){let t=[];for(let n of e){let e=n.path.split(`/`),r=t;for(let t=0;t<e.length;t++){let i=e[t],a=e.slice(0,t+1).join(`/`),o=t===e.length-1,s=r.find(e=>e.name===i);s||(s={name:i,fullPath:a,file:o?n:void 0,children:[]},r.push(s)),o&&(s.file=n),r=s.children}}return t}function Bp(e){let t=[];e.file&&t.push(e.file);for(let n of e.children)t.push(...Bp(n));return t}function Vp({metadata:e,tabId:t,onNavigate:n}){let r=e?.projectName,[i,a]=(0,B.useState)(null),[o,s]=(0,B.useState)(!0),[l,u]=(0,B.useState)(null),[d,f]=(0,B.useState)(``),[p,m]=(0,B.useState)(!1),[h,g]=(0,B.useState)(null),{openTab:v}=_(),y=V(e=>e.gitStatusViewMode),b=V(e=>e.setGitStatusViewMode),x=(0,B.useCallback)(async()=>{if(r)try{s(!0),a(await z.get(`${fe(r)}/git/status`)),u(null)}catch(e){u(e instanceof Error?e.message:`Failed to fetch status`)}finally{s(!1)}},[r]);(0,B.useEffect)(()=>{x();let e=setInterval(x,5e3);return()=>clearInterval(e)},[x]);let S=async e=>{if(r){m(!0);try{await z.post(`${fe(r)}/git/stage`,{files:e}),await x()}catch(e){u(e instanceof Error?e.message:`Stage failed`)}finally{m(!1)}}},C=async e=>{if(r){m(!0);try{await z.post(`${fe(r)}/git/unstage`,{files:e}),await x()}catch(e){u(e instanceof Error?e.message:`Unstage failed`)}finally{m(!1)}}},w=async e=>{if(r){m(!0);try{await z.post(`${fe(r)}/git/discard`,{files:e}),await x()}catch(e){u(e instanceof Error?e.message:`Discard failed`)}finally{m(!1)}}},T=async()=>{h&&(await w(h.files),g(null))},E=async()=>{if(!(!r||!d.trim()||!i?.staged.length)){m(!0);try{await z.post(`${fe(r)}/git/commit`,{message:d.trim()}),f(``),await x()}catch(e){u(e instanceof Error?e.message:`Commit failed`)}finally{m(!1)}}},D=async()=>{if(r){m(!0);try{await z.post(`${fe(r)}/git/push`,{}),await x()}catch(e){u(e instanceof Error?e.message:`Push failed`)}finally{m(!1)}}},O=async()=>{if(r){m(!0);try{await z.post(`${fe(r)}/git/pull`,{}),await x()}catch(e){u(e instanceof Error?e.message:`Pull failed`)}finally{m(!1)}}},ee=e=>{v({type:`git-diff`,title:ue(e.path),closable:!0,metadata:{projectName:r,filePath:e.path},projectId:r??null}),n?.()},k=e=>{v({type:`editor`,title:ue(e.path),closable:!0,metadata:{projectName:r,filePath:e.path},projectId:r??null}),n?.()},A=(0,B.useMemo)(()=>[...i?.unstaged??[],...i?.untracked.map(e=>({path:e,status:`?`}))??[]],[i]);return r?o&&!i?(0,H.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,H.jsx)(pt,{className:`size-5 animate-spin`}),(0,H.jsx)(`span`,{className:`text-sm`,children:`Loading git status...`})]}):l&&!i?(0,H.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-2 text-destructive text-sm`,children:[(0,H.jsx)(`p`,{children:l}),(0,H.jsx)(c,{variant:`outline`,size:`sm`,onClick:x,children:`Retry`})]}):(0,H.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b shrink-0`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:i?.current?`On: ${i.current}`:`Git Status`}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(c,{variant:y===`flat`?`secondary`:`ghost`,size:`icon-xs`,onClick:()=>b(`flat`),title:`Flat view`,children:(0,H.jsx)(ft,{className:`size-3.5`})}),(0,H.jsx)(c,{variant:y===`tree`?`secondary`:`ghost`,size:`icon-xs`,onClick:()=>b(`tree`),title:`Tree view`,children:(0,H.jsx)(et,{className:`size-3.5`})}),(0,H.jsx)(c,{variant:`ghost`,size:`icon-xs`,onClick:x,disabled:p,children:(0,H.jsx)(kt,{className:o?`animate-spin`:``})})]})]}),l&&(0,H.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-destructive bg-destructive/10 shrink-0`,children:l}),(0,H.jsx)(dp,{className:`flex-1 overflow-hidden`,children:(0,H.jsxs)(`div`,{className:`p-1.5 space-y-2 overflow-hidden`,children:[(0,H.jsx)(Up,{title:`Staged Changes`,count:i?.staged.length??0,files:i?.staged??[],viewMode:y,actionIcon:(0,H.jsx)(yt,{className:`size-3`}),actionAllIcon:(0,H.jsx)(yt,{className:`size-3`}),actionTitle:`Unstage`,onAction:e=>C([e.path]),onActionAll:i?.staged.length?()=>C(i.staged.map(e=>e.path)):void 0,actionAllLabel:`Unstage All`,onFolderAction:e=>C(e.map(e=>e.path)),onClickFile:ee,onOpenFile:k,disabled:p}),(0,H.jsx)(Up,{title:`Changes`,count:A.length,files:A,viewMode:y,actionIcon:(0,H.jsx)(Ot,{className:`size-3`}),actionAllIcon:(0,H.jsx)(Ot,{className:`size-3`}),actionTitle:`Stage`,onAction:e=>S([e.path]),onActionAll:A.length?()=>S(A.map(e=>e.path)):void 0,actionAllLabel:`Stage All`,onFolderAction:e=>S(e.map(e=>e.path)),onClickFile:ee,onOpenFile:k,disabled:p,showRevert:!0,onRevert:e=>g({label:e.path,files:[e.path]}),onFolderRevert:(e,t)=>g({label:`${t}/ (${e.length} files)`,files:e.map(e=>e.path)})})]})}),(0,H.jsxs)(`div`,{className:`border-t p-2 space-y-2 shrink-0`,children:[(0,H.jsx)(`textarea`,{className:`w-full h-16 px-3 py-2 text-base md:text-sm text-foreground bg-surface border border-border rounded-lg resize-none focus:outline-none focus:border-ring placeholder:text-muted-foreground`,placeholder:`Commit message...`,value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&E()}}),(0,H.jsx)(c,{size:`sm`,className:`w-full`,disabled:p||!d.trim()||!i?.staged.length,onClick:E,children:p?(0,H.jsx)(pt,{className:`size-3 animate-spin`}):`Commit (${i?.staged.length??0})`}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsxs)(c,{variant:`outline`,size:`sm`,className:`flex-1`,disabled:p,onClick:D,children:[(0,H.jsx)(Te,{className:`size-3`}),`Push`]}),(0,H.jsxs)(c,{variant:`outline`,size:`sm`,className:`flex-1`,disabled:p,onClick:O,children:[(0,H.jsx)(Se,{className:`size-3`}),`Pull`]})]})]}),(0,H.jsx)(vp,{open:!!h,onOpenChange:e=>!e&&g(null),children:(0,H.jsxs)(xp,{showCloseButton:!1,children:[(0,H.jsxs)(Sp,{children:[(0,H.jsx)(wp,{children:`Discard Changes`}),(0,H.jsxs)(Tp,{children:[`Are you sure you want to discard all changes to`,` `,(0,H.jsx)(`code`,{className:`px-1 py-0.5 rounded bg-muted text-sm font-mono`,children:h?.label}),`? This action cannot be undone.`]})]}),(0,H.jsxs)(Cp,{children:[(0,H.jsx)(c,{variant:`outline`,onClick:()=>g(null),children:`Cancel`}),(0,H.jsx)(c,{variant:`destructive`,onClick:T,disabled:p,children:p?(0,H.jsx)(pt,{className:`size-3 animate-spin`}):`Discard`})]})]})})]}):(0,H.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`No project selected.`})}function Hp({showRevert:e,onRevert:t,onAction:n,onOpenFile:r,actionIcon:i,actionTitle:a,disabled:o}){return(0,H.jsxs)(`div`,{className:`hidden md:flex absolute right-0 top-0 bottom-0 items-center gap-0.5 pl-6 pr-1 bg-gradient-to-l from-background from-70% to-transparent opacity-0 group-hover:opacity-100 transition-opacity`,children:[r&&(0,H.jsx)(`button`,{type:`button`,className:`flex items-center justify-center size-5 rounded text-muted-foreground hover:text-primary active:scale-95 transition-colors`,onClick:e=>{e.stopPropagation(),r()},disabled:o,title:`Open file`,children:(0,H.jsx)(Xe,{className:`size-3`})}),e&&t&&(0,H.jsx)(`button`,{type:`button`,className:`flex items-center justify-center size-5 rounded text-muted-foreground hover:text-destructive active:scale-95 transition-colors`,onClick:e=>{e.stopPropagation(),t()},disabled:o,title:`Discard changes`,children:(0,H.jsx)(Vt,{className:`size-3`})}),(0,H.jsx)(`button`,{type:`button`,className:`flex items-center justify-center size-5 rounded text-muted-foreground hover:text-accent-foreground active:scale-95 transition-colors`,onClick:e=>{e.stopPropagation(),n()},disabled:o,title:a,children:i})]})}function Up({title:e,count:t,files:n,viewMode:r,actionIcon:i,actionAllIcon:a,actionTitle:o,onAction:s,onActionAll:c,actionAllLabel:l,onFolderAction:u,onClickFile:d,onOpenFile:f,disabled:p,showRevert:m,onRevert:h,onFolderRevert:g}){return(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between mb-0.5`,children:[(0,H.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase`,children:[e,` (`,t,`)`]}),c&&t>0&&(0,H.jsx)(`button`,{type:`button`,className:`flex items-center justify-center size-5 rounded text-muted-foreground hover:text-accent-foreground active:scale-95 transition-colors`,onClick:c,disabled:p,title:l,children:a})]}),n.length===0?(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground px-1`,children:`No changes`}):r===`flat`?(0,H.jsx)(`div`,{className:`w-full overflow-hidden`,children:n.map(e=>(0,H.jsx)(Gp,{file:e,actionIcon:i,actionTitle:o,onAction:s,onClickFile:d,onOpenFile:f,disabled:p,showRevert:m,onRevert:h},e.path))}):(0,H.jsx)(Kp,{files:n,actionIcon:i,actionTitle:o,onAction:s,onFolderAction:u,onClickFile:d,onOpenFile:f,disabled:p,showRevert:m,onRevert:h,onFolderRevert:g})]})}function Wp(e,t,n=400){let r=(0,B.useRef)(null),i=(0,B.useRef)(!1),a=(0,B.useRef)(!1),o=(0,B.useCallback)(()=>{r.current&&=(clearTimeout(r.current),null)},[]);return{onTouchStart:(0,B.useCallback)(t=>{i.current=!1,a.current=!1,r.current=setTimeout(()=>{a.current=!0,e()},n)},[e,n]),onTouchMove:(0,B.useCallback)(()=>{i.current=!0,o()},[o]),onTouchEnd:(0,B.useCallback)(e=>{o(),!i.current&&!a.current&&(e.preventDefault(),t())},[o,t])}}function Gp({file:e,actionIcon:t,actionTitle:n,onAction:r,onClickFile:i,onOpenFile:a,disabled:o,showRevert:s,onRevert:c,displayName:l}){let[u,d]=(0,B.useState)(!1),f=Wp((0,B.useCallback)(()=>d(!0),[]),(0,B.useCallback)(()=>i(e),[i,e])),p=(0,H.jsxs)(`div`,{className:`group relative flex items-center gap-1 hover:bg-muted/50 rounded pl-1 py-px w-full min-w-0`,children:[(0,H.jsx)(`span`,{className:`text-xs font-mono w-4 text-center shrink-0 ${Rp[e.status]??``}`,children:e.status}),(0,H.jsx)(`button`,{type:`button`,className:`hidden md:block flex-1 text-left text-xs font-mono truncate hover:underline min-w-0`,onClick:()=>i(e),title:e.path,children:l??e.path}),(0,H.jsx)(`span`,{className:`md:hidden flex-1 text-left text-xs font-mono truncate min-w-0 select-none`,children:l??e.path}),(0,H.jsx)(Hp,{showRevert:s,onRevert:c?()=>c(e):void 0,onOpenFile:a?()=>a(e):void 0,onAction:()=>r(e),actionIcon:t,actionTitle:n,disabled:o})]});return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`hidden md:block`,children:p}),(0,H.jsx)(`div`,{className:`md:hidden select-none`,...f,children:(0,H.jsxs)(jp,{open:u,onOpenChange:d,children:[(0,H.jsx)(Mp,{asChild:!0,children:p}),(0,H.jsxs)(Np,{align:`start`,className:`min-w-40`,children:[(0,H.jsx)(Pp,{onClick:()=>i(e),children:`View Diff`}),a&&(0,H.jsx)(Pp,{onClick:()=>a(e),children:`Open File`}),(0,H.jsx)(Pp,{onClick:()=>r(e),disabled:o,children:n}),s&&c&&(0,H.jsx)(Pp,{className:`text-destructive focus:text-destructive`,onClick:()=>c(e),disabled:o,children:`Discard Changes`})]})]})})]})}function Kp({files:e,actionIcon:t,actionTitle:n,onAction:r,onFolderAction:i,onClickFile:a,onOpenFile:o,disabled:s,showRevert:c,onRevert:l,onFolderRevert:u}){let d=(0,B.useMemo)(()=>zp(e),[e]);return(0,H.jsx)(`div`,{children:d.map((e,f)=>(0,H.jsx)(qp,{node:e,depth:0,isLast:f===d.length-1,actionIcon:t,actionTitle:n,onAction:r,onFolderAction:i,onClickFile:a,onOpenFile:o,disabled:s,showRevert:c,onRevert:l,onFolderRevert:u},e.fullPath))})}function qp({node:e,depth:t,isLast:n,actionIcon:r,actionTitle:i,onAction:a,onFolderAction:o,onClickFile:c,onOpenFile:l,disabled:u,showRevert:f,onRevert:p,onFolderRevert:m}){let[h,g]=(0,B.useState)(!0),_=e.children.length>0&&!e.file,v=t*12-6,y=`absolute border-dashed border-border`;if(e.file)return(0,H.jsxs)(`div`,{className:`relative`,style:{paddingLeft:t*12},children:[t>0&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`${y} border-l`,style:{left:v,top:0,bottom:n?`50%`:0}}),(0,H.jsx)(`div`,{className:`${y} border-t`,style:{left:v,top:`50%`,width:6}})]}),(0,H.jsx)(Gp,{file:e.file,displayName:e.name,actionIcon:r,actionTitle:i,onAction:a,onClickFile:c,onOpenFile:l,disabled:u,showRevert:f,onRevert:p})]});if(_){let _=Bp(e);return(0,H.jsxs)(`div`,{className:`relative`,children:[t>0&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`${y} border-l`,style:{left:v,top:0,...n?{height:13}:{bottom:0}}}),(0,H.jsx)(`div`,{className:`${y} border-t`,style:{left:v,top:13,width:8}})]}),(()=>{let n=(0,H.jsxs)(`div`,{className:`group relative flex items-center hover:bg-muted/50 rounded py-0.5`,style:{paddingLeft:t*12+2},children:[(0,H.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 flex-1 min-w-0 text-xs font-mono text-muted-foreground`,onClick:()=>g(!h),children:[h?(0,H.jsx)(s,{className:`size-3.5 shrink-0`}):(0,H.jsx)(d,{className:`size-3.5 shrink-0`}),(0,H.jsx)(`span`,{className:`truncate font-semibold`,children:e.name}),(0,H.jsxs)(`span`,{className:`text-[10px] opacity-60 shrink-0`,children:[`(`,_.length,`)`]})]}),(0,H.jsx)(Hp,{showRevert:f,onRevert:m?()=>m(_,e.fullPath):void 0,onAction:()=>o?.(_),actionIcon:r,actionTitle:`${i} ${e.name}/`,disabled:u})]});return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`hidden md:block`,children:n}),(0,H.jsx)(`div`,{className:`md:hidden`,children:(0,H.jsxs)(jp,{children:[(0,H.jsx)(Mp,{asChild:!0,children:n}),(0,H.jsxs)(Np,{align:`start`,className:`min-w-40`,children:[(0,H.jsxs)(Pp,{onClick:()=>o?.(_),disabled:u,children:[i,` `,e.name,`/`]}),m&&(0,H.jsx)(Pp,{className:`text-destructive focus:text-destructive`,onClick:()=>m(_,e.fullPath),disabled:u,children:`Discard Changes`})]})]})})]})})(),h&&(0,H.jsx)(`div`,{children:e.children.map((n,s)=>(0,H.jsx)(qp,{node:n,depth:t+1,isLast:s===e.children.length-1,actionIcon:r,actionTitle:i,onAction:a,onFolderAction:o,onClickFile:c,onOpenFile:l,disabled:u,showRevert:f,onRevert:p,onFolderRevert:m},n.fullPath))})]})}return null}function Jp({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,H.jsx)(Dl,{"data-slot":`separator`,decorative:n,orientation:t,className:R(`shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px`,e),...r})}function Yp({className:e,...t}){return(0,H.jsx)(us,{"data-slot":`label`,className:R(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}function Xp({...e}){return(0,H.jsx)(ul,{"data-slot":`select`,...e})}function Zp({...e}){return(0,H.jsx)(fl,{"data-slot":`select-value`,...e})}function Qp({className:e,size:t=`default`,children:n,...r}){return(0,H.jsxs)(dl,{"data-slot":`select-trigger`,"data-size":t,className:R(`flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,H.jsx)(pl,{asChild:!0,children:(0,H.jsx)(s,{className:`size-4 opacity-50`})})]})}function $p({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,H.jsx)(ml,{children:(0,H.jsxs)(hl,{"data-slot":`select-content`,className:R(`relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...i,children:[(0,H.jsx)(tm,{}),(0,H.jsx)(gl,{className:R(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,H.jsx)(nm,{})]})})}function em({className:e,children:t,...n}){return(0,H.jsxs)(_l,{"data-slot":`select-item`,className:R(`relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,H.jsx)(`span`,{"data-slot":`select-item-indicator`,className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,H.jsx)(yl,{children:(0,H.jsx)(o,{className:`size-4`})})}),(0,H.jsx)(vl,{children:t})]})}function tm({className:e,...t}){return(0,H.jsx)(bl,{"data-slot":`select-scroll-up-button`,className:R(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,H.jsx)(Ne,{className:`size-4`})})}function nm({className:e,...t}){return(0,H.jsx)(xl,{"data-slot":`select-scroll-down-button`,className:R(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,H.jsx)(s,{className:`size-4`})})}var rm=[{value:`claude-sonnet-4-6`,label:`Claude Sonnet 4.6`},{value:`claude-opus-4-6`,label:`Claude Opus 4.6`},{value:`claude-haiku-4-5`,label:`Claude Haiku 4.5`}],im=[{value:`low`,label:`Low`},{value:`medium`,label:`Medium`},{value:`high`,label:`High`}],am=[{value:`bypassPermissions`,label:`Bypass permissions (default)`},{value:`default`,label:`Ask before edits`},{value:`acceptEdits`,label:`Edit automatically`},{value:`plan`,label:`Plan mode`}];function om({compact:e}={}){let[t,n]=(0,B.useState)(null),[r,i]=(0,B.useState)(!1),[a,o]=(0,B.useState)(null),[s,c]=(0,B.useState)(0);(0,B.useEffect)(()=>{he().then(n).catch(e=>o(e.message))},[]);let l=t?.default_provider??`claude`,d=t?.providers[l],f=async(e,r)=>{if(t){i(!0),o(null);try{n(await me({providers:{[l]:{[e]:r}}})),c(e=>e+1)}catch(e){o(e.message)}finally{i(!1)}}},p=e?`text-[11px]`:`text-sm`,m=e?`text-xs`:`text-sm`,h=e?`space-y-2`:`space-y-4`,g=e?`space-y-1.5`:`space-y-3`,_=e?`space-y-1`:`space-y-1.5`;return t?(0,H.jsxs)(`div`,{className:h,children:[(0,H.jsx)(`h3`,{className:`${m} font-medium text-text-secondary`,children:`AI Provider`}),(0,H.jsxs)(`div`,{className:g,children:[(0,H.jsxs)(`div`,{className:_,children:[(0,H.jsx)(Yp,{htmlFor:`ai-model`,className:e?p:void 0,children:`Model`}),(0,H.jsxs)(Xp,{value:d?.model??`claude-sonnet-4-6`,onValueChange:e=>f(`model`,e),children:[(0,H.jsx)(Qp,{id:`ai-model`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,H.jsx)(Zp,{})}),(0,H.jsx)($p,{children:rm.map(e=>(0,H.jsx)(em,{value:e.value,children:e.label},e.value))})]})]}),(0,H.jsxs)(`div`,{className:_,children:[(0,H.jsx)(Yp,{htmlFor:`ai-base-url`,className:e?p:void 0,children:`Base URL`}),(0,H.jsx)(u,{id:`ai-base-url`,type:`url`,defaultValue:d?.base_url??``,placeholder:`https://api.anthropic.com (default)`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{f(`base_url`,e.target.value.trim()||void 0)}},`baseurl-${s}`)]}),(0,H.jsxs)(`div`,{className:_,children:[(0,H.jsx)(Yp,{htmlFor:`ai-api-key`,className:e?p:void 0,children:`API Key / Token`}),(0,H.jsx)(u,{id:`ai-api-key`,type:`password`,defaultValue:d?.api_key??``,placeholder:`sk-ant-... (optional, overrides accounts)`,className:e?`h-7 text-[11px] font-mono`:`font-mono`,onBlur:e=>{let t=e.target.value.trim();t.startsWith(`••••`)||f(`api_key`,t||void 0)}},`apikey-${s}`),(0,H.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Direct API key or OAuth token. Leave empty to use connected accounts.`})]}),(0,H.jsxs)(`div`,{className:_,children:[(0,H.jsx)(Yp,{htmlFor:`ai-effort`,className:e?p:void 0,children:`Effort`}),(0,H.jsxs)(Xp,{value:d?.effort??`high`,onValueChange:e=>f(`effort`,e),children:[(0,H.jsx)(Qp,{id:`ai-effort`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,H.jsx)(Zp,{})}),(0,H.jsx)($p,{children:im.map(e=>(0,H.jsx)(em,{value:e.value,children:e.label},e.value))})]})]}),(0,H.jsxs)(`div`,{className:_,children:[(0,H.jsx)(Yp,{htmlFor:`ai-max-turns`,className:e?p:void 0,children:`Max Turns (1-500)`}),(0,H.jsx)(u,{id:`ai-max-turns`,type:`number`,min:1,max:500,defaultValue:d?.max_turns??100,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseInt(e.target.value);isNaN(t)||f(`max_turns`,t)}},`turns-${s}`)]}),(0,H.jsxs)(`div`,{className:_,children:[(0,H.jsx)(Yp,{htmlFor:`ai-budget`,className:e?p:void 0,children:`Max Budget (USD)`}),(0,H.jsx)(u,{id:`ai-budget`,type:`number`,step:.1,min:.01,max:50,defaultValue:d?.max_budget_usd??``,placeholder:`No limit`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseFloat(e.target.value);f(`max_budget_usd`,isNaN(t)?void 0:t)}},`budget-${s}`)]}),(0,H.jsxs)(`div`,{className:_,children:[(0,H.jsx)(Yp,{htmlFor:`ai-thinking`,className:e?p:void 0,children:`Thinking Budget (tokens)`}),(0,H.jsx)(u,{id:`ai-thinking`,type:`number`,min:0,defaultValue:d?.thinking_budget_tokens??``,placeholder:`Disabled`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseInt(e.target.value);f(`thinking_budget_tokens`,isNaN(t)?void 0:t)}},`thinking-${s}`)]}),(0,H.jsxs)(`div`,{className:_,children:[(0,H.jsx)(Yp,{htmlFor:`ai-permission-mode`,className:e?p:void 0,children:`Default Permission Mode`}),(0,H.jsxs)(Xp,{value:d?.permission_mode??`bypassPermissions`,onValueChange:e=>f(`permission_mode`,e),children:[(0,H.jsx)(Qp,{id:`ai-permission-mode`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,H.jsx)(Zp,{})}),(0,H.jsx)($p,{children:am.map(e=>(0,H.jsx)(em,{value:e.value,children:e.label},e.value))})]})]}),(0,H.jsxs)(`div`,{className:_,children:[(0,H.jsx)(Yp,{htmlFor:`ai-system-prompt`,className:e?p:void 0,children:`Additional Instructions`}),(0,H.jsx)(`textarea`,{id:`ai-system-prompt`,rows:4,defaultValue:d?.system_prompt??``,placeholder:`Enter additional instructions for Claude...`,className:`w-full rounded-md border border-input bg-background px-3 py-2 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${e?`text-[11px]`:`text-sm`}`,onBlur:e=>{f(`system_prompt`,e.target.value.trim()||void 0)}},`sysprompt-${s}`)]})]}),r&&(0,H.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`Saving...`}),a&&(0,H.jsx)(`p`,{className:`text-xs text-red-500`,children:a})]}):(0,H.jsxs)(`div`,{className:g,children:[(0,H.jsx)(`h3`,{className:`${m} font-medium text-text-secondary`,children:`AI Provider`}),(0,H.jsx)(`p`,{className:`${p} text-text-subtle`,children:a?`Error: ${a}`:`Loading...`})]})}var sm=[{key:`general`,label:`General`},{key:`tabs`,label:`Tabs`},{key:`projects`,label:`Projects`}],cm=[`Ctrl+T`,`Ctrl+W`,`Ctrl+N`,`Ctrl+Tab`,`Ctrl+L`,`Ctrl+H`,`Ctrl+J`,`F5`,`Ctrl+R`,`Ctrl+Shift+I`,`Ctrl+Shift+J`];function lm({actionId:e,combo:t,locked:n}){let[r,i]=(0,B.useState)(!1),a=Ff(e=>e.setBinding),o=(0,B.useRef)(null),s=(0,B.useCallback)(t=>{if(t.preventDefault(),t.stopPropagation(),t.key===`Escape`){i(!1);return}let n=Pf(t);n&&(a(e,n),i(!1))},[e,a]);return(0,B.useEffect)(()=>{if(r)return document.addEventListener(`keydown`,s,!0),()=>document.removeEventListener(`keydown`,s,!0)},[r,s]),(0,B.useEffect)(()=>{if(!r)return;let e=e=>{o.current&&!o.current.contains(e.target)&&i(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[r]),n?(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-border bg-muted px-2 py-0.5 text-[11px] font-mono text-muted-foreground`,children:[(0,H.jsx)(mt,{className:`size-2.5`}),Nf(t)]}):r?(0,H.jsx)(`button`,{ref:o,className:`inline-flex items-center rounded border-2 border-primary bg-primary/10 px-2 py-0.5 text-[11px] font-mono text-primary animate-pulse`,children:`Press keys...`}):(0,H.jsx)(`button`,{ref:o,onClick:()=>i(!0),className:`inline-flex items-center rounded border border-border bg-surface px-2 py-0.5 text-[11px] font-mono text-foreground hover:border-primary hover:bg-primary/5 transition-colors cursor-pointer`,title:`Click to change shortcut`,children:Nf(t)})}function um(){let{getBinding:e,resetBinding:t,resetAll:n,overrides:r}=Ff();return(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(`h3`,{className:`text-xs font-medium text-text-secondary`,children:`Keyboard Shortcuts`}),Object.keys(r).length>0&&(0,H.jsxs)(c,{variant:`ghost`,size:`sm`,className:`h-6 text-[10px] text-muted-foreground`,onClick:n,children:[(0,H.jsx)(l,{className:`size-3 mr-1`}),`Reset all`]})]}),(0,H.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-amber-500/30 bg-amber-500/5 px-2.5 py-2`,children:[(0,H.jsx)(Bt,{className:`size-3.5 text-amber-500 shrink-0 mt-0.5`}),(0,H.jsxs)(`p`,{className:`text-[10px] text-muted-foreground leading-relaxed`,children:[`Some shortcuts (`,cm.slice(0,4).join(`, `),`...) are reserved by the browser and cannot be overridden.`]})]}),sm.map(n=>{let i=kf.filter(e=>e.category===n.key);return i.length===0?null:(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wide`,children:n.label}),(0,H.jsx)(`div`,{className:`space-y-0.5`,children:i.map(n=>{let i=e(n.id),a=n.id in r;return(0,H.jsxs)(`div`,{className:`flex items-center justify-between py-1 px-1 rounded hover:bg-surface-elevated/50 transition-colors`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,H.jsx)(`span`,{className:`text-xs text-foreground`,children:n.label}),n.note&&(0,H.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n.note})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0 ml-2`,children:[(0,H.jsx)(lm,{actionId:n.id,combo:i,locked:n.locked}),a&&!n.locked&&(0,H.jsx)(`button`,{onClick:()=>t(n.id),className:`flex items-center justify-center size-5 rounded text-muted-foreground hover:text-foreground hover:bg-surface-elevated transition-colors`,title:`Reset to default`,children:(0,H.jsx)(l,{className:`size-3`})})]})]},n.id)})})]},n.key)})]})}function dm(){let[e,t]=(0,B.useState)({bot_token:``,chat_id:``}),[n,r]=(0,B.useState)(``),[i,a]=(0,B.useState)(``),[o,s]=(0,B.useState)(!1),[l,d]=(0,B.useState)(!1),[f,p]=(0,B.useState)(null);(0,B.useEffect)(()=>{z.get(`/api/settings/telegram`).then(e=>{t(e),a(e.chat_id)}).catch(()=>{})},[]);let m=async()=>{s(!0),p(null);try{let e={chat_id:i};n&&(e.bot_token=n),t(await z.put(`/api/settings/telegram`,e)),r(``),p({type:`ok`,msg:`Saved`})}catch(e){p({type:`err`,msg:e.message})}finally{s(!1)}},h=async()=>{d(!0),p(null);try{await z.post(`/api/settings/telegram/test`,{...n?{bot_token:n}:{},...i?{chat_id:i}:{}}),p({type:`ok`,msg:`Test message sent!`})}catch(e){p({type:`err`,msg:e.message})}finally{d(!1)}},g=!!e.bot_token;return(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(`label`,{className:`text-[11px] text-text-subtle`,children:`Bot Token`}),(0,H.jsx)(u,{type:`password`,placeholder:g?`•••••• (saved)`:`123456:ABC-DEF...`,value:n,onChange:e=>r(e.target.value),className:`h-7 text-xs`})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(`label`,{className:`text-[11px] text-text-subtle`,children:`Chat ID`}),(0,H.jsx)(u,{placeholder:`-1001234567890`,value:i,onChange:e=>a(e.target.value),className:`h-7 text-xs`}),(0,H.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:`Personal or group chat ID`})]}),(0,H.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,H.jsx)(c,{variant:`default`,size:`sm`,className:`h-7 text-xs flex-1`,disabled:o||!n&&!i,onClick:m,children:o?`...`:`Save`}),(0,H.jsxs)(c,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:l||!g,onClick:h,children:[(0,H.jsx)(Nt,{className:`size-3`}),l?`...`:`Test`]})]}),f&&(0,H.jsx)(`p`,{className:`text-[11px] ${f.type===`ok`?`text-green-600 dark:text-green-400`:`text-destructive`}`,children:f.msg})]})}var fm=B.forwardRef(({className:e,...t},n)=>(0,H.jsx)(zl,{className:R(`peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input`,e),...t,ref:n,children:(0,H.jsx)(G,{className:R(`pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0`)})}));fm.displayName=zl.displayName;function pm(){let[e,t]=(0,B.useState)(null),[n,r]=(0,B.useState)(!0),[i,a]=(0,B.useState)(!1),[o,s]=(0,B.useState)(null),[l,d]=(0,B.useState)(null);(0,B.useEffect)(()=>{r(!0),ge().then(t).catch(e=>s(e.message)).finally(()=>r(!1))},[]);let f=async e=>{a(!0),s(null);try{t(await _e(e))}catch(e){s(e.message)}finally{a(!1)}},p=(e,t)=>{navigator.clipboard.writeText(e),d(t),setTimeout(()=>d(null),2e3)};if(n||!e)return(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(`h3`,{className:`text-xs font-medium text-text-secondary`,children:`API Proxy`}),(0,H.jsx)(`p`,{className:`text-[11px] text-text-subtle`,children:o?`Error: ${o}`:`Loading...`})]});let m=!!e.authKey,h=!!e.tunnelUrl;return(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsx)(`div`,{className:`space-y-1.5`,children:(0,H.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Expose your Claude accounts as an Anthropic-compatible API endpoint. External tools (OpenCode, Cursor, etc.) can use your accounts via this proxy.`})}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,H.jsx)(Yp,{className:`text-xs`,children:`Enable Proxy`}),(0,H.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Accept API requests on /proxy/v1/messages`})]}),(0,H.jsx)(fm,{checked:e.enabled,onCheckedChange:e=>f({enabled:e}),disabled:i})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Yp,{className:`text-[11px]`,children:`Auth Key`}),m?(0,H.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,H.jsx)(u,{readOnly:!0,value:e.authKey,className:`h-7 text-[11px] font-mono flex-1`}),(0,H.jsx)(c,{variant:`outline`,size:`sm`,className:`h-7 px-2 cursor-pointer shrink-0`,onClick:()=>p(e.authKey,`key`),children:l===`key`?`Copied!`:(0,H.jsx)(Ve,{className:`size-3`})}),(0,H.jsx)(c,{variant:`outline`,size:`sm`,className:`h-7 px-2 cursor-pointer shrink-0`,onClick:()=>f({generateKey:!0}),disabled:i,children:(0,H.jsx)(kt,{className:`size-3`})})]}):(0,H.jsx)(c,{variant:`outline`,size:`sm`,className:`h-7 text-xs cursor-pointer`,onClick:()=>f({generateKey:!0}),disabled:i,children:`Generate Auth Key`}),(0,H.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Use as Bearer token or x-api-key when calling the proxy.`})]}),e.enabled&&m&&(0,H.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3 bg-muted/30`,children:[(0,H.jsx)(`h4`,{className:`text-[11px] font-medium`,children:`Connection Info`}),(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(Yp,{className:`text-[10px] text-muted-foreground`,children:`Local Endpoint`}),(0,H.jsxs)(`div`,{className:`flex gap-1.5 items-center`,children:[(0,H.jsx)(`code`,{className:`text-[10px] font-mono bg-muted px-1.5 py-0.5 rounded flex-1 truncate`,children:`${window.location.origin}/proxy/v1/messages`}),(0,H.jsx)(c,{variant:`ghost`,size:`sm`,className:`h-6 px-1.5 cursor-pointer shrink-0`,onClick:()=>p(`${window.location.origin}/proxy/v1/messages`,`local`),children:l===`local`?`Copied!`:(0,H.jsx)(Ve,{className:`size-3`})})]})]}),h&&e.proxyEndpoint&&(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(Yp,{className:`text-[10px] text-muted-foreground`,children:`Public Endpoint (Tunnel)`}),(0,H.jsxs)(`div`,{className:`flex gap-1.5 items-center`,children:[(0,H.jsx)(`code`,{className:`text-[10px] font-mono bg-muted px-1.5 py-0.5 rounded flex-1 truncate`,children:e.proxyEndpoint}),(0,H.jsx)(c,{variant:`ghost`,size:`sm`,className:`h-6 px-1.5 cursor-pointer shrink-0`,onClick:()=>p(e.proxyEndpoint,`tunnel`),children:l===`tunnel`?`Copied!`:(0,H.jsx)(Ve,{className:`size-3`})})]})]}),!h&&(0,H.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Start a Cloudflare tunnel (Share) to get a public URL.`}),(0,H.jsxs)(`div`,{className:`space-y-1 pt-1`,children:[(0,H.jsx)(Yp,{className:`text-[10px] text-muted-foreground`,children:`Usage Example`}),(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(`pre`,{className:`text-[9px] font-mono bg-muted p-2 rounded overflow-x-auto whitespace-pre`,children:`# Set as base URL in your tool
20
20
  ANTHROPIC_BASE_URL=${h&&e.proxyEndpoint?e.tunnelUrl+`/proxy`:window.location.origin+`/proxy`}
21
21
  ANTHROPIC_API_KEY=${e.authKey}
22
22
 
@@ -25,13 +25,13 @@ curl ${h&&e.proxyEndpoint?e.proxyEndpoint:window.location.origin+`/proxy/v1/mess
25
25
  -H "x-api-key: ${e.authKey}" \\
26
26
  -H "content-type: application/json" \\
27
27
  -H "anthropic-version: 2023-06-01" \\
28
- -d '{"model":"claude-sonnet-4-6","max_tokens":1024,"messages":[{"role":"user","content":"Hello"}]}'`}),(0,H.jsx)(c,{variant:`ghost`,size:`sm`,className:`absolute top-1 right-1 h-5 px-1 cursor-pointer`,onClick:()=>p(`ANTHROPIC_BASE_URL=${h?e.tunnelUrl+`/proxy`:window.location.origin+`/proxy`}\nANTHROPIC_API_KEY=${e.authKey}`,`example`),children:l===`example`?`Copied!`:(0,H.jsx)(Ve,{className:`size-2.5`})})]})]}),(0,H.jsx)(`div`,{className:`flex items-center gap-3 pt-1`,children:(0,H.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`Requests served: `,(0,H.jsx)(`span`,{className:`font-mono`,children:e.requestCount})]})})]}),i&&(0,H.jsx)(`p`,{className:`text-[11px] text-text-subtle`,children:`Saving...`}),o&&(0,H.jsx)(`p`,{className:`text-[11px] text-red-500`,children:o})]})}function fm(e){let t=(e+`=`.repeat((4-e.length%4)%4)).replace(/-/g,`+`).replace(/_/g,`/`),n=atob(t);return Uint8Array.from(n,e=>e.charCodeAt(0))}function pm(){let[e,t]=(0,B.useState)(`default`),[n,r]=(0,B.useState)(!1),[i,a]=(0,B.useState)(!1),[o,s]=(0,B.useState)(null);return(0,B.useEffect)(()=>{`Notification`in window&&t(Notification.permission),r(localStorage.getItem(`ppm-push-subscribed`)===`true`)},[]),{permission:e,isSubscribed:n,loading:i,error:o,subscribe:(0,B.useCallback)(async()=>{a(!0),s(null);try{let e=await Notification.requestPermission();if(t(e),e!==`granted`){s(`Permission denied`);return}if(!navigator.serviceWorker?.controller&&!navigator.serviceWorker?.ready){s(`Service worker not available (dev mode?)`);return}let n=await Promise.race([navigator.serviceWorker.ready,new Promise((e,t)=>setTimeout(()=>t(Error(`Service worker timeout`)),5e3))]);if(!n)throw Error(`Service worker not ready`);let i={},a=pe();a&&(i.Authorization=`Bearer ${a}`);let o=await(await fetch(`/api/push/vapid-key`,{headers:i})).json();if(!o.ok)throw Error(o.error||`Failed to get VAPID key`);let c=await n.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:fm(o.data.publicKey).buffer});await fetch(`/api/push/subscribe`,{method:`POST`,headers:{...i,"Content-Type":`application/json`},body:JSON.stringify(c.toJSON())}),r(!0),localStorage.setItem(`ppm-push-subscribed`,`true`)}catch(e){s(e instanceof Error?e.message:`Subscribe failed`),console.error(`[push] Subscribe failed:`,e)}finally{a(!1)}},[]),unsubscribe:(0,B.useCallback)(async()=>{a(!0);try{let e=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(e){let t={"Content-Type":`application/json`},n=pe();n&&(t.Authorization=`Bearer ${n}`),await fetch(`/api/push/subscribe`,{method:`DELETE`,headers:t,body:JSON.stringify({endpoint:e.endpoint})}),await e.unsubscribe()}r(!1),localStorage.removeItem(`ppm-push-subscribed`)}catch(e){console.error(`[push] Unsubscribe failed:`,e)}finally{a(!1)}},[])}}var mm=[{value:`light`,label:`Light`,icon:Lt},{value:`dark`,label:`Dark`,icon:xt},{value:`system`,label:`System`,icon:bt}],hm=`PushManager`in window&&`serviceWorker`in navigator,gm=/iPhone|iPad/.test(navigator.userAgent)&&!window.matchMedia(`(display-mode: standalone)`).matches,_m=[{value:`ai`,label:`AI Provider`,subtitle:`Model, execution mode, limits`,icon:ke},{value:`notifications`,label:`Notifications`,subtitle:`Push & Telegram alerts`,icon:De},{value:`proxy`,label:`API Proxy`,subtitle:`Expose accounts as Anthropic API`,icon:it},{value:`shortcuts`,label:`Keyboard Shortcuts`,subtitle:`Customize key bindings`,icon:lt}];function vm(){let{theme:e,setTheme:t,deviceName:n,setDeviceName:r,version:i}=V(),{permission:a,isSubscribed:s,loading:l,error:f,subscribe:p,unsubscribe:m}=pm(),[h,g]=(0,B.useState)(null),[_,v]=(0,B.useState)(n??``),[y,b]=(0,B.useState)(!1),[x,S]=(0,B.useState)(!1),C=(0,B.useRef)(void 0),w=_.trim()!==(n??``),T=(0,B.useCallback)(async()=>{if(w){b(!0);try{await r(_),S(!0),clearTimeout(C.current),C.current=setTimeout(()=>S(!1),2e3)}finally{b(!1)}}},[_,w,r]);if(h){let e=_m.find(e=>e.value===h),t=e.icon;return(0,H.jsxs)(`div`,{className:`h-full w-full flex flex-col`,children:[(0,H.jsxs)(`div`,{className:`shrink-0 px-2 pt-3 pb-1 flex items-center gap-1`,children:[(0,H.jsx)(c,{variant:`ghost`,size:`icon`,className:`size-8 cursor-pointer shrink-0`,onClick:()=>g(null),children:(0,H.jsx)(Ce,{className:`size-4`})}),(0,H.jsx)(t,{className:`size-4 text-muted-foreground shrink-0`}),(0,H.jsx)(`h2`,{className:`text-sm font-semibold truncate`,children:e.label})]}),(0,H.jsx)(Kp,{}),(0,H.jsx)(lp,{className:`flex-1 min-h-0`,children:(0,H.jsxs)(`div`,{className:`p-3`,children:[h===`ai`&&(0,H.jsx)(im,{compact:!0}),h===`notifications`&&(0,H.jsx)(ym,{isSubscribed:s,loading:l,permission:a,pushError:f,subscribe:p,unsubscribe:m}),h===`proxy`&&(0,H.jsx)(dm,{}),h===`shortcuts`&&(0,H.jsx)(cm,{})]})})]})}return(0,H.jsxs)(`div`,{className:`h-full w-full flex flex-col`,children:[(0,H.jsx)(`div`,{className:`shrink-0 px-3 pt-3 pb-1`,children:(0,H.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Settings`})}),(0,H.jsx)(lp,{className:`flex-1 min-h-0`,children:(0,H.jsxs)(`div`,{className:`p-3 space-y-4`,children:[(0,H.jsxs)(`section`,{className:`space-y-2`,children:[(0,H.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:`Device Name`}),(0,H.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,H.jsx)(u,{value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&T()},placeholder:`My Device`,className:`h-8 text-xs flex-1`,maxLength:100}),(0,H.jsx)(c,{variant:x?`default`:`outline`,size:`sm`,className:`h-8 text-xs px-3 cursor-pointer`,disabled:!w||y,onClick:T,children:y?`...`:x?(0,H.jsx)(o,{className:`size-3.5`}):`Save`})]}),(0,H.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Shown in page title and synced to PPM Cloud.`})]}),(0,H.jsxs)(`section`,{className:`space-y-2`,children:[(0,H.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:`Theme`}),(0,H.jsx)(`div`,{className:`flex gap-1.5`,children:mm.map(n=>{let r=n.icon;return(0,H.jsxs)(c,{variant:e===n.value?`default`:`outline`,size:`sm`,onClick:()=>t(n.value),className:R(`flex-1 gap-1.5 text-xs h-8 cursor-pointer`,e===n.value&&`ring-2 ring-primary`),children:[(0,H.jsx)(r,{className:`size-3.5`}),n.label]},n.value)})})]}),(0,H.jsx)(Kp,{}),(0,H.jsx)(`nav`,{className:`space-y-1`,"aria-label":`Settings categories`,children:_m.map(e=>{let t=e.icon;return(0,H.jsxs)(`button`,{onClick:()=>g(e.value),className:`w-full flex items-center gap-3 px-2.5 py-2.5 rounded-lg hover:bg-accent/50 active:bg-accent transition-colors cursor-pointer text-left group`,children:[(0,H.jsx)(`div`,{className:`size-8 rounded-md bg-muted flex items-center justify-center shrink-0 group-hover:bg-accent`,children:(0,H.jsx)(t,{className:`size-4 text-muted-foreground`})}),(0,H.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium text-foreground truncate`,children:e.label}),(0,H.jsx)(`p`,{className:`text-[11px] text-muted-foreground truncate`,children:e.subtitle})]}),(0,H.jsx)(d,{className:`size-4 text-muted-foreground shrink-0`})]},e.value)})}),(0,H.jsx)(Kp,{}),(0,H.jsxs)(`section`,{className:`space-y-1 pb-2`,children:[(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`PPM — Personal Project Manager`}),(0,H.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`A mobile-first web IDE for managing your projects.`}),i&&(0,H.jsxs)(`p`,{className:`text-[11px] text-muted-foreground tabular-nums`,children:[`Version `,i]})]})]})})]})}function ym({isSubscribed:e,loading:t,permission:n,pushError:r,subscribe:i,unsubscribe:a}){return(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`section`,{className:`space-y-2`,children:[(0,H.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:`Push Notifications`}),hm?(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[e?(0,H.jsx)(Oe,{className:`size-3.5`}):(0,H.jsx)(Ee,{className:`size-3.5`}),(0,H.jsx)(`span`,{className:`text-xs`,children:`Push notifications`})]}),(0,H.jsx)(c,{variant:e?`default`:`outline`,size:`sm`,className:`h-7 text-xs cursor-pointer`,disabled:t||n===`denied`,onClick:()=>e?a():i(),children:t?`...`:e?`On`:`Off`})]}),e&&(0,H.jsx)(c,{variant:`outline`,size:`sm`,className:`h-7 text-xs w-full cursor-pointer`,onClick:()=>{new Notification(`PPM Test`,{body:`Push notifications are working!`})},children:`Test notification`}),r&&(0,H.jsx)(`p`,{className:`text-[11px] text-destructive`,children:r}),n===`denied`&&(0,H.jsx)(`p`,{className:`text-[11px] text-destructive`,children:`Notifications blocked. Enable in browser settings.`}),gm&&(0,H.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`On iOS, install PPM to Home Screen for push notifications.`})]}):(0,H.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Push notifications not supported in this browser.`})]}),(0,H.jsx)(Kp,{}),(0,H.jsxs)(`section`,{className:`space-y-2`,children:[(0,H.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:`Telegram`}),(0,H.jsx)(lm,{})]})]})}function bm({connections:e,cachedTables:t,onOpenTable:n,onRefreshTables:r,onEdit:i,onDelete:a}){let[o,c]=(0,B.useState)(new Set),[l,u]=(0,B.useState)(new Set([`__ungrouped__`])),[f,p]=(0,B.useState)(new Set),[m,h]=(0,B.useState)(new Map),g=e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},_=e=>{u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},v=async e=>{p(t=>new Set(t).add(e));try{await r(e)}finally{p(t=>{let n=new Set(t);return n.delete(e),n})}},y={};for(let t of e){let e=t.group_name??`__ungrouped__`;(y[e]??=[]).push(t)}let b=Object.keys(y).sort((e,t)=>e===`__ungrouped__`?1:t===`__ungrouped__`?-1:e.localeCompare(t));return e.length===0?(0,H.jsxs)(`p`,{className:`px-4 py-6 text-xs text-text-subtle text-center`,children:[`No connections yet.`,(0,H.jsx)(`br`,{}),`Click + to add one.`]}):(0,H.jsx)(`div`,{className:`py-1`,children:b.map(e=>{let r=l.has(e),c=e===`__ungrouped__`?`Ungrouped`:e,u=y[e],p=b.length>1||e!==`__ungrouped__`;return(0,H.jsxs)(`div`,{children:[p&&(0,H.jsxs)(`button`,{onClick:()=>_(e),className:`w-full flex items-center gap-1 px-2 py-1 text-[10px] font-semibold text-text-subtle uppercase tracking-wider hover:text-text-secondary transition-colors`,children:[r?(0,H.jsx)(s,{className:`size-3`}):(0,H.jsx)(d,{className:`size-3`}),c]}),r&&(0,H.jsx)(`div`,{className:p?`ml-[11px] border-l border-dashed border-border`:``,children:u.map(e=>{let r=o.has(e.id),c=t.get(e.id)??[],l=f.has(e.id);return(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:R(`group flex items-center gap-1 py-1 hover:bg-surface-elevated transition-colors`,p?`pl-3 pr-2`:`px-2`),children:[(0,H.jsx)(`button`,{onClick:()=>{g(e.id),!o.has(e.id)&&c.length===0&&v(e.id)},className:`shrink-0 text-text-subtle hover:text-foreground transition-colors`,children:r?(0,H.jsx)(s,{className:`size-3`}):(0,H.jsx)(d,{className:`size-3`})}),(0,H.jsx)(`span`,{className:`shrink-0 size-2 rounded-full border border-border`,style:{backgroundColor:e.color??`transparent`}}),(0,H.jsx)(`button`,{className:`flex-1 text-left text-xs truncate hover:text-primary transition-colors`,onClick:()=>{g(e.id),!o.has(e.id)&&c.length===0&&v(e.id)},children:e.name}),(0,H.jsx)(`span`,{className:`shrink-0 text-[9px] text-text-subtle uppercase px-1 rounded bg-surface-elevated`,children:e.type===`postgres`?`PG`:`DB`}),e.readonly===1&&(0,H.jsx)(`span`,{title:`Readonly`,children:(0,H.jsx)(mt,{className:`shrink-0 size-2.5 text-text-subtle`,"aria-label":`Readonly`})}),(0,H.jsxs)(`div`,{className:`hidden group-hover:flex items-center gap-0.5 shrink-0`,children:[(0,H.jsx)(`button`,{onClick:()=>v(e.id),disabled:l,className:`p-0.5 text-text-subtle hover:text-foreground transition-colors`,title:`Refresh tables`,children:(0,H.jsx)(kt,{className:R(`size-3`,l&&`animate-spin`)})}),(0,H.jsx)(`button`,{onClick:()=>i(e),className:`p-0.5 text-text-subtle hover:text-foreground transition-colors`,title:`Edit`,children:(0,H.jsx)(Dt,{className:`size-3`})}),(0,H.jsx)(`button`,{onClick:()=>a(e.id),className:`p-0.5 text-text-subtle hover:text-red-500 transition-colors`,title:`Delete`,children:(0,H.jsx)(zt,{className:`size-3`})})]})]}),r&&(0,H.jsxs)(`div`,{className:`ml-[11px] border-l border-dashed border-border pl-3`,children:[l&&c.length===0&&(0,H.jsx)(`p`,{className:`text-[10px] text-text-subtle px-2 py-1`,children:`Loading…`}),!l&&c.length===0&&(0,H.jsx)(`p`,{className:`text-[10px] text-text-subtle px-2 py-1`,children:`No tables cached`}),c.length>0&&(0,H.jsx)(Sm,{connId:e.id,tables:c,filter:m.get(e.id)??``,onFilterChange:t=>h(n=>new Map(n).set(e.id,t)),onOpenTable:(t,r)=>n(e,t,r)})]})]},e.id)})})]},e)})})}var xm=200;function Sm({connId:e,tables:t,filter:n,onFilterChange:r,onOpenTable:i}){let a=(0,B.useMemo)(()=>{if(!n)return t;let e=n.toLowerCase();return t.filter(t=>t.tableName.toLowerCase().includes(e))},[t,n]);return(0,H.jsxs)(`div`,{children:[t.length>5&&(0,H.jsxs)(`div`,{className:`flex items-center gap-1 px-1 py-0.5`,children:[(0,H.jsx)(Mt,{className:`size-2.5 text-text-subtle shrink-0`}),(0,H.jsx)(`input`,{type:`text`,value:n,onChange:e=>r(e.target.value),placeholder:`Filter tables…`,className:`w-full text-[10px] bg-transparent border-none outline-none text-foreground placeholder:text-text-subtle`})]}),(0,H.jsxs)(`div`,{className:`overflow-y-auto`,style:{maxHeight:xm},children:[a.map(t=>(0,H.jsxs)(`button`,{onClick:()=>i(t.tableName,t.schemaName),className:`w-full flex items-center gap-1.5 px-2 py-0.5 text-[11px] text-text-secondary hover:text-foreground hover:bg-surface-elevated transition-colors text-left truncate`,children:[(0,H.jsx)(He,{className:`size-2.5 shrink-0 text-text-subtle`}),(0,H.jsx)(`span`,{className:`truncate`,children:t.tableName})]},`${e}-${t.schemaName}.${t.tableName}`)),n&&a.length===0&&(0,H.jsx)(`p`,{className:`text-[10px] text-text-subtle px-2 py-1`,children:`No match`})]})]})}var Cm=`ppm-recent-paths`,wm=5,Tm=[{name:`Home`,path:`~`,icon:st},{name:`Desktop`,path:`~/Desktop`,icon:bt},{name:`Documents`,path:`~/Documents`,icon:Xe},{name:`Downloads`,path:`~/Downloads`,icon:Ue}];function Em(){try{return JSON.parse(localStorage.getItem(Cm)??`[]`)}catch{return[]}}function Dm(e){let t=[e,...Em().filter(t=>t!==e)].slice(0,wm);localStorage.setItem(Cm,JSON.stringify(t))}function Om(e){return e==null?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function km(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return`now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function Am(e){if(e.type===`directory`)return(0,H.jsx)(tt,{className:`size-4 text-blue-500`});let t=e.name.split(`.`).pop()?.toLowerCase();return t&&[`db`,`sqlite`,`sqlite3`].includes(t)?(0,H.jsx)(He,{className:`size-4 text-amber-500`}):(0,H.jsx)(Qe,{className:`size-4 text-text-subtle`})}function jm(e,t){if(!t?.length)return!0;let n=`.`+e.split(`.`).pop()?.toLowerCase();return t.includes(n)}function Mm({open:e,mode:t,accept:n,root:r,title:i,onSelect:a,onCancel:o}){let[s,l]=(0,B.useState)([]),[f,p]=(0,B.useState)(``),[m,h]=(0,B.useState)(null),[g,_]=(0,B.useState)([]),[v,y]=(0,B.useState)(null),[b,x]=(0,B.useState)(!1),[S,C]=(0,B.useState)(null),[w,T]=(0,B.useState)(``),[E,D]=(0,B.useState)(``),[O,ee]=(0,B.useState)(!1),[k,A]=(0,B.useState)([]),j=(0,B.useRef)(null),te=typeof window<`u`&&window.innerWidth<768,M=t===`folder`?`Select Folder`:t===`file`?`Select File`:`Select File or Folder`,N=(0,B.useCallback)(async(e,t)=>{x(!0),C(null),y(null),T(``);try{let n=new URLSearchParams;e&&n.set(`path`,e),t&&n.set(`showHidden`,`true`);let r=await z.get(`/api/fs/browse?${n}`);l(r.entries),p(r.current),h(r.parent),_(r.breadcrumbs),D(r.current)}catch(e){C(e.message||`Failed to browse directory`)}finally{x(!1)}},[]);(0,B.useEffect)(()=>{e&&(N(r??`~`,O),A(Em()))},[e,r,N,O]);let P=e=>N(e,O),ne=()=>{let e=!O;ee(e),N(f||(r??`~`),e)},re=e=>{e.key===`Enter`&&E.trim()&&N(E.trim())},F=e=>{e.type===`directory`?t===`file`?P(e.path):y(e.path):t!==`folder`&&y(e.path)},ie=e=>{e.type===`directory`&&P(e.path)},ae=()=>{v&&(Dm(f),a(v))},I=s.filter(e=>!(w&&!e.name.toLowerCase().includes(w.toLowerCase())||e.type===`file`&&n?.length&&!jm(e.name,n))),oe=e=>e.type===`directory`?t!==`file`:t!==`folder`,se=(0,H.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-2 border-b border-border`,children:[m&&(0,H.jsx)(c,{variant:`ghost`,size:`icon`,className:`size-7 shrink-0`,onClick:()=>P(m),children:(0,H.jsx)(Ce,{className:`size-4`})}),(0,H.jsx)(u,{value:E,onChange:e=>D(e.target.value),onKeyDown:re,placeholder:`Type path and press Enter`,className:`h-7 text-xs font-mono flex-1`})]}),(0,H.jsx)(`div`,{className:`flex items-center gap-0.5 px-3 py-1.5 border-b border-border overflow-x-auto text-xs`,children:g.map((e,t)=>(0,H.jsxs)(`span`,{className:`flex items-center shrink-0`,children:[t>0&&(0,H.jsx)(d,{className:`size-3 text-text-subtle mx-0.5`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>P(e.path),className:`hover:text-primary hover:underline text-text-secondary`,children:e.name})]},e.path))}),(0,H.jsxs)(`div`,{className:`flex flex-1 min-h-0 overflow-hidden`,children:[!te&&(0,H.jsxs)(`div`,{className:`w-36 border-r border-border py-2 px-1 shrink-0 overflow-y-auto`,children:[Tm.map(e=>(0,H.jsxs)(`button`,{type:`button`,onClick:()=>P(e.path),className:R(`flex items-center gap-2 w-full px-2 py-1 text-xs rounded-md hover:bg-surface-hover text-left`,f.endsWith(e.name)&&`bg-primary/10 text-primary`),children:[(0,H.jsx)(e.icon,{className:`size-3.5`}),e.name]},e.path)),k.length>0&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`text-[10px] text-text-subtle px-2 mt-3 mb-1 font-medium`,children:`Recent`}),k.map(e=>(0,H.jsxs)(`button`,{type:`button`,onClick:()=>P(e),className:`flex items-center gap-2 w-full px-2 py-1 text-xs rounded-md hover:bg-surface-hover text-left truncate`,children:[(0,H.jsx)(ze,{className:`size-3 shrink-0`}),(0,H.jsx)(`span`,{className:`truncate`,children:e.split(`/`).pop()})]},e))]})]}),(0,H.jsx)(lp,{className:`flex-1 min-h-0`,children:b?(0,H.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,H.jsx)(pt,{className:`size-5 animate-spin text-text-subtle`})}):S?(0,H.jsx)(`div`,{className:`text-center py-8 text-xs text-red-500`,children:S}):I.length===0?(0,H.jsx)(`div`,{className:`text-center py-8 text-xs text-text-subtle`,children:w?`No matching entries`:`Empty directory`}):(0,H.jsx)(`div`,{ref:j,className:`py-1`,children:I.map(e=>{let t=oe(e);return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>F(e),onDoubleClick:()=>ie(e),className:R(`flex items-center gap-2 w-full px-3 py-1.5 text-left text-xs transition-colors`,v===e.path?`bg-primary/10 text-primary`:t?`hover:bg-surface-hover text-text-primary`:`opacity-40 cursor-default`),disabled:!t&&e.type===`file`,children:[Am(e),(0,H.jsx)(`span`,{className:R(`flex-1 truncate`,e.type===`directory`&&`font-medium`),children:e.name}),(0,H.jsx)(`span`,{className:`text-text-subtle text-[10px] shrink-0 w-14 text-right`,children:Om(e.size)}),(0,H.jsx)(`span`,{className:`text-text-subtle text-[10px] shrink-0 w-14 text-right`,children:km(e.modified)})]},e.path)})})})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-t border-border shrink-0`,children:[(0,H.jsx)(c,{variant:`ghost`,size:`icon`,className:R(`size-7 shrink-0`,O&&`text-primary`),onClick:ne,title:O?`Hide hidden files`:`Show hidden files`,children:O?(0,H.jsx)(Ke,{className:`size-3.5`}):(0,H.jsx)(Ge,{className:`size-3.5`})}),n?.length?(0,H.jsx)(`span`,{className:`text-[10px] text-text-subtle bg-surface-hover px-1.5 py-0.5 rounded`,children:n.join(`, `)}):null,(0,H.jsx)(`div`,{className:`flex-1 max-w-48`,children:(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(Mt,{className:`absolute left-2 top-1/2 -translate-y-1/2 size-3 text-text-subtle`}),(0,H.jsx)(u,{value:w,onChange:e=>T(e.target.value),placeholder:`Filter...`,className:`h-6 text-[11px] pl-6`})]})}),(0,H.jsx)(`div`,{className:`flex-1`}),(0,H.jsx)(c,{variant:`outline`,size:`sm`,onClick:o,className:`h-7 text-xs`,children:`Cancel`}),(0,H.jsx)(c,{size:`sm`,onClick:ae,disabled:!v,className:`h-7 text-xs`,children:`Select`})]})]});return(0,H.jsx)(gp,{open:e,onOpenChange:e=>{e||o()},children:(0,H.jsxs)(yp,{className:R(`p-0 gap-0 overflow-hidden flex flex-col`,te?`max-w-[95vw] h-[85vh]`:`max-w-2xl h-[70vh]`),children:[(0,H.jsx)(bp,{className:`px-3 py-2 border-b border-border`,children:(0,H.jsx)(Sp,{className:`text-sm`,children:i??M})}),se]})})}function Nm({mode:e,accept:t,root:n,title:r,onSelect:i,className:a}){let[o,s]=(0,B.useState)(!1);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(c,{type:`button`,variant:`ghost`,size:`icon`,className:R(`size-8 shrink-0`,a),onClick:()=>s(!0),title:r??`Browse...`,children:(0,H.jsx)($e,{className:`size-4`})}),(0,H.jsx)(Mm,{open:o,mode:e,accept:t,root:n,title:r,onSelect:e=>{i(e),s(!1)},onCancel:()=>s(!1)})]})}var Pm=[`#ef4444`,`#f97316`,`#eab308`,`#22c55e`,`#06b6d4`,`#3b82f6`,`#8b5cf6`,`#ec4899`,`#6b7280`,`#000000`];function Fm({value:e,onChange:t}){return(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>t(null),className:R(`size-6 rounded-full border-2 transition-all`,e?`border-border hover:scale-105`:`border-primary scale-110`,`bg-transparent relative`),title:`No color`,children:(0,H.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center text-[8px] text-text-subtle`,children:`×`})}),Pm.map(n=>(0,H.jsx)(`button`,{type:`button`,onClick:()=>t(n),className:R(`size-6 rounded-full border-2 transition-all hover:scale-105`,e===n?`border-primary scale-110`:`border-transparent`),style:{backgroundColor:n},title:n},n))]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`div`,{className:`size-6 rounded-full border border-border shrink-0`,style:{backgroundColor:e??`transparent`}}),(0,H.jsx)(`input`,{type:`text`,value:e??``,onChange:e=>{let n=e.target.value.trim();if(n===``){t(null);return}/^#[0-9a-fA-F]{6}$/.test(n),t(n)},placeholder:`#3b82f6`,className:`flex-1 h-7 text-xs px-2 rounded-md border border-border bg-background focus:outline-none focus:border-primary font-mono`})]})]})}function Im({open:e,onClose:t,connection:n,onSave:r,onUpdate:i,onTest:a}){let o=!!n,[s,l]=(0,B.useState)({name:``,type:`postgres`,path:``,connectionString:``,groupName:``,color:null,readonly:!0}),[u,d]=(0,B.useState)(!1),[f,p]=(0,B.useState)(null),[m,h]=(0,B.useState)(!1),[g,_]=(0,B.useState)(null);(0,B.useEffect)(()=>{if(!e){p(null),_(null);return}l(n?{name:n.name,type:n.type,path:``,connectionString:``,groupName:n.group_name??``,color:n.color,readonly:n.readonly===1}:{name:``,type:`postgres`,path:``,connectionString:``,groupName:``,color:null,readonly:!0})},[e,n]);let v=(e,t)=>{l(n=>({...n,[e]:t})),p(null)};return(0,H.jsx)(gp,{open:e,onOpenChange:e=>{e||t()},children:(0,H.jsxs)(yp,{className:`max-w-md`,children:[(0,H.jsx)(bp,{children:(0,H.jsx)(Sp,{children:o?`Edit Connection`:`Add Connection`})}),(0,H.jsxs)(`div`,{className:`space-y-3 py-1`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`text-xs font-medium text-text-secondary mb-1 block`,children:`Name *`}),(0,H.jsx)(`input`,{value:s.name,onChange:e=>v(`name`,e.target.value),placeholder:`my-database`,className:`w-full h-8 text-sm px-2.5 rounded-md border border-border bg-background focus:outline-none focus:border-primary`})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`text-xs font-medium text-text-secondary mb-1 block`,children:`Type`}),(0,H.jsxs)(`select`,{value:s.type,onChange:e=>v(`type`,e.target.value),className:`w-full h-8 text-sm px-2 rounded-md border border-border bg-background focus:outline-none focus:border-primary`,children:[(0,H.jsx)(`option`,{value:`postgres`,children:`PostgreSQL`}),(0,H.jsx)(`option`,{value:`sqlite`,children:`SQLite`})]})]}),s.type===`postgres`?(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`text-xs font-medium text-text-secondary mb-1 block`,children:`Connection String *`}),(0,H.jsx)(`input`,{type:`password`,value:s.connectionString,onChange:e=>v(`connectionString`,e.target.value),placeholder:`postgresql://user:pass@host:5432/db`,className:`w-full h-8 text-sm px-2.5 rounded-md border border-border bg-background focus:outline-none focus:border-primary font-mono`})]}):(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`text-xs font-medium text-text-secondary mb-1 block`,children:`File Path *`}),(0,H.jsxs)(`div`,{className:`flex gap-1.5 items-center`,children:[(0,H.jsx)(`input`,{value:s.path,onChange:e=>v(`path`,e.target.value),placeholder:`/path/to/database.db`,className:`flex-1 h-8 text-sm px-2.5 rounded-md border border-border bg-background focus:outline-none focus:border-primary font-mono`}),(0,H.jsx)(Nm,{mode:`file`,accept:[`.db`,`.sqlite`,`.sqlite3`],title:`Browse for SQLite database`,onSelect:e=>v(`path`,e)})]})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`text-xs font-medium text-text-secondary mb-1 block`,children:`Group`}),(0,H.jsx)(`input`,{value:s.groupName,onChange:e=>v(`groupName`,e.target.value),placeholder:`Production`,className:`w-full h-8 text-sm px-2.5 rounded-md border border-border bg-background focus:outline-none focus:border-primary`})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`text-xs font-medium text-text-secondary mb-1 block`,children:`Tab Color`}),(0,H.jsx)(Fm,{value:s.color,onChange:e=>v(`color`,e)})]}),o&&(0,H.jsxs)(`div`,{className:`flex items-center justify-between py-1`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-xs font-medium`,children:`Readonly`}),(0,H.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:`Block non-SELECT queries (AI protection)`})]}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>v(`readonly`,!s.readonly),className:`relative w-9 h-5 rounded-full transition-colors ${s.readonly?`bg-primary`:`bg-border`}`,children:(0,H.jsx)(`span`,{className:`absolute top-0.5 left-0.5 size-4 rounded-full bg-white transition-transform ${s.readonly?`translate-x-4`:``}`})})]}),f&&(0,H.jsx)(`p`,{className:`text-xs ${f.ok?`text-green-500`:`text-red-500`}`,children:f.ok?`✓ Connection successful`:`✗ ${f.error}`}),g&&(0,H.jsx)(`p`,{className:`text-xs text-red-500`,children:g})]}),(0,H.jsxs)(xp,{children:[o&&(0,H.jsx)(c,{variant:`outline`,size:`sm`,onClick:async()=>{if(o){d(!0),p(null);try{p(await a(n.id))}finally{d(!1)}}},disabled:u,className:`mr-auto`,children:u?`Testing…`:`Test Connection`}),(0,H.jsx)(c,{variant:`outline`,size:`sm`,onClick:t,children:`Cancel`}),(0,H.jsx)(c,{size:`sm`,onClick:async()=>{if(_(null),!s.name.trim()){_(`Name is required`);return}h(!0);try{if(o&&i){let e=(s.type===`postgres`?s.connectionString.trim():s.path.trim())?s.type===`postgres`?{type:`postgres`,connectionString:s.connectionString}:{type:`sqlite`,path:s.path}:void 0;await i(n.id,{name:s.name.trim(),...e!==void 0&&{connectionConfig:e},groupName:s.groupName.trim()||null,color:s.color,readonly:s.readonly?1:0})}else if(r){let e=s.type===`postgres`?{type:`postgres`,connectionString:s.connectionString}:{type:`sqlite`,path:s.path};await r({type:s.type,name:s.name.trim(),connectionConfig:e,groupName:s.groupName.trim()||void 0,color:s.color??void 0})}t()}catch(e){_(e.message)}finally{h(!1)}},disabled:m,children:m?`Saving…`:o?`Save`:`Add`})]})]})})}function Lm({onExport:e,onImport:t}){let[n,r]=(0,B.useState)(!1),i=(0,B.useRef)(null),a=()=>r(!1),o=async()=>{a();try{let t=await e(),n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`ppm-connections-${new Date().toISOString().slice(0,10)}.json`,i.click(),URL.revokeObjectURL(r)}catch(e){alert(`Export failed: ${e.message}`)}},s=async()=>{a();try{let t=await e();await navigator.clipboard.writeText(JSON.stringify(t,null,2)),alert(`Copied ${t.connections.length} connection(s) to clipboard`)}catch(e){alert(`Export failed: ${e.message}`)}},c=async e=>{try{let n=JSON.parse(e),r=n.connections??n;if(!Array.isArray(r)){alert(`Invalid format: expected connections array`);return}let i=await t({connections:r}),a=`Imported ${i.imported} connection(s)`;i.skipped>0&&(a+=`, ${i.skipped} skipped`),i.errors?.length>0&&(a+=`\n\nErrors:\n${i.errors.join(`
29
- `)}`),alert(a)}catch(e){alert(`Import failed: ${e.message}`)}};return(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(`button`,{onClick:()=>r(e=>!e),className:`flex items-center justify-center size-5 rounded hover:bg-surface-elevated transition-colors text-text-subtle hover:text-foreground`,title:`Import / Export`,children:(0,H.jsx)(We,{className:`size-3.5`})}),n&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:a}),(0,H.jsxs)(`div`,{className:`absolute right-0 top-full mt-1 z-50 w-44 bg-background border border-border rounded-md shadow-lg py-1 text-xs`,children:[(0,H.jsxs)(`button`,{onClick:o,className:`w-full flex items-center gap-2 px-3 py-1.5 hover:bg-surface-elevated transition-colors text-left`,children:[(0,H.jsx)(Ue,{className:`size-3`}),` Export to file`]}),(0,H.jsxs)(`button`,{onClick:s,className:`w-full flex items-center gap-2 px-3 py-1.5 hover:bg-surface-elevated transition-colors text-left`,children:[(0,H.jsx)(Re,{className:`size-3`}),` Export to clipboard`]}),(0,H.jsx)(`div`,{className:`border-t border-border my-1`}),(0,H.jsxs)(`button`,{onClick:()=>{a(),i.current?.click()},className:`w-full flex items-center gap-2 px-3 py-1.5 hover:bg-surface-elevated transition-colors text-left`,children:[(0,H.jsx)(Ut,{className:`size-3`}),` Import from file`]}),(0,H.jsxs)(`button`,{onClick:async()=>{a();try{let e=await navigator.clipboard.readText();if(!e.trim()){alert(`Clipboard is empty`);return}await c(e)}catch(e){alert(`Clipboard read failed: ${e.message}`)}},className:`w-full flex items-center gap-2 px-3 py-1.5 hover:bg-surface-elevated transition-colors text-left`,children:[(0,H.jsx)(Le,{className:`size-3`}),` Import from clipboard`]})]})]}),(0,H.jsx)(`input`,{ref:i,type:`file`,accept:`.json`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.onload=()=>c(n.result),n.readAsText(t),e.target.value=``}})]})}function Rm(){let[e,t]=(0,B.useState)([]),[n,r]=(0,B.useState)(!0),[i,a]=(0,B.useState)(new Map),o=(0,B.useCallback)(async()=>{try{t(await z.get(`/api/db/connections`))}catch{}finally{r(!1)}},[]);return(0,B.useEffect)(()=>{o()},[o]),{connections:e,loading:n,cachedTables:i,createConnection:(0,B.useCallback)(async e=>{let n=await z.post(`/api/db/connections`,e);return t(e=>[...e,n]),n},[]),updateConnection:(0,B.useCallback)(async(e,n)=>{let r=await z.put(`/api/db/connections/${e}`,n);t(t=>t.map(t=>t.id===e?r:t))},[]),deleteConnection:(0,B.useCallback)(async e=>{await z.del(`/api/db/connections/${e}`),t(t=>t.filter(t=>t.id!==e)),a(t=>{let n=new Map(t);return n.delete(e),n})},[]),testConnection:(0,B.useCallback)(async e=>z.post(`/api/db/connections/${e}/test`),[]),refreshTables:(0,B.useCallback)(async e=>{let t=(await z.get(`/api/db/connections/${e}/tables`)).map(t=>({connectionId:e,tableName:t.name,schemaName:t.schema,rowCount:t.rowCount,cachedAt:new Date().toISOString()}));a(n=>new Map(n).set(e,t))},[]),exportConnections:(0,B.useCallback)(async()=>z.get(`/api/db/connections/export`),[]),importConnections:(0,B.useCallback)(async e=>{let t=await z.post(`/api/db/connections/import`,e);return await o(),t},[o])}}function zm(){let{connections:e,loading:t,cachedTables:n,createConnection:r,updateConnection:i,deleteConnection:a,testConnection:o,refreshTables:s,exportConnections:c,importConnections:l}=Rm(),u=_(e=>e.openTab),[d,f]=(0,B.useState)(!1),[p,m]=(0,B.useState)(null);return(0,H.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border shrink-0`,children:[(0,H.jsx)(`span`,{className:`text-[10px] font-semibold text-text-subtle uppercase tracking-wider`,children:`Database`}),(0,H.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,H.jsx)(Lm,{onExport:c,onImport:l}),(0,H.jsx)(`button`,{onClick:()=>f(!0),className:`flex items-center justify-center size-5 rounded hover:bg-surface-elevated transition-colors text-text-subtle hover:text-foreground`,title:`Add connection`,children:(0,H.jsx)(Ot,{className:`size-3.5`})})]})]}),(0,H.jsx)(`div`,{className:`flex-1 overflow-y-auto min-h-0`,children:t?(0,H.jsx)(`p`,{className:`px-4 py-6 text-xs text-text-subtle text-center`,children:`Loading…`}):(0,H.jsx)(bm,{connections:e,cachedTables:n,onOpenTable:(e,t,n)=>{u({type:`database`,title:`${e.name} · ${t}`,projectId:null,closable:!0,metadata:{connectionId:e.id,connectionName:e.name,dbType:e.type,tableName:t,schemaName:n,connectionColor:e.color}})},onRefreshTables:s,onEdit:m,onDelete:async e=>{confirm(`Delete this connection?`)&&await a(e)}})}),(0,H.jsx)(Im,{open:d,onClose:()=>f(!1),onSave:async e=>{let t=await r(e);t&&s(t.id).catch(()=>{})},onTest:()=>Promise.resolve({ok:!1,error:`Save connection first`})}),p&&(0,H.jsx)(Im,{open:!!p,onClose:()=>m(null),connection:p,onUpdate:async(e,t)=>{await i(e,t)},onTest:e=>o(e)})]})}function Bm(e,t,n,r){if(!e)return null;try{let i=r?e:e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return n&&(i=`\\b${i}\\b`),RegExp(`(${i})`,t?`g`:`gi`)}catch{return null}}function Vm({text:e,re:t}){if(!t)return(0,H.jsx)(`span`,{children:e});try{t.lastIndex=0;let n=e.split(t);return t.lastIndex=0,(0,H.jsx)(`span`,{children:n.map((e,n)=>(t.lastIndex=0,t.test(e)?(0,H.jsx)(`mark`,{className:`bg-yellow-300/40 text-foreground rounded-sm`,children:e},n):e))})}catch{return(0,H.jsx)(`span`,{children:e})}}function Hm({active:e,onClick:t,title:n,children:r}){return(0,H.jsx)(`button`,{onClick:t,title:n,className:R(`flex items-center justify-center w-6 h-6 rounded border shrink-0`,e?`border-primary text-primary bg-primary/10`:`border-border text-text-subtle hover:text-foreground hover:border-border/80`),children:r})}function Um(){let{activeProject:e}=bf(),t=_(e=>e.openTab),[n,r]=(0,B.useState)(``),[i,a]=(0,B.useState)(!1),[o,c]=(0,B.useState)(!1),[l,u]=(0,B.useState)(!1),[f,p]=(0,B.useState)(!1),[m,h]=(0,B.useState)(``),[g,v]=(0,B.useState)(``),[y,b]=(0,B.useState)(!1),[x,S]=(0,B.useState)(null),[C,w]=(0,B.useState)([]),[T,E]=(0,B.useState)(0),[D,O]=(0,B.useState)(!1),[ee,k]=(0,B.useState)(new Set),A=(0,B.useRef)(null),j=(0,B.useRef)(null),te=(0,B.useCallback)(async(t,n,r,i,a)=>{if(p(!1),!e||!i&&t.length<2||i&&t.length<1){w([]),E(0);return}if(i)try{new RegExp(t)}catch{p(!0),w([]);return}O(!0);try{let o=new URLSearchParams({q:t,caseSensitive:String(n),wholeWord:String(r),regex:String(i)});a&&o.set(`include`,a);let s=await z.get(`${fe(e.name)}/files/search?${o}`);w(s.results),E(s.total)}catch{w([])}finally{O(!1)}},[e]);(0,B.useEffect)(()=>(j.current&&clearTimeout(j.current),j.current=setTimeout(()=>te(n,i,o,l,m),300),()=>{j.current&&clearTimeout(j.current)}),[n,i,o,l,m,te]),(0,B.useEffect)(()=>{A.current?.focus()},[]);let M=Bm(n,i,o,l);function N(n,r){e&&t({type:`editor`,title:n.split(`/`).pop()??n,metadata:{filePath:n,projectName:e.name,lineNumber:r},projectId:e.name,closable:!0})}function P(e){k(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function ne(){if(!e||!n||C.length===0||y)return;b(!0),S(null);let t=0;try{for(let r of C){let a=await z.get(`${fe(e.name)}/files/read?path=${encodeURIComponent(r.file)}`),s=Bm(n,i,o,l);if(!s)continue;s.lastIndex=0;let c=a.content.match(s)??[];if(!c.length)continue;t+=c.length,s.lastIndex=0;let u=a.content.replace(s,g);await z.put(`${fe(e.name)}/files/write`,{path:r.file,content:u})}S(t),te(n,i,o,l,m)}catch{}finally{b(!1)}}return(0,H.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,H.jsxs)(`div`,{className:`p-2 border-b border-border space-y-1.5`,children:[(0,H.jsx)(`div`,{className:`relative flex items-center gap-1`,children:(0,H.jsxs)(`div`,{className:`relative flex-1`,children:[(0,H.jsx)(Mt,{className:`absolute left-2 top-1/2 -translate-y-1/2 size-3.5 text-text-subtle pointer-events-none`}),(0,H.jsx)(`input`,{ref:A,value:n,onChange:e=>{r(e.target.value),S(null)},placeholder:e?`Search files…`:`Select a project first`,disabled:!e,className:R(`w-full pl-7 pr-6 py-1 text-xs bg-input border rounded focus:outline-none focus:ring-1 focus:ring-primary/50 disabled:opacity-50`,f?`border-destructive`:`border-border`)}),n&&(0,H.jsx)(`button`,{onClick:()=>{r(``),w([]),E(0),p(!1),S(null)},className:`absolute right-1.5 top-1/2 -translate-y-1/2 text-text-subtle hover:text-foreground`,children:(0,H.jsx)(Gt,{className:`size-3`})})]})}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(Hm,{active:i,onClick:()=>a(e=>!e),title:`Match Case (Alt+C)`,children:(0,H.jsx)(je,{className:`size-3.5`})}),(0,H.jsx)(Hm,{active:o,onClick:()=>{c(e=>!e),l&&u(!1)},title:`Match Whole Word (Alt+W)`,children:(0,H.jsx)(Wt,{className:`size-3.5`})}),(0,H.jsx)(Hm,{active:l,onClick:()=>{u(e=>!e),o&&c(!1)},title:`Use Regular Expression (Alt+R)`,children:(0,H.jsx)(At,{className:`size-3.5`})}),f&&(0,H.jsx)(`span`,{className:`text-[10px] text-destructive ml-1`,children:`Invalid regex`})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsxs)(`div`,{className:`relative flex-1`,children:[(0,H.jsx)(`input`,{value:g,onChange:e=>v(e.target.value),placeholder:`Replace…`,disabled:!e,className:`w-full pl-2 pr-6 py-1 text-xs bg-input border border-border rounded focus:outline-none focus:ring-1 focus:ring-primary/50 disabled:opacity-50`}),g&&(0,H.jsx)(`button`,{onClick:()=>v(``),className:`absolute right-1.5 top-1/2 -translate-y-1/2 text-text-subtle hover:text-foreground`,children:(0,H.jsx)(Gt,{className:`size-3`})})]}),(0,H.jsx)(`button`,{onClick:ne,disabled:!n||C.length===0||y,title:`Replace All`,className:`flex items-center justify-center w-6 h-6 rounded border border-border text-text-subtle hover:text-foreground hover:border-border/80 disabled:opacity-40 shrink-0`,children:y?(0,H.jsx)(pt,{className:`size-3.5 animate-spin`}):(0,H.jsx)(jt,{className:`size-3.5`})})]}),(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(`input`,{value:m,onChange:e=>h(e.target.value),placeholder:`Files to include (e.g. *.ts, src/**)`,disabled:!e,className:`w-full pl-2 pr-6 py-1 text-xs bg-input border border-border rounded focus:outline-none focus:ring-1 focus:ring-primary/50 disabled:opacity-50`}),m&&(0,H.jsx)(`button`,{onClick:()=>h(``),className:`absolute right-1.5 top-1/2 -translate-y-1/2 text-text-subtle hover:text-foreground`,children:(0,H.jsx)(Gt,{className:`size-3`})})]}),(0,H.jsxs)(`div`,{className:`text-[10px] text-text-subtle h-3`,children:[(D||y)&&(0,H.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(pt,{className:`size-2.5 animate-spin`}),y?`Replacing…`:`Searching…`]}),!D&&!y&&x!==null&&(0,H.jsxs)(`span`,{className:`text-green-500`,children:[x,` replacement`,x===1?``:`s`,` made`]}),!D&&!y&&x===null&&!f&&n.length>=2&&C.length===0&&(0,H.jsx)(`span`,{children:`No results`}),!D&&!y&&x===null&&T>0&&(0,H.jsxs)(`span`,{children:[T,` result`,T===1?``:`s`,` in `,C.length,` file`,C.length===1?``:`s`]})]})]}),(0,H.jsx)(`div`,{className:`flex-1 overflow-y-auto min-h-0`,children:C.map(e=>{let t=ee.has(e.file),n=e.file.split(`/`).pop()??e.file,r=e.file.includes(`/`)?e.file.slice(0,e.file.lastIndexOf(`/`)):``;return(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`button`,{onClick:()=>P(e.file),className:`w-full flex items-center gap-1 px-2 py-1 hover:bg-muted/50 text-left`,children:[t?(0,H.jsx)(d,{className:`size-3 shrink-0 text-text-subtle`}):(0,H.jsx)(s,{className:`size-3 shrink-0 text-text-subtle`}),(0,H.jsx)(Xe,{className:`size-3 shrink-0 text-text-subtle`}),(0,H.jsx)(`span`,{className:`text-xs font-medium text-foreground truncate`,children:n}),(0,H.jsx)(`span`,{className:`text-[10px] text-text-subtle truncate flex-1 min-w-0 ml-1`,children:r}),(0,H.jsx)(`span`,{className:`text-[10px] text-text-subtle shrink-0 ml-1 bg-muted px-1 rounded`,children:e.matches.length})]}),!t&&e.matches.map(t=>(0,H.jsxs)(`button`,{onClick:()=>N(e.file,t.lineNum),className:`w-full flex items-start gap-2 pl-7 pr-2 py-0.5 hover:bg-primary/10 text-left`,children:[(0,H.jsx)(`span`,{className:`text-[10px] text-text-subtle shrink-0 w-7 text-right pt-px`,children:t.lineNum}),(0,H.jsx)(`span`,{className:`text-xs text-text-secondary truncate font-mono leading-4`,children:(0,H.jsx)(Vm,{text:t.content.trimStart(),re:M})})]},`${e.file}-${t.lineNum}`))]},e.file)})})]})}var Wm=[{id:`explorer`,label:`Explorer`,icon:$e},{id:`search`,label:`Search`,icon:Mt},{id:`git`,label:`Git`,icon:nt},{id:`database`,label:`Database`,icon:He},{id:`settings`,label:`Settings`,icon:Pt}];function Gm({onResize:e}){let t=(0,B.useRef)(!1);return(0,H.jsx)(`div`,{className:`absolute right-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-primary/30 active:bg-primary/50 transition-colors z-10`,onPointerDown:(0,B.useCallback)(e=>{e.preventDefault(),t.current=!0,e.currentTarget.setPointerCapture(e.pointerId),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`},[]),onPointerMove:(0,B.useCallback)(n=>{t.current&&e(n.clientX-48)},[e]),onPointerUp:(0,B.useCallback)(e=>{t.current=!1,e.currentTarget.releasePointerCapture(e.pointerId),document.body.style.cursor=``,document.body.style.userSelect=``},[])})}function Km(){let{activeProject:e}=bf(),t=V(e=>e.sidebarCollapsed),n=V(e=>e.sidebarWidth),r=V(e=>e.toggleSidebar),i=V(e=>e.setSidebarWidth),a=V(e=>e.sidebarActiveTab),o=V(e=>e.setSidebarActiveTab);return t?(0,H.jsx)(`aside`,{className:`hidden md:flex flex-col w-10 min-w-10 bg-background border-r border-border`,children:(0,H.jsx)(`button`,{onClick:r,title:`Expand sidebar (⌘B)`,className:`flex items-center justify-center h-[41px] border-b border-border text-text-secondary hover:text-foreground transition-colors`,children:(0,H.jsx)(Et,{className:`size-4`})})}):(0,H.jsxs)(`aside`,{className:`hidden md:flex flex-col bg-background border-r border-border overflow-hidden relative`,style:{width:n,minWidth:200,maxWidth:600},children:[(0,H.jsxs)(`div`,{className:`flex items-center h-[41px] border-b border-border shrink-0`,children:[Wm.map(e=>{let t=e.icon;return(0,H.jsx)(`button`,{onClick:()=>o(e.id),className:R(`flex-1 flex items-center justify-center gap-1.5 h-full text-xs transition-colors border-b-2 -mb-px`,a===e.id?`border-primary text-primary font-medium`:`border-transparent text-text-secondary hover:text-foreground`),children:(0,H.jsx)(t,{className:`size-3.5`,title:e.label})},e.id)}),(0,H.jsx)(`button`,{onClick:r,title:`Collapse sidebar (⌘B)`,className:`flex items-center justify-center w-8 h-full text-text-subtle hover:text-text-secondary transition-colors shrink-0`,children:(0,H.jsx)(Tt,{className:`size-3.5`})})]}),(0,H.jsxs)(`div`,{className:`flex-1 overflow-y-auto min-h-0`,children:[a===`explorer`&&(e?(0,H.jsx)(Op,{}):(0,H.jsx)(`div`,{className:`flex items-center justify-center h-24 p-4`,children:(0,H.jsx)(`p`,{className:`text-xs text-text-subtle text-center`,children:`Select a project to browse files`})})),a===`git`&&(0,H.jsx)(zp,{metadata:{projectName:e?.name}}),a===`search`&&(0,H.jsx)(Um,{}),a===`database`&&(0,H.jsx)(zm,{}),a===`settings`&&(0,H.jsx)(vm,{})]}),(0,H.jsx)(Gm,{onResize:i})]})}var qm=Object.defineProperty,Jm=Object.getOwnPropertySymbols,Ym=Object.prototype.hasOwnProperty,Xm=Object.prototype.propertyIsEnumerable,Zm=(e,t,n)=>t in e?qm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Qm=(e,t)=>{for(var n in t||={})Ym.call(t,n)&&Zm(e,n,t[n]);if(Jm)for(var n of Jm(t))Xm.call(t,n)&&Zm(e,n,t[n]);return e},$m=(e,t)=>{var n={};for(var r in e)Ym.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Jm)for(var r of Jm(e))t.indexOf(r)<0&&Xm.call(e,r)&&(n[r]=e[r]);return n},eh;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+(t?1:0),n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i;for(i=0;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})(eh||={}),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(eh||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(eh||={});var th=eh,nh={L:th.QrCode.Ecc.LOW,M:th.QrCode.Ecc.MEDIUM,Q:th.QrCode.Ecc.QUARTILE,H:th.QrCode.Ecc.HIGH},rh=128,ih=`L`,ah=`#FFFFFF`,oh=`#000000`,sh=!1,ch=1,lh=4,uh=0,dh=.1;function fh(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function ph(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function mh(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*dh),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function hh(e,t){return t==null?e?lh:uh:Math.max(Math.floor(t),0)}function gh({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=B.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...th.QrSegment.makeSegments(t)),e),[]);return th.QrCode.encodeSegments(r,nh[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:u,numCells:d,calculatedImageSettings:f}=B.useMemo(()=>{let e=c.getModules(),t=hh(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:mh(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var _h=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),vh=B.forwardRef(function(e,t){let n=e,{value:r,size:i=rh,level:a=ih,bgColor:o=ah,fgColor:s=oh,includeMargin:c=sh,minVersion:l=ch,boostLevel:u,marginSize:d,imageSettings:f}=n,p=$m(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=$m(p,[`style`]),g=f?.src,_=B.useRef(null),v=B.useRef(null),y=B.useCallback(e=>{_.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[b,x]=B.useState(!1),{margin:S,cells:C,numCells:w,calculatedImageSettings:T}=gh({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:d,imageSettings:f,size:i});B.useEffect(()=>{if(_.current!=null){let e=_.current,t=e.getContext(`2d`);if(!t)return;let n=C,r=v.current,a=T!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&T.excavation!=null&&(n=ph(C,T.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/w*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,w,w),t.fillStyle=s,_h?t.fill(new Path2D(fh(n,S))):C.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+S,n+S,1,1)})}),T&&(t.globalAlpha=T.opacity),a&&t.drawImage(r,T.x+S,T.y+S,T.w,T.h)}}),B.useEffect(()=>{x(!1)},[g]);let E=Qm({height:i,width:i},m),D=null;return g!=null&&(D=B.createElement(`img`,{src:g,key:g,style:{display:`none`},onLoad:()=>{x(!0)},ref:v,crossOrigin:T?.crossOrigin})),B.createElement(B.Fragment,null,B.createElement(`canvas`,Qm({style:E,height:i,width:i,ref:y,role:`img`},h)),D)});vh.displayName=`QRCodeCanvas`;var yh=B.forwardRef(function(e,t){let n=e,{value:r,size:i=rh,level:a=ih,bgColor:o=ah,fgColor:s=oh,includeMargin:c=sh,minVersion:l=ch,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=$m(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:g,numCells:_,calculatedImageSettings:v}=gh({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:f,imageSettings:p,size:i}),y=g,b=null;p!=null&&v!=null&&(v.excavation!=null&&(y=ph(g,v.excavation)),b=B.createElement(`image`,{href:p.src,height:v.h,width:v.w,x:v.x+h,y:v.y+h,preserveAspectRatio:`none`,opacity:v.opacity,crossOrigin:v.crossOrigin}));let x=fh(y,h);return B.createElement(`svg`,Qm({height:i,width:i,viewBox:`0 0 ${_} ${_}`,ref:t,role:`img`},m),!!d&&B.createElement(`title`,null,d),B.createElement(`path`,{fill:o,d:`M0,0 h${_}v${_}H0z`,shapeRendering:`crispEdges`}),B.createElement(`path`,{fill:s,d:x,shapeRendering:`crispEdges`}),b)});yh.displayName=`QRCodeSVG`;function bh({onClose:e}){let[t,n]=(0,B.useState)(null),[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)(!0),[s,c]=(0,B.useState)(!1),[l,u]=(0,B.useState)(!1),[d,f]=(0,B.useState)(!1),[p,m]=(0,B.useState)(null),[g,_]=(0,B.useState)(null),[v,y]=(0,B.useState)(null),[b,x]=(0,B.useState)(!1);(0,B.useEffect)(()=>{(async()=>{try{let[e,t]=await Promise.all([z.get(`/api/cloud/status`),z.get(`/api/tunnel`)]);n(e),i(t)}catch{}o(!1)})()},[]);let S=(0,B.useCallback)(e=>{navigator.clipboard.writeText(e),_(e),setTimeout(()=>_(null),2e3)},[]),C=(0,B.useCallback)(async()=>{c(!0),m(null);try{i({active:!0,url:(await z.post(`/api/tunnel/start`,{})).url,localUrl:r?.localUrl??null}),n(await z.get(`/api/cloud/status`))}catch(e){m(e instanceof Error?e.message:`Failed to start tunnel`)}finally{c(!1)}},[r]),w=(0,B.useCallback)(async()=>{m(null);try{let{cloud_url:e}=await z.get(`/api/cloud/login-url`),t=await fetch(`${e}/auth/device-code`,{method:`POST`,headers:{"Content-Type":`application/json`}});if(!t.ok)throw Error(`Failed to get device code`);let r=await t.json();y({userCode:r.user_code,verifyUrl:r.verification_uri}),x(!0);let i=(r.interval||5)*1e3,a=Date.now()+r.expires_in*1e3,o=setInterval(async()=>{if(Date.now()>a){clearInterval(o),x(!1),y(null),m(`Login expired. Try again.`);return}try{let t=await fetch(`${e}/auth/device-code/poll`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({device_code:r.device_code})});if(!t.ok)return;let i=await t.json();i.status===`approved`&&i.access_token&&i.email&&(clearInterval(o),x(!1),y(null),await z.post(`/api/cloud/login`,{access_token:i.access_token,email:i.email,cloud_url:e}),n(await z.get(`/api/cloud/status`)))}catch{}},i)}catch(e){m(e instanceof Error?e.message:`Failed to start login`),x(!1),y(null)}},[]),T=(0,B.useCallback)(async()=>{u(!0),m(null);try{r?.active||i({active:!0,url:(await z.post(`/api/tunnel/start`,{})).url,localUrl:r?.localUrl??null}),await z.post(`/api/cloud/link`,{}),n(await z.get(`/api/cloud/status`))}catch(e){m(e instanceof Error?e.message:`Failed to link device`)}finally{u(!1)}},[r]),E=(0,B.useCallback)(async()=>{if(confirm(`Unlink this device from PPM Cloud? It will no longer appear on your cloud dashboard.`)){f(!0);try{await z.post(`/api/cloud/unlink`,{}),n(await z.get(`/api/cloud/status`))}catch{}f(!1)}},[]),D=(0,B.useCallback)(async()=>{let e=t?.linked?`Sign out from PPM Cloud? This will also unlink your device.`:`Sign out from PPM Cloud?`;if(confirm(e)){if(t?.linked)try{await z.post(`/api/cloud/unlink`,{})}catch{}await z.post(`/api/cloud/logout`,{}),n(e=>e?{...e,logged_in:!1,email:null,linked:!1,device_name:null,device_id:null}:null)}},[t?.linked]),O=r?.url||t?.tunnel_url;return(0,H.jsxs)(`div`,{className:`w-72 bg-background border border-border rounded-lg shadow-lg p-3 space-y-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,H.jsx)(Be,{className:`size-4 text-primary`}),(0,H.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:`PPM Cloud`})]}),(0,H.jsx)(`button`,{onClick:e,className:`text-text-subtle hover:text-foreground`,children:(0,H.jsx)(Gt,{className:`size-3.5`})})]}),a&&(0,H.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground text-xs py-2`,children:[(0,H.jsx)(pt,{className:`size-4 animate-spin`}),(0,H.jsx)(`span`,{children:`Loading...`})]}),!a&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`space-y-1.5`,children:t?.logged_in?(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,H.jsx)(`div`,{className:`size-2 rounded-full bg-green-500 shrink-0`}),(0,H.jsx)(`span`,{className:`text-xs text-foreground truncate`,children:t.email})]}),(0,H.jsx)(`button`,{onClick:D,className:`text-text-subtle hover:text-foreground p-1 rounded hover:bg-muted transition-colors shrink-0`,title:`Sign out`,children:(0,H.jsx)(ht,{className:`size-3`})})]}):v?(0,H.jsxs)(`div`,{className:`space-y-2 text-center`,children:[(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Open the link below and enter the code:`}),(0,H.jsx)(`div`,{className:`font-mono text-2xl font-bold tracking-[0.3em] text-primary`,children:v.userCode}),(0,H.jsx)(`a`,{href:v.verifyUrl,target:`_blank`,rel:`noopener noreferrer`,className:`text-xs text-primary hover:underline`,children:v.verifyUrl}),b&&(0,H.jsxs)(`div`,{className:`flex items-center justify-center gap-1.5 text-xs text-muted-foreground`,children:[(0,H.jsx)(pt,{className:`size-3 animate-spin`}),(0,H.jsx)(`span`,{children:`Waiting for verification...`})]})]}):(0,H.jsxs)(`button`,{onClick:w,className:`w-full flex items-center justify-center gap-1.5 px-3 py-2 text-xs font-medium rounded-md border border-border hover:bg-muted transition-colors`,children:[(0,H.jsx)(Be,{className:`size-3.5`}),`Sign in to PPM Cloud`]})}),t?.logged_in&&(0,H.jsx)(`div`,{className:`space-y-1.5`,children:t.linked?(0,H.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,H.jsx)(dt,{className:`size-3 text-primary shrink-0`}),(0,H.jsx)(`span`,{className:`text-foreground truncate`,children:t.device_name})]}),(0,H.jsx)(`button`,{onClick:E,disabled:d,className:`text-text-subtle hover:text-destructive p-1 rounded hover:bg-muted transition-colors shrink-0`,title:`Unlink device`,children:d?(0,H.jsx)(pt,{className:`size-3 animate-spin`}):(0,H.jsx)(Ht,{className:`size-3`})})]}):(0,H.jsx)(`button`,{onClick:T,disabled:l,className:`w-full flex items-center justify-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50`,children:l?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(pt,{className:`size-3.5 animate-spin`}),` Linking...`]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(dt,{className:`size-3.5`}),` Link this machine`]})})}),(0,H.jsx)(`div`,{className:`border-t border-border`}),r?.localUrl&&(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wide`,children:`Local Network`}),(0,H.jsx)(xh,{url:r.localUrl,copied:g,onCopy:S})]}),!O&&!s&&(0,H.jsxs)(`button`,{onClick:C,className:`w-full flex items-center justify-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 transition-colors`,children:[(0,H.jsx)(Ft,{className:`size-3.5`}),`Start Sharing`]}),s&&(0,H.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-2`,children:[(0,H.jsx)(pt,{className:`size-5 animate-spin text-primary`}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Starting tunnel...`})]}),O&&(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wide`,children:`Public URL`}),(0,H.jsx)(`div`,{className:`flex justify-center`,children:(0,H.jsx)(`div`,{className:`p-3 rounded-lg`,style:{backgroundColor:`#ffffff`,colorScheme:`light`},children:(0,H.jsx)(yh,{value:O,size:180,bgColor:`#ffffff`,fgColor:`#000000`,level:`L`,style:{display:`block`}})})}),(0,H.jsx)(xh,{url:O,copied:g,onCopy:S})]}),t?.logged_in&&t.linked&&(0,H.jsxs)(`a`,{href:t.cloud_url+`/dashboard`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center justify-center gap-1.5 w-full px-3 py-1.5 text-xs text-muted-foreground hover:text-foreground rounded-md border border-border hover:bg-muted transition-colors`,children:[(0,H.jsx)(h,{className:`size-3`}),`Open Cloud Dashboard`]}),p&&(0,H.jsx)(`p`,{className:`text-xs text-destructive`,children:p})]})]})}function xh({url:e,copied:t,onCopy:n}){return(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`input`,{readOnly:!0,value:e,className:`flex-1 text-xs font-mono text-foreground bg-muted px-2 py-1.5 rounded border border-border truncate`,onClick:e=>e.target.select()}),(0,H.jsx)(`button`,{onClick:()=>n(e),className:`flex items-center justify-center size-7 rounded border border-border text-muted-foreground bg-muted hover:bg-accent hover:text-foreground transition-colors shrink-0`,title:`Copy URL`,children:t===e?(0,H.jsx)(o,{className:`size-3.5 text-primary`}):(0,H.jsx)(Ve,{className:`size-3.5`})})]})}var Sh=`hienlh/ppm`;async function Ch(e,t){let n=`(could not fetch)`;try{let e=await(await fetch(`/api/logs/recent`)).json();e.ok&&(n=e.data.logs||`(empty)`)}catch{}let r=``;if(t?.sessionId&&t?.projectName)try{let e=await z.get(`${fe(t.projectName)}/chat/sessions/${t.sessionId}/logs?tail=100`);e.logs&&(r=e.logs)}catch{}return[`## Environment`,`- PPM: v${e??`unknown`}`,`- Browser: ${navigator.userAgent}`,``,`## Description`,`<!-- Describe the bug -->`,``,`## Steps to Reproduce`,`1. `,``,`## Expected Behavior`,``,...r?[`## Chat Session Logs (${t?.sessionId?.slice(0,8)})`,"```",r,"```",``]:[],`## Server Logs (last 30 lines)`,"```",n,"```"].join(`
30
- `)}function wh(e){let t=`https://github.com/${Sh}/issues/new?title=bug%3A%20&body=${encodeURIComponent(e)}`;window.open(t,`_blank`)}async function Th(e){try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}function Eh(e,t){Ch(e,t).then(e=>{window.dispatchEvent(new CustomEvent(`open-bug-report`,{detail:e}))})}var Dh=[`linear-gradient(135deg, #667eea, #764ba2)`,`linear-gradient(135deg, #f5576c, #f093fb)`,`linear-gradient(135deg, #4facfe, #00c6ff)`,`linear-gradient(135deg, #43e97b, #38f9d7)`,`linear-gradient(135deg, #fa709a, #fee140)`,`linear-gradient(135deg, #a18cd1, #6a3de8)`,`linear-gradient(135deg, #fd7043, #ff8a65)`,`linear-gradient(135deg, #26c6da, #0097a7)`,`linear-gradient(135deg, #ab47bc, #7b1fa2)`,`linear-gradient(135deg, #ef5350, #b71c1c)`,`linear-gradient(135deg, #1976d2, #42a5f5)`,`linear-gradient(135deg, #2e7d32, #66bb6a)`];function Oh(e,t){return e??Dh[t%Dh.length]}function kh(e,t){let n=e.split(/[-_.\s]+/).filter(Boolean),r=(n[0]?.[0]??e[0]??`?`).toUpperCase(),i=n.length>1?r+(n[1][0]??``).toUpperCase():r,a=t.filter(t=>t!==e);if(!a.map(e=>(e.split(/[-_.\s]+/).filter(Boolean)[0]?.[0]??e[0]??``).toUpperCase()).includes(r))return r;if(!a.map(e=>{let t=e.split(/[-_.\s]+/).filter(Boolean),n=(t[0]?.[0]??e[0]??``).toUpperCase(),r=t.length>1?(t[1][0]??``).toUpperCase():n;return t.length>1?n+r:n}).includes(i))return i;let o=t.indexOf(e);return String(o>=0?o+1:`?`)}function Ah({onSuccess:e,onCancel:t,footerClassName:n}){let{addProject:r}=bf(),[i,a]=(0,B.useState)(``),[o,s]=(0,B.useState)(``),[c,l]=(0,B.useState)([]),[u,d]=(0,B.useState)(!1),[f,p]=(0,B.useState)(!1),[m,h]=(0,B.useState)(!1),[g,_]=(0,B.useState)(``),v=(0,B.useRef)(null),y=(0,B.useRef)(null);(0,B.useEffect)(()=>{if(v.current&&clearTimeout(v.current),!i.trim()){l([]),d(!1);return}v.current=setTimeout(async()=>{p(!0);try{l(await z.get(`/api/projects/suggest-dirs?q=${encodeURIComponent(i)}`)??[]),d(!0)}catch{l([])}finally{p(!1)}},250)},[i]),(0,B.useEffect)(()=>{function e(e){y.current&&!y.current.contains(e.target)&&d(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);function b(e){a(e.path),o||s(e.name),d(!1)}async function x(t){if(t?.preventDefault(),!i.trim()){_(`Path is required`);return}_(``),h(!0);try{await r(i.trim(),o.trim()||void 0),e()}catch(e){_(e instanceof Error?e.message:`Failed to add project`)}finally{h(!1)}}return(0,H.jsxs)(`form`,{onSubmit:x,className:`flex flex-col gap-3`,children:[(0,H.jsxs)(`div`,{ref:y,className:`relative`,children:[(0,H.jsx)(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Project path`}),(0,H.jsxs)(`div`,{className:`flex gap-1.5 items-center`,children:[(0,H.jsxs)(`div`,{className:`relative flex items-center flex-1`,children:[(0,H.jsx)($e,{className:`absolute left-2.5 size-3.5 text-text-subtle pointer-events-none`}),(0,H.jsx)(`input`,{type:`text`,value:i,onChange:e=>{a(e.target.value),_(``)},onFocus:()=>c.length>0&&d(!0),placeholder:`/path/to/project`,className:`w-full pl-8 pr-3 py-2 rounded-md border border-border bg-background text-sm focus:outline-none focus:ring-1 focus:ring-primary`,autoFocus:!0,autoComplete:`off`}),f&&(0,H.jsx)(pt,{className:`absolute right-2.5 size-3.5 text-text-subtle animate-spin`})]}),(0,H.jsx)(Nm,{mode:`folder`,onSelect:e=>{a(e),o||s(e.split(`/`).pop()??``),_(``)}})]}),u&&c.length>0&&(0,H.jsx)(`div`,{className:`absolute top-full left-0 right-0 mt-1 z-10 bg-popover border border-border rounded-md shadow-md max-h-48 overflow-y-auto`,children:c.map(e=>(0,H.jsxs)(`button`,{type:`button`,onMouseDown:()=>b(e),className:`w-full flex flex-col items-start px-3 py-2 text-left hover:bg-accent/50 transition-colors`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium truncate w-full`,children:e.name}),(0,H.jsx)(`span`,{className:`text-xs text-text-subtle truncate w-full`,children:e.path})]},e.path))})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:[`Display name `,(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:`(optional)`})]}),(0,H.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),placeholder:`my-project`,className:`w-full px-3 py-2 rounded-md border border-border bg-background text-sm focus:outline-none focus:ring-1 focus:ring-primary`})]}),g&&(0,H.jsx)(`p`,{className:`text-xs text-destructive`,children:g}),(0,H.jsxs)(`div`,{className:R(`flex justify-end gap-2 pt-1`,n),children:[(0,H.jsx)(`button`,{type:`button`,onClick:t,className:`px-3 py-1.5 text-sm text-text-secondary hover:text-foreground transition-colors`,children:`Cancel`}),(0,H.jsx)(`button`,{type:`submit`,disabled:m||!i.trim(),className:`px-3 py-1.5 text-sm bg-primary text-white rounded-md hover:bg-primary/90 transition-colors disabled:opacity-50`,children:m?`Adding…`:`Add Project`})]})]})}function jh({name:e,color:t,active:n,allNames:r}){let i=kh(e,r),a=Vf((0,B.useMemo)(()=>Uf(e),[e]));return(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(`div`,{className:R(`size-10 rounded-full flex items-center justify-center text-xs font-bold text-white select-none shrink-0`,n&&`ring-2 ring-primary ring-offset-2 ring-offset-background`),style:{background:t},children:i}),a&&(0,H.jsx)(`div`,{className:R(`absolute -top-0.5 -right-0.5 size-2.5 rounded-full border-2 border-background`,Bf(a))})]})}function Mh({current:e,onChange:t}){return(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Dh.map(n=>(0,H.jsx)(`button`,{type:`button`,onClick:()=>t(n),className:R(`size-8 rounded-full border-2 transition-all`,e===n?`border-primary scale-110`:`border-transparent hover:scale-105`),style:{background:n}},n))})}function Nh(){let{projects:e,activeProject:t,setActiveProject:n,setProjectColor:r,reorderProjects:i,renameProject:a,deleteProject:o,customOrder:s}=bf();_(e=>e.openTab);let c=V(e=>e.version),l=(0,B.useCallback)(()=>Eh(c),[c]),[u,d]=(0,B.useState)(null),[f,p]=(0,B.useState)(null),m=yf(e,s),h=m.map(e=>e.name),[g,v]=(0,B.useState)(!1),[y,b]=(0,B.useState)(``),[x,S]=(0,B.useState)(``),[C,w]=(0,B.useState)(!1),[T,E]=(0,B.useState)(``),[D,O]=(0,B.useState)(!1),[ee,k]=(0,B.useState)(!1),[A,j]=(0,B.useState)(``),[te,M]=(0,B.useState)(``),[N,P]=(0,B.useState)(!1),ne=(0,B.useCallback)(e=>{b(e),S(e),v(!0)},[]),re=(0,B.useCallback)(e=>{E(e),w(!0)},[]),F=(0,B.useCallback)((e,t)=>{j(e),M(t),k(!0)},[]);async function ie(){if(!x.trim()||x===y){v(!1);return}try{await a(y,x.trim())}catch{}v(!1)}async function ae(){try{await o(T)}catch{}w(!1)}async function I(){P(!0);try{await r(A,te),k(!1)}catch(e){console.error(`Failed to save color:`,e)}finally{P(!1)}}function oe(){O(!0)}let[se,ce]=(0,B.useState)(!1),le=(0,B.useRef)(null),[L,ue]=(0,B.useState)(null);(0,B.useEffect)(()=>{if(!se||!le.current){ue(null);return}let e=le.current.getBoundingClientRect();ue({left:e.right+6,bottom:window.innerHeight-e.bottom})},[se]);function de(){let{sidebarCollapsed:e,toggleSidebar:t,setSidebarActiveTab:n}=V.getState();e&&t(),n(`settings`)}return(0,H.jsxs)(`aside`,{className:`hidden md:flex flex-col w-[52px] min-w-[52px] bg-background border-r border-border overflow-hidden`,children:[(0,H.jsxs)(`div`,{className:`shrink-0 flex flex-col items-center justify-center h-[41px] border-b border-border gap-0.5`,children:[(0,H.jsx)(`span`,{className:`text-[11px] font-bold text-primary leading-none`,children:`PPM`}),c&&(0,H.jsxs)(`span`,{className:`text-[8px] text-text-subtle leading-none`,children:[`v`,c]})]}),(0,H.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 flex flex-col items-center gap-2 min-h-0`,children:[m.map((e,r)=>{let a=Oh(e.color,r),o=t?.name===e.name;return(0,H.jsxs)(dp,{children:[(0,H.jsxs)(Cu,{children:[(0,H.jsx)(wu,{asChild:!0,children:(0,H.jsx)(fp,{asChild:!0,children:(0,H.jsx)(`button`,{draggable:!0,onDragStart:()=>d(r),onDragOver:e=>{e.preventDefault(),p(r)},onDragLeave:()=>p(null),onDragEnd:()=>{d(null),p(null)},onDrop:()=>{if(u!=null&&u!==r){let e=m.map(e=>e.name),[t]=e.splice(u,1);e.splice(r,0,t),i(e)}d(null),p(null)},onClick:()=>n(e),className:`p-1 rounded-lg hover:bg-surface-elevated transition-all ${u===r?`opacity-40 scale-90`:``} ${f===r&&u!==r?`ring-2 ring-accent`:``}`,children:(0,H.jsx)(jh,{name:e.name,color:a,active:o,allNames:h})})})}),(0,H.jsxs)(Tu,{side:`right`,className:`max-w-[200px]`,children:[(0,H.jsx)(`p`,{className:`font-medium`,children:e.name}),(0,H.jsx)(`p`,{className:`text-xs text-text-subtle truncate`,children:e.path})]})]}),(0,H.jsxs)(pp,{children:[(0,H.jsxs)(mp,{onClick:()=>ne(e.name),children:[(0,H.jsx)(Dt,{className:`size-3.5 mr-2`}),` Rename`]}),(0,H.jsxs)(mp,{onClick:()=>F(e.name,a),children:[(0,H.jsx)(wt,{className:`size-3.5 mr-2`}),` Change Color`]}),(0,H.jsx)(hp,{}),(0,H.jsxs)(mp,{className:`text-destructive focus:text-destructive`,onClick:()=>re(e.name),children:[(0,H.jsx)(zt,{className:`size-3.5 mr-2`}),` Delete`]})]})]},e.name)}),(0,H.jsxs)(Cu,{children:[(0,H.jsx)(wu,{asChild:!0,children:(0,H.jsx)(`button`,{onClick:oe,className:`size-10 rounded-full border-2 border-dashed border-border flex items-center justify-center text-text-subtle hover:border-primary hover:text-primary transition-colors`,children:(0,H.jsx)(Ot,{className:`size-4`})})}),(0,H.jsx)(Tu,{side:`right`,children:`Add Project`})]})]}),(0,H.jsxs)(`div`,{className:`shrink-0 flex flex-col items-center gap-1 py-2 border-t border-border`,children:[(0,H.jsxs)(Cu,{children:[(0,H.jsx)(wu,{asChild:!0,children:(0,H.jsx)(`button`,{ref:le,onClick:()=>ce(!se),className:R(`flex items-center justify-center size-8 rounded-md transition-colors`,se?`text-primary bg-primary/10`:`text-text-subtle hover:text-foreground hover:bg-surface-elevated`),children:(0,H.jsx)(Be,{className:`size-4`})})}),(0,H.jsx)(Tu,{side:`right`,children:`Cloud & Share`})]}),se&&L&&(0,Yt.createPortal)((0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>ce(!1)}),(0,H.jsx)(`div`,{className:`fixed z-50`,style:{left:L.left,bottom:L.bottom},children:(0,H.jsx)(bh,{onClose:()=>ce(!1)})})]}),document.body),(0,H.jsxs)(Cu,{children:[(0,H.jsx)(wu,{asChild:!0,children:(0,H.jsx)(`button`,{onClick:l,className:`flex items-center justify-center size-8 rounded-md text-text-subtle hover:text-foreground hover:bg-surface-elevated transition-colors`,children:(0,H.jsx)(Ae,{className:`size-4`})})}),(0,H.jsx)(Tu,{side:`right`,children:`Report Bug`})]}),(0,H.jsxs)(Cu,{children:[(0,H.jsx)(wu,{asChild:!0,children:(0,H.jsx)(`button`,{onClick:de,className:`flex items-center justify-center size-8 rounded-md text-text-subtle hover:text-foreground hover:bg-surface-elevated transition-colors`,children:(0,H.jsx)(Pt,{className:`size-4`})})}),(0,H.jsx)(Tu,{side:`right`,children:`Settings`})]})]}),(0,H.jsx)(gp,{open:D,onOpenChange:O,children:(0,H.jsxs)(yp,{className:`sm:max-w-sm`,children:[(0,H.jsx)(bp,{children:(0,H.jsx)(Sp,{children:`Add Project`})}),(0,H.jsx)(Ah,{onSuccess:()=>O(!1),onCancel:()=>O(!1)})]})}),(0,H.jsx)(gp,{open:g,onOpenChange:v,children:(0,H.jsxs)(yp,{className:`sm:max-w-sm`,children:[(0,H.jsx)(bp,{children:(0,H.jsx)(Sp,{children:`Rename Project`})}),(0,H.jsx)(`input`,{type:`text`,value:x,onChange:e=>S(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ie()},className:`w-full px-3 py-2 rounded-md border border-border bg-background text-sm focus:outline-none focus:ring-1 focus:ring-primary`,autoFocus:!0}),(0,H.jsxs)(xp,{children:[(0,H.jsx)(`button`,{onClick:()=>v(!1),className:`px-3 py-1.5 text-sm text-text-secondary hover:text-foreground transition-colors`,children:`Cancel`}),(0,H.jsx)(`button`,{onClick:ie,className:`px-3 py-1.5 text-sm bg-primary text-white rounded-md hover:bg-primary/90 transition-colors`,children:`Rename`})]})]})}),(0,H.jsx)(gp,{open:C,onOpenChange:w,children:(0,H.jsxs)(yp,{className:`sm:max-w-sm`,children:[(0,H.jsx)(bp,{children:(0,H.jsx)(Sp,{children:`Delete Project`})}),(0,H.jsxs)(`p`,{className:`text-sm text-text-secondary`,children:[`Remove `,(0,H.jsx)(`strong`,{className:`text-foreground`,children:T}),` from PPM? The files on disk won't be deleted.`]}),(0,H.jsxs)(xp,{children:[(0,H.jsx)(`button`,{onClick:()=>w(!1),className:`px-3 py-1.5 text-sm text-text-secondary hover:text-foreground transition-colors`,children:`Cancel`}),(0,H.jsx)(`button`,{onClick:ae,className:`px-3 py-1.5 text-sm bg-destructive text-white rounded-md hover:bg-destructive/90 transition-colors`,children:`Delete`})]})]})}),(0,H.jsx)(gp,{open:ee,onOpenChange:k,children:(0,H.jsxs)(yp,{className:`sm:max-w-sm`,children:[(0,H.jsx)(bp,{children:(0,H.jsx)(Sp,{children:`Change Color`})}),(0,H.jsx)(Mh,{current:te,onChange:M}),(0,H.jsxs)(xp,{children:[(0,H.jsx)(`button`,{onClick:()=>k(!1),className:`px-3 py-1.5 text-sm text-text-secondary hover:text-foreground transition-colors`,children:`Cancel`}),(0,H.jsx)(`button`,{onClick:I,disabled:N,className:`px-3 py-1.5 text-sm bg-primary text-white rounded-md hover:bg-primary/90 transition-colors disabled:opacity-50`,children:N?`Saving…`:`Save`})]})]})})]})}var Ph=[{type:`terminal`,label:`Terminal`},{type:`chat`,label:`AI Chat`},{type:`git-graph`,label:`Git Graph`},{type:`settings`,label:`Settings`}],Fh=Object.fromEntries(Ph.map(e=>[e.type,e.label])),Ih={terminal:Rt,chat:_t,editor:Je,database:He,sqlite:He,postgres:He,"git-graph":nt,"git-diff":Ye,settings:Pt,browser:it};function Lh({onMenuPress:e,onProjectsPress:t}){let n=m(e=>e.focusedPanelId),r=m(e=>e.panels[e.focusedPanelId]);m(e=>Object.keys(e.panels).length);let i=m(e=>e.grid),a=r?.tabs??[],o=r?.activeTabId??null,s=(0,B.useRef)(new Map),c=(0,B.useRef)(null),l=(0,B.useRef)(a.length),u=Vf(e=>e.notifications),{canScrollLeft:f,canScrollRight:h,scrollLeft:g,scrollRight:_}=Wf(c),v=Kf(c.current,s.current,a,u),[y,b]=(0,B.useState)(null),[x,S]=(0,B.useState)(!1),C=(0,B.useRef)(null);(0,B.useEffect)(()=>{a.length>l.current&&o&&s.current.get(o)?.scrollIntoView({behavior:`smooth`,block:`nearest`,inline:`nearest`}),l.current=a.length},[a.length,o]);let w=(0,B.useCallback)(e=>{C.current=setTimeout(()=>b(e),400)},[]),T=(0,B.useCallback)(()=>{C.current&&=(clearTimeout(C.current),null)},[]),E=p(i,n)?i.length<3:!1,D=Object.keys(m.getState().panels).filter(e=>e!==n);function O(e){let t=a.findIndex(t=>t.id===e);t>0&&m.getState().reorderTab(e,n,t-1)}function ee(e){let t=a.findIndex(t=>t.id===e);t<a.length-1&&m.getState().reorderTab(e,n,t+1)}function k(e){m.getState().splitPanel(`down`,e,n)}function A(e,t){m.getState().moveTab(e,n,t)}let j=y?a.find(e=>e.id===y):null,te=y?a.findIndex(e=>e.id===y):-1,{activeProject:M}=bf.getState();function N(e){let t=e===`git-graph`||e===`git-diff`||e===`terminal`||e===`chat`?{projectName:M?.name}:void 0;m.getState().openTab({type:e,title:Fh[e]??e,metadata:t,projectId:M?.name??null,closable:!0},n),S(!1)}let{activeProject:P,projects:ne,customOrder:re}=bf(),F=yf(ne,re??null),ie=F.map(e=>e.name),ae=F.findIndex(e=>e.name===P?.name),I=P?Oh(P.color,ae>=0?ae:0):`#4f86c6`,oe=P?kh(P.name,ie):null;return(0,H.jsxs)(`nav`,{className:`fixed bottom-0 left-0 right-0 md:hidden bg-background border-t border-border z-40 select-none`,children:[(0,H.jsxs)(`div`,{className:`flex items-center h-12`,children:[(0,H.jsx)(`button`,{onClick:e,className:`flex items-center justify-center size-12 shrink-0 text-text-secondary border-r border-border`,children:(0,H.jsx)(gt,{className:`size-5`})}),(0,H.jsxs)(`div`,{className:`flex-1 min-w-0 relative flex items-center h-12`,children:[f&&(0,H.jsx)(`button`,{onClick:g,className:`absolute left-0 z-10 flex items-center justify-center size-8 bg-gradient-to-r from-background via-background to-transparent`,children:(0,H.jsxs)(`span`,{className:`relative`,children:[(0,H.jsx)(Me,{className:`size-3.5 text-text-secondary`}),v.left&&(0,H.jsx)(`span`,{className:R(`absolute -top-1 -right-0.5 size-1.5 rounded-full`,Bf(v.left))})]})}),(0,H.jsx)(`div`,{ref:c,className:`flex-1 min-w-0 flex items-center h-12 overflow-x-auto scrollbar-none`,children:a.map(e=>{let t=Ih[e.type],n=e.id===o,r=e.type===`chat`?e.metadata?.sessionId:void 0,i=r?u.get(r):void 0,a=i&&i.count>0?i.type:null;return(0,H.jsxs)(`button`,{ref:t=>{t?s.current.set(e.id,t):s.current.delete(e.id)},onClick:()=>{m.getState().setActiveTab(e.id),r&&Vf.getState().clearForSession(r)},onTouchStart:()=>w(e.id),onTouchEnd:T,onTouchMove:T,onContextMenu:e=>e.preventDefault(),className:R(`flex items-center gap-1 px-3 h-12 whitespace-nowrap text-xs shrink-0 border-t-2 transition-colors`,n?`border-primary bg-surface text-primary`:`border-transparent text-text-secondary`),children:[(0,H.jsxs)(`span`,{className:`relative`,children:[(0,H.jsx)(t,{className:`size-4`}),a&&!n&&(0,H.jsx)(`span`,{className:R(`absolute -top-1 -right-1 size-2 rounded-full`,Bf(a))})]}),(0,H.jsx)(`span`,{className:`max-w-[80px] truncate`,children:e.title}),e.closable&&(0,H.jsx)(`span`,{role:`button`,tabIndex:0,onClick:t=>{t.stopPropagation(),m.getState().closeTab(e.id)},className:`ml-0.5 p-0.5 rounded hover:bg-surface-elevated`,children:(0,H.jsx)(Gt,{className:`size-3`})})]},e.id)})}),h&&(0,H.jsx)(`button`,{onClick:_,className:`absolute right-0 z-10 flex items-center justify-center size-8 bg-gradient-to-l from-background via-background to-transparent`,children:(0,H.jsxs)(`span`,{className:`relative`,children:[(0,H.jsx)(d,{className:`size-3.5 text-text-secondary`}),v.right&&(0,H.jsx)(`span`,{className:R(`absolute -top-1 -left-0.5 size-1.5 rounded-full`,Bf(v.right))})]})})]}),(0,H.jsx)(`button`,{onClick:()=>If(),className:`flex items-center justify-center size-12 shrink-0 border-t-2 border-transparent text-text-secondary`,children:(0,H.jsx)(Ot,{className:`size-4`})}),(0,H.jsx)(`button`,{onClick:t,className:`flex items-center justify-center size-12 shrink-0 text-text-secondary border-l border-border`,title:`Switch project`,children:oe?(0,H.jsx)(`div`,{className:`size-7 rounded-full flex items-center justify-center text-[10px] font-bold text-white`,style:{background:I},children:oe}):(0,H.jsx)(ut,{className:`size-5`})})]}),x&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`fixed inset-0 z-50`,onClick:()=>S(!1)}),(0,H.jsxs)(`div`,{className:`fixed bottom-14 left-2 right-2 z-50 bg-surface border border-border rounded-lg shadow-lg overflow-hidden animate-in slide-in-from-bottom-2 duration-150`,children:[(0,H.jsx)(`div`,{className:`px-3 py-2 text-xs text-text-secondary border-b border-border`,children:`New Tab`}),Ph.map(e=>{let t=Ih[e.type];return(0,H.jsxs)(`button`,{onClick:()=>N(e.type),className:`flex items-center gap-2 w-full px-3 py-2.5 text-sm text-foreground active:bg-surface-elevated`,children:[(0,H.jsx)(t,{className:`size-4`}),` `,e.label]},e.type)})]})]}),j&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`fixed inset-0 z-50`,onClick:()=>b(null)}),(0,H.jsxs)(`div`,{className:`fixed bottom-14 left-2 right-2 z-50 bg-surface border border-border rounded-lg shadow-lg overflow-hidden animate-in slide-in-from-bottom-2 duration-150`,children:[(0,H.jsx)(`div`,{className:`px-3 py-2 text-xs text-text-secondary border-b border-border truncate`,children:j.title}),te>0&&(0,H.jsxs)(`button`,{onClick:()=>{O(y),b(null)},className:`flex items-center gap-2 w-full px-3 py-2.5 text-sm text-foreground active:bg-surface-elevated`,children:[(0,H.jsx)(Ce,{className:`size-4`}),` Move Left`]}),te<a.length-1&&(0,H.jsxs)(`button`,{onClick:()=>{ee(y),b(null)},className:`flex items-center gap-2 w-full px-3 py-2.5 text-sm text-foreground active:bg-surface-elevated`,children:[(0,H.jsx)(we,{className:`size-4`}),` Move Right`]}),E&&a.length>1&&(0,H.jsxs)(`button`,{onClick:()=>{k(y),b(null)},className:`flex items-center gap-2 w-full px-3 py-2.5 text-sm text-foreground active:bg-surface-elevated`,children:[(0,H.jsx)(It,{className:`size-4`}),` Split to Bottom`]}),D.map((e,t)=>(0,H.jsxs)(`button`,{onClick:()=>{A(y,e),b(null)},className:`flex items-center gap-2 w-full px-3 py-2.5 text-sm text-foreground active:bg-surface-elevated`,children:[(0,H.jsx)(St,{className:`size-4`}),` Move to Panel `,t+1===1?`Top`:`Bottom`]},e))]})]})]})}var Rh=[{id:`explorer`,label:`Explorer`,icon:$e},{id:`git`,label:`Git`,icon:nt},{id:`database`,label:`Database`,icon:He},{id:`settings`,label:`Settings`,icon:Pt}];function zh({isOpen:e,onClose:t,initialTab:n}){let{activeProject:r}=bf(),i=V(e=>e.version),[a,o]=(0,B.useState)(n??`explorer`);(0,B.useEffect)(()=>{n&&o(n)},[n]);let s=(0,B.useCallback)(()=>Eh(i),[i]);return(0,H.jsxs)(`div`,{className:R(`fixed inset-0 z-50 md:hidden transition-opacity duration-200`,e?`opacity-100`:`opacity-0 pointer-events-none`),children:[(0,H.jsx)(`div`,{className:`absolute inset-0 bg-black/50`,onClick:t,"aria-label":`Close drawer`}),(0,H.jsxs)(`div`,{className:R(`fixed left-0 top-0 bottom-0 w-[90vw] bg-background border-r border-border`,`z-50 flex flex-col transition-transform duration-300 ease-out`,e?`translate-x-0`:`-translate-x-full`),children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-border shrink-0`,children:[(0,H.jsx)(`span`,{className:`text-sm font-bold text-primary tracking-tight`,children:r?.name??`PPM`}),(0,H.jsx)(`button`,{onClick:t,className:`flex items-center justify-center size-8 rounded-md hover:bg-surface-elevated transition-colors`,children:(0,H.jsx)(Gt,{className:`size-4`})})]}),(0,H.jsxs)(`div`,{className:`flex-1 overflow-y-auto min-h-0`,children:[a===`explorer`&&(r?(0,H.jsx)(Op,{onFileOpen:t}):(0,H.jsx)(`p`,{className:`px-4 py-6 text-xs text-text-secondary text-center`,children:`Select a project from the bottom nav bar`})),a===`git`&&(0,H.jsx)(zp,{metadata:{projectName:r?.name},onNavigate:t}),a===`database`&&(0,H.jsx)(zm,{}),a===`settings`&&(0,H.jsx)(vm,{})]}),(0,H.jsxs)(`div`,{className:`shrink-0 border-t border-border`,children:[(0,H.jsx)(`div`,{className:`flex items-center`,children:Rh.map(e=>{let t=e.icon;return(0,H.jsxs)(`button`,{onClick:()=>o(e.id),className:R(`flex-1 flex flex-col items-center gap-0.5 py-2.5 text-[10px] transition-colors`,a===e.id?`text-primary`:`text-text-secondary`),children:[(0,H.jsx)(t,{className:`size-4`}),(0,H.jsx)(`span`,{children:e.label})]},e.id)})}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-t border-border`,children:[i&&(0,H.jsxs)(`span`,{className:`text-[10px] text-text-subtle`,children:[`v`,i]}),(0,H.jsxs)(`button`,{onClick:s,className:`flex items-center gap-1 text-[10px] text-text-subtle hover:text-text-secondary transition-colors`,children:[(0,H.jsx)(Ae,{className:`size-3`}),(0,H.jsx)(`span`,{children:`Report Bug`})]})]})]})]})]})}function Bh({name:e,color:t,allNames:n}){let r=kh(e,n);return(0,H.jsx)(`div`,{className:`size-10 rounded-full flex items-center justify-center text-xs font-bold text-white shrink-0`,style:{background:t},children:r})}function Vh({isOpen:e,onClose:t}){let{projects:n,activeProject:r,setActiveProject:i,setProjectColor:a,reorderProjects:c,renameProject:l,deleteProject:u,customOrder:d}=bf();_(e=>e.openTab);let f=V(e=>e.version),p=yf(n,d),m=p.map(e=>e.name),[h,g]=(0,B.useState)(`list`),[v,y]=(0,B.useState)(null),[b,x]=(0,B.useState)(``),[S,C]=(0,B.useState)(!1),w=(0,B.useRef)(null),[T,E]=(0,B.useState)(null),[D,O]=(0,B.useState)(``),ee=(0,B.useCallback)(e=>{w.current=setTimeout(()=>y(e),400)},[]),k=(0,B.useCallback)(()=>{w.current&&=(clearTimeout(w.current),null)},[]);function A(){g(`list`),t()}function j(e){let t=n.find(t=>t.name===e);t&&(i(t),A())}function te(){g(`add`)}function M(){if(A(),window.innerWidth<768){window.dispatchEvent(new Event(`open-mobile-settings`));return}let{sidebarCollapsed:e,toggleSidebar:t,setSidebarActiveTab:n}=V.getState();e&&t(),n(`settings`)}async function N(){if(!T||!D.trim()||D===T){E(null);return}try{await l(T,D.trim())}catch{}E(null)}async function P(e){y(null);try{await u(e)}catch{}}async function ne(e,t){try{await a(e,t),C(!1),y(null)}catch(e){console.error(`Failed to save color:`,e)}}v&&p.find(e=>e.name===v);let re=v?p.findIndex(e=>e.name===v):-1,F=v?[{label:`Rename`,icon:Dt,onClick:()=>{O(v),E(v),y(null)}},{label:`Change Color`,icon:wt,onClick:()=>{let e=p.findIndex(e=>e.name===v),t=p[e];x(Oh(t?.color,e)),C(!0)}},...re>0?[{label:`Move Up`,icon:Ne,onClick:()=>{let e=p.map(e=>e.name),[t]=e.splice(re,1);e.splice(re-1,0,t),c(e),y(null)}}]:[],...re<p.length-1?[{label:`Move Down`,icon:s,onClick:()=>{let e=p.map(e=>e.name),[t]=e.splice(re,1);e.splice(re+1,0,t),c(e),y(null)}}]:[],{label:`Delete`,icon:zt,destructive:!0,onClick:()=>P(v)}]:[];return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:R(`fixed inset-0 z-50 md:hidden transition-opacity duration-200`,e?`opacity-100`:`opacity-0 pointer-events-none`),onClick:A,style:{backgroundColor:`rgba(0,0,0,0.5)`}}),(0,H.jsxs)(`div`,{className:R(`fixed bottom-0 left-0 right-0 z-50 md:hidden bg-background rounded-t-2xl border-t border-border shadow-2xl`,`transition-transform duration-300 ease-out`,e?`translate-y-0`:`translate-y-full`),children:[(0,H.jsx)(`div`,{className:`flex justify-center pt-3 pb-1`,children:(0,H.jsx)(`div`,{className:`w-10 h-1 rounded-full bg-border`})}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b border-border`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[h===`add`&&(0,H.jsx)(`button`,{onClick:()=>g(`list`),className:`flex items-center justify-center size-7 rounded-md hover:bg-surface-elevated transition-colors`,children:(0,H.jsx)(Ce,{className:`size-4`})}),(0,H.jsx)(`span`,{className:`text-sm font-semibold`,children:h===`add`?`Add Project`:`Projects`})]}),(0,H.jsx)(`button`,{onClick:A,className:`flex items-center justify-center size-7 rounded-md hover:bg-surface-elevated transition-colors`,children:(0,H.jsx)(Gt,{className:`size-4`})})]}),h===`add`&&(0,H.jsx)(`div`,{className:`px-4 py-4`,children:(0,H.jsx)(Ah,{onSuccess:()=>{g(`list`),t()},onCancel:()=>g(`list`),footerClassName:`pt-2`})}),(0,H.jsx)(`div`,{className:h===`add`?`hidden`:`max-h-[60vh] overflow-y-auto`,children:p.map((e,t)=>{let n=Oh(e.color,t),i=r?.name===e.name,a=T===e.name;return(0,H.jsxs)(`div`,{className:R(`flex items-center gap-3 px-4 py-3 transition-colors active:bg-surface-elevated`,i&&`bg-accent/10`),onClick:()=>!a&&j(e.name),onTouchStart:()=>ee(e.name),onTouchEnd:k,onTouchMove:k,children:[(0,H.jsx)(Bh,{name:e.name,color:n,allNames:m}),(0,H.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[a?(0,H.jsx)(`input`,{type:`text`,value:D,onChange:e=>O(e.target.value),onKeyDown:e=>{e.key===`Enter`&&N(),e.key===`Escape`&&E(null)},onBlur:N,onClick:e=>e.stopPropagation(),className:`w-full bg-transparent border-b border-primary text-sm outline-none`,autoFocus:!0}):(0,H.jsx)(`p`,{className:`text-sm font-medium truncate`,children:e.name}),(0,H.jsx)(`p`,{className:`text-xs text-text-subtle truncate`,children:e.path})]}),i&&(0,H.jsx)(o,{className:`size-4 text-primary shrink-0`})]},e.name)})}),(0,H.jsx)(`div`,{className:`border-t border-border`,children:(0,H.jsxs)(`button`,{onClick:te,className:`w-full flex items-center gap-3 px-4 py-3 text-text-secondary hover:bg-surface-elevated transition-colors`,children:[(0,H.jsx)(Ot,{className:`size-4 shrink-0`}),(0,H.jsx)(`span`,{className:`text-sm`,children:`Add Project`})]})}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-t border-border`,children:[(0,H.jsxs)(`button`,{onClick:M,className:`flex items-center gap-2 text-text-secondary hover:text-foreground transition-colors`,children:[(0,H.jsx)(Pt,{className:`size-4`}),(0,H.jsx)(`span`,{className:`text-sm`,children:`Settings`})]}),f&&(0,H.jsxs)(`span`,{className:`text-xs text-text-subtle`,children:[`v`,f]})]})]}),v&&!S&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`fixed inset-0 z-[60] md:hidden`,onClick:()=>y(null)}),(0,H.jsxs)(`div`,{className:`fixed bottom-0 left-0 right-0 z-[61] md:hidden bg-surface border-t border-border rounded-t-2xl shadow-2xl animate-in slide-in-from-bottom-2 duration-150`,children:[(0,H.jsx)(`div`,{className:`px-4 py-2 border-b border-border`,children:(0,H.jsx)(`p`,{className:`text-xs font-medium text-text-secondary`,children:v})}),F.map(e=>{let t=e.icon;return(0,H.jsxs)(`button`,{onClick:e.onClick,className:R(`w-full flex items-center gap-3 px-4 py-3 text-sm transition-colors active:bg-surface-elevated`,e.destructive?`text-destructive`:`text-foreground`),children:[(0,H.jsx)(t,{className:`size-4 shrink-0`}),e.label]},e.label)})]})]}),S&&v&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`fixed inset-0 z-[60] md:hidden`,onClick:()=>{C(!1),y(null)}}),(0,H.jsxs)(`div`,{className:`fixed bottom-0 left-0 right-0 z-[61] md:hidden bg-surface border-t border-border rounded-t-2xl shadow-2xl p-4 space-y-4`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium`,children:`Change Color`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:Dh.map(e=>(0,H.jsx)(`button`,{type:`button`,onClick:()=>x(e),className:R(`size-9 rounded-full border-2 transition-all`,b===e?`border-primary scale-110`:`border-transparent`),style:{background:e}},e))}),(0,H.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,H.jsx)(`button`,{onClick:()=>{C(!1),y(null)},className:`flex-1 py-2 text-sm text-text-secondary border border-border rounded-md`,children:`Cancel`}),(0,H.jsx)(`button`,{onClick:()=>ne(v,b),className:`flex-1 py-2 text-sm bg-primary text-white rounded-md`,children:`Save`})]})]})]})]})}function Hh({onSuccess:e}){let[t,n]=(0,B.useState)(``),r=V(e=>e.deviceName),[i,a]=(0,B.useState)(null),[o,s]=(0,B.useState)(!1);async function l(n){if(n.preventDefault(),t.trim()){s(!0),a(null);try{de(t.trim());let n=await(await fetch(`/api/auth/check`,{headers:{Authorization:`Bearer ${t.trim()}`}})).json();if(!n.ok)throw Error(n.error??`Invalid token`);e()}catch(e){a(e instanceof Error?e.message:`Authentication failed`),localStorage.removeItem(`ppm-auth-token`)}finally{s(!1)}}}return(0,H.jsx)(`div`,{className:`min-h-dvh flex items-center justify-center bg-background p-4`,children:(0,H.jsxs)(`div`,{className:`w-full max-w-sm bg-surface rounded-lg border border-border p-6 space-y-6`,children:[(0,H.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,H.jsx)(`div`,{className:`flex items-center justify-center size-12 mx-auto rounded-full bg-surface-elevated`,children:(0,H.jsx)(mt,{className:`size-6 text-primary`})}),(0,H.jsx)(`h1`,{className:`text-xl font-semibold text-foreground`,children:`PPM`}),r&&(0,H.jsx)(`p`,{className:`text-xs text-text-subtle bg-surface-elevated inline-block px-2 py-0.5 rounded-full`,children:r}),(0,H.jsx)(`p`,{className:`text-sm text-text-secondary`,children:`Enter your access password to unlock`})]}),(0,H.jsxs)(`form`,{onSubmit:l,className:`space-y-4`,children:[(0,H.jsx)(`div`,{children:(0,H.jsx)(u,{type:`password`,placeholder:`Auth token`,value:t,onChange:e=>n(e.target.value),className:`h-11 bg-background border-border`,autoFocus:!0})}),i&&(0,H.jsxs)(`div`,{className:`flex items-center gap-2 text-error text-sm`,children:[(0,H.jsx)(Pe,{className:`size-4 shrink-0`}),(0,H.jsx)(`span`,{children:i})]}),(0,H.jsx)(c,{type:`submit`,disabled:o||!t.trim(),className:`w-full h-11`,children:o?`Checking...`:`Unlock`})]})]})})}function Uh(){let e=window.location.pathname.match(/^\/project\/([^/]+)(?:\/tab\/([^/]+))?/),t=new URLSearchParams(window.location.search).get(`openChat`);return e?{projectName:e[1]?decodeURIComponent(e[1]):null,tabId:e[2]?decodeURIComponent(e[2]):null,openChat:t}:{projectName:null,tabId:null,openChat:t}}function Wh(e,t){if(!e||e===`__global__`)return`/`;let n=`/project/${encodeURIComponent(e)}`;return t&&(n+=`/tab/${encodeURIComponent(t)}`),n}function Gh(){let e=_(e=>e.activeTabId),t=_(e=>e.currentProject),n=(0,B.useRef)(!1);(0,B.useEffect)(()=>{if(n.current){n.current=!1;return}let r=Wh(t,e);window.location.pathname!==r&&window.history.pushState(null,``,r)},[e,t]),(0,B.useEffect)(()=>{function e(){let{tabId:e}=Uh(),{tabs:t,setActiveTab:r}=_.getState();e&&t.some(t=>t.id===e)&&(n.current=!0,r(e))}return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[])}var Kh=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
28
+ -d '{"model":"claude-sonnet-4-6","max_tokens":1024,"messages":[{"role":"user","content":"Hello"}]}'`}),(0,H.jsx)(c,{variant:`ghost`,size:`sm`,className:`absolute top-1 right-1 h-5 px-1 cursor-pointer`,onClick:()=>p(`ANTHROPIC_BASE_URL=${h?e.tunnelUrl+`/proxy`:window.location.origin+`/proxy`}\nANTHROPIC_API_KEY=${e.authKey}`,`example`),children:l===`example`?`Copied!`:(0,H.jsx)(Ve,{className:`size-2.5`})})]})]}),(0,H.jsx)(`div`,{className:`flex items-center gap-3 pt-1`,children:(0,H.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`Requests served: `,(0,H.jsx)(`span`,{className:`font-mono`,children:e.requestCount})]})})]}),i&&(0,H.jsx)(`p`,{className:`text-[11px] text-text-subtle`,children:`Saving...`}),o&&(0,H.jsx)(`p`,{className:`text-[11px] text-red-500`,children:o})]})}function mm(e){let t=(e+`=`.repeat((4-e.length%4)%4)).replace(/-/g,`+`).replace(/_/g,`/`),n=atob(t);return Uint8Array.from(n,e=>e.charCodeAt(0))}function hm(){let[e,t]=(0,B.useState)(`default`),[n,r]=(0,B.useState)(!1),[i,a]=(0,B.useState)(!1),[o,s]=(0,B.useState)(null);return(0,B.useEffect)(()=>{`Notification`in window&&t(Notification.permission),r(localStorage.getItem(`ppm-push-subscribed`)===`true`)},[]),{permission:e,isSubscribed:n,loading:i,error:o,subscribe:(0,B.useCallback)(async()=>{a(!0),s(null);try{let e=await Notification.requestPermission();if(t(e),e!==`granted`){s(`Permission denied`);return}if(!navigator.serviceWorker?.controller&&!navigator.serviceWorker?.ready){s(`Service worker not available (dev mode?)`);return}let n=await Promise.race([navigator.serviceWorker.ready,new Promise((e,t)=>setTimeout(()=>t(Error(`Service worker timeout`)),5e3))]);if(!n)throw Error(`Service worker not ready`);let i={},a=pe();a&&(i.Authorization=`Bearer ${a}`);let o=await(await fetch(`/api/push/vapid-key`,{headers:i})).json();if(!o.ok)throw Error(o.error||`Failed to get VAPID key`);let c=await n.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:mm(o.data.publicKey).buffer});await fetch(`/api/push/subscribe`,{method:`POST`,headers:{...i,"Content-Type":`application/json`},body:JSON.stringify(c.toJSON())}),r(!0),localStorage.setItem(`ppm-push-subscribed`,`true`)}catch(e){s(e instanceof Error?e.message:`Subscribe failed`),console.error(`[push] Subscribe failed:`,e)}finally{a(!1)}},[]),unsubscribe:(0,B.useCallback)(async()=>{a(!0);try{let e=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(e){let t={"Content-Type":`application/json`},n=pe();n&&(t.Authorization=`Bearer ${n}`),await fetch(`/api/push/subscribe`,{method:`DELETE`,headers:t,body:JSON.stringify({endpoint:e.endpoint})}),await e.unsubscribe()}r(!1),localStorage.removeItem(`ppm-push-subscribed`)}catch(e){console.error(`[push] Unsubscribe failed:`,e)}finally{a(!1)}},[])}}var gm=[{value:`light`,label:`Light`,icon:Lt},{value:`dark`,label:`Dark`,icon:xt},{value:`system`,label:`System`,icon:bt}],_m=`PushManager`in window&&`serviceWorker`in navigator,vm=/iPhone|iPad/.test(navigator.userAgent)&&!window.matchMedia(`(display-mode: standalone)`).matches,ym=[{value:`ai`,label:`AI Provider`,subtitle:`Model, execution mode, limits`,icon:ke},{value:`notifications`,label:`Notifications`,subtitle:`Push & Telegram alerts`,icon:De},{value:`proxy`,label:`API Proxy`,subtitle:`Expose accounts as Anthropic API`,icon:it},{value:`shortcuts`,label:`Keyboard Shortcuts`,subtitle:`Customize key bindings`,icon:lt}];function bm(){let{theme:e,setTheme:t,deviceName:n,setDeviceName:r,version:i}=V(),{permission:a,isSubscribed:s,loading:l,error:f,subscribe:p,unsubscribe:m}=hm(),[h,g]=(0,B.useState)(null),[_,v]=(0,B.useState)(n??``),[y,b]=(0,B.useState)(!1),[x,S]=(0,B.useState)(!1),C=(0,B.useRef)(void 0),w=_.trim()!==(n??``),T=(0,B.useCallback)(async()=>{if(w){b(!0);try{await r(_),S(!0),clearTimeout(C.current),C.current=setTimeout(()=>S(!1),2e3)}finally{b(!1)}}},[_,w,r]);if(h){let e=ym.find(e=>e.value===h),t=e.icon;return(0,H.jsxs)(`div`,{className:`h-full w-full flex flex-col`,children:[(0,H.jsxs)(`div`,{className:`shrink-0 px-2 pt-3 pb-1 flex items-center gap-1`,children:[(0,H.jsx)(c,{variant:`ghost`,size:`icon`,className:`size-8 cursor-pointer shrink-0`,onClick:()=>g(null),children:(0,H.jsx)(Ce,{className:`size-4`})}),(0,H.jsx)(t,{className:`size-4 text-muted-foreground shrink-0`}),(0,H.jsx)(`h2`,{className:`text-sm font-semibold truncate`,children:e.label})]}),(0,H.jsx)(Jp,{}),(0,H.jsx)(dp,{className:`flex-1 min-h-0`,children:(0,H.jsxs)(`div`,{className:`p-3`,children:[h===`ai`&&(0,H.jsx)(om,{compact:!0}),h===`notifications`&&(0,H.jsx)(xm,{isSubscribed:s,loading:l,permission:a,pushError:f,subscribe:p,unsubscribe:m}),h===`proxy`&&(0,H.jsx)(pm,{}),h===`shortcuts`&&(0,H.jsx)(um,{})]})})]})}return(0,H.jsxs)(`div`,{className:`h-full w-full flex flex-col`,children:[(0,H.jsx)(`div`,{className:`shrink-0 px-3 pt-3 pb-1`,children:(0,H.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Settings`})}),(0,H.jsx)(dp,{className:`flex-1 min-h-0`,children:(0,H.jsxs)(`div`,{className:`p-3 space-y-4`,children:[(0,H.jsxs)(`section`,{className:`space-y-2`,children:[(0,H.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:`Device Name`}),(0,H.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,H.jsx)(u,{value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&T()},placeholder:`My Device`,className:`h-8 text-xs flex-1`,maxLength:100}),(0,H.jsx)(c,{variant:x?`default`:`outline`,size:`sm`,className:`h-8 text-xs px-3 cursor-pointer`,disabled:!w||y,onClick:T,children:y?`...`:x?(0,H.jsx)(o,{className:`size-3.5`}):`Save`})]}),(0,H.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Shown in page title and synced to PPM Cloud.`})]}),(0,H.jsxs)(`section`,{className:`space-y-2`,children:[(0,H.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:`Theme`}),(0,H.jsx)(`div`,{className:`flex gap-1.5`,children:gm.map(n=>{let r=n.icon;return(0,H.jsxs)(c,{variant:e===n.value?`default`:`outline`,size:`sm`,onClick:()=>t(n.value),className:R(`flex-1 gap-1.5 text-xs h-8 cursor-pointer`,e===n.value&&`ring-2 ring-primary`),children:[(0,H.jsx)(r,{className:`size-3.5`}),n.label]},n.value)})})]}),(0,H.jsx)(Jp,{}),(0,H.jsx)(`nav`,{className:`space-y-1`,"aria-label":`Settings categories`,children:ym.map(e=>{let t=e.icon;return(0,H.jsxs)(`button`,{onClick:()=>g(e.value),className:`w-full flex items-center gap-3 px-2.5 py-2.5 rounded-lg hover:bg-accent/50 active:bg-accent transition-colors cursor-pointer text-left group`,children:[(0,H.jsx)(`div`,{className:`size-8 rounded-md bg-muted flex items-center justify-center shrink-0 group-hover:bg-accent`,children:(0,H.jsx)(t,{className:`size-4 text-muted-foreground`})}),(0,H.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium text-foreground truncate`,children:e.label}),(0,H.jsx)(`p`,{className:`text-[11px] text-muted-foreground truncate`,children:e.subtitle})]}),(0,H.jsx)(d,{className:`size-4 text-muted-foreground shrink-0`})]},e.value)})}),(0,H.jsx)(Jp,{}),(0,H.jsxs)(`section`,{className:`space-y-1 pb-2`,children:[(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`PPM — Personal Project Manager`}),(0,H.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`A mobile-first web IDE for managing your projects.`}),i&&(0,H.jsxs)(`p`,{className:`text-[11px] text-muted-foreground tabular-nums`,children:[`Version `,i]})]})]})})]})}function xm({isSubscribed:e,loading:t,permission:n,pushError:r,subscribe:i,unsubscribe:a}){return(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`section`,{className:`space-y-2`,children:[(0,H.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:`Push Notifications`}),_m?(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[e?(0,H.jsx)(Oe,{className:`size-3.5`}):(0,H.jsx)(Ee,{className:`size-3.5`}),(0,H.jsx)(`span`,{className:`text-xs`,children:`Push notifications`})]}),(0,H.jsx)(c,{variant:e?`default`:`outline`,size:`sm`,className:`h-7 text-xs cursor-pointer`,disabled:t||n===`denied`,onClick:()=>e?a():i(),children:t?`...`:e?`On`:`Off`})]}),e&&(0,H.jsx)(c,{variant:`outline`,size:`sm`,className:`h-7 text-xs w-full cursor-pointer`,onClick:()=>{new Notification(`PPM Test`,{body:`Push notifications are working!`})},children:`Test notification`}),r&&(0,H.jsx)(`p`,{className:`text-[11px] text-destructive`,children:r}),n===`denied`&&(0,H.jsx)(`p`,{className:`text-[11px] text-destructive`,children:`Notifications blocked. Enable in browser settings.`}),vm&&(0,H.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`On iOS, install PPM to Home Screen for push notifications.`})]}):(0,H.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Push notifications not supported in this browser.`})]}),(0,H.jsx)(Jp,{}),(0,H.jsxs)(`section`,{className:`space-y-2`,children:[(0,H.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:`Telegram`}),(0,H.jsx)(dm,{})]})]})}function Sm({connections:e,cachedTables:t,onOpenTable:n,onRefreshTables:r,onEdit:i,onDelete:a}){let[o,c]=(0,B.useState)(new Set),[l,u]=(0,B.useState)(new Set([`__ungrouped__`])),[f,p]=(0,B.useState)(new Set),[m,h]=(0,B.useState)(new Map),g=e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},_=e=>{u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},v=async e=>{p(t=>new Set(t).add(e));try{await r(e)}finally{p(t=>{let n=new Set(t);return n.delete(e),n})}},y={};for(let t of e){let e=t.group_name??`__ungrouped__`;(y[e]??=[]).push(t)}let b=Object.keys(y).sort((e,t)=>e===`__ungrouped__`?1:t===`__ungrouped__`?-1:e.localeCompare(t));return e.length===0?(0,H.jsxs)(`p`,{className:`px-4 py-6 text-xs text-text-subtle text-center`,children:[`No connections yet.`,(0,H.jsx)(`br`,{}),`Click + to add one.`]}):(0,H.jsx)(`div`,{className:`py-1`,children:b.map(e=>{let r=l.has(e),c=e===`__ungrouped__`?`Ungrouped`:e,u=y[e],p=b.length>1||e!==`__ungrouped__`;return(0,H.jsxs)(`div`,{children:[p&&(0,H.jsxs)(`button`,{onClick:()=>_(e),className:`w-full flex items-center gap-1 px-2 py-1 text-[10px] font-semibold text-text-subtle uppercase tracking-wider hover:text-text-secondary transition-colors`,children:[r?(0,H.jsx)(s,{className:`size-3`}):(0,H.jsx)(d,{className:`size-3`}),c]}),r&&(0,H.jsx)(`div`,{className:p?`ml-[11px] border-l border-dashed border-border`:``,children:u.map(e=>{let r=o.has(e.id),c=t.get(e.id)??[],l=f.has(e.id);return(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:R(`group flex items-center gap-1 py-1 hover:bg-surface-elevated transition-colors`,p?`pl-3 pr-2`:`px-2`),children:[(0,H.jsx)(`button`,{onClick:()=>{g(e.id),!o.has(e.id)&&c.length===0&&v(e.id)},className:`shrink-0 text-text-subtle hover:text-foreground transition-colors`,children:r?(0,H.jsx)(s,{className:`size-3`}):(0,H.jsx)(d,{className:`size-3`})}),(0,H.jsx)(`span`,{className:`shrink-0 size-2 rounded-full border border-border`,style:{backgroundColor:e.color??`transparent`}}),(0,H.jsx)(`button`,{className:`flex-1 text-left text-xs truncate hover:text-primary transition-colors`,onClick:()=>{g(e.id),!o.has(e.id)&&c.length===0&&v(e.id)},children:e.name}),(0,H.jsx)(`span`,{className:`shrink-0 text-[9px] text-text-subtle uppercase px-1 rounded bg-surface-elevated`,children:e.type===`postgres`?`PG`:`DB`}),e.readonly===1&&(0,H.jsx)(`span`,{title:`Readonly`,children:(0,H.jsx)(mt,{className:`shrink-0 size-2.5 text-text-subtle`,"aria-label":`Readonly`})}),(0,H.jsxs)(`div`,{className:`hidden group-hover:flex items-center gap-0.5 shrink-0`,children:[(0,H.jsx)(`button`,{onClick:()=>v(e.id),disabled:l,className:`p-0.5 text-text-subtle hover:text-foreground transition-colors`,title:`Refresh tables`,children:(0,H.jsx)(kt,{className:R(`size-3`,l&&`animate-spin`)})}),(0,H.jsx)(`button`,{onClick:()=>i(e),className:`p-0.5 text-text-subtle hover:text-foreground transition-colors`,title:`Edit`,children:(0,H.jsx)(Dt,{className:`size-3`})}),(0,H.jsx)(`button`,{onClick:()=>a(e.id),className:`p-0.5 text-text-subtle hover:text-red-500 transition-colors`,title:`Delete`,children:(0,H.jsx)(zt,{className:`size-3`})})]})]}),r&&(0,H.jsxs)(`div`,{className:`ml-[11px] border-l border-dashed border-border pl-3`,children:[l&&c.length===0&&(0,H.jsx)(`p`,{className:`text-[10px] text-text-subtle px-2 py-1`,children:`Loading…`}),!l&&c.length===0&&(0,H.jsx)(`p`,{className:`text-[10px] text-text-subtle px-2 py-1`,children:`No tables cached`}),c.length>0&&(0,H.jsx)(wm,{connId:e.id,tables:c,filter:m.get(e.id)??``,onFilterChange:t=>h(n=>new Map(n).set(e.id,t)),onOpenTable:(t,r)=>n(e,t,r)})]})]},e.id)})})]},e)})})}var Cm=200;function wm({connId:e,tables:t,filter:n,onFilterChange:r,onOpenTable:i}){let a=(0,B.useMemo)(()=>{if(!n)return t;let e=n.toLowerCase();return t.filter(t=>t.tableName.toLowerCase().includes(e))},[t,n]);return(0,H.jsxs)(`div`,{children:[t.length>5&&(0,H.jsxs)(`div`,{className:`flex items-center gap-1 px-1 py-0.5`,children:[(0,H.jsx)(Mt,{className:`size-2.5 text-text-subtle shrink-0`}),(0,H.jsx)(`input`,{type:`text`,value:n,onChange:e=>r(e.target.value),placeholder:`Filter tables…`,className:`w-full text-[10px] bg-transparent border-none outline-none text-foreground placeholder:text-text-subtle`})]}),(0,H.jsxs)(`div`,{className:`overflow-y-auto`,style:{maxHeight:Cm},children:[a.map(t=>(0,H.jsxs)(`button`,{onClick:()=>i(t.tableName,t.schemaName),className:`w-full flex items-center gap-1.5 px-2 py-0.5 text-[11px] text-text-secondary hover:text-foreground hover:bg-surface-elevated transition-colors text-left truncate`,children:[(0,H.jsx)(He,{className:`size-2.5 shrink-0 text-text-subtle`}),(0,H.jsx)(`span`,{className:`truncate`,children:t.tableName})]},`${e}-${t.schemaName}.${t.tableName}`)),n&&a.length===0&&(0,H.jsx)(`p`,{className:`text-[10px] text-text-subtle px-2 py-1`,children:`No match`})]})]})}var Tm=`ppm-recent-paths`,Em=5,Dm=[{name:`Home`,path:`~`,icon:st},{name:`Desktop`,path:`~/Desktop`,icon:bt},{name:`Documents`,path:`~/Documents`,icon:Xe},{name:`Downloads`,path:`~/Downloads`,icon:Ue}];function Om(){try{return JSON.parse(localStorage.getItem(Tm)??`[]`)}catch{return[]}}function km(e){let t=[e,...Om().filter(t=>t!==e)].slice(0,Em);localStorage.setItem(Tm,JSON.stringify(t))}function Am(e){return e==null?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function jm(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return`now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function Mm(e){if(e.type===`directory`)return(0,H.jsx)(tt,{className:`size-4 text-blue-500`});let t=e.name.split(`.`).pop()?.toLowerCase();return t&&[`db`,`sqlite`,`sqlite3`].includes(t)?(0,H.jsx)(He,{className:`size-4 text-amber-500`}):(0,H.jsx)(Qe,{className:`size-4 text-text-subtle`})}function Nm(e,t){if(!t?.length)return!0;let n=`.`+e.split(`.`).pop()?.toLowerCase();return t.includes(n)}function Pm({open:e,mode:t,accept:n,root:r,title:i,onSelect:a,onCancel:o}){let[s,l]=(0,B.useState)([]),[f,p]=(0,B.useState)(``),[m,h]=(0,B.useState)(null),[g,_]=(0,B.useState)([]),[v,y]=(0,B.useState)(null),[b,x]=(0,B.useState)(!1),[S,C]=(0,B.useState)(null),[w,T]=(0,B.useState)(``),[E,D]=(0,B.useState)(``),[O,ee]=(0,B.useState)(!1),[k,A]=(0,B.useState)([]),j=(0,B.useRef)(null),te=typeof window<`u`&&window.innerWidth<768,M=t===`folder`?`Select Folder`:t===`file`?`Select File`:`Select File or Folder`,N=(0,B.useCallback)(async(e,t)=>{x(!0),C(null),y(null),T(``);try{let n=new URLSearchParams;e&&n.set(`path`,e),t&&n.set(`showHidden`,`true`);let r=await z.get(`/api/fs/browse?${n}`);l(r.entries),p(r.current),h(r.parent),_(r.breadcrumbs),D(r.current)}catch(e){C(e.message||`Failed to browse directory`)}finally{x(!1)}},[]);(0,B.useEffect)(()=>{e&&(N(r??`~`,O),A(Om()))},[e,r,N,O]);let P=e=>N(e,O),ne=()=>{let e=!O;ee(e),N(f||(r??`~`),e)},re=e=>{e.key===`Enter`&&E.trim()&&N(E.trim())},F=e=>{e.type===`directory`?t===`file`?P(e.path):y(e.path):t!==`folder`&&y(e.path)},ie=e=>{e.type===`directory`&&P(e.path)},ae=()=>{v&&(km(f),a(v))},I=s.filter(e=>!(w&&!e.name.toLowerCase().includes(w.toLowerCase())||e.type===`file`&&n?.length&&!Nm(e.name,n))),oe=e=>e.type===`directory`?t!==`file`:t!==`folder`,se=(0,H.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-2 border-b border-border`,children:[m&&(0,H.jsx)(c,{variant:`ghost`,size:`icon`,className:`size-7 shrink-0`,onClick:()=>P(m),children:(0,H.jsx)(Ce,{className:`size-4`})}),(0,H.jsx)(u,{value:E,onChange:e=>D(e.target.value),onKeyDown:re,placeholder:`Type path and press Enter`,className:`h-7 text-xs font-mono flex-1`})]}),(0,H.jsx)(`div`,{className:`flex items-center gap-0.5 px-3 py-1.5 border-b border-border overflow-x-auto text-xs`,children:g.map((e,t)=>(0,H.jsxs)(`span`,{className:`flex items-center shrink-0`,children:[t>0&&(0,H.jsx)(d,{className:`size-3 text-text-subtle mx-0.5`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>P(e.path),className:`hover:text-primary hover:underline text-text-secondary`,children:e.name})]},e.path))}),(0,H.jsxs)(`div`,{className:`flex flex-1 min-h-0 overflow-hidden`,children:[!te&&(0,H.jsxs)(`div`,{className:`w-36 border-r border-border py-2 px-1 shrink-0 overflow-y-auto`,children:[Dm.map(e=>(0,H.jsxs)(`button`,{type:`button`,onClick:()=>P(e.path),className:R(`flex items-center gap-2 w-full px-2 py-1 text-xs rounded-md hover:bg-surface-hover text-left`,f.endsWith(e.name)&&`bg-primary/10 text-primary`),children:[(0,H.jsx)(e.icon,{className:`size-3.5`}),e.name]},e.path)),k.length>0&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`text-[10px] text-text-subtle px-2 mt-3 mb-1 font-medium`,children:`Recent`}),k.map(e=>(0,H.jsxs)(`button`,{type:`button`,onClick:()=>P(e),className:`flex items-center gap-2 w-full px-2 py-1 text-xs rounded-md hover:bg-surface-hover text-left truncate`,children:[(0,H.jsx)(ze,{className:`size-3 shrink-0`}),(0,H.jsx)(`span`,{className:`truncate`,children:e.split(`/`).pop()})]},e))]})]}),(0,H.jsx)(dp,{className:`flex-1 min-h-0`,children:b?(0,H.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,H.jsx)(pt,{className:`size-5 animate-spin text-text-subtle`})}):S?(0,H.jsx)(`div`,{className:`text-center py-8 text-xs text-red-500`,children:S}):I.length===0?(0,H.jsx)(`div`,{className:`text-center py-8 text-xs text-text-subtle`,children:w?`No matching entries`:`Empty directory`}):(0,H.jsx)(`div`,{ref:j,className:`py-1`,children:I.map(e=>{let t=oe(e);return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>F(e),onDoubleClick:()=>ie(e),className:R(`flex items-center gap-2 w-full px-3 py-1.5 text-left text-xs transition-colors`,v===e.path?`bg-primary/10 text-primary`:t?`hover:bg-surface-hover text-text-primary`:`opacity-40 cursor-default`),disabled:!t&&e.type===`file`,children:[Mm(e),(0,H.jsx)(`span`,{className:R(`flex-1 truncate`,e.type===`directory`&&`font-medium`),children:e.name}),(0,H.jsx)(`span`,{className:`text-text-subtle text-[10px] shrink-0 w-14 text-right`,children:Am(e.size)}),(0,H.jsx)(`span`,{className:`text-text-subtle text-[10px] shrink-0 w-14 text-right`,children:jm(e.modified)})]},e.path)})})})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-t border-border shrink-0`,children:[(0,H.jsx)(c,{variant:`ghost`,size:`icon`,className:R(`size-7 shrink-0`,O&&`text-primary`),onClick:ne,title:O?`Hide hidden files`:`Show hidden files`,children:O?(0,H.jsx)(Ke,{className:`size-3.5`}):(0,H.jsx)(Ge,{className:`size-3.5`})}),n?.length?(0,H.jsx)(`span`,{className:`text-[10px] text-text-subtle bg-surface-hover px-1.5 py-0.5 rounded`,children:n.join(`, `)}):null,(0,H.jsx)(`div`,{className:`flex-1 max-w-48`,children:(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(Mt,{className:`absolute left-2 top-1/2 -translate-y-1/2 size-3 text-text-subtle`}),(0,H.jsx)(u,{value:w,onChange:e=>T(e.target.value),placeholder:`Filter...`,className:`h-6 text-[11px] pl-6`})]})}),(0,H.jsx)(`div`,{className:`flex-1`}),(0,H.jsx)(c,{variant:`outline`,size:`sm`,onClick:o,className:`h-7 text-xs`,children:`Cancel`}),(0,H.jsx)(c,{size:`sm`,onClick:ae,disabled:!v,className:`h-7 text-xs`,children:`Select`})]})]});return(0,H.jsx)(vp,{open:e,onOpenChange:e=>{e||o()},children:(0,H.jsxs)(xp,{className:R(`p-0 gap-0 overflow-hidden flex flex-col`,te?`max-w-[95vw] h-[85vh]`:`max-w-2xl h-[70vh]`),children:[(0,H.jsx)(Sp,{className:`px-3 py-2 border-b border-border`,children:(0,H.jsx)(wp,{className:`text-sm`,children:i??M})}),se]})})}function Fm({mode:e,accept:t,root:n,title:r,onSelect:i,className:a}){let[o,s]=(0,B.useState)(!1);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(c,{type:`button`,variant:`ghost`,size:`icon`,className:R(`size-8 shrink-0`,a),onClick:()=>s(!0),title:r??`Browse...`,children:(0,H.jsx)($e,{className:`size-4`})}),(0,H.jsx)(Pm,{open:o,mode:e,accept:t,root:n,title:r,onSelect:e=>{i(e),s(!1)},onCancel:()=>s(!1)})]})}var Im=[`#ef4444`,`#f97316`,`#eab308`,`#22c55e`,`#06b6d4`,`#3b82f6`,`#8b5cf6`,`#ec4899`,`#6b7280`,`#000000`];function Lm({value:e,onChange:t}){return(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>t(null),className:R(`size-6 rounded-full border-2 transition-all`,e?`border-border hover:scale-105`:`border-primary scale-110`,`bg-transparent relative`),title:`No color`,children:(0,H.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center text-[8px] text-text-subtle`,children:`×`})}),Im.map(n=>(0,H.jsx)(`button`,{type:`button`,onClick:()=>t(n),className:R(`size-6 rounded-full border-2 transition-all hover:scale-105`,e===n?`border-primary scale-110`:`border-transparent`),style:{backgroundColor:n},title:n},n))]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`div`,{className:`size-6 rounded-full border border-border shrink-0`,style:{backgroundColor:e??`transparent`}}),(0,H.jsx)(`input`,{type:`text`,value:e??``,onChange:e=>{let n=e.target.value.trim();if(n===``){t(null);return}/^#[0-9a-fA-F]{6}$/.test(n),t(n)},placeholder:`#3b82f6`,className:`flex-1 h-7 text-xs px-2 rounded-md border border-border bg-background focus:outline-none focus:border-primary font-mono`})]})]})}function Rm({open:e,onClose:t,connection:n,onSave:r,onUpdate:i,onTest:a}){let o=!!n,[s,l]=(0,B.useState)({name:``,type:`postgres`,path:``,connectionString:``,groupName:``,color:null,readonly:!0}),[u,d]=(0,B.useState)(!1),[f,p]=(0,B.useState)(null),[m,h]=(0,B.useState)(!1),[g,_]=(0,B.useState)(null);(0,B.useEffect)(()=>{if(!e){p(null),_(null);return}l(n?{name:n.name,type:n.type,path:``,connectionString:``,groupName:n.group_name??``,color:n.color,readonly:n.readonly===1}:{name:``,type:`postgres`,path:``,connectionString:``,groupName:``,color:null,readonly:!0})},[e,n]);let v=(e,t)=>{l(n=>({...n,[e]:t})),p(null)};return(0,H.jsx)(vp,{open:e,onOpenChange:e=>{e||t()},children:(0,H.jsxs)(xp,{className:`max-w-md`,children:[(0,H.jsx)(Sp,{children:(0,H.jsx)(wp,{children:o?`Edit Connection`:`Add Connection`})}),(0,H.jsxs)(`div`,{className:`space-y-3 py-1`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`text-xs font-medium text-text-secondary mb-1 block`,children:`Name *`}),(0,H.jsx)(`input`,{value:s.name,onChange:e=>v(`name`,e.target.value),placeholder:`my-database`,className:`w-full h-8 text-sm px-2.5 rounded-md border border-border bg-background focus:outline-none focus:border-primary`})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`text-xs font-medium text-text-secondary mb-1 block`,children:`Type`}),(0,H.jsxs)(`select`,{value:s.type,onChange:e=>v(`type`,e.target.value),className:`w-full h-8 text-sm px-2 rounded-md border border-border bg-background focus:outline-none focus:border-primary`,children:[(0,H.jsx)(`option`,{value:`postgres`,children:`PostgreSQL`}),(0,H.jsx)(`option`,{value:`sqlite`,children:`SQLite`})]})]}),s.type===`postgres`?(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`text-xs font-medium text-text-secondary mb-1 block`,children:`Connection String *`}),(0,H.jsx)(`input`,{type:`password`,value:s.connectionString,onChange:e=>v(`connectionString`,e.target.value),placeholder:`postgresql://user:pass@host:5432/db`,className:`w-full h-8 text-sm px-2.5 rounded-md border border-border bg-background focus:outline-none focus:border-primary font-mono`})]}):(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`text-xs font-medium text-text-secondary mb-1 block`,children:`File Path *`}),(0,H.jsxs)(`div`,{className:`flex gap-1.5 items-center`,children:[(0,H.jsx)(`input`,{value:s.path,onChange:e=>v(`path`,e.target.value),placeholder:`/path/to/database.db`,className:`flex-1 h-8 text-sm px-2.5 rounded-md border border-border bg-background focus:outline-none focus:border-primary font-mono`}),(0,H.jsx)(Fm,{mode:`file`,accept:[`.db`,`.sqlite`,`.sqlite3`],title:`Browse for SQLite database`,onSelect:e=>v(`path`,e)})]})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`text-xs font-medium text-text-secondary mb-1 block`,children:`Group`}),(0,H.jsx)(`input`,{value:s.groupName,onChange:e=>v(`groupName`,e.target.value),placeholder:`Production`,className:`w-full h-8 text-sm px-2.5 rounded-md border border-border bg-background focus:outline-none focus:border-primary`})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`text-xs font-medium text-text-secondary mb-1 block`,children:`Tab Color`}),(0,H.jsx)(Lm,{value:s.color,onChange:e=>v(`color`,e)})]}),o&&(0,H.jsxs)(`div`,{className:`flex items-center justify-between py-1`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-xs font-medium`,children:`Readonly`}),(0,H.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:`Block non-SELECT queries (AI protection)`})]}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>v(`readonly`,!s.readonly),className:`relative w-9 h-5 rounded-full transition-colors ${s.readonly?`bg-primary`:`bg-border`}`,children:(0,H.jsx)(`span`,{className:`absolute top-0.5 left-0.5 size-4 rounded-full bg-white transition-transform ${s.readonly?`translate-x-4`:``}`})})]}),f&&(0,H.jsx)(`p`,{className:`text-xs ${f.ok?`text-green-500`:`text-red-500`}`,children:f.ok?`✓ Connection successful`:`✗ ${f.error}`}),g&&(0,H.jsx)(`p`,{className:`text-xs text-red-500`,children:g})]}),(0,H.jsxs)(Cp,{children:[o&&(0,H.jsx)(c,{variant:`outline`,size:`sm`,onClick:async()=>{if(o){d(!0),p(null);try{p(await a(n.id))}finally{d(!1)}}},disabled:u,className:`mr-auto`,children:u?`Testing…`:`Test Connection`}),(0,H.jsx)(c,{variant:`outline`,size:`sm`,onClick:t,children:`Cancel`}),(0,H.jsx)(c,{size:`sm`,onClick:async()=>{if(_(null),!s.name.trim()){_(`Name is required`);return}h(!0);try{if(o&&i){let e=(s.type===`postgres`?s.connectionString.trim():s.path.trim())?s.type===`postgres`?{type:`postgres`,connectionString:s.connectionString}:{type:`sqlite`,path:s.path}:void 0;await i(n.id,{name:s.name.trim(),...e!==void 0&&{connectionConfig:e},groupName:s.groupName.trim()||null,color:s.color,readonly:s.readonly?1:0})}else if(r){let e=s.type===`postgres`?{type:`postgres`,connectionString:s.connectionString}:{type:`sqlite`,path:s.path};await r({type:s.type,name:s.name.trim(),connectionConfig:e,groupName:s.groupName.trim()||void 0,color:s.color??void 0})}t()}catch(e){_(e.message)}finally{h(!1)}},disabled:m,children:m?`Saving…`:o?`Save`:`Add`})]})]})})}function zm({onExport:e,onImport:t}){let[n,r]=(0,B.useState)(!1),i=(0,B.useRef)(null),a=()=>r(!1),o=async()=>{a();try{let t=await e(),n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`ppm-connections-${new Date().toISOString().slice(0,10)}.json`,i.click(),URL.revokeObjectURL(r)}catch(e){alert(`Export failed: ${e.message}`)}},s=async()=>{a();try{let t=await e();await navigator.clipboard.writeText(JSON.stringify(t,null,2)),alert(`Copied ${t.connections.length} connection(s) to clipboard`)}catch(e){alert(`Export failed: ${e.message}`)}},c=async e=>{try{let n=JSON.parse(e),r=n.connections??n;if(!Array.isArray(r)){alert(`Invalid format: expected connections array`);return}let i=await t({connections:r}),a=`Imported ${i.imported} connection(s)`;i.skipped>0&&(a+=`, ${i.skipped} skipped`),i.errors?.length>0&&(a+=`\n\nErrors:\n${i.errors.join(`
29
+ `)}`),alert(a)}catch(e){alert(`Import failed: ${e.message}`)}};return(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(`button`,{onClick:()=>r(e=>!e),className:`flex items-center justify-center size-5 rounded hover:bg-surface-elevated transition-colors text-text-subtle hover:text-foreground`,title:`Import / Export`,children:(0,H.jsx)(We,{className:`size-3.5`})}),n&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:a}),(0,H.jsxs)(`div`,{className:`absolute right-0 top-full mt-1 z-50 w-44 bg-background border border-border rounded-md shadow-lg py-1 text-xs`,children:[(0,H.jsxs)(`button`,{onClick:o,className:`w-full flex items-center gap-2 px-3 py-1.5 hover:bg-surface-elevated transition-colors text-left`,children:[(0,H.jsx)(Ue,{className:`size-3`}),` Export to file`]}),(0,H.jsxs)(`button`,{onClick:s,className:`w-full flex items-center gap-2 px-3 py-1.5 hover:bg-surface-elevated transition-colors text-left`,children:[(0,H.jsx)(Re,{className:`size-3`}),` Export to clipboard`]}),(0,H.jsx)(`div`,{className:`border-t border-border my-1`}),(0,H.jsxs)(`button`,{onClick:()=>{a(),i.current?.click()},className:`w-full flex items-center gap-2 px-3 py-1.5 hover:bg-surface-elevated transition-colors text-left`,children:[(0,H.jsx)(Ut,{className:`size-3`}),` Import from file`]}),(0,H.jsxs)(`button`,{onClick:async()=>{a();try{let e=await navigator.clipboard.readText();if(!e.trim()){alert(`Clipboard is empty`);return}await c(e)}catch(e){alert(`Clipboard read failed: ${e.message}`)}},className:`w-full flex items-center gap-2 px-3 py-1.5 hover:bg-surface-elevated transition-colors text-left`,children:[(0,H.jsx)(Le,{className:`size-3`}),` Import from clipboard`]})]})]}),(0,H.jsx)(`input`,{ref:i,type:`file`,accept:`.json`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.onload=()=>c(n.result),n.readAsText(t),e.target.value=``}})]})}function Bm(){let[e,t]=(0,B.useState)([]),[n,r]=(0,B.useState)(!0),[i,a]=(0,B.useState)(new Map),o=(0,B.useCallback)(async()=>{try{t(await z.get(`/api/db/connections`))}catch{}finally{r(!1)}},[]);return(0,B.useEffect)(()=>{o()},[o]),{connections:e,loading:n,cachedTables:i,createConnection:(0,B.useCallback)(async e=>{let n=await z.post(`/api/db/connections`,e);return t(e=>[...e,n]),n},[]),updateConnection:(0,B.useCallback)(async(e,n)=>{let r=await z.put(`/api/db/connections/${e}`,n);t(t=>t.map(t=>t.id===e?r:t))},[]),deleteConnection:(0,B.useCallback)(async e=>{await z.del(`/api/db/connections/${e}`),t(t=>t.filter(t=>t.id!==e)),a(t=>{let n=new Map(t);return n.delete(e),n})},[]),testConnection:(0,B.useCallback)(async e=>z.post(`/api/db/connections/${e}/test`),[]),refreshTables:(0,B.useCallback)(async e=>{let t=(await z.get(`/api/db/connections/${e}/tables`)).map(t=>({connectionId:e,tableName:t.name,schemaName:t.schema,rowCount:t.rowCount,cachedAt:new Date().toISOString()}));a(n=>new Map(n).set(e,t))},[]),exportConnections:(0,B.useCallback)(async()=>z.get(`/api/db/connections/export`),[]),importConnections:(0,B.useCallback)(async e=>{let t=await z.post(`/api/db/connections/import`,e);return await o(),t},[o])}}function Vm(){let{connections:e,loading:t,cachedTables:n,createConnection:r,updateConnection:i,deleteConnection:a,testConnection:o,refreshTables:s,exportConnections:c,importConnections:l}=Bm(),u=_(e=>e.openTab),[d,f]=(0,B.useState)(!1),[p,m]=(0,B.useState)(null);return(0,H.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border shrink-0`,children:[(0,H.jsx)(`span`,{className:`text-[10px] font-semibold text-text-subtle uppercase tracking-wider`,children:`Database`}),(0,H.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,H.jsx)(zm,{onExport:c,onImport:l}),(0,H.jsx)(`button`,{onClick:()=>f(!0),className:`flex items-center justify-center size-5 rounded hover:bg-surface-elevated transition-colors text-text-subtle hover:text-foreground`,title:`Add connection`,children:(0,H.jsx)(Ot,{className:`size-3.5`})})]})]}),(0,H.jsx)(`div`,{className:`flex-1 overflow-y-auto min-h-0`,children:t?(0,H.jsx)(`p`,{className:`px-4 py-6 text-xs text-text-subtle text-center`,children:`Loading…`}):(0,H.jsx)(Sm,{connections:e,cachedTables:n,onOpenTable:(e,t,n)=>{u({type:`database`,title:`${e.name} · ${t}`,projectId:null,closable:!0,metadata:{connectionId:e.id,connectionName:e.name,dbType:e.type,tableName:t,schemaName:n,connectionColor:e.color}})},onRefreshTables:s,onEdit:m,onDelete:async e=>{confirm(`Delete this connection?`)&&await a(e)}})}),(0,H.jsx)(Rm,{open:d,onClose:()=>f(!1),onSave:async e=>{let t=await r(e);t&&s(t.id).catch(()=>{})},onTest:()=>Promise.resolve({ok:!1,error:`Save connection first`})}),p&&(0,H.jsx)(Rm,{open:!!p,onClose:()=>m(null),connection:p,onUpdate:async(e,t)=>{await i(e,t)},onTest:e=>o(e)})]})}function Hm(e,t,n,r){if(!e)return null;try{let i=r?e:e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return n&&(i=`\\b${i}\\b`),RegExp(`(${i})`,t?`g`:`gi`)}catch{return null}}function Um({text:e,re:t}){if(!t)return(0,H.jsx)(`span`,{children:e});try{t.lastIndex=0;let n=e.split(t);return t.lastIndex=0,(0,H.jsx)(`span`,{children:n.map((e,n)=>(t.lastIndex=0,t.test(e)?(0,H.jsx)(`mark`,{className:`bg-yellow-300/40 text-foreground rounded-sm`,children:e},n):e))})}catch{return(0,H.jsx)(`span`,{children:e})}}function Wm({active:e,onClick:t,title:n,children:r}){return(0,H.jsx)(`button`,{onClick:t,title:n,className:R(`flex items-center justify-center w-6 h-6 rounded border shrink-0`,e?`border-primary text-primary bg-primary/10`:`border-border text-text-subtle hover:text-foreground hover:border-border/80`),children:r})}function Gm(){let{activeProject:e}=bf(),t=_(e=>e.openTab),[n,r]=(0,B.useState)(``),[i,a]=(0,B.useState)(!1),[o,c]=(0,B.useState)(!1),[l,u]=(0,B.useState)(!1),[f,p]=(0,B.useState)(!1),[m,h]=(0,B.useState)(``),[g,v]=(0,B.useState)(``),[y,b]=(0,B.useState)(!1),[x,S]=(0,B.useState)(null),[C,w]=(0,B.useState)([]),[T,E]=(0,B.useState)(0),[D,O]=(0,B.useState)(!1),[ee,k]=(0,B.useState)(new Set),A=(0,B.useRef)(null),j=(0,B.useRef)(null),te=(0,B.useCallback)(async(t,n,r,i,a)=>{if(p(!1),!e||!i&&t.length<2||i&&t.length<1){w([]),E(0);return}if(i)try{new RegExp(t)}catch{p(!0),w([]);return}O(!0);try{let o=new URLSearchParams({q:t,caseSensitive:String(n),wholeWord:String(r),regex:String(i)});a&&o.set(`include`,a);let s=await z.get(`${fe(e.name)}/files/search?${o}`);w(s.results),E(s.total)}catch{w([])}finally{O(!1)}},[e]);(0,B.useEffect)(()=>(j.current&&clearTimeout(j.current),j.current=setTimeout(()=>te(n,i,o,l,m),300),()=>{j.current&&clearTimeout(j.current)}),[n,i,o,l,m,te]),(0,B.useEffect)(()=>{A.current?.focus()},[]);let M=Hm(n,i,o,l);function N(n,r){e&&t({type:`editor`,title:n.split(`/`).pop()??n,metadata:{filePath:n,projectName:e.name,lineNumber:r},projectId:e.name,closable:!0})}function P(e){k(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function ne(){if(!e||!n||C.length===0||y)return;b(!0),S(null);let t=0;try{for(let r of C){let a=await z.get(`${fe(e.name)}/files/read?path=${encodeURIComponent(r.file)}`),s=Hm(n,i,o,l);if(!s)continue;s.lastIndex=0;let c=a.content.match(s)??[];if(!c.length)continue;t+=c.length,s.lastIndex=0;let u=a.content.replace(s,g);await z.put(`${fe(e.name)}/files/write`,{path:r.file,content:u})}S(t),te(n,i,o,l,m)}catch{}finally{b(!1)}}return(0,H.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,H.jsxs)(`div`,{className:`p-2 border-b border-border space-y-1.5`,children:[(0,H.jsx)(`div`,{className:`relative flex items-center gap-1`,children:(0,H.jsxs)(`div`,{className:`relative flex-1`,children:[(0,H.jsx)(Mt,{className:`absolute left-2 top-1/2 -translate-y-1/2 size-3.5 text-text-subtle pointer-events-none`}),(0,H.jsx)(`input`,{ref:A,value:n,onChange:e=>{r(e.target.value),S(null)},placeholder:e?`Search files…`:`Select a project first`,disabled:!e,className:R(`w-full pl-7 pr-6 py-1 text-xs bg-input border rounded focus:outline-none focus:ring-1 focus:ring-primary/50 disabled:opacity-50`,f?`border-destructive`:`border-border`)}),n&&(0,H.jsx)(`button`,{onClick:()=>{r(``),w([]),E(0),p(!1),S(null)},className:`absolute right-1.5 top-1/2 -translate-y-1/2 text-text-subtle hover:text-foreground`,children:(0,H.jsx)(Gt,{className:`size-3`})})]})}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(Wm,{active:i,onClick:()=>a(e=>!e),title:`Match Case (Alt+C)`,children:(0,H.jsx)(je,{className:`size-3.5`})}),(0,H.jsx)(Wm,{active:o,onClick:()=>{c(e=>!e),l&&u(!1)},title:`Match Whole Word (Alt+W)`,children:(0,H.jsx)(Wt,{className:`size-3.5`})}),(0,H.jsx)(Wm,{active:l,onClick:()=>{u(e=>!e),o&&c(!1)},title:`Use Regular Expression (Alt+R)`,children:(0,H.jsx)(At,{className:`size-3.5`})}),f&&(0,H.jsx)(`span`,{className:`text-[10px] text-destructive ml-1`,children:`Invalid regex`})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsxs)(`div`,{className:`relative flex-1`,children:[(0,H.jsx)(`input`,{value:g,onChange:e=>v(e.target.value),placeholder:`Replace…`,disabled:!e,className:`w-full pl-2 pr-6 py-1 text-xs bg-input border border-border rounded focus:outline-none focus:ring-1 focus:ring-primary/50 disabled:opacity-50`}),g&&(0,H.jsx)(`button`,{onClick:()=>v(``),className:`absolute right-1.5 top-1/2 -translate-y-1/2 text-text-subtle hover:text-foreground`,children:(0,H.jsx)(Gt,{className:`size-3`})})]}),(0,H.jsx)(`button`,{onClick:ne,disabled:!n||C.length===0||y,title:`Replace All`,className:`flex items-center justify-center w-6 h-6 rounded border border-border text-text-subtle hover:text-foreground hover:border-border/80 disabled:opacity-40 shrink-0`,children:y?(0,H.jsx)(pt,{className:`size-3.5 animate-spin`}):(0,H.jsx)(jt,{className:`size-3.5`})})]}),(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(`input`,{value:m,onChange:e=>h(e.target.value),placeholder:`Files to include (e.g. *.ts, src/**)`,disabled:!e,className:`w-full pl-2 pr-6 py-1 text-xs bg-input border border-border rounded focus:outline-none focus:ring-1 focus:ring-primary/50 disabled:opacity-50`}),m&&(0,H.jsx)(`button`,{onClick:()=>h(``),className:`absolute right-1.5 top-1/2 -translate-y-1/2 text-text-subtle hover:text-foreground`,children:(0,H.jsx)(Gt,{className:`size-3`})})]}),(0,H.jsxs)(`div`,{className:`text-[10px] text-text-subtle h-3`,children:[(D||y)&&(0,H.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(pt,{className:`size-2.5 animate-spin`}),y?`Replacing…`:`Searching…`]}),!D&&!y&&x!==null&&(0,H.jsxs)(`span`,{className:`text-green-500`,children:[x,` replacement`,x===1?``:`s`,` made`]}),!D&&!y&&x===null&&!f&&n.length>=2&&C.length===0&&(0,H.jsx)(`span`,{children:`No results`}),!D&&!y&&x===null&&T>0&&(0,H.jsxs)(`span`,{children:[T,` result`,T===1?``:`s`,` in `,C.length,` file`,C.length===1?``:`s`]})]})]}),(0,H.jsx)(`div`,{className:`flex-1 overflow-y-auto min-h-0`,children:C.map(e=>{let t=ee.has(e.file),n=e.file.split(`/`).pop()??e.file,r=e.file.includes(`/`)?e.file.slice(0,e.file.lastIndexOf(`/`)):``;return(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`button`,{onClick:()=>P(e.file),className:`w-full flex items-center gap-1 px-2 py-1 hover:bg-muted/50 text-left`,children:[t?(0,H.jsx)(d,{className:`size-3 shrink-0 text-text-subtle`}):(0,H.jsx)(s,{className:`size-3 shrink-0 text-text-subtle`}),(0,H.jsx)(Xe,{className:`size-3 shrink-0 text-text-subtle`}),(0,H.jsx)(`span`,{className:`text-xs font-medium text-foreground truncate`,children:n}),(0,H.jsx)(`span`,{className:`text-[10px] text-text-subtle truncate flex-1 min-w-0 ml-1`,children:r}),(0,H.jsx)(`span`,{className:`text-[10px] text-text-subtle shrink-0 ml-1 bg-muted px-1 rounded`,children:e.matches.length})]}),!t&&e.matches.map(t=>(0,H.jsxs)(`button`,{onClick:()=>N(e.file,t.lineNum),className:`w-full flex items-start gap-2 pl-7 pr-2 py-0.5 hover:bg-primary/10 text-left`,children:[(0,H.jsx)(`span`,{className:`text-[10px] text-text-subtle shrink-0 w-7 text-right pt-px`,children:t.lineNum}),(0,H.jsx)(`span`,{className:`text-xs text-text-secondary truncate font-mono leading-4`,children:(0,H.jsx)(Um,{text:t.content.trimStart(),re:M})})]},`${e.file}-${t.lineNum}`))]},e.file)})})]})}var Km=[{id:`explorer`,label:`Explorer`,icon:$e},{id:`search`,label:`Search`,icon:Mt},{id:`git`,label:`Git`,icon:nt},{id:`database`,label:`Database`,icon:He},{id:`settings`,label:`Settings`,icon:Pt}];function qm({onResize:e}){let t=(0,B.useRef)(!1);return(0,H.jsx)(`div`,{className:`absolute right-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-primary/30 active:bg-primary/50 transition-colors z-10`,onPointerDown:(0,B.useCallback)(e=>{e.preventDefault(),t.current=!0,e.currentTarget.setPointerCapture(e.pointerId),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`},[]),onPointerMove:(0,B.useCallback)(n=>{t.current&&e(n.clientX-48)},[e]),onPointerUp:(0,B.useCallback)(e=>{t.current=!1,e.currentTarget.releasePointerCapture(e.pointerId),document.body.style.cursor=``,document.body.style.userSelect=``},[])})}function Jm(){let{activeProject:e}=bf(),t=V(e=>e.sidebarCollapsed),n=V(e=>e.sidebarWidth),r=V(e=>e.toggleSidebar),i=V(e=>e.setSidebarWidth),a=V(e=>e.sidebarActiveTab),o=V(e=>e.setSidebarActiveTab);return t?(0,H.jsx)(`aside`,{className:`hidden md:flex flex-col w-10 min-w-10 bg-background border-r border-border`,children:(0,H.jsx)(`button`,{onClick:r,title:`Expand sidebar (⌘B)`,className:`flex items-center justify-center h-[41px] border-b border-border text-text-secondary hover:text-foreground transition-colors`,children:(0,H.jsx)(Et,{className:`size-4`})})}):(0,H.jsxs)(`aside`,{className:`hidden md:flex flex-col bg-background border-r border-border overflow-hidden relative`,style:{width:n,minWidth:200,maxWidth:600},children:[(0,H.jsxs)(`div`,{className:`flex items-center h-[41px] border-b border-border shrink-0`,children:[Km.map(e=>{let t=e.icon;return(0,H.jsx)(`button`,{onClick:()=>o(e.id),className:R(`flex-1 flex items-center justify-center gap-1.5 h-full text-xs transition-colors border-b-2 -mb-px`,a===e.id?`border-primary text-primary font-medium`:`border-transparent text-text-secondary hover:text-foreground`),children:(0,H.jsx)(t,{className:`size-3.5`,title:e.label})},e.id)}),(0,H.jsx)(`button`,{onClick:r,title:`Collapse sidebar (⌘B)`,className:`flex items-center justify-center w-8 h-full text-text-subtle hover:text-text-secondary transition-colors shrink-0`,children:(0,H.jsx)(Tt,{className:`size-3.5`})})]}),(0,H.jsxs)(`div`,{className:`flex-1 overflow-y-auto min-h-0`,children:[a===`explorer`&&(e?(0,H.jsx)(Ap,{}):(0,H.jsx)(`div`,{className:`flex items-center justify-center h-24 p-4`,children:(0,H.jsx)(`p`,{className:`text-xs text-text-subtle text-center`,children:`Select a project to browse files`})})),a===`git`&&(0,H.jsx)(Vp,{metadata:{projectName:e?.name}}),a===`search`&&(0,H.jsx)(Gm,{}),a===`database`&&(0,H.jsx)(Vm,{}),a===`settings`&&(0,H.jsx)(bm,{})]}),(0,H.jsx)(qm,{onResize:i})]})}var Ym=Object.defineProperty,Xm=Object.getOwnPropertySymbols,Zm=Object.prototype.hasOwnProperty,Qm=Object.prototype.propertyIsEnumerable,$m=(e,t,n)=>t in e?Ym(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,eh=(e,t)=>{for(var n in t||={})Zm.call(t,n)&&$m(e,n,t[n]);if(Xm)for(var n of Xm(t))Qm.call(t,n)&&$m(e,n,t[n]);return e},th=(e,t)=>{var n={};for(var r in e)Zm.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Xm)for(var r of Xm(e))t.indexOf(r)<0&&Qm.call(e,r)&&(n[r]=e[r]);return n},nh;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+(t?1:0),n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i;for(i=0;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})(nh||={}),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(nh||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(nh||={});var rh=nh,ih={L:rh.QrCode.Ecc.LOW,M:rh.QrCode.Ecc.MEDIUM,Q:rh.QrCode.Ecc.QUARTILE,H:rh.QrCode.Ecc.HIGH},ah=128,oh=`L`,sh=`#FFFFFF`,ch=`#000000`,lh=!1,uh=1,dh=4,fh=0,ph=.1;function mh(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function hh(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function gh(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*ph),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function _h(e,t){return t==null?e?dh:fh:Math.max(Math.floor(t),0)}function vh({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=B.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...rh.QrSegment.makeSegments(t)),e),[]);return rh.QrCode.encodeSegments(r,ih[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:u,numCells:d,calculatedImageSettings:f}=B.useMemo(()=>{let e=c.getModules(),t=_h(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:gh(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var yh=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),bh=B.forwardRef(function(e,t){let n=e,{value:r,size:i=ah,level:a=oh,bgColor:o=sh,fgColor:s=ch,includeMargin:c=lh,minVersion:l=uh,boostLevel:u,marginSize:d,imageSettings:f}=n,p=th(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=th(p,[`style`]),g=f?.src,_=B.useRef(null),v=B.useRef(null),y=B.useCallback(e=>{_.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[b,x]=B.useState(!1),{margin:S,cells:C,numCells:w,calculatedImageSettings:T}=vh({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:d,imageSettings:f,size:i});B.useEffect(()=>{if(_.current!=null){let e=_.current,t=e.getContext(`2d`);if(!t)return;let n=C,r=v.current,a=T!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&T.excavation!=null&&(n=hh(C,T.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/w*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,w,w),t.fillStyle=s,yh?t.fill(new Path2D(mh(n,S))):C.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+S,n+S,1,1)})}),T&&(t.globalAlpha=T.opacity),a&&t.drawImage(r,T.x+S,T.y+S,T.w,T.h)}}),B.useEffect(()=>{x(!1)},[g]);let E=eh({height:i,width:i},m),D=null;return g!=null&&(D=B.createElement(`img`,{src:g,key:g,style:{display:`none`},onLoad:()=>{x(!0)},ref:v,crossOrigin:T?.crossOrigin})),B.createElement(B.Fragment,null,B.createElement(`canvas`,eh({style:E,height:i,width:i,ref:y,role:`img`},h)),D)});bh.displayName=`QRCodeCanvas`;var xh=B.forwardRef(function(e,t){let n=e,{value:r,size:i=ah,level:a=oh,bgColor:o=sh,fgColor:s=ch,includeMargin:c=lh,minVersion:l=uh,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=th(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:g,numCells:_,calculatedImageSettings:v}=vh({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:f,imageSettings:p,size:i}),y=g,b=null;p!=null&&v!=null&&(v.excavation!=null&&(y=hh(g,v.excavation)),b=B.createElement(`image`,{href:p.src,height:v.h,width:v.w,x:v.x+h,y:v.y+h,preserveAspectRatio:`none`,opacity:v.opacity,crossOrigin:v.crossOrigin}));let x=mh(y,h);return B.createElement(`svg`,eh({height:i,width:i,viewBox:`0 0 ${_} ${_}`,ref:t,role:`img`},m),!!d&&B.createElement(`title`,null,d),B.createElement(`path`,{fill:o,d:`M0,0 h${_}v${_}H0z`,shapeRendering:`crispEdges`}),B.createElement(`path`,{fill:s,d:x,shapeRendering:`crispEdges`}),b)});xh.displayName=`QRCodeSVG`;function Sh({onClose:e}){let[t,n]=(0,B.useState)(null),[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)(!0),[s,c]=(0,B.useState)(!1),[l,u]=(0,B.useState)(!1),[d,f]=(0,B.useState)(!1),[p,m]=(0,B.useState)(null),[g,_]=(0,B.useState)(null),[v,y]=(0,B.useState)(null),[b,x]=(0,B.useState)(!1);(0,B.useEffect)(()=>{(async()=>{try{let[e,t]=await Promise.all([z.get(`/api/cloud/status`),z.get(`/api/tunnel`)]);n(e),i(t)}catch{}o(!1)})()},[]);let S=(0,B.useCallback)(e=>{navigator.clipboard.writeText(e),_(e),setTimeout(()=>_(null),2e3)},[]),C=(0,B.useCallback)(async()=>{c(!0),m(null);try{i({active:!0,url:(await z.post(`/api/tunnel/start`,{})).url,localUrl:r?.localUrl??null}),n(await z.get(`/api/cloud/status`))}catch(e){m(e instanceof Error?e.message:`Failed to start tunnel`)}finally{c(!1)}},[r]),w=(0,B.useCallback)(async()=>{m(null);try{let{cloud_url:e}=await z.get(`/api/cloud/login-url`),t=await fetch(`${e}/auth/device-code`,{method:`POST`,headers:{"Content-Type":`application/json`}});if(!t.ok)throw Error(`Failed to get device code`);let r=await t.json();y({userCode:r.user_code,verifyUrl:r.verification_uri}),x(!0);let i=(r.interval||5)*1e3,a=Date.now()+r.expires_in*1e3,o=setInterval(async()=>{if(Date.now()>a){clearInterval(o),x(!1),y(null),m(`Login expired. Try again.`);return}try{let t=await fetch(`${e}/auth/device-code/poll`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({device_code:r.device_code})});if(!t.ok)return;let i=await t.json();i.status===`approved`&&i.access_token&&i.email&&(clearInterval(o),x(!1),y(null),await z.post(`/api/cloud/login`,{access_token:i.access_token,email:i.email,cloud_url:e}),n(await z.get(`/api/cloud/status`)))}catch{}},i)}catch(e){m(e instanceof Error?e.message:`Failed to start login`),x(!1),y(null)}},[]),T=(0,B.useCallback)(async()=>{u(!0),m(null);try{r?.active||i({active:!0,url:(await z.post(`/api/tunnel/start`,{})).url,localUrl:r?.localUrl??null}),await z.post(`/api/cloud/link`,{}),n(await z.get(`/api/cloud/status`))}catch(e){m(e instanceof Error?e.message:`Failed to link device`)}finally{u(!1)}},[r]),E=(0,B.useCallback)(async()=>{if(confirm(`Unlink this device from PPM Cloud? It will no longer appear on your cloud dashboard.`)){f(!0);try{await z.post(`/api/cloud/unlink`,{}),n(await z.get(`/api/cloud/status`))}catch{}f(!1)}},[]),D=(0,B.useCallback)(async()=>{let e=t?.linked?`Sign out from PPM Cloud? This will also unlink your device.`:`Sign out from PPM Cloud?`;if(confirm(e)){if(t?.linked)try{await z.post(`/api/cloud/unlink`,{})}catch{}await z.post(`/api/cloud/logout`,{}),n(e=>e?{...e,logged_in:!1,email:null,linked:!1,device_name:null,device_id:null}:null)}},[t?.linked]),O=r?.url||t?.tunnel_url;return(0,H.jsxs)(`div`,{className:`w-72 bg-background border border-border rounded-lg shadow-lg p-3 space-y-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,H.jsx)(Be,{className:`size-4 text-primary`}),(0,H.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:`PPM Cloud`})]}),(0,H.jsx)(`button`,{onClick:e,className:`text-text-subtle hover:text-foreground`,children:(0,H.jsx)(Gt,{className:`size-3.5`})})]}),a&&(0,H.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground text-xs py-2`,children:[(0,H.jsx)(pt,{className:`size-4 animate-spin`}),(0,H.jsx)(`span`,{children:`Loading...`})]}),!a&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`space-y-1.5`,children:t?.logged_in?(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,H.jsx)(`div`,{className:`size-2 rounded-full bg-green-500 shrink-0`}),(0,H.jsx)(`span`,{className:`text-xs text-foreground truncate`,children:t.email})]}),(0,H.jsx)(`button`,{onClick:D,className:`text-text-subtle hover:text-foreground p-1 rounded hover:bg-muted transition-colors shrink-0`,title:`Sign out`,children:(0,H.jsx)(ht,{className:`size-3`})})]}):v?(0,H.jsxs)(`div`,{className:`space-y-2 text-center`,children:[(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Open the link below and enter the code:`}),(0,H.jsx)(`div`,{className:`font-mono text-2xl font-bold tracking-[0.3em] text-primary`,children:v.userCode}),(0,H.jsx)(`a`,{href:v.verifyUrl,target:`_blank`,rel:`noopener noreferrer`,className:`text-xs text-primary hover:underline`,children:v.verifyUrl}),b&&(0,H.jsxs)(`div`,{className:`flex items-center justify-center gap-1.5 text-xs text-muted-foreground`,children:[(0,H.jsx)(pt,{className:`size-3 animate-spin`}),(0,H.jsx)(`span`,{children:`Waiting for verification...`})]})]}):(0,H.jsxs)(`button`,{onClick:w,className:`w-full flex items-center justify-center gap-1.5 px-3 py-2 text-xs font-medium rounded-md border border-border hover:bg-muted transition-colors`,children:[(0,H.jsx)(Be,{className:`size-3.5`}),`Sign in to PPM Cloud`]})}),t?.logged_in&&(0,H.jsx)(`div`,{className:`space-y-1.5`,children:t.linked?(0,H.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,H.jsx)(dt,{className:`size-3 text-primary shrink-0`}),(0,H.jsx)(`span`,{className:`text-foreground truncate`,children:t.device_name})]}),(0,H.jsx)(`button`,{onClick:E,disabled:d,className:`text-text-subtle hover:text-destructive p-1 rounded hover:bg-muted transition-colors shrink-0`,title:`Unlink device`,children:d?(0,H.jsx)(pt,{className:`size-3 animate-spin`}):(0,H.jsx)(Ht,{className:`size-3`})})]}):(0,H.jsx)(`button`,{onClick:T,disabled:l,className:`w-full flex items-center justify-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50`,children:l?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(pt,{className:`size-3.5 animate-spin`}),` Linking...`]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(dt,{className:`size-3.5`}),` Link this machine`]})})}),(0,H.jsx)(`div`,{className:`border-t border-border`}),r?.localUrl&&(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wide`,children:`Local Network`}),(0,H.jsx)(Ch,{url:r.localUrl,copied:g,onCopy:S})]}),!O&&!s&&(0,H.jsxs)(`button`,{onClick:C,className:`w-full flex items-center justify-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 transition-colors`,children:[(0,H.jsx)(Ft,{className:`size-3.5`}),`Start Sharing`]}),s&&(0,H.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-2`,children:[(0,H.jsx)(pt,{className:`size-5 animate-spin text-primary`}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Starting tunnel...`})]}),O&&(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wide`,children:`Public URL`}),(0,H.jsx)(`div`,{className:`flex justify-center`,children:(0,H.jsx)(`div`,{className:`p-3 rounded-lg`,style:{backgroundColor:`#ffffff`,colorScheme:`light`},children:(0,H.jsx)(xh,{value:O,size:180,bgColor:`#ffffff`,fgColor:`#000000`,level:`L`,style:{display:`block`}})})}),(0,H.jsx)(Ch,{url:O,copied:g,onCopy:S})]}),t?.logged_in&&t.linked&&(0,H.jsxs)(`a`,{href:t.cloud_url+`/dashboard`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center justify-center gap-1.5 w-full px-3 py-1.5 text-xs text-muted-foreground hover:text-foreground rounded-md border border-border hover:bg-muted transition-colors`,children:[(0,H.jsx)(h,{className:`size-3`}),`Open Cloud Dashboard`]}),p&&(0,H.jsx)(`p`,{className:`text-xs text-destructive`,children:p})]})]})}function Ch({url:e,copied:t,onCopy:n}){return(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`input`,{readOnly:!0,value:e,className:`flex-1 text-xs font-mono text-foreground bg-muted px-2 py-1.5 rounded border border-border truncate`,onClick:e=>e.target.select()}),(0,H.jsx)(`button`,{onClick:()=>n(e),className:`flex items-center justify-center size-7 rounded border border-border text-muted-foreground bg-muted hover:bg-accent hover:text-foreground transition-colors shrink-0`,title:`Copy URL`,children:t===e?(0,H.jsx)(o,{className:`size-3.5 text-primary`}):(0,H.jsx)(Ve,{className:`size-3.5`})})]})}var wh=`hienlh/ppm`;async function Th(e,t){let n=`(could not fetch)`;try{let e=await(await fetch(`/api/logs/recent`)).json();e.ok&&(n=e.data.logs||`(empty)`)}catch{}let r=``;if(t?.sessionId&&t?.projectName)try{let e=await z.get(`${fe(t.projectName)}/chat/sessions/${t.sessionId}/logs?tail=100`);e.logs&&(r=e.logs)}catch{}return[`## Environment`,`- PPM: v${e??`unknown`}`,`- Browser: ${navigator.userAgent}`,``,`## Description`,`<!-- Describe the bug -->`,``,`## Steps to Reproduce`,`1. `,``,`## Expected Behavior`,``,...r?[`## Chat Session Logs (${t?.sessionId?.slice(0,8)})`,"```",r,"```",``]:[],`## Server Logs (last 30 lines)`,"```",n,"```"].join(`
30
+ `)}function Eh(e){let t=`https://github.com/${wh}/issues/new?title=bug%3A%20&body=${encodeURIComponent(e)}`;window.open(t,`_blank`)}async function Dh(e){try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}function Oh(e,t){Th(e,t).then(e=>{window.dispatchEvent(new CustomEvent(`open-bug-report`,{detail:e}))})}var kh=[`linear-gradient(135deg, #667eea, #764ba2)`,`linear-gradient(135deg, #f5576c, #f093fb)`,`linear-gradient(135deg, #4facfe, #00c6ff)`,`linear-gradient(135deg, #43e97b, #38f9d7)`,`linear-gradient(135deg, #fa709a, #fee140)`,`linear-gradient(135deg, #a18cd1, #6a3de8)`,`linear-gradient(135deg, #fd7043, #ff8a65)`,`linear-gradient(135deg, #26c6da, #0097a7)`,`linear-gradient(135deg, #ab47bc, #7b1fa2)`,`linear-gradient(135deg, #ef5350, #b71c1c)`,`linear-gradient(135deg, #1976d2, #42a5f5)`,`linear-gradient(135deg, #2e7d32, #66bb6a)`];function Ah(e,t){return e??kh[t%kh.length]}function jh(e,t){let n=e.split(/[-_.\s]+/).filter(Boolean),r=(n[0]?.[0]??e[0]??`?`).toUpperCase(),i=n.length>1?r+(n[1][0]??``).toUpperCase():r,a=t.filter(t=>t!==e);if(!a.map(e=>(e.split(/[-_.\s]+/).filter(Boolean)[0]?.[0]??e[0]??``).toUpperCase()).includes(r))return r;if(!a.map(e=>{let t=e.split(/[-_.\s]+/).filter(Boolean),n=(t[0]?.[0]??e[0]??``).toUpperCase(),r=t.length>1?(t[1][0]??``).toUpperCase():n;return t.length>1?n+r:n}).includes(i))return i;let o=t.indexOf(e);return String(o>=0?o+1:`?`)}function Mh({onSuccess:e,onCancel:t,footerClassName:n}){let{addProject:r}=bf(),[i,a]=(0,B.useState)(``),[o,s]=(0,B.useState)(``),[c,l]=(0,B.useState)([]),[u,d]=(0,B.useState)(!1),[f,p]=(0,B.useState)(!1),[m,h]=(0,B.useState)(!1),[g,_]=(0,B.useState)(``),v=(0,B.useRef)(null),y=(0,B.useRef)(null);(0,B.useEffect)(()=>{if(v.current&&clearTimeout(v.current),!i.trim()){l([]),d(!1);return}v.current=setTimeout(async()=>{p(!0);try{l(await z.get(`/api/projects/suggest-dirs?q=${encodeURIComponent(i)}`)??[]),d(!0)}catch{l([])}finally{p(!1)}},250)},[i]),(0,B.useEffect)(()=>{function e(e){y.current&&!y.current.contains(e.target)&&d(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);function b(e){a(e.path),o||s(e.name),d(!1)}async function x(t){if(t?.preventDefault(),!i.trim()){_(`Path is required`);return}_(``),h(!0);try{await r(i.trim(),o.trim()||void 0),e()}catch(e){_(e instanceof Error?e.message:`Failed to add project`)}finally{h(!1)}}return(0,H.jsxs)(`form`,{onSubmit:x,className:`flex flex-col gap-3`,children:[(0,H.jsxs)(`div`,{ref:y,className:`relative`,children:[(0,H.jsx)(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Project path`}),(0,H.jsxs)(`div`,{className:`flex gap-1.5 items-center`,children:[(0,H.jsxs)(`div`,{className:`relative flex items-center flex-1`,children:[(0,H.jsx)($e,{className:`absolute left-2.5 size-3.5 text-text-subtle pointer-events-none`}),(0,H.jsx)(`input`,{type:`text`,value:i,onChange:e=>{a(e.target.value),_(``)},onFocus:()=>c.length>0&&d(!0),placeholder:`/path/to/project`,className:`w-full pl-8 pr-3 py-2 rounded-md border border-border bg-background text-sm focus:outline-none focus:ring-1 focus:ring-primary`,autoFocus:!0,autoComplete:`off`}),f&&(0,H.jsx)(pt,{className:`absolute right-2.5 size-3.5 text-text-subtle animate-spin`})]}),(0,H.jsx)(Fm,{mode:`folder`,onSelect:e=>{a(e),o||s(e.split(`/`).pop()??``),_(``)}})]}),u&&c.length>0&&(0,H.jsx)(`div`,{className:`absolute top-full left-0 right-0 mt-1 z-10 bg-popover border border-border rounded-md shadow-md max-h-48 overflow-y-auto`,children:c.map(e=>(0,H.jsxs)(`button`,{type:`button`,onMouseDown:()=>b(e),className:`w-full flex flex-col items-start px-3 py-2 text-left hover:bg-accent/50 transition-colors`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium truncate w-full`,children:e.name}),(0,H.jsx)(`span`,{className:`text-xs text-text-subtle truncate w-full`,children:e.path})]},e.path))})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:[`Display name `,(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:`(optional)`})]}),(0,H.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),placeholder:`my-project`,className:`w-full px-3 py-2 rounded-md border border-border bg-background text-sm focus:outline-none focus:ring-1 focus:ring-primary`})]}),g&&(0,H.jsx)(`p`,{className:`text-xs text-destructive`,children:g}),(0,H.jsxs)(`div`,{className:R(`flex justify-end gap-2 pt-1`,n),children:[(0,H.jsx)(`button`,{type:`button`,onClick:t,className:`px-3 py-1.5 text-sm text-text-secondary hover:text-foreground transition-colors`,children:`Cancel`}),(0,H.jsx)(`button`,{type:`submit`,disabled:m||!i.trim(),className:`px-3 py-1.5 text-sm bg-primary text-white rounded-md hover:bg-primary/90 transition-colors disabled:opacity-50`,children:m?`Adding…`:`Add Project`})]})]})}function Nh({name:e,color:t,active:n,allNames:r}){let i=jh(e,r),a=Vf((0,B.useMemo)(()=>Uf(e),[e]));return(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(`div`,{className:R(`size-10 rounded-full flex items-center justify-center text-xs font-bold text-white select-none shrink-0`,n&&`ring-2 ring-primary ring-offset-2 ring-offset-background`),style:{background:t},children:i}),a&&(0,H.jsx)(`div`,{className:R(`absolute -top-0.5 -right-0.5 size-2.5 rounded-full border-2 border-background`,Bf(a))})]})}function Ph({current:e,onChange:t}){return(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:kh.map(n=>(0,H.jsx)(`button`,{type:`button`,onClick:()=>t(n),className:R(`size-8 rounded-full border-2 transition-all`,e===n?`border-primary scale-110`:`border-transparent hover:scale-105`),style:{background:n}},n))})}function Fh(){let{projects:e,activeProject:t,setActiveProject:n,setProjectColor:r,reorderProjects:i,renameProject:a,deleteProject:o,customOrder:s}=bf();_(e=>e.openTab);let c=V(e=>e.version),l=(0,B.useCallback)(()=>Oh(c),[c]),[u,d]=(0,B.useState)(null),[f,p]=(0,B.useState)(null),m=yf(e,s),h=m.map(e=>e.name),[g,v]=(0,B.useState)(!1),[y,b]=(0,B.useState)(``),[x,S]=(0,B.useState)(``),[C,w]=(0,B.useState)(!1),[T,E]=(0,B.useState)(``),[D,O]=(0,B.useState)(!1),[ee,k]=(0,B.useState)(!1),[A,j]=(0,B.useState)(``),[te,M]=(0,B.useState)(``),[N,P]=(0,B.useState)(!1),ne=(0,B.useCallback)(e=>{b(e),S(e),v(!0)},[]),re=(0,B.useCallback)(e=>{E(e),w(!0)},[]),F=(0,B.useCallback)((e,t)=>{j(e),M(t),k(!0)},[]);async function ie(){if(!x.trim()||x===y){v(!1);return}try{await a(y,x.trim())}catch{}v(!1)}async function ae(){try{await o(T)}catch{}w(!1)}async function I(){P(!0);try{await r(A,te),k(!1)}catch(e){console.error(`Failed to save color:`,e)}finally{P(!1)}}function oe(){O(!0)}let[se,ce]=(0,B.useState)(!1),le=(0,B.useRef)(null),[L,ue]=(0,B.useState)(null);(0,B.useEffect)(()=>{if(!se||!le.current){ue(null);return}let e=le.current.getBoundingClientRect();ue({left:e.right+6,bottom:window.innerHeight-e.bottom})},[se]);function de(){let{sidebarCollapsed:e,toggleSidebar:t,setSidebarActiveTab:n}=V.getState();e&&t(),n(`settings`)}return(0,H.jsxs)(`aside`,{className:`hidden md:flex flex-col w-[52px] min-w-[52px] bg-background border-r border-border overflow-hidden`,children:[(0,H.jsxs)(`div`,{className:`shrink-0 flex flex-col items-center justify-center h-[41px] border-b border-border gap-0.5`,children:[(0,H.jsx)(`span`,{className:`text-[11px] font-bold text-primary leading-none`,children:`PPM`}),c&&(0,H.jsxs)(`span`,{className:`text-[8px] text-text-subtle leading-none`,children:[`v`,c]})]}),(0,H.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 flex flex-col items-center gap-2 min-h-0`,children:[m.map((e,r)=>{let a=Ah(e.color,r),o=t?.name===e.name;return(0,H.jsxs)(pp,{children:[(0,H.jsxs)(Cu,{children:[(0,H.jsx)(wu,{asChild:!0,children:(0,H.jsx)(mp,{asChild:!0,children:(0,H.jsx)(`button`,{draggable:!0,onDragStart:()=>d(r),onDragOver:e=>{e.preventDefault(),p(r)},onDragLeave:()=>p(null),onDragEnd:()=>{d(null),p(null)},onDrop:()=>{if(u!=null&&u!==r){let e=m.map(e=>e.name),[t]=e.splice(u,1);e.splice(r,0,t),i(e)}d(null),p(null)},onClick:()=>n(e),className:`p-1 rounded-lg hover:bg-surface-elevated transition-all ${u===r?`opacity-40 scale-90`:``} ${f===r&&u!==r?`ring-2 ring-accent`:``}`,children:(0,H.jsx)(Nh,{name:e.name,color:a,active:o,allNames:h})})})}),(0,H.jsxs)(Tu,{side:`right`,className:`max-w-[200px]`,children:[(0,H.jsx)(`p`,{className:`font-medium`,children:e.name}),(0,H.jsx)(`p`,{className:`text-xs text-text-subtle truncate`,children:e.path})]})]}),(0,H.jsxs)(hp,{children:[(0,H.jsxs)(gp,{onClick:()=>ne(e.name),children:[(0,H.jsx)(Dt,{className:`size-3.5 mr-2`}),` Rename`]}),(0,H.jsxs)(gp,{onClick:()=>F(e.name,a),children:[(0,H.jsx)(wt,{className:`size-3.5 mr-2`}),` Change Color`]}),(0,H.jsx)(_p,{}),(0,H.jsxs)(gp,{className:`text-destructive focus:text-destructive`,onClick:()=>re(e.name),children:[(0,H.jsx)(zt,{className:`size-3.5 mr-2`}),` Delete`]})]})]},e.name)}),(0,H.jsxs)(Cu,{children:[(0,H.jsx)(wu,{asChild:!0,children:(0,H.jsx)(`button`,{onClick:oe,className:`size-10 rounded-full border-2 border-dashed border-border flex items-center justify-center text-text-subtle hover:border-primary hover:text-primary transition-colors`,children:(0,H.jsx)(Ot,{className:`size-4`})})}),(0,H.jsx)(Tu,{side:`right`,children:`Add Project`})]})]}),(0,H.jsxs)(`div`,{className:`shrink-0 flex flex-col items-center gap-1 py-2 border-t border-border`,children:[(0,H.jsxs)(Cu,{children:[(0,H.jsx)(wu,{asChild:!0,children:(0,H.jsx)(`button`,{ref:le,onClick:()=>ce(!se),className:R(`flex items-center justify-center size-8 rounded-md transition-colors`,se?`text-primary bg-primary/10`:`text-text-subtle hover:text-foreground hover:bg-surface-elevated`),children:(0,H.jsx)(Be,{className:`size-4`})})}),(0,H.jsx)(Tu,{side:`right`,children:`Cloud & Share`})]}),se&&L&&(0,Yt.createPortal)((0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>ce(!1)}),(0,H.jsx)(`div`,{className:`fixed z-50`,style:{left:L.left,bottom:L.bottom},children:(0,H.jsx)(Sh,{onClose:()=>ce(!1)})})]}),document.body),(0,H.jsxs)(Cu,{children:[(0,H.jsx)(wu,{asChild:!0,children:(0,H.jsx)(`button`,{onClick:l,className:`flex items-center justify-center size-8 rounded-md text-text-subtle hover:text-foreground hover:bg-surface-elevated transition-colors`,children:(0,H.jsx)(Ae,{className:`size-4`})})}),(0,H.jsx)(Tu,{side:`right`,children:`Report Bug`})]}),(0,H.jsxs)(Cu,{children:[(0,H.jsx)(wu,{asChild:!0,children:(0,H.jsx)(`button`,{onClick:de,className:`flex items-center justify-center size-8 rounded-md text-text-subtle hover:text-foreground hover:bg-surface-elevated transition-colors`,children:(0,H.jsx)(Pt,{className:`size-4`})})}),(0,H.jsx)(Tu,{side:`right`,children:`Settings`})]})]}),(0,H.jsx)(vp,{open:D,onOpenChange:O,children:(0,H.jsxs)(xp,{className:`sm:max-w-sm`,children:[(0,H.jsx)(Sp,{children:(0,H.jsx)(wp,{children:`Add Project`})}),(0,H.jsx)(Mh,{onSuccess:()=>O(!1),onCancel:()=>O(!1)})]})}),(0,H.jsx)(vp,{open:g,onOpenChange:v,children:(0,H.jsxs)(xp,{className:`sm:max-w-sm`,children:[(0,H.jsx)(Sp,{children:(0,H.jsx)(wp,{children:`Rename Project`})}),(0,H.jsx)(`input`,{type:`text`,value:x,onChange:e=>S(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ie()},className:`w-full px-3 py-2 rounded-md border border-border bg-background text-sm focus:outline-none focus:ring-1 focus:ring-primary`,autoFocus:!0}),(0,H.jsxs)(Cp,{children:[(0,H.jsx)(`button`,{onClick:()=>v(!1),className:`px-3 py-1.5 text-sm text-text-secondary hover:text-foreground transition-colors`,children:`Cancel`}),(0,H.jsx)(`button`,{onClick:ie,className:`px-3 py-1.5 text-sm bg-primary text-white rounded-md hover:bg-primary/90 transition-colors`,children:`Rename`})]})]})}),(0,H.jsx)(vp,{open:C,onOpenChange:w,children:(0,H.jsxs)(xp,{className:`sm:max-w-sm`,children:[(0,H.jsx)(Sp,{children:(0,H.jsx)(wp,{children:`Delete Project`})}),(0,H.jsxs)(`p`,{className:`text-sm text-text-secondary`,children:[`Remove `,(0,H.jsx)(`strong`,{className:`text-foreground`,children:T}),` from PPM? The files on disk won't be deleted.`]}),(0,H.jsxs)(Cp,{children:[(0,H.jsx)(`button`,{onClick:()=>w(!1),className:`px-3 py-1.5 text-sm text-text-secondary hover:text-foreground transition-colors`,children:`Cancel`}),(0,H.jsx)(`button`,{onClick:ae,className:`px-3 py-1.5 text-sm bg-destructive text-white rounded-md hover:bg-destructive/90 transition-colors`,children:`Delete`})]})]})}),(0,H.jsx)(vp,{open:ee,onOpenChange:k,children:(0,H.jsxs)(xp,{className:`sm:max-w-sm`,children:[(0,H.jsx)(Sp,{children:(0,H.jsx)(wp,{children:`Change Color`})}),(0,H.jsx)(Ph,{current:te,onChange:M}),(0,H.jsxs)(Cp,{children:[(0,H.jsx)(`button`,{onClick:()=>k(!1),className:`px-3 py-1.5 text-sm text-text-secondary hover:text-foreground transition-colors`,children:`Cancel`}),(0,H.jsx)(`button`,{onClick:I,disabled:N,className:`px-3 py-1.5 text-sm bg-primary text-white rounded-md hover:bg-primary/90 transition-colors disabled:opacity-50`,children:N?`Saving…`:`Save`})]})]})})]})}var Ih=[{type:`terminal`,label:`Terminal`},{type:`chat`,label:`AI Chat`},{type:`git-graph`,label:`Git Graph`},{type:`settings`,label:`Settings`}],Lh=Object.fromEntries(Ih.map(e=>[e.type,e.label])),Rh={terminal:Rt,chat:_t,editor:Je,database:He,sqlite:He,postgres:He,"git-graph":nt,"git-diff":Ye,settings:Pt,browser:it};function zh({onMenuPress:e,onProjectsPress:t}){let n=m(e=>e.focusedPanelId),r=m(e=>e.panels[e.focusedPanelId]);m(e=>Object.keys(e.panels).length);let i=m(e=>e.grid),a=r?.tabs??[],o=r?.activeTabId??null,s=(0,B.useRef)(new Map),c=(0,B.useRef)(null),l=(0,B.useRef)(a.length),u=Vf(e=>e.notifications),{canScrollLeft:f,canScrollRight:h,scrollLeft:g,scrollRight:_}=Wf(c),v=Kf(c.current,s.current,a,u),[y,b]=(0,B.useState)(null),[x,S]=(0,B.useState)(!1),C=(0,B.useRef)(null);(0,B.useEffect)(()=>{a.length>l.current&&o&&s.current.get(o)?.scrollIntoView({behavior:`smooth`,block:`nearest`,inline:`nearest`}),l.current=a.length},[a.length,o]);let w=(0,B.useCallback)(e=>{C.current=setTimeout(()=>b(e),400)},[]),T=(0,B.useCallback)(()=>{C.current&&=(clearTimeout(C.current),null)},[]),E=p(i,n)?i.length<3:!1,D=Object.keys(m.getState().panels).filter(e=>e!==n);function O(e){let t=a.findIndex(t=>t.id===e);t>0&&m.getState().reorderTab(e,n,t-1)}function ee(e){let t=a.findIndex(t=>t.id===e);t<a.length-1&&m.getState().reorderTab(e,n,t+1)}function k(e){m.getState().splitPanel(`down`,e,n)}function A(e,t){m.getState().moveTab(e,n,t)}let j=y?a.find(e=>e.id===y):null,te=y?a.findIndex(e=>e.id===y):-1,{activeProject:M}=bf.getState();function N(e){let t=e===`git-graph`||e===`git-diff`||e===`terminal`||e===`chat`?{projectName:M?.name}:void 0;m.getState().openTab({type:e,title:Lh[e]??e,metadata:t,projectId:M?.name??null,closable:!0},n),S(!1)}let{activeProject:P,projects:ne,customOrder:re}=bf(),F=yf(ne,re??null),ie=F.map(e=>e.name),ae=F.findIndex(e=>e.name===P?.name),I=P?Ah(P.color,ae>=0?ae:0):`#4f86c6`,oe=P?jh(P.name,ie):null;return(0,H.jsxs)(`nav`,{className:`fixed bottom-0 left-0 right-0 md:hidden bg-background border-t border-border z-40 select-none`,children:[(0,H.jsxs)(`div`,{className:`flex items-center h-12`,children:[(0,H.jsx)(`button`,{onClick:e,className:`flex items-center justify-center size-12 shrink-0 text-text-secondary border-r border-border`,children:(0,H.jsx)(gt,{className:`size-5`})}),(0,H.jsxs)(`div`,{className:`flex-1 min-w-0 relative flex items-center h-12`,children:[f&&(0,H.jsx)(`button`,{onClick:g,className:`absolute left-0 z-10 flex items-center justify-center size-8 bg-gradient-to-r from-background via-background to-transparent`,children:(0,H.jsxs)(`span`,{className:`relative`,children:[(0,H.jsx)(Me,{className:`size-3.5 text-text-secondary`}),v.left&&(0,H.jsx)(`span`,{className:R(`absolute -top-1 -right-0.5 size-1.5 rounded-full`,Bf(v.left))})]})}),(0,H.jsx)(`div`,{ref:c,className:`flex-1 min-w-0 flex items-center h-12 overflow-x-auto scrollbar-none`,children:a.map(e=>{let t=Rh[e.type],n=e.id===o,r=e.type===`chat`?e.metadata?.sessionId:void 0,i=r?u.get(r):void 0,a=i&&i.count>0?i.type:null;return(0,H.jsxs)(`button`,{ref:t=>{t?s.current.set(e.id,t):s.current.delete(e.id)},onClick:()=>{m.getState().setActiveTab(e.id),r&&Vf.getState().clearForSession(r)},onTouchStart:()=>w(e.id),onTouchEnd:T,onTouchMove:T,onContextMenu:e=>e.preventDefault(),className:R(`flex items-center gap-1 px-3 h-12 whitespace-nowrap text-xs shrink-0 border-t-2 transition-colors`,n?`border-primary bg-surface text-primary`:`border-transparent text-text-secondary`),children:[(0,H.jsxs)(`span`,{className:`relative`,children:[(0,H.jsx)(t,{className:`size-4`}),a&&!n&&(0,H.jsx)(`span`,{className:R(`absolute -top-1 -right-1 size-2 rounded-full`,Bf(a))})]}),(0,H.jsx)(`span`,{className:`max-w-[80px] truncate`,children:e.title}),e.closable&&(0,H.jsx)(`span`,{role:`button`,tabIndex:0,onClick:t=>{t.stopPropagation(),m.getState().closeTab(e.id)},className:`ml-0.5 p-0.5 rounded hover:bg-surface-elevated`,children:(0,H.jsx)(Gt,{className:`size-3`})})]},e.id)})}),h&&(0,H.jsx)(`button`,{onClick:_,className:`absolute right-0 z-10 flex items-center justify-center size-8 bg-gradient-to-l from-background via-background to-transparent`,children:(0,H.jsxs)(`span`,{className:`relative`,children:[(0,H.jsx)(d,{className:`size-3.5 text-text-secondary`}),v.right&&(0,H.jsx)(`span`,{className:R(`absolute -top-1 -left-0.5 size-1.5 rounded-full`,Bf(v.right))})]})})]}),(0,H.jsx)(`button`,{onClick:()=>If(),className:`flex items-center justify-center size-12 shrink-0 border-t-2 border-transparent text-text-secondary`,children:(0,H.jsx)(Ot,{className:`size-4`})}),(0,H.jsx)(`button`,{onClick:t,className:`flex items-center justify-center size-12 shrink-0 text-text-secondary border-l border-border`,title:`Switch project`,children:oe?(0,H.jsx)(`div`,{className:`size-7 rounded-full flex items-center justify-center text-[10px] font-bold text-white`,style:{background:I},children:oe}):(0,H.jsx)(ut,{className:`size-5`})})]}),x&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`fixed inset-0 z-50`,onClick:()=>S(!1)}),(0,H.jsxs)(`div`,{className:`fixed bottom-14 left-2 right-2 z-50 bg-surface border border-border rounded-lg shadow-lg overflow-hidden animate-in slide-in-from-bottom-2 duration-150`,children:[(0,H.jsx)(`div`,{className:`px-3 py-2 text-xs text-text-secondary border-b border-border`,children:`New Tab`}),Ih.map(e=>{let t=Rh[e.type];return(0,H.jsxs)(`button`,{onClick:()=>N(e.type),className:`flex items-center gap-2 w-full px-3 py-2.5 text-sm text-foreground active:bg-surface-elevated`,children:[(0,H.jsx)(t,{className:`size-4`}),` `,e.label]},e.type)})]})]}),j&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`fixed inset-0 z-50`,onClick:()=>b(null)}),(0,H.jsxs)(`div`,{className:`fixed bottom-14 left-2 right-2 z-50 bg-surface border border-border rounded-lg shadow-lg overflow-hidden animate-in slide-in-from-bottom-2 duration-150`,children:[(0,H.jsx)(`div`,{className:`px-3 py-2 text-xs text-text-secondary border-b border-border truncate`,children:j.title}),te>0&&(0,H.jsxs)(`button`,{onClick:()=>{O(y),b(null)},className:`flex items-center gap-2 w-full px-3 py-2.5 text-sm text-foreground active:bg-surface-elevated`,children:[(0,H.jsx)(Ce,{className:`size-4`}),` Move Left`]}),te<a.length-1&&(0,H.jsxs)(`button`,{onClick:()=>{ee(y),b(null)},className:`flex items-center gap-2 w-full px-3 py-2.5 text-sm text-foreground active:bg-surface-elevated`,children:[(0,H.jsx)(we,{className:`size-4`}),` Move Right`]}),E&&a.length>1&&(0,H.jsxs)(`button`,{onClick:()=>{k(y),b(null)},className:`flex items-center gap-2 w-full px-3 py-2.5 text-sm text-foreground active:bg-surface-elevated`,children:[(0,H.jsx)(It,{className:`size-4`}),` Split to Bottom`]}),D.map((e,t)=>(0,H.jsxs)(`button`,{onClick:()=>{A(y,e),b(null)},className:`flex items-center gap-2 w-full px-3 py-2.5 text-sm text-foreground active:bg-surface-elevated`,children:[(0,H.jsx)(St,{className:`size-4`}),` Move to Panel `,t+1===1?`Top`:`Bottom`]},e))]})]})]})}var Bh=[{id:`explorer`,label:`Explorer`,icon:$e},{id:`git`,label:`Git`,icon:nt},{id:`database`,label:`Database`,icon:He},{id:`settings`,label:`Settings`,icon:Pt}];function Vh({isOpen:e,onClose:t,initialTab:n}){let{activeProject:r}=bf(),i=V(e=>e.version),[a,o]=(0,B.useState)(n??`explorer`);(0,B.useEffect)(()=>{n&&o(n)},[n]);let s=(0,B.useCallback)(()=>Oh(i),[i]);return(0,H.jsxs)(`div`,{className:R(`fixed inset-0 z-50 md:hidden transition-opacity duration-200`,e?`opacity-100`:`opacity-0 pointer-events-none`),children:[(0,H.jsx)(`div`,{className:`absolute inset-0 bg-black/50`,onClick:t,"aria-label":`Close drawer`}),(0,H.jsxs)(`div`,{className:R(`fixed left-0 top-0 bottom-0 w-[90vw] bg-background border-r border-border`,`z-50 flex flex-col transition-transform duration-300 ease-out`,e?`translate-x-0`:`-translate-x-full`),children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-border shrink-0`,children:[(0,H.jsx)(`span`,{className:`text-sm font-bold text-primary tracking-tight`,children:r?.name??`PPM`}),(0,H.jsx)(`button`,{onClick:t,className:`flex items-center justify-center size-8 rounded-md hover:bg-surface-elevated transition-colors`,children:(0,H.jsx)(Gt,{className:`size-4`})})]}),(0,H.jsxs)(`div`,{className:`flex-1 overflow-y-auto min-h-0`,children:[a===`explorer`&&(r?(0,H.jsx)(Ap,{onFileOpen:t}):(0,H.jsx)(`p`,{className:`px-4 py-6 text-xs text-text-secondary text-center`,children:`Select a project from the bottom nav bar`})),a===`git`&&(0,H.jsx)(Vp,{metadata:{projectName:r?.name},onNavigate:t}),a===`database`&&(0,H.jsx)(Vm,{}),a===`settings`&&(0,H.jsx)(bm,{})]}),(0,H.jsxs)(`div`,{className:`shrink-0 border-t border-border`,children:[(0,H.jsx)(`div`,{className:`flex items-center`,children:Bh.map(e=>{let t=e.icon;return(0,H.jsxs)(`button`,{onClick:()=>o(e.id),className:R(`flex-1 flex flex-col items-center gap-0.5 py-2.5 text-[10px] transition-colors`,a===e.id?`text-primary`:`text-text-secondary`),children:[(0,H.jsx)(t,{className:`size-4`}),(0,H.jsx)(`span`,{children:e.label})]},e.id)})}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-t border-border`,children:[i&&(0,H.jsxs)(`span`,{className:`text-[10px] text-text-subtle`,children:[`v`,i]}),(0,H.jsxs)(`button`,{onClick:s,className:`flex items-center gap-1 text-[10px] text-text-subtle hover:text-text-secondary transition-colors`,children:[(0,H.jsx)(Ae,{className:`size-3`}),(0,H.jsx)(`span`,{children:`Report Bug`})]})]})]})]})]})}function Hh({name:e,color:t,allNames:n}){let r=jh(e,n);return(0,H.jsx)(`div`,{className:`size-10 rounded-full flex items-center justify-center text-xs font-bold text-white shrink-0`,style:{background:t},children:r})}function Uh({isOpen:e,onClose:t}){let{projects:n,activeProject:r,setActiveProject:i,setProjectColor:a,reorderProjects:c,renameProject:l,deleteProject:u,customOrder:d}=bf();_(e=>e.openTab);let f=V(e=>e.version),p=yf(n,d),m=p.map(e=>e.name),[h,g]=(0,B.useState)(`list`),[v,y]=(0,B.useState)(null),[b,x]=(0,B.useState)(``),[S,C]=(0,B.useState)(!1),w=(0,B.useRef)(null),[T,E]=(0,B.useState)(null),[D,O]=(0,B.useState)(``),ee=(0,B.useCallback)(e=>{w.current=setTimeout(()=>y(e),400)},[]),k=(0,B.useCallback)(()=>{w.current&&=(clearTimeout(w.current),null)},[]);function A(){g(`list`),t()}function j(e){let t=n.find(t=>t.name===e);t&&(i(t),A())}function te(){g(`add`)}function M(){if(A(),window.innerWidth<768){window.dispatchEvent(new Event(`open-mobile-settings`));return}let{sidebarCollapsed:e,toggleSidebar:t,setSidebarActiveTab:n}=V.getState();e&&t(),n(`settings`)}async function N(){if(!T||!D.trim()||D===T){E(null);return}try{await l(T,D.trim())}catch{}E(null)}async function P(e){y(null);try{await u(e)}catch{}}async function ne(e,t){try{await a(e,t),C(!1),y(null)}catch(e){console.error(`Failed to save color:`,e)}}v&&p.find(e=>e.name===v);let re=v?p.findIndex(e=>e.name===v):-1,F=v?[{label:`Rename`,icon:Dt,onClick:()=>{O(v),E(v),y(null)}},{label:`Change Color`,icon:wt,onClick:()=>{let e=p.findIndex(e=>e.name===v),t=p[e];x(Ah(t?.color,e)),C(!0)}},...re>0?[{label:`Move Up`,icon:Ne,onClick:()=>{let e=p.map(e=>e.name),[t]=e.splice(re,1);e.splice(re-1,0,t),c(e),y(null)}}]:[],...re<p.length-1?[{label:`Move Down`,icon:s,onClick:()=>{let e=p.map(e=>e.name),[t]=e.splice(re,1);e.splice(re+1,0,t),c(e),y(null)}}]:[],{label:`Delete`,icon:zt,destructive:!0,onClick:()=>P(v)}]:[];return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:R(`fixed inset-0 z-50 md:hidden transition-opacity duration-200`,e?`opacity-100`:`opacity-0 pointer-events-none`),onClick:A,style:{backgroundColor:`rgba(0,0,0,0.5)`}}),(0,H.jsxs)(`div`,{className:R(`fixed bottom-0 left-0 right-0 z-50 md:hidden bg-background rounded-t-2xl border-t border-border shadow-2xl`,`transition-transform duration-300 ease-out`,e?`translate-y-0`:`translate-y-full`),children:[(0,H.jsx)(`div`,{className:`flex justify-center pt-3 pb-1`,children:(0,H.jsx)(`div`,{className:`w-10 h-1 rounded-full bg-border`})}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b border-border`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[h===`add`&&(0,H.jsx)(`button`,{onClick:()=>g(`list`),className:`flex items-center justify-center size-7 rounded-md hover:bg-surface-elevated transition-colors`,children:(0,H.jsx)(Ce,{className:`size-4`})}),(0,H.jsx)(`span`,{className:`text-sm font-semibold`,children:h===`add`?`Add Project`:`Projects`})]}),(0,H.jsx)(`button`,{onClick:A,className:`flex items-center justify-center size-7 rounded-md hover:bg-surface-elevated transition-colors`,children:(0,H.jsx)(Gt,{className:`size-4`})})]}),h===`add`&&(0,H.jsx)(`div`,{className:`px-4 py-4`,children:(0,H.jsx)(Mh,{onSuccess:()=>{g(`list`),t()},onCancel:()=>g(`list`),footerClassName:`pt-2`})}),(0,H.jsx)(`div`,{className:h===`add`?`hidden`:`max-h-[60vh] overflow-y-auto`,children:p.map((e,t)=>{let n=Ah(e.color,t),i=r?.name===e.name,a=T===e.name;return(0,H.jsxs)(`div`,{className:R(`flex items-center gap-3 px-4 py-3 transition-colors active:bg-surface-elevated`,i&&`bg-accent/10`),onClick:()=>!a&&j(e.name),onTouchStart:()=>ee(e.name),onTouchEnd:k,onTouchMove:k,children:[(0,H.jsx)(Hh,{name:e.name,color:n,allNames:m}),(0,H.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[a?(0,H.jsx)(`input`,{type:`text`,value:D,onChange:e=>O(e.target.value),onKeyDown:e=>{e.key===`Enter`&&N(),e.key===`Escape`&&E(null)},onBlur:N,onClick:e=>e.stopPropagation(),className:`w-full bg-transparent border-b border-primary text-sm outline-none`,autoFocus:!0}):(0,H.jsx)(`p`,{className:`text-sm font-medium truncate`,children:e.name}),(0,H.jsx)(`p`,{className:`text-xs text-text-subtle truncate`,children:e.path})]}),i&&(0,H.jsx)(o,{className:`size-4 text-primary shrink-0`})]},e.name)})}),(0,H.jsx)(`div`,{className:`border-t border-border`,children:(0,H.jsxs)(`button`,{onClick:te,className:`w-full flex items-center gap-3 px-4 py-3 text-text-secondary hover:bg-surface-elevated transition-colors`,children:[(0,H.jsx)(Ot,{className:`size-4 shrink-0`}),(0,H.jsx)(`span`,{className:`text-sm`,children:`Add Project`})]})}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-t border-border`,children:[(0,H.jsxs)(`button`,{onClick:M,className:`flex items-center gap-2 text-text-secondary hover:text-foreground transition-colors`,children:[(0,H.jsx)(Pt,{className:`size-4`}),(0,H.jsx)(`span`,{className:`text-sm`,children:`Settings`})]}),f&&(0,H.jsxs)(`span`,{className:`text-xs text-text-subtle`,children:[`v`,f]})]})]}),v&&!S&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`fixed inset-0 z-[60] md:hidden`,onClick:()=>y(null)}),(0,H.jsxs)(`div`,{className:`fixed bottom-0 left-0 right-0 z-[61] md:hidden bg-surface border-t border-border rounded-t-2xl shadow-2xl animate-in slide-in-from-bottom-2 duration-150`,children:[(0,H.jsx)(`div`,{className:`px-4 py-2 border-b border-border`,children:(0,H.jsx)(`p`,{className:`text-xs font-medium text-text-secondary`,children:v})}),F.map(e=>{let t=e.icon;return(0,H.jsxs)(`button`,{onClick:e.onClick,className:R(`w-full flex items-center gap-3 px-4 py-3 text-sm transition-colors active:bg-surface-elevated`,e.destructive?`text-destructive`:`text-foreground`),children:[(0,H.jsx)(t,{className:`size-4 shrink-0`}),e.label]},e.label)})]})]}),S&&v&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`fixed inset-0 z-[60] md:hidden`,onClick:()=>{C(!1),y(null)}}),(0,H.jsxs)(`div`,{className:`fixed bottom-0 left-0 right-0 z-[61] md:hidden bg-surface border-t border-border rounded-t-2xl shadow-2xl p-4 space-y-4`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium`,children:`Change Color`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:kh.map(e=>(0,H.jsx)(`button`,{type:`button`,onClick:()=>x(e),className:R(`size-9 rounded-full border-2 transition-all`,b===e?`border-primary scale-110`:`border-transparent`),style:{background:e}},e))}),(0,H.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,H.jsx)(`button`,{onClick:()=>{C(!1),y(null)},className:`flex-1 py-2 text-sm text-text-secondary border border-border rounded-md`,children:`Cancel`}),(0,H.jsx)(`button`,{onClick:()=>ne(v,b),className:`flex-1 py-2 text-sm bg-primary text-white rounded-md`,children:`Save`})]})]})]})]})}function Wh({onSuccess:e}){let[t,n]=(0,B.useState)(``),r=V(e=>e.deviceName),[i,a]=(0,B.useState)(null),[o,s]=(0,B.useState)(!1);async function l(n){if(n.preventDefault(),t.trim()){s(!0),a(null);try{de(t.trim());let n=await(await fetch(`/api/auth/check`,{headers:{Authorization:`Bearer ${t.trim()}`}})).json();if(!n.ok)throw Error(n.error??`Invalid token`);e()}catch(e){a(e instanceof Error?e.message:`Authentication failed`),localStorage.removeItem(`ppm-auth-token`)}finally{s(!1)}}}return(0,H.jsx)(`div`,{className:`min-h-dvh flex items-center justify-center bg-background p-4`,children:(0,H.jsxs)(`div`,{className:`w-full max-w-sm bg-surface rounded-lg border border-border p-6 space-y-6`,children:[(0,H.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,H.jsx)(`div`,{className:`flex items-center justify-center size-12 mx-auto rounded-full bg-surface-elevated`,children:(0,H.jsx)(mt,{className:`size-6 text-primary`})}),(0,H.jsx)(`h1`,{className:`text-xl font-semibold text-foreground`,children:`PPM`}),r&&(0,H.jsx)(`p`,{className:`text-xs text-text-subtle bg-surface-elevated inline-block px-2 py-0.5 rounded-full`,children:r}),(0,H.jsx)(`p`,{className:`text-sm text-text-secondary`,children:`Enter your access password to unlock`})]}),(0,H.jsxs)(`form`,{onSubmit:l,className:`space-y-4`,children:[(0,H.jsx)(`div`,{children:(0,H.jsx)(u,{type:`password`,placeholder:`Auth token`,value:t,onChange:e=>n(e.target.value),className:`h-11 bg-background border-border`,autoFocus:!0})}),i&&(0,H.jsxs)(`div`,{className:`flex items-center gap-2 text-error text-sm`,children:[(0,H.jsx)(Pe,{className:`size-4 shrink-0`}),(0,H.jsx)(`span`,{children:i})]}),(0,H.jsx)(c,{type:`submit`,disabled:o||!t.trim(),className:`w-full h-11`,children:o?`Checking...`:`Unlock`})]})]})})}function Gh(){let e=window.location.pathname.match(/^\/project\/([^/]+)(?:\/tab\/([^/]+))?/),t=new URLSearchParams(window.location.search).get(`openChat`);return e?{projectName:e[1]?decodeURIComponent(e[1]):null,tabId:e[2]?decodeURIComponent(e[2]):null,openChat:t}:{projectName:null,tabId:null,openChat:t}}function Kh(e,t){if(!e||e===`__global__`)return`/`;let n=`/project/${encodeURIComponent(e)}`;return t&&(n+=`/tab/${encodeURIComponent(t)}`),n}function qh(){let e=_(e=>e.activeTabId),t=_(e=>e.currentProject),n=(0,B.useRef)(!1);(0,B.useEffect)(()=>{if(n.current){n.current=!1;return}let r=Kh(t,e);window.location.pathname!==r&&window.history.pushState(null,``,r)},[e,t]),(0,B.useEffect)(()=>{function e(){let{tabId:e}=Gh(),{tabs:t,setActiveTab:r}=_.getState();e&&t.some(t=>t.id===e)&&(n.current=!0,r(e))}return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[])}var Jh=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
31
31
  <rect width="32" height="32" rx="6" fill="#3b82f6"/>
32
32
  <text x="16" y="22" text-anchor="middle" font-family="system-ui,sans-serif" font-weight="700" font-size="11" fill="white">PPM</text>
33
- </svg>`,qh=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
33
+ </svg>`,Yh=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
34
34
  <rect width="32" height="32" rx="6" fill="#3b82f6"/>
35
35
  <text x="16" y="22" text-anchor="middle" font-family="system-ui,sans-serif" font-weight="700" font-size="11" fill="white">PPM</text>
36
36
  <circle cx="26" cy="6" r="5" fill="#ef4444"/>
37
- </svg>`,Jh=`data:image/svg+xml,${encodeURIComponent(Kh)}`,Yh=`data:image/svg+xml,${encodeURIComponent(qh)}`;function Xh(e){let t=document.getElementById(`ppm-favicon`);t&&(t.href=e?Yh:Jh)}function Zh(e,t,n){let r=[t,n||null,`PPM`].filter(Boolean).join(` - `);return e>0?`(${e}) ${r}`:r}function Qh(){let e=bf(e=>e.activeProject),t=V(e=>e.deviceName);(0,B.useEffect)(()=>{let n=()=>{let n=Hf(Vf.getState());document.title=Zh(n,e?.name,t??void 0),Xh(n>0)};return n(),Vf.subscribe(n)},[e?.name,t])}var $h=1e4,eg=2e3;function tg(){(0,B.useEffect)(()=>{let e=!1,t;async function n(){try{if((await fetch(`/api/health`,{cache:`no-store`})).ok&&e){if(`caches`in window){let e=await caches.keys();await Promise.all(e.map(e=>caches.delete(e)))}window.location.reload();return}e=!1}catch{e=!0}t=setTimeout(n,e?eg:$h)}return t=setTimeout(n,$h),()=>clearTimeout(t)},[])}var ng=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.userAgent);function rg(e){return e?e.replace(/Mod\+/g,ng?`⌘`:`Ctrl+`).replace(/Alt\+/g,ng?`⌥`:`Alt+`).replace(/Shift\+/g,ng?`⇧`:`Shift+`).replace(/Meta\+/g,`⌘`).replace(/Ctrl\+/g,ng?`⌃`:`Ctrl+`):``}function ig(e){let t=[];for(let n of e)n.type===`file`&&t.push({name:n.name,path:n.path}),n.children&&t.push(...ig(n.children));return t}function ag(e){return e?e.startsWith(`/`)||e.startsWith(`~/`)||e.startsWith(`~\\`)||/^[A-Za-z]:[/\\]/.test(e):!1}function og(e){let t=e.replace(/\\/g,`/`);if(t.endsWith(`/`))return e;let n=Math.max(t.lastIndexOf(`/`),e.lastIndexOf(`\\`));return n>0?e.slice(0,n+1):e}var sg=new Map;function cg({open:e,onClose:t,initialQuery:n=``}){let[r,i]=(0,B.useState)(``),[a,o]=(0,B.useState)(0),[s,c]=(0,B.useState)([]),[l,u]=(0,B.useState)(!1),[d,f]=(0,B.useState)([]),p=(0,B.useRef)(null),m=(0,B.useRef)(null),h=_(e=>e.openTab),g=bf(e=>e.activeProject),v=cp(e=>e.tree),y=V(e=>e.setSidebarActiveTab),b=V(e=>e.sidebarCollapsed),x=V(e=>e.toggleSidebar),S=Ff(e=>e.getBinding),C=(0,B.useCallback)(async e=>{if(sg.has(e)){c(sg.get(e));return}u(!0);try{let t=await z.get(`/api/fs/list?dir=${encodeURIComponent(e)}`);sg.set(e,t),c(t)}catch{c([])}finally{u(!1)}},[]);(0,B.useEffect)(()=>{if(!ag(r)){c([]);return}C(og(r))},[r,C]),(0,B.useEffect)(()=>{if(ag(r)||r.trim().length<2){f([]);return}let e=setTimeout(async()=>{try{f(await z.get(`/api/db/search?q=${encodeURIComponent(r.trim())}`)??[])}catch{f([])}},300);return()=>clearTimeout(e)},[r]);let w=(0,B.useMemo)(()=>{let e=g?.name??null,n=g?{projectName:g.name}:void 0,r=(r,i)=>()=>{h({type:r,title:i,projectId:e,metadata:n,closable:!0}),t()};return[{id:`chat`,label:`New AI Chat`,icon:_t,action:r(`chat`,`AI Chat`),keywords:`ai assistant claude`,group:`action`,shortcut:rg(S(`open-chat`))},{id:`terminal`,label:`New Terminal`,icon:Rt,action:r(`terminal`,`Terminal`),keywords:`bash shell console`,group:`action`,shortcut:rg(S(`open-terminal`))},{id:`git-graph`,label:`Git Graph`,icon:nt,action:r(`git-graph`,`Git Graph`),keywords:`branch history log`,group:`action`,shortcut:rg(S(`open-git-graph`))},{id:`browser`,label:`Open Browser`,icon:it,action:r(`browser`,`Browser`),keywords:`web preview localhost iframe url`,group:`action`},{id:`postgres`,label:`PostgreSQL`,icon:He,action:r(`postgres`,`PostgreSQL`),keywords:`database pg sql query`,group:`action`},{id:`voice-input`,label:`Voice Input`,icon:vt,action:()=>{window.dispatchEvent(new CustomEvent(`toggle-voice-input`)),t()},keywords:`speech microphone dictate voice`,group:`action`,shortcut:rg(S(`voice-input`))},{id:`git-status`,label:`Git Status`,icon:rt,action:()=>{y(`git`),t()},keywords:`changes diff staged`,group:`action`,shortcut:rg(S(`open-git-status`))},{id:`settings`,label:`Settings`,icon:Pt,action:()=>{b&&x(),y(`settings`),t()},keywords:`config preferences theme`,group:`action`,shortcut:rg(S(`open-settings`))}]},[g,h,t,y,b,x,S]),T=(0,B.useMemo)(()=>{let e=g?.name??null,n=g?{projectName:g.name}:void 0;return ig(v).map(r=>({id:`file:${r.path}`,label:r.name,hint:r.path,icon:Je,group:`file`,keywords:r.path,action:()=>{h({type:`editor`,title:r.name,projectId:e,metadata:{...n,filePath:r.path},closable:!0}),t()}}))},[v,g,h,t]),E=(0,B.useMemo)(()=>{let e=g?.name??null,n=g?{projectName:g.name}:void 0;return s.map(r=>{let i=ue(r);return{id:`fs:${r}`,label:i,hint:r,icon:$e,group:`fs`,keywords:r,action:()=>{h({type:`editor`,title:i,projectId:e,metadata:{...n,filePath:r},closable:!0}),t()}}})},[s,g,h,t]),D=(0,B.useMemo)(()=>d.map(e=>({id:`db:${e.connectionId}:${e.schemaName}.${e.tableName}`,label:e.tableName,hint:`${e.connectionName} (${e.connectionType===`postgres`?`PG`:`SQLite`})`,icon:He,group:`db`,connectionColor:e.connectionColor,action:()=>{h({type:`database`,title:`${e.connectionName} · ${e.tableName}`,projectId:null,closable:!0,metadata:{connectionId:e.connectionId,connectionName:e.connectionName,dbType:e.connectionType,tableName:e.tableName,schemaName:e.schemaName,connectionColor:e.connectionColor}}),t()}})),[d,h,t]),O=(0,B.useMemo)(()=>[...w,...T],[w,T]),ee=(0,B.useMemo)(()=>{if(ag(r)){let e=r.lastIndexOf(`/`),t=e>=0?r.slice(e+1).toLowerCase():``;return t?E.filter(e=>{let n=e.label.toLowerCase(),r=(e.keywords??``).toLowerCase();return n.includes(t)||r.includes(t)}).slice(0,50):E.slice(0,50)}if(!r.trim())return w;let e=r.toLowerCase(),t=t=>{let n=0;for(let r=0;r<e.length;r++){if(n=t.indexOf(e[r],n),n===-1)return!1;n++}return!0},n=O.filter(e=>t(e.label.toLowerCase())||e.keywords&&t(e.keywords.toLowerCase()));return r.trim().length>=2?[...D,...n]:n},[O,w,E,D,r]);(0,B.useEffect)(()=>{e&&(i(n||``),o(0),c([]),f([]),requestAnimationFrame(()=>p.current?.focus()))},[e]),(0,B.useEffect)(()=>{o(e=>Math.min(e,Math.max(ee.length-1,0)))},[ee.length]),(0,B.useEffect)(()=>{let e=m.current;e&&e.children[a]?.scrollIntoView({block:`nearest`})},[a]);let k=(0,B.useCallback)(()=>{r.trim()&&(h({type:`chat`,title:`AI Chat`,projectId:g?.name??null,metadata:{projectName:g?.name,pendingMessage:r.trim()},closable:!0}),t())},[r,g,h,t]);function A(e){let n=ee.length;switch(e.key){case`ArrowDown`:e.preventDefault(),n>0&&o(e=>(e+1)%n);break;case`ArrowUp`:e.preventDefault(),n>0&&o(e=>(e-1+n)%n);break;case`Enter`:e.preventDefault(),n>0?ee[a]?.action():r.trim()&&k();break;case`Escape`:e.preventDefault(),t();break}}if(!e)return null;let j=ag(r);return(0,H.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-end md:items-start justify-center md:pt-[20vh]`,onClick:t,children:[(0,H.jsx)(`div`,{className:`fixed inset-0 bg-black/50`}),(0,H.jsxs)(`div`,{className:`relative z-10 w-full max-w-md rounded-t-xl md:rounded-xl border border-border bg-background shadow-2xl overflow-hidden max-h-[80vh] md:max-h-none`,onClick:e=>e.stopPropagation(),onKeyDown:A,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3 py-2.5`,children:[(0,H.jsx)(Mt,{className:`size-4 text-text-subtle shrink-0`}),(0,H.jsx)(`input`,{ref:p,type:`text`,value:r,onChange:e=>i(e.target.value),placeholder:`Search actions & files... (type / or ~/ for filesystem)`,className:`flex-1 bg-transparent text-sm text-text-primary outline-none placeholder:text-text-subtle`}),l&&(0,H.jsx)(pt,{className:`size-3.5 animate-spin text-text-subtle shrink-0`}),(0,H.jsx)(`kbd`,{className:`hidden sm:inline-flex items-center rounded border border-border bg-surface px-1.5 py-0.5 text-[10px] text-text-subtle font-mono`,children:`ESC`})]}),j&&!l&&s.length===0&&r.length<4&&(0,H.jsx)(`div`,{className:`px-3 py-2 text-xs text-text-subtle border-b border-border/50`,children:`Type a directory path to browse files (e.g. ~/Projects/)`}),(0,H.jsx)(`div`,{ref:m,className:`max-h-72 overflow-y-auto py-1`,children:ee.length===0?l?(0,H.jsx)(`p`,{className:`px-3 py-4 text-sm text-text-subtle text-center`,children:`Searching...`}):r.trim()?(0,H.jsxs)(`button`,{onClick:k,className:`flex items-center gap-3 w-full px-3 py-3 text-sm text-left text-text-secondary hover:bg-accent/15 hover:text-text-primary transition-colors`,children:[(0,H.jsx)(_t,{className:`size-4 shrink-0 text-accent`}),(0,H.jsxs)(`span`,{children:[`Ask AI: `,(0,H.jsx)(`span`,{className:`text-text-primary font-medium`,children:r.trim().slice(0,60)})]})]}):(0,H.jsx)(`p`,{className:`px-3 py-4 text-sm text-text-subtle text-center`,children:`No results`}):ee.map((e,t)=>{let n=e.icon;return(0,H.jsxs)(`button`,{onClick:e.action,className:`flex items-center gap-3 w-full px-3 py-2 text-sm text-left transition-colors ${t===a?`bg-accent/15 text-text-primary`:`text-text-secondary hover:bg-surface-elevated`}`,children:[(0,H.jsx)(n,{className:`size-4 shrink-0`}),(0,H.jsx)(`span`,{className:`truncate`,children:e.label}),e.hint&&(0,H.jsxs)(`span`,{className:`ml-auto flex items-center gap-1.5 text-xs text-text-subtle truncate max-w-[200px]`,children:[e.connectionColor&&(0,H.jsx)(`span`,{className:`shrink-0 size-2 rounded-full`,style:{backgroundColor:e.connectionColor}}),e.hint]}),e.shortcut&&(0,H.jsx)(`kbd`,{className:`ml-auto shrink-0 rounded border border-border bg-surface px-1.5 py-0.5 text-[10px] text-text-subtle font-mono`,children:e.shortcut})]},e.id)})}),(0,H.jsxs)(`div`,{className:`flex items-center justify-center gap-1.5 border-t border-border px-3 py-1.5`,children:[(0,H.jsx)(`span`,{className:`text-[10px] text-text-subtle`,children:`Press`}),(0,H.jsx)(`kbd`,{className:`inline-flex items-center rounded border border-border bg-surface px-1 py-0.5 text-[10px] text-text-subtle font-mono`,children:`Shift`}),(0,H.jsx)(`kbd`,{className:`inline-flex items-center rounded border border-border bg-surface px-1 py-0.5 text-[10px] text-text-subtle font-mono`,children:`Shift`}),(0,H.jsx)(`span`,{className:`text-[10px] text-text-subtle`,children:`to open this palette`})]})]})]})}function lg(){let[e,t]=(0,B.useState)(null),[n,r]=(0,B.useState)(!1);(0,B.useEffect)(()=>{function e(e){let n=e.detail;n&&(t(n),r(!1))}return window.addEventListener(`open-bug-report`,e),()=>window.removeEventListener(`open-bug-report`,e)},[]);let i=(0,B.useCallback)(()=>t(null),[]);return e?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`fixed inset-0 z-50 bg-black/50`,onClick:i}),(0,H.jsxs)(`div`,{className:`fixed inset-4 md:inset-auto md:top-[15%] md:left-1/2 md:-translate-x-1/2 md:w-full md:max-w-lg md:max-h-[70vh] z-50 flex flex-col bg-background border border-border rounded-lg shadow-2xl overflow-hidden`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b border-border`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`Bug Report`}),(0,H.jsx)(`button`,{onClick:i,className:`p-1 rounded hover:bg-surface-elevated`,children:(0,H.jsx)(Gt,{className:`size-4`})})]}),(0,H.jsx)(`pre`,{className:`flex-1 overflow-auto px-4 py-2 text-xs font-mono whitespace-pre-wrap break-all`,children:e}),(0,H.jsxs)(`div`,{className:`flex gap-2 p-3 border-t border-border`,children:[(0,H.jsxs)(`button`,{onClick:async()=>{await Th(e)&&r(!0)},className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-surface-elevated text-xs text-foreground hover:bg-surface transition-colors`,children:[n?(0,H.jsx)(o,{className:`size-3`}):(0,H.jsx)(Ve,{className:`size-3`}),n?`Copied`:`Copy`]}),(0,H.jsxs)(`button`,{onClick:()=>{wh(e),i()},className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-primary text-primary-foreground text-xs hover:bg-primary/90 transition-colors`,children:[(0,H.jsx)(h,{className:`size-3`}),`Open GitHub Issue`]})]})]})]}):null}var ug=6e4,dg=`ppm-upgrade-dismissed-`;function fg(){let[e,t]=(0,B.useState)(null),[n,r]=(0,B.useState)(!1),[i,a]=(0,B.useState)(!1);(0,B.useEffect)(()=>{let e;async function n(){try{let e=await z.get(`/api/upgrade`);if(e.availableVersion){t(e.availableVersion);let n=dg+e.availableVersion;sessionStorage.getItem(n)?a(!0):a(!1)}else t(null)}catch{}}return n(),e=setInterval(n,ug),()=>clearInterval(e)},[]);let o=(0,B.useCallback)(async()=>{r(!0);try{await z.post(`/api/upgrade/apply`)}catch(e){fn.error(`Upgrade failed: ${e.message}`),r(!1)}},[]),s=(0,B.useCallback)(()=>{e&&sessionStorage.setItem(dg+e,`1`),a(!0)},[e]);return!e||i?null:(0,H.jsx)(`div`,{className:`w-full bg-blue-600 dark:bg-blue-700 text-white px-3 py-2 flex items-center justify-between gap-2 z-50 text-sm shrink-0`,children:n?(0,H.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:[(0,H.jsx)(pt,{className:`size-4 animate-spin shrink-0`}),(0,H.jsxs)(`span`,{className:`truncate`,children:[`Upgrading to v`,e,`... PPM will restart shortly`]})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:[(0,H.jsx)(Fe,{className:`size-4 shrink-0`}),(0,H.jsxs)(`span`,{className:`truncate`,children:[`PPM v`,e,` available`]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,H.jsx)(`button`,{onClick:o,className:`bg-white text-blue-600 font-medium rounded-full px-3 min-h-[44px] min-w-[44px] flex items-center justify-center hover:bg-blue-50 active:bg-blue-100 transition-colors`,children:`Upgrade`}),(0,H.jsx)(`button`,{onClick:s,className:`min-h-[44px] min-w-[44px] flex items-center justify-center rounded-full hover:bg-blue-500 active:bg-blue-800 transition-colors`,"aria-label":`Dismiss upgrade notification`,children:(0,H.jsx)(Gt,{className:`size-4`})})]})]})})}var pg=v(e=>({src:null,alt:``,open:(t,n=``)=>e({src:t,alt:n}),close:()=>e({src:null,alt:``})}));function mg(){let{src:e,alt:t,close:n}=pg(),r=(0,B.useCallback)(e=>{e.key===`Escape`&&n()},[n]);return(0,B.useEffect)(()=>{if(e)return document.addEventListener(`keydown`,r),()=>document.removeEventListener(`keydown`,r)},[e,r]),e?(0,H.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center bg-black/80 backdrop-blur-sm animate-in fade-in duration-150`,onClick:n,children:[(0,H.jsx)(`button`,{onClick:n,className:`absolute top-4 right-4 z-10 flex items-center justify-center size-8 rounded-full bg-white/10 hover:bg-white/20 text-white transition-colors`,"aria-label":`Close`,children:(0,H.jsx)(Gt,{className:`size-5`})}),(0,H.jsx)(`img`,{src:e,alt:t,className:`max-w-[90vw] max-h-[90vh] object-contain rounded-lg shadow-2xl`,onClick:e=>e.stopPropagation()})]}):null}var hg=v(e=>({svg:null,open:t=>e({svg:t}),close:()=>e({svg:null})})),gg=.25,_g=4,vg=.25;function yg(){let{svg:e,close:t}=hg(),n=(0,B.useRef)(null),[r,i]=(0,B.useState)(1),[a,o]=(0,B.useState)({x:0,y:0}),s=(0,B.useRef)(!1),c=(0,B.useRef)({x:0,y:0});(0,B.useEffect)(()=>{e&&(i(1),o({x:0,y:0}))},[e]);let u=(0,B.useCallback)(e=>{e.key===`Escape`&&t(),(e.key===`=`||e.key===`+`)&&i(e=>Math.min(_g,e+vg)),e.key===`-`&&i(e=>Math.max(gg,e-vg)),e.key===`0`&&(i(1),o({x:0,y:0}))},[t]);(0,B.useEffect)(()=>{if(e)return document.addEventListener(`keydown`,u),()=>document.removeEventListener(`keydown`,u)},[e,u]);let d=(0,B.useCallback)(e=>{e.preventDefault();let t=e.deltaY>0?-vg:vg;i(e=>Math.min(_g,Math.max(gg,e+t)))},[]),f=(0,B.useCallback)(e=>{e.button===0&&(s.current=!0,c.current={x:e.clientX,y:e.clientY},e.target.setPointerCapture(e.pointerId))},[]),p=(0,B.useCallback)(e=>{if(!s.current)return;let t=e.clientX-c.current.x,n=e.clientY-c.current.y;c.current={x:e.clientX,y:e.clientY},o(e=>({x:e.x+t,y:e.y+n}))},[]),m=(0,B.useCallback)(()=>{s.current=!1},[]);return e?(0,H.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex flex-col bg-black/85 backdrop-blur-sm animate-in fade-in duration-150`,onClick:t,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 bg-black/40`,onClick:e=>e.stopPropagation(),children:[(0,H.jsxs)(`span`,{className:`text-sm text-white/70`,children:[Math.round(r*100),`% — Scroll to zoom, drag to pan, 0 to reset`]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`button`,{onClick:()=>i(e=>Math.max(gg,e-vg)),className:`flex items-center justify-center size-8 rounded bg-white/10 hover:bg-white/20 text-white transition-colors`,"aria-label":`Zoom out`,children:(0,H.jsx)(qt,{className:`size-4`})}),(0,H.jsx)(`button`,{onClick:()=>i(e=>Math.min(_g,e+vg)),className:`flex items-center justify-center size-8 rounded bg-white/10 hover:bg-white/20 text-white transition-colors`,"aria-label":`Zoom in`,children:(0,H.jsx)(Kt,{className:`size-4`})}),(0,H.jsx)(`button`,{onClick:()=>{i(1),o({x:0,y:0})},className:`flex items-center justify-center size-8 rounded bg-white/10 hover:bg-white/20 text-white transition-colors`,"aria-label":`Reset zoom`,children:(0,H.jsx)(l,{className:`size-4`})}),(0,H.jsx)(`button`,{onClick:t,className:`flex items-center justify-center size-8 rounded bg-white/10 hover:bg-white/20 text-white transition-colors ml-2`,"aria-label":`Close`,children:(0,H.jsx)(Gt,{className:`size-5`})})]})]}),(0,H.jsx)(`div`,{ref:n,className:`flex-1 overflow-hidden cursor-grab active:cursor-grabbing`,onClick:e=>e.stopPropagation(),onWheel:d,onPointerDown:f,onPointerMove:p,onPointerUp:m,children:(0,H.jsx)(`div`,{className:`w-full h-full flex items-center justify-center`,style:{transform:`translate(${a.x}px, ${a.y}px) scale(${r})`,transformOrigin:`center center`},children:(0,H.jsx)(`div`,{className:`mermaid-overlay-content bg-white rounded-lg p-6 shadow-2xl [&_svg]:max-w-full [&_svg]:h-auto`,dangerouslySetInnerHTML:{__html:e}})})})]}):null}function bg(){let[e,t]=(0,B.useState)(`checking`),[n,r]=(0,B.useState)(!1),[i,a]=(0,B.useState)(),[o,s]=(0,B.useState)(!1);(0,B.useEffect)(()=>{let e=()=>{a(`settings`),r(!0)};return window.addEventListener(`open-mobile-settings`,e),()=>window.removeEventListener(`open-mobile-settings`,e)},[]);let[c,l]=(0,B.useState)(()=>new Set([`__global__`])),u=V(e=>e.theme),d=V(e=>e.deviceName),f=bf(e=>e.fetchProjects),p=V(e=>e.fetchServerInfo),m=bf(e=>e.activeProject),h=(0,B.useRef)(Uh());(0,B.useEffect)(()=>{if(jn(u),u===`system`){let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>jn(`system`);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)}},[u]),(0,B.useEffect)(()=>{p()},[p]),(0,B.useEffect)(()=>{async function e(){let e=pe();try{let n={};e&&(n.Authorization=`Bearer ${e}`),(await(await fetch(`/api/auth/check`,{headers:n})).json()).ok?t(`authenticated`):t(`unauthenticated`)}catch{t(`unauthenticated`)}}e()},[]),Gh();let{paletteOpen:g,paletteInitialQuery:v,closePalette:b}=Lf();Qh(),tg(),(0,B.useEffect)(()=>{if(e!==`authenticated`)return;let t=e=>{e.preventDefault()};return window.addEventListener(`beforeunload`,t),()=>window.removeEventListener(`beforeunload`,t)},[e]),(0,B.useEffect)(()=>{e===`authenticated`&&y(async()=>{let{useKeybindingsStore:e}=await import(`./keybindings-store-DiM6OAOI.js`);return{useKeybindingsStore:e}},__vite__mapDeps([52,6,1,2])).then(({useKeybindingsStore:e})=>{e.getState().loadFromServer()})},[e]),(0,B.useEffect)(()=>{e===`authenticated`&&f().then(()=>{let{projectName:e,tabId:t,openChat:n}=h.current,{projects:r,customOrder:i}=bf.getState();if(r.length===0)return;let a=e?r.find(t=>t.name===e):void 0;a||=yf(r,i)[0],a&&(bf.getState().setActiveProject(a),e&&t&&queueMicrotask(()=>{let{tabs:e}=_.getState();e.some(e=>e.id===t)&&_.getState().setActiveTab(t)})),n&&queueMicrotask(()=>{let{tabs:e,setActiveTab:t,openTab:r}=_.getState(),i=e.find(e=>e.type===`chat`&&e.metadata?.sessionId===n);i?t(i.id):r({type:`chat`,title:`Chat`,projectId:a?.name??null,closable:!0,metadata:{sessionId:n}});let o=new URL(window.location.href);o.searchParams.delete(`openChat`),window.history.replaceState(null,``,o.pathname)})})},[e,f]),(0,B.useEffect)(()=>{let e=m?.name??`__global__`;_.getState().switchProject(e)},[m?.name]),(0,B.useEffect)(()=>{let e=m?.name??`__global__`;l(t=>t.has(e)?t:new Set([...t,e]))},[m?.name]),(0,B.useEffect)(()=>{e===`authenticated`&&!m&&_.getState().switchProject(`__global__`)},[e,m]);let x=(0,B.useCallback)(()=>{t(`authenticated`)},[]);if(e===`checking`)return(0,H.jsx)(`div`,{className:`min-h-dvh flex items-center justify-center bg-background`,children:(0,H.jsx)(`div`,{className:`animate-pulse text-text-secondary text-sm`,children:`Loading...`})});if(e===`unauthenticated`)return(0,H.jsx)(Hh,{onSuccess:x});let S=m?.name??`__global__`;return(0,H.jsx)(Su,{children:(0,H.jsxs)(`div`,{className:`h-dvh flex flex-col bg-background text-foreground overflow-hidden relative`,children:[(0,H.jsx)(fg,{}),d&&(0,H.jsx)(`div`,{className:`md:hidden fixed top-0 left-0 z-50 px-2 py-0.5 bg-primary/80 text-primary-foreground text-[10px] font-medium rounded-br`,children:d}),(0,H.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,H.jsx)(Nh,{}),(0,H.jsx)(Km,{}),[...c].map(e=>(0,H.jsx)(`div`,{className:R(`flex-1 overflow-hidden pb-12 md:pb-0`,S!==e&&`hidden`),children:(0,H.jsx)(ip,{projectName:e})},e))]}),(0,H.jsx)(Lh,{onMenuPress:()=>r(!0),onProjectsPress:()=>s(!0)}),(0,H.jsx)(zh,{isOpen:n,onClose:()=>{r(!1),a(void 0)},initialTab:i}),(0,H.jsx)(Vh,{isOpen:o,onClose:()=>s(!1)}),(0,H.jsx)(cg,{open:g,onClose:b,initialQuery:v}),(0,H.jsx)(lg,{}),(0,H.jsx)(mg,{}),(0,H.jsx)(yg,{}),(0,H.jsx)(Nn,{position:`bottom-left`,closeButton:!0,toastOptions:{className:`bg-surface border-border text-foreground`}})]})})}(0,Jt.createRoot)(document.getElementById(`root`)).render((0,H.jsx)(B.StrictMode,{children:(0,H.jsx)(bg,{})}));export{Ze as $,Pf as A,Mt as B,mp as C,Vf as D,cp as E,Gt as F,vt as G,Ot as H,Ut as I,pt as J,_t as K,zt as L,Ff as M,bf as N,If as O,V as P,Qe as Q,Rt as R,pp as S,fp as T,Dt as U,kt as V,Et as W,nt as X,it as Y,tt as Z,Cp as _,um as a,He as at,Sp as b,kp as c,Ie as ct,Np as d,Me as dt,Xe as et,Fp as f,ke as ft,yp as g,gp as h,vm as i,Ue as it,Nf as j,kf as k,jp as l,Pe as lt,Ap as m,Te as mt,pg as n,qe as nt,im as o,Ve as ot,Pp as p,Ee as pt,mt as q,Eh as r,Ke as rt,qp as s,Le as st,hg as t,Je as tt,Mp as u,Ne as ut,xp as v,hp as w,dp as x,bp as y,Pt as z};
37
+ </svg>`,Xh=`data:image/svg+xml,${encodeURIComponent(Jh)}`,Zh=`data:image/svg+xml,${encodeURIComponent(Yh)}`;function Qh(e){let t=document.getElementById(`ppm-favicon`);t&&(t.href=e?Zh:Xh)}function $h(e,t,n){let r=[t,n||null,`PPM`].filter(Boolean).join(` - `);return e>0?`(${e}) ${r}`:r}function eg(){let e=bf(e=>e.activeProject),t=V(e=>e.deviceName);(0,B.useEffect)(()=>{let n=()=>{let n=Hf(Vf.getState());document.title=$h(n,e?.name,t??void 0),Qh(n>0)};return n(),Vf.subscribe(n)},[e?.name,t])}var tg=1e4,ng=2e3;function rg(){(0,B.useEffect)(()=>{let e=!1,t;async function n(){try{if((await fetch(`/api/health`,{cache:`no-store`})).ok&&e){if(`caches`in window){let e=await caches.keys();await Promise.all(e.map(e=>caches.delete(e)))}window.location.reload();return}e=!1}catch{e=!0}t=setTimeout(n,e?ng:tg)}return t=setTimeout(n,tg),()=>clearTimeout(t)},[])}var ig=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.userAgent);function ag(e){return e?e.replace(/Mod\+/g,ig?`⌘`:`Ctrl+`).replace(/Alt\+/g,ig?`⌥`:`Alt+`).replace(/Shift\+/g,ig?`⇧`:`Shift+`).replace(/Meta\+/g,`⌘`).replace(/Ctrl\+/g,ig?`⌃`:`Ctrl+`):``}function og(e){let t=[];for(let n of e)n.type===`file`&&t.push({name:n.name,path:n.path}),n.children&&t.push(...og(n.children));return t}function sg(e){return e?e.startsWith(`/`)||e.startsWith(`~/`)||e.startsWith(`~\\`)||/^[A-Za-z]:[/\\]/.test(e):!1}function cg(e){let t=e.replace(/\\/g,`/`);if(t.endsWith(`/`))return e;let n=Math.max(t.lastIndexOf(`/`),e.lastIndexOf(`\\`));return n>0?e.slice(0,n+1):e}var lg=new Map;function ug({open:e,onClose:t,initialQuery:n=``}){let[r,i]=(0,B.useState)(``),[a,o]=(0,B.useState)(0),[s,c]=(0,B.useState)([]),[l,u]=(0,B.useState)(!1),[d,f]=(0,B.useState)([]),p=(0,B.useRef)(null),m=(0,B.useRef)(null),h=_(e=>e.openTab),g=bf(e=>e.activeProject),v=up(e=>e.tree),y=V(e=>e.setSidebarActiveTab),b=V(e=>e.sidebarCollapsed),x=V(e=>e.toggleSidebar),S=Ff(e=>e.getBinding),C=(0,B.useCallback)(async e=>{if(lg.has(e)){c(lg.get(e));return}u(!0);try{let t=await z.get(`/api/fs/list?dir=${encodeURIComponent(e)}`);lg.set(e,t),c(t)}catch{c([])}finally{u(!1)}},[]);(0,B.useEffect)(()=>{if(!sg(r)){c([]);return}C(cg(r))},[r,C]),(0,B.useEffect)(()=>{if(sg(r)||r.trim().length<2){f([]);return}let e=setTimeout(async()=>{try{f(await z.get(`/api/db/search?q=${encodeURIComponent(r.trim())}`)??[])}catch{f([])}},300);return()=>clearTimeout(e)},[r]);let w=(0,B.useMemo)(()=>{let e=g?.name??null,n=g?{projectName:g.name}:void 0,r=(r,i)=>()=>{h({type:r,title:i,projectId:e,metadata:n,closable:!0}),t()};return[{id:`chat`,label:`New AI Chat`,icon:_t,action:r(`chat`,`AI Chat`),keywords:`ai assistant claude`,group:`action`,shortcut:ag(S(`open-chat`))},{id:`terminal`,label:`New Terminal`,icon:Rt,action:r(`terminal`,`Terminal`),keywords:`bash shell console`,group:`action`,shortcut:ag(S(`open-terminal`))},{id:`git-graph`,label:`Git Graph`,icon:nt,action:r(`git-graph`,`Git Graph`),keywords:`branch history log`,group:`action`,shortcut:ag(S(`open-git-graph`))},{id:`browser`,label:`Open Browser`,icon:it,action:r(`browser`,`Browser`),keywords:`web preview localhost iframe url`,group:`action`},{id:`postgres`,label:`PostgreSQL`,icon:He,action:r(`postgres`,`PostgreSQL`),keywords:`database pg sql query`,group:`action`},{id:`voice-input`,label:`Voice Input`,icon:vt,action:()=>{window.dispatchEvent(new CustomEvent(`toggle-voice-input`)),t()},keywords:`speech microphone dictate voice`,group:`action`,shortcut:ag(S(`voice-input`))},{id:`git-status`,label:`Git Status`,icon:rt,action:()=>{y(`git`),t()},keywords:`changes diff staged`,group:`action`,shortcut:ag(S(`open-git-status`))},{id:`settings`,label:`Settings`,icon:Pt,action:()=>{b&&x(),y(`settings`),t()},keywords:`config preferences theme`,group:`action`,shortcut:ag(S(`open-settings`))}]},[g,h,t,y,b,x,S]),T=(0,B.useMemo)(()=>{let e=g?.name??null,n=g?{projectName:g.name}:void 0;return og(v).map(r=>({id:`file:${r.path}`,label:r.name,hint:r.path,icon:Je,group:`file`,keywords:r.path,action:()=>{h({type:`editor`,title:r.name,projectId:e,metadata:{...n,filePath:r.path},closable:!0}),t()}}))},[v,g,h,t]),E=(0,B.useMemo)(()=>{let e=g?.name??null,n=g?{projectName:g.name}:void 0;return s.map(r=>{let i=ue(r);return{id:`fs:${r}`,label:i,hint:r,icon:$e,group:`fs`,keywords:r,action:()=>{h({type:`editor`,title:i,projectId:e,metadata:{...n,filePath:r},closable:!0}),t()}}})},[s,g,h,t]),D=(0,B.useMemo)(()=>d.map(e=>({id:`db:${e.connectionId}:${e.schemaName}.${e.tableName}`,label:e.tableName,hint:`${e.connectionName} (${e.connectionType===`postgres`?`PG`:`SQLite`})`,icon:He,group:`db`,connectionColor:e.connectionColor,action:()=>{h({type:`database`,title:`${e.connectionName} · ${e.tableName}`,projectId:null,closable:!0,metadata:{connectionId:e.connectionId,connectionName:e.connectionName,dbType:e.connectionType,tableName:e.tableName,schemaName:e.schemaName,connectionColor:e.connectionColor}}),t()}})),[d,h,t]),O=(0,B.useMemo)(()=>[...w,...T],[w,T]),ee=(0,B.useMemo)(()=>{if(sg(r)){let e=r.lastIndexOf(`/`),t=e>=0?r.slice(e+1).toLowerCase():``;return t?E.filter(e=>{let n=e.label.toLowerCase(),r=(e.keywords??``).toLowerCase();return n.includes(t)||r.includes(t)}).slice(0,50):E.slice(0,50)}if(!r.trim())return w;let e=r.toLowerCase(),t=t=>{let n=0;for(let r=0;r<e.length;r++){if(n=t.indexOf(e[r],n),n===-1)return!1;n++}return!0},n=O.filter(e=>t(e.label.toLowerCase())||e.keywords&&t(e.keywords.toLowerCase()));return r.trim().length>=2?[...D,...n]:n},[O,w,E,D,r]);(0,B.useEffect)(()=>{e&&(i(n||``),o(0),c([]),f([]),requestAnimationFrame(()=>p.current?.focus()))},[e]),(0,B.useEffect)(()=>{o(e=>Math.min(e,Math.max(ee.length-1,0)))},[ee.length]),(0,B.useEffect)(()=>{let e=m.current;e&&e.children[a]?.scrollIntoView({block:`nearest`})},[a]);let k=(0,B.useCallback)(()=>{r.trim()&&(h({type:`chat`,title:`AI Chat`,projectId:g?.name??null,metadata:{projectName:g?.name,pendingMessage:r.trim()},closable:!0}),t())},[r,g,h,t]);function A(e){let n=ee.length;switch(e.key){case`ArrowDown`:e.preventDefault(),n>0&&o(e=>(e+1)%n);break;case`ArrowUp`:e.preventDefault(),n>0&&o(e=>(e-1+n)%n);break;case`Enter`:e.preventDefault(),n>0?ee[a]?.action():r.trim()&&k();break;case`Escape`:e.preventDefault(),t();break}}if(!e)return null;let j=sg(r);return(0,H.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-end md:items-start justify-center md:pt-[20vh]`,onClick:t,children:[(0,H.jsx)(`div`,{className:`fixed inset-0 bg-black/50`}),(0,H.jsxs)(`div`,{className:`relative z-10 w-full max-w-md rounded-t-xl md:rounded-xl border border-border bg-background shadow-2xl overflow-hidden max-h-[80vh] md:max-h-none`,onClick:e=>e.stopPropagation(),onKeyDown:A,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3 py-2.5`,children:[(0,H.jsx)(Mt,{className:`size-4 text-text-subtle shrink-0`}),(0,H.jsx)(`input`,{ref:p,type:`text`,value:r,onChange:e=>i(e.target.value),placeholder:`Search actions & files... (type / or ~/ for filesystem)`,className:`flex-1 bg-transparent text-sm text-text-primary outline-none placeholder:text-text-subtle`}),l&&(0,H.jsx)(pt,{className:`size-3.5 animate-spin text-text-subtle shrink-0`}),(0,H.jsx)(`kbd`,{className:`hidden sm:inline-flex items-center rounded border border-border bg-surface px-1.5 py-0.5 text-[10px] text-text-subtle font-mono`,children:`ESC`})]}),j&&!l&&s.length===0&&r.length<4&&(0,H.jsx)(`div`,{className:`px-3 py-2 text-xs text-text-subtle border-b border-border/50`,children:`Type a directory path to browse files (e.g. ~/Projects/)`}),(0,H.jsx)(`div`,{ref:m,className:`max-h-72 overflow-y-auto py-1`,children:ee.length===0?l?(0,H.jsx)(`p`,{className:`px-3 py-4 text-sm text-text-subtle text-center`,children:`Searching...`}):r.trim()?(0,H.jsxs)(`button`,{onClick:k,className:`flex items-center gap-3 w-full px-3 py-3 text-sm text-left text-text-secondary hover:bg-accent/15 hover:text-text-primary transition-colors`,children:[(0,H.jsx)(_t,{className:`size-4 shrink-0 text-accent`}),(0,H.jsxs)(`span`,{children:[`Ask AI: `,(0,H.jsx)(`span`,{className:`text-text-primary font-medium`,children:r.trim().slice(0,60)})]})]}):(0,H.jsx)(`p`,{className:`px-3 py-4 text-sm text-text-subtle text-center`,children:`No results`}):ee.map((e,t)=>{let n=e.icon;return(0,H.jsxs)(`button`,{onClick:e.action,className:`flex items-center gap-3 w-full px-3 py-2 text-sm text-left transition-colors ${t===a?`bg-accent/15 text-text-primary`:`text-text-secondary hover:bg-surface-elevated`}`,children:[(0,H.jsx)(n,{className:`size-4 shrink-0`}),(0,H.jsx)(`span`,{className:`truncate`,children:e.label}),e.hint&&(0,H.jsxs)(`span`,{className:`ml-auto flex items-center gap-1.5 text-xs text-text-subtle truncate max-w-[200px]`,children:[e.connectionColor&&(0,H.jsx)(`span`,{className:`shrink-0 size-2 rounded-full`,style:{backgroundColor:e.connectionColor}}),e.hint]}),e.shortcut&&(0,H.jsx)(`kbd`,{className:`ml-auto shrink-0 rounded border border-border bg-surface px-1.5 py-0.5 text-[10px] text-text-subtle font-mono`,children:e.shortcut})]},e.id)})}),(0,H.jsxs)(`div`,{className:`flex items-center justify-center gap-1.5 border-t border-border px-3 py-1.5`,children:[(0,H.jsx)(`span`,{className:`text-[10px] text-text-subtle`,children:`Press`}),(0,H.jsx)(`kbd`,{className:`inline-flex items-center rounded border border-border bg-surface px-1 py-0.5 text-[10px] text-text-subtle font-mono`,children:`Shift`}),(0,H.jsx)(`kbd`,{className:`inline-flex items-center rounded border border-border bg-surface px-1 py-0.5 text-[10px] text-text-subtle font-mono`,children:`Shift`}),(0,H.jsx)(`span`,{className:`text-[10px] text-text-subtle`,children:`to open this palette`})]})]})]})}function dg(){let[e,t]=(0,B.useState)(null),[n,r]=(0,B.useState)(!1);(0,B.useEffect)(()=>{function e(e){let n=e.detail;n&&(t(n),r(!1))}return window.addEventListener(`open-bug-report`,e),()=>window.removeEventListener(`open-bug-report`,e)},[]);let i=(0,B.useCallback)(()=>t(null),[]);return e?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`fixed inset-0 z-50 bg-black/50`,onClick:i}),(0,H.jsxs)(`div`,{className:`fixed inset-4 md:inset-auto md:top-[15%] md:left-1/2 md:-translate-x-1/2 md:w-full md:max-w-lg md:max-h-[70vh] z-50 flex flex-col bg-background border border-border rounded-lg shadow-2xl overflow-hidden`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b border-border`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`Bug Report`}),(0,H.jsx)(`button`,{onClick:i,className:`p-1 rounded hover:bg-surface-elevated`,children:(0,H.jsx)(Gt,{className:`size-4`})})]}),(0,H.jsx)(`pre`,{className:`flex-1 overflow-auto px-4 py-2 text-xs font-mono whitespace-pre-wrap break-all`,children:e}),(0,H.jsxs)(`div`,{className:`flex gap-2 p-3 border-t border-border`,children:[(0,H.jsxs)(`button`,{onClick:async()=>{await Dh(e)&&r(!0)},className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-surface-elevated text-xs text-foreground hover:bg-surface transition-colors`,children:[n?(0,H.jsx)(o,{className:`size-3`}):(0,H.jsx)(Ve,{className:`size-3`}),n?`Copied`:`Copy`]}),(0,H.jsxs)(`button`,{onClick:()=>{Eh(e),i()},className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-primary text-primary-foreground text-xs hover:bg-primary/90 transition-colors`,children:[(0,H.jsx)(h,{className:`size-3`}),`Open GitHub Issue`]})]})]})]}):null}var fg=6e4,pg=`ppm-upgrade-dismissed-`;function mg(){let[e,t]=(0,B.useState)(null),[n,r]=(0,B.useState)(!1),[i,a]=(0,B.useState)(!1);(0,B.useEffect)(()=>{let e;async function n(){try{let e=await z.get(`/api/upgrade`);if(e.availableVersion){t(e.availableVersion);let n=pg+e.availableVersion;sessionStorage.getItem(n)?a(!0):a(!1)}else t(null)}catch{}}return n(),e=setInterval(n,fg),()=>clearInterval(e)},[]);let o=(0,B.useCallback)(async()=>{r(!0);try{await z.post(`/api/upgrade/apply`)}catch(e){fn.error(`Upgrade failed: ${e.message}`),r(!1)}},[]),s=(0,B.useCallback)(()=>{e&&sessionStorage.setItem(pg+e,`1`),a(!0)},[e]);return!e||i?null:(0,H.jsx)(`div`,{className:`w-full bg-blue-600 dark:bg-blue-700 text-white px-3 py-2 flex items-center justify-between gap-2 z-50 text-sm shrink-0`,children:n?(0,H.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:[(0,H.jsx)(pt,{className:`size-4 animate-spin shrink-0`}),(0,H.jsxs)(`span`,{className:`truncate`,children:[`Upgrading to v`,e,`... PPM will restart shortly`]})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:[(0,H.jsx)(Fe,{className:`size-4 shrink-0`}),(0,H.jsxs)(`span`,{className:`truncate`,children:[`PPM v`,e,` available`]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,H.jsx)(`button`,{onClick:o,className:`bg-white text-blue-600 font-medium rounded-full px-3 min-h-[44px] min-w-[44px] flex items-center justify-center hover:bg-blue-50 active:bg-blue-100 transition-colors`,children:`Upgrade`}),(0,H.jsx)(`button`,{onClick:s,className:`min-h-[44px] min-w-[44px] flex items-center justify-center rounded-full hover:bg-blue-500 active:bg-blue-800 transition-colors`,"aria-label":`Dismiss upgrade notification`,children:(0,H.jsx)(Gt,{className:`size-4`})})]})]})})}var hg=v(e=>({src:null,alt:``,open:(t,n=``)=>e({src:t,alt:n}),close:()=>e({src:null,alt:``})}));function gg(){let{src:e,alt:t,close:n}=hg(),r=(0,B.useCallback)(e=>{e.key===`Escape`&&n()},[n]);return(0,B.useEffect)(()=>{if(e)return document.addEventListener(`keydown`,r),()=>document.removeEventListener(`keydown`,r)},[e,r]),e?(0,H.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center bg-black/80 backdrop-blur-sm animate-in fade-in duration-150`,onClick:n,children:[(0,H.jsx)(`button`,{onClick:n,className:`absolute top-4 right-4 z-10 flex items-center justify-center size-8 rounded-full bg-white/10 hover:bg-white/20 text-white transition-colors`,"aria-label":`Close`,children:(0,H.jsx)(Gt,{className:`size-5`})}),(0,H.jsx)(`img`,{src:e,alt:t,className:`max-w-[90vw] max-h-[90vh] object-contain rounded-lg shadow-2xl`,onClick:e=>e.stopPropagation()})]}):null}var _g=v(e=>({svg:null,open:t=>e({svg:t}),close:()=>e({svg:null})})),vg=.25,yg=4,bg=.25;function xg(){let{svg:e,close:t}=_g(),n=(0,B.useRef)(null),[r,i]=(0,B.useState)(1),[a,o]=(0,B.useState)({x:0,y:0}),s=(0,B.useRef)(!1),c=(0,B.useRef)({x:0,y:0});(0,B.useEffect)(()=>{e&&(i(1),o({x:0,y:0}))},[e]);let u=(0,B.useCallback)(e=>{e.key===`Escape`&&t(),(e.key===`=`||e.key===`+`)&&i(e=>Math.min(yg,e+bg)),e.key===`-`&&i(e=>Math.max(vg,e-bg)),e.key===`0`&&(i(1),o({x:0,y:0}))},[t]);(0,B.useEffect)(()=>{if(e)return document.addEventListener(`keydown`,u),()=>document.removeEventListener(`keydown`,u)},[e,u]);let d=(0,B.useCallback)(e=>{e.preventDefault();let t=e.deltaY>0?-bg:bg;i(e=>Math.min(yg,Math.max(vg,e+t)))},[]),f=(0,B.useCallback)(e=>{e.button===0&&(s.current=!0,c.current={x:e.clientX,y:e.clientY},e.target.setPointerCapture(e.pointerId))},[]),p=(0,B.useCallback)(e=>{if(!s.current)return;let t=e.clientX-c.current.x,n=e.clientY-c.current.y;c.current={x:e.clientX,y:e.clientY},o(e=>({x:e.x+t,y:e.y+n}))},[]),m=(0,B.useCallback)(()=>{s.current=!1},[]);return e?(0,H.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex flex-col bg-black/85 backdrop-blur-sm animate-in fade-in duration-150`,onClick:t,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 bg-black/40`,onClick:e=>e.stopPropagation(),children:[(0,H.jsxs)(`span`,{className:`text-sm text-white/70`,children:[Math.round(r*100),`% — Scroll to zoom, drag to pan, 0 to reset`]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`button`,{onClick:()=>i(e=>Math.max(vg,e-bg)),className:`flex items-center justify-center size-8 rounded bg-white/10 hover:bg-white/20 text-white transition-colors`,"aria-label":`Zoom out`,children:(0,H.jsx)(qt,{className:`size-4`})}),(0,H.jsx)(`button`,{onClick:()=>i(e=>Math.min(yg,e+bg)),className:`flex items-center justify-center size-8 rounded bg-white/10 hover:bg-white/20 text-white transition-colors`,"aria-label":`Zoom in`,children:(0,H.jsx)(Kt,{className:`size-4`})}),(0,H.jsx)(`button`,{onClick:()=>{i(1),o({x:0,y:0})},className:`flex items-center justify-center size-8 rounded bg-white/10 hover:bg-white/20 text-white transition-colors`,"aria-label":`Reset zoom`,children:(0,H.jsx)(l,{className:`size-4`})}),(0,H.jsx)(`button`,{onClick:t,className:`flex items-center justify-center size-8 rounded bg-white/10 hover:bg-white/20 text-white transition-colors ml-2`,"aria-label":`Close`,children:(0,H.jsx)(Gt,{className:`size-5`})})]})]}),(0,H.jsx)(`div`,{ref:n,className:`flex-1 overflow-hidden cursor-grab active:cursor-grabbing`,onClick:e=>e.stopPropagation(),onWheel:d,onPointerDown:f,onPointerMove:p,onPointerUp:m,children:(0,H.jsx)(`div`,{className:`w-full h-full flex items-center justify-center`,style:{transform:`translate(${a.x}px, ${a.y}px) scale(${r})`,transformOrigin:`center center`},children:(0,H.jsx)(`div`,{className:`mermaid-overlay-content bg-white rounded-lg p-6 shadow-2xl [&_svg]:max-w-full [&_svg]:h-auto`,dangerouslySetInnerHTML:{__html:e}})})})]}):null}function Sg(){let[e,t]=(0,B.useState)(`checking`),[n,r]=(0,B.useState)(!1),[i,a]=(0,B.useState)(),[o,s]=(0,B.useState)(!1);(0,B.useEffect)(()=>{let e=()=>{a(`settings`),r(!0)};return window.addEventListener(`open-mobile-settings`,e),()=>window.removeEventListener(`open-mobile-settings`,e)},[]);let[c,l]=(0,B.useState)(()=>new Set([`__global__`])),u=V(e=>e.theme),d=V(e=>e.deviceName),f=bf(e=>e.fetchProjects),p=V(e=>e.fetchServerInfo),m=bf(e=>e.activeProject),h=(0,B.useRef)(Gh());(0,B.useEffect)(()=>{if(jn(u),u===`system`){let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>jn(`system`);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)}},[u]),(0,B.useEffect)(()=>{p()},[p]),(0,B.useEffect)(()=>{async function e(){let e=pe();try{let n={};e&&(n.Authorization=`Bearer ${e}`),(await(await fetch(`/api/auth/check`,{headers:n})).json()).ok?t(`authenticated`):t(`unauthenticated`)}catch{t(`unauthenticated`)}}e()},[]),qh();let{paletteOpen:g,paletteInitialQuery:v,closePalette:b}=Lf();eg(),rg(),(0,B.useEffect)(()=>{if(e!==`authenticated`)return;let t=e=>{e.preventDefault()};return window.addEventListener(`beforeunload`,t),()=>window.removeEventListener(`beforeunload`,t)},[e]),(0,B.useEffect)(()=>{e===`authenticated`&&y(async()=>{let{useKeybindingsStore:e}=await import(`./keybindings-store-BxDBTcFM.js`);return{useKeybindingsStore:e}},__vite__mapDeps([52,6,1,2])).then(({useKeybindingsStore:e})=>{e.getState().loadFromServer()})},[e]),(0,B.useEffect)(()=>{e===`authenticated`&&f().then(()=>{let{projectName:e,tabId:t,openChat:n}=h.current,{projects:r,customOrder:i}=bf.getState();if(r.length===0)return;let a=e?r.find(t=>t.name===e):void 0;a||=yf(r,i)[0],a&&(bf.getState().setActiveProject(a),e&&t&&queueMicrotask(()=>{let{tabs:e}=_.getState();e.some(e=>e.id===t)&&_.getState().setActiveTab(t)})),n&&queueMicrotask(()=>{let{tabs:e,setActiveTab:t,openTab:r}=_.getState(),i=e.find(e=>e.type===`chat`&&e.metadata?.sessionId===n);i?t(i.id):r({type:`chat`,title:`Chat`,projectId:a?.name??null,closable:!0,metadata:{sessionId:n}});let o=new URL(window.location.href);o.searchParams.delete(`openChat`),window.history.replaceState(null,``,o.pathname)})})},[e,f]),(0,B.useEffect)(()=>{let e=m?.name??`__global__`;_.getState().switchProject(e)},[m?.name]),(0,B.useEffect)(()=>{let e=m?.name??`__global__`;l(t=>t.has(e)?t:new Set([...t,e]))},[m?.name]),(0,B.useEffect)(()=>{e===`authenticated`&&!m&&_.getState().switchProject(`__global__`)},[e,m]);let x=(0,B.useCallback)(()=>{t(`authenticated`)},[]);if(e===`checking`)return(0,H.jsx)(`div`,{className:`min-h-dvh flex items-center justify-center bg-background`,children:(0,H.jsx)(`div`,{className:`animate-pulse text-text-secondary text-sm`,children:`Loading...`})});if(e===`unauthenticated`)return(0,H.jsx)(Wh,{onSuccess:x});let S=m?.name??`__global__`;return(0,H.jsx)(Su,{children:(0,H.jsxs)(`div`,{className:`h-dvh flex flex-col bg-background text-foreground overflow-hidden relative`,children:[(0,H.jsx)(mg,{}),d&&(0,H.jsx)(`div`,{className:`md:hidden fixed top-0 left-0 z-50 px-2 py-0.5 bg-primary/80 text-primary-foreground text-[10px] font-medium rounded-br`,children:d}),(0,H.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,H.jsx)(Fh,{}),(0,H.jsx)(Jm,{}),[...c].map(e=>(0,H.jsx)(`div`,{className:R(`flex-1 overflow-hidden pb-12 md:pb-0`,S!==e&&`hidden`),children:(0,H.jsx)(op,{projectName:e})},e))]}),(0,H.jsx)(zh,{onMenuPress:()=>r(!0),onProjectsPress:()=>s(!0)}),(0,H.jsx)(Vh,{isOpen:n,onClose:()=>{r(!1),a(void 0)},initialTab:i}),(0,H.jsx)(Uh,{isOpen:o,onClose:()=>s(!1)}),(0,H.jsx)(ug,{open:g,onClose:b,initialQuery:v}),(0,H.jsx)(dg,{}),(0,H.jsx)(gg,{}),(0,H.jsx)(xg,{}),(0,H.jsx)(Nn,{position:`bottom-left`,closeButton:!0,toastOptions:{className:`bg-surface border-border text-foreground`}})]})})}(0,Jt.createRoot)(document.getElementById(`root`)).render((0,H.jsx)(B.StrictMode,{children:(0,H.jsx)(Sg,{})}));export{Ze as $,Pf as A,Mt as B,gp as C,Vf as D,up as E,Gt as F,vt as G,Ot as H,Ut as I,pt as J,_t as K,zt as L,Ff as M,bf as N,If as O,V as P,Qe as Q,Rt as R,hp as S,mp as T,Dt as U,kt as V,Et as W,nt as X,it as Y,tt as Z,Tp as _,fm as a,He as at,wp as b,jp as c,Ie as ct,Fp as d,Me as dt,Xe as et,Lp as f,Ae as ft,xp as g,vp as h,Te as ht,bm as i,Ue as it,Nf as j,kf as k,Np as l,Pe as lt,Mp as m,Ee as mt,hg as n,qe as nt,om as o,Ve as ot,Ip as p,ke as pt,mt as q,Oh as r,Ke as rt,Yp as s,Le as st,_g as t,Je as tt,Pp as u,Ne as ut,Cp as v,_p as w,pp as x,Sp as y,Pt as z};