@tom2012/cc-web 2026.4.19-v → 2026.4.19-x
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.
- package/README.md +1 -1
- package/backend/dist/memory-prompts.d.ts.map +1 -1
- package/backend/dist/memory-prompts.js +7 -3
- package/backend/dist/memory-prompts.js.map +1 -1
- package/backend/dist/sync-service.d.ts.map +1 -1
- package/backend/dist/sync-service.js +7 -2
- package/backend/dist/sync-service.js.map +1 -1
- package/frontend/dist/assets/{AssistantMessageContent-qmMdpSdp.js → AssistantMessageContent-DRo_wwOE.js} +1 -1
- package/frontend/dist/assets/{GraphPreview-Cj-m26nq.js → GraphPreview-8jsVSDTu.js} +1 -1
- package/frontend/dist/assets/{MobilePage-Dt7mdX_t.js → MobilePage-DtNZ_N9c.js} +3 -3
- package/frontend/dist/assets/{OfficePreview-CQROE6jJ.js → OfficePreview-BcxUD2mr.js} +2 -2
- package/frontend/dist/assets/{ProjectPage-B-7RSILW.js → ProjectPage-CsTaTE7W.js} +4 -4
- package/frontend/dist/assets/{SettingsPage-DrnZKm6L.js → SettingsPage-BSbsMogo.js} +1 -1
- package/frontend/dist/assets/{SkillHubPage-Cr3_-Iwx.js → SkillHubPage-LLy7t8L7.js} +1 -1
- package/frontend/dist/assets/{chevron-down-Ck7IYzKo.js → chevron-down-D_RQtGy2.js} +1 -1
- package/frontend/dist/assets/{chevron-up-vfhplDGO.js → chevron-up-C0jadenI.js} +1 -1
- package/frontend/dist/assets/{index-DCiTw3F5.css → index-BKYCkXv1.css} +1 -1
- package/frontend/dist/assets/{index-BIaRBMD3.js → index-CBleER0a.js} +2 -2
- package/frontend/dist/assets/{index-CYvos3U3.js → index-DO12wrd9.js} +1 -1
- package/frontend/dist/assets/{index-CPwWf4Su.js → index-dMJLjPxi.js} +1 -1
- package/frontend/dist/assets/{jszip.min-OAmm8lsw.js → jszip.min-xWErx4Qu.js} +1 -1
- package/frontend/dist/assets/{search-B2NI-Y0J.js → search-CLatOUMz.js} +1 -1
- package/frontend/dist/index.html +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ProjectPage-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ProjectPage-CsTaTE7W.js","assets/purify.es-CgRAQgUo.js","assets/AssistantMessageContent-DRo_wwOE.js","assets/chevron-down-D_RQtGy2.js","assets/chevron-up-C0jadenI.js","assets/AssistantMessageContent-wklAmtGL.css","assets/index-DO12wrd9.js","assets/search-CLatOUMz.js","assets/ProjectPage-9CEnUXvW.css","assets/SettingsPage-BSbsMogo.js","assets/SkillHubPage-LLy7t8L7.js","assets/MobilePage-DtNZ_N9c.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
var e=Object.defineProperty,t=(t,n,r)=>((t,n,r)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r)(t,"symbol"!=typeof n?n+"":n,r);function n(e,t){for(var n=0;n<t.length;n++){const r=t[n];if("string"!=typeof r&&!Array.isArray(r))for(const t in r)if("default"!==t&&!(t in e)){const n=Object.getOwnPropertyDescriptor(r,t);n&&Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>r[t]})}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}!function(){const e=document.createElement("link").relList;if(!(e&&e.supports&&e.supports("modulepreload"))){for(const e of document.querySelectorAll('link[rel="modulepreload"]'))t(e);new MutationObserver(e=>{for(const n of e)if("childList"===n.type)for(const e of n.addedNodes)"LINK"===e.tagName&&"modulepreload"===e.rel&&t(e)}).observe(document,{childList:!0,subtree:!0})}function t(e){if(e.ep)return;e.ep=!0;const t=function(e){const t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),"use-credentials"===e.crossOrigin?t.credentials="include":"anonymous"===e.crossOrigin?t.credentials="omit":t.credentials="same-origin",t}(e);fetch(e.href,t)}}();var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function o(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function a(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}),n}var i={exports:{}},s={},l={exports:{}},u={},c=Symbol.for("react.element"),d=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),p=Symbol.for("react.strict_mode"),h=Symbol.for("react.profiler"),m=Symbol.for("react.provider"),g=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),b=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),w=Symbol.iterator;var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,E={};function j(e,t,n){this.props=e,this.context=t,this.refs=E,this.updater=n||k}function C(){}function P(e,t,n){this.props=e,this.context=t,this.refs=E,this.updater=n||k}j.prototype.isReactComponent={},j.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},j.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},C.prototype=j.prototype;var N=P.prototype=new C;N.constructor=P,S(N,j.prototype),N.isPureReactComponent=!0;var T=Array.isArray,M=Object.prototype.hasOwnProperty,R={current:null},L={key:!0,ref:!0,__self:!0,__source:!0};function D(e,t,n){var r,o={},a=null,i=null;if(null!=t)for(r in void 0!==t.ref&&(i=t.ref),void 0!==t.key&&(a=""+t.key),t)M.call(t,r)&&!L.hasOwnProperty(r)&&(o[r]=t[r]);var s=arguments.length-2;if(1===s)o.children=n;else if(1<s){for(var l=Array(s),u=0;u<s;u++)l[u]=arguments[u+2];o.children=l}if(e&&e.defaultProps)for(r in s=e.defaultProps)void 0===o[r]&&(o[r]=s[r]);return{$$typeof:c,type:e,key:a,ref:i,props:o,_owner:R.current}}function _(e){return"object"==typeof e&&null!==e&&e.$$typeof===c}var A=/\/+/g;function O(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(e){return t[e]})}(""+e.key):t.toString(36)}function I(e,t,n,r,o){var a=typeof e;"undefined"!==a&&"boolean"!==a||(e=null);var i=!1;if(null===e)i=!0;else switch(a){case"string":case"number":i=!0;break;case"object":switch(e.$$typeof){case c:case d:i=!0}}if(i)return o=o(i=e),e=""===r?"."+O(i,0):r,T(o)?(n="",null!=e&&(n=e.replace(A,"$&/")+"/"),I(o,t,n,"",function(e){return e})):null!=o&&(_(o)&&(o=function(e,t){return{$$typeof:c,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(o,n+(!o.key||i&&i.key===o.key?"":(""+o.key).replace(A,"$&/")+"/")+e)),t.push(o)),1;if(i=0,r=""===r?".":r+":",T(e))for(var s=0;s<e.length;s++){var l=r+O(a=e[s],s);i+=I(a,t,n,l,o)}else if(l=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=w&&e[w]||e["@@iterator"])?e:null}(e),"function"==typeof l)for(e=l.call(e),s=0;!(a=e.next()).done;)i+=I(a=a.value,t,n,l=r+O(a,s++),o);else if("object"===a)throw t=String(e),Error("Objects are not valid as a React child (found: "+("[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return i}function z(e,t,n){if(null==e)return e;var r=[],o=0;return I(e,r,"","",function(e){return t.call(n,e,o++)}),r}function F(e){if(-1===e._status){var t=e._result;(t=t()).then(function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)},function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)}),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var V={current:null},B={transition:null},$={ReactCurrentDispatcher:V,ReactCurrentBatchConfig:B,ReactCurrentOwner:R};function U(){throw Error("act(...) is not supported in production builds of React.")}u.Children={map:z,forEach:function(e,t,n){z(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return z(e,function(){t++}),t},toArray:function(e){return z(e,function(e){return e})||[]},only:function(e){if(!_(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},u.Component=j,u.Fragment=f,u.Profiler=h,u.PureComponent=P,u.StrictMode=p,u.Suspense=y,u.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=$,u.act=U,u.cloneElement=function(e,t,n){if(null==e)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=S({},e.props),o=e.key,a=e.ref,i=e._owner;if(null!=t){if(void 0!==t.ref&&(a=t.ref,i=R.current),void 0!==t.key&&(o=""+t.key),e.type&&e.type.defaultProps)var s=e.type.defaultProps;for(l in t)M.call(t,l)&&!L.hasOwnProperty(l)&&(r[l]=void 0===t[l]&&void 0!==s?s[l]:t[l])}var l=arguments.length-2;if(1===l)r.children=n;else if(1<l){s=Array(l);for(var u=0;u<l;u++)s[u]=arguments[u+2];r.children=s}return{$$typeof:c,type:e.type,key:o,ref:a,props:r,_owner:i}},u.createContext=function(e){return(e={$$typeof:g,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:m,_context:e},e.Consumer=e},u.createElement=D,u.createFactory=function(e){var t=D.bind(null,e);return t.type=e,t},u.createRef=function(){return{current:null}},u.forwardRef=function(e){return{$$typeof:v,render:e}},u.isValidElement=_,u.lazy=function(e){return{$$typeof:x,_payload:{_status:-1,_result:e},_init:F}},u.memo=function(e,t){return{$$typeof:b,type:e,compare:void 0===t?null:t}},u.startTransition=function(e){var t=B.transition;B.transition={};try{e()}finally{B.transition=t}},u.unstable_act=U,u.useCallback=function(e,t){return V.current.useCallback(e,t)},u.useContext=function(e){return V.current.useContext(e)},u.useDebugValue=function(){},u.useDeferredValue=function(e){return V.current.useDeferredValue(e)},u.useEffect=function(e,t){return V.current.useEffect(e,t)},u.useId=function(){return V.current.useId()},u.useImperativeHandle=function(e,t,n){return V.current.useImperativeHandle(e,t,n)},u.useInsertionEffect=function(e,t){return V.current.useInsertionEffect(e,t)},u.useLayoutEffect=function(e,t){return V.current.useLayoutEffect(e,t)},u.useMemo=function(e,t){return V.current.useMemo(e,t)},u.useReducer=function(e,t,n){return V.current.useReducer(e,t,n)},u.useRef=function(e){return V.current.useRef(e)},u.useState=function(e){return V.current.useState(e)},u.useSyncExternalStore=function(e,t,n){return V.current.useSyncExternalStore(e,t,n)},u.useTransition=function(){return V.current.useTransition()},u.version="18.3.1",l.exports=u;var W=l.exports;const H=o(W),G=n({__proto__:null,default:H},[W]);
|
|
3
3
|
/**
|
|
4
4
|
* @license React
|
|
@@ -72,4 +72,4 @@ function Jd(){return Jd=Object.assign?Object.assign.bind():function(e){for(var t
|
|
|
72
72
|
*
|
|
73
73
|
* This source code is licensed under the ISC license.
|
|
74
74
|
* See the LICENSE file in the root directory of this source tree.
|
|
75
|
-
*/const OE=(e,t)=>{const n=W.forwardRef(({color:n="currentColor",size:r=24,strokeWidth:o=2,absoluteStrokeWidth:a,className:i="",children:s,...l},u)=>{return W.createElement("svg",{ref:u,...AE,width:r,height:r,stroke:n,strokeWidth:a?24*Number(o)/Number(r):o,className:["lucide",`lucide-${c=e,c.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim()}`,i].join(" "),...l},[...t.map(([e,t])=>W.createElement(e,t)),...Array.isArray(s)?s:[s]]);var c});return n.displayName=`${e}`,n},IE=OE("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]),zE=OE("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]),FE=OE("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),VE=OE("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]),BE=OE("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),$E=OE("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]),UE=OE("Eye",[["path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z",key:"rwhkz3"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),WE=OE("File",[["path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z",key:"1nnpy2"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}]]),HE=OE("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]),GE=OE("FolderPlus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),YE=OE("FolderSync",[["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v.5",key:"1dkoa9"}],["path",{d:"M12 10v4h4",key:"1czhmt"}],["path",{d:"m12 14 1.535-1.605a5 5 0 0 1 8 1.5",key:"lvuxfi"}],["path",{d:"M22 22v-4h-4",key:"1ewp4q"}],["path",{d:"m22 18-1.535 1.605a5 5 0 0 1-8-1.5",key:"14ync0"}]]),qE=OE("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),KE=OE("GitMerge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]),XE=OE("GripHorizontal",[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]]),QE=OE("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]),ZE=OE("Home",[["path",{d:"m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"y5dka4"}],["polyline",{points:"9 22 9 12 15 12 15 22",key:"e2us08"}]]),JE=OE("KeyRound",[["path",{d:"M2 18v3c0 .6.4 1 1 1h4v-3h3v-3h2l1.4-1.4a6.5 6.5 0 1 0-4-4Z",key:"167ctg"}],["circle",{cx:"16.5",cy:"7.5",r:".5",key:"1kog09"}]]),ej=OE("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]),tj=OE("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),nj=OE("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]),rj=OE("Maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]),oj=OE("Minimize",[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]]),aj=OE("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]),ij=OE("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]),sj=OE("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]),lj=OE("Pencil",[["path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z",key:"5qss01"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]),uj=OE("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),cj=OE("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),dj=OE("Send",[["path",{d:"m22 2-7 20-4-9-9-4Z",key:"1q3vgg"}],["path",{d:"M22 2 11 13",key:"nzbqef"}]]),fj=OE("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),pj=OE("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),hj=OE("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]),mj=OE("Sparkles",[["path",{d:"m12 3-1.912 5.813a2 2 0 0 1-1.275 1.275L3 12l5.813 1.912a2 2 0 0 1 1.275 1.275L12 21l1.912-5.813a2 2 0 0 1 1.275-1.275L21 12l-5.813-1.912a2 2 0 0 1-1.275-1.275L12 3Z",key:"17u4zn"}],["path",{d:"M5 3v4",key:"bklmnn"}],["path",{d:"M19 17v4",key:"iiml17"}],["path",{d:"M3 5h4",key:"nem4j1"}],["path",{d:"M17 19h4",key:"lbex7p"}]]),gj=OE("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]),vj=OE("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]),yj=OE("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]),bj=OE("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]),xj=OE("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]),wj=OE("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),kj=OE("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]),Sj=Tk("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Ej({className:e,variant:t,...n}){return ee.jsx("div",{className:uk(Sj({variant:t}),e),...n})}function jj(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(null==e||e(r),!1===n||!r.defaultPrevented)return null==t?void 0:t(r)}}function Cj(e,t=[]){let n=[];const r=()=>{const t=n.map(e=>W.createContext(e));return function(n){const r=(null==n?void 0:n[e])||t;return W.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return r.scopeName=e,[function(t,r){const o=W.createContext(r),a=n.length;n=[...n,r];const i=t=>{var n;const{scope:r,children:i,...s}=t,l=(null==(n=null==r?void 0:r[e])?void 0:n[a])||o,u=W.useMemo(()=>s,Object.values(s));return ee.jsx(l.Provider,{value:u,children:i})};return i.displayName=t+"Provider",[i,function(n,i){var s;const l=(null==(s=null==i?void 0:i[e])?void 0:s[a])||o,u=W.useContext(l);if(u)return u;if(void 0!==r)return r;throw new Error(`\`${n}\` must be used within \`${t}\``)}]},Pj(r,...t)]}function Pj(...e){const t=e[0];if(1===e.length)return t;const n=()=>{const n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){const r=n.reduce((t,{useScope:n,scopeName:r})=>({...t,...n(e)[`__scope${r}`]}),{});return W.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}var Nj=(null==globalThis?void 0:globalThis.document)?W.useLayoutEffect:()=>{},Tj=G[" useId ".trim().toString()]||(()=>{}),Mj=0;function Rj(e){const[t,n]=W.useState(Tj());return Nj(()=>{n(e=>e??String(Mj++))},[e]),e||(t?`radix-${t}`:"")}var Lj=G[" useInsertionEffect ".trim().toString()]||Nj;function Dj({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,a,i]=function({defaultProp:e,onChange:t}){const[n,r]=W.useState(e),o=W.useRef(n),a=W.useRef(t);return Lj(()=>{a.current=t},[t]),W.useEffect(()=>{var e;o.current!==n&&(null==(e=a.current)||e.call(a,n),o.current=n)},[n,o]),[n,r,a]}({defaultProp:t,onChange:n}),s=void 0!==e,l=s?e:o;{const t=W.useRef(void 0!==e);W.useEffect(()=>{const e=t.current;if(e!==s){const t=e?"controlled":"uncontrolled",n=s?"controlled":"uncontrolled";console.warn(`${r} is changing from ${t} to ${n}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`)}t.current=s},[s,r])}const u=W.useCallback(t=>{var n;if(s){const r=function(e){return"function"==typeof e}(t)?t(e):t;r!==e&&(null==(n=i.current)||n.call(i,r))}else a(t)},[s,e,a,i]);return[l,u]}function _j(e){const t=Aj(e),n=W.forwardRef((e,n)=>{const{children:r,...o}=e,a=W.Children.toArray(r),i=a.find(Ij);if(i){const e=i.props.children,r=a.map(t=>t===i?W.Children.count(e)>1?W.Children.only(null):W.isValidElement(e)?e.props.children:null:t);return ee.jsx(t,{...o,ref:n,children:W.isValidElement(e)?W.cloneElement(e,void 0,r):null})}return ee.jsx(t,{...o,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function Aj(e){const t=W.forwardRef((e,t)=>{const{children:n,...r}=e;if(W.isValidElement(n)){const e=function(e){var t,n;let r=null==(t=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:t.get,o=r&&"isReactWarning"in r&&r.isReactWarning;if(o)return e.ref;if(r=null==(n=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:n.get,o=r&&"isReactWarning"in r&&r.isReactWarning,o)return e.props.ref;return e.props.ref||e.ref}(n),o=function(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...e)=>{const t=a(...e);return o(...e),t}:o&&(n[r]=o):"style"===r?n[r]={...o,...a}:"className"===r&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==W.Fragment&&(o.ref=t?vk(t,e):e),W.cloneElement(n,o)}return W.Children.count(n)>1?W.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Oj=Symbol("radix.slottable");function Ij(e){return W.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===Oj}var zj=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{const n=_j(`Primitive.${t}`),r=W.forwardRef((e,r)=>{const{asChild:o,...a}=e,i=o?n:t;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),ee.jsx(i,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Fj(e,t){e&&ld.flushSync(()=>e.dispatchEvent(t))}function Vj(e){const t=W.useRef(e);return W.useEffect(()=>{t.current=e}),W.useMemo(()=>(...e)=>{var n;return null==(n=t.current)?void 0:n.call(t,...e)},[])}var Bj,$j="dismissableLayer.update",Uj="dismissableLayer.pointerDownOutside",Wj="dismissableLayer.focusOutside",Hj=W.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Gj=W.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:i,onDismiss:s,...l}=e,u=W.useContext(Hj),[c,d]=W.useState(null),f=(null==c?void 0:c.ownerDocument)??(null==globalThis?void 0:globalThis.document),[,p]=W.useState({}),h=yk(t,e=>d(e)),m=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=m.indexOf(g),y=c?m.indexOf(c):-1,b=u.layersWithOutsidePointerEventsDisabled.size>0,x=y>=v,w=function(e,t=(null==globalThis?void 0:globalThis.document)){const n=Vj(e),r=W.useRef(!1),o=W.useRef(()=>{});return W.useEffect(()=>{const e=e=>{if(e.target&&!r.current){let r=function(){qj(Uj,n,a,{discrete:!0})};const a={originalEvent:e};"touch"===e.pointerType?(t.removeEventListener("click",o.current),o.current=r,t.addEventListener("click",o.current,{once:!0})):r()}else t.removeEventListener("click",o.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",e),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}(e=>{const t=e.target,n=[...u.branches].some(e=>e.contains(t));x&&!n&&(null==o||o(e),null==i||i(e),e.defaultPrevented||null==s||s())},f),k=function(e,t=(null==globalThis?void 0:globalThis.document)){const n=Vj(e),r=W.useRef(!1);return W.useEffect(()=>{const e=e=>{if(e.target&&!r.current){qj(Wj,n,{originalEvent:e},{discrete:!1})}};return t.addEventListener("focusin",e),()=>t.removeEventListener("focusin",e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}(e=>{const t=e.target;[...u.branches].some(e=>e.contains(t))||(null==a||a(e),null==i||i(e),e.defaultPrevented||null==s||s())},f);return function(e,t=(null==globalThis?void 0:globalThis.document)){const n=Vj(e);W.useEffect(()=>{const e=e=>{"Escape"===e.key&&n(e)};return t.addEventListener("keydown",e,{capture:!0}),()=>t.removeEventListener("keydown",e,{capture:!0})},[n,t])}(e=>{y===u.layers.size-1&&(null==r||r(e),!e.defaultPrevented&&s&&(e.preventDefault(),s()))},f),W.useEffect(()=>{if(c)return n&&(0===u.layersWithOutsidePointerEventsDisabled.size&&(Bj=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(c)),u.layers.add(c),Yj(),()=>{n&&1===u.layersWithOutsidePointerEventsDisabled.size&&(f.body.style.pointerEvents=Bj)}},[c,f,n,u]),W.useEffect(()=>()=>{c&&(u.layers.delete(c),u.layersWithOutsidePointerEventsDisabled.delete(c),Yj())},[c,u]),W.useEffect(()=>{const e=()=>p({});return document.addEventListener($j,e),()=>document.removeEventListener($j,e)},[]),ee.jsx(zj.div,{...l,ref:h,style:{pointerEvents:b?x?"auto":"none":void 0,...e.style},onFocusCapture:jj(e.onFocusCapture,k.onFocusCapture),onBlurCapture:jj(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:jj(e.onPointerDownCapture,w.onPointerDownCapture)})});Gj.displayName="DismissableLayer";function Yj(){const e=new CustomEvent($j);document.dispatchEvent(e)}function qj(e,t,n,{discrete:r}){const o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Fj(o,a):o.dispatchEvent(a)}W.forwardRef((e,t)=>{const n=W.useContext(Hj),r=W.useRef(null),o=yk(t,r);return W.useEffect(()=>{const e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),ee.jsx(zj.div,{...e,ref:o})}).displayName="DismissableLayerBranch";var Kj="focusScope.autoFocusOnMount",Xj="focusScope.autoFocusOnUnmount",Qj={bubbles:!1,cancelable:!0},Zj=W.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...i}=e,[s,l]=W.useState(null),u=Vj(o),c=Vj(a),d=W.useRef(null),f=yk(t,e=>l(e)),p=W.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;W.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;const t=e.target;s.contains(t)?d.current=t:nC(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;const t=e.relatedTarget;null!==t&&(s.contains(t)||nC(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&nC(s)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),r.disconnect()}}},[r,s,p.paused]),W.useEffect(()=>{if(s){rC.add(p);const t=document.activeElement;if(!s.contains(t)){const n=new CustomEvent(Kj,Qj);s.addEventListener(Kj,u),s.dispatchEvent(n),n.defaultPrevented||(!function(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(nC(r,{select:t}),document.activeElement!==n)return}((e=Jj(s),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&nC(s))}return()=>{s.removeEventListener(Kj,u),setTimeout(()=>{const e=new CustomEvent(Xj,Qj);s.addEventListener(Xj,c),s.dispatchEvent(e),e.defaultPrevented||nC(t??document.body,{select:!0}),s.removeEventListener(Xj,c),rC.remove(p)},0)}}var e},[s,u,c,p]);const h=W.useCallback(e=>{if(!n&&!r)return;if(p.paused)return;const t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,o=document.activeElement;if(t&&o){const t=e.currentTarget,[r,a]=function(e){const t=Jj(e),n=eC(t,e),r=eC(t.reverse(),e);return[n,r]}(t);r&&a?e.shiftKey||o!==a?e.shiftKey&&o===r&&(e.preventDefault(),n&&nC(a,{select:!0})):(e.preventDefault(),n&&nC(r,{select:!0})):o===t&&e.preventDefault()}},[n,r,p.paused]);return ee.jsx(zj.div,{tabIndex:-1,...i,ref:f,onKeyDown:h})});function Jj(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{const t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function eC(e,t){for(const n of e)if(!tC(n,{upTo:t}))return n}function tC(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==t&&e===t)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function nC(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&t&&e.select()}}Zj.displayName="FocusScope";var rC=function(){let e=[];return{add(t){const n=e[0];t!==n&&(null==n||n.pause()),e=oC(e,t),e.unshift(t)},remove(t){var n;e=oC(e,t),null==(n=e[0])||n.resume()}}}();function oC(e,t){const n=[...e],r=n.indexOf(t);return-1!==r&&n.splice(r,1),n}var aC=W.forwardRef((e,t)=>{var n;const{container:r,...o}=e,[a,i]=W.useState(!1);Nj(()=>i(!0),[]);const s=r||a&&(null==(n=null==globalThis?void 0:globalThis.document)?void 0:n.body);return s?ud.createPortal(ee.jsx(zj.div,{...o,ref:t}),s):null});aC.displayName="Portal";var iC=e=>{const{present:t,children:n}=e,r=function(e){const[t,n]=W.useState(),r=W.useRef(null),o=W.useRef(e),a=W.useRef("none"),i=e?"mounted":"unmounted",[s,l]=function(e,t){return W.useReducer((e,n)=>t[e][n]??e,e)}(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return W.useEffect(()=>{const e=sC(r.current);a.current="mounted"===s?e:"none"},[s]),Nj(()=>{const t=r.current,n=o.current;if(n!==e){const r=a.current,i=sC(t);if(e)l("MOUNT");else if("none"===i||"none"===(null==t?void 0:t.display))l("UNMOUNT");else{l(n&&r!==i?"ANIMATION_OUT":"UNMOUNT")}o.current=e}},[e,l]),Nj(()=>{if(t){let e;const n=t.ownerDocument.defaultView??window,i=a=>{const i=sC(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&i&&(l("ANIMATION_END"),!o.current)){const r=t.style.animationFillMode;t.style.animationFillMode="forwards",e=n.setTimeout(()=>{"forwards"===t.style.animationFillMode&&(t.style.animationFillMode=r)})}},s=e=>{e.target===t&&(a.current=sC(r.current))};return t.addEventListener("animationstart",s),t.addEventListener("animationcancel",i),t.addEventListener("animationend",i),()=>{n.clearTimeout(e),t.removeEventListener("animationstart",s),t.removeEventListener("animationcancel",i),t.removeEventListener("animationend",i)}}l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:W.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}(t),o="function"==typeof n?n({present:r.isPresent}):W.Children.only(n),a=yk(r.ref,function(e){var t,n;let r=null==(t=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:t.get,o=r&&"isReactWarning"in r&&r.isReactWarning;if(o)return e.ref;if(r=null==(n=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:n.get,o=r&&"isReactWarning"in r&&r.isReactWarning,o)return e.props.ref;return e.props.ref||e.ref}(o));return"function"==typeof n||r.isPresent?W.cloneElement(o,{ref:a}):null};function sC(e){return(null==e?void 0:e.animationName)||"none"}iC.displayName="Presence";var lC=0;function uC(){W.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??cC()),document.body.insertAdjacentElement("beforeend",e[1]??cC()),lC++,()=>{1===lC&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),lC--}},[])}function cC(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var dC=function(){return dC=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},dC.apply(this,arguments)};function fC(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}"function"==typeof SuppressedError&&SuppressedError;var pC="right-scroll-bar-position",hC="width-before-scroll-bar";function mC(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}var gC="undefined"!=typeof window?W.useLayoutEffect:W.useEffect,vC=new WeakMap;function yC(e,t){var n,r,o,a=(n=null,r=function(t){return e.forEach(function(e){return mC(e,t)})},(o=W.useState(function(){return{value:n,callback:r,facade:{get current(){return o.value},set current(e){var t=o.value;t!==e&&(o.value=e,o.callback(e,t))}}}})[0]).callback=r,o.facade);return gC(function(){var t=vC.get(a);if(t){var n=new Set(t),r=new Set(e),o=a.current;n.forEach(function(e){r.has(e)||mC(e,null)}),r.forEach(function(e){n.has(e)||mC(e,o)})}vC.set(a,e)},[e]),a}function bC(e){return e}var xC=function(e){var t=e.sideCar,n=fC(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return W.createElement(r,dC({},n))};xC.isSideCarExport=!0;var wC=function(e){void 0===e&&(e={});var t=function(e,t){void 0===t&&(t=bC);var n=[],r=!1;return{read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var o=t(e,r);return n.push(o),function(){n=n.filter(function(e){return e!==o})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var o=n;n=[],o.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},i=function(){return Promise.resolve().then(a)};i(),n={push:function(e){t.push(e),i()},filter:function(e){return t=t.filter(e),n}}}}}(null);return t.options=dC({async:!0,ssr:!1},e),t}(),kC=function(){},SC=W.forwardRef(function(e,t){var n=W.useRef(null),r=W.useState({onScrollCapture:kC,onWheelCapture:kC,onTouchMoveCapture:kC}),o=r[0],a=r[1],i=e.forwardProps,s=e.children,l=e.className,u=e.removeScrollBar,c=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,h=e.noIsolation,m=e.inert,g=e.allowPinchZoom,v=e.as,y=void 0===v?"div":v,b=e.gapMode,x=fC(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),w=f,k=yC([n,t]),S=dC(dC({},x),o);return W.createElement(W.Fragment,null,c&&W.createElement(w,{sideCar:wC,removeScrollBar:u,shards:d,noRelative:p,noIsolation:h,inert:m,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:b}),i?W.cloneElement(W.Children.only(s),dC(dC({},S),{ref:k})):W.createElement(y,dC({},S,{className:l,ref:k}),s))});SC.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},SC.classNames={fullWidth:hC,zeroRight:pC};function EC(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=function(){if("undefined"!=typeof __webpack_nonce__)return __webpack_nonce__}();return t&&e.setAttribute("nonce",t),e}var jC=function(){var e=0,t=null;return{add:function(n){var r,o;0==e&&(t=EC())&&(o=n,(r=t).styleSheet?r.styleSheet.cssText=o:r.appendChild(document.createTextNode(o)),function(e){(document.head||document.getElementsByTagName("head")[0]).appendChild(e)}(t)),e++},remove:function(){! --e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},CC=function(){var e,t=(e=jC(),function(t,n){W.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])});return function(e){var n=e.styles,r=e.dynamic;return t(n,r),null}},PC={left:0,top:0,right:0,gap:0},NC=function(e){return parseInt(e||"",10)||0},TC=function(e){if(void 0===e&&(e="margin"),"undefined"==typeof window)return PC;var t=function(e){var t=window.getComputedStyle(document.body),n=t["padding"===e?"paddingLeft":"marginLeft"],r=t["padding"===e?"paddingTop":"marginTop"],o=t["padding"===e?"paddingRight":"marginRight"];return[NC(n),NC(r),NC(o)]}(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},MC=CC(),RC="data-scroll-locked",LC=function(e,t,n,r){var o=e.left,a=e.top,i=e.right,s=e.gap;return void 0===n&&(n="margin"),"\n .".concat("with-scroll-bars-hidden"," {\n overflow: hidden ").concat(r,";\n padding-right: ").concat(s,"px ").concat(r,";\n }\n body[").concat(RC,"] {\n overflow: hidden ").concat(r,";\n overscroll-behavior: contain;\n ").concat([t&&"position: relative ".concat(r,";"),"margin"===n&&"\n padding-left: ".concat(o,"px;\n padding-top: ").concat(a,"px;\n padding-right: ").concat(i,"px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(s,"px ").concat(r,";\n "),"padding"===n&&"padding-right: ".concat(s,"px ").concat(r,";")].filter(Boolean).join(""),"\n }\n \n .").concat(pC," {\n right: ").concat(s,"px ").concat(r,";\n }\n \n .").concat(hC," {\n margin-right: ").concat(s,"px ").concat(r,";\n }\n \n .").concat(pC," .").concat(pC," {\n right: 0 ").concat(r,";\n }\n \n .").concat(hC," .").concat(hC," {\n margin-right: 0 ").concat(r,";\n }\n \n body[").concat(RC,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(s,"px;\n }\n")},DC=function(){var e=parseInt(document.body.getAttribute(RC)||"0",10);return isFinite(e)?e:0},_C=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=void 0===r?"margin":r;W.useEffect(function(){return document.body.setAttribute(RC,(DC()+1).toString()),function(){var e=DC()-1;e<=0?document.body.removeAttribute(RC):document.body.setAttribute(RC,e.toString())}},[]);var a=W.useMemo(function(){return TC(o)},[o]);return W.createElement(MC,{styles:LC(a,!t,o,n?"":"!important")})},AC=!1;if("undefined"!=typeof window)try{var OC=Object.defineProperty({},"passive",{get:function(){return AC=!0,!0}});window.addEventListener("test",OC,OC),window.removeEventListener("test",OC,OC)}catch(RT){AC=!1}var IC=!!AC&&{passive:!1},zC=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return"hidden"!==n[t]&&!(n.overflowY===n.overflowX&&!function(e){return"TEXTAREA"===e.tagName}(e)&&"visible"===n[t])},FC=function(e,t){var n=t.ownerDocument,r=t;do{if("undefined"!=typeof ShadowRoot&&r instanceof ShadowRoot&&(r=r.host),VC(e,r)){var o=BC(e,r);if(o[1]>o[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},VC=function(e,t){return"v"===e?function(e){return zC(e,"overflowY")}(t):function(e){return zC(e,"overflowX")}(t)},BC=function(e,t){return"v"===e?[(n=t).scrollTop,n.scrollHeight,n.clientHeight]:function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]}(t);var n},$C=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},UC=function(e){return[e.deltaX,e.deltaY]},WC=function(e){return e&&"current"in e?e.current:e},HC=function(e){return"\n .block-interactivity-".concat(e," {pointer-events: none;}\n .allow-interactivity-").concat(e," {pointer-events: all;}\n")},GC=0,YC=[];function qC(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const KC=(XC=function(e){var t=W.useRef([]),n=W.useRef([0,0]),r=W.useRef(),o=W.useState(GC++)[0],a=W.useState(CC)[0],i=W.useRef(e);W.useEffect(function(){i.current=e},[e]),W.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var t=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}([e.lockRef.current],(e.shards||[]).map(WC),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),t.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var s=W.useCallback(function(e,t){if("touches"in e&&2===e.touches.length||"wheel"===e.type&&e.ctrlKey)return!i.current.allowPinchZoom;var o,a=$C(e),s=n.current,l="deltaX"in e?e.deltaX:s[0]-a[0],u="deltaY"in e?e.deltaY:s[1]-a[1],c=e.target,d=Math.abs(l)>Math.abs(u)?"h":"v";if("touches"in e&&"h"===d&&"range"===c.type)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===c||p.contains(c)))return!1;var h=FC(d,c);if(!h)return!0;if(h?o=d:(o="v"===d?"h":"v",h=FC(d,c)),!h)return!1;if(!r.current&&"changedTouches"in e&&(l||u)&&(r.current=o),!o)return!0;var m=r.current||o;return function(e,t,n,r){var o=function(e,t){return"h"===e&&"rtl"===t?-1:1}(e,window.getComputedStyle(t).direction),a=o*r,i=n.target,s=t.contains(i),l=!1,u=a>0,c=0,d=0;do{if(!i)break;var f=BC(e,i),p=f[0],h=f[1]-f[2]-o*p;(p||h)&&VC(e,i)&&(c+=h,d+=p);var m=i.parentNode;i=m&&m.nodeType===Node.DOCUMENT_FRAGMENT_NODE?m.host:m}while(!s&&i!==document.body||s&&(t.contains(i)||t===i));return(u&&Math.abs(c)<1||!u&&Math.abs(d)<1)&&(l=!0),l}(m,t,e,"h"===m?l:u)},[]),l=W.useCallback(function(e){var n=e;if(YC.length&&YC[YC.length-1]===a){var r="deltaY"in n?UC(n):$C(n),o=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&(t=e.delta,o=r,t[0]===o[0]&&t[1]===o[1]);var t,o})[0];if(o&&o.should)n.cancelable&&n.preventDefault();else if(!o){var l=(i.current.shards||[]).map(WC).filter(Boolean).filter(function(e){return e.contains(n.target)});(l.length>0?s(n,l[0]):!i.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),u=W.useCallback(function(e,n,r,o){var a={name:e,delta:n,target:r,should:o,shadowParent:qC(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),c=W.useCallback(function(e){n.current=$C(e),r.current=void 0},[]),d=W.useCallback(function(t){u(t.type,UC(t),t.target,s(t,e.lockRef.current))},[]),f=W.useCallback(function(t){u(t.type,$C(t),t.target,s(t,e.lockRef.current))},[]);W.useEffect(function(){return YC.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,IC),document.addEventListener("touchmove",l,IC),document.addEventListener("touchstart",c,IC),function(){YC=YC.filter(function(e){return e!==a}),document.removeEventListener("wheel",l,IC),document.removeEventListener("touchmove",l,IC),document.removeEventListener("touchstart",c,IC)}},[]);var p=e.removeScrollBar,h=e.inert;return W.createElement(W.Fragment,null,h?W.createElement(a,{styles:HC(o)}):null,p?W.createElement(_C,{noRelative:e.noRelative,gapMode:e.gapMode}):null)},wC.useMedium(XC),xC);var XC,QC=W.forwardRef(function(e,t){return W.createElement(SC,dC({},e,{ref:t,sideCar:KC}))});QC.classNames=SC.classNames;var ZC=new WeakMap,JC=new WeakMap,eP={},tP=0,nP=function(e){return e&&(e.host||nP(e.parentNode))},rP=function(e,t,n,r){var o=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=nP(t);return n&&e.contains(n)?n:(console.error("aria-hidden",t,"in not contained inside",e,". Doing nothing"),null)}).filter(function(e){return Boolean(e)})}(t,Array.isArray(e)?e:[e]);eP[n]||(eP[n]=new WeakMap);var a=eP[n],i=[],s=new Set,l=new Set(o),u=function(e){e&&!s.has(e)&&(s.add(e),u(e.parentNode))};o.forEach(u);var c=function(e){e&&!l.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))c(e);else try{var t=e.getAttribute(r),o=null!==t&&"false"!==t,l=(ZC.get(e)||0)+1,u=(a.get(e)||0)+1;ZC.set(e,l),a.set(e,u),i.push(e),1===l&&o&&JC.set(e,!0),1===u&&e.setAttribute(n,"true"),o||e.setAttribute(r,"true")}catch(MT){console.error("aria-hidden: cannot operate on ",e,MT)}})};return c(t),s.clear(),tP++,function(){i.forEach(function(e){var t=ZC.get(e)-1,o=a.get(e)-1;ZC.set(e,t),a.set(e,o),t||(JC.has(e)||e.removeAttribute(r),JC.delete(e)),o||e.removeAttribute(n)}),--tP||(ZC=new WeakMap,ZC=new WeakMap,JC=new WeakMap,eP={})}},oP=function(e,t,n){void 0===n&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=function(e){return"undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body}(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),rP(r,o,n,"aria-hidden")):function(){return null}};function aP(e){const t=iP(e),n=W.forwardRef((e,n)=>{const{children:r,...o}=e,a=W.Children.toArray(r),i=a.find(lP);if(i){const e=i.props.children,r=a.map(t=>t===i?W.Children.count(e)>1?W.Children.only(null):W.isValidElement(e)?e.props.children:null:t);return ee.jsx(t,{...o,ref:n,children:W.isValidElement(e)?W.cloneElement(e,void 0,r):null})}return ee.jsx(t,{...o,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function iP(e){const t=W.forwardRef((e,t)=>{const{children:n,...r}=e;if(W.isValidElement(n)){const e=function(e){var t,n;let r=null==(t=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:t.get,o=r&&"isReactWarning"in r&&r.isReactWarning;if(o)return e.ref;if(r=null==(n=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:n.get,o=r&&"isReactWarning"in r&&r.isReactWarning,o)return e.props.ref;return e.props.ref||e.ref}(n),o=function(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...e)=>{const t=a(...e);return o(...e),t}:o&&(n[r]=o):"style"===r?n[r]={...o,...a}:"className"===r&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==W.Fragment&&(o.ref=t?vk(t,e):e),W.cloneElement(n,o)}return W.Children.count(n)>1?W.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var sP=Symbol("radix.slottable");function lP(e){return W.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===sP}var uP="Dialog",[cP]=Cj(uP),[dP,fP]=cP(uP),pP=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:a,modal:i=!0}=e,s=W.useRef(null),l=W.useRef(null),[u,c]=Dj({prop:r,defaultProp:o??!1,onChange:a,caller:uP});return ee.jsx(dP,{scope:t,triggerRef:s,contentRef:l,contentId:Rj(),titleId:Rj(),descriptionId:Rj(),open:u,onOpenChange:c,onOpenToggle:W.useCallback(()=>c(e=>!e),[c]),modal:i,children:n})};pP.displayName=uP;var hP="DialogTrigger";W.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fP(hP,n),a=yk(t,o.triggerRef);return ee.jsx(zj.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":_P(o.open),...r,ref:a,onClick:jj(e.onClick,o.onOpenToggle)})}).displayName=hP;var mP="DialogPortal",[gP,vP]=cP(mP,{forceMount:void 0}),yP=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,a=fP(mP,t);return ee.jsx(gP,{scope:t,forceMount:n,children:W.Children.map(r,e=>ee.jsx(iC,{present:n||a.open,children:ee.jsx(aC,{asChild:!0,container:o,children:e})}))})};yP.displayName=mP;var bP="DialogOverlay",xP=W.forwardRef((e,t)=>{const n=vP(bP,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=fP(bP,e.__scopeDialog);return a.modal?ee.jsx(iC,{present:r||a.open,children:ee.jsx(kP,{...o,ref:t})}):null});xP.displayName=bP;var wP=aP("DialogOverlay.RemoveScroll"),kP=W.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fP(bP,n);return ee.jsx(QC,{as:wP,allowPinchZoom:!0,shards:[o.contentRef],children:ee.jsx(zj.div,{"data-state":_P(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),SP="DialogContent",EP=W.forwardRef((e,t)=>{const n=vP(SP,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=fP(SP,e.__scopeDialog);return ee.jsx(iC,{present:r||a.open,children:a.modal?ee.jsx(jP,{...o,ref:t}):ee.jsx(CP,{...o,ref:t})})});EP.displayName=SP;var jP=W.forwardRef((e,t)=>{const n=fP(SP,e.__scopeDialog),r=W.useRef(null),o=yk(t,n.contentRef,r);return W.useEffect(()=>{const e=r.current;if(e)return oP(e)},[]),ee.jsx(PP,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:jj(e.onCloseAutoFocus,e=>{var t;e.preventDefault(),null==(t=n.triggerRef.current)||t.focus()}),onPointerDownOutside:jj(e.onPointerDownOutside,e=>{const t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey;(2===t.button||n)&&e.preventDefault()}),onFocusOutside:jj(e.onFocusOutside,e=>e.preventDefault())})}),CP=W.forwardRef((e,t)=>{const n=fP(SP,e.__scopeDialog),r=W.useRef(!1),o=W.useRef(!1);return ee.jsx(PP,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{var a,i;null==(a=e.onCloseAutoFocus)||a.call(e,t),t.defaultPrevented||(r.current||null==(i=n.triggerRef.current)||i.focus(),t.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:t=>{var a,i;null==(a=e.onInteractOutside)||a.call(e,t),t.defaultPrevented||(r.current=!0,"pointerdown"===t.detail.originalEvent.type&&(o.current=!0));const s=t.target;(null==(i=n.triggerRef.current)?void 0:i.contains(s))&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&o.current&&t.preventDefault()}})}),PP=W.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,...i}=e,s=fP(SP,n),l=W.useRef(null),u=yk(t,l);return uC(),ee.jsxs(ee.Fragment,{children:[ee.jsx(Zj,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:ee.jsx(Gj,{role:"dialog",id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":_P(s.open),...i,ref:u,onDismiss:()=>s.onOpenChange(!1)})}),ee.jsxs(ee.Fragment,{children:[ee.jsx(zP,{titleId:s.titleId}),ee.jsx(FP,{contentRef:l,descriptionId:s.descriptionId})]})]})}),NP="DialogTitle",TP=W.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fP(NP,n);return ee.jsx(zj.h2,{id:o.titleId,...r,ref:t})});TP.displayName=NP;var MP="DialogDescription",RP=W.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fP(MP,n);return ee.jsx(zj.p,{id:o.descriptionId,...r,ref:t})});RP.displayName=MP;var LP="DialogClose",DP=W.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fP(LP,n);return ee.jsx(zj.button,{type:"button",...r,ref:t,onClick:jj(e.onClick,()=>o.onOpenChange(!1))})});function _P(e){return e?"open":"closed"}DP.displayName=LP;var AP="DialogTitleWarning",[OP,IP]=function(e,t){const n=W.createContext(t),r=e=>{const{children:t,...r}=e,o=W.useMemo(()=>r,Object.values(r));return ee.jsx(n.Provider,{value:o,children:t})};return r.displayName=e+"Provider",[r,function(r){const o=W.useContext(n);if(o)return o;if(void 0!==t)return t;throw new Error(`\`${r}\` must be used within \`${e}\``)}]}(AP,{contentName:SP,titleName:NP,docsSlug:"dialog"}),zP=({titleId:e})=>{const t=IP(AP),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.\n\nIf you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.\n\nFor more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return W.useEffect(()=>{if(e){document.getElementById(e)||console.error(n)}},[n,e]),null},FP=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${IP("DialogDescriptionWarning").contentName}}.`;return W.useEffect(()=>{var r;const o=null==(r=e.current)?void 0:r.getAttribute("aria-describedby");if(t&&o){document.getElementById(t)||console.warn(n)}},[n,e,t]),null},VP=xP,BP=EP,$P=TP,UP=RP,WP=DP;const HP=pP,GP=yP,YP=W.forwardRef(({className:e,...t},n)=>ee.jsx(VP,{ref:n,className:uk("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));YP.displayName=VP.displayName;const qP=W.forwardRef(({className:e,children:t,noOverlay:n,...r},o)=>ee.jsxs(GP,{children:[!n&&ee.jsx(YP,{}),ee.jsxs(BP,{ref:o,className:uk("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...r,children:[t,ee.jsxs(WP,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[ee.jsx(wj,{className:"h-4 w-4"}),ee.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));qP.displayName=BP.displayName;const KP=({className:e,...t})=>ee.jsx("div",{className:uk("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});KP.displayName="DialogHeader";const XP=({className:e,...t})=>ee.jsx("div",{className:uk("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});XP.displayName="DialogFooter";const QP=W.forwardRef(({className:e,...t},n)=>ee.jsx($P,{ref:n,className:uk("text-lg font-semibold leading-none tracking-tight",e),...t}));QP.displayName=$P.displayName;const ZP=W.forwardRef(({className:e,...t},n)=>ee.jsx(UP,{ref:n,className:uk("text-sm text-muted-foreground",e),...t}));function JP({project:e,open:t,onOpenChange:n,onUpdated:r}){const[o,a]=W.useState([]),[i,s]=W.useState([]),[l,u]=W.useState(!1),[c,d]=W.useState(null);W.useEffect(()=>{if(!t)return;a(e.shares?[...e.shares]:[]),d(null);let n=!1;return iS().then(e=>{n||s(e)}).catch(()=>{}),()=>{n=!0}},[t,e.id]);const f=new Set(o.map(e=>e.username)),p=i.filter(t=>t!==e.owner&&!f.has(t));return ee.jsx(HP,{open:t,onOpenChange:n,children:ee.jsxs(qP,{className:"sm:max-w-md",children:[ee.jsxs(KP,{children:[ee.jsxs(QP,{className:"flex items-center gap-2",children:[ee.jsx(xj,{className:"h-4 w-4"}),"共享设置"]}),ee.jsx(ZP,{children:"选择用户并设置权限:可见(只读)或可编辑(读写+终端)"})]}),ee.jsxs("div",{className:"space-y-3 max-h-64 overflow-y-auto",children:[0===o.length&&ee.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"尚未共享给任何用户"}),o.map(e=>ee.jsxs("div",{className:"flex items-center justify-between gap-2 px-1",children:[ee.jsx("span",{className:"text-sm font-medium",children:e.username}),ee.jsxs("div",{className:"flex items-center gap-1.5",children:[ee.jsx("button",{onClick:()=>{return t=e.username,void a(e=>e.map(e=>e.username===t?{...e,permission:"view"===e.permission?"edit":"view"}:e));var t},className:"focus:outline-none",children:ee.jsx(Ej,{variant:"edit"===e.permission?"default":"secondary",className:"cursor-pointer text-xs",children:"edit"===e.permission?"可编辑":"可见"})}),ee.jsx(Rk,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive",onClick:()=>{return t=e.username,void a(e=>e.filter(e=>e.username!==t));var t},children:ee.jsx(bj,{className:"h-3.5 w-3.5"})})]})]},e.username))]}),p.length>0&&ee.jsxs("div",{className:"border-t pt-3",children:[ee.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"添加用户"}),ee.jsx("div",{className:"flex flex-wrap gap-1.5",children:p.map(e=>ee.jsxs(Rk,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>{return t=e,void a(e=>[...e,{username:t,permission:"view"}]);var t},children:[ee.jsx(uj,{className:"h-3 w-3"}),e]},e))})]}),c&&ee.jsx("p",{className:"text-sm text-destructive",children:c}),ee.jsxs(XP,{children:[ee.jsx(Rk,{variant:"outline",onClick:()=>n(!1),disabled:l,children:"取消"}),ee.jsx(Rk,{onClick:()=>{(async()=>{u(!0),d(null);try{const t=await sS(e.id,o);r(t),n(!1)}catch(RT){d(RT instanceof Error?RT.message:"Failed to update shares")}finally{u(!1)}})()},disabled:l,children:l?"保存中...":"保存"})]})]})})}ZP.displayName=UP.displayName;const eN=Array(12).fill(0),tN=({visible:e,className:t})=>H.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},H.createElement("div",{className:"sonner-spinner"},eN.map((e,t)=>H.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${t}`})))),nN=H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},H.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),rN=H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},H.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),oN=H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},H.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),aN=H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},H.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),iN=H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},H.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),H.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"}));let sN=1;const lN=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{const t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;const{message:n,...r}=e,o="number"==typeof(null==e?void 0:e.id)||(null==(t=e.id)?void 0:t.length)>0?e.id:sN++,a=this.toasts.find(e=>e.id===o),i=void 0===e.dismissible||e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),a?this.toasts=this.toasts.map(t=>t.id===o?(this.publish({...t,...e,id:o,title:n}),{...t,...e,id:o,dismissible:i,title:n}):t):this.addToast({title:n,...r,dismissible:i,id:o}),o},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;void 0!==t.loading&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:"function"!=typeof t.description?t.description:void 0}));const r=Promise.resolve(e instanceof Function?e():e);let o,a=void 0!==n;const i=r.then(async e=>{o=["resolve",e];if(H.isValidElement(e))a=!1,this.create({id:n,type:"default",message:e});else if(uN(e)&&!e.ok){a=!1;const r="function"==typeof t.error?await t.error(`HTTP error! status: ${e.status}`):t.error,o="function"==typeof t.description?await t.description(`HTTP error! status: ${e.status}`):t.description,i="object"==typeof r&&!H.isValidElement(r)?r:{message:r};this.create({id:n,type:"error",description:o,...i})}else if(e instanceof Error){a=!1;const r="function"==typeof t.error?await t.error(e):t.error,o="function"==typeof t.description?await t.description(e):t.description,i="object"==typeof r&&!H.isValidElement(r)?r:{message:r};this.create({id:n,type:"error",description:o,...i})}else if(void 0!==t.success){a=!1;const r="function"==typeof t.success?await t.success(e):t.success,o="function"==typeof t.description?await t.description(e):t.description,i="object"==typeof r&&!H.isValidElement(r)?r:{message:r};this.create({id:n,type:"success",description:o,...i})}}).catch(async e=>{if(o=["reject",e],void 0!==t.error){a=!1;const r="function"==typeof t.error?await t.error(e):t.error,o="function"==typeof t.description?await t.description(e):t.description,i="object"==typeof r&&!H.isValidElement(r)?r:{message:r};this.create({id:n,type:"error",description:o,...i})}}).finally(()=>{a&&(this.dismiss(n),n=void 0),null==t.finally||t.finally.call(t)}),s=()=>new Promise((e,t)=>i.then(()=>"reject"===o[0]?t(o[1]):e(o[1])).catch(t));return"string"!=typeof n&&"number"!=typeof n?{unwrap:s}:Object.assign(n,{unwrap:s})},this.custom=(e,t)=>{const n=(null==t?void 0:t.id)||sN++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},uN=e=>e&&"object"==typeof e&&"ok"in e&&"boolean"==typeof e.ok&&"status"in e&&"number"==typeof e.status,cN=(e,t)=>{const n=(null==t?void 0:t.id)||sN++;return lN.addToast({title:e,...t,id:n}),n},dN=Object.assign(cN,{success:lN.success,info:lN.info,warning:lN.warning,error:lN.error,custom:lN.custom,message:lN.message,promise:lN.promise,dismiss:lN.dismiss,loading:lN.loading},{getHistory:()=>lN.toasts,getToasts:()=>lN.getActiveToasts()});function fN(e){return void 0!==e.label}!function(e){if("undefined"==typeof document)return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");const pN=3,hN=14;function mN(...e){return e.filter(Boolean).join(" ")}const gN=e=>{var t,n,r,o,a,i,s,l,u;const{invert:c,toast:d,unstyled:f,interacting:p,setHeights:h,visibleToasts:m,heights:g,index:v,toasts:y,expanded:b,removeToast:x,defaultRichColors:w,closeButton:k,style:S,cancelButtonStyle:E,actionButtonStyle:j,className:C="",descriptionClassName:P="",duration:N,position:T,gap:M,expandByDefault:R,classNames:L,icons:D,closeButtonAriaLabel:_="Close toast"}=e,[A,O]=H.useState(null),[I,z]=H.useState(null),[F,V]=H.useState(!1),[B,$]=H.useState(!1),[U,W]=H.useState(!1),[G,Y]=H.useState(!1),[q,K]=H.useState(!1),[X,Q]=H.useState(0),[Z,J]=H.useState(0),ee=H.useRef(d.duration||N||4e3),te=H.useRef(null),ne=H.useRef(null),re=0===v,oe=v+1<=m,ae=d.type,ie=!1!==d.dismissible,se=d.className||"",le=d.descriptionClassName||"",ue=H.useMemo(()=>g.findIndex(e=>e.toastId===d.id)||0,[g,d.id]),ce=H.useMemo(()=>{var e;return null!=(e=d.closeButton)?e:k},[d.closeButton,k]),de=H.useMemo(()=>d.duration||N||4e3,[d.duration,N]),fe=H.useRef(0),pe=H.useRef(0),he=H.useRef(0),me=H.useRef(null),[ge,ve]=T.split("-"),ye=H.useMemo(()=>g.reduce((e,t,n)=>n>=ue?e:e+t.height,0),[g,ue]),be=(()=>{const[e,t]=H.useState(document.hidden);return H.useEffect(()=>{const e=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",e),()=>window.removeEventListener("visibilitychange",e)},[]),e})(),xe=d.invert||c,we="loading"===ae;pe.current=H.useMemo(()=>ue*M+ye,[ue,ye]),H.useEffect(()=>{ee.current=de},[de]),H.useEffect(()=>{V(!0)},[]),H.useEffect(()=>{const e=ne.current;if(e){const t=e.getBoundingClientRect().height;return J(t),h(e=>[{toastId:d.id,height:t,position:d.position},...e]),()=>h(e=>e.filter(e=>e.toastId!==d.id))}},[h,d.id]),H.useLayoutEffect(()=>{if(!F)return;const e=ne.current,t=e.style.height;e.style.height="auto";const n=e.getBoundingClientRect().height;e.style.height=t,J(n),h(e=>e.find(e=>e.toastId===d.id)?e.map(e=>e.toastId===d.id?{...e,height:n}:e):[{toastId:d.id,height:n,position:d.position},...e])},[F,d.title,d.description,h,d.id,d.jsx,d.action,d.cancel]);const ke=H.useCallback(()=>{$(!0),Q(pe.current),h(e=>e.filter(e=>e.toastId!==d.id)),setTimeout(()=>{x(d)},200)},[d,x,h,pe]);H.useEffect(()=>{if(d.promise&&"loading"===ae||d.duration===1/0||"loading"===d.type)return;let e;return b||p||be?(()=>{if(he.current<fe.current){const e=(new Date).getTime()-fe.current;ee.current=ee.current-e}he.current=(new Date).getTime()})():ee.current!==1/0&&(fe.current=(new Date).getTime(),e=setTimeout(()=>{null==d.onAutoClose||d.onAutoClose.call(d,d),ke()},ee.current)),()=>clearTimeout(e)},[b,p,d,ae,be,ke]),H.useEffect(()=>{d.delete&&(ke(),null==d.onDismiss||d.onDismiss.call(d,d))},[ke,d.delete]);const Se=d.icon||(null==D?void 0:D[ae])||(e=>{switch(e){case"success":return nN;case"info":return oN;case"warning":return rN;case"error":return aN;default:return null}})(ae);var Ee,je,Ce,Pe;return H.createElement("li",{tabIndex:0,ref:ne,className:mN(C,se,null==L?void 0:L.toast,null==d||null==(t=d.classNames)?void 0:t.toast,null==L?void 0:L.default,null==L?void 0:L[ae],null==d||null==(n=d.classNames)?void 0:n[ae]),"data-sonner-toast":"","data-rich-colors":null!=(Ee=d.richColors)?Ee:w,"data-styled":!Boolean(d.jsx||d.unstyled||f),"data-mounted":F,"data-promise":Boolean(d.promise),"data-swiped":q,"data-removed":B,"data-visible":oe,"data-y-position":ge,"data-x-position":ve,"data-index":v,"data-front":re,"data-swiping":U,"data-dismissible":ie,"data-type":ae,"data-invert":xe,"data-swipe-out":G,"data-swipe-direction":I,"data-expanded":Boolean(b||R&&F),"data-testid":d.testId,style:{"--index":v,"--toasts-before":v,"--z-index":y.length-v,"--offset":`${B?X:pe.current}px`,"--initial-height":R?"auto":`${Z}px`,...S,...d.style},onDragEnd:()=>{W(!1),O(null),me.current=null},onPointerDown:e=>{2!==e.button&&!we&&ie&&(te.current=new Date,Q(pe.current),e.target.setPointerCapture(e.pointerId),"BUTTON"!==e.target.tagName&&(W(!0),me.current={x:e.clientX,y:e.clientY}))},onPointerUp:()=>{var e,t,n;if(G||!ie)return;me.current=null;const r=Number((null==(e=ne.current)?void 0:e.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),o=Number((null==(t=ne.current)?void 0:t.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),a=(new Date).getTime()-(null==(n=te.current)?void 0:n.getTime()),i="x"===A?r:o,s=Math.abs(i)/a;if(Math.abs(i)>=45||s>.11)return Q(pe.current),null==d.onDismiss||d.onDismiss.call(d,d),z("x"===A?r>0?"right":"left":o>0?"down":"up"),ke(),void Y(!0);var l,u;null==(l=ne.current)||l.style.setProperty("--swipe-amount-x","0px"),null==(u=ne.current)||u.style.setProperty("--swipe-amount-y","0px"),K(!1),W(!1),O(null)},onPointerMove:t=>{var n,r,o;if(!me.current||!ie)return;if((null==(n=window.getSelection())?void 0:n.toString().length)>0)return;const a=t.clientY-me.current.y,i=t.clientX-me.current.x;var s;const l=null!=(s=e.swipeDirections)?s:function(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}(T);!A&&(Math.abs(i)>1||Math.abs(a)>1)&&O(Math.abs(i)>Math.abs(a)?"x":"y");let u={x:0,y:0};const c=e=>1/(1.5+Math.abs(e)/20);if("y"===A){if(l.includes("top")||l.includes("bottom"))if(l.includes("top")&&a<0||l.includes("bottom")&&a>0)u.y=a;else{const e=a*c(a);u.y=Math.abs(e)<Math.abs(a)?e:a}}else if("x"===A&&(l.includes("left")||l.includes("right")))if(l.includes("left")&&i<0||l.includes("right")&&i>0)u.x=i;else{const e=i*c(i);u.x=Math.abs(e)<Math.abs(i)?e:i}(Math.abs(u.x)>0||Math.abs(u.y)>0)&&K(!0),null==(r=ne.current)||r.style.setProperty("--swipe-amount-x",`${u.x}px`),null==(o=ne.current)||o.style.setProperty("--swipe-amount-y",`${u.y}px`)}},ce&&!d.jsx&&"loading"!==ae?H.createElement("button",{"aria-label":_,"data-disabled":we,"data-close-button":!0,onClick:we||!ie?()=>{}:()=>{ke(),null==d.onDismiss||d.onDismiss.call(d,d)},className:mN(null==L?void 0:L.closeButton,null==d||null==(r=d.classNames)?void 0:r.closeButton)},null!=(je=null==D?void 0:D.close)?je:iN):null,(ae||d.icon||d.promise)&&null!==d.icon&&(null!==(null==D?void 0:D[ae])||d.icon)?H.createElement("div",{"data-icon":"",className:mN(null==L?void 0:L.icon,null==d||null==(o=d.classNames)?void 0:o.icon)},d.promise||"loading"===d.type&&!d.icon?d.icon||((null==D?void 0:D.loading)?H.createElement("div",{className:mN(null==L?void 0:L.loader,null==d||null==(Pe=d.classNames)?void 0:Pe.loader,"sonner-loader"),"data-visible":"loading"===ae},D.loading):H.createElement(tN,{className:mN(null==L?void 0:L.loader,null==d||null==(Ce=d.classNames)?void 0:Ce.loader),visible:"loading"===ae})):null,"loading"!==d.type?Se:null):null,H.createElement("div",{"data-content":"",className:mN(null==L?void 0:L.content,null==d||null==(a=d.classNames)?void 0:a.content)},H.createElement("div",{"data-title":"",className:mN(null==L?void 0:L.title,null==d||null==(i=d.classNames)?void 0:i.title)},d.jsx?d.jsx:"function"==typeof d.title?d.title():d.title),d.description?H.createElement("div",{"data-description":"",className:mN(P,le,null==L?void 0:L.description,null==d||null==(s=d.classNames)?void 0:s.description)},"function"==typeof d.description?d.description():d.description):null),H.isValidElement(d.cancel)?d.cancel:d.cancel&&fN(d.cancel)?H.createElement("button",{"data-button":!0,"data-cancel":!0,style:d.cancelButtonStyle||E,onClick:e=>{fN(d.cancel)&&ie&&(null==d.cancel.onClick||d.cancel.onClick.call(d.cancel,e),ke())},className:mN(null==L?void 0:L.cancelButton,null==d||null==(l=d.classNames)?void 0:l.cancelButton)},d.cancel.label):null,H.isValidElement(d.action)?d.action:d.action&&fN(d.action)?H.createElement("button",{"data-button":!0,"data-action":!0,style:d.actionButtonStyle||j,onClick:e=>{fN(d.action)&&(null==d.action.onClick||d.action.onClick.call(d.action,e),e.defaultPrevented||ke())},className:mN(null==L?void 0:L.actionButton,null==d||null==(u=d.classNames)?void 0:u.actionButton)},d.action.label):null)};function vN(){if("undefined"==typeof window)return"ltr";if("undefined"==typeof document)return"ltr";const e=document.documentElement.getAttribute("dir");return"auto"!==e&&e?e:window.getComputedStyle(document.documentElement).direction}function yN(e,t){const n={};return[e,t].forEach((e,t)=>{const r=1===t,o=r?"--mobile-offset":"--offset",a=r?"16px":"24px";function i(e){["top","right","bottom","left"].forEach(t=>{n[`${o}-${t}`]="number"==typeof e?`${e}px`:e})}"number"==typeof e||"string"==typeof e?i(e):"object"==typeof e?["top","right","bottom","left"].forEach(t=>{void 0===e[t]?n[`${o}-${t}`]=a:n[`${o}-${t}`]="number"==typeof e[t]?`${e[t]}px`:e[t]}):i(a)}),n}const bN=H.forwardRef(function(e,t){const{id:n,invert:r,position:o="bottom-right",hotkey:a=["altKey","KeyT"],expand:i,closeButton:s,className:l,offset:u,mobileOffset:c,theme:d="light",richColors:f,duration:p,style:h,visibleToasts:m=pN,toastOptions:g,dir:v=vN(),gap:y=hN,icons:b,containerAriaLabel:x="Notifications"}=e,[w,k]=H.useState([]),S=H.useMemo(()=>n?w.filter(e=>e.toasterId===n):w.filter(e=>!e.toasterId),[w,n]),E=H.useMemo(()=>Array.from(new Set([o].concat(S.filter(e=>e.position).map(e=>e.position)))),[S,o]),[j,C]=H.useState([]),[P,N]=H.useState(!1),[T,M]=H.useState(!1),[R,L]=H.useState("system"!==d?d:"undefined"!=typeof window&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),D=H.useRef(null),_=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),A=H.useRef(null),O=H.useRef(!1),I=H.useCallback(e=>{k(t=>{var n;return(null==(n=t.find(t=>t.id===e.id))?void 0:n.delete)||lN.dismiss(e.id),t.filter(({id:t})=>t!==e.id)})},[]);return H.useEffect(()=>lN.subscribe(e=>{e.dismiss?requestAnimationFrame(()=>{k(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))}):setTimeout(()=>{ud.flushSync(()=>{k(t=>{const n=t.findIndex(t=>t.id===e.id);return-1!==n?[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]:[e,...t]})})})}),[w]),H.useEffect(()=>{if("system"!==d)return void L(d);if("system"===d&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?L("dark"):L("light")),"undefined"==typeof window)return;const e=window.matchMedia("(prefers-color-scheme: dark)");try{e.addEventListener("change",({matches:e})=>{L(e?"dark":"light")})}catch(t){e.addListener(({matches:e})=>{try{L(e?"dark":"light")}catch(MT){console.error(MT)}})}},[d]),H.useEffect(()=>{w.length<=1&&N(!1)},[w]),H.useEffect(()=>{const e=e=>{var t;var n;a.every(t=>e[t]||e.code===t)&&(N(!0),null==(n=D.current)||n.focus());"Escape"!==e.code||document.activeElement!==D.current&&!(null==(t=D.current)?void 0:t.contains(document.activeElement))||N(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[a]),H.useEffect(()=>{if(D.current)return()=>{A.current&&(A.current.focus({preventScroll:!0}),A.current=null,O.current=!1)}},[D.current]),H.createElement("section",{ref:t,"aria-label":`${x} ${_}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},E.map((t,n)=>{var o;const[a,d]=t.split("-");return S.length?H.createElement("ol",{key:t,dir:"auto"===v?vN():v,tabIndex:-1,ref:D,className:l,"data-sonner-toaster":!0,"data-sonner-theme":R,"data-y-position":a,"data-x-position":d,style:{"--front-toast-height":`${(null==(o=j[0])?void 0:o.height)||0}px`,"--width":"356px","--gap":`${y}px`,...h,...yN(u,c)},onBlur:e=>{O.current&&!e.currentTarget.contains(e.relatedTarget)&&(O.current=!1,A.current&&(A.current.focus({preventScroll:!0}),A.current=null))},onFocus:e=>{e.target instanceof HTMLElement&&"false"===e.target.dataset.dismissible||O.current||(O.current=!0,A.current=e.relatedTarget)},onMouseEnter:()=>N(!0),onMouseMove:()=>N(!0),onMouseLeave:()=>{T||N(!1)},onDragEnd:()=>N(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&"false"===e.target.dataset.dismissible||M(!0)},onPointerUp:()=>M(!1)},S.filter(e=>!e.position&&0===n||e.position===t).map((n,o)=>{var a,l;return H.createElement(gN,{key:n.id,icons:b,index:o,toast:n,defaultRichColors:f,duration:null!=(a=null==g?void 0:g.duration)?a:p,className:null==g?void 0:g.className,descriptionClassName:null==g?void 0:g.descriptionClassName,invert:r,visibleToasts:m,closeButton:null!=(l=null==g?void 0:g.closeButton)?l:s,interacting:T,position:t,style:null==g?void 0:g.style,unstyled:null==g?void 0:g.unstyled,classNames:null==g?void 0:g.classNames,cancelButtonStyle:null==g?void 0:g.cancelButtonStyle,actionButtonStyle:null==g?void 0:g.actionButtonStyle,closeButtonAriaLabel:null==g?void 0:g.closeButtonAriaLabel,removeToast:I,toasts:S.filter(e=>e.position==n.position),heights:j.filter(e=>e.position==n.position),setHeights:C,expandByDefault:i,gap:y,expanded:P,swipeDirections:e.swipeDirections})})):null}))}),xN=W.createContext(null);function wN({children:e}){const[t,n]=W.useState(!1),[r,o]=W.useState({}),a=W.useRef(null),i=W.useCallback(e=>(o(e),n(!0),new Promise(e=>{a.current=e})),[]),s=W.useCallback(e=>{n(!1);const t=a.current;a.current=null,t&&t(e)},[]);return ee.jsxs(xN.Provider,{value:i,children:[e,ee.jsx(HP,{open:t,onOpenChange:e=>{e||s(!1)},children:ee.jsxs(qP,{className:"max-w-md",children:[ee.jsxs(KP,{children:[ee.jsx(QP,{children:r.title??"确认"}),void 0!==r.description&&ee.jsx(ZP,{asChild:!0,children:ee.jsx("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),ee.jsxs(XP,{children:[ee.jsx(Rk,{variant:"outline",onClick:()=>s(!1),children:r.cancelLabel??"取消"}),ee.jsx(kN,{destructive:r.destructive,onClick:()=>s(!0),children:r.confirmLabel??"确定"})]})]})})]})}function kN({destructive:e,onClick:t,children:n}){const r=W.useRef(null);return W.useEffect(()=>{var e;null==(e=r.current)||e.focus()},[]),ee.jsx(Rk,{ref:r,onClick:t,className:uk(e&&"bg-red-600 hover:bg-red-700 text-white"),children:n})}function SN(){const e=W.useContext(xN);if(!e)throw new Error("useConfirm must be used within <ConfirmProvider>");return e}function EN(e,t){switch(e){case"thinking":return"Thinking…";case"tool_use":return t?`${t}`:"Tool…";case"tool_result":return"Reading…";case"text":return"Writing…"}}function jN({status:e}){return ee.jsx("span",{className:uk("inline-block w-2 h-2 rounded-full",{"bg-green-500":"running"===e,"bg-zinc-400":"stopped"===e,"bg-yellow-400 animate-pulse":"restarting"===e})})}const CN=H.memo(function({project:e,active:t=!1,statusStack:n=[],onDelete:r,onArchive:o,onUnarchive:a,onUpdated:i}){var s,l;const u=cf(),c=SN(),[d,f]=W.useState(!1),[p,h]=W.useState(null),[m,g]=W.useState(!1),[v,y]=W.useState(e.name),b=W.useRef(null),x=!!e._sharedPermission;W.useEffect(()=>{let t=!1;return gE(e.id).then(({bytes:e})=>{t||h(e)}).catch(()=>{}),()=>{t=!0}},[e.id]);const w="view"===e._sharedPermission,k=t=>{t.stopPropagation(),y(e.name),g(!0),setTimeout(()=>{var e;return null==(e=b.current)?void 0:e.select()},0)},S=async()=>{const t=v.trim();if(t&&t!==e.name)try{const n=await hE(e.id,t);null==i||i(n),g(!1)}catch(RT){dN.error("Rename failed",{description:null==RT?void 0:RT.message})}else g(!1)},E=ee.jsx(hw.div,{whileHover:e.archived||t?{}:{y:-2},transition:{duration:.2},children:ee.jsxs(ck,{className:uk("group cursor-pointer transition-colors relative",e.archived?"opacity-60 hover:opacity-80 hover:border-zinc-400":t?"border-transparent hover:border-transparent bg-transparent shadow-none":"hover:border-zinc-400 hover:shadow-md"),onClick:()=>!e.archived&&u(`/projects/${e.id}`),children:[ee.jsxs(dk,{className:"pb-2",children:[ee.jsxs("div",{className:"flex items-start justify-between gap-2",children:[m?ee.jsx("input",{ref:b,className:"text-base leading-tight font-semibold bg-transparent border-b border-primary outline-none w-full min-w-0",value:v,onChange:e=>y(e.target.value),onBlur:()=>{S()},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),S()),"Escape"===e.key&&g(!1)},onClick:e=>e.stopPropagation()}):ee.jsx(fk,{className:uk("text-base leading-tight",e.archived&&"text-muted-foreground"),onDoubleClick:x||e.archived?void 0:k,children:e.name}),ee.jsx("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",children:!x&&ee.jsxs(ee.Fragment,{children:[e.archived?ee.jsx(Rk,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:t=>{t.stopPropagation(),a(e.id)},title:"Restore project",children:ee.jsx(IE,{className:"h-3.5 w-3.5"})}):ee.jsxs(ee.Fragment,{children:[ee.jsx(Rk,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:k,title:"Rename project",children:ee.jsx(lj,{className:"h-3.5 w-3.5"})}),ee.jsx(Rk,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:e=>{e.stopPropagation(),f(!0)},title:"共享设置",children:ee.jsx(xj,{className:"h-3.5 w-3.5"})}),ee.jsx(Rk,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:t=>{t.stopPropagation(),o(e.id)},title:"Archive project",children:ee.jsx(zE,{className:"h-3.5 w-3.5"})})]}),ee.jsx(Rk,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:async t=>{t.stopPropagation();await c({title:"删除项目",description:`确认删除项目 "${e.name}"?此操作不可撤销。`,destructive:!0,confirmLabel:"删除"})&&r(e.id)},title:"Delete project",children:ee.jsx(bj,{className:"h-3.5 w-3.5"})})]})})]}),ee.jsx("div",{className:"flex items-center gap-1.5",children:e.archived?ee.jsx(Ej,{variant:"secondary",className:"text-xs",children:"Archived"}):ee.jsxs(ee.Fragment,{children:[ee.jsx(jN,{status:e.status}),ee.jsx("span",{className:"text-xs text-muted-foreground capitalize",children:e.status}),t&&n.length>0&&ee.jsx("div",{className:"ml-auto",children:ee.jsx(Xb,{mode:"wait",children:n.slice(-1).map(e=>ee.jsx(hw.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{duration:.25,ease:"easeOut"},children:ee.jsx(Ej,{variant:"outline",className:"text-xs font-normal whitespace-nowrap",children:EN(e.phase,e.detail)})},e.id))})})]})})]}),ee.jsxs(hk,{className:"space-y-2",children:[ee.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[ee.jsx(HE,{className:"h-3.5 w-3.5 flex-shrink-0"}),ee.jsx("span",{className:"truncate font-mono",children:e.folderPath}),null!==p&&ee.jsx("span",{className:"flex-shrink-0 ml-auto text-muted-foreground/70",children:(j=p,j>=1073741824?(j/1073741824).toFixed(1)+" GB":j>=1048576?(j/1048576).toFixed(1)+" MB":Math.round(j/1024)+" KB")})]}),ee.jsxs("div",{className:"flex items-center gap-2",children:[ee.jsx(Ej,{variant:"outline",className:"text-xs font-mono",children:e.cliTool??"claude"}),ee.jsx(Ej,{variant:"unlimited"===e.permissionMode?"destructive":"secondary",className:"text-xs",children:"unlimited"===e.permissionMode?"Unlimited":"Limited"}),x&&ee.jsxs(Ej,{variant:"outline",className:"text-xs gap-0.5",children:[w?ee.jsx(UE,{className:"h-3 w-3"}):ee.jsx(lj,{className:"h-3 w-3"}),w?"可见":"可编辑"]}),!x&&e.shares&&e.shares.length>0&&ee.jsxs(Ej,{variant:"outline",className:"text-xs gap-0.5",children:[ee.jsx(xj,{className:"h-3 w-3"}),e.shares.length]}),ee.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(e.createdAt).toLocaleDateString()})]}),(e.tags??[]).length>0&&ee.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[(e.tags??[]).slice(0,3).map(e=>ee.jsxs("span",{className:"px-1.5 py-0 rounded-full text-[10px] bg-muted text-muted-foreground border border-border",children:["#",e]},e)),((null==(s=e.tags)?void 0:s.length)??0)>3&&ee.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["+",((null==(l=e.tags)?void 0:l.length)??0)-3]})]})]})]})});var j;const C=t&&!e.archived?ee.jsx("div",{className:"card-active-glow rounded-lg",children:E}):E;return ee.jsxs(ee.Fragment,{children:[C,!x&&i&&ee.jsx(JP,{project:e,open:d,onOpenChange:f,onUpdated:i})]})});function PN({onSelect:e}){const[t,n]=W.useState(""),[r,o]=W.useState(null),[a,i]=W.useState([]),[s,l]=W.useState(!0),[u,c]=W.useState(null),[d,f]=W.useState(!1),[p,h]=W.useState(""),[m,g]=W.useState(null),[v,y]=W.useState(!1),b=W.useRef(null),x=async e=>{l(!0),c(null);try{const t=await VS(e);n(t.path),o(t.parent),i(t.entries)}catch(RT){c(RT instanceof Error?RT.message:"Failed to load directory")}finally{l(!1)}};W.useEffect(()=>{x()},[]),W.useEffect(()=>{d&&setTimeout(()=>{var e;return null==(e=b.current)?void 0:e.focus()},0)},[d]);const w=()=>{f(!1),h(""),g(null)},k=async()=>{const e=p.trim();if(e){y(!0),g(null);try{const{path:n}=await US(t,e);f(!1),h(""),await x(t),x(n)}catch(RT){g(RT instanceof Error?RT.message:"Failed to create folder")}finally{y(!1)}}},S=t.split("/").filter(Boolean);return ee.jsxs("div",{className:"flex flex-col h-64 border rounded-md overflow-hidden",children:[ee.jsxs("div",{className:"flex items-center gap-1 px-2 py-2 bg-muted border-b flex-shrink-0",children:[ee.jsx(Rk,{variant:"ghost",size:"sm",className:"h-6 px-1 flex-shrink-0",onClick:()=>{x()},title:"Home",children:ee.jsx(ZE,{className:"h-3 w-3"})}),ee.jsx("div",{className:"flex items-center gap-1 flex-1 overflow-x-auto min-w-0",children:S.map((e,t)=>ee.jsxs(H.Fragment,{children:[ee.jsx(BE,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),ee.jsx("button",{className:"text-xs hover:text-foreground text-muted-foreground whitespace-nowrap",onClick:()=>(e=>{const t="/"+S.slice(0,e+1).join("/");x(t)})(t),children:e})]},t))}),ee.jsxs(Rk,{variant:"ghost",size:"sm",className:"h-6 px-1.5 flex-shrink-0 gap-1 text-xs",onClick:()=>{h(""),g(null),f(!0)},disabled:d||s||!!u,title:"New folder",children:[ee.jsx(GE,{className:"h-3.5 w-3.5"}),ee.jsx("span",{className:"hidden sm:inline",children:"New folder"})]})]}),ee.jsxs("div",{className:"flex-1 overflow-y-auto",children:[s&&ee.jsx("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:"Loading..."}),u&&ee.jsx("div",{className:"flex items-center justify-center h-full text-sm text-destructive px-4 text-center",children:u}),!s&&!u&&ee.jsxs("div",{className:"p-1",children:[r&&ee.jsxs("button",{className:"flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded hover:bg-accent hover:text-accent-foreground",onClick:()=>{x(r)},children:[ee.jsx(FE,{className:"h-4 w-4 text-muted-foreground"}),ee.jsx("span",{children:".."})]}),d&&ee.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5",children:[ee.jsx(qE,{className:"h-4 w-4 text-blue-500 flex-shrink-0"}),ee.jsx("input",{ref:b,className:uk("flex-1 text-sm bg-background border rounded px-1.5 py-0.5 outline-none","focus:ring-1 focus:ring-ring",m&&"border-destructive"),placeholder:"Folder name",value:p,onChange:e=>{h(e.target.value),g(null)},onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),k()):"Escape"===e.key&&w()},disabled:v}),ee.jsx("button",{className:"p-1 rounded hover:bg-accent disabled:opacity-50",onClick:()=>{k()},disabled:!p.trim()||v,title:"Create",children:ee.jsx(VE,{className:"h-3.5 w-3.5 text-green-600"})}),ee.jsx("button",{className:"p-1 rounded hover:bg-accent",onClick:w,disabled:v,title:"Cancel",children:ee.jsx(wj,{className:"h-3.5 w-3.5 text-muted-foreground"})})]}),m&&ee.jsx("p",{className:"px-3 pb-1 text-xs text-destructive",children:m}),0===a.length&&!d&&ee.jsx("div",{className:"text-sm text-muted-foreground px-2 py-4 text-center",children:"Empty directory"}),a.map(e=>ee.jsxs("button",{className:uk("flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded text-left","dir"===e.type?"hover:bg-accent hover:text-accent-foreground cursor-pointer":"opacity-40 cursor-not-allowed"),onClick:()=>{"dir"===e.type&&x(e.path)},disabled:"file"===e.type,children:["dir"===e.type?ee.jsx(qE,{className:"h-4 w-4 text-blue-500 flex-shrink-0"}):ee.jsx(WE,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),ee.jsx("span",{className:"truncate",children:e.name})]},e.path))]})]}),ee.jsxs("div",{className:"border-t px-3 py-2 flex items-center justify-between gap-2 flex-shrink-0 bg-background",children:[ee.jsx("span",{className:"text-xs text-muted-foreground truncate flex-1",children:t}),ee.jsx(Rk,{size:"sm",onClick:()=>e(t),disabled:!t,children:"Select this folder"})]})]})}const NN=[{value:"claude",label:"Claude",desc:"Anthropic Claude Code CLI"},{value:"opencode",label:"OpenCode",desc:"OpenCode CLI (sst/opencode)"},{value:"codex",label:"Codex",desc:"OpenAI Codex CLI"},{value:"qwen",label:"Qwen",desc:"Qwen Code CLI (QwenLM)"},{value:"gemini",label:"Gemini",desc:"Google Gemini CLI"},{value:"terminal",label:"Terminal",desc:"Plain shell (no AI CLI)"}],TN={claude:{limited:"claude",unlimited:"claude --dangerously-skip-permissions"},opencode:{limited:"opencode",unlimited:"opencode --dangerously-skip-permissions"},codex:{limited:"codex",unlimited:"codex --ask-for-approval never --sandbox danger-full-access"},qwen:{limited:"qwen-code",unlimited:"qwen-code --yolo"},gemini:{limited:"gemini",unlimited:"gemini --yolo"},terminal:{limited:"$SHELL (interactive)",unlimited:"$SHELL (interactive)"}};function MN({open:e,onOpenChange:t,onCreated:n}){const[r,o]=W.useState("name"),[a,i]=W.useState(""),[s,l]=W.useState(""),[u,c]=W.useState("claude"),[d,f]=W.useState("limited"),[p,h]=W.useState(!1),[m,g]=W.useState(null),v=e=>{e||(o("name"),i(""),l(""),c("claude"),f("limited"),g(null),h(!1)),t(e)},y=()=>{a.trim()?(g(null),o("folder")):g("Please enter a project name")},b=["name","folder","settings"];return ee.jsx(HP,{open:e,onOpenChange:v,children:ee.jsxs(qP,{className:"sm:max-w-lg",children:[ee.jsxs(KP,{children:[ee.jsx(QP,{children:{name:"New Project — Name",folder:"New Project — Select Folder",settings:"New Project — Settings"}[r]}),ee.jsxs(ZP,{children:["name"===r&&"Give your project a name.","folder"===r&&"Choose the working directory for this project.","settings"===r&&"Choose the AI coding tool and run mode."]})]}),ee.jsx("div",{className:"flex gap-2 mb-2",children:b.map((e,t)=>ee.jsx("div",{className:"h-1.5 flex-1 rounded-full "+(r===e?"bg-primary":b.indexOf(r)>t?"bg-primary/40":"bg-muted")},e))}),"name"===r&&ee.jsxs("div",{className:"space-y-4",children:[ee.jsxs("div",{className:"space-y-2",children:[ee.jsx(Ik,{htmlFor:"project-name",children:"Project Name"}),ee.jsx(Lk,{id:"project-name",placeholder:"My Project",value:a,onChange:e=>i(e.target.value),onKeyDown:e=>{"Enter"===e.key&&y()},autoFocus:!0})]}),m&&ee.jsx("p",{className:"text-sm text-destructive",children:m})]}),"folder"===r&&ee.jsxs("div",{className:"space-y-2",children:[ee.jsx(Ik,{children:"Working Directory"}),ee.jsx(PN,{onSelect:e=>{l(e),o("settings")}})]}),"settings"===r&&ee.jsxs("div",{className:"space-y-5",children:[ee.jsxs("div",{className:"space-y-2",children:[ee.jsx(Ik,{children:"AI Coding Tool"}),ee.jsx("div",{className:"grid grid-cols-2 gap-2",children:NN.map(e=>ee.jsxs("label",{className:"flex items-center gap-2.5 cursor-pointer p-3 rounded-md border transition-colors "+(u===e.value?"border-primary bg-primary/5":"hover:bg-accent"),children:[ee.jsx("input",{type:"radio",name:"cliTool",value:e.value,checked:u===e.value,onChange:()=>c(e.value),className:"accent-primary"}),ee.jsxs("div",{children:[ee.jsx("div",{className:"font-medium text-sm",children:e.label}),ee.jsx("div",{className:"text-xs text-muted-foreground",children:e.desc})]})]},e.value))})]}),"terminal"!==u&&ee.jsxs("div",{className:"space-y-2",children:[ee.jsx(Ik,{children:"Permission Mode"}),ee.jsxs("div",{className:"space-y-2",children:[ee.jsxs("label",{className:"flex items-start gap-3 cursor-pointer p-3 rounded-md border hover:bg-accent transition-colors",children:[ee.jsx("input",{type:"radio",name:"permissionMode",value:"limited",checked:"limited"===d,onChange:()=>f("limited"),className:"mt-0.5"}),ee.jsxs("div",{children:[ee.jsx("div",{className:"font-medium text-sm",children:"Limited"}),ee.jsxs("div",{className:"text-xs text-muted-foreground",children:["Runs ",ee.jsx("code",{className:"bg-muted px-1 rounded",children:TN[u].limited})," — asks for permission before file changes."]})]})]}),ee.jsxs("label",{className:"flex items-start gap-3 cursor-pointer p-3 rounded-md border hover:bg-accent transition-colors",children:[ee.jsx("input",{type:"radio",name:"permissionMode",value:"unlimited",checked:"unlimited"===d,onChange:()=>f("unlimited"),className:"mt-0.5"}),ee.jsxs("div",{children:[ee.jsx("div",{className:"font-medium text-sm",children:"Unlimited"}),ee.jsxs("div",{className:"text-xs text-muted-foreground",children:["Runs ",ee.jsx("code",{className:"bg-muted px-1 rounded",children:TN[u].unlimited})," — acts autonomously."]})]})]})]})]}),ee.jsxs("div",{className:"text-xs text-muted-foreground",children:[ee.jsx("span",{className:"font-medium",children:"Folder:"})," ",ee.jsx("span",{className:"font-mono",children:s})]}),m&&ee.jsx("p",{className:"text-sm text-destructive",children:m})]}),ee.jsxs(XP,{children:["name"!==r&&ee.jsx(Rk,{variant:"outline",onClick:()=>o("settings"===r?"folder":"name"),disabled:p,children:"Back"}),"name"===r&&ee.jsx(Rk,{onClick:y,children:"Next"}),"folder"===r&&ee.jsx(Rk,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),"settings"===r&&ee.jsx(Rk,{onClick:()=>{(async()=>{h(!0),g(null);try{const e=await lS({name:a.trim(),folderPath:s,permissionMode:d,cliTool:u});n(e),v(!1)}catch(RT){g(RT instanceof Error?RT.message:"Failed to create project")}finally{h(!1)}})()},disabled:p,children:p?"Creating...":"Create Project"})]})]})})}function RN({open:e,onOpenChange:t,onOpened:n}){const[r,o]=W.useState(""),[a,i]=W.useState(!1),[s,l]=W.useState(null),u=e=>{e||(o(""),l(null),i(!1)),t(e)};return ee.jsx(HP,{open:e,onOpenChange:u,children:ee.jsxs(qP,{className:"sm:max-w-lg",children:[ee.jsxs(KP,{children:[ee.jsx(QP,{children:"Open Existing Project"}),ee.jsxs(ZP,{children:["Select a folder that contains a ",ee.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:".ccweb/"})," configuration. The project's history and settings will be restored."]})]}),ee.jsxs("div",{className:"space-y-2",children:[ee.jsx(Ik,{children:"Project Folder"}),ee.jsx(PN,{onSelect:e=>{(async e=>{o(e),i(!0),l(null);try{const t=await uS(e);n(t),u(!1)}catch(RT){l(RT instanceof Error?RT.message:"Failed to open project"),i(!1)}})(e)}})]}),s&&ee.jsx("p",{className:"text-sm text-destructive",children:s}),r&&!s&&a&&ee.jsxs("p",{className:"text-sm text-muted-foreground",children:["Opening project from ",r,"..."]}),ee.jsx(XP,{children:ee.jsx(Rk,{variant:"outline",onClick:()=>u(!1),disabled:a,children:"Cancel"})})]})})}const LN=`${"https:"===window.location.protocol?"wss:":"ws:"}//${window.location.host}`,DN=3e3;function _N(e,t){const n=W.useRef(null),r=W.useRef(0),o=W.useRef(!0),a=W.useRef(!1),i=W.useRef(null),s=W.useRef(t);s.current=t;const[l,u]=W.useState(!1),[c,d]=W.useState(0),f=W.useRef(!1),p=W.useRef([]),h=W.useCallback(e=>{var t;(null==(t=n.current)?void 0:t.readyState)===WebSocket.OPEN&&n.current.send(JSON.stringify(e))},[]),m=W.useCallback(()=>{var e;if((null==(e=n.current)?void 0:e.readyState)===WebSocket.OPEN)for(;p.current.length>0;){const e=p.current.shift();n.current.send(JSON.stringify({type:"terminal_input",data:e}))}},[]),g=W.useCallback((e,t)=>{var r;(null==(r=n.current)?void 0:r.readyState)===WebSocket.OPEN?(n.current.send(JSON.stringify({type:"terminal_subscribe",cols:e,rows:t})),f.current=!1):f.current=!0},[]),v=W.useCallback(e=>{var t;(null==(t=n.current)?void 0:t.readyState)===WebSocket.OPEN?n.current.send(JSON.stringify({type:"terminal_input",data:e})):p.current.push(e)},[]),y=W.useCallback((e,t)=>{h({type:"terminal_resize",cols:e,rows:t})},[h]),b=W.useCallback(()=>{h({type:"chat_subscribe",replay:50})},[h]),x=W.useCallback(()=>{if(!o.current)return;if(a.current)return;const t=Zk();if(!t)return void(window.location.href="/login");a.current=!0;const l=new WebSocket(`${LN}/ws/projects/${e}`);n.current=l,l.onopen=()=>{a.current=!1,r.current=0,l.send(JSON.stringify({type:"auth",token:t}))},l.onmessage=e=>{var t,n,r,o,a,i,l,c,p,h,g,v,y,b,x,w,k,S;let E;try{E=JSON.parse(e.data)}catch{return}switch(E.type){case"connected":f.current=!1,u(!0),d(e=>e+1),m(),null==(n=(t=s.current).onConnected)||n.call(t);break;case"terminal_data":null==(o=(r=s.current).onTerminalData)||o.call(r,E.data);break;case"status":null==(i=(a=s.current).onStatus)||i.call(a,E.status);break;case"chat_message":{const e=E;null==(c=(l=s.current).onChatMessage)||c.call(l,e);break}case"project_stopped":{const e=E;null==(h=(p=s.current).onProjectStopped)||h.call(p,e.projectId,e.projectName);break}case"context_update":null==(v=(g=s.current).onContextUpdate)||v.call(g,E);break;case"semantic_update":null==(b=(y=s.current).onSemanticUpdate)||b.call(y,E);break;case"approval_request":null==(w=(x=s.current).onApprovalRequest)||w.call(x,E);break;case"approval_resolved":null==(S=(k=s.current).onApprovalResolved)||S.call(k,E);break;case"error":console.error("[WS] Server error:",E.message)}},l.onclose=()=>{var e,t;a.current=!1,n.current===l&&(n.current=null),u(!1),null==(t=(e=s.current).onDisconnected)||t.call(e),o.current&&r.current<5&&(r.current++,i.current=window.setTimeout(x,DN))},l.onerror=e=>{a.current=!1,console.error("[WS] WebSocket error:",e)}},[e]);return W.useEffect(()=>(o.current=!0,x(),()=>{var e;o.current=!1,i.current&&(clearTimeout(i.current),i.current=null),null==(e=n.current)||e.close(),n.current=null,p.current=[]}),[x]),{subscribeTerminal:g,sendTerminalInput:v,sendTerminalResize:y,subscribeChatMessages:b,connected:l,readyTick:c}}function AN(e){const t=W.useRef(null),n=W.useRef(0),r=W.useRef(!0),o=W.useRef(!1),a=W.useRef(null),i=W.useRef(e);i.current=e;const s=W.useCallback(()=>{if(!r.current)return;if(o.current)return;const e=Zk();if(!e)return;o.current=!0;const l=new WebSocket(`${LN}/ws/dashboard`);t.current=l,l.onopen=()=>{o.current=!1,n.current=0,l.send(JSON.stringify({type:"auth",token:e}))},l.onmessage=e=>{var t,n;try{const r=JSON.parse(e.data);"activity_update"===r.type?i.current.onActivityUpdate(r):"project_stopped"===r.type&&(null==(n=(t=i.current).onProjectStopped)||n.call(t,r.projectId,r.projectName))}catch{}},l.onclose=()=>{o.current=!1,t.current===l&&(t.current=null),r.current&&n.current<5&&(n.current++,a.current=window.setTimeout(s,DN))},l.onerror=e=>{o.current=!1,console.error("[DashboardWS] Error:",e)}},[]);W.useEffect(()=>(r.current=!0,s(),()=>{var e;r.current=!1,a.current&&(clearTimeout(a.current),a.current=null),null==(e=t.current)||e.close(),t.current=null}),[s])}function ON({projectId:e,enabled:t,onChatMessage:n,onStatusChange:r,onContextUpdate:o,onApprovalRequest:a,onApprovalResolved:i}){const s=W.useRef(null),l=W.useRef(!0),u=W.useRef(0),c=W.useRef(null),d=W.useRef(!1),f=W.useRef(!1),p=W.useRef([]),h=W.useRef({onChatMessage:n,onStatusChange:r,onContextUpdate:o,onApprovalRequest:a,onApprovalResolved:i});h.current={onChatMessage:n,onStatusChange:r,onContextUpdate:o,onApprovalRequest:a,onApprovalResolved:i};const[m,g]=W.useState(!1),[v,y]=W.useState(0),b=W.useCallback(()=>{if(f.current&&s.current&&s.current.readyState===WebSocket.OPEN)for(;p.current.length>0;){const e=p.current.shift();s.current.send(JSON.stringify({type:"terminal_input",data:e}))}},[]),x=W.useCallback(e=>{var t;f.current&&(null==(t=s.current)?void 0:t.readyState)===WebSocket.OPEN?s.current.send(JSON.stringify({type:"terminal_input",data:e})):p.current.push(e)},[]),w=W.useCallback(()=>{if(!l.current||!t)return;if(d.current)return;const n=Zk();if(!n)return;d.current=!0,f.current=!1;const r=new WebSocket(`${LN}/ws/projects/${e}`);s.current=r,r.onopen=()=>{d.current=!1,u.current=0,r.send(JSON.stringify({type:"auth",token:n}))},r.onmessage=e=>{var t,n,o,a,i,s,l,u,c,d;try{const p=JSON.parse(e.data);"connected"===p.type?(r.send(JSON.stringify({type:"chat_subscribe",replay:50})),f.current=!0,g(!0),y(e=>e+1),b()):"chat_message"===p.type?h.current.onChatMessage(p):"status"===p.type&&p.status?null==(n=(t=h.current).onStatusChange)||n.call(t,p.status):"project_stopped"===p.type?null==(a=(o=h.current).onStatusChange)||a.call(o,"stopped"):"context_update"===p.type?null==(s=(i=h.current).onContextUpdate)||s.call(i,p):"approval_request"===p.type?null==(u=(l=h.current).onApprovalRequest)||u.call(l,p):"approval_resolved"===p.type&&(null==(d=(c=h.current).onApprovalResolved)||d.call(c,p))}catch{}},r.onclose=()=>{if(d.current=!1,f.current=!1,g(!1),s.current===r&&(s.current=null),l.current&&t)if(u.current<5){u.current++;const e=2e3*Math.random();c.current=window.setTimeout(w,DN+e)}else p.current.length>0&&(console.warn("[MonitorWS] Retries exhausted, dropping",p.current.length,"queued messages"),p.current=[])},r.onerror=()=>{d.current=!1}},[e,t,b]);return W.useEffect(()=>(l.current=!0,()=>{l.current=!1,p.current=[]}),[]),W.useEffect(()=>(u.current=0,w(),()=>{var e;f.current=!1,c.current&&(clearTimeout(c.current),c.current=null),null==(e=s.current)||e.close(),s.current=null}),[w,t]),{sendInput:x,connected:m,readyTick:v}}const IN="cc_project_order_cache";function zN(){try{const e=localStorage.getItem(IN);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)&&t.every(e=>"string"==typeof e)?t:[]}catch{return[]}}function FN(e){try{localStorage.setItem(IN,JSON.stringify(e))}catch{}}function VN(){const[e,t]=W.useState(zN),n=W.useRef(!1),r=W.useRef(null),o=W.useRef(null),a=W.useRef(!1),i=W.useRef(!0);W.useEffect(()=>{i.current=!0;let e=!1;return oS().then(r=>{e||n.current||(t(e=>function(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}(e,r)?e:r),FN(r))}).catch(()=>{}),()=>{e=!0,i.current=!1,o.current&&(clearTimeout(o.current),o.current=null)}},[]);const s=W.useCallback(async()=>{for(;r.current;){const e=r.current;r.current=null,a.current=!0;try{await aS(e)}catch{}a.current=!1}},[]),l=W.useCallback(e=>{n.current=!0,t(e),FN(e),r.current=e,o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{o.current=null,i.current&&(a.current||s())},400)},[s]),u=W.useCallback(t=>{const n=new Map(e.map((e,t)=>[e,t]));return[...t].sort((e,t)=>{const r=n.get(e.id)??1/0,o=n.get(t.id)??1/0;return r===o?0:r-o})},[e]);return W.useMemo(()=>({order:e,setOrder:l,applyOrder:u}),[e,l,u])}const BN=18e6,$N=6048e5;function UN(e,t=18e6){if(!e||void 0===e.utilization||e.utilization<=0||!e.resetAt)return null;const n=new Date(e.resetAt).getTime()-Date.now();if(n<=0)return null;const r=t-n;return r<=0?null:Math.round(e.utilization/(r/t))}function WN({label:e,bucket:t}){if(!t||void 0===t.utilization)return null;const n=t.utilization,r=n<50?"text-green-400":n<80?"text-yellow-400":"text-red-400",o=function(e){if(!e)return"";const t=new Date(e).getTime()-Date.now();if(t<=0)return"即将重置";const n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`${n}h${r}m`:`${r}m`}(t.resetAt);return ee.jsxs("span",{className:"text-muted-foreground whitespace-nowrap",children:[e," ",ee.jsxs("span",{className:uk("font-medium",r),children:[n,"%"]}),o&&ee.jsxs("span",{className:"text-muted-foreground/70 ml-0.5",children:["(",o,")"]})]})}function HN({className:e}){const[t,n]=W.useState("loading"),[r,o]=W.useState(!1),a=()=>Uk($k.usageMonitorTool,"claude");W.useEffect(()=>{const e=async()=>{try{n(await zS(a()))}catch{n(null)}};e();const t=setInterval(()=>{e()},3e5),r=()=>{e()},o=t=>{t.key===$k.usageMonitorTool&&e()};return window.addEventListener("ccweb:usage-tool-change",r),window.addEventListener("storage",o),()=>{clearInterval(t),window.removeEventListener("ccweb:usage-tool-change",r),window.removeEventListener("storage",o)}},[]);if("loading"===t)return null;if(!t)return null;const i=!!t.fiveHour,s=!!t.sevenDay,l=!!t.sevenDaySonnet,u=!!t.sevenDayOpus,c=i||s||l||u,d=UN(t.fiveHour,BN),f=UN(t.sevenDay,$N),p=UN(t.sevenDaySonnet,$N),h=null!==d||null!==f||null!==p;return ee.jsxs("div",{className:uk("flex items-center gap-1.5 text-xs",e),children:[h&&ee.jsxs("span",{className:"flex items-center gap-1",children:[null!==d&&ee.jsxs("span",{className:uk("font-medium",d<=100?"text-green-400":"text-orange-400"),title:`5h 配速:按当前速率,窗口结束时预计使用 ${d}%`,children:[d,"%"]}),null!==f&&ee.jsxs(ee.Fragment,{children:[ee.jsx("span",{className:"text-muted-foreground/40",children:"/"}),ee.jsxs("span",{className:uk("font-medium",f<=100?"text-green-400":"text-orange-400"),title:`7d 配速:按当前速率,窗口结束时预计使用 ${f}%`,children:[f,"%"]})]}),null!==p&&ee.jsxs(ee.Fragment,{children:[ee.jsx("span",{className:"text-muted-foreground/40",children:"/"}),ee.jsxs("span",{className:uk("font-medium",p<=100?"text-green-400":"text-orange-400"),title:`7d Sonnet 配速:按当前速率,窗口结束时预计使用 ${p}%`,children:[p,"%"]})]})]}),t.planName&&ee.jsx("span",{className:"font-medium text-foreground bg-muted border border-border px-2 py-0.5 rounded-full",children:t.planName}),c&&ee.jsxs(ee.Fragment,{children:[ee.jsx("span",{className:"text-muted-foreground/50",children:"|"}),ee.jsx(WN,{label:"5h",bucket:t.fiveHour}),s&&ee.jsxs(ee.Fragment,{children:[ee.jsx("span",{className:"text-muted-foreground/50",children:"·"}),ee.jsx(WN,{label:"7d",bucket:t.sevenDay})]}),l&&ee.jsxs(ee.Fragment,{children:[ee.jsx("span",{className:"text-muted-foreground/50",children:"·"}),ee.jsx(WN,{label:"7d Sonnet",bucket:t.sevenDaySonnet})]}),u&&ee.jsxs(ee.Fragment,{children:[ee.jsx("span",{className:"text-muted-foreground/50",children:"·"}),ee.jsx(WN,{label:"7d Opus",bucket:t.sevenDayOpus})]})]}),ee.jsx("button",{onClick:()=>{(async()=>{o(!0);try{n(await FS(a()))}catch{n(null)}finally{o(!1)}})()},className:"text-muted-foreground hover:text-foreground transition-colors",title:"刷新用量信息",children:ee.jsx(cj,{className:uk("h-3 w-3",r&&"animate-spin")})})]})}function GN({open:e,onOpenChange:t,kind:n,label:r,content:o}){const a=cf(),[i,s]=W.useState(()=>Uk($k.skillhubAuthor,"")),[l,u]=W.useState(""),[c,d]=W.useState(""),[f,p]=W.useState(!1),[h,m]=W.useState(null),[g,v]=W.useState(!0);W.useEffect(()=>{e&&(s(Uk($k.skillhubAuthor,"")),u(""),d(""),v(!0),_S().then(m).catch(()=>m({configured:!1,needsReset:!1})).finally(()=>v(!1)))},[e]);const y=()=>{t(!1),a("/settings?tab=hub")},b="quick-prompt"===n?"快捷 Prompt":"Agent Prompt",x=!g&&h&&!h.configured;return ee.jsx(HP,{open:e,onOpenChange:t,children:ee.jsxs(qP,{className:uk("sm:max-w-lg"),children:[ee.jsxs(KP,{children:[ee.jsx(QP,{children:"共享到 ccweb-hub"}),ee.jsxs(ZP,{children:["「",r,"」将以 GitHub Issue 形式提交到 ",ee.jsx("code",{children:"zbc0315/ccweb-hub"}),", 使用你配置的 GitHub token。审核通过后会合入为社区 prompt。"]})]}),g?ee.jsxs("div",{className:"py-8 flex items-center justify-center text-sm text-muted-foreground",children:[ee.jsx(tj,{className:"h-4 w-4 mr-2 animate-spin"}),"检查 token 配置…"]}):x?ee.jsxs("div",{className:"space-y-3 py-2",children:[ee.jsx("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2.5 text-xs",children:ee.jsxs("div",{className:"flex items-start gap-2",children:[ee.jsx(JE,{className:"h-4 w-4 shrink-0 text-amber-500 mt-0.5"}),ee.jsxs("div",{className:"space-y-1",children:[ee.jsx("div",{className:"font-medium text-foreground",children:(null==h?void 0:h.needsReset)?"之前配置的 token 已失效(服务端密钥可能已轮换),请重新设置":"还没配置 GitHub token"}),ee.jsxs("div",{className:"text-muted-foreground",children:["为保护你的 GitHub 账号,ccweb 不自带 token,需要你用自己的 GitHub fine-grained PAT(只勾 ",ee.jsx("code",{children:"ccweb-hub"})," 仓库的",ee.jsx("code",{children:" Issues: Read and write"}),")。"]})]})]})}),ee.jsxs("div",{className:"flex gap-2 pt-1",children:[ee.jsx(Rk,{variant:"outline",onClick:()=>t(!1),className:"flex-1",children:"稍后"}),ee.jsx(Rk,{onClick:y,className:"flex-1",children:"去设置页配置"})]})]}):ee.jsxs(ee.Fragment,{children:[ee.jsxs("div",{className:"space-y-3 py-2",children:[ee.jsxs("div",{className:"space-y-1.5",children:[ee.jsx(Ik,{htmlFor:"share-author",className:"text-xs",children:"GitHub 用户名(可选,用于作者标注)"}),ee.jsx(Lk,{id:"share-author",placeholder:"zbc0315",value:i,onChange:e=>s(e.target.value)})]}),ee.jsxs("div",{className:"space-y-1.5",children:[ee.jsx(Ik,{htmlFor:"share-desc",className:"text-xs",children:"一句话描述(可选)"}),ee.jsx(Lk,{id:"share-desc",placeholder:"quick-prompt"===n?"这个命令用来...":"这段 prompt 让 Claude...",value:l,onChange:e=>u(e.target.value)})]}),ee.jsxs("div",{className:"space-y-1.5",children:[ee.jsx(Ik,{htmlFor:"share-tags",className:"text-xs",children:"标签(逗号分隔,可选)"}),ee.jsx(Lk,{id:"share-tags",placeholder:"review, 中文, 代码",value:c,onChange:e=>d(e.target.value)})]})]}),ee.jsxs("div",{className:"rounded-md border bg-muted/30 px-3 py-2 text-xs text-muted-foreground",children:[ee.jsxs("div",{className:"font-medium text-foreground mb-1",children:["预览:",b," · ",r]}),ee.jsxs("pre",{className:"whitespace-pre-wrap font-mono text-[11px] leading-snug max-h-32 overflow-y-auto",children:[Array.from(o).slice(0,500).join(""),Array.from(o).length>500&&"…"]})]}),ee.jsxs(XP,{children:[ee.jsxs(Rk,{variant:"ghost",size:"sm",onClick:y,className:"mr-auto",title:"更换或清除 token",children:[ee.jsx(JE,{className:"h-3.5 w-3.5 mr-1"}),"管理 token"]}),ee.jsx(Rk,{variant:"outline",onClick:()=>t(!1),disabled:f,children:"取消"}),ee.jsx(Rk,{onClick:()=>{(async()=>{if(!f){p(!0),Wk($k.skillhubAuthor,i);try{const e=await IS({kind:n,label:r,body:o,description:l.trim()||void 0,author:i.trim()||void 0,tags:c.split(",").map(e=>e.trim()).filter(Boolean)});dN.success(`已提交:Issue #${e.issueNumber}`,{action:{label:"查看",onClick:()=>window.open(e.issueUrl,"_blank","noopener,noreferrer")}}),t(!1)}catch(RT){const t=RT.message;dN.error(t),/invalid|expired|401/.test(t)&&m({configured:!1,needsReset:!0})}finally{p(!1)}}})()},disabled:f,children:f?ee.jsxs(ee.Fragment,{children:[ee.jsx(tj,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"提交中"]}):ee.jsxs(ee.Fragment,{children:[ee.jsx(dj,{className:"h-3.5 w-3.5 mr-1.5"}),"直接提交"]})})]})]})]})})}function YN(){const[e,t]=W.useState([]),[n,r]=W.useState(!1),[o,a]=W.useState(""),[i,s]=W.useState(""),[l,u]=W.useState(""),[c,d]=W.useState(null),[f,p]=W.useState(""),[h,m]=W.useState(""),[g,v]=W.useState(""),y=W.useRef(null),b=W.useRef(null),[x,w]=W.useState(null);W.useEffect(()=>{hS().then(t).catch(()=>t([]))},[]),W.useEffect(()=>{n&&setTimeout(()=>{var e;return null==(e=y.current)?void 0:e.focus()},0)},[n]),W.useEffect(()=>{c&&setTimeout(()=>{var e;return null==(e=b.current)?void 0:e.focus()},0)},[c]);const k=async()=>{const e=i.trim();if(e)try{const n=await mS({label:o.trim()||e,command:e,...l?{parentId:l}:{}});t(e=>[...e,n]),a(""),s(""),u(""),r(!1)}catch(RT){console.error("[GlobalShortcuts] Failed to add:",RT)}},S=async()=>{const e=h.trim();if(e&&c)try{const n=await gS(c,{label:f.trim()||e,command:e,parentId:g||null});t(e=>e.map(e=>e.id===c?n:e)),d(null)}catch(RT){console.error("[GlobalShortcuts] Failed to save:",RT)}};return ee.jsxs("section",{className:"mt-10",children:[ee.jsxs("div",{className:"flex items-center justify-between mb-4",children:[ee.jsxs("div",{className:"flex items-center gap-2",children:[ee.jsx(kj,{className:"h-4 w-4 text-muted-foreground"}),ee.jsx("h2",{className:"text-lg font-semibold",children:"全局快捷 Prompts"}),ee.jsx("span",{className:"text-xs text-muted-foreground",children:"在所有项目的终端中可用"})]}),ee.jsxs("button",{onClick:()=>{r(e=>!e),d(null)},className:uk("flex items-center gap-1.5 text-sm px-3 py-1.5 rounded-md border transition-colors",n?"border-border text-foreground bg-muted":"border-border text-muted-foreground hover:text-foreground hover:bg-muted"),children:[ee.jsx(uj,{className:"h-3.5 w-3.5"}),"新建"]})]}),n&&ee.jsxs("div",{className:"mb-4 p-4 rounded-lg border border-border bg-background space-y-3",children:[ee.jsx("input",{ref:y,placeholder:"名称(可选)",value:o,onChange:e=>a(e.target.value),className:"w-full text-sm bg-muted border border-border rounded px-3 py-1.5 text-foreground placeholder:text-muted-foreground outline-none focus:border-border transition-colors"}),ee.jsx("textarea",{placeholder:"命令内容…",value:i,onChange:e=>s(e.target.value),rows:3,className:"w-full text-sm bg-muted border border-border rounded px-3 py-1.5 text-foreground placeholder:text-muted-foreground font-mono outline-none focus:border-border transition-colors resize-none",onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),k()),"Escape"===e.key&&(r(!1),a(""),s(""),u(""))}}),ee.jsxs("div",{className:"flex items-center gap-2",children:[ee.jsx(KE,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),ee.jsxs("select",{value:l,onChange:e=>u(e.target.value),className:"flex-1 text-sm bg-muted border border-border rounded px-3 py-1.5 text-foreground outline-none focus:border-border transition-colors",children:[ee.jsx("option",{value:"",children:"无继承"}),e.map(e=>ee.jsx("option",{value:e.id,children:e.label},e.id))]})]}),ee.jsxs("div",{className:"flex items-center justify-between",children:[ee.jsx("span",{className:"text-xs text-muted-foreground",children:"⌘↩ 保存 · Esc 取消"}),ee.jsxs("div",{className:"flex gap-2",children:[ee.jsx("button",{onClick:()=>{r(!1),a(""),s("")},className:"text-sm px-3 py-1 rounded bg-secondary hover:bg-accent text-foreground transition-colors",children:"取消"}),ee.jsx("button",{onClick:()=>{k()},disabled:!i.trim(),className:uk("text-sm px-3 py-1 rounded transition-colors text-white",i.trim()?"bg-blue-600 hover:bg-blue-500":"bg-secondary opacity-40 cursor-not-allowed"),children:"保存"})]})]})]}),0!==e.length||n?ee.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:e.map(n=>c===n.id?ee.jsxs("div",{className:"rounded-lg border border-border bg-background p-3 space-y-2",children:[ee.jsx("input",{ref:b,value:f,onChange:e=>p(e.target.value),placeholder:"名称(可选)",className:"w-full text-sm bg-muted border border-border rounded px-2.5 py-1 text-foreground placeholder:text-muted-foreground outline-none focus:border-border transition-colors"}),ee.jsx("textarea",{value:h,onChange:e=>m(e.target.value),rows:3,className:"w-full text-sm bg-muted border border-border rounded px-2.5 py-1 text-foreground font-mono outline-none focus:border-border transition-colors resize-none",onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),S()),"Escape"===e.key&&d(null)}}),ee.jsxs("div",{className:"flex items-center gap-2",children:[ee.jsx(KE,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),ee.jsxs("select",{value:g,onChange:e=>v(e.target.value),className:"flex-1 text-sm bg-muted border border-border rounded px-2.5 py-1 text-foreground outline-none focus:border-border transition-colors",children:[ee.jsx("option",{value:"",children:"无继承"}),e.filter(e=>e.id!==n.id).map(e=>ee.jsx("option",{value:e.id,children:e.label},e.id))]})]}),ee.jsxs("div",{className:"flex gap-2 justify-end",children:[ee.jsx("button",{onClick:()=>d(null),className:"text-xs px-2.5 py-1 rounded bg-secondary hover:bg-accent text-foreground transition-colors",children:"取消"}),ee.jsx("button",{onClick:()=>{S()},disabled:!h.trim(),className:uk("text-xs px-2.5 py-1 rounded transition-colors text-white",h.trim()?"bg-blue-600 hover:bg-blue-500":"bg-secondary opacity-40 cursor-not-allowed"),children:"保存"})]})]},n.id):ee.jsxs("div",{className:"group relative rounded-lg border border-border bg-background hover:border-muted-foreground/30 transition-colors p-3",children:[ee.jsx("div",{className:"text-sm font-medium text-foreground truncate pr-14",children:n.label}),n.parentId&&(()=>{const t=e.find(e=>e.id===n.parentId);return t?ee.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[ee.jsx(KE,{className:"h-3 w-3 text-muted-foreground"}),ee.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["继承: ",t.label]})]}):null})(),!n.parentId&&n.label!==n.command&&ee.jsx("div",{className:"text-xs text-muted-foreground font-mono truncate mt-1 pr-14",children:n.command}),ee.jsxs("div",{className:"absolute top-2.5 right-2.5 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[ee.jsx("button",{onClick:()=>w({label:n.label,content:n.command}),className:"p-1 rounded text-muted-foreground hover:text-green-400 transition-colors",title:"共享到 ccweb-hub",children:ee.jsx(pj,{className:"h-3.5 w-3.5"})}),ee.jsx("button",{onClick:()=>{d(n.id),p(n.label),m(n.command),v(n.parentId||""),r(!1)},className:"p-1 rounded text-muted-foreground hover:text-blue-400 transition-colors",title:"编辑",children:ee.jsx(lj,{className:"h-3.5 w-3.5"})}),ee.jsx("button",{onClick:()=>{(async e=>{try{await vS(e),t(t=>t.filter(t=>t.id!==e)),c===e&&d(null)}catch(RT){console.error("[GlobalShortcuts] Failed to delete:",RT)}})(n.id)},className:"p-1 rounded text-muted-foreground hover:text-red-400 transition-colors",title:"删除",children:ee.jsx(wj,{className:"h-3.5 w-3.5"})})]})]},n.id))}):ee.jsxs("div",{className:"flex flex-col items-center gap-2 py-10 text-muted-foreground/50 border border-dashed border-border rounded-lg",children:[ee.jsx(kj,{className:"h-6 w-6"}),ee.jsx("p",{className:"text-sm",children:"还没有全局快捷 Prompts"})]}),ee.jsx(GN,{open:!!x,onOpenChange:e=>{e||w(null)},kind:"quick-prompt",label:(null==x?void 0:x.label)??"",content:(null==x?void 0:x.content)??""})]})}const qN=W.createContext({theme:"system",resolved:"dark",setTheme:()=>{}});function KN(){return W.useSyncExternalStore(e=>{const t=window.matchMedia("(prefers-color-scheme: dark)");return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},()=>window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")}function XN({children:e}){const[t,n]=W.useState(()=>Uk($k.theme,"system")),r=KN(),o="system"===t?r:t;W.useEffect(()=>{const e=document.documentElement;e.classList.remove("light","dark"),e.classList.add(o)},[o]);return ee.jsx(qN.Provider,{value:{theme:t,resolved:o,setTheme:e=>{n(e),Wk($k.theme,e)}},children:e})}function QN(){return W.useContext(qN)}function ZN(){const{theme:e,setTheme:t}=QN(),n=[{value:"light",icon:gj,label:"浅色"},{value:"dark",icon:sj,label:"深色"},{value:"system",icon:ij,label:"系统"}];return ee.jsx("div",{className:"flex items-center rounded-md border border-border bg-muted/50 p-0.5",children:n.map(({value:n,icon:r,label:o})=>ee.jsx("button",{onClick:()=>t(n),className:uk("p-1 rounded-sm transition-colors",e===n?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:o,children:ee.jsx(r,{className:"h-3.5 w-3.5"})},n))})}const JN={workMinutes:30,breakMinutes:5};function eT(){return Uk($k.pomodoroConfig,JN,!0)}const tT=Bk(e=>({running:!1,phase:"work",secondsLeft:60*eT().workMinutes,setRunning:t=>e({running:t}),setPhase:t=>e({phase:t}),setSecondsLeft:t=>e({secondsLeft:t})}));function nT(){const{running:e,phase:t,secondsLeft:n,setPhase:r,setSecondsLeft:o}=tT(),a=W.useCallback(e=>{const t=eT();var n;r(e),o("work"===e?60*t.workMinutes:60*t.breakMinutes),n="break"===e?"休息一下 ☕":"该工作了 💻",dN.info(`番茄钟: ${n}`)},[r,o]);return W.useEffect(()=>{if(!e)return;if(0===n)return void a("work"===t?"break":"work");const r=setTimeout(()=>o(n-1),1e3);return()=>clearTimeout(r)},[e,n,t,a,o]),null}function rT(){const{running:e,phase:t,secondsLeft:n}=tT(),r=Math.floor(n/60),o=n%60,a=`${String(r).padStart(2,"0")}:${String(o).padStart(2,"0")}`;return e?ld.createPortal(ee.jsxs("div",{className:"fixed inset-0 flex flex-col items-center justify-center pointer-events-none z-40 select-none",style:{opacity:"work"===t?.1:.6},children:[ee.jsx("div",{className:uk("font-mono font-bold tabular-nums leading-none","work"===t?"text-foreground":"text-blue-400 dark:text-blue-300"),style:{fontSize:"clamp(360px, 90vw, 1100px)"},children:a}),ee.jsx("div",{className:"mt-3 text-muted-foreground font-medium tracking-widest uppercase",style:{fontSize:"clamp(12px, 1.5vw, 20px)"},children:"work"===t?"专注工作":"休息一下"})]}),document.body):null}function oT(){const{running:e,phase:t,secondsLeft:n,setRunning:r,setPhase:o,setSecondsLeft:a}=tT(),i=Math.floor(n/60),s=n%60,l=`${String(i).padStart(2,"0")}:${String(s).padStart(2,"0")}`;return ee.jsx("button",{onClick:()=>{if(e){const e=eT();o("work"),a(60*e.workMinutes)}else{const e=eT();o("work"),a(60*e.workMinutes)}r(!e)},className:uk("p-1 rounded transition-colors",e?"work"===t?"text-red-500 bg-red-500/10 hover:bg-red-500/20":"text-green-500 bg-green-500/10 hover:bg-green-500/20":"text-muted-foreground hover:text-foreground hover:bg-muted"),title:e?"work"===t?`工作中 ${l} — 点击停止`:`休息中 ${l} — 点击停止`:"启动番茄钟",children:ee.jsx(yj,{className:"h-4 w-4"})})}const aT="v2026.4.19-v",iT=!!window.electronUpdater;function sT(){const[e,t]=W.useState("idle"),[n,r]=W.useState(!1),[o,a]=W.useState(""),[i,s]=W.useState(0),[l,u]=W.useState(null),[c,d]=W.useState(null);W.useEffect(()=>{if(!window.electronUpdater)return;return window.electronUpdater.onUpdateStatus(e=>{switch(e.type){case"progress":{const t=e.info;s(Math.round((null==t?void 0:t.percent)??0));break}case"downloaded":t("downloaded");break;case"error":u(e.info||"Download failed"),t("error")}})},[]);const f=W.useCallback(async()=>{t("checking"),u(null),r(!0);try{if(iT){const e=await window.electronUpdater.checkForUpdate();if(e.error)throw new Error(e.error);if(!e.available)return void t("no_update");a(e.version?`v${e.version}`:"new version")}else{const e=await YS();if(!e.updateAvailable)return void t("no_update");a(`v${e.latest}`)}t("update_available")}catch(RT){u(RT instanceof Error?RT.message:"Check failed"),t("error")}},[]),p=W.useCallback(()=>{const e=3e3,n=Date.now(),r=()=>{if(Date.now()-n>3e5)return u("更新超时(5 分钟)— 请检查服务器状态"),void t("update_failed");KS().then(n=>{n?n.success?(a(n.newVersion?`v${n.newVersion}`:"new version"),t("update_complete")):(u(n.error||"Update failed"),t("update_failed")):setTimeout(r,e)}).catch(()=>{setTimeout(r,e)})};setTimeout(r,e)},[]),h=()=>{r(!1),setTimeout(()=>{t("idle"),a(""),u(null),s(0),d(null)},200)};return ee.jsxs(ee.Fragment,{children:[ee.jsx(Rk,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{f()},disabled:"checking"===e||"downloading"===e||"executing"===e||"reconnecting"===e,title:"检查更新",children:"checking"===e||"downloading"===e||"executing"===e||"reconnecting"===e?ee.jsx(tj,{className:"h-4 w-4 animate-spin"}):ee.jsx($E,{className:"h-4 w-4"})}),ee.jsx(HP,{open:n,onOpenChange:e=>{e||h()},children:ee.jsxs(qP,{className:"sm:max-w-md",children:[ee.jsxs(KP,{children:[ee.jsxs(QP,{children:["checking"===e&&"Checking for updates...","no_update"===e&&"Up to date","update_available"===e&&`Update ${o} available`,"downloading"===e&&"Downloading update...","downloaded"===e&&"Update ready to install","executing"===e&&"Updating server...","reconnecting"===e&&"Waiting for server restart...","update_complete"===e&&`Updated to ${o}`,"update_failed"===e&&"Update failed","error"===e&&"Update error"]}),ee.jsxs(ZP,{children:["checking"===e&&"Checking for the latest version...","no_update"===e&&`Current version ${aT} is the latest.`,"update_available"===e&&"A new version is available. "+(iT?"Click download to update automatically.":""),"downloading"===e&&`Downloading... ${i}%`,"downloaded"===e&&"The update has been downloaded. Click install to restart and apply.","executing"===e&&"Server is shutting down and installing the update. Please wait...","reconnecting"===e&&"Update installed. Waiting for server to restart...","update_complete"===e&&`Successfully updated from ${aT} to ${o}. Click reload to use the new version.`,"update_failed"===e&&(l||"Update failed. You may need to restart the server manually."),"error"===e&&(l||"An error occurred.")]})]}),"downloading"===e&&ee.jsx("div",{className:"w-full bg-muted rounded-full h-2 overflow-hidden",children:ee.jsx("div",{className:"bg-primary h-full transition-all duration-300",style:{width:`${i}%`}})}),("executing"===e||"reconnecting"===e)&&ee.jsx("div",{className:"flex items-center justify-center py-6",children:ee.jsx(tj,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),ee.jsxs(XP,{children:["no_update"===e&&ee.jsx(Rk,{onClick:h,children:"OK"}),"update_available"===e&&ee.jsxs(ee.Fragment,{children:[ee.jsx(Rk,{variant:"outline",onClick:h,children:"Later"}),ee.jsx(Rk,{onClick:()=>{(async()=>{if(iT){t("downloading"),s(0);const e=await window.electronUpdater.downloadUpdate();e.success?e.path&&d(e.path):(u(e.error||"Download failed"),t("error"))}else{t("executing");try{await qS(),t("reconnecting"),p()}catch(RT){u(RT instanceof Error?RT.message:"Execute failed"),t("error")}}})()},children:iT?"Download & Install":`Update to ${o}`})]}),"downloaded"===e&&ee.jsxs(ee.Fragment,{children:[ee.jsx(Rk,{variant:"outline",onClick:h,children:"Later"}),ee.jsx(Rk,{onClick:()=>{var e;null==(e=window.electronUpdater)||e.quitAndInstall(c||void 0)},children:"Restart & Install"})]}),"update_complete"===e&&ee.jsx(Rk,{onClick:()=>window.location.reload(),children:"Reload Page"}),"update_failed"===e&&ee.jsx(Rk,{onClick:h,children:"Close"}),"error"===e&&ee.jsx(Rk,{onClick:h,children:"Close"})]})]})})]})}function lT(e){return e.map(e=>"text"===e.type?e.content:`\n\`\`\`${e.type}\n${e.content}\n\`\`\`\n`).join("")}function uT(e,t){return{id:e.id??t(),role:e.role,content:lT(e.blocks),blocks:e.blocks,ts:e.timestamp}}function cT({project:e,liveMessages:t,ws:n,historyLimit:r=20,liveWindow:o=50,historyEnabled:a=!0}){const i=e.id,[s,l]=W.useState("running"===e.status?"live":"stopped"),{history:u,hasMore:c,reload:d,loadMore:f}=function({projectId:e,historyLimit:t=20,enabled:n=!0}){const[r,o]=W.useState([]),[a,i]=W.useState(!1),[s,l]=W.useState(!1),u=W.useRef(0),c=W.useCallback(()=>"h"+ ++u.current,[]),d=W.useRef({projectId:e,enabled:n});d.current={projectId:e,enabled:n};const f=W.useCallback(async()=>{if(!d.current.enabled)return;const e=d.current.projectId;l(!0);try{const n=await mE(e,{limit:t});if(d.current.projectId!==e)return;const r=[];for(const e of n.blocks){const t=uT(e,c);t.content.trim()&&r.push(t)}o(r),i(n.hasMore)}catch{}finally{l(!1)}},[t,c]),p=W.useCallback(async()=>{if(!a||s||0===r.length)return;if(!d.current.enabled)return;const e=d.current.projectId,n=r[0];if(n.id&&!n.id.startsWith("h")){l(!0);try{const r=await mE(e,{limit:t,before:n.id});if(d.current.projectId!==e)return;const a=[];for(const e of r.blocks){const t=uT(e,c);t.content.trim()&&a.push(t)}o(e=>[...a,...e]),i(r.hasMore)}catch{}finally{l(!1)}}},[t,a,s,r,c]);return W.useEffect(()=>{n&&f()},[e,n]),{history:r,hasMore:a,isLoading:s,reload:f,loadMore:p}}({projectId:i,historyLimit:r,enabled:a}),[p,h]=W.useState([]),m=W.useRef(0),g=W.useCallback(()=>"m"+ ++m.current,[]),v=W.useRef(null),y=W.useCallback(()=>{v.current&&(clearTimeout(v.current.timer),v.current=null)},[]),b=W.useRef([]),x=W.useRef(!1),w=W.useRef(0);W.useEffect(()=>{if(t.length<w.current&&(w.current=0,b.current=[]),t.length<=w.current)return;const e=t.slice(w.current);w.current=t.length;for(const t of e){x.current=!0;const e=lT(t.blocks);if(e.trim()){if("user"===t.role){const t=b.current.indexOf(e.trim());if(-1!==t){b.current.splice(t,1),y();continue}}h(n=>{if(t.id&&n.some(e=>e.id===t.id))return n;const r={id:t.id??g(),role:t.role,content:e,blocks:t.blocks,ts:t.timestamp};return[...n,r].slice(-o)})}}},[t,g,o,y]),W.useEffect(()=>{if("live"!==s)return void(x.current=!1);const e=setTimeout(()=>{x.current||d()},3e3);return()=>clearTimeout(e)},[s,d]),W.useEffect(()=>{"running"!==e.status||"stopped"!==s&&"error"!==s?"stopped"===e.status&&"live"===s&&l("stopped"):(h([]),l("live"))},[e.status]);const k=W.useRef([]),S=W.useRef(null),E=W.useRef(0),j=W.useCallback(()=>{if(v.current)return;const e=t=>{const r=setTimeout(()=>{if(0!==b.current.length){if(t>=20)return b.current=[],void(v.current=null);n.send("\r"),e(t+1)}else v.current=null},3e3);v.current={timer:r,attempts:t}};e(0)},[n]);W.useEffect(()=>{if(!n.connected)return;if("live"!==s)return;if(0===k.current.length)return;const e=[...k.current];k.current=[];for(const t of e)n.send(t.replace(/\n/g,"\r")+"\r");j()},[n.connected,s,n,j]),W.useEffect(()=>()=>{S.current&&clearTimeout(S.current),y()},[y]);const C=W.useCallback(e=>{k.current.length>=20&&k.current.shift(),k.current.push(e)},[]),P=W.useCallback(e=>{if(b.current.push(e),b.current.length>10&&b.current.shift(),h(t=>[...t,{id:g(),role:"user",content:e,ts:(new Date).toISOString()}].slice(-o)),"live"===s)!n.connected||k.current.length>0?C(e):(n.send(e.replace(/\n/g,"\r")+"\r"),j());else if("waking"===s)C(e);else if("stopped"===s||"error"===s){C(e);const t=++E.current;l("waking"),dS(i).then(()=>{t===E.current&&(S.current&&clearTimeout(S.current),l("live"))}).catch(e=>{t===E.current&&(dN.error(`启动失败: ${e instanceof Error?e.message:String(e)}`),l("error"),k.current=[])}),S.current=setTimeout(()=>{t===E.current&&k.current.length>0&&(dN.error("启动超时(10s)"),l("error"),k.current=[])},1e4)}},[s,n,i,g,o,j,C]),N=W.useCallback(e=>{const t=e.replace(/\r$/,"").trim();t&&(b.current.push(t),b.current.length>10&&b.current.shift(),h(e=>[...e,{id:g(),role:"user",content:t,ts:(new Date).toISOString()}].slice(-o)))},[g,o]),T=W.useMemo(()=>{const e=new Set;for(const t of p)t.id&&e.add(t.id);return[...u.filter(t=>!t.id||!e.has(t.id)),...p]},[u,p]);return{state:s,setState:l,messages:T,historyMessages:u,displayMessages:p,setDisplayMessages:h,hasMoreHistory:c,loadMoreHistory:f,reloadHistory:d,liveReceivedRef:x,sendMessage:P,appendUserMessage:N,clearSendRetry:y,isWaking:"waking"===s,isRunning:"live"===s}}function dT(e,t,n){const r=W.useRef(!0),o=W.useRef(0),a=W.useCallback(()=>{const t=e.current;t&&(o.current=performance.now(),t.scrollTop=t.scrollHeight)},[e]);return W.useEffect(()=>{const t=e.current;if(!t)return;const n=()=>{if(performance.now()-o.current<80)return;const e=t.scrollHeight-t.scrollTop-t.clientHeight<80;r.current=e};return t.addEventListener("scroll",n,{passive:!0}),()=>t.removeEventListener("scroll",n)},[e]),W.useLayoutEffect(()=>{r.current&&a()},[a,...n]),W.useEffect(()=>{const e=t.current;if(!e)return;const n=new ResizeObserver(()=>{r.current&&a()});return n.observe(e),()=>n.disconnect()},[t,a]),{pinnedRef:r,scrollToBottom:a}}function fT(e,t="shift"){return W.useCallback(n=>{if("Enter"!==n.key)return;if(n.nativeEvent.isComposing||229===n.keyCode)return;("shift"===t?!n.shiftKey:n.shiftKey)&&(n.preventDefault(),e())},[e,t])}const pT=H.memo(function({project:e,externalStatus:t,active:n=!1}){const r=cf(),[o,a]=W.useState(""),[i,s]=W.useState(!1),l=W.useRef(null),u=W.useRef(null),[c,d]=W.useState([]),f=W.useRef(0),p=W.useCallback(e=>{d(t=>{const n=[...t,e];return n.length>200?n.slice(-200):n}),"assistant"===e.role&&(s(!0),setTimeout(()=>s(!1),1e3))},[]),h=W.useCallback(e=>{var t;"stopped"===e&&(null==(t=S.current)||t.call(S,"stopped"))},[]),{sendInput:m,connected:g}=ON({projectId:e.id,enabled:!0,onChatMessage:p,onStatusChange:h}),{state:v,setState:y,messages:b,sendMessage:x,isRunning:w,isWaking:k}=cT({project:e,liveMessages:c,ws:{send:m,connected:g},historyLimit:4,liveWindow:4}),S=W.useRef(y);S.current=y,W.useEffect(()=>{"stopped"===v&&(d([]),f.current=0)},[v]),W.useEffect(()=>{t&&("running"!==t||"stopped"!==v&&"error"!==v?"stopped"===t&&"live"===v&&y("stopped"):(d([]),y("live")))},[t]),dT(l,u,[b]);const E=fT(W.useCallback(()=>{const e=o.trim();e&&(a(""),x(e))},[o,x]),"enter"),j="stopped"===v,C=b.slice(-4),P=ee.jsxs("div",{className:uk("flex flex-col h-full rounded-lg overflow-hidden bg-background transition-colors duration-300",n?"border-transparent bg-transparent shadow-none":i?"border border-blue-500":"border border-border","error"===v&&"border border-red-500/50"),children:[ee.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-1.5 border-b border-border bg-muted/30 transition-colors",children:[ee.jsx(QE,{className:"h-3.5 w-3.5 text-muted-foreground/40 flex-shrink-0 cursor-grab active:cursor-grabbing"}),ee.jsx("span",{className:"font-medium text-sm truncate flex-1 cursor-pointer hover:text-blue-400 transition-colors",onClick:()=>r(`/projects/${e.id}`),title:"打开项目详情",children:e.name}),ee.jsx("span",{className:"text-[10px] text-muted-foreground font-mono",children:e.cliTool??"claude"}),ee.jsx("span",{className:uk("w-2 h-2 rounded-full flex-shrink-0",w?"bg-green-500":k?"bg-yellow-400 animate-pulse":"bg-zinc-400")})]}),ee.jsx("div",{ref:l,className:"flex-1 overflow-y-auto min-h-0 text-xs",children:ee.jsxs("div",{ref:u,className:"p-2 space-y-2 min-h-full",children:[C.map(e=>{const t="user"===e.role;return ee.jsx("div",{className:uk("flex",t?"justify-end":"justify-start"),children:ee.jsx("div",{className:uk("max-w-[85%] rounded-lg px-2.5 py-1.5 whitespace-pre-wrap break-words leading-relaxed",t?"bg-blue-500/15 text-foreground border border-blue-500/20 rounded-br-sm dark:bg-blue-500/20 dark:border-blue-500/25":"bg-secondary text-secondary-foreground border border-border rounded-bl-sm"),children:ee.jsx("div",{className:"line-clamp-6",children:e.content})})},e.id)}),j&&0===C.length&&ee.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground/40 text-xs",children:"无对话记录"}),k&&ee.jsx("div",{className:"flex items-center justify-center h-full text-yellow-400 text-xs animate-pulse",children:"启动中..."})]})}),ee.jsx("div",{className:"border-t border-border p-1.5",children:ee.jsx("input",{type:"text",value:o,onChange:e=>a(e.target.value),onKeyDown:E,disabled:k,placeholder:k?"启动中...":j?"输入命令(自动启动)... Shift+⏎":"输入命令... Shift+⏎",className:uk("w-full bg-transparent text-xs font-mono outline-none placeholder:text-muted-foreground/40 px-1.5 py-1",k&&"opacity-50 cursor-not-allowed")})})]});return n?ee.jsx("div",{className:"card-active-glow rounded-lg h-full",children:P}):P});function hT({projects:e,projectStatuses:t,activeProjectIds:n}){const r=W.useMemo(()=>e.filter(e=>!e.archived),[e]),{order:o,setOrder:a,applyOrder:i}=VN(),[s,l]=W.useState(null),[u,c]=W.useState(null),d=W.useRef(null),f=W.useMemo(()=>i(r),[r,i]),p=W.useCallback((e,t)=>{l(t),e.dataTransfer.effectAllowed="move";const n=document.createElement("div");n.style.width="1px",n.style.height="1px",n.style.opacity="0.01",document.body.appendChild(n),e.dataTransfer.setDragImage(n,0,0),d.current=n},[]),h=W.useCallback((e,t)=>{e.preventDefault(),e.dataTransfer.dropEffect="move",c(t)},[]),m=W.useCallback((e,t)=>{if(e.preventDefault(),!s||s===t)return l(null),void c(null);const n=f.map(e=>e.id),r=o.length?[...o]:n;for(const o of n)r.includes(o)||r.push(o);const i=r.indexOf(s),u=r.indexOf(t);if(-1===i||-1===u)return l(null),void c(null);r.splice(i,1),r.splice(u,0,s),a(r),l(null),c(null)},[s,f,o,a]),g=W.useCallback(()=>{l(null),c(null),d.current&&(d.current.remove(),d.current=null)},[]),{cols:v,rows:y}=(b=f.length)<=1?{cols:1,rows:1}:b<=2?{cols:2,rows:1}:b<=4?{cols:2,rows:2}:b<=6?{cols:3,rows:2}:b<=9?{cols:3,rows:3}:b<=12?{cols:4,rows:3}:{cols:4,rows:Math.ceil(b/4)};var b;if(0===f.length)return ee.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground/50 text-sm",children:"没有活跃项目"});const x=y<=3;return ee.jsx("div",{className:"h-full w-full p-2 gap-2 overflow-y-auto",style:{display:"grid",gridTemplateColumns:`repeat(${v}, minmax(0, 1fr))`,gridAutoRows:x?`minmax(180px, min(${Math.floor(100/y)}vh, 350px))`:"280px"},children:f.map(e=>ee.jsx("div",{draggable:!0,onDragStart:t=>p(t,e.id),onDragOver:t=>h(t,e.id),onDrop:t=>m(t,e.id),onDragEnd:g,className:uk("transition-all duration-200",s===e.id&&"opacity-40 scale-95",u===e.id&&s!==e.id&&"ring-2 ring-blue-500/50 rounded-lg"),children:ee.jsx(pT,{project:e,externalStatus:t.get(e.id),active:n.has(e.id)})},e.id))})}function mT(){const e=cf(),{projects:t,loading:n,error:r,hasFetched:o,fetchProjects:a,addProject:i,updateProject:s,removeProject:l}=Kk(),u=Yk(e=>e.clearToken),[c,d]=W.useState(!1),[f,p]=W.useState(!1),[h,m]=W.useState(new Set),g=W.useRef(new Map),[v,y]=W.useState(new Map),b=W.useRef(0),[x,w]=W.useState(!!document.fullscreenElement),[k,S]=W.useState(!1),[E,j]=Gk($k.monitorMode,!1,{parse:!0}),[C,P]=W.useState(new Map);W.useEffect(()=>{const e=()=>w(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]),W.useEffect(()=>{a()},[a]);AN({onActivityUpdate:W.useCallback(e=>{if(e.status){const t=Kk.getState().projects.find(t=>t.id===e.projectId);t&&t.status!==e.status&&s({...t,status:e.status}),P(t=>{const n=new Map(t);return n.set(e.projectId,e.status),n})}const t=Date.now(),n=g.current;if(e.active){m(t=>t.has(e.projectId)?t:new Set(t).add(e.projectId));const r=n.get(e.projectId)??[];let o=!1;if(e.semantic){const n=r[r.length-1];`${e.semantic.phase}:${e.semantic.detail??""}`!==(n?`${n.phase}:${n.detail??""}`:"")?(r.push({id:b.current++,phase:e.semantic.phase,detail:e.semantic.detail,ts:t}),o=!0):n&&(n.ts=t)}const a=r.filter(e=>t-e.ts<8e3),i=a.length>3?a.slice(-3):a;i.length!==r.length&&(o=!0),n.set(e.projectId,i),o&&y(new Map(n))}else m(t=>{if(!t.has(e.projectId))return t;const n=new Set(t);return n.delete(e.projectId),n}),n.has(e.projectId)&&n.get(e.projectId).length>0&&(n.set(e.projectId,[]),y(new Map(n)))},[s])}),W.useEffect(()=>{const e=setInterval(()=>{const e=Date.now(),t=g.current;let n=!1;for(const[r,o]of t){const a=o.filter(t=>e-t.ts<8e3);a.length!==o.length&&(t.set(r,a),n=!0)}n&&y(new Map(t)),m(e=>{let n=!1;const r=new Set(e);for(const o of e){const e=t.get(o);e&&0!==e.length||(r.delete(o),n=!0)}return n?r:e})},3e3);return()=>clearInterval(e)},[]);const N=W.useMemo(()=>t.filter(e=>!e.archived),[t]),T=W.useMemo(()=>t.filter(e=>e.archived),[t]),M=W.useMemo(()=>Array.from(new Set(t.flatMap(e=>e.tags??[]))),[t]),[R,L]=W.useState([]),D=W.useMemo(()=>0===R.length?N:N.filter(e=>R.some(t=>{var n;return null==(n=e.tags)?void 0:n.includes(t)})),[N,R]),[_,A]=W.useState(!1),O=W.useCallback(async()=>{if(!_){A(!0);try{const e=await LE(),t=e.results.filter(e=>e.ok).length,n=e.results.filter(e=>e.skipped).length,r=e.total-t-n;dN.success(`同步完成:${t} 成功 / ${n} 跳过 / ${r} 失败`)}catch(RT){dN.error(`同步失败:${RT.message}`)}finally{A(!1)}}},[_]),{order:I,setOrder:z,applyOrder:F}=VN(),[V,B]=W.useState(null),[$,U]=W.useState(null),H=W.useMemo(()=>F(D),[D,F]),G=W.useCallback(e=>B(e),[]),Y=W.useCallback(()=>{B(null),U(null)},[]),q=W.useCallback((e,t)=>{e.preventDefault(),U(t)},[]),K=W.useCallback((e,t,n)=>{if(e.preventDefault(),!n||n===t)return void U(null);const r=H.map(e=>e.id),o=I.length?[...I]:r;for(const s of r)o.includes(s)||o.push(s);const a=o.indexOf(n),i=o.indexOf(t);if(-1===a||-1===i)return B(null),void U(null);o.splice(a,1),o.splice(i,0,n),z(o),B(null),U(null)},[H,I,z]),X={onDelete:e=>{(async e=>{try{await cS(e),l(e)}catch(RT){dN.error(RT instanceof Error?RT.message:"Failed to delete project")}})(e)},onArchive:e=>{(async e=>{try{const t=await fS(e);s(t)}catch(RT){dN.error(RT instanceof Error?RT.message:"Failed to archive project")}})(e)},onUnarchive:e=>{(async e=>{try{const t=await pS(e);s(t)}catch(RT){dN.error(RT instanceof Error?RT.message:"Failed to restore project")}})(e)},onUpdated:s};return ee.jsxs("div",{className:"min-h-screen bg-background",children:[ee.jsx("header",{className:"border-b sticky top-0 bg-background z-10",children:ee.jsxs("div",{className:"max-w-6xl mx-auto px-4 h-14 flex items-center justify-between",children:[ee.jsxs("div",{className:"flex items-center gap-2",children:[ee.jsx(vj,{className:"h-5 w-5"}),ee.jsxs("div",{children:[ee.jsx("span",{className:"font-semibold text-lg leading-tight block",children:"CC Web"}),ee.jsx("span",{className:"text-[10px] text-muted-foreground leading-none",children:aT})]})]}),ee.jsx(HN,{}),ee.jsx(Rk,{variant:"ghost",size:"sm",onClick:()=>e("/skillhub"),title:"CCWeb Hub",children:ee.jsx(mj,{className:"h-4 w-4"})}),ee.jsx(Rk,{variant:"ghost",size:"sm",onClick:()=>e("/mobile"),title:"手机界面",children:ee.jsx(hj,{className:"h-4 w-4"})}),ee.jsx(Rk,{variant:"ghost",size:"sm",onClick:()=>e("/settings"),title:"设置",children:ee.jsx(fj,{className:"h-4 w-4"})}),ee.jsx(Rk,{variant:"ghost",size:"sm",onClick:()=>j(!E),title:E?"卡片模式":"监控大屏",className:uk(E&&"text-blue-400 bg-blue-500/10"),children:E?ee.jsx(ej,{className:"h-4 w-4"}):ee.jsx(ij,{className:"h-4 w-4"})}),ee.jsx(Rk,{variant:"ghost",size:"sm",onClick:()=>{document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen()},title:x?"Exit fullscreen":"Fullscreen",children:x?ee.jsx(oj,{className:"h-4 w-4"}):ee.jsx(rj,{className:"h-4 w-4"})}),ee.jsx(sT,{}),ee.jsx(oT,{}),ee.jsx(ZN,{}),ee.jsxs(Rk,{variant:"ghost",size:"sm",onClick:()=>{u(),e("/login")},children:[ee.jsx(nj,{className:"h-4 w-4 mr-2"}),"Logout"]})]})}),E&&ee.jsx("div",{className:"flex-1 min-h-0",children:ee.jsx(hT,{projects:t,projectStatuses:C,activeProjectIds:h})}),!E&&ee.jsxs("main",{className:"max-w-6xl mx-auto px-4 py-8",children:[ee.jsxs("div",{className:"flex items-center justify-between mb-6",children:[ee.jsxs("div",{children:[ee.jsx("h1",{className:"text-2xl font-bold",children:"Projects"}),ee.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Each project runs Claude CLI in a dedicated terminal session."})]}),ee.jsxs("div",{className:"flex gap-2",children:[ee.jsxs(Rk,{variant:"outline",onClick:()=>{O()},disabled:_,title:"通过 rsync 同步所有项目(在设置里配置服务器)",children:[_?ee.jsx(tj,{className:"h-4 w-4 mr-2 animate-spin"}):ee.jsx(YE,{className:"h-4 w-4 mr-2"}),"全部同步"]}),ee.jsxs(Rk,{variant:"outline",onClick:()=>p(!0),children:[ee.jsx(HE,{className:"h-4 w-4 mr-2"}),"Open Project"]}),ee.jsxs(Rk,{onClick:()=>d(!0),children:[ee.jsx(uj,{className:"h-4 w-4 mr-2"}),"New Project"]})]})]}),n&&!o&&ee.jsx("div",{className:"text-center text-muted-foreground py-12",children:"Loading projects..."}),r&&ee.jsx("div",{className:"text-center text-destructive py-12",children:r}),o&&!n&&!r&&0===t.length&&ee.jsxs("div",{className:"text-center py-20",children:[ee.jsx(vj,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),ee.jsx("h2",{className:"text-lg font-semibold mb-2",children:"No projects yet"}),ee.jsx("p",{className:"text-muted-foreground text-sm mb-6",children:"Create a new project or open an existing one."}),ee.jsxs("div",{className:"flex gap-2 justify-center",children:[ee.jsxs(Rk,{variant:"outline",onClick:()=>p(!0),children:[ee.jsx(HE,{className:"h-4 w-4 mr-2"}),"Open Project"]}),ee.jsxs(Rk,{onClick:()=>d(!0),children:[ee.jsx(uj,{className:"h-4 w-4 mr-2"}),"New Project"]})]})]}),!n&&!r&&M.length>0&&ee.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-4",children:[M.map(e=>ee.jsxs("button",{onClick:()=>L(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),className:uk("px-2 py-0.5 rounded-full text-xs border transition-colors",R.includes(e)?"bg-blue-500/20 text-blue-400 border-blue-500/40":"bg-muted text-muted-foreground border-border hover:border-muted-foreground/40"),children:["#",e]},e)),R.length>0&&ee.jsx("button",{onClick:()=>L([]),className:"px-2 py-0.5 rounded-full text-xs text-muted-foreground hover:text-foreground transition-colors",children:"清除"})]}),!n&&!r&&H.length>0&&ee.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:H.map((e,t)=>ee.jsx(hw.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.3,delay:Math.min(.05*t,.3),ease:"easeOut"},draggable:!0,onDragStart:()=>G(e.id),onDragOver:t=>q(t,e.id),onDrop:t=>K(t,e.id,V),onDragEnd:Y,style:{opacity:V===e.id?.4:1,cursor:"grab"},className:uk($===e.id&&V!==e.id&&"ring-2 ring-blue-500/50 rounded-xl"),children:ee.jsx(CN,{project:e,active:h.has(e.id),statusStack:v.get(e.id)??[],...X})},e.id))}),!n&&!r&&T.length>0&&ee.jsxs("div",{className:"mt-10",children:[ee.jsxs("button",{className:"flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors mb-4 group",onClick:()=>S(e=>!e),children:[ee.jsx(hw.span,{animate:{rotate:k?90:0},transition:{duration:.2},children:ee.jsx(BE,{className:"h-4 w-4"})}),ee.jsx("span",{className:"font-medium",children:"Archived"}),ee.jsx("span",{className:"text-xs bg-muted rounded-full px-2 py-0.5",children:T.length})]}),ee.jsx(Xb,{children:k&&ee.jsx(hw.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.25,ease:"easeInOut"},className:"overflow-hidden",children:ee.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:T.map(e=>ee.jsx(CN,{project:e,active:!1,...X},e.id))})})})]}),ee.jsx(YN,{})]}),ee.jsx(MN,{open:c,onOpenChange:d,onCreated:e=>{i(e)}}),ee.jsx(RN,{open:f,onOpenChange:p,onOpened:e=>{i(e)}})]})}class gT extends H.Component{constructor(){super(...arguments),t(this,"state",{hasError:!1,error:null}),t(this,"handleReset",()=>{var e,t;this.setState({hasError:!1,error:null}),null==(t=(e=this.props).onReset)||t.call(e)})}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error("[ErrorBoundary]",e,t.componentStack),dN.error(e.message||"Something went wrong")}render(){return this.state.hasError?this.props.fallback?this.props.fallback:ee.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 p-4 text-sm text-muted-foreground",children:[ee.jsx("p",{children:"出错了"}),ee.jsx("button",{onClick:this.handleReset,className:"px-3 py-1.5 text-xs rounded-md border border-border hover:bg-muted transition-colors",children:"重新加载"})]}):this.props.children}}function vT({plugin:e,onConfigChange:t,onClose:n}){const{float:r,userConfig:o}=e,[a,i]=W.useState(()=>{var e,t;return{x:(null==(e=o.floatPosition)?void 0:e.x)??.5*window.innerWidth-r.defaultWidth/2,y:(null==(t=o.floatPosition)?void 0:t.y)??.3*window.innerHeight}}),[s,l]=W.useState(()=>{var e,t;return{w:(null==(e=o.floatSize)?void 0:e.w)??r.defaultWidth,h:(null==(t=o.floatSize)?void 0:t.h)??r.defaultHeight}}),[u,c]=W.useState(!1),[d,f]=W.useState(100),p=W.useRef(null),h=W.useRef(null),m=W.useCallback(()=>{f(Date.now()%1e5+100)},[]),g=W.useRef(null),v=W.useCallback(n=>{n.preventDefault(),m(),g.current={sx:n.clientX,sy:n.clientY,ox:a.x,oy:a.y},h.current&&(h.current.style.pointerEvents="none");const r=e=>{if(!g.current)return;const t=Math.max(0,Math.min(window.innerWidth-100,g.current.ox+e.clientX-g.current.sx)),n=Math.max(0,Math.min(window.innerHeight-40,g.current.oy+e.clientY-g.current.sy));p.current&&(p.current.style.left=t+"px",p.current.style.top=n+"px")},o=n=>{if(!g.current)return;const a=Math.max(0,Math.min(window.innerWidth-100,g.current.ox+n.clientX-g.current.sx)),s=Math.max(0,Math.min(window.innerHeight-40,g.current.oy+n.clientY-g.current.sy));g.current=null,h.current&&(h.current.style.pointerEvents=""),i({x:a,y:s}),t(e.id,{floatPosition:{x:a,y:s}}),window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",o)};window.addEventListener("mousemove",r),window.addEventListener("mouseup",o)},[a,m,e.id,t]),y=W.useRef(null),b=W.useCallback(n=>{if(!r.resizable)return;n.preventDefault(),n.stopPropagation(),m(),y.current={sx:n.clientX,sy:n.clientY,ow:s.w,oh:s.h},h.current&&(h.current.style.pointerEvents="none");const o=r.minWidth??150,a=r.minHeight??100,i=e=>{if(!y.current)return;const t=Math.max(o,y.current.ow+e.clientX-y.current.sx),n=Math.max(a,y.current.oh+e.clientY-y.current.sy);p.current&&(p.current.style.width=t+"px",p.current.style.height=n+"px")},u=n=>{if(!y.current)return;const r=Math.max(o,y.current.ow+n.clientX-y.current.sx),s=Math.max(a,y.current.oh+n.clientY-y.current.sy);y.current=null,h.current&&(h.current.style.pointerEvents=""),l({w:r,h:s}),t(e.id,{floatSize:{w:r,h:s}}),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",u)};window.addEventListener("mousemove",i),window.addEventListener("mouseup",u)},[s,r,m,e.id,t]);W.useEffect(()=>{const t=async t=>{var n,r,o,a,i;if(t.source!==(null==(n=h.current)?void 0:n.contentWindow))return;const{callId:s,method:l,args:u}=t.data;if(s&&l)try{const t=Zk(),n={"Content-Type":"application/json","X-Plugin-Id":e.id};let a,i;if(t&&(n.Authorization=`Bearer ${t}`),"storage:get"===l)a=`/api/plugin-bridge/storage/${e.id}`,i={method:"GET",headers:n};else if("storage:set"===l)a=`/api/plugin-bridge/storage/${e.id}`,i={method:"PUT",headers:n,body:JSON.stringify(u)};else{const t={"project:status":{path:`/api/plugin-bridge/project/status/${u.projectId}`,httpMethod:"GET"},"project:list":{path:"/api/plugin-bridge/project/list",httpMethod:"GET"},"terminal:send":{path:"/api/plugin-bridge/terminal/send",httpMethod:"POST"},"session:read":{path:`/api/plugin-bridge/session/${u.projectId}`,httpMethod:"GET"},"system:info":{path:"/api/plugin-bridge/system/info",httpMethod:"GET"}};if("backend:api"===l){const{method:t,path:r,body:o}=u;if(!r||!r.startsWith("/")||r.includes(".."))throw new Error("Invalid API path");a=`/api/plugins/${e.id}${r}`,i={method:t||"GET",headers:n},!o||"POST"!==t&&"PUT"!==t||(i.body=JSON.stringify(o))}else{const e=t[l];if(!e)throw new Error(`Unknown method: ${l}`);a=e.path,i={method:e.httpMethod,headers:n},"POST"===e.httpMethod&&(i.body=JSON.stringify(u))}}const c=await fetch(a,i),d=await c.json();null==(o=null==(r=h.current)?void 0:r.contentWindow)||o.postMessage({callId:s,result:d,error:null},window.location.origin)}catch(RT){const t=RT instanceof Error?RT.message:"Bridge error";null==(i=null==(a=h.current)?void 0:a.contentWindow)||i.postMessage({callId:s,result:null,error:t},window.location.origin)}};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[e.id]);const x=o.clickable??r.clickable.default,w=`/plugins/${e.id}/${e.float?"index.html":""}`;return ee.jsxs(hw.div,{ref:p,className:uk("fixed rounded-lg border border-border shadow-xl overflow-hidden flex flex-col","bg-background/95 backdrop-blur-sm"),style:{left:a.x,top:a.y,width:u?200:s.w,height:u?32:s.h,zIndex:d},initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.15},onMouseDown:m,children:[ee.jsxs("div",{className:"h-8 flex items-center gap-1 px-2 bg-muted/50 border-b border-border cursor-grab active:cursor-grabbing flex-shrink-0 select-none",onMouseDown:v,children:[ee.jsx(XE,{className:"h-3 w-3 text-muted-foreground/40 flex-shrink-0"}),ee.jsx("span",{className:"text-xs text-muted-foreground truncate flex-1",children:e.name}),ee.jsx("button",{onClick:()=>c(e=>!e),className:"p-0.5 rounded hover:bg-white/10 text-muted-foreground/60 hover:text-foreground transition-colors",children:ee.jsx(aj,{className:"h-3 w-3"})}),ee.jsx("button",{onClick:()=>n(e.id),className:"p-0.5 rounded hover:bg-red-500/20 text-muted-foreground/60 hover:text-red-400 transition-colors",children:ee.jsx(wj,{className:"h-3 w-3"})})]}),!u&&ee.jsxs("div",{className:"flex-1 min-h-0 relative",children:[ee.jsx("iframe",{ref:h,src:w,sandbox:"allow-scripts allow-same-origin",className:"w-full h-full border-0",style:{pointerEvents:x?"auto":"none"}}),r.resizable&&ee.jsx("div",{className:"absolute bottom-0 right-0 w-3 h-3 cursor-se-resize",onMouseDown:b,children:ee.jsxs("svg",{viewBox:"0 0 12 12",className:"w-3 h-3 text-muted-foreground/30",children:[ee.jsx("path",{d:"M11 1v10H1",fill:"none",stroke:"currentColor",strokeWidth:"1.5"}),ee.jsx("path",{d:"M11 5v6H5",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})]})})]})]})}function yT({plugins:e,onPluginsChange:t,onClose:n}){const r=W.useCallback(async(e,n)=>{t(t=>t.map(t=>t.id===e?{...t,userConfig:{...t.userConfig,...n}}:t));try{await EE(e,n)}catch{}},[t]);return 0===e.length?null:ee.jsx(Xb,{children:e.map(e=>ee.jsx(vT,{plugin:e,onConfigChange:r,onClose:n},e.id))})}function bT({onTogglePlugin:e,activeIds:t}){const[n,r]=W.useState([]);return W.useEffect(()=>{wE().then(e=>r(e.filter(e=>e.enabled))).catch(()=>r([]))},[]),W.useEffect(()=>{const e=()=>{wE().then(e=>r(e.filter(e=>e.enabled))).catch(()=>{})};return window.addEventListener("focus",e),()=>window.removeEventListener("focus",e)},[]),0===n.length?null:ee.jsx("div",{className:"fixed top-14 left-1/2 -translate-x-1/2 z-40 pointer-events-none",children:ee.jsx(hw.div,{className:"pointer-events-auto flex items-center gap-1 px-2 py-1 rounded-full bg-background/60 backdrop-blur-md border border-border/50 shadow-lg",initial:{opacity:0,y:-8},animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},children:n.map(n=>{const r=t.has(n.id),o=n.name.slice(0,2);return ee.jsxs(hw.button,{onClick:()=>e(n),className:uk("relative flex items-center justify-center w-7 h-7 rounded-full text-[10px] font-medium transition-colors",r?"bg-blue-500/20 text-blue-400":"text-muted-foreground/70 hover:text-foreground hover:bg-muted/80"),whileHover:{scale:1.12},whileTap:{scale:.92},title:n.name+(n.description?` — ${n.description}`:""),children:[o,ee.jsx(Xb,{children:r&&ee.jsx(hw.span,{className:"absolute -bottom-0.5 left-1/2 -translate-x-1/2 h-1 w-1 rounded-full bg-blue-400",initial:{scale:0},animate:{scale:1},exit:{scale:0}})})]},n.id)})})})}const xT=H.lazy(()=>fd(()=>import("./ProjectPage-B-7RSILW.js").then(e=>e.P),__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(e=>({default:e.ProjectPage}))),wT=H.lazy(()=>fd(()=>import("./SettingsPage-DrnZKm6L.js"),__vite__mapDeps([9,6,3,4])).then(e=>({default:e.SettingsPage}))),kT=H.lazy(()=>fd(()=>import("./SkillHubPage-Cr3_-Iwx.js"),__vite__mapDeps([10,7,3])).then(e=>({default:e.SkillHubPage}))),ST=H.lazy(()=>fd(()=>import("./MobilePage-Dt7mdX_t.js"),__vite__mapDeps([11,2,3,4,5])).then(e=>({default:e.MobilePage})));function ET(){return ee.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:ee.jsx("span",{className:"text-muted-foreground text-sm",children:"Loading…"})})}function jT({children:e}){const[t,n]=W.useState(!1),r=Yk(e=>e.token),o=Yk(e=>e.setToken);return W.useEffect(()=>{r?n(!0):nS()?rS().then(e=>o(e)).catch(()=>{}).finally(()=>n(!0)):n(!0)},[]),t||r?r?ee.jsx(ee.Fragment,{children:e}):ee.jsx(wf,{to:"/login",replace:!0}):null}const CT=window.matchMedia("(pointer: coarse)").matches&&window.innerWidth<768;function PT(){const[e,t]=W.useState([]),[n,r]=W.useState(()=>{try{return new Set(JSON.parse(localStorage.getItem("cc_plugin_open")||"[]"))}catch{return new Set}}),o=lf();W.useEffect(()=>{wE().then(t).catch(()=>t([]))},[]);const a=W.useCallback(e=>{r(t=>{const n=new Set(t);n.has(e.id)?n.delete(e.id):n.add(e.id);try{localStorage.setItem("cc_plugin_open",JSON.stringify([...n]))}catch{}return n})},[]),i=W.useCallback(e=>{r(t=>{const n=new Set(t);n.delete(e);try{localStorage.setItem("cc_plugin_open",JSON.stringify([...n]))}catch{}return n})},[]),s=function(e){if("/"===e||"/dashboard"===e)return{type:"dashboard"};const t=e.match(/^\/projects?\/([^/]+)/);return t?{type:"project",projectId:t[1]}:{type:"other"}}(o.pathname),l=e.filter(e=>{if(!e.enabled||!n.has(e.id))return!1;switch(e.userConfig.scope??e.float.scope.default){case"global":return!0;case"dashboard":return"dashboard"===s.type;case"project":return"project"===s.type;case"project:specific":return"project"===s.type&&(e.userConfig.projectIds??[]).includes(s.projectId??"");default:return!1}}),u="/login"===o.pathname,c="/mobile"===o.pathname;return ee.jsxs(ee.Fragment,{children:[!u&&!c&&!CT&&ee.jsx(bT,{onTogglePlugin:a,activeIds:n}),ee.jsx(yT,{plugins:l,onPluginsChange:t,onClose:i})]})}function NT({children:e}){const t=lf();return CT&&"/"===t.pathname?ee.jsx(wf,{to:"/mobile",replace:!0}):ee.jsx(ee.Fragment,{children:e})}function TT(){return ee.jsx(XN,{children:ee.jsxs(wN,{children:[ee.jsx(bN,{richColors:!0,position:"bottom-right"}),ee.jsx(nT,{}),ee.jsx(rT,{}),ee.jsx(gT,{children:ee.jsxs(Nf,{children:[ee.jsx(PT,{}),ee.jsx(NT,{children:ee.jsx(W.Suspense,{fallback:ee.jsx(ET,{}),children:ee.jsxs(Ef,{children:[ee.jsx(kf,{path:"/login",element:ee.jsx(_E,{})}),ee.jsx(kf,{path:"/",element:ee.jsx(jT,{children:ee.jsx(mT,{})})}),ee.jsx(kf,{path:"/projects/:id",element:ee.jsx(jT,{children:ee.jsx(xT,{})})}),ee.jsx(kf,{path:"/settings",element:ee.jsx(jT,{children:ee.jsx(wT,{})})}),ee.jsx(kf,{path:"/skillhub",element:ee.jsx(jT,{children:ee.jsx(kT,{})})}),ee.jsx(kf,{path:"/mobile",element:ee.jsx(jT,{children:ee.jsx(ST,{})})}),ee.jsx(kf,{path:"*",element:ee.jsx(wf,{to:"/",replace:!0})})]})})})]})})]})})}te.createRoot(document.getElementById("root")).render(ee.jsx(H.StrictMode,{children:ee.jsx(TT,{})}));export{uC as $,Xb as A,Rk as B,BE as C,$E as D,UE as E,HE as F,dE as G,fE as H,Lk as I,Gk as J,vk as K,Vj as L,oj as M,Cj as N,iC as O,lj as P,aC as Q,H as R,$k as S,bj as T,yk as U,jj as V,zj as W,wj as X,oP as Y,Fj as Z,fd as _,QN as a,eE as a$,QC as a0,Zj as a1,Gj as a2,pj as a3,yS as a4,hS as a5,KE as a6,GN as a7,wS as a8,vS as a9,oT as aA,ZN as aB,tj as aC,YE as aD,RE as aE,tE as aF,dS as aG,_N as aH,HN as aI,Nj as aJ,CE as aK,cT as aL,bE as aM,vE as aN,dT as aO,Hk as aP,xE as aQ,yE as aR,dj as aS,df as aT,Kk as aU,vj as aV,Dj as aW,Rj as aX,ld as aY,XS as aZ,ZS as a_,HP as aa,qP as ab,KP as ac,QP as ad,ZP as ae,Ik as af,XP as ag,mS as ah,bS as ai,gS as aj,xS as ak,CS as al,LS as am,SS as an,PS as ao,ES as ap,NS as aq,jS as ar,TS as as,MS as at,RS as au,kj as av,mj as aw,cf as ax,FE as ay,Ej as az,WS as b,ck as b0,dk as b1,fk as b2,hk as b3,NE as b4,TE as b5,ME as b6,LE as b7,_S as b8,OS as b9,zS as bA,jv as bB,Pv as bC,Ev as bD,r as bE,o as bF,PE as bG,a as bH,DE as bI,AS as ba,Df as bb,eT as bc,sE as bd,yj as be,QS as bf,nE as bg,oE as bh,iE as bi,JS as bj,aE as bk,rE as bl,lE as bm,wE as bn,kE as bo,SE as bp,jE as bq,DS as br,kS as bs,AN as bt,VN as bu,sT as bv,ij as bw,ON as bx,fT as by,WE as bz,OE as c,uk as d,rj as e,BS as f,Zk as g,Uk as h,Qk as i,ee as j,VS as k,cj as l,GS as m,$S as n,qE as o,hw as p,uE as q,W as r,Wk as s,dN as t,SN as u,pE as v,HS as w,VE as x,uj as y,cE as z};
|
|
75
|
+
*/const OE=(e,t)=>{const n=W.forwardRef(({color:n="currentColor",size:r=24,strokeWidth:o=2,absoluteStrokeWidth:a,className:i="",children:s,...l},u)=>{return W.createElement("svg",{ref:u,...AE,width:r,height:r,stroke:n,strokeWidth:a?24*Number(o)/Number(r):o,className:["lucide",`lucide-${c=e,c.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim()}`,i].join(" "),...l},[...t.map(([e,t])=>W.createElement(e,t)),...Array.isArray(s)?s:[s]]);var c});return n.displayName=`${e}`,n},IE=OE("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]),zE=OE("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]),FE=OE("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),VE=OE("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]),BE=OE("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),$E=OE("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]),UE=OE("Eye",[["path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z",key:"rwhkz3"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),WE=OE("File",[["path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z",key:"1nnpy2"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}]]),HE=OE("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]),GE=OE("FolderPlus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),YE=OE("FolderSync",[["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v.5",key:"1dkoa9"}],["path",{d:"M12 10v4h4",key:"1czhmt"}],["path",{d:"m12 14 1.535-1.605a5 5 0 0 1 8 1.5",key:"lvuxfi"}],["path",{d:"M22 22v-4h-4",key:"1ewp4q"}],["path",{d:"m22 18-1.535 1.605a5 5 0 0 1-8-1.5",key:"14ync0"}]]),qE=OE("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),KE=OE("GitMerge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]),XE=OE("GripHorizontal",[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]]),QE=OE("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]),ZE=OE("Home",[["path",{d:"m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"y5dka4"}],["polyline",{points:"9 22 9 12 15 12 15 22",key:"e2us08"}]]),JE=OE("KeyRound",[["path",{d:"M2 18v3c0 .6.4 1 1 1h4v-3h3v-3h2l1.4-1.4a6.5 6.5 0 1 0-4-4Z",key:"167ctg"}],["circle",{cx:"16.5",cy:"7.5",r:".5",key:"1kog09"}]]),ej=OE("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]),tj=OE("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),nj=OE("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]),rj=OE("Maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]),oj=OE("Minimize",[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]]),aj=OE("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]),ij=OE("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]),sj=OE("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]),lj=OE("Pencil",[["path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z",key:"5qss01"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]),uj=OE("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),cj=OE("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),dj=OE("Send",[["path",{d:"m22 2-7 20-4-9-9-4Z",key:"1q3vgg"}],["path",{d:"M22 2 11 13",key:"nzbqef"}]]),fj=OE("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),pj=OE("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),hj=OE("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]),mj=OE("Sparkles",[["path",{d:"m12 3-1.912 5.813a2 2 0 0 1-1.275 1.275L3 12l5.813 1.912a2 2 0 0 1 1.275 1.275L12 21l1.912-5.813a2 2 0 0 1 1.275-1.275L21 12l-5.813-1.912a2 2 0 0 1-1.275-1.275L12 3Z",key:"17u4zn"}],["path",{d:"M5 3v4",key:"bklmnn"}],["path",{d:"M19 17v4",key:"iiml17"}],["path",{d:"M3 5h4",key:"nem4j1"}],["path",{d:"M17 19h4",key:"lbex7p"}]]),gj=OE("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]),vj=OE("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]),yj=OE("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]),bj=OE("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]),xj=OE("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]),wj=OE("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),kj=OE("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]),Sj=Tk("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Ej({className:e,variant:t,...n}){return ee.jsx("div",{className:uk(Sj({variant:t}),e),...n})}function jj(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(null==e||e(r),!1===n||!r.defaultPrevented)return null==t?void 0:t(r)}}function Cj(e,t=[]){let n=[];const r=()=>{const t=n.map(e=>W.createContext(e));return function(n){const r=(null==n?void 0:n[e])||t;return W.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return r.scopeName=e,[function(t,r){const o=W.createContext(r),a=n.length;n=[...n,r];const i=t=>{var n;const{scope:r,children:i,...s}=t,l=(null==(n=null==r?void 0:r[e])?void 0:n[a])||o,u=W.useMemo(()=>s,Object.values(s));return ee.jsx(l.Provider,{value:u,children:i})};return i.displayName=t+"Provider",[i,function(n,i){var s;const l=(null==(s=null==i?void 0:i[e])?void 0:s[a])||o,u=W.useContext(l);if(u)return u;if(void 0!==r)return r;throw new Error(`\`${n}\` must be used within \`${t}\``)}]},Pj(r,...t)]}function Pj(...e){const t=e[0];if(1===e.length)return t;const n=()=>{const n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){const r=n.reduce((t,{useScope:n,scopeName:r})=>({...t,...n(e)[`__scope${r}`]}),{});return W.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}var Nj=(null==globalThis?void 0:globalThis.document)?W.useLayoutEffect:()=>{},Tj=G[" useId ".trim().toString()]||(()=>{}),Mj=0;function Rj(e){const[t,n]=W.useState(Tj());return Nj(()=>{n(e=>e??String(Mj++))},[e]),e||(t?`radix-${t}`:"")}var Lj=G[" useInsertionEffect ".trim().toString()]||Nj;function Dj({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,a,i]=function({defaultProp:e,onChange:t}){const[n,r]=W.useState(e),o=W.useRef(n),a=W.useRef(t);return Lj(()=>{a.current=t},[t]),W.useEffect(()=>{var e;o.current!==n&&(null==(e=a.current)||e.call(a,n),o.current=n)},[n,o]),[n,r,a]}({defaultProp:t,onChange:n}),s=void 0!==e,l=s?e:o;{const t=W.useRef(void 0!==e);W.useEffect(()=>{const e=t.current;if(e!==s){const t=e?"controlled":"uncontrolled",n=s?"controlled":"uncontrolled";console.warn(`${r} is changing from ${t} to ${n}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`)}t.current=s},[s,r])}const u=W.useCallback(t=>{var n;if(s){const r=function(e){return"function"==typeof e}(t)?t(e):t;r!==e&&(null==(n=i.current)||n.call(i,r))}else a(t)},[s,e,a,i]);return[l,u]}function _j(e){const t=Aj(e),n=W.forwardRef((e,n)=>{const{children:r,...o}=e,a=W.Children.toArray(r),i=a.find(Ij);if(i){const e=i.props.children,r=a.map(t=>t===i?W.Children.count(e)>1?W.Children.only(null):W.isValidElement(e)?e.props.children:null:t);return ee.jsx(t,{...o,ref:n,children:W.isValidElement(e)?W.cloneElement(e,void 0,r):null})}return ee.jsx(t,{...o,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function Aj(e){const t=W.forwardRef((e,t)=>{const{children:n,...r}=e;if(W.isValidElement(n)){const e=function(e){var t,n;let r=null==(t=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:t.get,o=r&&"isReactWarning"in r&&r.isReactWarning;if(o)return e.ref;if(r=null==(n=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:n.get,o=r&&"isReactWarning"in r&&r.isReactWarning,o)return e.props.ref;return e.props.ref||e.ref}(n),o=function(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...e)=>{const t=a(...e);return o(...e),t}:o&&(n[r]=o):"style"===r?n[r]={...o,...a}:"className"===r&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==W.Fragment&&(o.ref=t?vk(t,e):e),W.cloneElement(n,o)}return W.Children.count(n)>1?W.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Oj=Symbol("radix.slottable");function Ij(e){return W.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===Oj}var zj=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{const n=_j(`Primitive.${t}`),r=W.forwardRef((e,r)=>{const{asChild:o,...a}=e,i=o?n:t;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),ee.jsx(i,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Fj(e,t){e&&ld.flushSync(()=>e.dispatchEvent(t))}function Vj(e){const t=W.useRef(e);return W.useEffect(()=>{t.current=e}),W.useMemo(()=>(...e)=>{var n;return null==(n=t.current)?void 0:n.call(t,...e)},[])}var Bj,$j="dismissableLayer.update",Uj="dismissableLayer.pointerDownOutside",Wj="dismissableLayer.focusOutside",Hj=W.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Gj=W.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:i,onDismiss:s,...l}=e,u=W.useContext(Hj),[c,d]=W.useState(null),f=(null==c?void 0:c.ownerDocument)??(null==globalThis?void 0:globalThis.document),[,p]=W.useState({}),h=yk(t,e=>d(e)),m=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=m.indexOf(g),y=c?m.indexOf(c):-1,b=u.layersWithOutsidePointerEventsDisabled.size>0,x=y>=v,w=function(e,t=(null==globalThis?void 0:globalThis.document)){const n=Vj(e),r=W.useRef(!1),o=W.useRef(()=>{});return W.useEffect(()=>{const e=e=>{if(e.target&&!r.current){let r=function(){qj(Uj,n,a,{discrete:!0})};const a={originalEvent:e};"touch"===e.pointerType?(t.removeEventListener("click",o.current),o.current=r,t.addEventListener("click",o.current,{once:!0})):r()}else t.removeEventListener("click",o.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",e),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}(e=>{const t=e.target,n=[...u.branches].some(e=>e.contains(t));x&&!n&&(null==o||o(e),null==i||i(e),e.defaultPrevented||null==s||s())},f),k=function(e,t=(null==globalThis?void 0:globalThis.document)){const n=Vj(e),r=W.useRef(!1);return W.useEffect(()=>{const e=e=>{if(e.target&&!r.current){qj(Wj,n,{originalEvent:e},{discrete:!1})}};return t.addEventListener("focusin",e),()=>t.removeEventListener("focusin",e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}(e=>{const t=e.target;[...u.branches].some(e=>e.contains(t))||(null==a||a(e),null==i||i(e),e.defaultPrevented||null==s||s())},f);return function(e,t=(null==globalThis?void 0:globalThis.document)){const n=Vj(e);W.useEffect(()=>{const e=e=>{"Escape"===e.key&&n(e)};return t.addEventListener("keydown",e,{capture:!0}),()=>t.removeEventListener("keydown",e,{capture:!0})},[n,t])}(e=>{y===u.layers.size-1&&(null==r||r(e),!e.defaultPrevented&&s&&(e.preventDefault(),s()))},f),W.useEffect(()=>{if(c)return n&&(0===u.layersWithOutsidePointerEventsDisabled.size&&(Bj=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(c)),u.layers.add(c),Yj(),()=>{n&&1===u.layersWithOutsidePointerEventsDisabled.size&&(f.body.style.pointerEvents=Bj)}},[c,f,n,u]),W.useEffect(()=>()=>{c&&(u.layers.delete(c),u.layersWithOutsidePointerEventsDisabled.delete(c),Yj())},[c,u]),W.useEffect(()=>{const e=()=>p({});return document.addEventListener($j,e),()=>document.removeEventListener($j,e)},[]),ee.jsx(zj.div,{...l,ref:h,style:{pointerEvents:b?x?"auto":"none":void 0,...e.style},onFocusCapture:jj(e.onFocusCapture,k.onFocusCapture),onBlurCapture:jj(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:jj(e.onPointerDownCapture,w.onPointerDownCapture)})});Gj.displayName="DismissableLayer";function Yj(){const e=new CustomEvent($j);document.dispatchEvent(e)}function qj(e,t,n,{discrete:r}){const o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Fj(o,a):o.dispatchEvent(a)}W.forwardRef((e,t)=>{const n=W.useContext(Hj),r=W.useRef(null),o=yk(t,r);return W.useEffect(()=>{const e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),ee.jsx(zj.div,{...e,ref:o})}).displayName="DismissableLayerBranch";var Kj="focusScope.autoFocusOnMount",Xj="focusScope.autoFocusOnUnmount",Qj={bubbles:!1,cancelable:!0},Zj=W.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...i}=e,[s,l]=W.useState(null),u=Vj(o),c=Vj(a),d=W.useRef(null),f=yk(t,e=>l(e)),p=W.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;W.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;const t=e.target;s.contains(t)?d.current=t:nC(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;const t=e.relatedTarget;null!==t&&(s.contains(t)||nC(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&nC(s)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),r.disconnect()}}},[r,s,p.paused]),W.useEffect(()=>{if(s){rC.add(p);const t=document.activeElement;if(!s.contains(t)){const n=new CustomEvent(Kj,Qj);s.addEventListener(Kj,u),s.dispatchEvent(n),n.defaultPrevented||(!function(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(nC(r,{select:t}),document.activeElement!==n)return}((e=Jj(s),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&nC(s))}return()=>{s.removeEventListener(Kj,u),setTimeout(()=>{const e=new CustomEvent(Xj,Qj);s.addEventListener(Xj,c),s.dispatchEvent(e),e.defaultPrevented||nC(t??document.body,{select:!0}),s.removeEventListener(Xj,c),rC.remove(p)},0)}}var e},[s,u,c,p]);const h=W.useCallback(e=>{if(!n&&!r)return;if(p.paused)return;const t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,o=document.activeElement;if(t&&o){const t=e.currentTarget,[r,a]=function(e){const t=Jj(e),n=eC(t,e),r=eC(t.reverse(),e);return[n,r]}(t);r&&a?e.shiftKey||o!==a?e.shiftKey&&o===r&&(e.preventDefault(),n&&nC(a,{select:!0})):(e.preventDefault(),n&&nC(r,{select:!0})):o===t&&e.preventDefault()}},[n,r,p.paused]);return ee.jsx(zj.div,{tabIndex:-1,...i,ref:f,onKeyDown:h})});function Jj(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{const t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function eC(e,t){for(const n of e)if(!tC(n,{upTo:t}))return n}function tC(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==t&&e===t)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function nC(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&t&&e.select()}}Zj.displayName="FocusScope";var rC=function(){let e=[];return{add(t){const n=e[0];t!==n&&(null==n||n.pause()),e=oC(e,t),e.unshift(t)},remove(t){var n;e=oC(e,t),null==(n=e[0])||n.resume()}}}();function oC(e,t){const n=[...e],r=n.indexOf(t);return-1!==r&&n.splice(r,1),n}var aC=W.forwardRef((e,t)=>{var n;const{container:r,...o}=e,[a,i]=W.useState(!1);Nj(()=>i(!0),[]);const s=r||a&&(null==(n=null==globalThis?void 0:globalThis.document)?void 0:n.body);return s?ud.createPortal(ee.jsx(zj.div,{...o,ref:t}),s):null});aC.displayName="Portal";var iC=e=>{const{present:t,children:n}=e,r=function(e){const[t,n]=W.useState(),r=W.useRef(null),o=W.useRef(e),a=W.useRef("none"),i=e?"mounted":"unmounted",[s,l]=function(e,t){return W.useReducer((e,n)=>t[e][n]??e,e)}(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return W.useEffect(()=>{const e=sC(r.current);a.current="mounted"===s?e:"none"},[s]),Nj(()=>{const t=r.current,n=o.current;if(n!==e){const r=a.current,i=sC(t);if(e)l("MOUNT");else if("none"===i||"none"===(null==t?void 0:t.display))l("UNMOUNT");else{l(n&&r!==i?"ANIMATION_OUT":"UNMOUNT")}o.current=e}},[e,l]),Nj(()=>{if(t){let e;const n=t.ownerDocument.defaultView??window,i=a=>{const i=sC(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&i&&(l("ANIMATION_END"),!o.current)){const r=t.style.animationFillMode;t.style.animationFillMode="forwards",e=n.setTimeout(()=>{"forwards"===t.style.animationFillMode&&(t.style.animationFillMode=r)})}},s=e=>{e.target===t&&(a.current=sC(r.current))};return t.addEventListener("animationstart",s),t.addEventListener("animationcancel",i),t.addEventListener("animationend",i),()=>{n.clearTimeout(e),t.removeEventListener("animationstart",s),t.removeEventListener("animationcancel",i),t.removeEventListener("animationend",i)}}l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:W.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}(t),o="function"==typeof n?n({present:r.isPresent}):W.Children.only(n),a=yk(r.ref,function(e){var t,n;let r=null==(t=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:t.get,o=r&&"isReactWarning"in r&&r.isReactWarning;if(o)return e.ref;if(r=null==(n=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:n.get,o=r&&"isReactWarning"in r&&r.isReactWarning,o)return e.props.ref;return e.props.ref||e.ref}(o));return"function"==typeof n||r.isPresent?W.cloneElement(o,{ref:a}):null};function sC(e){return(null==e?void 0:e.animationName)||"none"}iC.displayName="Presence";var lC=0;function uC(){W.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??cC()),document.body.insertAdjacentElement("beforeend",e[1]??cC()),lC++,()=>{1===lC&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),lC--}},[])}function cC(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var dC=function(){return dC=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},dC.apply(this,arguments)};function fC(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}"function"==typeof SuppressedError&&SuppressedError;var pC="right-scroll-bar-position",hC="width-before-scroll-bar";function mC(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}var gC="undefined"!=typeof window?W.useLayoutEffect:W.useEffect,vC=new WeakMap;function yC(e,t){var n,r,o,a=(n=null,r=function(t){return e.forEach(function(e){return mC(e,t)})},(o=W.useState(function(){return{value:n,callback:r,facade:{get current(){return o.value},set current(e){var t=o.value;t!==e&&(o.value=e,o.callback(e,t))}}}})[0]).callback=r,o.facade);return gC(function(){var t=vC.get(a);if(t){var n=new Set(t),r=new Set(e),o=a.current;n.forEach(function(e){r.has(e)||mC(e,null)}),r.forEach(function(e){n.has(e)||mC(e,o)})}vC.set(a,e)},[e]),a}function bC(e){return e}var xC=function(e){var t=e.sideCar,n=fC(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return W.createElement(r,dC({},n))};xC.isSideCarExport=!0;var wC=function(e){void 0===e&&(e={});var t=function(e,t){void 0===t&&(t=bC);var n=[],r=!1;return{read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var o=t(e,r);return n.push(o),function(){n=n.filter(function(e){return e!==o})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var o=n;n=[],o.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},i=function(){return Promise.resolve().then(a)};i(),n={push:function(e){t.push(e),i()},filter:function(e){return t=t.filter(e),n}}}}}(null);return t.options=dC({async:!0,ssr:!1},e),t}(),kC=function(){},SC=W.forwardRef(function(e,t){var n=W.useRef(null),r=W.useState({onScrollCapture:kC,onWheelCapture:kC,onTouchMoveCapture:kC}),o=r[0],a=r[1],i=e.forwardProps,s=e.children,l=e.className,u=e.removeScrollBar,c=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,h=e.noIsolation,m=e.inert,g=e.allowPinchZoom,v=e.as,y=void 0===v?"div":v,b=e.gapMode,x=fC(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),w=f,k=yC([n,t]),S=dC(dC({},x),o);return W.createElement(W.Fragment,null,c&&W.createElement(w,{sideCar:wC,removeScrollBar:u,shards:d,noRelative:p,noIsolation:h,inert:m,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:b}),i?W.cloneElement(W.Children.only(s),dC(dC({},S),{ref:k})):W.createElement(y,dC({},S,{className:l,ref:k}),s))});SC.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},SC.classNames={fullWidth:hC,zeroRight:pC};function EC(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=function(){if("undefined"!=typeof __webpack_nonce__)return __webpack_nonce__}();return t&&e.setAttribute("nonce",t),e}var jC=function(){var e=0,t=null;return{add:function(n){var r,o;0==e&&(t=EC())&&(o=n,(r=t).styleSheet?r.styleSheet.cssText=o:r.appendChild(document.createTextNode(o)),function(e){(document.head||document.getElementsByTagName("head")[0]).appendChild(e)}(t)),e++},remove:function(){! --e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},CC=function(){var e,t=(e=jC(),function(t,n){W.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])});return function(e){var n=e.styles,r=e.dynamic;return t(n,r),null}},PC={left:0,top:0,right:0,gap:0},NC=function(e){return parseInt(e||"",10)||0},TC=function(e){if(void 0===e&&(e="margin"),"undefined"==typeof window)return PC;var t=function(e){var t=window.getComputedStyle(document.body),n=t["padding"===e?"paddingLeft":"marginLeft"],r=t["padding"===e?"paddingTop":"marginTop"],o=t["padding"===e?"paddingRight":"marginRight"];return[NC(n),NC(r),NC(o)]}(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},MC=CC(),RC="data-scroll-locked",LC=function(e,t,n,r){var o=e.left,a=e.top,i=e.right,s=e.gap;return void 0===n&&(n="margin"),"\n .".concat("with-scroll-bars-hidden"," {\n overflow: hidden ").concat(r,";\n padding-right: ").concat(s,"px ").concat(r,";\n }\n body[").concat(RC,"] {\n overflow: hidden ").concat(r,";\n overscroll-behavior: contain;\n ").concat([t&&"position: relative ".concat(r,";"),"margin"===n&&"\n padding-left: ".concat(o,"px;\n padding-top: ").concat(a,"px;\n padding-right: ").concat(i,"px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(s,"px ").concat(r,";\n "),"padding"===n&&"padding-right: ".concat(s,"px ").concat(r,";")].filter(Boolean).join(""),"\n }\n \n .").concat(pC," {\n right: ").concat(s,"px ").concat(r,";\n }\n \n .").concat(hC," {\n margin-right: ").concat(s,"px ").concat(r,";\n }\n \n .").concat(pC," .").concat(pC," {\n right: 0 ").concat(r,";\n }\n \n .").concat(hC," .").concat(hC," {\n margin-right: 0 ").concat(r,";\n }\n \n body[").concat(RC,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(s,"px;\n }\n")},DC=function(){var e=parseInt(document.body.getAttribute(RC)||"0",10);return isFinite(e)?e:0},_C=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=void 0===r?"margin":r;W.useEffect(function(){return document.body.setAttribute(RC,(DC()+1).toString()),function(){var e=DC()-1;e<=0?document.body.removeAttribute(RC):document.body.setAttribute(RC,e.toString())}},[]);var a=W.useMemo(function(){return TC(o)},[o]);return W.createElement(MC,{styles:LC(a,!t,o,n?"":"!important")})},AC=!1;if("undefined"!=typeof window)try{var OC=Object.defineProperty({},"passive",{get:function(){return AC=!0,!0}});window.addEventListener("test",OC,OC),window.removeEventListener("test",OC,OC)}catch(RT){AC=!1}var IC=!!AC&&{passive:!1},zC=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return"hidden"!==n[t]&&!(n.overflowY===n.overflowX&&!function(e){return"TEXTAREA"===e.tagName}(e)&&"visible"===n[t])},FC=function(e,t){var n=t.ownerDocument,r=t;do{if("undefined"!=typeof ShadowRoot&&r instanceof ShadowRoot&&(r=r.host),VC(e,r)){var o=BC(e,r);if(o[1]>o[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},VC=function(e,t){return"v"===e?function(e){return zC(e,"overflowY")}(t):function(e){return zC(e,"overflowX")}(t)},BC=function(e,t){return"v"===e?[(n=t).scrollTop,n.scrollHeight,n.clientHeight]:function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]}(t);var n},$C=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},UC=function(e){return[e.deltaX,e.deltaY]},WC=function(e){return e&&"current"in e?e.current:e},HC=function(e){return"\n .block-interactivity-".concat(e," {pointer-events: none;}\n .allow-interactivity-").concat(e," {pointer-events: all;}\n")},GC=0,YC=[];function qC(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const KC=(XC=function(e){var t=W.useRef([]),n=W.useRef([0,0]),r=W.useRef(),o=W.useState(GC++)[0],a=W.useState(CC)[0],i=W.useRef(e);W.useEffect(function(){i.current=e},[e]),W.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var t=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}([e.lockRef.current],(e.shards||[]).map(WC),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),t.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var s=W.useCallback(function(e,t){if("touches"in e&&2===e.touches.length||"wheel"===e.type&&e.ctrlKey)return!i.current.allowPinchZoom;var o,a=$C(e),s=n.current,l="deltaX"in e?e.deltaX:s[0]-a[0],u="deltaY"in e?e.deltaY:s[1]-a[1],c=e.target,d=Math.abs(l)>Math.abs(u)?"h":"v";if("touches"in e&&"h"===d&&"range"===c.type)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===c||p.contains(c)))return!1;var h=FC(d,c);if(!h)return!0;if(h?o=d:(o="v"===d?"h":"v",h=FC(d,c)),!h)return!1;if(!r.current&&"changedTouches"in e&&(l||u)&&(r.current=o),!o)return!0;var m=r.current||o;return function(e,t,n,r){var o=function(e,t){return"h"===e&&"rtl"===t?-1:1}(e,window.getComputedStyle(t).direction),a=o*r,i=n.target,s=t.contains(i),l=!1,u=a>0,c=0,d=0;do{if(!i)break;var f=BC(e,i),p=f[0],h=f[1]-f[2]-o*p;(p||h)&&VC(e,i)&&(c+=h,d+=p);var m=i.parentNode;i=m&&m.nodeType===Node.DOCUMENT_FRAGMENT_NODE?m.host:m}while(!s&&i!==document.body||s&&(t.contains(i)||t===i));return(u&&Math.abs(c)<1||!u&&Math.abs(d)<1)&&(l=!0),l}(m,t,e,"h"===m?l:u)},[]),l=W.useCallback(function(e){var n=e;if(YC.length&&YC[YC.length-1]===a){var r="deltaY"in n?UC(n):$C(n),o=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&(t=e.delta,o=r,t[0]===o[0]&&t[1]===o[1]);var t,o})[0];if(o&&o.should)n.cancelable&&n.preventDefault();else if(!o){var l=(i.current.shards||[]).map(WC).filter(Boolean).filter(function(e){return e.contains(n.target)});(l.length>0?s(n,l[0]):!i.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),u=W.useCallback(function(e,n,r,o){var a={name:e,delta:n,target:r,should:o,shadowParent:qC(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),c=W.useCallback(function(e){n.current=$C(e),r.current=void 0},[]),d=W.useCallback(function(t){u(t.type,UC(t),t.target,s(t,e.lockRef.current))},[]),f=W.useCallback(function(t){u(t.type,$C(t),t.target,s(t,e.lockRef.current))},[]);W.useEffect(function(){return YC.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,IC),document.addEventListener("touchmove",l,IC),document.addEventListener("touchstart",c,IC),function(){YC=YC.filter(function(e){return e!==a}),document.removeEventListener("wheel",l,IC),document.removeEventListener("touchmove",l,IC),document.removeEventListener("touchstart",c,IC)}},[]);var p=e.removeScrollBar,h=e.inert;return W.createElement(W.Fragment,null,h?W.createElement(a,{styles:HC(o)}):null,p?W.createElement(_C,{noRelative:e.noRelative,gapMode:e.gapMode}):null)},wC.useMedium(XC),xC);var XC,QC=W.forwardRef(function(e,t){return W.createElement(SC,dC({},e,{ref:t,sideCar:KC}))});QC.classNames=SC.classNames;var ZC=new WeakMap,JC=new WeakMap,eP={},tP=0,nP=function(e){return e&&(e.host||nP(e.parentNode))},rP=function(e,t,n,r){var o=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=nP(t);return n&&e.contains(n)?n:(console.error("aria-hidden",t,"in not contained inside",e,". Doing nothing"),null)}).filter(function(e){return Boolean(e)})}(t,Array.isArray(e)?e:[e]);eP[n]||(eP[n]=new WeakMap);var a=eP[n],i=[],s=new Set,l=new Set(o),u=function(e){e&&!s.has(e)&&(s.add(e),u(e.parentNode))};o.forEach(u);var c=function(e){e&&!l.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))c(e);else try{var t=e.getAttribute(r),o=null!==t&&"false"!==t,l=(ZC.get(e)||0)+1,u=(a.get(e)||0)+1;ZC.set(e,l),a.set(e,u),i.push(e),1===l&&o&&JC.set(e,!0),1===u&&e.setAttribute(n,"true"),o||e.setAttribute(r,"true")}catch(MT){console.error("aria-hidden: cannot operate on ",e,MT)}})};return c(t),s.clear(),tP++,function(){i.forEach(function(e){var t=ZC.get(e)-1,o=a.get(e)-1;ZC.set(e,t),a.set(e,o),t||(JC.has(e)||e.removeAttribute(r),JC.delete(e)),o||e.removeAttribute(n)}),--tP||(ZC=new WeakMap,ZC=new WeakMap,JC=new WeakMap,eP={})}},oP=function(e,t,n){void 0===n&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=function(e){return"undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body}(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),rP(r,o,n,"aria-hidden")):function(){return null}};function aP(e){const t=iP(e),n=W.forwardRef((e,n)=>{const{children:r,...o}=e,a=W.Children.toArray(r),i=a.find(lP);if(i){const e=i.props.children,r=a.map(t=>t===i?W.Children.count(e)>1?W.Children.only(null):W.isValidElement(e)?e.props.children:null:t);return ee.jsx(t,{...o,ref:n,children:W.isValidElement(e)?W.cloneElement(e,void 0,r):null})}return ee.jsx(t,{...o,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function iP(e){const t=W.forwardRef((e,t)=>{const{children:n,...r}=e;if(W.isValidElement(n)){const e=function(e){var t,n;let r=null==(t=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:t.get,o=r&&"isReactWarning"in r&&r.isReactWarning;if(o)return e.ref;if(r=null==(n=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:n.get,o=r&&"isReactWarning"in r&&r.isReactWarning,o)return e.props.ref;return e.props.ref||e.ref}(n),o=function(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...e)=>{const t=a(...e);return o(...e),t}:o&&(n[r]=o):"style"===r?n[r]={...o,...a}:"className"===r&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==W.Fragment&&(o.ref=t?vk(t,e):e),W.cloneElement(n,o)}return W.Children.count(n)>1?W.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var sP=Symbol("radix.slottable");function lP(e){return W.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===sP}var uP="Dialog",[cP]=Cj(uP),[dP,fP]=cP(uP),pP=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:a,modal:i=!0}=e,s=W.useRef(null),l=W.useRef(null),[u,c]=Dj({prop:r,defaultProp:o??!1,onChange:a,caller:uP});return ee.jsx(dP,{scope:t,triggerRef:s,contentRef:l,contentId:Rj(),titleId:Rj(),descriptionId:Rj(),open:u,onOpenChange:c,onOpenToggle:W.useCallback(()=>c(e=>!e),[c]),modal:i,children:n})};pP.displayName=uP;var hP="DialogTrigger";W.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fP(hP,n),a=yk(t,o.triggerRef);return ee.jsx(zj.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":_P(o.open),...r,ref:a,onClick:jj(e.onClick,o.onOpenToggle)})}).displayName=hP;var mP="DialogPortal",[gP,vP]=cP(mP,{forceMount:void 0}),yP=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,a=fP(mP,t);return ee.jsx(gP,{scope:t,forceMount:n,children:W.Children.map(r,e=>ee.jsx(iC,{present:n||a.open,children:ee.jsx(aC,{asChild:!0,container:o,children:e})}))})};yP.displayName=mP;var bP="DialogOverlay",xP=W.forwardRef((e,t)=>{const n=vP(bP,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=fP(bP,e.__scopeDialog);return a.modal?ee.jsx(iC,{present:r||a.open,children:ee.jsx(kP,{...o,ref:t})}):null});xP.displayName=bP;var wP=aP("DialogOverlay.RemoveScroll"),kP=W.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fP(bP,n);return ee.jsx(QC,{as:wP,allowPinchZoom:!0,shards:[o.contentRef],children:ee.jsx(zj.div,{"data-state":_P(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),SP="DialogContent",EP=W.forwardRef((e,t)=>{const n=vP(SP,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=fP(SP,e.__scopeDialog);return ee.jsx(iC,{present:r||a.open,children:a.modal?ee.jsx(jP,{...o,ref:t}):ee.jsx(CP,{...o,ref:t})})});EP.displayName=SP;var jP=W.forwardRef((e,t)=>{const n=fP(SP,e.__scopeDialog),r=W.useRef(null),o=yk(t,n.contentRef,r);return W.useEffect(()=>{const e=r.current;if(e)return oP(e)},[]),ee.jsx(PP,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:jj(e.onCloseAutoFocus,e=>{var t;e.preventDefault(),null==(t=n.triggerRef.current)||t.focus()}),onPointerDownOutside:jj(e.onPointerDownOutside,e=>{const t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey;(2===t.button||n)&&e.preventDefault()}),onFocusOutside:jj(e.onFocusOutside,e=>e.preventDefault())})}),CP=W.forwardRef((e,t)=>{const n=fP(SP,e.__scopeDialog),r=W.useRef(!1),o=W.useRef(!1);return ee.jsx(PP,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{var a,i;null==(a=e.onCloseAutoFocus)||a.call(e,t),t.defaultPrevented||(r.current||null==(i=n.triggerRef.current)||i.focus(),t.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:t=>{var a,i;null==(a=e.onInteractOutside)||a.call(e,t),t.defaultPrevented||(r.current=!0,"pointerdown"===t.detail.originalEvent.type&&(o.current=!0));const s=t.target;(null==(i=n.triggerRef.current)?void 0:i.contains(s))&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&o.current&&t.preventDefault()}})}),PP=W.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,...i}=e,s=fP(SP,n),l=W.useRef(null),u=yk(t,l);return uC(),ee.jsxs(ee.Fragment,{children:[ee.jsx(Zj,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:ee.jsx(Gj,{role:"dialog",id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":_P(s.open),...i,ref:u,onDismiss:()=>s.onOpenChange(!1)})}),ee.jsxs(ee.Fragment,{children:[ee.jsx(zP,{titleId:s.titleId}),ee.jsx(FP,{contentRef:l,descriptionId:s.descriptionId})]})]})}),NP="DialogTitle",TP=W.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fP(NP,n);return ee.jsx(zj.h2,{id:o.titleId,...r,ref:t})});TP.displayName=NP;var MP="DialogDescription",RP=W.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fP(MP,n);return ee.jsx(zj.p,{id:o.descriptionId,...r,ref:t})});RP.displayName=MP;var LP="DialogClose",DP=W.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fP(LP,n);return ee.jsx(zj.button,{type:"button",...r,ref:t,onClick:jj(e.onClick,()=>o.onOpenChange(!1))})});function _P(e){return e?"open":"closed"}DP.displayName=LP;var AP="DialogTitleWarning",[OP,IP]=function(e,t){const n=W.createContext(t),r=e=>{const{children:t,...r}=e,o=W.useMemo(()=>r,Object.values(r));return ee.jsx(n.Provider,{value:o,children:t})};return r.displayName=e+"Provider",[r,function(r){const o=W.useContext(n);if(o)return o;if(void 0!==t)return t;throw new Error(`\`${r}\` must be used within \`${e}\``)}]}(AP,{contentName:SP,titleName:NP,docsSlug:"dialog"}),zP=({titleId:e})=>{const t=IP(AP),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.\n\nIf you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.\n\nFor more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return W.useEffect(()=>{if(e){document.getElementById(e)||console.error(n)}},[n,e]),null},FP=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${IP("DialogDescriptionWarning").contentName}}.`;return W.useEffect(()=>{var r;const o=null==(r=e.current)?void 0:r.getAttribute("aria-describedby");if(t&&o){document.getElementById(t)||console.warn(n)}},[n,e,t]),null},VP=xP,BP=EP,$P=TP,UP=RP,WP=DP;const HP=pP,GP=yP,YP=W.forwardRef(({className:e,...t},n)=>ee.jsx(VP,{ref:n,className:uk("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));YP.displayName=VP.displayName;const qP=W.forwardRef(({className:e,children:t,noOverlay:n,...r},o)=>ee.jsxs(GP,{children:[!n&&ee.jsx(YP,{}),ee.jsxs(BP,{ref:o,className:uk("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...r,children:[t,ee.jsxs(WP,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[ee.jsx(wj,{className:"h-4 w-4"}),ee.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));qP.displayName=BP.displayName;const KP=({className:e,...t})=>ee.jsx("div",{className:uk("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});KP.displayName="DialogHeader";const XP=({className:e,...t})=>ee.jsx("div",{className:uk("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});XP.displayName="DialogFooter";const QP=W.forwardRef(({className:e,...t},n)=>ee.jsx($P,{ref:n,className:uk("text-lg font-semibold leading-none tracking-tight",e),...t}));QP.displayName=$P.displayName;const ZP=W.forwardRef(({className:e,...t},n)=>ee.jsx(UP,{ref:n,className:uk("text-sm text-muted-foreground",e),...t}));function JP({project:e,open:t,onOpenChange:n,onUpdated:r}){const[o,a]=W.useState([]),[i,s]=W.useState([]),[l,u]=W.useState(!1),[c,d]=W.useState(null);W.useEffect(()=>{if(!t)return;a(e.shares?[...e.shares]:[]),d(null);let n=!1;return iS().then(e=>{n||s(e)}).catch(()=>{}),()=>{n=!0}},[t,e.id]);const f=new Set(o.map(e=>e.username)),p=i.filter(t=>t!==e.owner&&!f.has(t));return ee.jsx(HP,{open:t,onOpenChange:n,children:ee.jsxs(qP,{className:"sm:max-w-md",children:[ee.jsxs(KP,{children:[ee.jsxs(QP,{className:"flex items-center gap-2",children:[ee.jsx(xj,{className:"h-4 w-4"}),"共享设置"]}),ee.jsx(ZP,{children:"选择用户并设置权限:可见(只读)或可编辑(读写+终端)"})]}),ee.jsxs("div",{className:"space-y-3 max-h-64 overflow-y-auto",children:[0===o.length&&ee.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"尚未共享给任何用户"}),o.map(e=>ee.jsxs("div",{className:"flex items-center justify-between gap-2 px-1",children:[ee.jsx("span",{className:"text-sm font-medium",children:e.username}),ee.jsxs("div",{className:"flex items-center gap-1.5",children:[ee.jsx("button",{onClick:()=>{return t=e.username,void a(e=>e.map(e=>e.username===t?{...e,permission:"view"===e.permission?"edit":"view"}:e));var t},className:"focus:outline-none",children:ee.jsx(Ej,{variant:"edit"===e.permission?"default":"secondary",className:"cursor-pointer text-xs",children:"edit"===e.permission?"可编辑":"可见"})}),ee.jsx(Rk,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive",onClick:()=>{return t=e.username,void a(e=>e.filter(e=>e.username!==t));var t},children:ee.jsx(bj,{className:"h-3.5 w-3.5"})})]})]},e.username))]}),p.length>0&&ee.jsxs("div",{className:"border-t pt-3",children:[ee.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"添加用户"}),ee.jsx("div",{className:"flex flex-wrap gap-1.5",children:p.map(e=>ee.jsxs(Rk,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>{return t=e,void a(e=>[...e,{username:t,permission:"view"}]);var t},children:[ee.jsx(uj,{className:"h-3 w-3"}),e]},e))})]}),c&&ee.jsx("p",{className:"text-sm text-destructive",children:c}),ee.jsxs(XP,{children:[ee.jsx(Rk,{variant:"outline",onClick:()=>n(!1),disabled:l,children:"取消"}),ee.jsx(Rk,{onClick:()=>{(async()=>{u(!0),d(null);try{const t=await sS(e.id,o);r(t),n(!1)}catch(RT){d(RT instanceof Error?RT.message:"Failed to update shares")}finally{u(!1)}})()},disabled:l,children:l?"保存中...":"保存"})]})]})})}ZP.displayName=UP.displayName;const eN=Array(12).fill(0),tN=({visible:e,className:t})=>H.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},H.createElement("div",{className:"sonner-spinner"},eN.map((e,t)=>H.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${t}`})))),nN=H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},H.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),rN=H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},H.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),oN=H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},H.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),aN=H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},H.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),iN=H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},H.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),H.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"}));let sN=1;const lN=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{const t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;const{message:n,...r}=e,o="number"==typeof(null==e?void 0:e.id)||(null==(t=e.id)?void 0:t.length)>0?e.id:sN++,a=this.toasts.find(e=>e.id===o),i=void 0===e.dismissible||e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),a?this.toasts=this.toasts.map(t=>t.id===o?(this.publish({...t,...e,id:o,title:n}),{...t,...e,id:o,dismissible:i,title:n}):t):this.addToast({title:n,...r,dismissible:i,id:o}),o},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;void 0!==t.loading&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:"function"!=typeof t.description?t.description:void 0}));const r=Promise.resolve(e instanceof Function?e():e);let o,a=void 0!==n;const i=r.then(async e=>{o=["resolve",e];if(H.isValidElement(e))a=!1,this.create({id:n,type:"default",message:e});else if(uN(e)&&!e.ok){a=!1;const r="function"==typeof t.error?await t.error(`HTTP error! status: ${e.status}`):t.error,o="function"==typeof t.description?await t.description(`HTTP error! status: ${e.status}`):t.description,i="object"==typeof r&&!H.isValidElement(r)?r:{message:r};this.create({id:n,type:"error",description:o,...i})}else if(e instanceof Error){a=!1;const r="function"==typeof t.error?await t.error(e):t.error,o="function"==typeof t.description?await t.description(e):t.description,i="object"==typeof r&&!H.isValidElement(r)?r:{message:r};this.create({id:n,type:"error",description:o,...i})}else if(void 0!==t.success){a=!1;const r="function"==typeof t.success?await t.success(e):t.success,o="function"==typeof t.description?await t.description(e):t.description,i="object"==typeof r&&!H.isValidElement(r)?r:{message:r};this.create({id:n,type:"success",description:o,...i})}}).catch(async e=>{if(o=["reject",e],void 0!==t.error){a=!1;const r="function"==typeof t.error?await t.error(e):t.error,o="function"==typeof t.description?await t.description(e):t.description,i="object"==typeof r&&!H.isValidElement(r)?r:{message:r};this.create({id:n,type:"error",description:o,...i})}}).finally(()=>{a&&(this.dismiss(n),n=void 0),null==t.finally||t.finally.call(t)}),s=()=>new Promise((e,t)=>i.then(()=>"reject"===o[0]?t(o[1]):e(o[1])).catch(t));return"string"!=typeof n&&"number"!=typeof n?{unwrap:s}:Object.assign(n,{unwrap:s})},this.custom=(e,t)=>{const n=(null==t?void 0:t.id)||sN++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},uN=e=>e&&"object"==typeof e&&"ok"in e&&"boolean"==typeof e.ok&&"status"in e&&"number"==typeof e.status,cN=(e,t)=>{const n=(null==t?void 0:t.id)||sN++;return lN.addToast({title:e,...t,id:n}),n},dN=Object.assign(cN,{success:lN.success,info:lN.info,warning:lN.warning,error:lN.error,custom:lN.custom,message:lN.message,promise:lN.promise,dismiss:lN.dismiss,loading:lN.loading},{getHistory:()=>lN.toasts,getToasts:()=>lN.getActiveToasts()});function fN(e){return void 0!==e.label}!function(e){if("undefined"==typeof document)return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");const pN=3,hN=14;function mN(...e){return e.filter(Boolean).join(" ")}const gN=e=>{var t,n,r,o,a,i,s,l,u;const{invert:c,toast:d,unstyled:f,interacting:p,setHeights:h,visibleToasts:m,heights:g,index:v,toasts:y,expanded:b,removeToast:x,defaultRichColors:w,closeButton:k,style:S,cancelButtonStyle:E,actionButtonStyle:j,className:C="",descriptionClassName:P="",duration:N,position:T,gap:M,expandByDefault:R,classNames:L,icons:D,closeButtonAriaLabel:_="Close toast"}=e,[A,O]=H.useState(null),[I,z]=H.useState(null),[F,V]=H.useState(!1),[B,$]=H.useState(!1),[U,W]=H.useState(!1),[G,Y]=H.useState(!1),[q,K]=H.useState(!1),[X,Q]=H.useState(0),[Z,J]=H.useState(0),ee=H.useRef(d.duration||N||4e3),te=H.useRef(null),ne=H.useRef(null),re=0===v,oe=v+1<=m,ae=d.type,ie=!1!==d.dismissible,se=d.className||"",le=d.descriptionClassName||"",ue=H.useMemo(()=>g.findIndex(e=>e.toastId===d.id)||0,[g,d.id]),ce=H.useMemo(()=>{var e;return null!=(e=d.closeButton)?e:k},[d.closeButton,k]),de=H.useMemo(()=>d.duration||N||4e3,[d.duration,N]),fe=H.useRef(0),pe=H.useRef(0),he=H.useRef(0),me=H.useRef(null),[ge,ve]=T.split("-"),ye=H.useMemo(()=>g.reduce((e,t,n)=>n>=ue?e:e+t.height,0),[g,ue]),be=(()=>{const[e,t]=H.useState(document.hidden);return H.useEffect(()=>{const e=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",e),()=>window.removeEventListener("visibilitychange",e)},[]),e})(),xe=d.invert||c,we="loading"===ae;pe.current=H.useMemo(()=>ue*M+ye,[ue,ye]),H.useEffect(()=>{ee.current=de},[de]),H.useEffect(()=>{V(!0)},[]),H.useEffect(()=>{const e=ne.current;if(e){const t=e.getBoundingClientRect().height;return J(t),h(e=>[{toastId:d.id,height:t,position:d.position},...e]),()=>h(e=>e.filter(e=>e.toastId!==d.id))}},[h,d.id]),H.useLayoutEffect(()=>{if(!F)return;const e=ne.current,t=e.style.height;e.style.height="auto";const n=e.getBoundingClientRect().height;e.style.height=t,J(n),h(e=>e.find(e=>e.toastId===d.id)?e.map(e=>e.toastId===d.id?{...e,height:n}:e):[{toastId:d.id,height:n,position:d.position},...e])},[F,d.title,d.description,h,d.id,d.jsx,d.action,d.cancel]);const ke=H.useCallback(()=>{$(!0),Q(pe.current),h(e=>e.filter(e=>e.toastId!==d.id)),setTimeout(()=>{x(d)},200)},[d,x,h,pe]);H.useEffect(()=>{if(d.promise&&"loading"===ae||d.duration===1/0||"loading"===d.type)return;let e;return b||p||be?(()=>{if(he.current<fe.current){const e=(new Date).getTime()-fe.current;ee.current=ee.current-e}he.current=(new Date).getTime()})():ee.current!==1/0&&(fe.current=(new Date).getTime(),e=setTimeout(()=>{null==d.onAutoClose||d.onAutoClose.call(d,d),ke()},ee.current)),()=>clearTimeout(e)},[b,p,d,ae,be,ke]),H.useEffect(()=>{d.delete&&(ke(),null==d.onDismiss||d.onDismiss.call(d,d))},[ke,d.delete]);const Se=d.icon||(null==D?void 0:D[ae])||(e=>{switch(e){case"success":return nN;case"info":return oN;case"warning":return rN;case"error":return aN;default:return null}})(ae);var Ee,je,Ce,Pe;return H.createElement("li",{tabIndex:0,ref:ne,className:mN(C,se,null==L?void 0:L.toast,null==d||null==(t=d.classNames)?void 0:t.toast,null==L?void 0:L.default,null==L?void 0:L[ae],null==d||null==(n=d.classNames)?void 0:n[ae]),"data-sonner-toast":"","data-rich-colors":null!=(Ee=d.richColors)?Ee:w,"data-styled":!Boolean(d.jsx||d.unstyled||f),"data-mounted":F,"data-promise":Boolean(d.promise),"data-swiped":q,"data-removed":B,"data-visible":oe,"data-y-position":ge,"data-x-position":ve,"data-index":v,"data-front":re,"data-swiping":U,"data-dismissible":ie,"data-type":ae,"data-invert":xe,"data-swipe-out":G,"data-swipe-direction":I,"data-expanded":Boolean(b||R&&F),"data-testid":d.testId,style:{"--index":v,"--toasts-before":v,"--z-index":y.length-v,"--offset":`${B?X:pe.current}px`,"--initial-height":R?"auto":`${Z}px`,...S,...d.style},onDragEnd:()=>{W(!1),O(null),me.current=null},onPointerDown:e=>{2!==e.button&&!we&&ie&&(te.current=new Date,Q(pe.current),e.target.setPointerCapture(e.pointerId),"BUTTON"!==e.target.tagName&&(W(!0),me.current={x:e.clientX,y:e.clientY}))},onPointerUp:()=>{var e,t,n;if(G||!ie)return;me.current=null;const r=Number((null==(e=ne.current)?void 0:e.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),o=Number((null==(t=ne.current)?void 0:t.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),a=(new Date).getTime()-(null==(n=te.current)?void 0:n.getTime()),i="x"===A?r:o,s=Math.abs(i)/a;if(Math.abs(i)>=45||s>.11)return Q(pe.current),null==d.onDismiss||d.onDismiss.call(d,d),z("x"===A?r>0?"right":"left":o>0?"down":"up"),ke(),void Y(!0);var l,u;null==(l=ne.current)||l.style.setProperty("--swipe-amount-x","0px"),null==(u=ne.current)||u.style.setProperty("--swipe-amount-y","0px"),K(!1),W(!1),O(null)},onPointerMove:t=>{var n,r,o;if(!me.current||!ie)return;if((null==(n=window.getSelection())?void 0:n.toString().length)>0)return;const a=t.clientY-me.current.y,i=t.clientX-me.current.x;var s;const l=null!=(s=e.swipeDirections)?s:function(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}(T);!A&&(Math.abs(i)>1||Math.abs(a)>1)&&O(Math.abs(i)>Math.abs(a)?"x":"y");let u={x:0,y:0};const c=e=>1/(1.5+Math.abs(e)/20);if("y"===A){if(l.includes("top")||l.includes("bottom"))if(l.includes("top")&&a<0||l.includes("bottom")&&a>0)u.y=a;else{const e=a*c(a);u.y=Math.abs(e)<Math.abs(a)?e:a}}else if("x"===A&&(l.includes("left")||l.includes("right")))if(l.includes("left")&&i<0||l.includes("right")&&i>0)u.x=i;else{const e=i*c(i);u.x=Math.abs(e)<Math.abs(i)?e:i}(Math.abs(u.x)>0||Math.abs(u.y)>0)&&K(!0),null==(r=ne.current)||r.style.setProperty("--swipe-amount-x",`${u.x}px`),null==(o=ne.current)||o.style.setProperty("--swipe-amount-y",`${u.y}px`)}},ce&&!d.jsx&&"loading"!==ae?H.createElement("button",{"aria-label":_,"data-disabled":we,"data-close-button":!0,onClick:we||!ie?()=>{}:()=>{ke(),null==d.onDismiss||d.onDismiss.call(d,d)},className:mN(null==L?void 0:L.closeButton,null==d||null==(r=d.classNames)?void 0:r.closeButton)},null!=(je=null==D?void 0:D.close)?je:iN):null,(ae||d.icon||d.promise)&&null!==d.icon&&(null!==(null==D?void 0:D[ae])||d.icon)?H.createElement("div",{"data-icon":"",className:mN(null==L?void 0:L.icon,null==d||null==(o=d.classNames)?void 0:o.icon)},d.promise||"loading"===d.type&&!d.icon?d.icon||((null==D?void 0:D.loading)?H.createElement("div",{className:mN(null==L?void 0:L.loader,null==d||null==(Pe=d.classNames)?void 0:Pe.loader,"sonner-loader"),"data-visible":"loading"===ae},D.loading):H.createElement(tN,{className:mN(null==L?void 0:L.loader,null==d||null==(Ce=d.classNames)?void 0:Ce.loader),visible:"loading"===ae})):null,"loading"!==d.type?Se:null):null,H.createElement("div",{"data-content":"",className:mN(null==L?void 0:L.content,null==d||null==(a=d.classNames)?void 0:a.content)},H.createElement("div",{"data-title":"",className:mN(null==L?void 0:L.title,null==d||null==(i=d.classNames)?void 0:i.title)},d.jsx?d.jsx:"function"==typeof d.title?d.title():d.title),d.description?H.createElement("div",{"data-description":"",className:mN(P,le,null==L?void 0:L.description,null==d||null==(s=d.classNames)?void 0:s.description)},"function"==typeof d.description?d.description():d.description):null),H.isValidElement(d.cancel)?d.cancel:d.cancel&&fN(d.cancel)?H.createElement("button",{"data-button":!0,"data-cancel":!0,style:d.cancelButtonStyle||E,onClick:e=>{fN(d.cancel)&&ie&&(null==d.cancel.onClick||d.cancel.onClick.call(d.cancel,e),ke())},className:mN(null==L?void 0:L.cancelButton,null==d||null==(l=d.classNames)?void 0:l.cancelButton)},d.cancel.label):null,H.isValidElement(d.action)?d.action:d.action&&fN(d.action)?H.createElement("button",{"data-button":!0,"data-action":!0,style:d.actionButtonStyle||j,onClick:e=>{fN(d.action)&&(null==d.action.onClick||d.action.onClick.call(d.action,e),e.defaultPrevented||ke())},className:mN(null==L?void 0:L.actionButton,null==d||null==(u=d.classNames)?void 0:u.actionButton)},d.action.label):null)};function vN(){if("undefined"==typeof window)return"ltr";if("undefined"==typeof document)return"ltr";const e=document.documentElement.getAttribute("dir");return"auto"!==e&&e?e:window.getComputedStyle(document.documentElement).direction}function yN(e,t){const n={};return[e,t].forEach((e,t)=>{const r=1===t,o=r?"--mobile-offset":"--offset",a=r?"16px":"24px";function i(e){["top","right","bottom","left"].forEach(t=>{n[`${o}-${t}`]="number"==typeof e?`${e}px`:e})}"number"==typeof e||"string"==typeof e?i(e):"object"==typeof e?["top","right","bottom","left"].forEach(t=>{void 0===e[t]?n[`${o}-${t}`]=a:n[`${o}-${t}`]="number"==typeof e[t]?`${e[t]}px`:e[t]}):i(a)}),n}const bN=H.forwardRef(function(e,t){const{id:n,invert:r,position:o="bottom-right",hotkey:a=["altKey","KeyT"],expand:i,closeButton:s,className:l,offset:u,mobileOffset:c,theme:d="light",richColors:f,duration:p,style:h,visibleToasts:m=pN,toastOptions:g,dir:v=vN(),gap:y=hN,icons:b,containerAriaLabel:x="Notifications"}=e,[w,k]=H.useState([]),S=H.useMemo(()=>n?w.filter(e=>e.toasterId===n):w.filter(e=>!e.toasterId),[w,n]),E=H.useMemo(()=>Array.from(new Set([o].concat(S.filter(e=>e.position).map(e=>e.position)))),[S,o]),[j,C]=H.useState([]),[P,N]=H.useState(!1),[T,M]=H.useState(!1),[R,L]=H.useState("system"!==d?d:"undefined"!=typeof window&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),D=H.useRef(null),_=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),A=H.useRef(null),O=H.useRef(!1),I=H.useCallback(e=>{k(t=>{var n;return(null==(n=t.find(t=>t.id===e.id))?void 0:n.delete)||lN.dismiss(e.id),t.filter(({id:t})=>t!==e.id)})},[]);return H.useEffect(()=>lN.subscribe(e=>{e.dismiss?requestAnimationFrame(()=>{k(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))}):setTimeout(()=>{ud.flushSync(()=>{k(t=>{const n=t.findIndex(t=>t.id===e.id);return-1!==n?[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]:[e,...t]})})})}),[w]),H.useEffect(()=>{if("system"!==d)return void L(d);if("system"===d&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?L("dark"):L("light")),"undefined"==typeof window)return;const e=window.matchMedia("(prefers-color-scheme: dark)");try{e.addEventListener("change",({matches:e})=>{L(e?"dark":"light")})}catch(t){e.addListener(({matches:e})=>{try{L(e?"dark":"light")}catch(MT){console.error(MT)}})}},[d]),H.useEffect(()=>{w.length<=1&&N(!1)},[w]),H.useEffect(()=>{const e=e=>{var t;var n;a.every(t=>e[t]||e.code===t)&&(N(!0),null==(n=D.current)||n.focus());"Escape"!==e.code||document.activeElement!==D.current&&!(null==(t=D.current)?void 0:t.contains(document.activeElement))||N(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[a]),H.useEffect(()=>{if(D.current)return()=>{A.current&&(A.current.focus({preventScroll:!0}),A.current=null,O.current=!1)}},[D.current]),H.createElement("section",{ref:t,"aria-label":`${x} ${_}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},E.map((t,n)=>{var o;const[a,d]=t.split("-");return S.length?H.createElement("ol",{key:t,dir:"auto"===v?vN():v,tabIndex:-1,ref:D,className:l,"data-sonner-toaster":!0,"data-sonner-theme":R,"data-y-position":a,"data-x-position":d,style:{"--front-toast-height":`${(null==(o=j[0])?void 0:o.height)||0}px`,"--width":"356px","--gap":`${y}px`,...h,...yN(u,c)},onBlur:e=>{O.current&&!e.currentTarget.contains(e.relatedTarget)&&(O.current=!1,A.current&&(A.current.focus({preventScroll:!0}),A.current=null))},onFocus:e=>{e.target instanceof HTMLElement&&"false"===e.target.dataset.dismissible||O.current||(O.current=!0,A.current=e.relatedTarget)},onMouseEnter:()=>N(!0),onMouseMove:()=>N(!0),onMouseLeave:()=>{T||N(!1)},onDragEnd:()=>N(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&"false"===e.target.dataset.dismissible||M(!0)},onPointerUp:()=>M(!1)},S.filter(e=>!e.position&&0===n||e.position===t).map((n,o)=>{var a,l;return H.createElement(gN,{key:n.id,icons:b,index:o,toast:n,defaultRichColors:f,duration:null!=(a=null==g?void 0:g.duration)?a:p,className:null==g?void 0:g.className,descriptionClassName:null==g?void 0:g.descriptionClassName,invert:r,visibleToasts:m,closeButton:null!=(l=null==g?void 0:g.closeButton)?l:s,interacting:T,position:t,style:null==g?void 0:g.style,unstyled:null==g?void 0:g.unstyled,classNames:null==g?void 0:g.classNames,cancelButtonStyle:null==g?void 0:g.cancelButtonStyle,actionButtonStyle:null==g?void 0:g.actionButtonStyle,closeButtonAriaLabel:null==g?void 0:g.closeButtonAriaLabel,removeToast:I,toasts:S.filter(e=>e.position==n.position),heights:j.filter(e=>e.position==n.position),setHeights:C,expandByDefault:i,gap:y,expanded:P,swipeDirections:e.swipeDirections})})):null}))}),xN=W.createContext(null);function wN({children:e}){const[t,n]=W.useState(!1),[r,o]=W.useState({}),a=W.useRef(null),i=W.useCallback(e=>(o(e),n(!0),new Promise(e=>{a.current=e})),[]),s=W.useCallback(e=>{n(!1);const t=a.current;a.current=null,t&&t(e)},[]);return ee.jsxs(xN.Provider,{value:i,children:[e,ee.jsx(HP,{open:t,onOpenChange:e=>{e||s(!1)},children:ee.jsxs(qP,{className:"max-w-md",children:[ee.jsxs(KP,{children:[ee.jsx(QP,{children:r.title??"确认"}),void 0!==r.description&&ee.jsx(ZP,{asChild:!0,children:ee.jsx("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),ee.jsxs(XP,{children:[ee.jsx(Rk,{variant:"outline",onClick:()=>s(!1),children:r.cancelLabel??"取消"}),ee.jsx(kN,{destructive:r.destructive,onClick:()=>s(!0),children:r.confirmLabel??"确定"})]})]})})]})}function kN({destructive:e,onClick:t,children:n}){const r=W.useRef(null);return W.useEffect(()=>{var e;null==(e=r.current)||e.focus()},[]),ee.jsx(Rk,{ref:r,onClick:t,className:uk(e&&"bg-red-600 hover:bg-red-700 text-white"),children:n})}function SN(){const e=W.useContext(xN);if(!e)throw new Error("useConfirm must be used within <ConfirmProvider>");return e}function EN(e,t){switch(e){case"thinking":return"Thinking…";case"tool_use":return t?`${t}`:"Tool…";case"tool_result":return"Reading…";case"text":return"Writing…"}}function jN({status:e}){return ee.jsx("span",{className:uk("inline-block w-2 h-2 rounded-full",{"bg-green-500":"running"===e,"bg-zinc-400":"stopped"===e,"bg-yellow-400 animate-pulse":"restarting"===e})})}const CN=H.memo(function({project:e,active:t=!1,statusStack:n=[],onDelete:r,onArchive:o,onUnarchive:a,onUpdated:i}){var s,l;const u=cf(),c=SN(),[d,f]=W.useState(!1),[p,h]=W.useState(null),[m,g]=W.useState(!1),[v,y]=W.useState(e.name),b=W.useRef(null),x=!!e._sharedPermission;W.useEffect(()=>{let t=!1;return gE(e.id).then(({bytes:e})=>{t||h(e)}).catch(()=>{}),()=>{t=!0}},[e.id]);const w="view"===e._sharedPermission,k=t=>{t.stopPropagation(),y(e.name),g(!0),setTimeout(()=>{var e;return null==(e=b.current)?void 0:e.select()},0)},S=async()=>{const t=v.trim();if(t&&t!==e.name)try{const n=await hE(e.id,t);null==i||i(n),g(!1)}catch(RT){dN.error("Rename failed",{description:null==RT?void 0:RT.message})}else g(!1)},E=ee.jsx(hw.div,{whileHover:e.archived||t?{}:{y:-2},transition:{duration:.2},children:ee.jsxs(ck,{className:uk("group cursor-pointer transition-colors relative",e.archived?"opacity-60 hover:opacity-80 hover:border-zinc-400":t?"border-transparent hover:border-transparent bg-transparent shadow-none":"hover:border-zinc-400 hover:shadow-md"),onClick:()=>!e.archived&&u(`/projects/${e.id}`),children:[ee.jsxs(dk,{className:"pb-2",children:[ee.jsxs("div",{className:"flex items-start justify-between gap-2",children:[m?ee.jsx("input",{ref:b,className:"text-base leading-tight font-semibold bg-transparent border-b border-primary outline-none w-full min-w-0",value:v,onChange:e=>y(e.target.value),onBlur:()=>{S()},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),S()),"Escape"===e.key&&g(!1)},onClick:e=>e.stopPropagation()}):ee.jsx(fk,{className:uk("text-base leading-tight",e.archived&&"text-muted-foreground"),onDoubleClick:x||e.archived?void 0:k,children:e.name}),ee.jsx("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",children:!x&&ee.jsxs(ee.Fragment,{children:[e.archived?ee.jsx(Rk,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:t=>{t.stopPropagation(),a(e.id)},title:"Restore project",children:ee.jsx(IE,{className:"h-3.5 w-3.5"})}):ee.jsxs(ee.Fragment,{children:[ee.jsx(Rk,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:k,title:"Rename project",children:ee.jsx(lj,{className:"h-3.5 w-3.5"})}),ee.jsx(Rk,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:e=>{e.stopPropagation(),f(!0)},title:"共享设置",children:ee.jsx(xj,{className:"h-3.5 w-3.5"})}),ee.jsx(Rk,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:t=>{t.stopPropagation(),o(e.id)},title:"Archive project",children:ee.jsx(zE,{className:"h-3.5 w-3.5"})})]}),ee.jsx(Rk,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:async t=>{t.stopPropagation();await c({title:"删除项目",description:`确认删除项目 "${e.name}"?此操作不可撤销。`,destructive:!0,confirmLabel:"删除"})&&r(e.id)},title:"Delete project",children:ee.jsx(bj,{className:"h-3.5 w-3.5"})})]})})]}),ee.jsx("div",{className:"flex items-center gap-1.5",children:e.archived?ee.jsx(Ej,{variant:"secondary",className:"text-xs",children:"Archived"}):ee.jsxs(ee.Fragment,{children:[ee.jsx(jN,{status:e.status}),ee.jsx("span",{className:"text-xs text-muted-foreground capitalize",children:e.status}),t&&n.length>0&&ee.jsx("div",{className:"ml-auto",children:ee.jsx(Xb,{mode:"wait",children:n.slice(-1).map(e=>ee.jsx(hw.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{duration:.25,ease:"easeOut"},children:ee.jsx(Ej,{variant:"outline",className:"text-xs font-normal whitespace-nowrap",children:EN(e.phase,e.detail)})},e.id))})})]})})]}),ee.jsxs(hk,{className:"space-y-2",children:[ee.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[ee.jsx(HE,{className:"h-3.5 w-3.5 flex-shrink-0"}),ee.jsx("span",{className:"truncate font-mono",children:e.folderPath}),null!==p&&ee.jsx("span",{className:"flex-shrink-0 ml-auto text-muted-foreground/70",children:(j=p,j>=1073741824?(j/1073741824).toFixed(1)+" GB":j>=1048576?(j/1048576).toFixed(1)+" MB":Math.round(j/1024)+" KB")})]}),ee.jsxs("div",{className:"flex items-center gap-2",children:[ee.jsx(Ej,{variant:"outline",className:"text-xs font-mono",children:e.cliTool??"claude"}),ee.jsx(Ej,{variant:"unlimited"===e.permissionMode?"destructive":"secondary",className:"text-xs",children:"unlimited"===e.permissionMode?"Unlimited":"Limited"}),x&&ee.jsxs(Ej,{variant:"outline",className:"text-xs gap-0.5",children:[w?ee.jsx(UE,{className:"h-3 w-3"}):ee.jsx(lj,{className:"h-3 w-3"}),w?"可见":"可编辑"]}),!x&&e.shares&&e.shares.length>0&&ee.jsxs(Ej,{variant:"outline",className:"text-xs gap-0.5",children:[ee.jsx(xj,{className:"h-3 w-3"}),e.shares.length]}),ee.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(e.createdAt).toLocaleDateString()})]}),(e.tags??[]).length>0&&ee.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[(e.tags??[]).slice(0,3).map(e=>ee.jsxs("span",{className:"px-1.5 py-0 rounded-full text-[10px] bg-muted text-muted-foreground border border-border",children:["#",e]},e)),((null==(s=e.tags)?void 0:s.length)??0)>3&&ee.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["+",((null==(l=e.tags)?void 0:l.length)??0)-3]})]})]})]})});var j;const C=t&&!e.archived?ee.jsx("div",{className:"card-active-glow rounded-lg",children:E}):E;return ee.jsxs(ee.Fragment,{children:[C,!x&&i&&ee.jsx(JP,{project:e,open:d,onOpenChange:f,onUpdated:i})]})});function PN({onSelect:e}){const[t,n]=W.useState(""),[r,o]=W.useState(null),[a,i]=W.useState([]),[s,l]=W.useState(!0),[u,c]=W.useState(null),[d,f]=W.useState(!1),[p,h]=W.useState(""),[m,g]=W.useState(null),[v,y]=W.useState(!1),b=W.useRef(null),x=async e=>{l(!0),c(null);try{const t=await VS(e);n(t.path),o(t.parent),i(t.entries)}catch(RT){c(RT instanceof Error?RT.message:"Failed to load directory")}finally{l(!1)}};W.useEffect(()=>{x()},[]),W.useEffect(()=>{d&&setTimeout(()=>{var e;return null==(e=b.current)?void 0:e.focus()},0)},[d]);const w=()=>{f(!1),h(""),g(null)},k=async()=>{const e=p.trim();if(e){y(!0),g(null);try{const{path:n}=await US(t,e);f(!1),h(""),await x(t),x(n)}catch(RT){g(RT instanceof Error?RT.message:"Failed to create folder")}finally{y(!1)}}},S=t.split("/").filter(Boolean);return ee.jsxs("div",{className:"flex flex-col h-64 border rounded-md overflow-hidden",children:[ee.jsxs("div",{className:"flex items-center gap-1 px-2 py-2 bg-muted border-b flex-shrink-0",children:[ee.jsx(Rk,{variant:"ghost",size:"sm",className:"h-6 px-1 flex-shrink-0",onClick:()=>{x()},title:"Home",children:ee.jsx(ZE,{className:"h-3 w-3"})}),ee.jsx("div",{className:"flex items-center gap-1 flex-1 overflow-x-auto min-w-0",children:S.map((e,t)=>ee.jsxs(H.Fragment,{children:[ee.jsx(BE,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),ee.jsx("button",{className:"text-xs hover:text-foreground text-muted-foreground whitespace-nowrap",onClick:()=>(e=>{const t="/"+S.slice(0,e+1).join("/");x(t)})(t),children:e})]},t))}),ee.jsxs(Rk,{variant:"ghost",size:"sm",className:"h-6 px-1.5 flex-shrink-0 gap-1 text-xs",onClick:()=>{h(""),g(null),f(!0)},disabled:d||s||!!u,title:"New folder",children:[ee.jsx(GE,{className:"h-3.5 w-3.5"}),ee.jsx("span",{className:"hidden sm:inline",children:"New folder"})]})]}),ee.jsxs("div",{className:"flex-1 overflow-y-auto",children:[s&&ee.jsx("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:"Loading..."}),u&&ee.jsx("div",{className:"flex items-center justify-center h-full text-sm text-destructive px-4 text-center",children:u}),!s&&!u&&ee.jsxs("div",{className:"p-1",children:[r&&ee.jsxs("button",{className:"flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded hover:bg-accent hover:text-accent-foreground",onClick:()=>{x(r)},children:[ee.jsx(FE,{className:"h-4 w-4 text-muted-foreground"}),ee.jsx("span",{children:".."})]}),d&&ee.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5",children:[ee.jsx(qE,{className:"h-4 w-4 text-blue-500 flex-shrink-0"}),ee.jsx("input",{ref:b,className:uk("flex-1 text-sm bg-background border rounded px-1.5 py-0.5 outline-none","focus:ring-1 focus:ring-ring",m&&"border-destructive"),placeholder:"Folder name",value:p,onChange:e=>{h(e.target.value),g(null)},onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),k()):"Escape"===e.key&&w()},disabled:v}),ee.jsx("button",{className:"p-1 rounded hover:bg-accent disabled:opacity-50",onClick:()=>{k()},disabled:!p.trim()||v,title:"Create",children:ee.jsx(VE,{className:"h-3.5 w-3.5 text-green-600"})}),ee.jsx("button",{className:"p-1 rounded hover:bg-accent",onClick:w,disabled:v,title:"Cancel",children:ee.jsx(wj,{className:"h-3.5 w-3.5 text-muted-foreground"})})]}),m&&ee.jsx("p",{className:"px-3 pb-1 text-xs text-destructive",children:m}),0===a.length&&!d&&ee.jsx("div",{className:"text-sm text-muted-foreground px-2 py-4 text-center",children:"Empty directory"}),a.map(e=>ee.jsxs("button",{className:uk("flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded text-left","dir"===e.type?"hover:bg-accent hover:text-accent-foreground cursor-pointer":"opacity-40 cursor-not-allowed"),onClick:()=>{"dir"===e.type&&x(e.path)},disabled:"file"===e.type,children:["dir"===e.type?ee.jsx(qE,{className:"h-4 w-4 text-blue-500 flex-shrink-0"}):ee.jsx(WE,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),ee.jsx("span",{className:"truncate",children:e.name})]},e.path))]})]}),ee.jsxs("div",{className:"border-t px-3 py-2 flex items-center justify-between gap-2 flex-shrink-0 bg-background",children:[ee.jsx("span",{className:"text-xs text-muted-foreground truncate flex-1",children:t}),ee.jsx(Rk,{size:"sm",onClick:()=>e(t),disabled:!t,children:"Select this folder"})]})]})}const NN=[{value:"claude",label:"Claude",desc:"Anthropic Claude Code CLI"},{value:"opencode",label:"OpenCode",desc:"OpenCode CLI (sst/opencode)"},{value:"codex",label:"Codex",desc:"OpenAI Codex CLI"},{value:"qwen",label:"Qwen",desc:"Qwen Code CLI (QwenLM)"},{value:"gemini",label:"Gemini",desc:"Google Gemini CLI"},{value:"terminal",label:"Terminal",desc:"Plain shell (no AI CLI)"}],TN={claude:{limited:"claude",unlimited:"claude --dangerously-skip-permissions"},opencode:{limited:"opencode",unlimited:"opencode --dangerously-skip-permissions"},codex:{limited:"codex",unlimited:"codex --ask-for-approval never --sandbox danger-full-access"},qwen:{limited:"qwen-code",unlimited:"qwen-code --yolo"},gemini:{limited:"gemini",unlimited:"gemini --yolo"},terminal:{limited:"$SHELL (interactive)",unlimited:"$SHELL (interactive)"}};function MN({open:e,onOpenChange:t,onCreated:n}){const[r,o]=W.useState("name"),[a,i]=W.useState(""),[s,l]=W.useState(""),[u,c]=W.useState("claude"),[d,f]=W.useState("limited"),[p,h]=W.useState(!1),[m,g]=W.useState(null),v=e=>{e||(o("name"),i(""),l(""),c("claude"),f("limited"),g(null),h(!1)),t(e)},y=()=>{a.trim()?(g(null),o("folder")):g("Please enter a project name")},b=["name","folder","settings"];return ee.jsx(HP,{open:e,onOpenChange:v,children:ee.jsxs(qP,{className:"sm:max-w-lg",children:[ee.jsxs(KP,{children:[ee.jsx(QP,{children:{name:"New Project — Name",folder:"New Project — Select Folder",settings:"New Project — Settings"}[r]}),ee.jsxs(ZP,{children:["name"===r&&"Give your project a name.","folder"===r&&"Choose the working directory for this project.","settings"===r&&"Choose the AI coding tool and run mode."]})]}),ee.jsx("div",{className:"flex gap-2 mb-2",children:b.map((e,t)=>ee.jsx("div",{className:"h-1.5 flex-1 rounded-full "+(r===e?"bg-primary":b.indexOf(r)>t?"bg-primary/40":"bg-muted")},e))}),"name"===r&&ee.jsxs("div",{className:"space-y-4",children:[ee.jsxs("div",{className:"space-y-2",children:[ee.jsx(Ik,{htmlFor:"project-name",children:"Project Name"}),ee.jsx(Lk,{id:"project-name",placeholder:"My Project",value:a,onChange:e=>i(e.target.value),onKeyDown:e=>{"Enter"===e.key&&y()},autoFocus:!0})]}),m&&ee.jsx("p",{className:"text-sm text-destructive",children:m})]}),"folder"===r&&ee.jsxs("div",{className:"space-y-2",children:[ee.jsx(Ik,{children:"Working Directory"}),ee.jsx(PN,{onSelect:e=>{l(e),o("settings")}})]}),"settings"===r&&ee.jsxs("div",{className:"space-y-5",children:[ee.jsxs("div",{className:"space-y-2",children:[ee.jsx(Ik,{children:"AI Coding Tool"}),ee.jsx("div",{className:"grid grid-cols-2 gap-2",children:NN.map(e=>ee.jsxs("label",{className:"flex items-center gap-2.5 cursor-pointer p-3 rounded-md border transition-colors "+(u===e.value?"border-primary bg-primary/5":"hover:bg-accent"),children:[ee.jsx("input",{type:"radio",name:"cliTool",value:e.value,checked:u===e.value,onChange:()=>c(e.value),className:"accent-primary"}),ee.jsxs("div",{children:[ee.jsx("div",{className:"font-medium text-sm",children:e.label}),ee.jsx("div",{className:"text-xs text-muted-foreground",children:e.desc})]})]},e.value))})]}),"terminal"!==u&&ee.jsxs("div",{className:"space-y-2",children:[ee.jsx(Ik,{children:"Permission Mode"}),ee.jsxs("div",{className:"space-y-2",children:[ee.jsxs("label",{className:"flex items-start gap-3 cursor-pointer p-3 rounded-md border hover:bg-accent transition-colors",children:[ee.jsx("input",{type:"radio",name:"permissionMode",value:"limited",checked:"limited"===d,onChange:()=>f("limited"),className:"mt-0.5"}),ee.jsxs("div",{children:[ee.jsx("div",{className:"font-medium text-sm",children:"Limited"}),ee.jsxs("div",{className:"text-xs text-muted-foreground",children:["Runs ",ee.jsx("code",{className:"bg-muted px-1 rounded",children:TN[u].limited})," — asks for permission before file changes."]})]})]}),ee.jsxs("label",{className:"flex items-start gap-3 cursor-pointer p-3 rounded-md border hover:bg-accent transition-colors",children:[ee.jsx("input",{type:"radio",name:"permissionMode",value:"unlimited",checked:"unlimited"===d,onChange:()=>f("unlimited"),className:"mt-0.5"}),ee.jsxs("div",{children:[ee.jsx("div",{className:"font-medium text-sm",children:"Unlimited"}),ee.jsxs("div",{className:"text-xs text-muted-foreground",children:["Runs ",ee.jsx("code",{className:"bg-muted px-1 rounded",children:TN[u].unlimited})," — acts autonomously."]})]})]})]})]}),ee.jsxs("div",{className:"text-xs text-muted-foreground",children:[ee.jsx("span",{className:"font-medium",children:"Folder:"})," ",ee.jsx("span",{className:"font-mono",children:s})]}),m&&ee.jsx("p",{className:"text-sm text-destructive",children:m})]}),ee.jsxs(XP,{children:["name"!==r&&ee.jsx(Rk,{variant:"outline",onClick:()=>o("settings"===r?"folder":"name"),disabled:p,children:"Back"}),"name"===r&&ee.jsx(Rk,{onClick:y,children:"Next"}),"folder"===r&&ee.jsx(Rk,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),"settings"===r&&ee.jsx(Rk,{onClick:()=>{(async()=>{h(!0),g(null);try{const e=await lS({name:a.trim(),folderPath:s,permissionMode:d,cliTool:u});n(e),v(!1)}catch(RT){g(RT instanceof Error?RT.message:"Failed to create project")}finally{h(!1)}})()},disabled:p,children:p?"Creating...":"Create Project"})]})]})})}function RN({open:e,onOpenChange:t,onOpened:n}){const[r,o]=W.useState(""),[a,i]=W.useState(!1),[s,l]=W.useState(null),u=e=>{e||(o(""),l(null),i(!1)),t(e)};return ee.jsx(HP,{open:e,onOpenChange:u,children:ee.jsxs(qP,{className:"sm:max-w-lg",children:[ee.jsxs(KP,{children:[ee.jsx(QP,{children:"Open Existing Project"}),ee.jsxs(ZP,{children:["Select a folder that contains a ",ee.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:".ccweb/"})," configuration. The project's history and settings will be restored."]})]}),ee.jsxs("div",{className:"space-y-2",children:[ee.jsx(Ik,{children:"Project Folder"}),ee.jsx(PN,{onSelect:e=>{(async e=>{o(e),i(!0),l(null);try{const t=await uS(e);n(t),u(!1)}catch(RT){l(RT instanceof Error?RT.message:"Failed to open project"),i(!1)}})(e)}})]}),s&&ee.jsx("p",{className:"text-sm text-destructive",children:s}),r&&!s&&a&&ee.jsxs("p",{className:"text-sm text-muted-foreground",children:["Opening project from ",r,"..."]}),ee.jsx(XP,{children:ee.jsx(Rk,{variant:"outline",onClick:()=>u(!1),disabled:a,children:"Cancel"})})]})})}const LN=`${"https:"===window.location.protocol?"wss:":"ws:"}//${window.location.host}`,DN=3e3;function _N(e,t){const n=W.useRef(null),r=W.useRef(0),o=W.useRef(!0),a=W.useRef(!1),i=W.useRef(null),s=W.useRef(t);s.current=t;const[l,u]=W.useState(!1),[c,d]=W.useState(0),f=W.useRef(!1),p=W.useRef([]),h=W.useCallback(e=>{var t;(null==(t=n.current)?void 0:t.readyState)===WebSocket.OPEN&&n.current.send(JSON.stringify(e))},[]),m=W.useCallback(()=>{var e;if((null==(e=n.current)?void 0:e.readyState)===WebSocket.OPEN)for(;p.current.length>0;){const e=p.current.shift();n.current.send(JSON.stringify({type:"terminal_input",data:e}))}},[]),g=W.useCallback((e,t)=>{var r;(null==(r=n.current)?void 0:r.readyState)===WebSocket.OPEN?(n.current.send(JSON.stringify({type:"terminal_subscribe",cols:e,rows:t})),f.current=!1):f.current=!0},[]),v=W.useCallback(e=>{var t;(null==(t=n.current)?void 0:t.readyState)===WebSocket.OPEN?n.current.send(JSON.stringify({type:"terminal_input",data:e})):p.current.push(e)},[]),y=W.useCallback((e,t)=>{h({type:"terminal_resize",cols:e,rows:t})},[h]),b=W.useCallback(()=>{h({type:"chat_subscribe",replay:50})},[h]),x=W.useCallback(()=>{if(!o.current)return;if(a.current)return;const t=Zk();if(!t)return void(window.location.href="/login");a.current=!0;const l=new WebSocket(`${LN}/ws/projects/${e}`);n.current=l,l.onopen=()=>{a.current=!1,r.current=0,l.send(JSON.stringify({type:"auth",token:t}))},l.onmessage=e=>{var t,n,r,o,a,i,l,c,p,h,g,v,y,b,x,w,k,S;let E;try{E=JSON.parse(e.data)}catch{return}switch(E.type){case"connected":f.current=!1,u(!0),d(e=>e+1),m(),null==(n=(t=s.current).onConnected)||n.call(t);break;case"terminal_data":null==(o=(r=s.current).onTerminalData)||o.call(r,E.data);break;case"status":null==(i=(a=s.current).onStatus)||i.call(a,E.status);break;case"chat_message":{const e=E;null==(c=(l=s.current).onChatMessage)||c.call(l,e);break}case"project_stopped":{const e=E;null==(h=(p=s.current).onProjectStopped)||h.call(p,e.projectId,e.projectName);break}case"context_update":null==(v=(g=s.current).onContextUpdate)||v.call(g,E);break;case"semantic_update":null==(b=(y=s.current).onSemanticUpdate)||b.call(y,E);break;case"approval_request":null==(w=(x=s.current).onApprovalRequest)||w.call(x,E);break;case"approval_resolved":null==(S=(k=s.current).onApprovalResolved)||S.call(k,E);break;case"error":console.error("[WS] Server error:",E.message)}},l.onclose=()=>{var e,t;a.current=!1,n.current===l&&(n.current=null),u(!1),null==(t=(e=s.current).onDisconnected)||t.call(e),o.current&&r.current<5&&(r.current++,i.current=window.setTimeout(x,DN))},l.onerror=e=>{a.current=!1,console.error("[WS] WebSocket error:",e)}},[e]);return W.useEffect(()=>(o.current=!0,x(),()=>{var e;o.current=!1,i.current&&(clearTimeout(i.current),i.current=null),null==(e=n.current)||e.close(),n.current=null,p.current=[]}),[x]),{subscribeTerminal:g,sendTerminalInput:v,sendTerminalResize:y,subscribeChatMessages:b,connected:l,readyTick:c}}function AN(e){const t=W.useRef(null),n=W.useRef(0),r=W.useRef(!0),o=W.useRef(!1),a=W.useRef(null),i=W.useRef(e);i.current=e;const s=W.useCallback(()=>{if(!r.current)return;if(o.current)return;const e=Zk();if(!e)return;o.current=!0;const l=new WebSocket(`${LN}/ws/dashboard`);t.current=l,l.onopen=()=>{o.current=!1,n.current=0,l.send(JSON.stringify({type:"auth",token:e}))},l.onmessage=e=>{var t,n;try{const r=JSON.parse(e.data);"activity_update"===r.type?i.current.onActivityUpdate(r):"project_stopped"===r.type&&(null==(n=(t=i.current).onProjectStopped)||n.call(t,r.projectId,r.projectName))}catch{}},l.onclose=()=>{o.current=!1,t.current===l&&(t.current=null),r.current&&n.current<5&&(n.current++,a.current=window.setTimeout(s,DN))},l.onerror=e=>{o.current=!1,console.error("[DashboardWS] Error:",e)}},[]);W.useEffect(()=>(r.current=!0,s(),()=>{var e;r.current=!1,a.current&&(clearTimeout(a.current),a.current=null),null==(e=t.current)||e.close(),t.current=null}),[s])}function ON({projectId:e,enabled:t,onChatMessage:n,onStatusChange:r,onContextUpdate:o,onApprovalRequest:a,onApprovalResolved:i}){const s=W.useRef(null),l=W.useRef(!0),u=W.useRef(0),c=W.useRef(null),d=W.useRef(!1),f=W.useRef(!1),p=W.useRef([]),h=W.useRef({onChatMessage:n,onStatusChange:r,onContextUpdate:o,onApprovalRequest:a,onApprovalResolved:i});h.current={onChatMessage:n,onStatusChange:r,onContextUpdate:o,onApprovalRequest:a,onApprovalResolved:i};const[m,g]=W.useState(!1),[v,y]=W.useState(0),b=W.useCallback(()=>{if(f.current&&s.current&&s.current.readyState===WebSocket.OPEN)for(;p.current.length>0;){const e=p.current.shift();s.current.send(JSON.stringify({type:"terminal_input",data:e}))}},[]),x=W.useCallback(e=>{var t;f.current&&(null==(t=s.current)?void 0:t.readyState)===WebSocket.OPEN?s.current.send(JSON.stringify({type:"terminal_input",data:e})):p.current.push(e)},[]),w=W.useCallback(()=>{if(!l.current||!t)return;if(d.current)return;const n=Zk();if(!n)return;d.current=!0,f.current=!1;const r=new WebSocket(`${LN}/ws/projects/${e}`);s.current=r,r.onopen=()=>{d.current=!1,u.current=0,r.send(JSON.stringify({type:"auth",token:n}))},r.onmessage=e=>{var t,n,o,a,i,s,l,u,c,d;try{const p=JSON.parse(e.data);"connected"===p.type?(r.send(JSON.stringify({type:"chat_subscribe",replay:50})),f.current=!0,g(!0),y(e=>e+1),b()):"chat_message"===p.type?h.current.onChatMessage(p):"status"===p.type&&p.status?null==(n=(t=h.current).onStatusChange)||n.call(t,p.status):"project_stopped"===p.type?null==(a=(o=h.current).onStatusChange)||a.call(o,"stopped"):"context_update"===p.type?null==(s=(i=h.current).onContextUpdate)||s.call(i,p):"approval_request"===p.type?null==(u=(l=h.current).onApprovalRequest)||u.call(l,p):"approval_resolved"===p.type&&(null==(d=(c=h.current).onApprovalResolved)||d.call(c,p))}catch{}},r.onclose=()=>{if(d.current=!1,f.current=!1,g(!1),s.current===r&&(s.current=null),l.current&&t)if(u.current<5){u.current++;const e=2e3*Math.random();c.current=window.setTimeout(w,DN+e)}else p.current.length>0&&(console.warn("[MonitorWS] Retries exhausted, dropping",p.current.length,"queued messages"),p.current=[])},r.onerror=()=>{d.current=!1}},[e,t,b]);return W.useEffect(()=>(l.current=!0,()=>{l.current=!1,p.current=[]}),[]),W.useEffect(()=>(u.current=0,w(),()=>{var e;f.current=!1,c.current&&(clearTimeout(c.current),c.current=null),null==(e=s.current)||e.close(),s.current=null}),[w,t]),{sendInput:x,connected:m,readyTick:v}}const IN="cc_project_order_cache";function zN(){try{const e=localStorage.getItem(IN);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)&&t.every(e=>"string"==typeof e)?t:[]}catch{return[]}}function FN(e){try{localStorage.setItem(IN,JSON.stringify(e))}catch{}}function VN(){const[e,t]=W.useState(zN),n=W.useRef(!1),r=W.useRef(null),o=W.useRef(null),a=W.useRef(!1),i=W.useRef(!0);W.useEffect(()=>{i.current=!0;let e=!1;return oS().then(r=>{e||n.current||(t(e=>function(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}(e,r)?e:r),FN(r))}).catch(()=>{}),()=>{e=!0,i.current=!1,o.current&&(clearTimeout(o.current),o.current=null)}},[]);const s=W.useCallback(async()=>{for(;r.current;){const e=r.current;r.current=null,a.current=!0;try{await aS(e)}catch{}a.current=!1}},[]),l=W.useCallback(e=>{n.current=!0,t(e),FN(e),r.current=e,o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{o.current=null,i.current&&(a.current||s())},400)},[s]),u=W.useCallback(t=>{const n=new Map(e.map((e,t)=>[e,t]));return[...t].sort((e,t)=>{const r=n.get(e.id)??1/0,o=n.get(t.id)??1/0;return r===o?0:r-o})},[e]);return W.useMemo(()=>({order:e,setOrder:l,applyOrder:u}),[e,l,u])}const BN=18e6,$N=6048e5;function UN(e,t=18e6){if(!e||void 0===e.utilization||e.utilization<=0||!e.resetAt)return null;const n=new Date(e.resetAt).getTime()-Date.now();if(n<=0)return null;const r=t-n;return r<=0?null:Math.round(e.utilization/(r/t))}function WN({label:e,bucket:t}){if(!t||void 0===t.utilization)return null;const n=t.utilization,r=n<50?"text-green-400":n<80?"text-yellow-400":"text-red-400",o=function(e){if(!e)return"";const t=new Date(e).getTime()-Date.now();if(t<=0)return"即将重置";const n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`${n}h${r}m`:`${r}m`}(t.resetAt);return ee.jsxs("span",{className:"text-muted-foreground whitespace-nowrap",children:[e," ",ee.jsxs("span",{className:uk("font-medium",r),children:[n,"%"]}),o&&ee.jsxs("span",{className:"text-muted-foreground/70 ml-0.5",children:["(",o,")"]})]})}function HN({className:e}){const[t,n]=W.useState("loading"),[r,o]=W.useState(!1),a=()=>Uk($k.usageMonitorTool,"claude");W.useEffect(()=>{const e=async()=>{try{n(await zS(a()))}catch{n(null)}};e();const t=setInterval(()=>{e()},3e5),r=()=>{e()},o=t=>{t.key===$k.usageMonitorTool&&e()};return window.addEventListener("ccweb:usage-tool-change",r),window.addEventListener("storage",o),()=>{clearInterval(t),window.removeEventListener("ccweb:usage-tool-change",r),window.removeEventListener("storage",o)}},[]);if("loading"===t)return null;if(!t)return null;const i=!!t.fiveHour,s=!!t.sevenDay,l=!!t.sevenDaySonnet,u=!!t.sevenDayOpus,c=i||s||l||u,d=UN(t.fiveHour,BN),f=UN(t.sevenDay,$N),p=UN(t.sevenDaySonnet,$N),h=null!==d||null!==f||null!==p;return ee.jsxs("div",{className:uk("flex items-center gap-1.5 text-xs",e),children:[h&&ee.jsxs("span",{className:"flex items-center gap-1",children:[null!==d&&ee.jsxs("span",{className:uk("font-medium",d<=100?"text-green-400":"text-orange-400"),title:`5h 配速:按当前速率,窗口结束时预计使用 ${d}%`,children:[d,"%"]}),null!==f&&ee.jsxs(ee.Fragment,{children:[ee.jsx("span",{className:"text-muted-foreground/40",children:"/"}),ee.jsxs("span",{className:uk("font-medium",f<=100?"text-green-400":"text-orange-400"),title:`7d 配速:按当前速率,窗口结束时预计使用 ${f}%`,children:[f,"%"]})]}),null!==p&&ee.jsxs(ee.Fragment,{children:[ee.jsx("span",{className:"text-muted-foreground/40",children:"/"}),ee.jsxs("span",{className:uk("font-medium",p<=100?"text-green-400":"text-orange-400"),title:`7d Sonnet 配速:按当前速率,窗口结束时预计使用 ${p}%`,children:[p,"%"]})]})]}),t.planName&&ee.jsx("span",{className:"font-medium text-foreground bg-muted border border-border px-2 py-0.5 rounded-full",children:t.planName}),c&&ee.jsxs(ee.Fragment,{children:[ee.jsx("span",{className:"text-muted-foreground/50",children:"|"}),ee.jsx(WN,{label:"5h",bucket:t.fiveHour}),s&&ee.jsxs(ee.Fragment,{children:[ee.jsx("span",{className:"text-muted-foreground/50",children:"·"}),ee.jsx(WN,{label:"7d",bucket:t.sevenDay})]}),l&&ee.jsxs(ee.Fragment,{children:[ee.jsx("span",{className:"text-muted-foreground/50",children:"·"}),ee.jsx(WN,{label:"7d Sonnet",bucket:t.sevenDaySonnet})]}),u&&ee.jsxs(ee.Fragment,{children:[ee.jsx("span",{className:"text-muted-foreground/50",children:"·"}),ee.jsx(WN,{label:"7d Opus",bucket:t.sevenDayOpus})]})]}),ee.jsx("button",{onClick:()=>{(async()=>{o(!0);try{n(await FS(a()))}catch{n(null)}finally{o(!1)}})()},className:"text-muted-foreground hover:text-foreground transition-colors",title:"刷新用量信息",children:ee.jsx(cj,{className:uk("h-3 w-3",r&&"animate-spin")})})]})}function GN({open:e,onOpenChange:t,kind:n,label:r,content:o}){const a=cf(),[i,s]=W.useState(()=>Uk($k.skillhubAuthor,"")),[l,u]=W.useState(""),[c,d]=W.useState(""),[f,p]=W.useState(!1),[h,m]=W.useState(null),[g,v]=W.useState(!0);W.useEffect(()=>{e&&(s(Uk($k.skillhubAuthor,"")),u(""),d(""),v(!0),_S().then(m).catch(()=>m({configured:!1,needsReset:!1})).finally(()=>v(!1)))},[e]);const y=()=>{t(!1),a("/settings?tab=hub")},b="quick-prompt"===n?"快捷 Prompt":"Agent Prompt",x=!g&&h&&!h.configured;return ee.jsx(HP,{open:e,onOpenChange:t,children:ee.jsxs(qP,{className:uk("sm:max-w-lg"),children:[ee.jsxs(KP,{children:[ee.jsx(QP,{children:"共享到 ccweb-hub"}),ee.jsxs(ZP,{children:["「",r,"」将以 GitHub Issue 形式提交到 ",ee.jsx("code",{children:"zbc0315/ccweb-hub"}),", 使用你配置的 GitHub token。审核通过后会合入为社区 prompt。"]})]}),g?ee.jsxs("div",{className:"py-8 flex items-center justify-center text-sm text-muted-foreground",children:[ee.jsx(tj,{className:"h-4 w-4 mr-2 animate-spin"}),"检查 token 配置…"]}):x?ee.jsxs("div",{className:"space-y-3 py-2",children:[ee.jsx("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2.5 text-xs",children:ee.jsxs("div",{className:"flex items-start gap-2",children:[ee.jsx(JE,{className:"h-4 w-4 shrink-0 text-amber-500 mt-0.5"}),ee.jsxs("div",{className:"space-y-1",children:[ee.jsx("div",{className:"font-medium text-foreground",children:(null==h?void 0:h.needsReset)?"之前配置的 token 已失效(服务端密钥可能已轮换),请重新设置":"还没配置 GitHub token"}),ee.jsxs("div",{className:"text-muted-foreground",children:["为保护你的 GitHub 账号,ccweb 不自带 token,需要你用自己的 GitHub fine-grained PAT(只勾 ",ee.jsx("code",{children:"ccweb-hub"})," 仓库的",ee.jsx("code",{children:" Issues: Read and write"}),")。"]})]})]})}),ee.jsxs("div",{className:"flex gap-2 pt-1",children:[ee.jsx(Rk,{variant:"outline",onClick:()=>t(!1),className:"flex-1",children:"稍后"}),ee.jsx(Rk,{onClick:y,className:"flex-1",children:"去设置页配置"})]})]}):ee.jsxs(ee.Fragment,{children:[ee.jsxs("div",{className:"space-y-3 py-2",children:[ee.jsxs("div",{className:"space-y-1.5",children:[ee.jsx(Ik,{htmlFor:"share-author",className:"text-xs",children:"GitHub 用户名(可选,用于作者标注)"}),ee.jsx(Lk,{id:"share-author",placeholder:"zbc0315",value:i,onChange:e=>s(e.target.value)})]}),ee.jsxs("div",{className:"space-y-1.5",children:[ee.jsx(Ik,{htmlFor:"share-desc",className:"text-xs",children:"一句话描述(可选)"}),ee.jsx(Lk,{id:"share-desc",placeholder:"quick-prompt"===n?"这个命令用来...":"这段 prompt 让 Claude...",value:l,onChange:e=>u(e.target.value)})]}),ee.jsxs("div",{className:"space-y-1.5",children:[ee.jsx(Ik,{htmlFor:"share-tags",className:"text-xs",children:"标签(逗号分隔,可选)"}),ee.jsx(Lk,{id:"share-tags",placeholder:"review, 中文, 代码",value:c,onChange:e=>d(e.target.value)})]})]}),ee.jsxs("div",{className:"rounded-md border bg-muted/30 px-3 py-2 text-xs text-muted-foreground",children:[ee.jsxs("div",{className:"font-medium text-foreground mb-1",children:["预览:",b," · ",r]}),ee.jsxs("pre",{className:"whitespace-pre-wrap font-mono text-[11px] leading-snug max-h-32 overflow-y-auto",children:[Array.from(o).slice(0,500).join(""),Array.from(o).length>500&&"…"]})]}),ee.jsxs(XP,{children:[ee.jsxs(Rk,{variant:"ghost",size:"sm",onClick:y,className:"mr-auto",title:"更换或清除 token",children:[ee.jsx(JE,{className:"h-3.5 w-3.5 mr-1"}),"管理 token"]}),ee.jsx(Rk,{variant:"outline",onClick:()=>t(!1),disabled:f,children:"取消"}),ee.jsx(Rk,{onClick:()=>{(async()=>{if(!f){p(!0),Wk($k.skillhubAuthor,i);try{const e=await IS({kind:n,label:r,body:o,description:l.trim()||void 0,author:i.trim()||void 0,tags:c.split(",").map(e=>e.trim()).filter(Boolean)});dN.success(`已提交:Issue #${e.issueNumber}`,{action:{label:"查看",onClick:()=>window.open(e.issueUrl,"_blank","noopener,noreferrer")}}),t(!1)}catch(RT){const t=RT.message;dN.error(t),/invalid|expired|401/.test(t)&&m({configured:!1,needsReset:!0})}finally{p(!1)}}})()},disabled:f,children:f?ee.jsxs(ee.Fragment,{children:[ee.jsx(tj,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"提交中"]}):ee.jsxs(ee.Fragment,{children:[ee.jsx(dj,{className:"h-3.5 w-3.5 mr-1.5"}),"直接提交"]})})]})]})]})})}function YN(){const[e,t]=W.useState([]),[n,r]=W.useState(!1),[o,a]=W.useState(""),[i,s]=W.useState(""),[l,u]=W.useState(""),[c,d]=W.useState(null),[f,p]=W.useState(""),[h,m]=W.useState(""),[g,v]=W.useState(""),y=W.useRef(null),b=W.useRef(null),[x,w]=W.useState(null);W.useEffect(()=>{hS().then(t).catch(()=>t([]))},[]),W.useEffect(()=>{n&&setTimeout(()=>{var e;return null==(e=y.current)?void 0:e.focus()},0)},[n]),W.useEffect(()=>{c&&setTimeout(()=>{var e;return null==(e=b.current)?void 0:e.focus()},0)},[c]);const k=async()=>{const e=i.trim();if(e)try{const n=await mS({label:o.trim()||e,command:e,...l?{parentId:l}:{}});t(e=>[...e,n]),a(""),s(""),u(""),r(!1)}catch(RT){console.error("[GlobalShortcuts] Failed to add:",RT)}},S=async()=>{const e=h.trim();if(e&&c)try{const n=await gS(c,{label:f.trim()||e,command:e,parentId:g||null});t(e=>e.map(e=>e.id===c?n:e)),d(null)}catch(RT){console.error("[GlobalShortcuts] Failed to save:",RT)}};return ee.jsxs("section",{className:"mt-10",children:[ee.jsxs("div",{className:"flex items-center justify-between mb-4",children:[ee.jsxs("div",{className:"flex items-center gap-2",children:[ee.jsx(kj,{className:"h-4 w-4 text-muted-foreground"}),ee.jsx("h2",{className:"text-lg font-semibold",children:"全局快捷 Prompts"}),ee.jsx("span",{className:"text-xs text-muted-foreground",children:"在所有项目的终端中可用"})]}),ee.jsxs("button",{onClick:()=>{r(e=>!e),d(null)},className:uk("flex items-center gap-1.5 text-sm px-3 py-1.5 rounded-md border transition-colors",n?"border-border text-foreground bg-muted":"border-border text-muted-foreground hover:text-foreground hover:bg-muted"),children:[ee.jsx(uj,{className:"h-3.5 w-3.5"}),"新建"]})]}),n&&ee.jsxs("div",{className:"mb-4 p-4 rounded-lg border border-border bg-background space-y-3",children:[ee.jsx("input",{ref:y,placeholder:"名称(可选)",value:o,onChange:e=>a(e.target.value),className:"w-full text-sm bg-muted border border-border rounded px-3 py-1.5 text-foreground placeholder:text-muted-foreground outline-none focus:border-border transition-colors"}),ee.jsx("textarea",{placeholder:"命令内容…",value:i,onChange:e=>s(e.target.value),rows:3,className:"w-full text-sm bg-muted border border-border rounded px-3 py-1.5 text-foreground placeholder:text-muted-foreground font-mono outline-none focus:border-border transition-colors resize-none",onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),k()),"Escape"===e.key&&(r(!1),a(""),s(""),u(""))}}),ee.jsxs("div",{className:"flex items-center gap-2",children:[ee.jsx(KE,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),ee.jsxs("select",{value:l,onChange:e=>u(e.target.value),className:"flex-1 text-sm bg-muted border border-border rounded px-3 py-1.5 text-foreground outline-none focus:border-border transition-colors",children:[ee.jsx("option",{value:"",children:"无继承"}),e.map(e=>ee.jsx("option",{value:e.id,children:e.label},e.id))]})]}),ee.jsxs("div",{className:"flex items-center justify-between",children:[ee.jsx("span",{className:"text-xs text-muted-foreground",children:"⌘↩ 保存 · Esc 取消"}),ee.jsxs("div",{className:"flex gap-2",children:[ee.jsx("button",{onClick:()=>{r(!1),a(""),s("")},className:"text-sm px-3 py-1 rounded bg-secondary hover:bg-accent text-foreground transition-colors",children:"取消"}),ee.jsx("button",{onClick:()=>{k()},disabled:!i.trim(),className:uk("text-sm px-3 py-1 rounded transition-colors text-white",i.trim()?"bg-blue-600 hover:bg-blue-500":"bg-secondary opacity-40 cursor-not-allowed"),children:"保存"})]})]})]}),0!==e.length||n?ee.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:e.map(n=>c===n.id?ee.jsxs("div",{className:"rounded-lg border border-border bg-background p-3 space-y-2",children:[ee.jsx("input",{ref:b,value:f,onChange:e=>p(e.target.value),placeholder:"名称(可选)",className:"w-full text-sm bg-muted border border-border rounded px-2.5 py-1 text-foreground placeholder:text-muted-foreground outline-none focus:border-border transition-colors"}),ee.jsx("textarea",{value:h,onChange:e=>m(e.target.value),rows:3,className:"w-full text-sm bg-muted border border-border rounded px-2.5 py-1 text-foreground font-mono outline-none focus:border-border transition-colors resize-none",onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),S()),"Escape"===e.key&&d(null)}}),ee.jsxs("div",{className:"flex items-center gap-2",children:[ee.jsx(KE,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),ee.jsxs("select",{value:g,onChange:e=>v(e.target.value),className:"flex-1 text-sm bg-muted border border-border rounded px-2.5 py-1 text-foreground outline-none focus:border-border transition-colors",children:[ee.jsx("option",{value:"",children:"无继承"}),e.filter(e=>e.id!==n.id).map(e=>ee.jsx("option",{value:e.id,children:e.label},e.id))]})]}),ee.jsxs("div",{className:"flex gap-2 justify-end",children:[ee.jsx("button",{onClick:()=>d(null),className:"text-xs px-2.5 py-1 rounded bg-secondary hover:bg-accent text-foreground transition-colors",children:"取消"}),ee.jsx("button",{onClick:()=>{S()},disabled:!h.trim(),className:uk("text-xs px-2.5 py-1 rounded transition-colors text-white",h.trim()?"bg-blue-600 hover:bg-blue-500":"bg-secondary opacity-40 cursor-not-allowed"),children:"保存"})]})]},n.id):ee.jsxs("div",{className:"group relative rounded-lg border border-border bg-background hover:border-muted-foreground/30 transition-colors p-3",children:[ee.jsx("div",{className:"text-sm font-medium text-foreground truncate pr-14",children:n.label}),n.parentId&&(()=>{const t=e.find(e=>e.id===n.parentId);return t?ee.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[ee.jsx(KE,{className:"h-3 w-3 text-muted-foreground"}),ee.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["继承: ",t.label]})]}):null})(),!n.parentId&&n.label!==n.command&&ee.jsx("div",{className:"text-xs text-muted-foreground font-mono truncate mt-1 pr-14",children:n.command}),ee.jsxs("div",{className:"absolute top-2.5 right-2.5 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[ee.jsx("button",{onClick:()=>w({label:n.label,content:n.command}),className:"p-1 rounded text-muted-foreground hover:text-green-400 transition-colors",title:"共享到 ccweb-hub",children:ee.jsx(pj,{className:"h-3.5 w-3.5"})}),ee.jsx("button",{onClick:()=>{d(n.id),p(n.label),m(n.command),v(n.parentId||""),r(!1)},className:"p-1 rounded text-muted-foreground hover:text-blue-400 transition-colors",title:"编辑",children:ee.jsx(lj,{className:"h-3.5 w-3.5"})}),ee.jsx("button",{onClick:()=>{(async e=>{try{await vS(e),t(t=>t.filter(t=>t.id!==e)),c===e&&d(null)}catch(RT){console.error("[GlobalShortcuts] Failed to delete:",RT)}})(n.id)},className:"p-1 rounded text-muted-foreground hover:text-red-400 transition-colors",title:"删除",children:ee.jsx(wj,{className:"h-3.5 w-3.5"})})]})]},n.id))}):ee.jsxs("div",{className:"flex flex-col items-center gap-2 py-10 text-muted-foreground/50 border border-dashed border-border rounded-lg",children:[ee.jsx(kj,{className:"h-6 w-6"}),ee.jsx("p",{className:"text-sm",children:"还没有全局快捷 Prompts"})]}),ee.jsx(GN,{open:!!x,onOpenChange:e=>{e||w(null)},kind:"quick-prompt",label:(null==x?void 0:x.label)??"",content:(null==x?void 0:x.content)??""})]})}const qN=W.createContext({theme:"system",resolved:"dark",setTheme:()=>{}});function KN(){return W.useSyncExternalStore(e=>{const t=window.matchMedia("(prefers-color-scheme: dark)");return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},()=>window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")}function XN({children:e}){const[t,n]=W.useState(()=>Uk($k.theme,"system")),r=KN(),o="system"===t?r:t;W.useEffect(()=>{const e=document.documentElement;e.classList.remove("light","dark"),e.classList.add(o)},[o]);return ee.jsx(qN.Provider,{value:{theme:t,resolved:o,setTheme:e=>{n(e),Wk($k.theme,e)}},children:e})}function QN(){return W.useContext(qN)}function ZN(){const{theme:e,setTheme:t}=QN(),n=[{value:"light",icon:gj,label:"浅色"},{value:"dark",icon:sj,label:"深色"},{value:"system",icon:ij,label:"系统"}];return ee.jsx("div",{className:"flex items-center rounded-md border border-border bg-muted/50 p-0.5",children:n.map(({value:n,icon:r,label:o})=>ee.jsx("button",{onClick:()=>t(n),className:uk("p-1 rounded-sm transition-colors",e===n?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:o,children:ee.jsx(r,{className:"h-3.5 w-3.5"})},n))})}const JN={workMinutes:30,breakMinutes:5};function eT(){return Uk($k.pomodoroConfig,JN,!0)}const tT=Bk(e=>({running:!1,phase:"work",secondsLeft:60*eT().workMinutes,setRunning:t=>e({running:t}),setPhase:t=>e({phase:t}),setSecondsLeft:t=>e({secondsLeft:t})}));function nT(){const{running:e,phase:t,secondsLeft:n,setPhase:r,setSecondsLeft:o}=tT(),a=W.useCallback(e=>{const t=eT();var n;r(e),o("work"===e?60*t.workMinutes:60*t.breakMinutes),n="break"===e?"休息一下 ☕":"该工作了 💻",dN.info(`番茄钟: ${n}`)},[r,o]);return W.useEffect(()=>{if(!e)return;if(0===n)return void a("work"===t?"break":"work");const r=setTimeout(()=>o(n-1),1e3);return()=>clearTimeout(r)},[e,n,t,a,o]),null}function rT(){const{running:e,phase:t,secondsLeft:n}=tT(),r=Math.floor(n/60),o=n%60,a=`${String(r).padStart(2,"0")}:${String(o).padStart(2,"0")}`;return e?ld.createPortal(ee.jsxs("div",{className:"fixed inset-0 flex flex-col items-center justify-center pointer-events-none z-40 select-none",style:{opacity:"work"===t?.1:.6},children:[ee.jsx("div",{className:uk("font-mono font-bold tabular-nums leading-none","work"===t?"text-foreground":"text-blue-400 dark:text-blue-300"),style:{fontSize:"clamp(360px, 90vw, 1100px)"},children:a}),ee.jsx("div",{className:"mt-3 text-muted-foreground font-medium tracking-widest uppercase",style:{fontSize:"clamp(12px, 1.5vw, 20px)"},children:"work"===t?"专注工作":"休息一下"})]}),document.body):null}function oT(){const{running:e,phase:t,secondsLeft:n,setRunning:r,setPhase:o,setSecondsLeft:a}=tT(),i=Math.floor(n/60),s=n%60,l=`${String(i).padStart(2,"0")}:${String(s).padStart(2,"0")}`;return ee.jsx("button",{onClick:()=>{if(e){const e=eT();o("work"),a(60*e.workMinutes)}else{const e=eT();o("work"),a(60*e.workMinutes)}r(!e)},className:uk("p-1 rounded transition-colors",e?"work"===t?"text-red-500 bg-red-500/10 hover:bg-red-500/20":"text-green-500 bg-green-500/10 hover:bg-green-500/20":"text-muted-foreground hover:text-foreground hover:bg-muted"),title:e?"work"===t?`工作中 ${l} — 点击停止`:`休息中 ${l} — 点击停止`:"启动番茄钟",children:ee.jsx(yj,{className:"h-4 w-4"})})}const aT="v2026.4.19-x",iT=!!window.electronUpdater;function sT(){const[e,t]=W.useState("idle"),[n,r]=W.useState(!1),[o,a]=W.useState(""),[i,s]=W.useState(0),[l,u]=W.useState(null),[c,d]=W.useState(null);W.useEffect(()=>{if(!window.electronUpdater)return;return window.electronUpdater.onUpdateStatus(e=>{switch(e.type){case"progress":{const t=e.info;s(Math.round((null==t?void 0:t.percent)??0));break}case"downloaded":t("downloaded");break;case"error":u(e.info||"Download failed"),t("error")}})},[]);const f=W.useCallback(async()=>{t("checking"),u(null),r(!0);try{if(iT){const e=await window.electronUpdater.checkForUpdate();if(e.error)throw new Error(e.error);if(!e.available)return void t("no_update");a(e.version?`v${e.version}`:"new version")}else{const e=await YS();if(!e.updateAvailable)return void t("no_update");a(`v${e.latest}`)}t("update_available")}catch(RT){u(RT instanceof Error?RT.message:"Check failed"),t("error")}},[]),p=W.useCallback(()=>{const e=3e3,n=Date.now(),r=()=>{if(Date.now()-n>3e5)return u("更新超时(5 分钟)— 请检查服务器状态"),void t("update_failed");KS().then(n=>{n?n.success?(a(n.newVersion?`v${n.newVersion}`:"new version"),t("update_complete")):(u(n.error||"Update failed"),t("update_failed")):setTimeout(r,e)}).catch(()=>{setTimeout(r,e)})};setTimeout(r,e)},[]),h=()=>{r(!1),setTimeout(()=>{t("idle"),a(""),u(null),s(0),d(null)},200)};return ee.jsxs(ee.Fragment,{children:[ee.jsx(Rk,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{f()},disabled:"checking"===e||"downloading"===e||"executing"===e||"reconnecting"===e,title:"检查更新",children:"checking"===e||"downloading"===e||"executing"===e||"reconnecting"===e?ee.jsx(tj,{className:"h-4 w-4 animate-spin"}):ee.jsx($E,{className:"h-4 w-4"})}),ee.jsx(HP,{open:n,onOpenChange:e=>{e||h()},children:ee.jsxs(qP,{className:"sm:max-w-md",children:[ee.jsxs(KP,{children:[ee.jsxs(QP,{children:["checking"===e&&"Checking for updates...","no_update"===e&&"Up to date","update_available"===e&&`Update ${o} available`,"downloading"===e&&"Downloading update...","downloaded"===e&&"Update ready to install","executing"===e&&"Updating server...","reconnecting"===e&&"Waiting for server restart...","update_complete"===e&&`Updated to ${o}`,"update_failed"===e&&"Update failed","error"===e&&"Update error"]}),ee.jsxs(ZP,{children:["checking"===e&&"Checking for the latest version...","no_update"===e&&`Current version ${aT} is the latest.`,"update_available"===e&&"A new version is available. "+(iT?"Click download to update automatically.":""),"downloading"===e&&`Downloading... ${i}%`,"downloaded"===e&&"The update has been downloaded. Click install to restart and apply.","executing"===e&&"Server is shutting down and installing the update. Please wait...","reconnecting"===e&&"Update installed. Waiting for server to restart...","update_complete"===e&&`Successfully updated from ${aT} to ${o}. Click reload to use the new version.`,"update_failed"===e&&(l||"Update failed. You may need to restart the server manually."),"error"===e&&(l||"An error occurred.")]})]}),"downloading"===e&&ee.jsx("div",{className:"w-full bg-muted rounded-full h-2 overflow-hidden",children:ee.jsx("div",{className:"bg-primary h-full transition-all duration-300",style:{width:`${i}%`}})}),("executing"===e||"reconnecting"===e)&&ee.jsx("div",{className:"flex items-center justify-center py-6",children:ee.jsx(tj,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),ee.jsxs(XP,{children:["no_update"===e&&ee.jsx(Rk,{onClick:h,children:"OK"}),"update_available"===e&&ee.jsxs(ee.Fragment,{children:[ee.jsx(Rk,{variant:"outline",onClick:h,children:"Later"}),ee.jsx(Rk,{onClick:()=>{(async()=>{if(iT){t("downloading"),s(0);const e=await window.electronUpdater.downloadUpdate();e.success?e.path&&d(e.path):(u(e.error||"Download failed"),t("error"))}else{t("executing");try{await qS(),t("reconnecting"),p()}catch(RT){u(RT instanceof Error?RT.message:"Execute failed"),t("error")}}})()},children:iT?"Download & Install":`Update to ${o}`})]}),"downloaded"===e&&ee.jsxs(ee.Fragment,{children:[ee.jsx(Rk,{variant:"outline",onClick:h,children:"Later"}),ee.jsx(Rk,{onClick:()=>{var e;null==(e=window.electronUpdater)||e.quitAndInstall(c||void 0)},children:"Restart & Install"})]}),"update_complete"===e&&ee.jsx(Rk,{onClick:()=>window.location.reload(),children:"Reload Page"}),"update_failed"===e&&ee.jsx(Rk,{onClick:h,children:"Close"}),"error"===e&&ee.jsx(Rk,{onClick:h,children:"Close"})]})]})})]})}function lT(e){return e.map(e=>"text"===e.type?e.content:`\n\`\`\`${e.type}\n${e.content}\n\`\`\`\n`).join("")}function uT(e,t){return{id:e.id??t(),role:e.role,content:lT(e.blocks),blocks:e.blocks,ts:e.timestamp}}function cT({project:e,liveMessages:t,ws:n,historyLimit:r=20,liveWindow:o=50,historyEnabled:a=!0}){const i=e.id,[s,l]=W.useState("running"===e.status?"live":"stopped"),{history:u,hasMore:c,reload:d,loadMore:f}=function({projectId:e,historyLimit:t=20,enabled:n=!0}){const[r,o]=W.useState([]),[a,i]=W.useState(!1),[s,l]=W.useState(!1),u=W.useRef(0),c=W.useCallback(()=>"h"+ ++u.current,[]),d=W.useRef({projectId:e,enabled:n});d.current={projectId:e,enabled:n};const f=W.useCallback(async()=>{if(!d.current.enabled)return;const e=d.current.projectId;l(!0);try{const n=await mE(e,{limit:t});if(d.current.projectId!==e)return;const r=[];for(const e of n.blocks){const t=uT(e,c);t.content.trim()&&r.push(t)}o(r),i(n.hasMore)}catch{}finally{l(!1)}},[t,c]),p=W.useCallback(async()=>{if(!a||s||0===r.length)return;if(!d.current.enabled)return;const e=d.current.projectId,n=r[0];if(n.id&&!n.id.startsWith("h")){l(!0);try{const r=await mE(e,{limit:t,before:n.id});if(d.current.projectId!==e)return;const a=[];for(const e of r.blocks){const t=uT(e,c);t.content.trim()&&a.push(t)}o(e=>[...a,...e]),i(r.hasMore)}catch{}finally{l(!1)}}},[t,a,s,r,c]);return W.useEffect(()=>{n&&f()},[e,n]),{history:r,hasMore:a,isLoading:s,reload:f,loadMore:p}}({projectId:i,historyLimit:r,enabled:a}),[p,h]=W.useState([]),m=W.useRef(0),g=W.useCallback(()=>"m"+ ++m.current,[]),v=W.useRef(null),y=W.useCallback(()=>{v.current&&(clearTimeout(v.current.timer),v.current=null)},[]),b=W.useRef([]),x=W.useRef(!1),w=W.useRef(0);W.useEffect(()=>{if(t.length<w.current&&(w.current=0,b.current=[]),t.length<=w.current)return;const e=t.slice(w.current);w.current=t.length;for(const t of e){x.current=!0;const e=lT(t.blocks);if(e.trim()){if("user"===t.role){const t=b.current.indexOf(e.trim());if(-1!==t){b.current.splice(t,1),y();continue}}h(n=>{if(t.id&&n.some(e=>e.id===t.id))return n;const r={id:t.id??g(),role:t.role,content:e,blocks:t.blocks,ts:t.timestamp};return[...n,r].slice(-o)})}}},[t,g,o,y]),W.useEffect(()=>{if("live"!==s)return void(x.current=!1);const e=setTimeout(()=>{x.current||d()},3e3);return()=>clearTimeout(e)},[s,d]),W.useEffect(()=>{"running"!==e.status||"stopped"!==s&&"error"!==s?"stopped"===e.status&&"live"===s&&l("stopped"):(h([]),l("live"))},[e.status]);const k=W.useRef([]),S=W.useRef(null),E=W.useRef(0),j=W.useCallback(()=>{if(v.current)return;const e=t=>{const r=setTimeout(()=>{if(0!==b.current.length){if(t>=20)return b.current=[],void(v.current=null);n.send("\r"),e(t+1)}else v.current=null},3e3);v.current={timer:r,attempts:t}};e(0)},[n]);W.useEffect(()=>{if(!n.connected)return;if("live"!==s)return;if(0===k.current.length)return;const e=[...k.current];k.current=[];for(const t of e)n.send(t.replace(/\n/g,"\r")+"\r");j()},[n.connected,s,n,j]),W.useEffect(()=>()=>{S.current&&clearTimeout(S.current),y()},[y]);const C=W.useCallback(e=>{k.current.length>=20&&k.current.shift(),k.current.push(e)},[]),P=W.useCallback(e=>{if(b.current.push(e),b.current.length>10&&b.current.shift(),h(t=>[...t,{id:g(),role:"user",content:e,ts:(new Date).toISOString()}].slice(-o)),"live"===s)!n.connected||k.current.length>0?C(e):(n.send(e.replace(/\n/g,"\r")+"\r"),j());else if("waking"===s)C(e);else if("stopped"===s||"error"===s){C(e);const t=++E.current;l("waking"),dS(i).then(()=>{t===E.current&&(S.current&&clearTimeout(S.current),l("live"))}).catch(e=>{t===E.current&&(dN.error(`启动失败: ${e instanceof Error?e.message:String(e)}`),l("error"),k.current=[])}),S.current=setTimeout(()=>{t===E.current&&k.current.length>0&&(dN.error("启动超时(10s)"),l("error"),k.current=[])},1e4)}},[s,n,i,g,o,j,C]),N=W.useCallback(e=>{const t=e.replace(/\r$/,"").trim();t&&(b.current.push(t),b.current.length>10&&b.current.shift(),h(e=>[...e,{id:g(),role:"user",content:t,ts:(new Date).toISOString()}].slice(-o)))},[g,o]),T=W.useMemo(()=>{const e=new Set;for(const t of p)t.id&&e.add(t.id);return[...u.filter(t=>!t.id||!e.has(t.id)),...p]},[u,p]);return{state:s,setState:l,messages:T,historyMessages:u,displayMessages:p,setDisplayMessages:h,hasMoreHistory:c,loadMoreHistory:f,reloadHistory:d,liveReceivedRef:x,sendMessage:P,appendUserMessage:N,clearSendRetry:y,isWaking:"waking"===s,isRunning:"live"===s}}function dT(e,t,n){const r=W.useRef(!0),o=W.useRef(0),a=W.useCallback(()=>{const t=e.current;t&&(o.current=performance.now(),t.scrollTop=t.scrollHeight)},[e]);return W.useEffect(()=>{const t=e.current;if(!t)return;const n=()=>{if(performance.now()-o.current<80)return;const e=t.scrollHeight-t.scrollTop-t.clientHeight<80;r.current=e};return t.addEventListener("scroll",n,{passive:!0}),()=>t.removeEventListener("scroll",n)},[e]),W.useLayoutEffect(()=>{r.current&&a()},[a,...n]),W.useEffect(()=>{const e=t.current;if(!e)return;const n=new ResizeObserver(()=>{r.current&&a()});return n.observe(e),()=>n.disconnect()},[t,a]),{pinnedRef:r,scrollToBottom:a}}function fT(e,t="shift"){return W.useCallback(n=>{if("Enter"!==n.key)return;if(n.nativeEvent.isComposing||229===n.keyCode)return;("shift"===t?!n.shiftKey:n.shiftKey)&&(n.preventDefault(),e())},[e,t])}const pT=H.memo(function({project:e,externalStatus:t,active:n=!1}){const r=cf(),[o,a]=W.useState(""),[i,s]=W.useState(!1),l=W.useRef(null),u=W.useRef(null),[c,d]=W.useState([]),f=W.useRef(0),p=W.useCallback(e=>{d(t=>{const n=[...t,e];return n.length>200?n.slice(-200):n}),"assistant"===e.role&&(s(!0),setTimeout(()=>s(!1),1e3))},[]),h=W.useCallback(e=>{var t;"stopped"===e&&(null==(t=S.current)||t.call(S,"stopped"))},[]),{sendInput:m,connected:g}=ON({projectId:e.id,enabled:!0,onChatMessage:p,onStatusChange:h}),{state:v,setState:y,messages:b,sendMessage:x,isRunning:w,isWaking:k}=cT({project:e,liveMessages:c,ws:{send:m,connected:g},historyLimit:4,liveWindow:4}),S=W.useRef(y);S.current=y,W.useEffect(()=>{"stopped"===v&&(d([]),f.current=0)},[v]),W.useEffect(()=>{t&&("running"!==t||"stopped"!==v&&"error"!==v?"stopped"===t&&"live"===v&&y("stopped"):(d([]),y("live")))},[t]),dT(l,u,[b]);const E=fT(W.useCallback(()=>{const e=o.trim();e&&(a(""),x(e))},[o,x]),"enter"),j="stopped"===v,C=b.slice(-4),P=ee.jsxs("div",{className:uk("flex flex-col h-full rounded-lg overflow-hidden bg-background transition-colors duration-300",n?"border-transparent bg-transparent shadow-none":i?"border border-blue-500":"border border-border","error"===v&&"border border-red-500/50"),children:[ee.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-1.5 border-b border-border bg-muted/30 transition-colors",children:[ee.jsx(QE,{className:"h-3.5 w-3.5 text-muted-foreground/40 flex-shrink-0 cursor-grab active:cursor-grabbing"}),ee.jsx("span",{className:"font-medium text-sm truncate flex-1 cursor-pointer hover:text-blue-400 transition-colors",onClick:()=>r(`/projects/${e.id}`),title:"打开项目详情",children:e.name}),ee.jsx("span",{className:"text-[10px] text-muted-foreground font-mono",children:e.cliTool??"claude"}),ee.jsx("span",{className:uk("w-2 h-2 rounded-full flex-shrink-0",w?"bg-green-500":k?"bg-yellow-400 animate-pulse":"bg-zinc-400")})]}),ee.jsx("div",{ref:l,className:"flex-1 overflow-y-auto min-h-0 text-xs",children:ee.jsxs("div",{ref:u,className:"p-2 space-y-2 min-h-full",children:[C.map(e=>{const t="user"===e.role;return ee.jsx("div",{className:uk("flex",t?"justify-end":"justify-start"),children:ee.jsx("div",{className:uk("max-w-[85%] rounded-lg px-2.5 py-1.5 whitespace-pre-wrap break-words leading-relaxed",t?"bg-blue-500/15 text-foreground border border-blue-500/20 rounded-br-sm dark:bg-blue-500/20 dark:border-blue-500/25":"bg-secondary text-secondary-foreground border border-border rounded-bl-sm"),children:ee.jsx("div",{className:"line-clamp-6",children:e.content})})},e.id)}),j&&0===C.length&&ee.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground/40 text-xs",children:"无对话记录"}),k&&ee.jsx("div",{className:"flex items-center justify-center h-full text-yellow-400 text-xs animate-pulse",children:"启动中..."})]})}),ee.jsx("div",{className:"border-t border-border p-1.5",children:ee.jsx("input",{type:"text",value:o,onChange:e=>a(e.target.value),onKeyDown:E,disabled:k,placeholder:k?"启动中...":j?"输入命令(自动启动)... Shift+⏎":"输入命令... Shift+⏎",className:uk("w-full bg-transparent text-xs font-mono outline-none placeholder:text-muted-foreground/40 px-1.5 py-1",k&&"opacity-50 cursor-not-allowed")})})]});return n?ee.jsx("div",{className:"card-active-glow rounded-lg h-full",children:P}):P});function hT({projects:e,projectStatuses:t,activeProjectIds:n}){const r=W.useMemo(()=>e.filter(e=>!e.archived),[e]),{order:o,setOrder:a,applyOrder:i}=VN(),[s,l]=W.useState(null),[u,c]=W.useState(null),d=W.useRef(null),f=W.useMemo(()=>i(r),[r,i]),p=W.useCallback((e,t)=>{l(t),e.dataTransfer.effectAllowed="move";const n=document.createElement("div");n.style.width="1px",n.style.height="1px",n.style.opacity="0.01",document.body.appendChild(n),e.dataTransfer.setDragImage(n,0,0),d.current=n},[]),h=W.useCallback((e,t)=>{e.preventDefault(),e.dataTransfer.dropEffect="move",c(t)},[]),m=W.useCallback((e,t)=>{if(e.preventDefault(),!s||s===t)return l(null),void c(null);const n=f.map(e=>e.id),r=o.length?[...o]:n;for(const o of n)r.includes(o)||r.push(o);const i=r.indexOf(s),u=r.indexOf(t);if(-1===i||-1===u)return l(null),void c(null);r.splice(i,1),r.splice(u,0,s),a(r),l(null),c(null)},[s,f,o,a]),g=W.useCallback(()=>{l(null),c(null),d.current&&(d.current.remove(),d.current=null)},[]),{cols:v,rows:y}=(b=f.length)<=1?{cols:1,rows:1}:b<=2?{cols:2,rows:1}:b<=4?{cols:2,rows:2}:b<=6?{cols:3,rows:2}:b<=9?{cols:3,rows:3}:b<=12?{cols:4,rows:3}:{cols:4,rows:Math.ceil(b/4)};var b;if(0===f.length)return ee.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground/50 text-sm",children:"没有活跃项目"});const x=y<=3;return ee.jsx("div",{className:"h-full w-full p-2 gap-2 overflow-y-auto",style:{display:"grid",gridTemplateColumns:`repeat(${v}, minmax(0, 1fr))`,gridAutoRows:x?`minmax(180px, min(${Math.floor(100/y)}vh, 350px))`:"280px"},children:f.map(e=>ee.jsx("div",{draggable:!0,onDragStart:t=>p(t,e.id),onDragOver:t=>h(t,e.id),onDrop:t=>m(t,e.id),onDragEnd:g,className:uk("transition-all duration-200",s===e.id&&"opacity-40 scale-95",u===e.id&&s!==e.id&&"ring-2 ring-blue-500/50 rounded-lg"),children:ee.jsx(pT,{project:e,externalStatus:t.get(e.id),active:n.has(e.id)})},e.id))})}function mT(){const e=cf(),{projects:t,loading:n,error:r,hasFetched:o,fetchProjects:a,addProject:i,updateProject:s,removeProject:l}=Kk(),u=Yk(e=>e.clearToken),[c,d]=W.useState(!1),[f,p]=W.useState(!1),[h,m]=W.useState(new Set),g=W.useRef(new Map),[v,y]=W.useState(new Map),b=W.useRef(0),[x,w]=W.useState(!!document.fullscreenElement),[k,S]=W.useState(!1),[E,j]=Gk($k.monitorMode,!1,{parse:!0}),[C,P]=W.useState(new Map);W.useEffect(()=>{const e=()=>w(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]),W.useEffect(()=>{a()},[a]);AN({onActivityUpdate:W.useCallback(e=>{if(e.status){const t=Kk.getState().projects.find(t=>t.id===e.projectId);t&&t.status!==e.status&&s({...t,status:e.status}),P(t=>{const n=new Map(t);return n.set(e.projectId,e.status),n})}const t=Date.now(),n=g.current;if(e.active){m(t=>t.has(e.projectId)?t:new Set(t).add(e.projectId));const r=n.get(e.projectId)??[];let o=!1;if(e.semantic){const n=r[r.length-1];`${e.semantic.phase}:${e.semantic.detail??""}`!==(n?`${n.phase}:${n.detail??""}`:"")?(r.push({id:b.current++,phase:e.semantic.phase,detail:e.semantic.detail,ts:t}),o=!0):n&&(n.ts=t)}const a=r.filter(e=>t-e.ts<8e3),i=a.length>3?a.slice(-3):a;i.length!==r.length&&(o=!0),n.set(e.projectId,i),o&&y(new Map(n))}else m(t=>{if(!t.has(e.projectId))return t;const n=new Set(t);return n.delete(e.projectId),n}),n.has(e.projectId)&&n.get(e.projectId).length>0&&(n.set(e.projectId,[]),y(new Map(n)))},[s])}),W.useEffect(()=>{const e=setInterval(()=>{const e=Date.now(),t=g.current;let n=!1;for(const[r,o]of t){const a=o.filter(t=>e-t.ts<8e3);a.length!==o.length&&(t.set(r,a),n=!0)}n&&y(new Map(t)),m(e=>{let n=!1;const r=new Set(e);for(const o of e){const e=t.get(o);e&&0!==e.length||(r.delete(o),n=!0)}return n?r:e})},3e3);return()=>clearInterval(e)},[]);const N=W.useMemo(()=>t.filter(e=>!e.archived),[t]),T=W.useMemo(()=>t.filter(e=>e.archived),[t]),M=W.useMemo(()=>Array.from(new Set(t.flatMap(e=>e.tags??[]))),[t]),[R,L]=W.useState([]),D=W.useMemo(()=>0===R.length?N:N.filter(e=>R.some(t=>{var n;return null==(n=e.tags)?void 0:n.includes(t)})),[N,R]),[_,A]=W.useState(!1),O=W.useCallback(async()=>{if(!_){A(!0);try{const e=await LE(),t=e.results.filter(e=>e.ok).length,n=e.results.filter(e=>e.skipped).length,r=e.total-t-n;dN.success(`同步完成:${t} 成功 / ${n} 跳过 / ${r} 失败`)}catch(RT){dN.error(`同步失败:${RT.message}`)}finally{A(!1)}}},[_]),{order:I,setOrder:z,applyOrder:F}=VN(),[V,B]=W.useState(null),[$,U]=W.useState(null),H=W.useMemo(()=>F(D),[D,F]),G=W.useCallback(e=>B(e),[]),Y=W.useCallback(()=>{B(null),U(null)},[]),q=W.useCallback((e,t)=>{e.preventDefault(),U(t)},[]),K=W.useCallback((e,t,n)=>{if(e.preventDefault(),!n||n===t)return void U(null);const r=H.map(e=>e.id),o=I.length?[...I]:r;for(const s of r)o.includes(s)||o.push(s);const a=o.indexOf(n),i=o.indexOf(t);if(-1===a||-1===i)return B(null),void U(null);o.splice(a,1),o.splice(i,0,n),z(o),B(null),U(null)},[H,I,z]),X={onDelete:e=>{(async e=>{try{await cS(e),l(e)}catch(RT){dN.error(RT instanceof Error?RT.message:"Failed to delete project")}})(e)},onArchive:e=>{(async e=>{try{const t=await fS(e);s(t)}catch(RT){dN.error(RT instanceof Error?RT.message:"Failed to archive project")}})(e)},onUnarchive:e=>{(async e=>{try{const t=await pS(e);s(t)}catch(RT){dN.error(RT instanceof Error?RT.message:"Failed to restore project")}})(e)},onUpdated:s};return ee.jsxs("div",{className:"min-h-screen bg-background",children:[ee.jsx("header",{className:"border-b sticky top-0 bg-background z-10",children:ee.jsxs("div",{className:"max-w-6xl mx-auto px-4 h-14 flex items-center justify-between",children:[ee.jsxs("div",{className:"flex items-center gap-2",children:[ee.jsx(vj,{className:"h-5 w-5"}),ee.jsxs("div",{children:[ee.jsx("span",{className:"font-semibold text-lg leading-tight block",children:"CC Web"}),ee.jsx("span",{className:"text-[10px] text-muted-foreground leading-none",children:aT})]})]}),ee.jsx(HN,{}),ee.jsx(Rk,{variant:"ghost",size:"sm",onClick:()=>e("/skillhub"),title:"CCWeb Hub",children:ee.jsx(mj,{className:"h-4 w-4"})}),ee.jsx(Rk,{variant:"ghost",size:"sm",onClick:()=>e("/mobile"),title:"手机界面",children:ee.jsx(hj,{className:"h-4 w-4"})}),ee.jsx(Rk,{variant:"ghost",size:"sm",onClick:()=>e("/settings"),title:"设置",children:ee.jsx(fj,{className:"h-4 w-4"})}),ee.jsx(Rk,{variant:"ghost",size:"sm",onClick:()=>j(!E),title:E?"卡片模式":"监控大屏",className:uk(E&&"text-blue-400 bg-blue-500/10"),children:E?ee.jsx(ej,{className:"h-4 w-4"}):ee.jsx(ij,{className:"h-4 w-4"})}),ee.jsx(Rk,{variant:"ghost",size:"sm",onClick:()=>{document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen()},title:x?"Exit fullscreen":"Fullscreen",children:x?ee.jsx(oj,{className:"h-4 w-4"}):ee.jsx(rj,{className:"h-4 w-4"})}),ee.jsx(sT,{}),ee.jsx(oT,{}),ee.jsx(ZN,{}),ee.jsxs(Rk,{variant:"ghost",size:"sm",onClick:()=>{u(),e("/login")},children:[ee.jsx(nj,{className:"h-4 w-4 mr-2"}),"Logout"]})]})}),E&&ee.jsx("div",{className:"flex-1 min-h-0",children:ee.jsx(hT,{projects:t,projectStatuses:C,activeProjectIds:h})}),!E&&ee.jsxs("main",{className:"max-w-6xl mx-auto px-4 py-8",children:[ee.jsxs("div",{className:"flex items-center justify-between mb-6",children:[ee.jsxs("div",{children:[ee.jsx("h1",{className:"text-2xl font-bold",children:"Projects"}),ee.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Each project runs Claude CLI in a dedicated terminal session."})]}),ee.jsxs("div",{className:"flex gap-2",children:[ee.jsxs(Rk,{variant:"outline",onClick:()=>{O()},disabled:_,title:"通过 rsync 同步所有项目(在设置里配置服务器)",children:[_?ee.jsx(tj,{className:"h-4 w-4 mr-2 animate-spin"}):ee.jsx(YE,{className:"h-4 w-4 mr-2"}),"全部同步"]}),ee.jsxs(Rk,{variant:"outline",onClick:()=>p(!0),children:[ee.jsx(HE,{className:"h-4 w-4 mr-2"}),"Open Project"]}),ee.jsxs(Rk,{onClick:()=>d(!0),children:[ee.jsx(uj,{className:"h-4 w-4 mr-2"}),"New Project"]})]})]}),n&&!o&&ee.jsx("div",{className:"text-center text-muted-foreground py-12",children:"Loading projects..."}),r&&ee.jsx("div",{className:"text-center text-destructive py-12",children:r}),o&&!n&&!r&&0===t.length&&ee.jsxs("div",{className:"text-center py-20",children:[ee.jsx(vj,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),ee.jsx("h2",{className:"text-lg font-semibold mb-2",children:"No projects yet"}),ee.jsx("p",{className:"text-muted-foreground text-sm mb-6",children:"Create a new project or open an existing one."}),ee.jsxs("div",{className:"flex gap-2 justify-center",children:[ee.jsxs(Rk,{variant:"outline",onClick:()=>p(!0),children:[ee.jsx(HE,{className:"h-4 w-4 mr-2"}),"Open Project"]}),ee.jsxs(Rk,{onClick:()=>d(!0),children:[ee.jsx(uj,{className:"h-4 w-4 mr-2"}),"New Project"]})]})]}),!n&&!r&&M.length>0&&ee.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-4",children:[M.map(e=>ee.jsxs("button",{onClick:()=>L(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),className:uk("px-2 py-0.5 rounded-full text-xs border transition-colors",R.includes(e)?"bg-blue-500/20 text-blue-400 border-blue-500/40":"bg-muted text-muted-foreground border-border hover:border-muted-foreground/40"),children:["#",e]},e)),R.length>0&&ee.jsx("button",{onClick:()=>L([]),className:"px-2 py-0.5 rounded-full text-xs text-muted-foreground hover:text-foreground transition-colors",children:"清除"})]}),!n&&!r&&H.length>0&&ee.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:H.map((e,t)=>ee.jsx(hw.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.3,delay:Math.min(.05*t,.3),ease:"easeOut"},draggable:!0,onDragStart:()=>G(e.id),onDragOver:t=>q(t,e.id),onDrop:t=>K(t,e.id,V),onDragEnd:Y,style:{opacity:V===e.id?.4:1,cursor:"grab"},className:uk($===e.id&&V!==e.id&&"ring-2 ring-blue-500/50 rounded-xl"),children:ee.jsx(CN,{project:e,active:h.has(e.id),statusStack:v.get(e.id)??[],...X})},e.id))}),!n&&!r&&T.length>0&&ee.jsxs("div",{className:"mt-10",children:[ee.jsxs("button",{className:"flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors mb-4 group",onClick:()=>S(e=>!e),children:[ee.jsx(hw.span,{animate:{rotate:k?90:0},transition:{duration:.2},children:ee.jsx(BE,{className:"h-4 w-4"})}),ee.jsx("span",{className:"font-medium",children:"Archived"}),ee.jsx("span",{className:"text-xs bg-muted rounded-full px-2 py-0.5",children:T.length})]}),ee.jsx(Xb,{children:k&&ee.jsx(hw.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.25,ease:"easeInOut"},className:"overflow-hidden",children:ee.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:T.map(e=>ee.jsx(CN,{project:e,active:!1,...X},e.id))})})})]}),ee.jsx(YN,{})]}),ee.jsx(MN,{open:c,onOpenChange:d,onCreated:e=>{i(e)}}),ee.jsx(RN,{open:f,onOpenChange:p,onOpened:e=>{i(e)}})]})}class gT extends H.Component{constructor(){super(...arguments),t(this,"state",{hasError:!1,error:null}),t(this,"handleReset",()=>{var e,t;this.setState({hasError:!1,error:null}),null==(t=(e=this.props).onReset)||t.call(e)})}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error("[ErrorBoundary]",e,t.componentStack),dN.error(e.message||"Something went wrong")}render(){return this.state.hasError?this.props.fallback?this.props.fallback:ee.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 p-4 text-sm text-muted-foreground",children:[ee.jsx("p",{children:"出错了"}),ee.jsx("button",{onClick:this.handleReset,className:"px-3 py-1.5 text-xs rounded-md border border-border hover:bg-muted transition-colors",children:"重新加载"})]}):this.props.children}}function vT({plugin:e,onConfigChange:t,onClose:n}){const{float:r,userConfig:o}=e,[a,i]=W.useState(()=>{var e,t;return{x:(null==(e=o.floatPosition)?void 0:e.x)??.5*window.innerWidth-r.defaultWidth/2,y:(null==(t=o.floatPosition)?void 0:t.y)??.3*window.innerHeight}}),[s,l]=W.useState(()=>{var e,t;return{w:(null==(e=o.floatSize)?void 0:e.w)??r.defaultWidth,h:(null==(t=o.floatSize)?void 0:t.h)??r.defaultHeight}}),[u,c]=W.useState(!1),[d,f]=W.useState(100),p=W.useRef(null),h=W.useRef(null),m=W.useCallback(()=>{f(Date.now()%1e5+100)},[]),g=W.useRef(null),v=W.useCallback(n=>{n.preventDefault(),m(),g.current={sx:n.clientX,sy:n.clientY,ox:a.x,oy:a.y},h.current&&(h.current.style.pointerEvents="none");const r=e=>{if(!g.current)return;const t=Math.max(0,Math.min(window.innerWidth-100,g.current.ox+e.clientX-g.current.sx)),n=Math.max(0,Math.min(window.innerHeight-40,g.current.oy+e.clientY-g.current.sy));p.current&&(p.current.style.left=t+"px",p.current.style.top=n+"px")},o=n=>{if(!g.current)return;const a=Math.max(0,Math.min(window.innerWidth-100,g.current.ox+n.clientX-g.current.sx)),s=Math.max(0,Math.min(window.innerHeight-40,g.current.oy+n.clientY-g.current.sy));g.current=null,h.current&&(h.current.style.pointerEvents=""),i({x:a,y:s}),t(e.id,{floatPosition:{x:a,y:s}}),window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",o)};window.addEventListener("mousemove",r),window.addEventListener("mouseup",o)},[a,m,e.id,t]),y=W.useRef(null),b=W.useCallback(n=>{if(!r.resizable)return;n.preventDefault(),n.stopPropagation(),m(),y.current={sx:n.clientX,sy:n.clientY,ow:s.w,oh:s.h},h.current&&(h.current.style.pointerEvents="none");const o=r.minWidth??150,a=r.minHeight??100,i=e=>{if(!y.current)return;const t=Math.max(o,y.current.ow+e.clientX-y.current.sx),n=Math.max(a,y.current.oh+e.clientY-y.current.sy);p.current&&(p.current.style.width=t+"px",p.current.style.height=n+"px")},u=n=>{if(!y.current)return;const r=Math.max(o,y.current.ow+n.clientX-y.current.sx),s=Math.max(a,y.current.oh+n.clientY-y.current.sy);y.current=null,h.current&&(h.current.style.pointerEvents=""),l({w:r,h:s}),t(e.id,{floatSize:{w:r,h:s}}),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",u)};window.addEventListener("mousemove",i),window.addEventListener("mouseup",u)},[s,r,m,e.id,t]);W.useEffect(()=>{const t=async t=>{var n,r,o,a,i;if(t.source!==(null==(n=h.current)?void 0:n.contentWindow))return;const{callId:s,method:l,args:u}=t.data;if(s&&l)try{const t=Zk(),n={"Content-Type":"application/json","X-Plugin-Id":e.id};let a,i;if(t&&(n.Authorization=`Bearer ${t}`),"storage:get"===l)a=`/api/plugin-bridge/storage/${e.id}`,i={method:"GET",headers:n};else if("storage:set"===l)a=`/api/plugin-bridge/storage/${e.id}`,i={method:"PUT",headers:n,body:JSON.stringify(u)};else{const t={"project:status":{path:`/api/plugin-bridge/project/status/${u.projectId}`,httpMethod:"GET"},"project:list":{path:"/api/plugin-bridge/project/list",httpMethod:"GET"},"terminal:send":{path:"/api/plugin-bridge/terminal/send",httpMethod:"POST"},"session:read":{path:`/api/plugin-bridge/session/${u.projectId}`,httpMethod:"GET"},"system:info":{path:"/api/plugin-bridge/system/info",httpMethod:"GET"}};if("backend:api"===l){const{method:t,path:r,body:o}=u;if(!r||!r.startsWith("/")||r.includes(".."))throw new Error("Invalid API path");a=`/api/plugins/${e.id}${r}`,i={method:t||"GET",headers:n},!o||"POST"!==t&&"PUT"!==t||(i.body=JSON.stringify(o))}else{const e=t[l];if(!e)throw new Error(`Unknown method: ${l}`);a=e.path,i={method:e.httpMethod,headers:n},"POST"===e.httpMethod&&(i.body=JSON.stringify(u))}}const c=await fetch(a,i),d=await c.json();null==(o=null==(r=h.current)?void 0:r.contentWindow)||o.postMessage({callId:s,result:d,error:null},window.location.origin)}catch(RT){const t=RT instanceof Error?RT.message:"Bridge error";null==(i=null==(a=h.current)?void 0:a.contentWindow)||i.postMessage({callId:s,result:null,error:t},window.location.origin)}};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[e.id]);const x=o.clickable??r.clickable.default,w=`/plugins/${e.id}/${e.float?"index.html":""}`;return ee.jsxs(hw.div,{ref:p,className:uk("fixed rounded-lg border border-border shadow-xl overflow-hidden flex flex-col","bg-background/95 backdrop-blur-sm"),style:{left:a.x,top:a.y,width:u?200:s.w,height:u?32:s.h,zIndex:d},initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.15},onMouseDown:m,children:[ee.jsxs("div",{className:"h-8 flex items-center gap-1 px-2 bg-muted/50 border-b border-border cursor-grab active:cursor-grabbing flex-shrink-0 select-none",onMouseDown:v,children:[ee.jsx(XE,{className:"h-3 w-3 text-muted-foreground/40 flex-shrink-0"}),ee.jsx("span",{className:"text-xs text-muted-foreground truncate flex-1",children:e.name}),ee.jsx("button",{onClick:()=>c(e=>!e),className:"p-0.5 rounded hover:bg-white/10 text-muted-foreground/60 hover:text-foreground transition-colors",children:ee.jsx(aj,{className:"h-3 w-3"})}),ee.jsx("button",{onClick:()=>n(e.id),className:"p-0.5 rounded hover:bg-red-500/20 text-muted-foreground/60 hover:text-red-400 transition-colors",children:ee.jsx(wj,{className:"h-3 w-3"})})]}),!u&&ee.jsxs("div",{className:"flex-1 min-h-0 relative",children:[ee.jsx("iframe",{ref:h,src:w,sandbox:"allow-scripts allow-same-origin",className:"w-full h-full border-0",style:{pointerEvents:x?"auto":"none"}}),r.resizable&&ee.jsx("div",{className:"absolute bottom-0 right-0 w-3 h-3 cursor-se-resize",onMouseDown:b,children:ee.jsxs("svg",{viewBox:"0 0 12 12",className:"w-3 h-3 text-muted-foreground/30",children:[ee.jsx("path",{d:"M11 1v10H1",fill:"none",stroke:"currentColor",strokeWidth:"1.5"}),ee.jsx("path",{d:"M11 5v6H5",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})]})})]})]})}function yT({plugins:e,onPluginsChange:t,onClose:n}){const r=W.useCallback(async(e,n)=>{t(t=>t.map(t=>t.id===e?{...t,userConfig:{...t.userConfig,...n}}:t));try{await EE(e,n)}catch{}},[t]);return 0===e.length?null:ee.jsx(Xb,{children:e.map(e=>ee.jsx(vT,{plugin:e,onConfigChange:r,onClose:n},e.id))})}function bT({onTogglePlugin:e,activeIds:t}){const[n,r]=W.useState([]);return W.useEffect(()=>{wE().then(e=>r(e.filter(e=>e.enabled))).catch(()=>r([]))},[]),W.useEffect(()=>{const e=()=>{wE().then(e=>r(e.filter(e=>e.enabled))).catch(()=>{})};return window.addEventListener("focus",e),()=>window.removeEventListener("focus",e)},[]),0===n.length?null:ee.jsx("div",{className:"fixed top-14 left-1/2 -translate-x-1/2 z-40 pointer-events-none",children:ee.jsx(hw.div,{className:"pointer-events-auto flex items-center gap-1 px-2 py-1 rounded-full bg-background/60 backdrop-blur-md border border-border/50 shadow-lg",initial:{opacity:0,y:-8},animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},children:n.map(n=>{const r=t.has(n.id),o=n.name.slice(0,2);return ee.jsxs(hw.button,{onClick:()=>e(n),className:uk("relative flex items-center justify-center w-7 h-7 rounded-full text-[10px] font-medium transition-colors",r?"bg-blue-500/20 text-blue-400":"text-muted-foreground/70 hover:text-foreground hover:bg-muted/80"),whileHover:{scale:1.12},whileTap:{scale:.92},title:n.name+(n.description?` — ${n.description}`:""),children:[o,ee.jsx(Xb,{children:r&&ee.jsx(hw.span,{className:"absolute -bottom-0.5 left-1/2 -translate-x-1/2 h-1 w-1 rounded-full bg-blue-400",initial:{scale:0},animate:{scale:1},exit:{scale:0}})})]},n.id)})})})}const xT=H.lazy(()=>fd(()=>import("./ProjectPage-CsTaTE7W.js").then(e=>e.P),__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(e=>({default:e.ProjectPage}))),wT=H.lazy(()=>fd(()=>import("./SettingsPage-BSbsMogo.js"),__vite__mapDeps([9,6,3,4])).then(e=>({default:e.SettingsPage}))),kT=H.lazy(()=>fd(()=>import("./SkillHubPage-LLy7t8L7.js"),__vite__mapDeps([10,7,3])).then(e=>({default:e.SkillHubPage}))),ST=H.lazy(()=>fd(()=>import("./MobilePage-DtNZ_N9c.js"),__vite__mapDeps([11,2,3,4,5])).then(e=>({default:e.MobilePage})));function ET(){return ee.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:ee.jsx("span",{className:"text-muted-foreground text-sm",children:"Loading…"})})}function jT({children:e}){const[t,n]=W.useState(!1),r=Yk(e=>e.token),o=Yk(e=>e.setToken);return W.useEffect(()=>{r?n(!0):nS()?rS().then(e=>o(e)).catch(()=>{}).finally(()=>n(!0)):n(!0)},[]),t||r?r?ee.jsx(ee.Fragment,{children:e}):ee.jsx(wf,{to:"/login",replace:!0}):null}const CT=window.matchMedia("(pointer: coarse)").matches&&window.innerWidth<768;function PT(){const[e,t]=W.useState([]),[n,r]=W.useState(()=>{try{return new Set(JSON.parse(localStorage.getItem("cc_plugin_open")||"[]"))}catch{return new Set}}),o=lf();W.useEffect(()=>{wE().then(t).catch(()=>t([]))},[]);const a=W.useCallback(e=>{r(t=>{const n=new Set(t);n.has(e.id)?n.delete(e.id):n.add(e.id);try{localStorage.setItem("cc_plugin_open",JSON.stringify([...n]))}catch{}return n})},[]),i=W.useCallback(e=>{r(t=>{const n=new Set(t);n.delete(e);try{localStorage.setItem("cc_plugin_open",JSON.stringify([...n]))}catch{}return n})},[]),s=function(e){if("/"===e||"/dashboard"===e)return{type:"dashboard"};const t=e.match(/^\/projects?\/([^/]+)/);return t?{type:"project",projectId:t[1]}:{type:"other"}}(o.pathname),l=e.filter(e=>{if(!e.enabled||!n.has(e.id))return!1;switch(e.userConfig.scope??e.float.scope.default){case"global":return!0;case"dashboard":return"dashboard"===s.type;case"project":return"project"===s.type;case"project:specific":return"project"===s.type&&(e.userConfig.projectIds??[]).includes(s.projectId??"");default:return!1}}),u="/login"===o.pathname,c="/mobile"===o.pathname;return ee.jsxs(ee.Fragment,{children:[!u&&!c&&!CT&&ee.jsx(bT,{onTogglePlugin:a,activeIds:n}),ee.jsx(yT,{plugins:l,onPluginsChange:t,onClose:i})]})}function NT({children:e}){const t=lf();return CT&&"/"===t.pathname?ee.jsx(wf,{to:"/mobile",replace:!0}):ee.jsx(ee.Fragment,{children:e})}function TT(){return ee.jsx(XN,{children:ee.jsxs(wN,{children:[ee.jsx(bN,{richColors:!0,position:"bottom-right"}),ee.jsx(nT,{}),ee.jsx(rT,{}),ee.jsx(gT,{children:ee.jsxs(Nf,{children:[ee.jsx(PT,{}),ee.jsx(NT,{children:ee.jsx(W.Suspense,{fallback:ee.jsx(ET,{}),children:ee.jsxs(Ef,{children:[ee.jsx(kf,{path:"/login",element:ee.jsx(_E,{})}),ee.jsx(kf,{path:"/",element:ee.jsx(jT,{children:ee.jsx(mT,{})})}),ee.jsx(kf,{path:"/projects/:id",element:ee.jsx(jT,{children:ee.jsx(xT,{})})}),ee.jsx(kf,{path:"/settings",element:ee.jsx(jT,{children:ee.jsx(wT,{})})}),ee.jsx(kf,{path:"/skillhub",element:ee.jsx(jT,{children:ee.jsx(kT,{})})}),ee.jsx(kf,{path:"/mobile",element:ee.jsx(jT,{children:ee.jsx(ST,{})})}),ee.jsx(kf,{path:"*",element:ee.jsx(wf,{to:"/",replace:!0})})]})})})]})})]})})}te.createRoot(document.getElementById("root")).render(ee.jsx(H.StrictMode,{children:ee.jsx(TT,{})}));export{uC as $,Xb as A,Rk as B,BE as C,$E as D,UE as E,HE as F,dE as G,fE as H,Lk as I,Gk as J,vk as K,Vj as L,oj as M,Cj as N,iC as O,lj as P,aC as Q,H as R,$k as S,bj as T,yk as U,jj as V,zj as W,wj as X,oP as Y,Fj as Z,fd as _,QN as a,eE as a$,QC as a0,Zj as a1,Gj as a2,pj as a3,yS as a4,hS as a5,KE as a6,GN as a7,wS as a8,vS as a9,oT as aA,ZN as aB,tj as aC,YE as aD,RE as aE,tE as aF,dS as aG,_N as aH,HN as aI,Nj as aJ,CE as aK,cT as aL,bE as aM,vE as aN,dT as aO,Hk as aP,xE as aQ,yE as aR,dj as aS,df as aT,Kk as aU,vj as aV,Dj as aW,Rj as aX,ld as aY,XS as aZ,ZS as a_,HP as aa,qP as ab,KP as ac,QP as ad,ZP as ae,Ik as af,XP as ag,mS as ah,bS as ai,gS as aj,xS as ak,CS as al,LS as am,SS as an,PS as ao,ES as ap,NS as aq,jS as ar,TS as as,MS as at,RS as au,kj as av,mj as aw,cf as ax,FE as ay,Ej as az,WS as b,ck as b0,dk as b1,fk as b2,hk as b3,NE as b4,TE as b5,ME as b6,LE as b7,_S as b8,OS as b9,zS as bA,jv as bB,Pv as bC,Ev as bD,r as bE,o as bF,PE as bG,a as bH,DE as bI,AS as ba,Df as bb,eT as bc,sE as bd,yj as be,QS as bf,nE as bg,oE as bh,iE as bi,JS as bj,aE as bk,rE as bl,lE as bm,wE as bn,kE as bo,SE as bp,jE as bq,DS as br,kS as bs,AN as bt,VN as bu,sT as bv,ij as bw,ON as bx,fT as by,WE as bz,OE as c,uk as d,rj as e,BS as f,Zk as g,Uk as h,Qk as i,ee as j,VS as k,cj as l,GS as m,$S as n,qE as o,hw as p,uE as q,W as r,Wk as s,dN as t,SN as u,pE as v,HS as w,VE as x,uj as y,cE as z};
|