@markus-global/cli 0.12.5-rc.2 → 0.12.5-rc.4
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/dist/web-ui/assets/{AsyncState-BCS9C43h.js → AsyncState-CeDmMBla.js} +1 -1
- package/dist/web-ui/assets/{ChatComponents-B4gMEEQr.js → ChatComponents-u_iLnHEf.js} +1 -1
- package/dist/web-ui/assets/{ContentRenderer-iGJdjFvn.js → ContentRenderer-CHzFmlGx.js} +2 -2
- package/dist/web-ui/assets/{DeliverableShareModal-CY0_wqDC.js → DeliverableShareModal-By9CYH0Q.js} +1 -1
- package/dist/web-ui/assets/{Deliverables-oCzunom7.js → Deliverables-Cn_DRg-F.js} +1 -1
- package/dist/web-ui/assets/{MarkdownMessage-B-9NMrYX.js → MarkdownMessage-BX6YVVx8.js} +1 -1
- package/dist/web-ui/assets/{Search-Badheo3V.js → Search-BGSuNeNO.js} +1 -1
- package/dist/web-ui/assets/{SendToChat-X-3sK9Ph.js → SendToChat-BR3-e7d4.js} +1 -1
- package/dist/web-ui/assets/{Settings-B05tnigv.js → Settings-DJyCWAY9.js} +1 -1
- package/dist/web-ui/assets/{Store-B4hpcTFJ.js → Store-Cl-05eXo.js} +1 -1
- package/dist/web-ui/assets/{Switch-BgdJa330.js → Switch-DGrHkwcq.js} +1 -1
- package/dist/web-ui/assets/{Team-Dfz_Jkoy.js → Team-DfNOc2Oj.js} +4 -4
- package/dist/web-ui/assets/{Work-DqxE8g_Q.js → Work-Cwkb9n7H.js} +1 -1
- package/dist/web-ui/assets/{arc-Dns31Tc9.js → arc-DUrpNW2s.js} +1 -1
- package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-C0MbQViF.js → architectureDiagram-3BPJPVTR-_itbdqjs.js} +1 -1
- package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-DRAhpfjQ.js → blockDiagram-GPEHLZMM-7gcaAgpE.js} +1 -1
- package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-DVAnq8L5.js → c4Diagram-AAUBKEIU-BqKuOXWt.js} +1 -1
- package/dist/web-ui/assets/channel-BNcjWETI.js +1 -0
- package/dist/web-ui/assets/{chunk-2J33WTMH-CNZ1Di5i.js → chunk-2J33WTMH-DmFCktA6.js} +1 -1
- package/dist/web-ui/assets/{chunk-4BX2VUAB-BfZWR2ax.js → chunk-4BX2VUAB-w8YtZlZ5.js} +1 -1
- package/dist/web-ui/assets/{chunk-55IACEB6-CLvm88GS.js → chunk-55IACEB6-4k-E46Qp.js} +1 -1
- package/dist/web-ui/assets/{chunk-727SXJPM-YptrHhiQ.js → chunk-727SXJPM-C1-6Iiik.js} +1 -1
- package/dist/web-ui/assets/{chunk-AQP2D5EJ-Bht-7eQm.js → chunk-AQP2D5EJ-CO4NtkeR.js} +1 -1
- package/dist/web-ui/assets/{chunk-FMBD7UC4-CXoaPK-Q.js → chunk-FMBD7UC4-CS_sseZh.js} +1 -1
- package/dist/web-ui/assets/{chunk-ND2GUHAM-Bor_8TtZ.js → chunk-ND2GUHAM-D7-BkEUG.js} +1 -1
- package/dist/web-ui/assets/{chunk-QZHKN3VN-BWVZxTBv.js → chunk-QZHKN3VN-BPCz16Gj.js} +1 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-v3_2DQPV.js +1 -0
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-v3_2DQPV.js +1 -0
- package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-Dc0GRajy.js → cose-bilkent-S5V4N54A-CpYmq76O.js} +1 -1
- package/dist/web-ui/assets/{dagre-BM42HDAG-CTnRRUJj.js → dagre-BM42HDAG-DrBF0YKT.js} +1 -1
- package/dist/web-ui/assets/{diagram-2AECGRRQ-BJpt589H.js → diagram-2AECGRRQ-CzQkjw5L.js} +1 -1
- package/dist/web-ui/assets/{diagram-5GNKFQAL-Wonl9ScH.js → diagram-5GNKFQAL-SneRBO1C.js} +1 -1
- package/dist/web-ui/assets/{diagram-KO2AKTUF-DYlCFdL8.js → diagram-KO2AKTUF-C8iAMOJw.js} +1 -1
- package/dist/web-ui/assets/{diagram-LMA3HP47-0bqbxPqr.js → diagram-LMA3HP47-C2lb4oU1.js} +1 -1
- package/dist/web-ui/assets/{diagram-OG6HWLK6-CCgq0GqI.js → diagram-OG6HWLK6-P-NuPlh6.js} +1 -1
- package/dist/web-ui/assets/{docx-preview-BvKeUHJr.js → docx-preview-YtzS0xMU.js} +1 -1
- package/dist/web-ui/assets/{erDiagram-TEJ5UH35-CLUiZPDr.js → erDiagram-TEJ5UH35-BXcYtaBT.js} +1 -1
- package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-f6pN4cw1.js → flowDiagram-I6XJVG4X-Dm48mLdd.js} +1 -1
- package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-BwJkS7mo.js → ganttDiagram-6RSMTGT7-BXrfFYnN.js} +1 -1
- package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-DI2zMknR.js → gitGraphDiagram-PVQCEYII-CxO9AKdS.js} +1 -1
- package/dist/web-ui/assets/{index-Dc1HlaXE.js → index-CudHikwU.js} +6 -6
- package/dist/web-ui/assets/{infoDiagram-5YYISTIA-oD_kael7.js → infoDiagram-5YYISTIA-DSP5_m8e.js} +1 -1
- package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-CU8h8XWC.js → ishikawaDiagram-YF4QCWOH-Bsmqh7_N.js} +1 -1
- package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-0RIRYcwi.js → journeyDiagram-JHISSGLW-CCBod5iD.js} +1 -1
- package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-BbjHZ91H.js → kanban-definition-UN3LZRKU-BGbAEz6s.js} +1 -1
- package/dist/web-ui/assets/{mermaid.core-BlPZWkyC.js → mermaid.core-B17l8z4S.js} +5 -5
- package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-BvaY6iLy.js → mindmap-definition-RKZ34NQL-7pahuML0.js} +1 -1
- package/dist/web-ui/assets/{pieDiagram-4H26LBE5-CHAkMEBP.js → pieDiagram-4H26LBE5-AtMgK6F2.js} +1 -1
- package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-BLmxZKSH.js → quadrantDiagram-W4KKPZXB-DxwCSN_z.js} +1 -1
- package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-CszQubly.js → requirementDiagram-4Y6WPE33-DQ4GULQe.js} +1 -1
- package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-ovwXJ_-9.js → sankeyDiagram-5OEKKPKP-DJaWWRUa.js} +1 -1
- package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-C5biPL1f.js → sequenceDiagram-3UESZ5HK-ChrFC_0T.js} +1 -1
- package/dist/web-ui/assets/{stateDiagram-AJRCARHV-B_H8A-zE.js → stateDiagram-AJRCARHV-DZthn0Xq.js} +1 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-CFMNtQOk.js +1 -0
- package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-DxHkO_i6.js → timeline-definition-PNZ67QCA-BM0bxJB9.js} +1 -1
- package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-XuByI13m.js → vennDiagram-CIIHVFJN-Buu596v7.js} +1 -1
- package/dist/web-ui/assets/{wardley-L42UT6IY-DEu5IbdV.js → wardley-L42UT6IY-FsFYXKCE.js} +1 -1
- package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-Coe77zhN.js → wardleyDiagram-YWT4CUSO-CEl-G6gD.js} +1 -1
- package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-vMLEL3LK.js → xychartDiagram-2RQKCTM6-c-k0Gyas.js} +1 -1
- package/dist/web-ui/index.html +1 -1
- package/docs/architecture/desktop-auto-update.md +46 -2
- package/package.json +1 -1
- package/dist/web-ui/assets/channel-Dll32qm6.js +0 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-BAXna0Rk.js +0 -1
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-BAXna0Rk.js +0 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-BHZhFie0.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-B17l8z4S.js","assets/transform-BqqRT-Iy.js","assets/Team-DfNOc2Oj.js","assets/MarkdownMessage-BX6YVVx8.js","assets/ChatComponents-u_iLnHEf.js","assets/chatChips-DVIRVTpT.js","assets/AsyncState-CeDmMBla.js","assets/Switch-DGrHkwcq.js","assets/ContentRenderer-CHzFmlGx.js","assets/DeliverableShareModal-By9CYH0Q.js","assets/Team-DFuMZ0ql.css","assets/Settings-DJyCWAY9.js","assets/Work-Cwkb9n7H.js","assets/SendToChat-BR3-e7d4.js","assets/value-wA6veExk.js","assets/Work-BZV40eAE.css","assets/Deliverables-Cn_DRg-F.js","assets/Search-BGSuNeNO.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))a(i);new MutationObserver(i=>{for(const l of i)if(l.type==="childList")for(const c of l.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&a(c)}).observe(document,{childList:!0,subtree:!0});function n(i){const l={};return i.integrity&&(l.integrity=i.integrity),i.referrerPolicy&&(l.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?l.credentials="include":i.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function a(i){if(i.ep)return;i.ep=!0;const l=n(i);fetch(i.href,l)}})();var Mme=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Bc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ah={exports:{}},Ql={};var Mx;function v6(){if(Mx)return Ql;Mx=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(a,i,l){var c=null;if(l!==void 0&&(c=""+l),i.key!==void 0&&(c=""+i.key),"key"in i){l={};for(var u in i)u!=="key"&&(l[u]=i[u])}else l=i;return i=l.ref,{$$typeof:e,type:a,key:c,ref:i!==void 0?i:null,props:l}}return Ql.Fragment=t,Ql.jsx=n,Ql.jsxs=n,Ql}var jx;function x6(){return jx||(jx=1,Ah.exports=v6()),Ah.exports}var o=x6(),Th={exports:{}},It={};var Rx;function w6(){if(Rx)return It;Rx=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),b=Symbol.iterator;function y(W){return W===null||typeof W!="object"?null:(W=b&&W[b]||W["@@iterator"],typeof W=="function"?W:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,T={};function A(W,oe,L){this.props=W,this.context=oe,this.refs=T,this.updater=L||k}A.prototype.isReactComponent={},A.prototype.setState=function(W,oe){if(typeof W!="object"&&typeof W!="function"&&W!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,W,oe,"setState")},A.prototype.forceUpdate=function(W){this.updater.enqueueForceUpdate(this,W,"forceUpdate")};function M(){}M.prototype=A.prototype;function I(W,oe,L){this.props=W,this.context=oe,this.refs=T,this.updater=L||k}var B=I.prototype=new M;B.constructor=I,C(B,A.prototype),B.isPureReactComponent=!0;var G=Array.isArray;function j(){}var O={H:null,A:null,T:null,S:null},F=Object.prototype.hasOwnProperty;function Y(W,oe,L){var Ne=L.ref;return{$$typeof:e,type:W,key:oe,ref:Ne!==void 0?Ne:null,props:L}}function q(W,oe){return Y(W.type,oe,W.props)}function V(W){return typeof W=="object"&&W!==null&&W.$$typeof===e}function z(W){var oe={"=":"=0",":":"=2"};return"$"+W.replace(/[=:]/g,function(L){return oe[L]})}var J=/\/+/g;function D(W,oe){return typeof W=="object"&&W!==null&&W.key!=null?z(""+W.key):oe.toString(36)}function ee(W){switch(W.status){case"fulfilled":return W.value;case"rejected":throw W.reason;default:switch(typeof W.status=="string"?W.then(j,j):(W.status="pending",W.then(function(oe){W.status==="pending"&&(W.status="fulfilled",W.value=oe)},function(oe){W.status==="pending"&&(W.status="rejected",W.reason=oe)})),W.status){case"fulfilled":return W.value;case"rejected":throw W.reason}}throw W}function R(W,oe,L,Ne,qe){var me=typeof W;(me==="undefined"||me==="boolean")&&(W=null);var ze=!1;if(W===null)ze=!0;else switch(me){case"bigint":case"string":case"number":ze=!0;break;case"object":switch(W.$$typeof){case e:case t:ze=!0;break;case g:return ze=W._init,R(ze(W._payload),oe,L,Ne,qe)}}if(ze)return qe=qe(W),ze=Ne===""?"."+D(W,0):Ne,G(qe)?(L="",ze!=null&&(L=ze.replace(J,"$&/")+"/"),R(qe,oe,L,"",function(Ye){return Ye})):qe!=null&&(V(qe)&&(qe=q(qe,L+(qe.key==null||W&&W.key===qe.key?"":(""+qe.key).replace(J,"$&/")+"/")+ze)),oe.push(qe)),1;ze=0;var Ue=Ne===""?".":Ne+":";if(G(W))for(var je=0;je<W.length;je++)Ne=W[je],me=Ue+D(Ne,je),ze+=R(Ne,oe,L,me,qe);else if(je=y(W),typeof je=="function")for(W=je.call(W),je=0;!(Ne=W.next()).done;)Ne=Ne.value,me=Ue+D(Ne,je++),ze+=R(Ne,oe,L,me,qe);else if(me==="object"){if(typeof W.then=="function")return R(ee(W),oe,L,Ne,qe);throw oe=String(W),Error("Objects are not valid as a React child (found: "+(oe==="[object Object]"?"object with keys {"+Object.keys(W).join(", ")+"}":oe)+"). If you meant to render a collection of children, use an array instead.")}return ze}function te(W,oe,L){if(W==null)return W;var Ne=[],qe=0;return R(W,Ne,"","",function(me){return oe.call(L,me,qe++)}),Ne}function le(W){if(W._status===-1){var oe=W._result;oe=oe(),oe.then(function(L){(W._status===0||W._status===-1)&&(W._status=1,W._result=L)},function(L){(W._status===0||W._status===-1)&&(W._status=2,W._result=L)}),W._status===-1&&(W._status=0,W._result=oe)}if(W._status===1)return W._result.default;throw W._result}var ke=typeof reportError=="function"?reportError:function(W){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var oe=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof W=="object"&&W!==null&&typeof W.message=="string"?String(W.message):String(W),error:W});if(!window.dispatchEvent(oe))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",W);return}console.error(W)},$={map:te,forEach:function(W,oe,L){te(W,function(){oe.apply(this,arguments)},L)},count:function(W){var oe=0;return te(W,function(){oe++}),oe},toArray:function(W){return te(W,function(oe){return oe})||[]},only:function(W){if(!V(W))throw Error("React.Children.only expected to receive a single React element child.");return W}};return It.Activity=h,It.Children=$,It.Component=A,It.Fragment=n,It.Profiler=i,It.PureComponent=I,It.StrictMode=a,It.Suspense=m,It.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=O,It.__COMPILER_RUNTIME={__proto__:null,c:function(W){return O.H.useMemoCache(W)}},It.cache=function(W){return function(){return W.apply(null,arguments)}},It.cacheSignal=function(){return null},It.cloneElement=function(W,oe,L){if(W==null)throw Error("The argument must be a React element, but you passed "+W+".");var Ne=C({},W.props),qe=W.key;if(oe!=null)for(me in oe.key!==void 0&&(qe=""+oe.key),oe)!F.call(oe,me)||me==="key"||me==="__self"||me==="__source"||me==="ref"&&oe.ref===void 0||(Ne[me]=oe[me]);var me=arguments.length-2;if(me===1)Ne.children=L;else if(1<me){for(var ze=Array(me),Ue=0;Ue<me;Ue++)ze[Ue]=arguments[Ue+2];Ne.children=ze}return Y(W.type,qe,Ne)},It.createContext=function(W){return W={$$typeof:c,_currentValue:W,_currentValue2:W,_threadCount:0,Provider:null,Consumer:null},W.Provider=W,W.Consumer={$$typeof:l,_context:W},W},It.createElement=function(W,oe,L){var Ne,qe={},me=null;if(oe!=null)for(Ne in oe.key!==void 0&&(me=""+oe.key),oe)F.call(oe,Ne)&&Ne!=="key"&&Ne!=="__self"&&Ne!=="__source"&&(qe[Ne]=oe[Ne]);var ze=arguments.length-2;if(ze===1)qe.children=L;else if(1<ze){for(var Ue=Array(ze),je=0;je<ze;je++)Ue[je]=arguments[je+2];qe.children=Ue}if(W&&W.defaultProps)for(Ne in ze=W.defaultProps,ze)qe[Ne]===void 0&&(qe[Ne]=ze[Ne]);return Y(W,me,qe)},It.createRef=function(){return{current:null}},It.forwardRef=function(W){return{$$typeof:u,render:W}},It.isValidElement=V,It.lazy=function(W){return{$$typeof:g,_payload:{_status:-1,_result:W},_init:le}},It.memo=function(W,oe){return{$$typeof:f,type:W,compare:oe===void 0?null:oe}},It.startTransition=function(W){var oe=O.T,L={};O.T=L;try{var Ne=W(),qe=O.S;qe!==null&&qe(L,Ne),typeof Ne=="object"&&Ne!==null&&typeof Ne.then=="function"&&Ne.then(j,ke)}catch(me){ke(me)}finally{oe!==null&&L.types!==null&&(oe.types=L.types),O.T=oe}},It.unstable_useCacheRefresh=function(){return O.H.useCacheRefresh()},It.use=function(W){return O.H.use(W)},It.useActionState=function(W,oe,L){return O.H.useActionState(W,oe,L)},It.useCallback=function(W,oe){return O.H.useCallback(W,oe)},It.useContext=function(W){return O.H.useContext(W)},It.useDebugValue=function(){},It.useDeferredValue=function(W,oe){return O.H.useDeferredValue(W,oe)},It.useEffect=function(W,oe){return O.H.useEffect(W,oe)},It.useEffectEvent=function(W){return O.H.useEffectEvent(W)},It.useId=function(){return O.H.useId()},It.useImperativeHandle=function(W,oe,L){return O.H.useImperativeHandle(W,oe,L)},It.useInsertionEffect=function(W,oe){return O.H.useInsertionEffect(W,oe)},It.useLayoutEffect=function(W,oe){return O.H.useLayoutEffect(W,oe)},It.useMemo=function(W,oe){return O.H.useMemo(W,oe)},It.useOptimistic=function(W,oe){return O.H.useOptimistic(W,oe)},It.useReducer=function(W,oe,L){return O.H.useReducer(W,oe,L)},It.useRef=function(W){return O.H.useRef(W)},It.useState=function(W){return O.H.useState(W)},It.useSyncExternalStore=function(W,oe,L){return O.H.useSyncExternalStore(W,oe,L)},It.useTransition=function(){return O.H.useTransition()},It.version="19.2.4",It}var _x;function Qm(){return _x||(_x=1,Th.exports=w6()),Th.exports}var w=Qm();const jme=Bc(w);var Eh={exports:{}},Jl={},Nh={exports:{}},Mh={};var Dx;function k6(){return Dx||(Dx=1,(function(e){function t(R,te){var le=R.length;R.push(te);e:for(;0<le;){var ke=le-1>>>1,$=R[ke];if(0<i($,te))R[ke]=te,R[le]=$,le=ke;else break e}}function n(R){return R.length===0?null:R[0]}function a(R){if(R.length===0)return null;var te=R[0],le=R.pop();if(le!==te){R[0]=le;e:for(var ke=0,$=R.length,W=$>>>1;ke<W;){var oe=2*(ke+1)-1,L=R[oe],Ne=oe+1,qe=R[Ne];if(0>i(L,le))Ne<$&&0>i(qe,L)?(R[ke]=qe,R[Ne]=le,ke=Ne):(R[ke]=L,R[oe]=le,ke=oe);else if(Ne<$&&0>i(qe,le))R[ke]=qe,R[Ne]=le,ke=Ne;else break e}}return te}function i(R,te){var le=R.sortIndex-te.sortIndex;return le!==0?le:R.id-te.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var c=Date,u=c.now();e.unstable_now=function(){return c.now()-u}}var m=[],f=[],g=1,h=null,b=3,y=!1,k=!1,C=!1,T=!1,A=typeof setTimeout=="function"?setTimeout:null,M=typeof clearTimeout=="function"?clearTimeout:null,I=typeof setImmediate<"u"?setImmediate:null;function B(R){for(var te=n(f);te!==null;){if(te.callback===null)a(f);else if(te.startTime<=R)a(f),te.sortIndex=te.expirationTime,t(m,te);else break;te=n(f)}}function G(R){if(C=!1,B(R),!k)if(n(m)!==null)k=!0,j||(j=!0,z());else{var te=n(f);te!==null&&ee(G,te.startTime-R)}}var j=!1,O=-1,F=5,Y=-1;function q(){return T?!0:!(e.unstable_now()-Y<F)}function V(){if(T=!1,j){var R=e.unstable_now();Y=R;var te=!0;try{e:{k=!1,C&&(C=!1,M(O),O=-1),y=!0;var le=b;try{t:{for(B(R),h=n(m);h!==null&&!(h.expirationTime>R&&q());){var ke=h.callback;if(typeof ke=="function"){h.callback=null,b=h.priorityLevel;var $=ke(h.expirationTime<=R);if(R=e.unstable_now(),typeof $=="function"){h.callback=$,B(R),te=!0;break t}h===n(m)&&a(m),B(R)}else a(m);h=n(m)}if(h!==null)te=!0;else{var W=n(f);W!==null&&ee(G,W.startTime-R),te=!1}}break e}finally{h=null,b=le,y=!1}te=void 0}}finally{te?z():j=!1}}}var z;if(typeof I=="function")z=function(){I(V)};else if(typeof MessageChannel<"u"){var J=new MessageChannel,D=J.port2;J.port1.onmessage=V,z=function(){D.postMessage(null)}}else z=function(){A(V,0)};function ee(R,te){O=A(function(){R(e.unstable_now())},te)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(R){R.callback=null},e.unstable_forceFrameRate=function(R){0>R||125<R?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):F=0<R?Math.floor(1e3/R):5},e.unstable_getCurrentPriorityLevel=function(){return b},e.unstable_next=function(R){switch(b){case 1:case 2:case 3:var te=3;break;default:te=b}var le=b;b=te;try{return R()}finally{b=le}},e.unstable_requestPaint=function(){T=!0},e.unstable_runWithPriority=function(R,te){switch(R){case 1:case 2:case 3:case 4:case 5:break;default:R=3}var le=b;b=R;try{return te()}finally{b=le}},e.unstable_scheduleCallback=function(R,te,le){var ke=e.unstable_now();switch(typeof le=="object"&&le!==null?(le=le.delay,le=typeof le=="number"&&0<le?ke+le:ke):le=ke,R){case 1:var $=-1;break;case 2:$=250;break;case 5:$=1073741823;break;case 4:$=1e4;break;default:$=5e3}return $=le+$,R={id:g++,callback:te,priorityLevel:R,startTime:le,expirationTime:$,sortIndex:-1},le>ke?(R.sortIndex=le,t(f,R),n(m)===null&&R===n(f)&&(C?(M(O),O=-1):C=!0,ee(G,le-ke))):(R.sortIndex=$,t(m,R),k||y||(k=!0,j||(j=!0,z()))),R},e.unstable_shouldYield=q,e.unstable_wrapCallback=function(R){var te=b;return function(){var le=b;b=te;try{return R.apply(this,arguments)}finally{b=le}}}})(Mh)),Mh}var Ix;function S6(){return Ix||(Ix=1,Nh.exports=k6()),Nh.exports}var jh={exports:{}},ua={};var Lx;function C6(){if(Lx)return ua;Lx=1;var e=Qm();function t(m){var f="https://react.dev/errors/"+m;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var g=2;g<arguments.length;g++)f+="&args[]="+encodeURIComponent(arguments[g])}return"Minified React error #"+m+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var a={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},i=Symbol.for("react.portal");function l(m,f,g){var h=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:h==null?null:""+h,children:m,containerInfo:f,implementation:g}}var c=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(m,f){if(m==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return ua.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,ua.createPortal=function(m,f){var g=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)throw Error(t(299));return l(m,f,null,g)},ua.flushSync=function(m){var f=c.T,g=a.p;try{if(c.T=null,a.p=2,m)return m()}finally{c.T=f,a.p=g,a.d.f()}},ua.preconnect=function(m,f){typeof m=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,a.d.C(m,f))},ua.prefetchDNS=function(m){typeof m=="string"&&a.d.D(m)},ua.preinit=function(m,f){if(typeof m=="string"&&f&&typeof f.as=="string"){var g=f.as,h=u(g,f.crossOrigin),b=typeof f.integrity=="string"?f.integrity:void 0,y=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;g==="style"?a.d.S(m,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:h,integrity:b,fetchPriority:y}):g==="script"&&a.d.X(m,{crossOrigin:h,integrity:b,fetchPriority:y,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},ua.preinitModule=function(m,f){if(typeof m=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var g=u(f.as,f.crossOrigin);a.d.M(m,{crossOrigin:g,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&a.d.M(m)},ua.preload=function(m,f){if(typeof m=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var g=f.as,h=u(g,f.crossOrigin);a.d.L(m,g,{crossOrigin:h,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0,type:typeof f.type=="string"?f.type:void 0,fetchPriority:typeof f.fetchPriority=="string"?f.fetchPriority:void 0,referrerPolicy:typeof f.referrerPolicy=="string"?f.referrerPolicy:void 0,imageSrcSet:typeof f.imageSrcSet=="string"?f.imageSrcSet:void 0,imageSizes:typeof f.imageSizes=="string"?f.imageSizes:void 0,media:typeof f.media=="string"?f.media:void 0})}},ua.preloadModule=function(m,f){if(typeof m=="string")if(f){var g=u(f.as,f.crossOrigin);a.d.m(m,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:g,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else a.d.m(m)},ua.requestFormReset=function(m){a.d.r(m)},ua.unstable_batchedUpdates=function(m,f){return m(f)},ua.useFormState=function(m,f,g){return c.H.useFormState(m,f,g)},ua.useFormStatus=function(){return c.H.useHostTransitionStatus()},ua.version="19.2.4",ua}var Px;function I4(){if(Px)return jh.exports;Px=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),jh.exports=C6(),jh.exports}var Ox;function A6(){if(Ox)return Jl;Ox=1;var e=S6(),t=Qm(),n=I4();function a(r){var s="https://react.dev/errors/"+r;if(1<arguments.length){s+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)s+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+r+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function l(r){var s=r,d=r;if(r.alternate)for(;s.return;)s=s.return;else{r=s;do s=r,(s.flags&4098)!==0&&(d=s.return),r=s.return;while(r)}return s.tag===3?d:null}function c(r){if(r.tag===13){var s=r.memoizedState;if(s===null&&(r=r.alternate,r!==null&&(s=r.memoizedState)),s!==null)return s.dehydrated}return null}function u(r){if(r.tag===31){var s=r.memoizedState;if(s===null&&(r=r.alternate,r!==null&&(s=r.memoizedState)),s!==null)return s.dehydrated}return null}function m(r){if(l(r)!==r)throw Error(a(188))}function f(r){var s=r.alternate;if(!s){if(s=l(r),s===null)throw Error(a(188));return s!==r?null:r}for(var d=r,p=s;;){var v=d.return;if(v===null)break;var x=v.alternate;if(x===null){if(p=v.return,p!==null){d=p;continue}break}if(v.child===x.child){for(x=v.child;x;){if(x===d)return m(v),r;if(x===p)return m(v),s;x=x.sibling}throw Error(a(188))}if(d.return!==p.return)d=v,p=x;else{for(var N=!1,P=v.child;P;){if(P===d){N=!0,d=v,p=x;break}if(P===p){N=!0,p=v,d=x;break}P=P.sibling}if(!N){for(P=x.child;P;){if(P===d){N=!0,d=x,p=v;break}if(P===p){N=!0,p=x,d=v;break}P=P.sibling}if(!N)throw Error(a(189))}}if(d.alternate!==p)throw Error(a(190))}if(d.tag!==3)throw Error(a(188));return d.stateNode.current===d?r:s}function g(r){var s=r.tag;if(s===5||s===26||s===27||s===6)return r;for(r=r.child;r!==null;){if(s=g(r),s!==null)return s;r=r.sibling}return null}var h=Object.assign,b=Symbol.for("react.element"),y=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),M=Symbol.for("react.consumer"),I=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),G=Symbol.for("react.suspense"),j=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),F=Symbol.for("react.lazy"),Y=Symbol.for("react.activity"),q=Symbol.for("react.memo_cache_sentinel"),V=Symbol.iterator;function z(r){return r===null||typeof r!="object"?null:(r=V&&r[V]||r["@@iterator"],typeof r=="function"?r:null)}var J=Symbol.for("react.client.reference");function D(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===J?null:r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case C:return"Fragment";case A:return"Profiler";case T:return"StrictMode";case G:return"Suspense";case j:return"SuspenseList";case Y:return"Activity"}if(typeof r=="object")switch(r.$$typeof){case k:return"Portal";case I:return r.displayName||"Context";case M:return(r._context.displayName||"Context")+".Consumer";case B:var s=r.render;return r=r.displayName,r||(r=s.displayName||s.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case O:return s=r.displayName||null,s!==null?s:D(r.type)||"Memo";case F:s=r._payload,r=r._init;try{return D(r(s))}catch{}}return null}var ee=Array.isArray,R=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,te=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,le={pending:!1,data:null,method:null,action:null},ke=[],$=-1;function W(r){return{current:r}}function oe(r){0>$||(r.current=ke[$],ke[$]=null,$--)}function L(r,s){$++,ke[$]=r.current,r.current=s}var Ne=W(null),qe=W(null),me=W(null),ze=W(null);function Ue(r,s){switch(L(me,s),L(qe,r),L(Ne,null),s.nodeType){case 9:case 11:r=(r=s.documentElement)&&(r=r.namespaceURI)?X1(r):0;break;default:if(r=s.tagName,s=s.namespaceURI)s=X1(s),r=Z1(s,r);else switch(r){case"svg":r=1;break;case"math":r=2;break;default:r=0}}oe(Ne),L(Ne,r)}function je(){oe(Ne),oe(qe),oe(me)}function Ye(r){r.memoizedState!==null&&L(ze,r);var s=Ne.current,d=Z1(s,r.type);s!==d&&(L(qe,r),L(Ne,d))}function xt(r){qe.current===r&&(oe(Ne),oe(qe)),ze.current===r&&(oe(ze),Kl._currentValue=le)}var mt,ft;function rt(r){if(mt===void 0)try{throw Error()}catch(d){var s=d.stack.trim().match(/\n( *(at )?)/);mt=s&&s[1]||"",ft=-1<d.stack.indexOf(`
|
|
3
3
|
at`)?" (<anonymous>)":-1<d.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
4
|
`+mt+r+ft}var jt=!1;function ht(r,s){if(!r||jt)return"";jt=!0;var d=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var p={DetermineComponentFrameRoot:function(){try{if(s){var Oe=function(){throw Error()};if(Object.defineProperty(Oe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Oe,[])}catch(Ae){var we=Ae}Reflect.construct(r,[],Oe)}else{try{Oe.call()}catch(Ae){we=Ae}r.call(Oe.prototype)}}else{try{throw Error()}catch(Ae){we=Ae}(Oe=r())&&typeof Oe.catch=="function"&&Oe.catch(function(){})}}catch(Ae){if(Ae&&we&&typeof Ae.stack=="string")return[Ae.stack,we.stack]}return[null,null]}};p.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var v=Object.getOwnPropertyDescriptor(p.DetermineComponentFrameRoot,"name");v&&v.configurable&&Object.defineProperty(p.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var x=p.DetermineComponentFrameRoot(),N=x[0],P=x[1];if(N&&P){var ae=N.split(`
|
|
@@ -517,7 +517,7 @@ tención F1 Score tención 95.2% TEN 97.4% TENIDO +2.2%
|
|
|
517
517
|
**Deployment:**Explotación de canario → 5% de tráfico → monitoreo 48hr → producción completa`,seoMatrix:"Matriz de investigación de palabras clave que cubre 1.200+ términos a través de 8 verticales de productos. Incluye tendencias de volumen de búsqueda, puntajes de competición, análisis de brechas de contenido, oportunidades de SERP y calendario editorial de 6 meses con impacto de tráfico proyectado (+340% orgánico).",financeReport:"Cierre financiero mensual para mayo de 2025. Ingresos: $2.4M (+18% MoM). Destacados clave: SaaS ARR cruzó el hito de $24M, la devolución del CAC cayó a 11 meses, el margen bruto mejoró al 78%. Incluye el desglose por departamento de P plaga y el pronóstico de la corriente de efectivo.",apiDocsV2:"Documentación del portal para desarrolladores para API v2. Autenticación de cubiertas (OAuth 2.0 + API keys), 86 puntos finales con ejemplos de código en 5 idiomas, guía de integración webhook, políticas de limitación de tarifas, estrategia de versionado y configuración interactiva de juegos API.",interviewNotes:"Síntesis de 24 entrevistas de usuarios a través de 4 personas (usuarios de potencia, administradores, nuevos usuarios, churned). Información clave: fricción a bordo al paso 3, la personalización de tablero es #1 petición de características, uso móvil 3× superior a lo esperado. Incluye diagramas de afinidad y clips de vídeo.",wireframes:"Cables de alta fidelidad para aplicación móvil v2.0. Cubre 32 pantallas a través de 5 flujos de usuario: a bordo, dashboard, notificaciones, ajustes y modo offline. Incluye anotaciones de gestos, especificaciones de transición y adaptaciones específicas de plataforma para iOS y Android.",patentAnalysis:"Análisis de paisajes de patentes que cubren 847 patentes a través de la automatización de flujo de trabajo impulsada por AI. Se identificaron 12 riesgos de libertad para operar, 3 oportunidades potenciales de concesión de licencias y 5 áreas de espacio blanco para la presentación de IP patentada. Incluye mapeo de reclamaciones y bibliografía de arte anterior.",testFramework:"Marco de automatización de pruebas de extremo a extremo que soporta API, interfaz de usuario y pruebas de rendimiento. 312 casos de prueba en 8 módulos. Incluye ejecución paralela (4× speedup), regresión visual a través de Playwright, escenarios de prueba de carga (10K usuarios concurrentes), y reportaje integrado por Slack.",socialAssets:"Biblioteca de contenidos con 60+ activos de redes sociales para la campaña de lanzamiento de productos. Incluye plantillas de carrusel, video storyboards, variantes de encabezado A/B, tamaño de plataforma específica (LinkedIn, Twitter/X, Instagram), paletas de colores compatibles con la marca y calendario de publicación."},LW={general:"#general",announcements:"#anuncios",watercooler:"#watercooler"},PW={general:{secretaryMorning:"Buen equipo de mañana. 18 empleados activos, 12 tareas en curso. Prioridades de hoy: Revisión de la API de pago, Componentes de panel, Q2 plazo de investigación.",alexReport:"Buen progreso. @Líder de investigación — necesito el informe competitivo para la reunión del consejo el viernes. Podemos tenerlo para el jueves?",researchLeadReply:"El informe es del 90%. Tendré la versión final con resumen ejecutivo para el jueves por la mañana.",engLeadApi:"La API de conciliación de pagos está lista para su revisión. @QA El plomo por favor prioriza — esto toca el oleoducto financiero.",qaLeadReply:"En ello. Test report by EOD. Suite de regresión atrapado 2 cajas de borde en el manejador de webhook - fijaciones empujadas.",pmStandup:"Actualización rápida — a bordo de mockups de rediseño aprobados por James. Moviéndose a la planificación de la huella. @Frontend Developer puede estimar los componentes del panel?",frontendEstimate:"Tarjetas de panel: 2 días. Componentes de carga: 3 días. Compartirá el desglose de componentes en los entregables al final del día.",chiefOfStaffSync:"Sincronización de equipo cruzado: La ingeniería está bloqueada en las fichas de diseño del producto. @UI Diseñador por favor empuje la exportación token al repo compartido hoy.",uiDesignerTokens:"¡Hecho! Tokens de diseño exportados al paquete compartido. 42 fichas de color, 8 escalas de espaciado, 6 presets de tipografía. Enlace de relaciones públicas en los productos.",sarahReview:"Excelente velocidad hoy. 3 PRs fusionados, 2 entregables verificados. Mantengamos este ritmo para la fecha límite de Q2..",dataAnalystInsight:"Analítica de panel: 89% de los usuarios terminan a bordo en menos de 3 minutos. La conversión móvil sigue disminuyendo en un 62% — priorizando la optimización móvil.",devopsDeployment:"Despliegue completo. Todos los cheques de salud pasan. Presupuesto de rendimiento: API p99 a 180ms, menos de 340ms la semana pasada.",strategyMarket:"Actualización de información competitiva: dos competidores lanzaron características similares esta semana. Nuestra ventaja sigue siendo la coordinación de los agentes autónomos, nadie más tiene una delegación de tareas multiagente."},engineering:{sarahArchitecture:"Equipo, he revisado el doc de la arquitectura de pago. El enfoque de idempotencia parece sólido. Una preocupación: hemos considerado la caducidad distribuida bajo carga alta?",srBackendReply:"Buena captura. He añadido una extensión de la ventana deslizante — si la operación sigue funcionando cuando TTL llega al 80%, se autoextienda. PR actualizado.",devopsCi:"CO2 verde. Construir el tiempo hasta 4m32s después de la optimización de caché. Despliegue el estancamiento ahora.",sarahBuildTime:"Gran trabajo en el tiempo de construcción. Apuntemos 3 minutos después. @DevOps Ingeniero puede mirar en paralelo las suites de prueba?",frontendLib:"Biblioteca de componentes 80% hecho. Gráficos, tablas, formas, modales en todos. Data grid next.",backendMigration:"Los scripts de migración de bases de datos listos para Pago v2. esquema compatible con la marcha atrás — cero despliegue de tiempo de inactividad confirmado.",engLeadCodeReview:"Revisión de código hecho para PRs #127–#134. Todo aprobado. @Senior Backend Dev fusionar la rama de conciliación del pago cuando esté listo.",securityDep:"@Senior Backend Dev head up — flagged 2 transitive deps with CVEs in the payment module. jsonwebtoken necesita actualizar a 9.x. Patch PR entrando.",qaE2e:"Suite E2E ampliada: 312 casos de prueba, 98,4% tasa de paso. Las 5 pruebas flaky eran problemas de tiempo - fijos con la lógica de retry. Regreso completo listo para la liberación.",sarahShipIt:"Excelente progreso todos. Vamos a apuntar el miércoles para la congelación. Envíenlo.! 🚀",engLeadWrapUp:"Entendido. He actualizado el tablero de sprint — 23 tareas completadas, 4 en revisión, 2 bloqueadas en el módulo de pago. Asignar las tareas bloqueadas a Senior Backend Dev para la resolución prioritaria. El miércoles se confirma la congelación de la sesión, coordinaré la ronda final de críticas de código mañana por la mañana."},product:{jamesFunnel:"Basado en @Data Análisis de embudos de Analyst, estamos priorizando el rediseño a bordo. Esta es la primera iniciativa de Q2.",pmMockups:"@UI Designer puede tener maquetas para el jueves? Prepararé el PRD hoy..",uiDesignerReply:"¡Ya empezó! El enlace de Figma será en entregables. Nuevas fichas de diseño también listas para la ingeniería.",emilyA11y:"Me encanta la dirección. Asegúrese de mantener los estándares de accesibilidad — WCAG AA mínimo. Revisaré el jueves por la tarde..",dataAnalystConversion:"El nuevo flujo de salida muestra una mejora de conversión del 23% en la prueba A/B. Informe completo sobre los productos."},alpha:{engLeadSprint:"Día de la huella alfa 3. API de backend hecho, comenzó la integración de frontend. @Mobile Developer — puntos finales de pago viven en el estancamiento.",mobileIntegration:"Empezar la integración ahora. Flujo de pago ETA: 2 días.",jamesTimeline:"Línea de tiempo apretada pero en pista. @QA Lead prepare el plan de prueba final a final para el viernes. Este lanzamiento es visible desde el tablero.",qaLeadTestPlan:"El plan de prueba cubrirá flujo de pago, recuperación de errores y pruebas de carga. Coordinaré con @Security Auditor para un escaneo prelanzamiento."}},OW={humans:AW,agents:TW,teams:EW,projects:NW,tasks:MW,taskDesc:jW,requirements:RW,reqDesc:_W,deliverables:DW,delSummary:IW,channels:LW,messages:PW},Rme=[{code:"en",label:"English"},{code:"zh-CN",label:"中文"},{code:"es",label:"Español"}],HW="common",BW=["common","nav","auth","home","team","work","settings","onboarding","builder","store","agent","deliverables","reports","showcase"];tn.use(K4).use(bE).init({resources:{en:{common:tM,nav:fM,auth:vM,home:qM,team:nj,work:gj,settings:n9,onboarding:u9,builder:F9,store:oR,agent:xR,deliverables:p_,reports:T_,showcase:B_},"zh-CN":{common:eP,nav:pP,auth:yP,home:zP,team:tO,work:hO,settings:tH,onboarding:dH,builder:$H,store:sB,agent:vB,deliverables:mz,reports:Az,showcase:Hz},es:{common:ZF,nav:mU,auth:bU,home:BU,team:eG,work:fG,settings:eK,onboarding:cK,builder:qK,store:iV,agent:yV,deliverables:uW,reports:CW,showcase:OW}},fallbackLng:"en",defaultNS:HW,ns:[...BW],react:{nsMode:"fallback"},interpolation:{escapeValue:!1},detection:{order:["localStorage","navigator"],lookupLocalStorage:"markus-language",caches:["localStorage"]}});const zW="modulepreload",qW=function(e){return"/"+e},o2={},fa=function(t,n,a){let i=Promise.resolve();if(n&&n.length>0){let m=function(f){return Promise.all(f.map(g=>Promise.resolve(g).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),u=c?.nonce||c?.getAttribute("nonce");i=m(n.map(f=>{if(f=qW(f),f in o2)return;o2[f]=!0;const g=f.endsWith(".css"),h=g?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${h}`))return;const b=document.createElement("link");if(b.rel=g?"stylesheet":zW,g||(b.as="script"),b.crossOrigin="",b.href=f,u&&b.setAttribute("nonce",u),document.head.appendChild(b),g)return new Promise((y,k)=>{b.addEventListener("load",y),b.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${f}`)))})}))}function l(c){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=c,window.dispatchEvent(u),!u.defaultPrevented)throw c}return i.then(c=>{for(const u of c||[])u.status==="rejected"&&l(u.reason);return t().catch(l)})},ce={HOME:"home",TEAM:"team",WORK:"work",STORE:"store",BUILDER:"builder",DELIVERABLES:"deliverables",SETTINGS:"settings",SEARCH:"search",AUDIT:"audit"},$W=new Set(Object.values(ce)),FW={dashboard:ce.HOME,chat:ce.TEAM,projects:ce.WORK,usage:ce.HOME,reports:ce.HOME,prompts:ce.BUILDER,templates:ce.STORE,agents:ce.STORE,skills:ce.STORE,teams:ce.STORE,knowledge:ce.DELIVERABLES,governance:ce.SETTINGS,notifications:ce.HOME},V4={[ce.HOME]:"overview",[ce.TEAM]:"team",[ce.WORK]:"tasks",[ce.STORE]:"explore",[ce.BUILDER]:"assets",[ce.DELIVERABLES]:"output",[ce.SETTINGS]:"settings",[ce.SEARCH]:"search",[ce.AUDIT]:"audit"},l2=Object.fromEntries(Object.entries(V4).map(([e,t])=>[t,e]));function V0(e){return V4[e]??e}function Tc(e){return l2[e]?l2[e]:$W.has(e)?e:FW[e]??ce.HOME}function Ec(){const e=window.location.hash.slice(1).split("/")[0];return Tc(e)}function Hs(e,t){const n=V0(e);return t?`#${n}/${t}`:`#${n}`}const W4={[ce.STORE]:ce.BUILDER},Xm={[ce.HOME]:"M4 3h5a1 1 0 0 1 1 1v7a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1z M15 3h5a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-5a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1z M15 12h5a1 1 0 0 1 1 1v7a1 1 0 0 1-1 1h-5a1 1 0 0 1-1-1v-7a1 1 0 0 1 1-1z M4 16h5a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1z",[ce.WORK]:"M9 2h6a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H9a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1z M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2 M12 11h4 M12 16h4 M8 11h.01 M8 16h.01",[ce.TEAM]:"M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1",[ce.DELIVERABLES]:"m7.5 4.27 9 5.15 M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8Z M3.3 7 12 12l8.7-5 M12 22V12",[ce.BUILDER]:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12 M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",[ce.STORE]:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20Z M16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88Z",[ce.SETTINGS]:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"},UW=[{key:"workspace",label:"WORKSPACE"},{key:"build",label:"BUILD"},{key:"system",label:"SYSTEM"}],Y4=[{id:ce.HOME,label:"Overview",section:"workspace"},{id:ce.TEAM,label:"Team",section:"workspace"},{id:ce.WORK,label:"Tasks",section:"workspace"},{id:ce.DELIVERABLES,label:"Output",section:"workspace"},{id:ce.BUILDER,label:"Builder",section:"build"},{id:ce.STORE,label:"Store",section:"build"},{id:ce.SETTINGS,label:"Settings",section:"system"}],GW=new Set([ce.TEAM,ce.WORK,ce.DELIVERABLES,ce.STORE,ce.SETTINGS]),Mo=Y4.map(e=>e.id),KW=[{id:ce.HOME,label:"Overview",group:[ce.HOME]},{id:ce.TEAM,label:"Team",group:[ce.TEAM]},{id:ce.WORK,label:"Tasks",group:[ce.WORK]},{id:ce.DELIVERABLES,label:"Output",group:[ce.DELIVERABLES]}];let js=0,mm=!0;function Q4(){return typeof window<"u"?window.markusDesktop?.browser:void 0}function _me(){return js>0}function Dme(){return mm}function Oh(e){mm!==e&&(mm=e,e||Q4()?.hideAll?.(),window.dispatchEvent(new CustomEvent("markus:native-browser-page",{detail:{allowed:e}})),e&&js===0&&window.dispatchEvent(new CustomEvent("markus:embedded-browser-resync")))}function VW(){js+=1,js===1&&(Q4()?.hideAll?.(),window.dispatchEvent(new CustomEvent("markus:native-browser-overlay",{detail:{active:!0}})));let e=!1;return()=>{e||(e=!0,js=Math.max(0,js-1),js===0&&(window.dispatchEvent(new CustomEvent("markus:native-browser-overlay",{detail:{active:!1}})),mm&&window.dispatchEvent(new CustomEvent("markus:embedded-browser-resync"))))}}function Nc(e){const t=(e||"").trim();if(!t||t==="about:blank")return!1;let n="",a="";try{const i=new URL(/^[a-z][a-z0-9+.-]*:/i.test(t)?t:`https://${t}`);n=i.hostname.toLowerCase(),a=i.pathname.toLowerCase()}catch{const i=t.toLowerCase();return i.includes("magic.link")||i.includes("/oauth")||i.includes("/authorize")||i.includes("walletconnect")}return n==="magic.link"||n.endsWith(".magic.link")||n==="privy.io"||n.endsWith(".privy.io")||n.endsWith(".walletconnect.com")||n==="verify.walletconnect.com"||n==="accounts.google.com"||n==="appleid.apple.com"||n==="login.microsoftonline.com"||n.endsWith(".auth0.com")||n.endsWith(".okta.com")||n.endsWith(".clerk.accounts.dev")||n.endsWith(".dynamic.xyz")||n.endsWith(".web3auth.io")?!0:a.includes("/oauth")||a.includes("/authorize")||a.includes("/auth/login")||a.includes("/auth/callback")||a.includes("/auth/connect")}const J4=Object.freeze({});let Vu=J4;const W0=new Set;function WW(){for(const e of W0)e()}function c2(e,t){const n=t>0?1:0;if((Vu[e]??0)===n)return;const a={...Vu};n>0?a[e]=n:delete a[e],Vu=Object.freeze(a),WW()}function YW(e,t){return e[t]??0}function X4(e,t){return YW(e,t)===0}function QW(e){return W0.add(e),()=>{W0.delete(e)}}function Z4(){return Vu}function JW(){return J4}const fc=[{id:"overview",page:ce.HOME},{id:"team-l1",page:ce.TEAM,sub:"l1"},{id:"tasks-backlog",page:ce.WORK,sub:"backlog"},{id:"tasks-kanban",page:ce.WORK,sub:"kanban"},{id:"tasks-dag",page:ce.WORK,sub:"dag"},{id:"tasks-workflows",page:ce.WORK,sub:"workflows"},{id:"deliverables",page:ce.DELIVERABLES}],XW=50,ZW=30,Wu=new Map;function Ime(e,t){return Wu.set(e,t),()=>{Wu.get(e)===t&&Wu.delete(e)}}function eY(e){return Wu.get(e)?.()}function tY(e,t){const n=fc.findIndex(a=>a.page===e&&a.sub===t);return n!==-1?n:fc.findIndex(a=>a.page===e)}function nY(e,t,n){const a=tY(e,t);if(a===-1)return null;const i=(a+n+fc.length)%fc.length;return fc[i]??null}function aY(e,t){return Math.abs(e)<XW||Math.atan2(Math.abs(t),Math.abs(e))*180/Math.PI>ZW?0:e<0?1:-1}function rY(e,t,n,a){return n<=t+1?!1:a?e+t<n-1:e>1}function iY(e,t){let n=e;for(;n&&n!==document.documentElement;){const a=getComputedStyle(n).overflowX;if((a==="auto"||a==="scroll")&&n.scrollWidth>n.clientWidth+1&&rY(n.scrollLeft,n.clientWidth,n.scrollWidth,t))return!0;n=n.parentElement}return!1}const Y0="markus:ring-sub";function sY(e,t){window.dispatchEvent(new CustomEvent(Y0,{detail:{page:e,sub:t}}))}function Lme(e){const t=n=>{const a=n.detail;a&&e(a.page,a.sub)};return window.addEventListener(Y0,t),()=>window.removeEventListener(Y0,t)}function oY(e){const t=e;if(t&&typeof t.closest=="function"&&t.closest("[data-swipe-owner]"))return!0;const n=document.querySelectorAll('[role="dialog"], [aria-modal="true"]');for(const a of n){const i=a.getBoundingClientRect();if(i.width>0&&i.height>0)return!0}return!1}function lY(e){return e?!X4(Z4(),e):!1}let Yu=null,Q0=null,d2=!1,J0=!1,pm=null,eS=null;function cY(e){if(J0=!0,eS=e.target??null,oY(e.target)){pm=null;return}const t=e.touches[0];pm=t?{x:t.clientX,y:t.clientY}:null}function dY(e){if(!J0)return;J0=!1;const t=pm;if(pm=null,!t)return;const n=e.changedTouches[0];if(!n)return;const a=aY(n.clientX-t.x,n.clientY-t.y);a!==0&&(lY(Q0?.()??null)||iY(eS,a===1)||Yu?.(a))}function uY(){d2||(document.addEventListener("touchstart",cY,{passive:!0}),document.addEventListener("touchend",dY,{passive:!0}),d2=!0)}function mY(e){const t=w.useRef(e.onStep);t.current=e.onStep;const n=w.useRef(e.activePage);n.current=e.activePage,w.useEffect(()=>{if(!e.enabled)return;const a=i=>t.current(i);return Yu=a,Q0=()=>n.current?.()??null,uY(),()=>{Yu===a&&(Yu=null),Q0=null}},[e.enabled])}const fm=new Set;let hm=!1;function pY(){hm=!0,fm.size!==0&&(hm=!1,fm.forEach(e=>e()))}function fY(e){return fm.add(e),hm&&(hm=!1,e()),()=>{fm.delete(e)}}const hY=6e4;function u2(e){const t=e.timeoutMs??hY;let n=null,a=!1;const i=()=>{n!==null&&(clearTimeout(n),n=null)},l=()=>{a||e.signal.aborted||(i(),n=setTimeout(()=>{n=null,!(a||e.signal.aborted)&&(a=!0,e.onStall?.())},t))},c=()=>i();return e.signal.addEventListener("abort",c,{once:!0}),l(),{bump(){n!==null&&l()},stop(){i(),e.signal.removeEventListener("abort",c)}}}function Pme(e,t){const n=t?.baseMs,a=t?.maxMs,i=t?.maxAttempts,l=t?.random??Math.random,c=Math.min(e,Math.max(0,i-1)),u=Math.min(n*Math.pow(2,c),a);return Math.floor(l()*u)}function Uo(e){if(e==null)return[];if(Array.isArray(e)){const t=[];for(const n of e)if(typeof n=="string"){const a=n.trim();a&&t.push(a)}else(typeof n=="number"||typeof n=="boolean")&&t.push(String(n));return t}if(typeof e=="string"){const t=e.trim();if(!t)return[];if(t.startsWith("[")||t.startsWith("{")||t.startsWith('"'))try{return Uo(JSON.parse(t))}catch{}return t.split(",").map(n=>n.trim()).filter(Boolean)}if(typeof e=="object"){const t=Object.values(e).filter(Array.isArray);return t.length===1?Uo(t[0]):[]}return[]}function su(e){if(!e||typeof e!="object")return e;const t=e;return{...t,tags:Uo(t.tags),taskIds:Uo(t.taskIds)}}function gY(e){if(!e||typeof e!="object")return e;const t=e;return{...t,tags:Uo(t.tags)}}function Hh(e){if(!e||typeof e!="object")return e;const t=e;return{...t,blockedBy:Uo(t.blockedBy)}}const bY=["cloudflare_quick","cloudflare_named","tailscale_funnel","tailscale_serve","custom"],yY=["unknown","up","down"],vY=[...bY,"relay_legacy"],xY=["idle","installing","starting","verifying","ready","degraded","error"],wY="remote.markus.global",kY="https://www.markus.global",m2=[{kind:"cloudflare_quick",recommended:!1,barrier:"low",stability:"low",needsAccount:!1,needsDomain:!1,binary:"cloudflared",reachesHub:!0},{kind:"cloudflare_named",recommended:!0,barrier:"medium",stability:"high",needsAccount:!0,needsDomain:!0,binary:"cloudflared",reachesHub:!0},{kind:"tailscale_funnel",recommended:!1,barrier:"low",stability:"high",needsAccount:!0,needsDomain:!1,binary:"tailscale",reachesHub:!0},{kind:"tailscale_serve",recommended:!1,barrier:"low",stability:"high",needsAccount:!0,needsDomain:!1,binary:"tailscale",reachesHub:!1},{kind:"custom",recommended:!1,barrier:"high",stability:"medium",needsAccount:!1,needsDomain:!1,binary:null,reachesHub:!0}];function Ome(e){return m2.find(t=>t.kind===e)??m2[0]}const SY=8056;function Hme(e,t,n=SY){const a=n;switch(e){case"cloudflare_quick":return{install:t==="macos"?"brew install cloudflared":t==="linux"?"curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o /usr/local/bin/cloudflared && chmod +x /usr/local/bin/cloudflared":"winget install --id Cloudflare.cloudflared",run:`cloudflared tunnel --url http://localhost:${a}`};case"cloudflare_named":return{install:t==="macos"?"brew install cloudflared":t==="linux"?"curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o /usr/local/bin/cloudflared && chmod +x /usr/local/bin/cloudflared":"winget install --id Cloudflare.cloudflared",run:`cloudflared tunnel login && cloudflared tunnel run --url http://localhost:${a} markus`};case"tailscale_funnel":return{install:t==="macos"?"brew install tailscale":t==="linux"?"curl -fsSL https://tailscale.com/install.sh | sh":"winget install --id Tailscale.Tailscale",run:`tailscale up && tailscale funnel ${a}`};case"tailscale_serve":return{install:t==="macos"?"brew install tailscale":t==="linux"?"curl -fsSL https://tailscale.com/install.sh | sh":"winget install --id Tailscale.Tailscale",run:`tailscale up && tailscale serve ${a}`};case"custom":return{install:"# Install your own reverse proxy / FRP client (see the guide)",run:`# Point your proxy at http://localhost:${a} and expose it over HTTPS`}}}const Gi={status:"/settings/remote",detect:"/settings/remote/detect",tunnelRestart:"/settings/remote/tunnel/restart",tunnelRotate:"/settings/remote/tunnel/rotate",tunnelStop:"/settings/remote/tunnel/stop",tunnelRegister:"/settings/remote/tunnel/register",agentSetup:"/settings/remote/agent-setup",agentSetupTargets:"/settings/remote/agent-setup/targets"},CY=["install","start","resolve","register","verify","ready"],tS={path:null,kind:null,phase:"idle",remoteState:null,entryUrl:null,publicUrl:null,health:"unknown",latencyMs:null,message:null,verifyFailure:null,wasReady:!1,agentId:null,handedToChat:!1,agentContract:null};function AY(e,t){switch(e){case"idle":return"idle";case"installing":return"install";case"starting":return t.entryUrl?"verify":t.publicUrl?"register":"start";case"verifying":return"verify";case"ready":case"degraded":return"ready";case"error":return"error"}}function Bme(e){return CY.indexOf(e)}function zme(e){return e?.enabled&&e.publicUrl?{type:"addressResolved",publicUrl:e.publicUrl}:{type:"processStarted"}}function qme(e,t){switch(t.type){case"selectKind":return{...e,kind:t.kind};case"choosePath":return{...e,path:t.path};case"selectAgent":return{...e,agentId:t.agentId};case"handedToChat":return{...e,path:"agent",handedToChat:!0,agentContract:t.contract??e.agentContract,message:null,verifyFailure:null};case"beginInstall":return{...e,phase:"install",message:null,verifyFailure:null};case"installSucceeded":return{...e,phase:"start",message:null};case"installFailed":return{...e,phase:"error",message:t.message};case"processStarted":return{...e,phase:"resolve",message:null};case"addressResolved":return{...e,publicUrl:t.publicUrl,phase:"register",health:"up",message:null};case"registered":return{...e,entryUrl:t.entryUrl??e.entryUrl,phase:"verify",message:null};case"verifyStarted":return{...e,phase:"verify",message:null};case"verifyFailed":return{...e,phase:"error",verifyFailure:t.reason,message:t.message??null};case"ready":return{...e,phase:"ready",wasReady:!0,verifyFailure:null,message:null,health:"up"};case"degraded":return{...e,phase:"ready",wasReady:!0,message:t.message??e.message};case"disconnected":return e.wasReady?{...e,phase:"reconnecting",publicUrl:null,health:"down"}:{...e,phase:"error",health:"down",message:t.message??null};case"userError":return{...e,phase:"error",message:t.message};case"reset":return{...tS,kind:e.kind,path:e.path};case"status":return TY(e,t.status)}}function TY(e,t){if(!t.enabled)return{...tS,kind:e.kind,path:e.path};const n={...e,remoteState:t.state,entryUrl:t.entryUrl??e.entryUrl,publicUrl:t.publicUrl??e.publicUrl,health:t.health,latencyMs:t.latencyMs??null,message:t.message??null};return t.state==="ready"||t.state==="degraded"?{...n,phase:"ready",wasReady:!0,verifyFailure:null}:t.state==="error"?{...n,phase:"error"}:e.phase==="ready"||e.phase==="reconnecting"?{...n,phase:"reconnecting",wasReady:!0}:{...n,phase:AY(t.state,n)}}const Bh=(e,t)=>typeof t=="string"&&e.includes(t);function EY(e){if(!e||typeof e!="object")return null;const t=e;if(Bh(vY,t.mode)&&Bh(xY,t.state))return{enabled:t.enabled===!0,mode:t.mode,state:t.state,entryUrl:typeof t.entryUrl=="string"?t.entryUrl:null,publicUrl:typeof t.publicUrl=="string"?t.publicUrl:null,health:Bh(yY,t.health)?t.health:"unknown",latencyMs:typeof t.latencyMs=="number"?t.latencyMs:void 0,message:typeof t.message=="string"?t.message:void 0};if(typeof t.enabled=="boolean"||typeof t.state=="string"){const n=t.connected===!0,a=typeof t.state=="string"?t.state:"idle";return{enabled:t.enabled===!0,mode:"relay_legacy",state:NY(a,n),entryUrl:null,publicUrl:typeof t.remoteUrl=="string"?t.remoteUrl:null,health:n?"up":"unknown"}}return null}function NY(e,t){switch(e){case"registering":case"connecting":return"starting";case"connected":return"ready";case"disconnected":return t?"ready":"error";default:return"idle"}}function $me(e){return e?`https://${e}.${wY}`:null}function Fme(e){return`${`${kY}/auth/login`}?redirect=${encodeURIComponent(e)}`}function Ume(e){const t=e.toLowerCase();return t.includes("mac")||t.includes("darwin")?"macos":t.includes("win")?"windows":"linux"}const Rs="/api";class nS extends Error{code;status;constructor(t,n,a){super(t),this.code=n,this.status=a}}const X0="markus:auth-expired";function Gme(e){return e instanceof nS&&(e.code==="AUTH_REQUIRED"||e.status===401&&e.code!==void 0)}let Z0=!1;function MY(){Z0||(Z0=!0,window.dispatchEvent(new CustomEvent(X0)))}function p2(){Z0=!1}const Ji=new Map,jY=3e3;function RY(e){if(!e){Ji.clear();return}for(const t of Ji.keys())t.startsWith(e)&&Ji.delete(t)}async function K(e,t){const a=(t?.method?.toUpperCase()??"GET")==="GET"&&!t?.body;if(a){const l=Ji.get(e);if(l&&Date.now()-l.ts<jY)return l.promise}else{const l=e.replace(/\/[^/]+$/,"");for(const c of Ji.keys())(c===e||c.startsWith(l))&&Ji.delete(c)}const i=(async()=>{const l=await fetch(`${Rs}${e}`,{headers:{"Content-Type":"application/json"},credentials:"include",...t,body:t?.body?typeof t.body=="string"?t.body:JSON.stringify(t.body):void 0});if(!l.ok){let c="",u;try{const m=await l.json();c=m.error??m.message??"",u=m.code}catch{}throw l.status===401&&!e.startsWith("/auth")&&MY(),new nS(c||`API error: ${l.status}`,u,l.status)}return l.json()})();return a&&(Ji.set(e,{promise:i,ts:Date.now()}),i.catch(()=>Ji.delete(e))),i}function f2(e,t){if(e.onThinking){e.onThinking(t);return}e.onChunk?.(`<think>${t}</think>`)}const _Y={list:(e="")=>K(`/facts${e}`)},Se={externalSignals:{getIngress:e=>K(`/orgs/${encodeURIComponent(e)}/external-ingress`),setIngress:(e,t)=>K(`/orgs/${encodeURIComponent(e)}/external-ingress`,{method:"POST",body:JSON.stringify({policy:t})}),list:e=>K(`/external-sources?agentId=${encodeURIComponent(e)}`),setEnabled:(e,t,n)=>K(`/external-sources/${encodeURIComponent(t)}/toggle`,{method:"POST",body:JSON.stringify({agentId:e,enabled:n})}),rotateSecret:(e,t)=>K(`/external-sources/${encodeURIComponent(t)}/token`,{method:"POST",body:JSON.stringify({agentId:e})})},agents:{list:e=>K(`/agents${e?.lean?"?lean=1":""}`).then(t=>({...t,agents:t.agents.filter(n=>n.name)})),get:e=>K(`/agents/${e}`),create:(e,t,n,a)=>K("/agents",{method:"POST",body:JSON.stringify({name:e,...t?{roleName:t}:{},agentRole:n,teamId:a})}),start:e=>K(`/agents/${e}/start`,{method:"POST"}),stop:e=>K(`/agents/${e}/stop`,{method:"POST"}),cancelProcessing:(e,t)=>K(`/agents/${e}/cancel-processing`,{method:"POST",body:t?JSON.stringify(t):void 0,headers:t?{"Content-Type":"application/json"}:void 0}),dropMailboxItem:(e,t,n)=>K(`/agents/${e}/mailbox/${encodeURIComponent(t)}/drop`,{method:"POST",body:JSON.stringify({reason:n}),headers:{"Content-Type":"application/json"}}),recoverStaleMailbox:e=>K(`/agents/${e}/mailbox/recover-stale`,{method:"POST"}),evolveFromMessage:(e,t)=>K(`/agents/${e}/evolve-from-message`,{method:"POST",body:JSON.stringify(t)}),remove:(e,t)=>K(`/agents/${e}${t?.purgeFiles?"?purgeFiles=true":""}`,{method:"DELETE"}),updateConfig:(e,t)=>K(`/agents/${e}/config`,{method:"PATCH",body:JSON.stringify(t)}),getMemory:e=>K(`/agents/${e}/memory`),getMemorySession:(e,t)=>K(`/agents/${e}/memory/sessions/${encodeURIComponent(t)}`),updateDailyMemory:(e,t)=>K(`/agents/${e}/memory/daily`,{method:"PUT",body:JSON.stringify({content:t})}),updateLongTermMemory:(e,t,n)=>K(`/agents/${e}/memory/longterm`,{method:"PUT",body:JSON.stringify({key:t,content:n})}),getFiles:e=>K(`/agents/${e}/files`),getFilesMap:e=>K(`/agents/${e}/files`),updateFile:(e,t,n)=>K(`/agents/${e}/files/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({content:n})}),updateSystemPrompt:(e,t)=>K(`/agents/${e}/system-prompt`,{method:"PUT",body:JSON.stringify({systemPrompt:t})}),roleStatus:e=>K(`/agents/${e}/role-status`),roleDiff:(e,t="ROLE.md")=>K(`/agents/${e}/role-diff?file=${encodeURIComponent(t)}`),roleSync:(e,t)=>K(`/agents/${e}/role-sync`,{method:"POST",body:JSON.stringify(t?{files:t}:{})}),roleSmartSync:(e,t)=>K(`/agents/${e}/role-smart-sync`,{method:"POST",body:JSON.stringify({file:t})}),roleUpdates:()=>K("/agents/role-updates"),addSkill:(e,t)=>K(`/agents/${e}/skills`,{method:"POST",body:JSON.stringify({skillName:t})}),removeSkill:(e,t)=>K(`/agents/${e}/skills/${encodeURIComponent(t)}`,{method:"DELETE"}),getHeartbeat:e=>K(`/agents/${e}/heartbeat`),storage:e=>K(`/agents/${e}/storage`),sendToAgent:(e,t)=>K("/message",{method:"POST",body:JSON.stringify({targetAgentId:e,text:t})}),triggerHeartbeat:e=>K(`/agents/${e}/heartbeat/trigger`,{method:"POST"}),cancelWakeup:(e,t)=>K(`/agents/${e}/wakeups/${t}`,{method:"DELETE"}),getRecentActivities:e=>K(`/agents/${e}/recent-activities`),getActivityLogs:(e,t)=>K(`/agents/${e}/activity-logs?activityId=${encodeURIComponent(t)}`),getActivities:(e,t)=>{const n=new URLSearchParams;t?.type&&n.set("type",t.type),t?.limit&&n.set("limit",String(t.limit)),t?.before&&n.set("before",t.before),t?.taskId&&n.set("taskId",t.taskId);const a=n.toString();return K(`/agents/${e}/activities${a?"?"+a:""}`)},getMindState:e=>K(`/agents/${e}/mind`),sendCommand:(e,t,n)=>K(`/agents/${e}/command`,{method:"POST",body:JSON.stringify({command:t,args:n})}),getMailbox:(e,t)=>{const n=new URLSearchParams;t?.limit&&n.set("limit",String(t.limit)),t?.offset&&n.set("offset",String(t.offset)),t?.category&&n.set("category",t.category),t?.sourceType&&n.set("sourceType",t.sourceType),t?.status&&n.set("status",t.status),t?.itemId&&n.set("itemId",t.itemId),t?.mode&&n.set("mode",t.mode),t?.entity&&n.set("entity",t.entity),t?.entityKind&&n.set("entityKind",t.entityKind);const a=n.toString();return K(`/agents/${e}/mailbox${a?"?"+a:""}`)},workUnits:(e,t="running",n=50)=>K(`/agents/${e}/work-units?status=${encodeURIComponent(t)}&limit=${n}`),getDecisions:(e,t=50)=>K(`/agents/${e}/decisions?limit=${t}`),messageStream:(e,t,n,a)=>new Promise(async(i,l)=>{const{signal:c,images:u,sessionId:m,isRetry:f,isResume:g,fileNames:h,replyTo:b,titleSource:y,chips:k,userMessageId:C,assistantMessageId:T}=a??{};let A=!1,M="",I,B,G,j=null;try{const O=await fetch(`${Rs}/agents/${e}/message`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({text:t,stream:!0,images:u,fileNames:h,sessionId:m??void 0,isRetry:f||void 0,isResume:g||void 0,replyTo:b||void 0,titleSource:y||void 0,chips:k&&k.length>0?k:void 0,userMessageId:C||void 0,assistantMessageId:T||void 0}),signal:c});if(!O.ok){l(new Error(`API error: ${O.status}`));return}const F=O.body?.getReader();if(!F){l(new Error("No reader"));return}const Y=new TextDecoder;let q="";for(c&&(j=u2({signal:c,onStall:()=>{F.cancel().catch(()=>{})}}));;){const{done:V,value:z}=await F.read();if(j?.bump(),V)break;q+=Y.decode(z,{stream:!0});const J=q.split(`
|
|
518
518
|
`);q=J.pop()??"";for(const D of J){const ee=D.trim();if(ee.startsWith("data: "))try{const R=JSON.parse(ee.slice(6));if(R.type==="session_start"&&R.sessionId){I=R.sessionId;const te=R.userMessageId;n.onCommit?.({type:"session_start",content:"",createdAt:new Date().toISOString(),sessionId:R.sessionId,userMessageId:te})}else if(R.type==="text_delta"&&R.text)M+=R.text,n.onChunk?.(R.text);else if(R.type==="thinking_delta"&&R.thinking)f2(n,R.thinking);else if(R.type==="done"){A=!0,M=R.content||M,R.sessionId&&(I=R.sessionId);{const W=R.messageId??R.assistantMessageId??R.agentMessageId;typeof W=="string"&&W&&(G=W)}const te=R.segments;te&&(B=te);const le=!!R.merged,ke=!!R.cancelled,$=!!R.emptyReply;i({content:M,sessionId:I,segments:B,merged:le,cancelled:ke,emptyReply:$,messageId:G}),F.cancel().catch(()=>{}),j?.stop();return}else if(R.type==="error"){const te=R;te.sessionId&&(I=te.sessionId);const le=new Error(te.message??te.error??"Unknown stream error");le.sessionId=te.sessionId,l(le),F.cancel().catch(()=>{}),j?.stop();return}else R.type==="thinking_commit"&&R.thinking?n.onCommit?.({type:"thinking_commit",content:R.thinking,createdAt:R.createdAt??new Date().toISOString()}):R.type==="text_commit"&&R.text?n.onCommit?.({type:"text_commit",content:R.text,createdAt:R.createdAt??new Date().toISOString()}):R.type==="tool_call_start"&&R.toolCall?.name?n.onActivity?.({tool:R.toolCall.name,phase:"start"}):R.type==="agent_tool"&&R.tool&&R.phase?R.phase==="start"?n.onActivity?.({tool:R.tool,phase:"start",arguments:R.arguments}):R.phase==="end"&&n.onActivity?.({tool:R.tool,phase:"end",success:R.success,arguments:R.arguments,result:R.result,error:R.error,durationMs:R.durationMs}):R.type==="tool_output"&&R.tool?n.onActivity?.({tool:R.tool,phase:"output",output:R.text}):R.type==="subagent_progress"&&R.tool?n.onActivity?.({tool:R.tool,phase:"subagent_progress",subagentEvent:R.subagentEvent}):R.type==="heartbeat"&&n.onActivity?.({tool:"",phase:"heartbeat"})}catch{}}}j?.stop(),i({content:M,sessionId:I,segments:B,messageId:G,softDisconnected:!A})}catch(O){j?.stop(),O instanceof Error&&O.name==="AbortError"?i({content:M,sessionId:I,segments:B,messageId:G,softDisconnected:!A}):l(O)}})},roles:{list:()=>K("/roles")},teams:{list:e=>K(`/teams?orgId=${e??"default"}`),create:(e,t)=>K("/teams",{method:"POST",body:JSON.stringify({name:e,description:t})}),update:(e,t)=>K(`/teams/${e}`,{method:"PATCH",body:JSON.stringify(t)}),delete:(e,t,n)=>K(`/teams/${e}?deleteMembers=${t?"true":"false"}${n?.purgeFiles?"&purgeFiles=true":""}`,{method:"DELETE"}),addMember:(e,t,n)=>K(`/teams/${e}/members`,{method:"POST",body:JSON.stringify({memberId:t,memberType:n})}),removeMember:(e,t)=>K(`/teams/${e}/members/${t}`,{method:"DELETE"}),startAll:e=>K(`/teams/${e}/start`,{method:"POST"}),stopAll:e=>K(`/teams/${e}/stop`,{method:"POST"}),status:e=>K(`/teams/${e}/status`),getFiles:e=>K(`/teams/${e}/files`),getFile:(e,t)=>K(`/teams/${e}/files/${encodeURIComponent(t)}`),updateFile:(e,t,n)=>K(`/teams/${e}/files/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({content:n})}),exportTeam:e=>K(`/teams/${e}/export`,{method:"POST"}),getFilesMap:e=>K(`/teams/${e}/export`)},externalAgents:{list:e=>K(`/external-agents?orgId=${e??"default"}`)},tasks:{list:e=>{const t=new URLSearchParams;e?.lean&&t.set("lean","1"),e?.assignedAgentId&&t.set("assignedAgentId",e.assignedAgentId),e?.status&&t.set("status",e.status),e?.projectId&&t.set("projectId",e.projectId),e?.requirementId&&t.set("requirementId",e.requirementId),e?.priority&&t.set("priority",e.priority),e?.search&&t.set("search",e.search),e?.sortBy&&t.set("sortBy",e.sortBy),e?.sortOrder&&t.set("sortOrder",e.sortOrder),e?.page!==null&&e?.page!==void 0&&t.set("page",String(e.page)),e?.pageSize!==null&&e?.pageSize!==void 0&&t.set("pageSize",String(e.pageSize));const n=t.toString();return K(`/tasks${n?`?${n}`:""}`).then(a=>({...a,tasks:(a.tasks??[]).map(Hh)}))},get:e=>K(`/tasks/${e}`).then(t=>({...t,task:{...Hh(t.task),threadStage:t.threadStage,evidence:t.evidence??[]}})),create:(e,t,n,a,i,l,c,u,m,f,g)=>K("/tasks",{method:"POST",body:JSON.stringify({title:e,description:t,assignedAgentId:n,reviewerId:a,priority:i,projectId:l,blockedBy:c,requirementId:u,taskType:m,scheduleConfig:f,reviewerType:g})}),update:(e,t)=>K(`/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)}),updateStatus:(e,t)=>K(`/tasks/${e}`,{method:"PUT",body:JSON.stringify({status:t})}),assign:(e,t)=>K(`/tasks/${e}`,{method:"PUT",body:JSON.stringify({assignedAgentId:t})}),approve:(e,t)=>K(`/tasks/${e}/approve`,{method:"POST",body:JSON.stringify({runNow:t??void 0})}),reject:e=>K(`/tasks/${e}/reject`,{method:"POST"}),requestApproval:e=>K(`/tasks/${e}/request-approval`,{method:"POST"}),cancel:(e,t=!1)=>K(`/tasks/${e}/cancel`,{method:"POST",body:JSON.stringify({cascade:t})}),getDependentCount:e=>K(`/tasks/${e}/dependents`),board:e=>{const t=new URLSearchParams;e?.projectId&&t.set("projectId",e.projectId);const n=t.toString();return K(`/taskboard${n?`?${n}`:""}`).then(a=>({...a,board:Object.fromEntries(Object.entries(a.board??{}).map(([i,l])=>[i,(l??[]).map(Hh)]))}))},boardSummary:e=>{const t=new URLSearchParams;e?.projectId&&t.set("projectId",e.projectId);const n=t.toString();return K(`/taskboard/summary${n?`?${n}`:""}`)},listSubtasks:e=>K(`/tasks/${e}/subtasks`),createSubtask:(e,t)=>K(`/tasks/${e}/subtasks`,{method:"POST",body:JSON.stringify({title:t})}),completeSubtask:(e,t)=>K(`/tasks/${e}/subtasks/${t}/complete`,{method:"POST"}),cancelSubtask:(e,t)=>K(`/tasks/${e}/subtasks/${t}/cancel`,{method:"POST"}),deleteSubtask:(e,t)=>K(`/tasks/${e}/subtasks/${t}`,{method:"DELETE"}),run:e=>K(`/tasks/${e}/run`,{method:"POST"}),getLogs:(e,t)=>K(`/tasks/${e}/logs${t!=null?`?round=${t}`:""}`),getLogsSummary:e=>K(`/tasks/${e}/logs/summary`),accept:(e,t)=>K(`/tasks/${e}/accept`,{method:"POST",body:JSON.stringify({reviewerId:t??"human"})}),revision:(e,t,n)=>K(`/tasks/${e}/revision`,{method:"POST",body:JSON.stringify({reason:t,reviewerId:n??"human"})}),archive:e=>K(`/tasks/${e}/archive`,{method:"POST"}),pause:e=>K(`/tasks/${e}/pause`,{method:"POST"}),resume:e=>K(`/tasks/${e}/resume`,{method:"POST"}),retry:e=>K(`/tasks/${e}/retry`,{method:"POST"}),getComments:e=>K(`/tasks/${e}/comments`),getHistory:e=>K(`/tasks/${e}/history`),addComment:(e,t,n,a,i,l,c)=>K(`/tasks/${e}/comments`,{method:"POST",body:JSON.stringify({content:t,authorId:i??"human",authorName:n??"User",authorType:"human",attachments:a,mentions:l,replyTo:c})}),pauseSchedule:e=>K(`/tasks/${e}/schedule/pause`,{method:"POST"}),resumeSchedule:e=>K(`/tasks/${e}/schedule/resume`,{method:"POST"}),runNow:e=>K(`/tasks/${e}/schedule/run-now`,{method:"POST"}),updateSchedule:(e,t)=>K(`/tasks/${e}/schedule`,{method:"PUT",body:JSON.stringify(t)}),deliverables:e=>{const t=e?`?projectId=${encodeURIComponent(e)}`:"";return K(`/tasks/deliverables${t}`)}},files:{preview:e=>K(`/files/preview?path=${encodeURIComponent(e)}`),streamUrl:e=>`${Rs}/files/stream?path=${encodeURIComponent(e)}`,stat:e=>K(`/files/stat?path=${encodeURIComponent(e)}`),reveal:e=>K("/files/reveal",{method:"POST",body:JSON.stringify({path:e})}),check:e=>K("/files/check",{method:"POST",body:JSON.stringify({paths:e})}),write:(e,t)=>K("/files/write",{method:"POST",body:JSON.stringify({path:e,content:t})})},requirements:{list:e=>{const t=new URLSearchParams;e?.orgId&&t.set("orgId",e.orgId),e?.status&&t.set("status",e.status),e?.source&&t.set("source",e.source),e?.projectId&&t.set("projectId",e.projectId),e?.limit&&t.set("limit",String(e.limit)),e?.offset&&t.set("offset",String(e.offset)),e?.lean&&t.set("lean","1");const n=t.toString();return K(`/requirements${n?`?${n}`:""}`).then(a=>({...a,requirements:(a.requirements??[]).map(su)}))},get:e=>K(`/requirements/${e}`).then(t=>({...t,requirement:su(t.requirement)})),create:e=>K("/requirements",{method:"POST",body:JSON.stringify(e)}).then(t=>({...t,requirement:su(t.requirement)})),update:(e,t)=>K(`/requirements/${e}`,{method:"PUT",body:JSON.stringify(t)}).then(n=>({...n,requirement:su(n.requirement)})),updateStatus:(e,t)=>K(`/requirements/${e}/status`,{method:"POST",body:JSON.stringify({status:t})}),approve:e=>K(`/requirements/${e}/approve`,{method:"POST"}),approveTasksBulk:(e,t)=>K(`/requirements/${e}/tasks/approve-bulk`,{method:"POST",body:JSON.stringify({dryRun:t?.dryRun===!0,runNow:t?.runNow!==!1})}),reject:(e,t)=>K(`/requirements/${e}/reject`,{method:"POST",body:JSON.stringify({reason:t})}),requestApproval:e=>K(`/requirements/${e}/request-approval`,{method:"POST"}),cancel:e=>K(`/requirements/${e}/cancel`,{method:"POST"}),delete:e=>K(`/requirements/${e}`,{method:"DELETE"}),getComments:e=>K(`/requirements/${e}/comments`),getHistory:e=>K(`/requirements/${e}/history`),addComment:(e,t,n,a,i,l,c)=>K(`/requirements/${e}/comments`,{method:"POST",body:JSON.stringify({content:t,authorId:i??"human",authorName:n??"User",authorType:"human",attachments:a,mentions:l,replyTo:c})})},users:{list:e=>K(`/users?orgId=${e??"default"}`),create:(e,t,n,a,i,l)=>K("/users",{method:"POST",body:JSON.stringify({name:e,role:t,orgId:n,email:a,password:i,teamId:l})}),update:(e,t)=>K(`/users/${e}`,{method:"PATCH",body:JSON.stringify(t)}),resetPassword:(e,t)=>K(`/users/${e}/reset-password`,{method:"POST",body:JSON.stringify({password:t})}),reinvite:e=>K(`/users/${e}/reinvite`,{method:"POST"}),remove:e=>K(`/users/${e}`,{method:"DELETE"})},teamTemplates:{list:e=>{const t=e?`?q=${encodeURIComponent(e)}`:"";return K(`/team-templates${t}`)},get:e=>K(`/team-templates/${e}`)},ops:{dashboard:(e="24h")=>K(`/ops/dashboard?period=${e}`)},agentMetrics:(e,t="24h")=>K(`/agents/${e}/metrics?period=${t}`),usage:{summary:(e="default",t)=>{const n=new URLSearchParams({orgId:e});return t&&n.set("period",t),K(`/usage?${n}`)},agents:(e="default")=>K(`/usage/agents?orgId=${e}`)},cu:{status:()=>K("/cu/status")},health:()=>K("/health"),system:{openPath:e=>K("/system/open-path",{method:"POST",body:JSON.stringify({path:e})}),storage:()=>K("/system/storage"),info:()=>K("/system/info"),orphans:()=>K("/system/storage/orphans"),purgeOrphans:e=>K("/system/storage/orphans",{method:"DELETE",body:e?JSON.stringify({ids:e}):void 0})},browser:{tabOwnership:()=>K("/browser/tab-ownership")},terminal:{sessionOwnership:()=>K("/terminal/session-ownership")},settings:{getLlm:()=>K("/settings/llm"),getOrg:()=>K("/settings/org"),updateOrg:e=>K("/settings/org",{method:"PUT",body:JSON.stringify({name:e})}),syncOpenRouter:()=>K("/settings/llm/sync-openrouter",{method:"POST",body:JSON.stringify({})}),getRouting:()=>K("/settings/llm/routing"),updateRouting:e=>K("/settings/llm",{method:"POST",body:JSON.stringify(e)}),getAgent:()=>K("/settings/agent"),updateAgent:e=>K("/settings/agent",{method:"POST",body:JSON.stringify(e)}),getBrowser:()=>K("/settings/browser"),updateBrowser:e=>K("/settings/browser",{method:"POST",body:JSON.stringify(e)}),testAutoClick:()=>K("/settings/browser/test-auto-click",{method:"POST"}),downloadExtensionZip:()=>{const e=`${Rs}/settings/browser/extension.zip`,t={},n=localStorage.getItem("markus_token");return n&&(t.Authorization=`Bearer ${n}`),fetch(e,{headers:t}).then(a=>{if(!a.ok)throw new Error(`HTTP ${a.status}`);return a.blob()}).then(a=>{const i=document.createElement("a");i.href=URL.createObjectURL(a),i.download="markus-browser-extension.zip",i.click(),URL.revokeObjectURL(i.href)})},openExtensionsPage:()=>K("/settings/browser/open-extensions-page",{method:"POST"}),testConcurrentBrowserQuick:()=>K("/settings/browser/test-concurrent",{method:"POST",body:JSON.stringify({mode:"quick"})}),testConcurrentBrowserChaos:async(e,t)=>{const n={"Content-Type":"application/json"},a=localStorage.getItem("markus_token");a&&(n.Authorization=`Bearer ${a}`);const i=await fetch(`${Rs}/settings/browser/test-concurrent`,{method:"POST",headers:n,body:JSON.stringify({mode:"chaos",durationSec:e.durationSec??120,agents:e.agents??3})});if(!i.ok)throw new Error(`HTTP ${i.status}`);const l=i.body.getReader(),c=new TextDecoder;let u="";for(;;){const{done:m,value:f}=await l.read();if(m)break;u+=c.decode(f,{stream:!0});const g=u.split(`
|
|
519
519
|
`);u=g.pop()??"";let h="";for(const b of g)if(b.startsWith("event: "))h=b.slice(7).trim();else if(b.startsWith("data: ")){try{t({type:h||"unknown",...JSON.parse(b.slice(6))})}catch{}h=""}}},stopConcurrentBrowserTest:()=>K("/settings/browser/test-concurrent",{method:"DELETE"}),getSearch:()=>K("/settings/search"),updateSearch:e=>K("/settings/search",{method:"POST",body:JSON.stringify(e)}),testSearch:(e,t)=>K("/settings/search/test",{method:"POST",body:JSON.stringify({provider:e,...t})}),getRemote:()=>K("/settings/remote"),enableRemote:()=>K("/settings/remote/enable",{method:"POST"}),disableRemote:()=>K("/settings/remote/disable",{method:"POST"}),getRemoteV2:async()=>EY(await K(Gi.status)),remoteDetect:()=>K(Gi.detect),remoteTunnelRestart:()=>K(Gi.tunnelRestart,{method:"POST"}),remoteTunnelRotate:()=>K(Gi.tunnelRotate,{method:"POST"}),remoteTunnelStop:()=>K(Gi.tunnelStop,{method:"POST"}),remoteTunnelRegister:e=>K(Gi.tunnelRegister,{method:"POST",body:JSON.stringify(e)}),remoteAgentSetup:e=>K(Gi.agentSetup,{method:"POST",body:JSON.stringify(e)}),remoteSetupTargets:()=>K(Gi.agentSetupTargets),sendFeishuTestMessage:e=>K("/settings/integrations/feishu/test-message",{method:"POST",body:JSON.stringify(e)}),listFeishuChats:()=>K("/settings/integrations/feishu/chats"),registerFeishuApp:e=>K("/settings/integrations/feishu/register",{method:"POST",body:JSON.stringify(e??{})}),getFeishuRegisterStatus:()=>K("/settings/integrations/feishu/register/status"),listIntegrations:()=>K("/settings/integrations"),getIntegration:e=>K(`/settings/integrations/${encodeURIComponent(e)}`),saveIntegration:(e,t)=>K(`/settings/integrations/${encodeURIComponent(e)}`,{method:"POST",body:JSON.stringify(t)}),deleteIntegration:e=>K(`/settings/integrations/${encodeURIComponent(e)}`,{method:"DELETE"}),testIntegration:(e,t)=>K(`/settings/integrations/${encodeURIComponent(e)}/test`,{method:"POST",body:JSON.stringify(t??{})}),listInstances:()=>K("/settings/integrations/instances"),createInstance:(e,t)=>K("/settings/integrations/instances",{method:"POST",body:JSON.stringify({platform:e,label:t})}),saveInstance:(e,t)=>K(`/settings/integrations/instances/${encodeURIComponent(e)}`,{method:"POST",body:JSON.stringify(t)}),deleteInstance:e=>K(`/settings/integrations/instances/${encodeURIComponent(e)}`,{method:"DELETE"}),testInstance:(e,t)=>K(`/settings/integrations/instances/${encodeURIComponent(e)}/test`,{method:"POST",body:JSON.stringify(t??{})}),startConnectionTest:(e,t)=>K(`/settings/integrations/instances/${encodeURIComponent(e)}/connection-test`,{method:"POST",body:JSON.stringify(t??{})}),getConnectionTest:e=>K(`/settings/integrations/instances/${encodeURIComponent(e)}/connection-test`),listInstanceChannels:e=>K(`/settings/integrations/instances/${encodeURIComponent(e)}/channels`),saveInstanceChannels:(e,t)=>K(`/settings/integrations/instances/${encodeURIComponent(e)}/channels`,{method:"PUT",body:JSON.stringify({channels:t})}),getCodingTools:()=>K("/settings/coding-tools"),updateCodingTools:e=>K("/settings/coding-tools",{method:"POST",body:JSON.stringify(e)}),detectCodingTools:()=>K("/settings/coding-tools/detect"),detectCodingTool:e=>K(`/settings/coding-tools/detect/${e}`),authCodingTool:(e,t,n)=>K(`/settings/coding-tools/${e}/auth`,{method:"POST",body:JSON.stringify({method:t,apiKey:n})}),listCodingToolModels:e=>K(`/settings/coding-tools/${e}/models`),testCodingTool:e=>K(`/settings/coding-tools/${e}/test`,{method:"POST"})},modelCatalog:{getByProvider:e=>K(`/models/catalog/${e}`),getLive:e=>K(`/models/live/${e}`),getAll:e=>{const t=e?`?provider=${e}`:"";return K(`/models/catalog${t}`)},getStatus:()=>K("/models/catalog/status"),providerCatalog:()=>K("/llm/provider-catalog"),refresh:()=>K("/models/catalog/refresh",{method:"POST"}),validateKey:(e,t,n)=>K("/models/validate-key",{method:"POST",body:JSON.stringify({provider:e,apiKey:t,baseUrl:n})})},skills:{list:()=>K("/skills"),builtin:()=>K("/skills/builtin"),updates:()=>K("/skills/updates"),registry:e=>K(`/skills/registry${e?`?source=${e}`:""}`),registrySkillhub:e=>{const t=new URLSearchParams;e?.q&&t.set("q",e.q),e?.category&&t.set("category",e.category),e?.page&&t.set("page",String(e.page)),e?.limit&&t.set("limit",String(e.limit)),e?.sort&&t.set("sort",e.sort);const n=t.toString();return K(`/skills/registry/skillhub${n?`?${n}`:""}`)},registrySkillssh:e=>K(`/skills/registry/skillssh${e?`?q=${encodeURIComponent(e)}`:""}`),import:(e,t,n,a)=>K("/skills/import",{method:"POST",body:JSON.stringify({name:e,sourceUrl:t,description:n,category:a})}),install:e=>K("/skills/install",{method:"POST",body:JSON.stringify(e)}),uninstall:e=>K(`/skills/installed/${encodeURIComponent(e)}`,{method:"DELETE"}),getFilesMap:e=>K(`/skills/${encodeURIComponent(e)}/files`)},builder:{artifacts:{list:()=>K("/builder/artifacts"),get:(e,t)=>K(`/builder/artifacts/${e}s/${encodeURIComponent(t)}`),save:(e,t)=>K("/builder/artifacts/save",{method:"POST",body:JSON.stringify({mode:e,artifact:t})}),import:(e,t,n,a,i)=>K("/builder/artifacts/import",{method:"POST",body:JSON.stringify({type:e,name:t,files:n,source:a,version:i})}),install:(e,t)=>K(`/builder/artifacts/${e}s/${encodeURIComponent(t)}/install`,{method:"POST"}),uninstall:(e,t)=>K(`/builder/artifacts/${e}s/${encodeURIComponent(t)}/uninstall`,{method:"POST"}),delete:(e,t)=>K(`/builder/artifacts/${e}s/${encodeURIComponent(t)}`,{method:"DELETE"}),ensureSlug:(e,t)=>K(`/builder/artifacts/${e}s/${encodeURIComponent(t)}/ensure-slug`,{method:"POST"}),ensureSlugSafe:async(e,t,n)=>{const a=jc(t);if(a&&a===t)return{converted:!1,type:e,name:t,slug:a,displayName:n,path:""};try{return await Se.builder.artifacts.ensureSlug(e,t)}catch(i){if(a)return{converted:!1,type:e,name:a,slug:a,displayName:n,path:""};throw i}},installed:()=>K("/builder/artifacts/installed")}},auth:{status:()=>K("/auth/status"),init:(e,t,n)=>K("/auth/init",{method:"POST",body:JSON.stringify({name:e,email:t,password:n})}),login:(e,t)=>K("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:t})}),hubLogin:(e,t)=>K("/auth/hub-login",{method:"POST",body:JSON.stringify({hubToken:e,hubUser:t})}),logout:()=>K("/auth/logout",{method:"POST"}),me:()=>K("/auth/me"),changePassword:(e,t)=>K("/auth/change-password",{method:"POST",body:JSON.stringify({currentPassword:e,newPassword:t})}),updateProfile:(e,t)=>K("/auth/profile",{method:"PUT",body:JSON.stringify({name:e,email:t})}),updatePreferences:e=>K("/auth/me/preferences",{method:"PUT",body:JSON.stringify(e)}),setup:(e,t)=>K("/auth/setup",{method:"POST",body:JSON.stringify({token:e,password:t})}),inviteInfo:e=>K(`/auth/invite-info?token=${encodeURIComponent(e)}`),uploadAvatar:(e,t="user",n)=>K("/avatars/upload",{method:"POST",body:JSON.stringify({image:e,type:t,id:n})})},sessions:{hasAny:()=>K("/sessions/has-any"),create:e=>K(`/agents/${e}/sessions`,{method:"POST"}),listByAgent:(e,t=10,n=1)=>K(`/agents/${e}/sessions?page=${n}&limit=${t}`),renameTitle:(e,t)=>K(`/sessions/${e}/title`,{method:"PATCH",body:JSON.stringify({title:t})}),getMessages:(e,t=30,n)=>K(`/sessions/${e}/messages?limit=${t}${n?`&before=${n}`:""}`),getMessageDetail:(e,t)=>K(`/sessions/${e}/messages/${encodeURIComponent(t)}`),delete:e=>K(`/sessions/${e}`,{method:"DELETE"}),setModelOverride:(e,t)=>K(`/sessions/${e}/model-override`,{method:"PUT",body:JSON.stringify(t??{provider:"",model:""})}),streamStatus:(e,t)=>K(`/agents/${e}/sessions/${t}/stream/status`),streamStatusBatch:(e,t)=>K("/sessions/stream/status",{method:"POST",body:JSON.stringify({agentId:e,sessionIds:t}),headers:{"Content-Type":"application/json"}}),reattachStream:(e,t,n,a,i=0)=>new Promise(async(l,c)=>{let u="",m=t,f,g,h=null;try{const b=await fetch(`${Rs}/agents/${e}/sessions/${t}/stream?afterSeq=${i}`,{method:"GET",credentials:"include",signal:a});if(b.status===204){l({content:"",sessionId:t,attached:!1,terminal:!1});return}if(!b.ok){c(new Error(`API error: ${b.status}`));return}const y=b.body?.getReader();if(!y){c(new Error("No reader"));return}const k=new TextDecoder;let C="",T=!1;for(a&&(h=u2({signal:a,onStall:()=>{y.cancel().catch(()=>{})}}));;){const{done:A,value:M}=await y.read();if(h?.bump(),A)break;C+=k.decode(M,{stream:!0});const I=C.split(`
|
|
520
|
-
`);C=I.pop()??"";for(const B of I){const G=B.trim();if(G.startsWith("data: "))try{const j=JSON.parse(G.slice(6)),O=j.type;if(O==="snapshot"){const F=j.segments??[],Y=typeof j.content=="string"?j.content:"";u=Y,F.length&&(f=F),n.onSnapshot?.({content:Y,segments:F})}else if(O==="text_delta"&&typeof j.text=="string")u+=j.text,n.onChunk?.(j.text);else if(O==="thinking_delta"&&typeof j.thinking=="string")f2(n,j.thinking);else if(O==="done"){u=j.content||u,typeof j.sessionId=="string"&&(m=j.sessionId),typeof j.messageId=="string"&&(g=j.messageId);const F=j.segments;F&&(f=F),T=!0,l({content:u,sessionId:m,segments:f,messageId:g,attached:!0,terminal:!0}),y.cancel().catch(()=>{}),h?.stop();return}else if(O==="error"){c(new Error(j.message??j.error??"Stream error")),y.cancel().catch(()=>{}),h?.stop();return}else O==="thinking_commit"&&typeof j.thinking=="string"?n.onCommit?.({type:"thinking_commit",content:j.thinking,createdAt:j.createdAt??new Date().toISOString()}):O==="text_commit"&&typeof j.text=="string"?n.onCommit?.({type:"text_commit",content:j.text,createdAt:j.createdAt??new Date().toISOString()}):O==="agent_tool"&&j.tool&&j.phase?j.phase==="start"?n.onActivity?.({tool:j.tool,phase:"start",arguments:j.arguments}):j.phase==="end"&&n.onActivity?.({tool:j.tool,phase:"end",success:j.success,arguments:j.arguments,result:j.result,error:j.error,durationMs:j.durationMs}):O==="subagent_progress"&&j.tool?n.onActivity?.({tool:j.tool,phase:"subagent_progress",subagentEvent:j.subagentEvent}):O==="heartbeat"&&n.onActivity?.({tool:"",phase:"heartbeat"})}catch{}}}h?.stop(),l({content:u,sessionId:m,segments:f,messageId:g,attached:!0,terminal:T})}catch(b){h?.stop(),c(b)}})},channels:{getMessages:(e,t=30,n)=>K(`/channels/${encodeURIComponent(e)}/messages?limit=${t}${n?`&before=${n}`:""}`),sendMessage:(e,t)=>K(`/channels/${encodeURIComponent(e)}/messages`,{method:"POST",body:JSON.stringify(t)})},governance:{getSystemStatus:()=>K("/system/status"),emergencyStop:e=>K("/system/emergency-stop",{method:"POST",body:JSON.stringify({reason:e})}),getAnnouncements:()=>K("/system/announcements"),createAnnouncement:e=>K("/system/announcements",{method:"POST",body:JSON.stringify(e)}),getPolicy:()=>K("/governance/policy"),setPolicy:e=>K("/governance/policy",{method:"PUT",body:JSON.stringify(e)})},approvals:{list:(e,t)=>{const n=new URLSearchParams;e&&n.set("status",e),t?.limit!==void 0&&n.set("limit",String(t.limit)),t?.offset!==void 0&&n.set("offset",String(t.offset));const a=n.toString();return K(`/approvals${a?`?${a}`:""}`)},respond:(e,t,n,a,i,l)=>K(`/approvals/${e}`,{method:"POST",body:JSON.stringify({approved:t,respondedBy:n,comment:a,selectedOption:i,answers:l})})},notifications:{list:(e,t,n)=>{const a=new URLSearchParams;return e&&a.set("userId",e),t&&a.set("unread","true"),n?.type&&a.set("type",n.type),n?.limit&&a.set("limit",String(n.limit)),n?.offset&&a.set("offset",String(n.offset)),K(`/notifications?${a}`)},create:e=>K("/notifications",{method:"POST",body:JSON.stringify(e)}),markRead:e=>K(`/notifications/${e}`,{method:"POST"}),markAllRead:e=>K("/notifications/mark-all-read",{method:"POST",body:JSON.stringify({userId:e})})},unread:{getCounts:()=>K("/unread"),markRead:(e,t,n)=>K("/unread/mark-read",{method:"POST",body:JSON.stringify({conversationKey:e,lastReadAt:t,lastReadId:n})}),markReadBatch:e=>K("/unread/mark-read-batch",{method:"POST",body:JSON.stringify({items:e})}),markAllRead:()=>K("/unread/mark-all-read",{method:"POST"})},messages:{search:(e,t)=>{const n=new URLSearchParams({q:e});return t?.scope&&n.set("scope",t.scope),t?.channel&&n.set("channel",t.channel),t?.limit&&n.set("limit",String(t.limit)),K(`/messages/search?${n}`)}},activity:{list:e=>{const t=new URLSearchParams;e?.limit&&t.set("limit",String(e.limit)),e?.type&&t.set("type",e.type);const n=t.toString();return K(`/activity${n?`?${n}`:""}`)}},projects:{list:e=>{const t=e?`?orgId=${e}`:"";return K(`/projects${t}`)},get:e=>K(`/projects/${e}`),create:e=>K("/projects",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>K(`/projects/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>K(`/projects/${e}`,{method:"DELETE"}),syncKnowledge:(e,t)=>K(`/projects/${e}/knowledge/sync`,{method:"POST",body:JSON.stringify({knowledgeRoots:t})})},knowledge:{search:(e,t,n)=>{const a=new URLSearchParams;return e&&a.set("query",e),t&&a.set("scope",t),n&&a.set("category",n),K(`/knowledge/search?${a}`)},contribute:e=>K("/knowledge",{method:"POST",body:JSON.stringify(e)}),flagOutdated:(e,t)=>K(`/knowledge/${e}/flag-outdated`,{method:"POST",body:JSON.stringify({reason:t})}),verify:e=>K(`/knowledge/${e}/verify`,{method:"POST",body:JSON.stringify({verifiedBy:"human"})}),remove:e=>K(`/knowledge/${e}`,{method:"DELETE"})},deliverables:{search:e=>{const t=new URLSearchParams;return e?.q&&t.set("q",e.q),e?.projectId&&t.set("projectId",e.projectId),e?.agentId&&t.set("agentId",e.agentId),e?.taskId&&t.set("taskId",e.taskId),e?.type&&t.set("type",e.type),e?.status&&t.set("status",e.status),e?.artifactType&&t.set("artifactType",e.artifactType),e?.source&&t.set("source",e.source),e?.offset&&t.set("offset",String(e.offset)),e?.limit&&t.set("limit",String(e.limit)),K(`/deliverables?${t}`)},get:e=>K(`/deliverables/${e}`).then(t=>({...t,deliverable:gY(t.deliverable)})),create:e=>K("/deliverables",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>K(`/deliverables/${e}`,{method:"PUT",body:JSON.stringify(t)}),remove:e=>K(`/deliverables/${e}`,{method:"DELETE"}),verify:e=>K(`/deliverables/${e}`,{method:"PUT",body:JSON.stringify({status:"verified"})}),checkHealth:e=>{const t=new URLSearchParams;return e&&t.set("agentId",e),K(`/deliverables/health?${t}`)}},codeReviews:{list:(e,t=20)=>{const n=new URLSearchParams;return e&&n.set("taskId",e),n.set("limit",String(t)),K(`/reviews?${n}`)},get:e=>K(`/reviews/${e}`),run:e=>K("/reviews",{method:"POST",body:JSON.stringify(e)})},reports:{list:()=>K("/reports"),get:e=>K(`/reports/${e}`),generate:e=>K("/reports/generate",{method:"POST",body:JSON.stringify(e)}),approvePlan:(e,t)=>K(`/reports/${e}/plan/approve`,{method:"POST",body:JSON.stringify(t)}),rejectPlan:(e,t)=>K(`/reports/${e}/plan/reject`,{method:"POST",body:JSON.stringify(t)}),addFeedback:(e,t)=>K(`/reports/${e}/feedback`,{method:"POST",body:JSON.stringify(t)}),getFeedback:e=>K(`/reports/${e}/feedback`)},executionLogs:{get:(e,t)=>K(`/execution-logs?sourceType=${encodeURIComponent(e)}&sourceId=${encodeURIComponent(t)}`)},groupChats:{list:()=>K("/group-chats"),create:e=>K("/group-chats",{method:"POST",body:JSON.stringify(e)}),getById:e=>K(`/group-chats/${e}`),update:(e,t)=>K(`/group-chats/${e}`,{method:"PATCH",body:JSON.stringify(t)}),delete:e=>K(`/group-chats/${e}`,{method:"DELETE"}),addMember:(e,t,n,a)=>K(`/group-chats/${e}/members`,{method:"POST",body:JSON.stringify({memberId:t,memberType:n,memberName:a})}),removeMember:(e,t)=>K(`/group-chats/${e}/members/${t}`,{method:"DELETE"})},uploads:{upload:(e,t)=>K("/uploads",{method:"POST",body:JSON.stringify({files:e,prefix:t})})},hubOrgs:{mine:()=>Gt("/orgs/mine"),get:e=>Gt(`/orgs/${e}`),update:(e,t)=>Gt(`/orgs/${e}`,{method:"PUT",body:JSON.stringify(t)}),create:e=>Gt("/orgs",{method:"POST",body:JSON.stringify({name:e})}),members:e=>Gt(`/orgs/${e}/members`),invite:(e,t)=>Gt(`/orgs/${e}/members`,{method:"POST",body:JSON.stringify(t)}),removeMember:(e,t)=>Gt(`/orgs/${e}/members/${t}`,{method:"DELETE"}),updateMemberRole:(e,t,n)=>Gt(`/orgs/${e}/members/${t}`,{method:"PATCH",body:JSON.stringify({role:n})}),invitations:()=>Gt("/orgs/invitations"),acceptInvitation:e=>Gt(`/orgs/${e}/members/accept`,{method:"POST"}),leave:e=>Gt(`/orgs/${e}/leave`,{method:"POST"})},workflows:{list:e=>K(`/teams/${e}/workflows`),get:(e,t)=>K(`/teams/${e}/workflows/${encodeURIComponent(t)}`),create:(e,t,n)=>K(`/teams/${e}/workflows`,{method:"POST",body:JSON.stringify({name:t,yaml:n})}),update:(e,t,n)=>K(`/teams/${e}/workflows/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({yaml:n})}),remove:(e,t)=>K(`/teams/${e}/workflows/${encodeURIComponent(t)}`,{method:"DELETE"}),roles:(e,t)=>K(`/teams/${e}/workflows/${encodeURIComponent(t)}/roles`),listRuns:(e,t,n)=>K(`/teams/${e}/workflows/${encodeURIComponent(t)}/runs${n?`?limit=${n}`:""}`),startRun:(e,t,n,a,i)=>K(`/teams/${e}/workflows/${encodeURIComponent(t)}/runs`,{method:"POST",body:JSON.stringify({projectId:n,params:a,roleMapping:i})}),getRun:e=>K(`/workflow-runs/${e}`),cancelRun:e=>K(`/workflow-runs/${e}`,{method:"DELETE"}),pauseRun:e=>K(`/workflow-runs/${e}/pause`,{method:"POST"}),resumeRun:e=>K(`/workflow-runs/${e}/resume`,{method:"POST"})}};function Kme(e){return{id:e.id,sourceType:"task",sourceId:e.taskId,agentId:e.agentId,seq:e.seq,type:e.type,content:e.content,metadata:e.metadata,executionRound:e.executionRound,createdAt:e.createdAt}}function Vme(e,t,n){return e.type==="llm_request"?null:{id:`alog_${t}_${e.seq}`,sourceType:"activity",sourceId:t,agentId:n,seq:e.seq,type:e.type,content:e.content,metadata:e.metadata,createdAt:e.createdAt}}class hc{ws=null;handlers=new Map;reconnectTimer=null;heartbeatTimer=null;intentionalClose=!1;currentUserId;reconnectAttempts=0;lastEventTimestamp=null;static BACKOFF_BASE=1e3;static BACKOFF_MAX=3e4;static HEARTBEAT_INTERVAL=25e3;connect(t){if(t!==void 0&&(this.currentUserId=t),this.ws&&(this.ws.readyState===WebSocket.CONNECTING||this.ws.readyState===WebSocket.OPEN))if(t!==void 0&&this.ws.url&&!this.ws.url.includes(`userId=${t}`))this.ws.onclose=null,this.ws.close(),this.ws=null;else return;this.intentionalClose=!1;const n=window.location.protocol==="https:"?"wss:":"ws:",a=new URLSearchParams;this.currentUserId&&a.set("userId",this.currentUserId),this.lastEventTimestamp&&a.set("since",this.lastEventTimestamp);const i=a.toString(),l=`${n}//${window.location.host}/ws${i?`?${i}`:""}`,c=new WebSocket(l);this.ws=c,c.onopen=()=>{this.reconnectAttempts=0,this.startHeartbeat(c)},c.onmessage=u=>{if(this.ws===c)try{const m=JSON.parse(u.data);if(m.timestamp&&(this.lastEventTimestamp=m.timestamp),m.type==="pong")return;const f=this.handlers.get(m.type);if(f)for(const h of f)h(m);const g=this.handlers.get("*");if(g)for(const h of g)h(m)}catch{}},c.onclose=()=>{if(this.stopHeartbeat(),this.intentionalClose)return;const u=Math.min(hc.BACKOFF_BASE*Math.pow(2,this.reconnectAttempts),hc.BACKOFF_MAX);this.reconnectAttempts++,this.reconnectTimer=setTimeout(()=>this.connect(this.currentUserId),u)},c.onerror=()=>{c.close()}}startHeartbeat(t){this.stopHeartbeat(),this.heartbeatTimer=setInterval(()=>{t.readyState===WebSocket.OPEN&&t.send(JSON.stringify({type:"ping"}))},hc.HEARTBEAT_INTERVAL)}stopHeartbeat(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null)}disconnect(){this.intentionalClose=!0,this.stopHeartbeat(),this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.ws&&(this.ws.onclose=null,this.ws.close(),this.ws=null)}on(t,n){return this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t).add(n),()=>this.handlers.get(t)?.delete(n)}}const di=new hc;let Zm=typeof window<"u"?window.__MARKUS_HUB_URL__??"https://markus.global":"https://markus.global",Qu=null;async function eg(){if(!Tn())return null;try{const e=await Gt("/auth/me");if(e?.user?.id){const t=Tn();return ym(t,e.user),e.user}}catch{}return Oa()}async function aS(){if(!window.__MARKUS_PREVIEW__)try{const e=await K("/settings/hub");e.hubUrl&&(Zm=e.hubUrl)}catch{}}function DY(){return Qu||(Qu=aS().finally(()=>{})),Qu}window.__MARKUS_PREVIEW__||(Qu=aS().then(async()=>{const e=localStorage.getItem("markus_hub_token");if(e)K("/settings/hub-token",{method:"POST",body:JSON.stringify({token:e})}).catch(()=>{}),eg();else try{await Se.auth.me();const t=await K("/settings/hub-token");t.token&&(localStorage.setItem("markus_hub_token",t.token),await eg())}catch{}}).catch(()=>{}));const Mc="markus_hub_token",gm="markus_hub_user";function Tn(){return localStorage.getItem(Mc)}async function IY(){const e=Tn();if(e)return e;try{await Se.auth.me()}catch{return null}try{const t=await K("/settings/hub-token");if(t.token)return localStorage.setItem(Mc,t.token),eg(),t.token}catch{}return null}function Oa(){try{const e=localStorage.getItem(gm);return e?JSON.parse(e):null}catch{return null}}function bm(e,t){if(e.purchasedByCurrentUser||t?.has(e.id))return!0;const n=Oa();if(!n?.id)return!1;const a=e.author?.id??e.authorId;return!!a&&a===n.id}function Is(){localStorage.removeItem(Mc),localStorage.removeItem(gm),rS(null),window.dispatchEvent(new CustomEvent("markus:hub-auth"))}function ym(e,t){const n=localStorage.getItem(Mc),a=localStorage.getItem(gm),i=JSON.stringify(t);n===e&&a===i||(localStorage.setItem(Mc,e),localStorage.setItem(gm,i),rS(e),window.dispatchEvent(new CustomEvent("markus:hub-auth")))}function rS(e){K("/settings/hub-token",{method:"POST",body:JSON.stringify({token:e})}).catch(()=>{})}async function LY(e){e.openrouter?.key&&await K("/settings/subscription-key",{method:"POST",body:JSON.stringify({openrouter:e.openrouter})}).catch(()=>{})}async function ab(e){try{return await K(`/auth/hub-connect-status?session=${encodeURIComponent(e)}&_t=${Date.now()}`)}catch{return null}}async function rb(e){!e.token||!e.user||(ym(e.token,e.user),e.openrouter?.key&&await LY({openrouter:e.openrouter}),PY())}async function PY(){if(Tn())try{const{org:e}=await K("/settings/org"),t=e?.name?.trim();if(!t||t==="My Organization")return;const a=((await Gt("/orgs/mine")).orgs??[]).find(i=>i.role==="owner");if(!a||a.name===t)return;await Gt(`/orgs/${a.id}`,{method:"PUT",body:JSON.stringify({name:t})})}catch{}}function iS(){return window.markusDesktop}async function OY(e,t=12e4){const n=Date.now()+t;for(;Date.now()<n;){const a=await ab(e);if(a?.ready&&a.token&&a.user)return await rb(a),!0;await new Promise(i=>setTimeout(i,1200))}return!1}let Ju=null;iS()?.onDeepLinkAuth?.(e=>{Ju?.(e?.session??"")});let vm=null;function HY(){vm?.(),Ms=null}function BY(e,t,n){return new Promise((a,i)=>{let l=!1,c=!1;const u=(C,T)=>{l||(l=!0,vm=null,clearInterval(y),clearTimeout(k),window.removeEventListener("focus",g),document.removeEventListener("visibilitychange",h),Ju===f&&(Ju=null),C?(n.focusWindow?.(),a()):i(T))};vm=()=>u(!1,new Error("Hub login cancelled"));const m=async()=>{if(!(l||c)){c=!0;try{const C=await ab(e);C?.ready&&C.token&&C.user&&(await rb(C),u(!0))}finally{c=!1}}},f=C=>{(!C||C===e)&&m()};Ju=f;const g=()=>{m()},h=()=>{document.visibilityState==="visible"&&m()};window.addEventListener("focus",g),document.addEventListener("visibilitychange",h);let b=`${Zm}/auth/connect?session=${encodeURIComponent(e)}&redirect=${encodeURIComponent("markus://auth")}`;t&&(b+=`&method=${encodeURIComponent(t)}`),Promise.resolve(n.openExternal(b)).then(()=>{m()}).catch(C=>{u(!1,C instanceof Error?C:new Error("Failed to open browser"))});const y=setInterval(()=>{m()},1500),k=setTimeout(()=>u(!1,new Error("Hub login timed out")),5*6e4)})}function zY(e,t){return new Promise((n,a)=>{let i=`${Zm}/auth/connect?session=${encodeURIComponent(e)}`;t&&(i+=`&method=${encodeURIComponent(t)}`);const l=460,c=580,u=Math.round(window.screenX+(window.outerWidth-l)/2),m=Math.round(window.screenY+(window.outerHeight-c)/2),f=window.open(i,"markus_hub_auth",`popup=yes,width=${l},height=${c},left=${u},top=${m}`);if(!f){a(new Error("Popup blocked by browser. Please allow popups for this site."));return}let g=!1,h=null;const b=()=>{clearInterval(k),clearInterval(T),h&&clearInterval(h),document.removeEventListener("visibilitychange",C)},y=async()=>{if(g)return;const A=await ab(e);A?.ready&&A.token&&A.user&&(g=!0,await rb(A),b(),f?.close(),n())},k=setInterval(()=>{y()},1500),C=()=>{!g&&document.visibilityState==="visible"&&y()};document.addEventListener("visibilitychange",C);const T=setInterval(()=>{if(!g&&f?.closed){clearInterval(T);let A=0;h=setInterval(async()=>{if(g){clearInterval(h);return}A++,await y(),A>=5&&!g&&(g=!0,b(),Tn()?n():a(new Error("Hub login cancelled")))},1e3)}},500)})}let Ms=null;function Ia(e){const t=typeof e=="string"?{method:e}:e??{};if(t.force)vm?.(),Ms=null,(Tn()||Oa())&&Is();else if(Tn())return Promise.resolve();if(Ms)return Ms;const n=`cs_${Date.now()}_${Math.random().toString(36).slice(2,10)}`,a=iS(),i=(async()=>{await DY(),a?await BY(n,t.method,a):await zY(n,t.method)})();return Ms=i,i.catch(()=>{}).finally(()=>{Ms===i&&(Ms=null)}),i}async function Gt(e,t){const n=Tn(),a={"Content-Type":"application/json",...t?.headers};n&&(a.Authorization=`Bearer ${n}`);const i=await fetch(`${Rs}/hub${e}`,{...t,headers:a,credentials:"include"}),l=await i.json();if(i.status===401&&n&&Is(),!i.ok){const c=new Error(l.error??`Hub HTTP ${i.status}`);throw c.code=typeof l.code=="string"?l.code:void 0,c.retryAfterSeconds=typeof l.retryAfterSeconds=="number"?l.retryAfterSeconds:void 0,c.status=i.status,c}return l}async function sS(){if(!Tn())return!1;try{return await Gt("/user/plan"),!0}catch{return!1}}const at={getUrl:()=>Zm,isAuthenticated:()=>!!Tn(),getUser:Oa,logout:()=>{Is()},ensureAuth:Ia,validateSession:sS,login:async(e,t)=>{const n=await Gt("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:t})});return ym(n.token,n.user),n},register:async(e,t,n)=>{const a=await Gt("/auth/register",{method:"POST",body:JSON.stringify({username:e,email:t,password:n})});return ym(a.token,a.user),a},search:e=>{const t=new URLSearchParams;e?.type&&t.set("type",e.type),e?.subtype&&t.set("subtype",e.subtype),e?.q&&t.set("q",e.q),e?.category&&t.set("category",e.category),e?.sort&&t.set("sort",e.sort),e?.page&&t.set("page",String(e.page)),e?.limit&&t.set("limit",String(e.limit));const n=t.toString();return Gt(`/items${n?`?${n}`:""}`)},getItem:e=>Gt(`/items/${e}`),download:async e=>{await Ia();try{return await Gt(`/items/${e}/download`,{method:"POST"})}catch(t){if(!Tn())return await Ia(),Gt(`/items/${e}/download`,{method:"POST"});throw t}},publish:async e=>{await Ia();try{return await Gt("/items",{method:"POST",body:JSON.stringify(e)})}catch(t){if(!Tn())return await Ia(),Gt("/items",{method:"POST",body:JSON.stringify(e)});throw t}},uploadImage:async e=>{await Ia();try{const t=new FormData;t.append("file",e);const n=await fetch("/api/hub/upload",{method:"POST",credentials:"include",headers:{Authorization:`Bearer ${Tn()}`},body:t});return n.ok?await n.json():null}catch{return null}},uploadMediaBatch:async e=>{await Ia();try{const t=await fetch("/api/hub/deliverables/media",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Tn()}`},body:JSON.stringify({files:e})});return t.ok?await t.json():{files:[],errors:[{filename:"batch",error:`HTTP ${t.status}`}]}}catch(t){return{files:[],errors:[{filename:"batch",error:String(t)}]}}},publishViaProxy:async e=>{await Ia();try{return await Gt("/items",{method:"POST",body:JSON.stringify(e)})}catch(t){if(!Tn())return await Ia(),Gt("/items",{method:"POST",body:JSON.stringify(e)});throw t}},updateItem:async(e,t)=>(await Ia(),Gt(`/items/${e}`,{method:"PUT",body:JSON.stringify(t)})),myItems:async()=>Tn()?Gt("/items/mine"):{items:[]},browseItems:async e=>{const t=new URLSearchParams;e?.type&&t.set("type",e.type),e?.orgId&&t.set("orgId",e.orgId),e?.q&&t.set("q",e.q),e?.page&&t.set("page",String(e.page)),e?.limit&&t.set("limit",String(e.limit??50));const n=t.toString();return Gt(`/items${n?`?${n}`:""}`)},myOrgs:async()=>Tn()?Gt("/orgs/mine").then(e=>({memberships:(e.orgs??[]).map(t=>({id:t.id,name:t.name,slug:t.slug,role:t.role}))})):{memberships:[]},deleteItem:async e=>(await Ia(),Gt(`/items/${e}`,{method:"DELETE"})),purchases:{checkout:e=>Gt("/purchases/checkout",{method:"POST",body:JSON.stringify({itemId:e})}),payWithEarnings:e=>Gt("/purchases/pay-with-earnings",{method:"POST",body:JSON.stringify({itemId:e})}),mine:()=>Gt("/purchases/mine")},creator:{getBalance:()=>Gt("/creator/balance")},feedback:{create:e=>Gt("/feedback",{method:"POST",body:JSON.stringify(e)})},user:{plan:()=>Gt("/user/plan"),cuStats:(e=30,t="day")=>Gt(`/user/cu/stats?days=${e}&granularity=${t}`),claimFreeCreditsStatus:()=>Gt("/user/claim-free-credits"),claimFreeCredits:()=>Gt("/user/claim-free-credits",{method:"POST"}),referral:()=>Gt("/user/referral")}},qY=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;function oS(e){return typeof e=="string"&&e.length>=2&&e.length<=64&&qY.test(e)}function jc(e){const t=e.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-+|-+$/g,"");return oS(t)?t:null}function xm(e,t){const n=jc(e);if(n)return n;if(t){const i=jc(t);if(i)return i;if(oS(t))return t}let a=0;for(let i=0;i<e.length;i++)a=(a<<5)-a+e.charCodeAt(i)|0;return`pkg-${Math.abs(a).toString(36)}`}function $Y(e,t){if(e.blockedReason==="deps"||e.blockedReason==="hold"||e.blockedReason==="workflow")return e.blockedReason;const n=e.blockedBy??[];return n.length===0||t&&n.every(i=>t(i)?.status==="completed")?"hold":"deps"}let h2=null,ou=ce.HOME;const yt={setHandler(e){h2=e},navigate(e,t){t&&Object.entries(t).forEach(([n,a])=>localStorage.setItem(`markus_nav_${n}`,a)),h2?.(e,t),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:e,params:t}}))},setSettingsReturnPage(e){e!==ce.SETTINGS&&(ou=e)},getSettingsReturnPage(){return ou},leaveSettings(){const e=ou!==ce.SETTINGS?ou:ce.HOME;this.navigate(e)}};function lS(e){if(!e||e.status&&e.status!=="pending"||e.type!=="action"||Array.isArray(e.questions)&&e.questions.length>0)return!1;const t=e.details?.toolName;return typeof t=="string"&&t.length>0}function FY(e){return e.details?.agentId??e.agentId}function UY(e){const t=e.details??{};return[t.chatSessionId,t.sessionId].filter(n=>typeof n=="string"&&n.length>0)}function Wme(e,t){const n=e.filter(l=>lS(l)&&FY(l)===t.agentId);if(!t.sessionId)return n;const a=[],i=[];for(const l of n)(UY(l).includes(t.sessionId)?a:i).push(l);return[...a,...i]}function GY(e){return Array.isArray(e.questions)&&e.questions.length>0}function tg(e){if(!e)return null;try{const t=JSON.parse(e);return t&&typeof t=="object"?t:null}catch{return null}}function g2(e){const t={},n=e.split("?")[1];if(!n)return t;for(const[a,i]of new URLSearchParams(n).entries())t[a]=i;return t}function KY(e){if(e.actionType==="open_chat"||e.actionType==="navigate")return!0;const t=e.metadata??{};return!!(t.agentId||t.taskId||t.requirementId||t.projectId||t.channel||t.senderId||t.approvalId||t.sessionId)}function ng(e,t={}){if(GY(e)){if(t.onOpenApproval){t.onOpenApproval(e);return}const a=e.details?.sessionId,i={};e.agentId&&(i.agentId=e.agentId),a&&(i.sessionId=a),yt.navigate(ce.TEAM,Object.keys(i).length>0?i:void 0);return}const n=e.details;if(lS(e)&&e.agentId)return void yt.navigate(ce.TEAM,{agentId:e.agentId});if(n?.taskId)return void yt.navigate(ce.WORK,{openTask:n.taskId});if(n?.requirementId)return void yt.navigate(ce.WORK,{openRequirement:n.requirementId});if(e.agentId)return void yt.navigate(ce.TEAM,{agentId:e.agentId,preferMain:"1"});yt.navigate(ce.WORK)}function cS(e){const t=e.metadata??{},n=a=>typeof a=="string"&&a.length>0?a:void 0;if(e.actionType==="open_chat"){const a=n(t.taskId),i=n(t.requirementId);if(a)return{page:"WORK",params:{openTask:a}};if(i)return{page:"WORK",params:{openRequirement:i}};const l=tg(e.actionTarget),c=n(l?.agentId);if(c){const u={agentId:c},m=n(l?.sessionId);return m&&(u.sessionId=m),{page:"TEAM",params:u}}}if(e.actionType==="navigate"){const a=tg(e.actionTarget),i=n(a?.path);if(i){if(i.startsWith("/team"))return{page:"TEAM",params:g2(i)};if(i.startsWith("/work"))return{page:"WORK",params:g2(i)};if(i.startsWith("/approvals/"))return null}}switch(e.type){case"approval_request":return null;case"task_completed":case"task_created":case"task_review":case"task_failed":{const a=n(t.taskId);return{page:"WORK",params:a?{openTask:a}:{}}}case"requirement_created":case"requirement_decision":{const a=n(t.requirementId);return{page:"WORK",params:a?{openRequirement:a}:{}}}case"agent_report":case"system":{if(t.creditExhausted||t.templateUpdates)return null;const a=n(t.agentId),i={};a&&(i.agentId=a);const l=n(t.sessionId);return l?i.sessionId=l:a&&(i.preferMain="1"),{page:"TEAM",params:i}}case"direct_message":{const a=n(t.senderId);return{page:"TEAM",params:a?{dm:a}:{}}}case"group_message":{const a=n(t.channel);return{page:"TEAM",params:a?{channel:a}:{}}}default:{const a=n(t.taskId);if(a)return{page:"WORK",params:{openTask:a}};const i=n(t.requirementId);if(i)return{page:"WORK",params:{openRequirement:i}};const l=n(t.projectId);if(l)return{page:"WORK",params:{projectId:l}};const c=n(t.agentId);return c?{page:"TEAM",params:{agentId:c}}:{page:"WORK",params:{}}}}}function VY(e,t={}){const n=cS(e);if(n){const l=Object.keys(n.params).length>0?n.params:void 0;return void yt.navigate(n.page==="WORK"?ce.WORK:ce.TEAM,l)}const a=e.metadata??{},i=l=>typeof l=="string"&&l.length>0?l:void 0;if(e.actionType==="navigate"){const l=tg(e.actionTarget),c=i(l?.path);if(c?.startsWith("/approvals/")){const u=c.split("?")[0].split("/")[2],m=u?t.approvals?.find(f=>f.id===u):void 0;if(m)return ng(m,t)}}if(e.type==="approval_request"){const l=i(a.approvalId),c=l?t.approvals?.find(g=>g.id===l):void 0;if(c)return ng(c,t);const u=i(a.taskId);if(u)return void yt.navigate(ce.WORK,{openTask:u});const m=i(a.requirementId);if(m)return void yt.navigate(ce.WORK,{openRequirement:m});const f=i(a.agentId);return f?void yt.navigate(ce.TEAM,{agentId:f,preferMain:"1"}):void yt.navigate(ce.WORK)}if(a.creditExhausted){t.onCreditExhausted?.();return}if(a.templateUpdates){t.onTemplateUpdates?.();return}yt.navigate(ce.WORK)}const WY={answer:!0,approve:!0,unblock:!0,resolve_failure:!1,review:!0,read:!1},YY={answer:0,approve:1,unblock:2,resolve_failure:3,review:5,read:6},QY=4;function b2(e,t,n){return`${e}:${t}:${n}`}const dS="1970-01-01T00:00:00.000Z",JY={urgent:0,high:1,medium:2,low:3};function y2(e){return JY[(e??"").toLowerCase()]??4}function Zl(e){return e&&e.length>0?e:dS}function jo(e,t){return e==="approve"&&t==="requirement"?QY:YY[e]}function XY(e){return Array.isArray(e.questions)&&e.questions.length>0}function ZY(){return"read"}function eQ(e,t){const n=t.params.openTask;if(n)return{kind:"task",id:n};const a=t.params.openRequirement;return a?{kind:"requirement",id:a}:{kind:"notification",id:e.id}}function tQ(e,t,n={}){const{lastSeenAt:a=null,includeUnread:i=!0}=n,l=[],c=[],u=b=>e.tasks.find(y=>y.id===b)?.title??b,m=b=>e.requirements.find(y=>y.id===b)?.title??b;for(const b of e.approvals){if(b.status!=="pending")continue;const y=b.details??{},k={};let C="TEAM",T="approval",A=b.id;y.taskId?(C="WORK",k.openTask=y.taskId,T="task",A=y.taskId):y.requirementId&&(C="WORK",k.openRequirement=y.requirementId,T="requirement",A=y.requirementId),b.agentId&&(k.agentId=b.agentId),C==="TEAM"&&(k.preferMain="1");const M=C==="WORK"?{page:C,params:k}:b.agentId?{page:C,params:k}:null;if(!M){c.push({source:"approval",ref:b.id,reason:"no_action"});continue}l.push({subjectKind:T,subjectId:A,need:XY(b)?"answer":"approve",title:b.title,priority:"none",waitingSince:Zl(b.requestedAt),waitingBasis:"requested",action:M,source:{kind:"approval",ref:b.id},...b.agentName?{meta:b.agentName}:{}})}for(const b of e.requirements)b.status==="pending"&&l.push({subjectKind:"requirement",subjectId:b.id,need:"approve",title:b.title,priority:b.priority??"none",waitingSince:Zl(b.createdAt),waitingBasis:"created",action:{page:"WORK",params:{openRequirement:b.id}},source:{kind:"fsm",ref:b.id}});for(const b of e.tasks){let y=null,k="approximate",C=Zl(b.statusChangedAt??b.updatedAt??b.createdAt);b.status==="review"&&b.reviewerType==="human"?(y="review",k=b.statusChangedAt?"status":"approximate"):b.status==="blocked"&&t.resolveBlockedReason(b)==="hold"?(y="unblock",k=b.statusChangedAt?"status":"approximate"):b.status==="failed"&&(y="resolve_failure",k=b.statusChangedAt?"status":"approximate"),y&&(C=Zl(b.statusChangedAt??b.updatedAt??b.createdAt),l.push({subjectKind:"task",subjectId:b.id,need:y,title:b.title,priority:b.priority??"none",waitingSince:C,waitingBasis:k,action:{page:"WORK",params:{openTask:b.id}},source:{kind:"fsm",ref:b.id}}))}for(const b of e.stages??[]){let y=null;if(b.stage==="waiting_human"?y="answer":b.stage==="failed"&&(y="resolve_failure"),!y)continue;const k=b.subjectKind==="task"?{page:"WORK",params:{openTask:b.subjectId}}:{page:"WORK",params:{openRequirement:b.subjectId}};l.push({subjectKind:b.subjectKind,subjectId:b.subjectId,need:y,title:b.subjectKind==="task"?u(b.subjectId):m(b.subjectId),priority:"none",waitingSince:dS,waitingBasis:"approximate",action:k,source:{kind:"stage",ref:b.subjectId}})}if(i)for(const b of e.notifications){if(b.read)continue;const y=t.resolveNotificationTarget(b);if(!y){c.push({source:"notification",ref:b.id,reason:"no_action"});continue}const k=eQ(b,y);l.push({subjectKind:k.kind,subjectId:k.id,need:ZY(),title:t.renderNotificationTitle?t.renderNotificationTitle(b):b.title,priority:b.priority??"none",waitingSince:Zl(b.createdAt),waitingBasis:"created",action:y,source:{kind:"notification",ref:b.id},noticeId:b.id,alwaysNew:!0})}const f=new Map;for(const b of l){const y=b2(b.subjectKind,b.subjectId,b.need),k=f.get(y);k?k.push(b):f.set(y,[b])}const g=new Map;for(const b of f.values()){const y=b[0],k=`${y.subjectKind}:${y.subjectId}`,C=g.get(k);C?C.members.push(...b):g.set(k,{subjectKind:y.subjectKind,subjectId:y.subjectId,members:[...b]})}const h=[];for(const b of g.values()){const y=[...b.members].sort((G,j)=>jo(G.need,G.subjectKind)-jo(j.need,j.subjectKind)),k=y[0],C=[],T=[],A=[];let M=k.waitingSince,I=!1,B=k.meta;for(const G of y)C.some(j=>j.kind===G.source.kind&&j.ref===G.source.ref)||C.push(G.source),G.noticeId&&!T.includes(G.noticeId)&&T.push(G.noticeId),G.need!==k.need&&!A.includes(G.need)&&A.push(G.need),G.waitingSince<M&&(M=G.waitingSince),WY[G.need]&&(I=!0),!B&&G.meta&&(B=G.meta);h.push({key:b2(k.subjectKind,k.subjectId,k.need),subjectKind:k.subjectKind,subjectId:k.subjectId,needKind:k.need,mergedNeeds:A.sort((G,j)=>jo(G,k.subjectKind)-jo(j,k.subjectKind)),title:k.title,priority:k.priority,waitingSince:M,waitingBasis:M===k.waitingSince?k.waitingBasis:"approximate",action:k.action,blocking:I,sources:C,anchor:k.source,noticeIds:T,isNew:k.alwaysNew===!0?!0:a!==null&&k.waitingSince>a,...B?{meta:B}:{}})}return h.sort((b,y)=>{if(b.waitingSince!==y.waitingSince)return b.waitingSince<y.waitingSince?-1:1;const k=y2(b.priority)-y2(y.priority);if(k!==0)return k;const C=jo(b.needKind,b.subjectKind)-jo(y.needKind,y.subjectKind);return C!==0?C:b.key<y.key?-1:b.key>y.key?1:0}),{items:h,dropped:c}}function v2(e){return Array.isArray(e?.questions)&&e.questions.length>0}function ec(e){return typeof e=="string"&&e.length>0?e:void 0}function nQ(e,t){if(e.type==="approval_request"){const u=e.metadata??{},m=ec(u.approvalId),g=(m?t?.find(y=>y.id===m):void 0)?.details??{},h=ec(g.taskId);if(h)return{page:"WORK",params:{openTask:h}};const b=ec(g.requirementId);if(b)return{page:"WORK",params:{openRequirement:b}}}const n=cS(e);if(n)return n;const a=e.metadata??{},i=ec(a.agentId),l=ec(a.sessionId),c={};return i&&(c.agentId=i),l?c.sessionId=l:i&&(c.preferMain="1"),Object.keys(c).length>0?{page:"TEAM",params:c}:null}function aQ(e){switch(e.needKind){case"answer":return"agent_question";case"approve":return e.subjectKind==="requirement"?"requirement_approval":"approval_request";case"review":return"task_review";case"unblock":return"blocked_hold";case"resolve_failure":return"task_failed";case"read":return"unread_message"}}function rQ(e){switch(e.needKind){case"answer":case"approve":return e.anchor.kind==="approval"?`approval:${e.anchor.ref}`:e.subjectKind==="requirement"?`requirement:${e.subjectId}`:`approval:${e.anchor.ref}`;case"review":return`task:${e.subjectId}`;case"unblock":return`blocked:${e.subjectId}`;case"resolve_failure":return`failed:${e.subjectId}`;case"read":return`notice:${e.anchor.ref}`}}function uS(e){const{tasks:t,requirements:n,approvals:a,notifications:i,taskById:l,lastSeenAt:c=null,includeUnread:u=!0,notifyTitle:m}=e,f={approvals:a,notifications:i,tasks:t,requirements:n},g={resolveNotificationTarget:y=>nQ(y,a),resolveBlockedReason:y=>$Y(y,k=>l?.(k)),...m?{renderNotificationTitle:y=>m(y)}:{}},{items:h}=tQ(f,g,{lastSeenAt:c,includeUnread:u}),b=new Map(i.map(y=>[y.id,y]));return h.map(y=>{const k=y.noticeIds.map(C=>b.get(C)).filter(C=>!!C);return{id:rQ(y),kind:aQ(y),title:y.title,priority:y.priority,waitingSince:y.waitingSince,waitingBasis:y.waitingBasis,target:y.action,isNew:y.isNew,...y.meta?{meta:y.meta}:{},...k.length>0?{notices:k}:{}}})}function iQ(e){return e.filter(t=>t.kind!=="unread_message").length}function mS(e,t=Date.now()){const n=Date.parse(e.waitingSince);if(!Number.isFinite(n))return"—";const a=Math.max(0,t-n),i=Math.floor(a/6e4),l=Math.floor(i/60),c=Math.floor(l/24);let u;return i<1?u=tn.t("common:duration.lessThan1Minute"):i<60?u=tn.t("common:duration.minutes",{count:i}):l<24?u=tn.t("common:duration.hours",{count:l}):c<30?u=l%24>0?tn.t("common:duration.daysHours",{days:c,hours:l%24}):tn.t("common:duration.days",{count:c}):u=tn.t("common:duration.moreThan30Days"),e.waitingBasis==="approximate"?tn.t("common:duration.approximate",{duration:u}):u}const pS="markus_attention_count",wm="markus:attention-count",fS="markus_attention_last_seen";function sQ(){try{return localStorage.getItem(fS)}catch{return null}}function oQ(e){try{localStorage.setItem(fS,e)}catch{}}function lQ(e){try{localStorage.setItem(pS,String(e))}catch{}window.dispatchEvent(new CustomEvent(wm,{detail:{count:e}}))}function ep(){return x2(pS)+x2(hS)}const hS="markus_unread_count";function x2(e){try{const t=localStorage.getItem(e),n=t===null?0:Number(t);return Number.isFinite(n)&&n>0?n:0}catch{return 0}}function cQ(e){try{localStorage.setItem(hS,String(Math.max(0,e)))}catch{}window.dispatchEvent(new CustomEvent(wm,{detail:{count:ep()}}))}function gS(e){const t=n=>{const a=n.detail;e(typeof a?.count=="number"?a.count:ep())};return window.addEventListener(wm,t),()=>window.removeEventListener(wm,t)}const dQ=1e3,uQ=6e4;function mQ(e){w.useEffect(()=>{if(!e)return;let t=!0,n;const a=()=>{(async()=>{try{const[c,u,m,f]=await Promise.all([Se.tasks.boardSummary(),Se.requirements.list({lean:!0}),Se.approvals.list(),Se.notifications.list(e,!0,{limit:20})]);if(!t)return;const g=Object.values(c.board).flat(),h=new Map(g.map(y=>[y.id,y])),b=uS({tasks:g,requirements:u.requirements,approvals:m.approvals??[],notifications:f.notifications??[],taskById:y=>h.get(y),lastSeenAt:null});lQ(iQ(b)),cQ(f.unreadCount??0)}catch{}})()},i=()=>{n!==void 0&&window.clearTimeout(n),n=window.setTimeout(a,dQ)};a();const l=window.setInterval(a,uQ);return window.addEventListener("markus:notifications-changed",i),window.addEventListener("markus:data-changed",i),()=>{t=!1,window.clearInterval(l),n!==void 0&&window.clearTimeout(n),window.removeEventListener("markus:notifications-changed",i),window.removeEventListener("markus:data-changed",i)}},[e])}const pQ=10*6e4;class fQ{bySession=new Map;listeners=new Set;_revision=0;getRevision=()=>this._revision;subscribe=t=>(this.listeners.add(t),()=>{this.listeners.delete(t)});applyServerState(t,n,a,i=Date.now(),l,c){const u=this.bySession.get(n);if(u&&u.source==="server"&&u.at>i)return;const m=l??null,f=!u||u.streaming!==a||u.assistantMessageId!==m;this.bySession.set(n,{agentId:t,streaming:a,source:"server",at:i,assistantMessageId:m,status:c}),f&&this.bump()}reconcileFromServer(t,n,a=Date.now()){for(const[i,l]of Object.entries(n))this.applyServerState(t,i,l,a)}applyLocalOptimistic(t,n,a){const i=this.bySession.get(n),l=Date.now();if(i&&i.source==="server"&&i.at>=l)return;const c=!i||i.streaming!==a;this.bySession.set(n,{agentId:t,streaming:a,source:"local",at:l,assistantMessageId:i?.assistantMessageId??null,status:i?.status}),c&&this.bump()}isStreaming(t){return t?this.bySession.get(t)?.streaming??!1:!1}isServerConfirmedStreaming(t){if(!t)return!1;const n=this.bySession.get(t);return!!n&&n.source==="server"&&n.streaming}liveBubbleId(t){if(!t)return null;const n=this.bySession.get(t);return!n||!n.streaming?null:n.assistantMessageId}isAgentStreaming(t){if(!t)return!1;for(const n of this.bySession.values())if(n.agentId===t&&n.streaming)return!0;return!1}streamingAgentIds(){const t=new Set;for(const n of this.bySession.values())n.streaming&&t.add(n.agentId);return t}hasEntry(t){return this.bySession.has(t)}entriesSnapshot(){return[...this.bySession].map(([t,n])=>({sessionId:t,...n}))}prune(t=Date.now(),n=pQ){for(const[a,i]of this.bySession)!i.streaming&&t-i.at>n&&this.bySession.delete(a)}bump(){this._revision+=1;for(const t of this.listeners)try{t()}catch{}}}const Lr=new fQ;function Yme(){return w.useSyncExternalStore(Lr.subscribe,Lr.getRevision,Lr.getRevision)}function Qme(e){return w.useSyncExternalStore(Lr.subscribe,Lr.getRevision,Lr.getRevision),Lr.isAgentStreaming(e)}const hQ={chime:[{freq:698.46,startMs:0,durationMs:170,wave:"sine",gain:.3,overtones:[{mult:2,gain:.35}]},{freq:880,startMs:120,durationMs:320,wave:"sine",gain:.28,overtones:[{mult:2,gain:.3},{mult:3,gain:.1}]}],ding:[{freq:261.63,startMs:0,durationMs:760,wave:"sine",gain:.09},{freq:523.25,startMs:0,durationMs:700,wave:"sine",gain:.08},{freq:1046.5,startMs:0,durationMs:650,wave:"sine",gain:.16,overtones:[{mult:2,gain:.32},{mult:2.76,gain:.16},{mult:4,gain:.08}]},{freq:1567.98,startMs:0,durationMs:320,wave:"sine",gain:.05}],pop:[{freq:523.25,startMs:0,durationMs:150,wave:"sine",gain:.3,overtones:[{mult:2,gain:.3}]},{freq:659.25,startMs:80,durationMs:190,wave:"sine",gain:.26,overtones:[{mult:2,gain:.25}]}],ask:[{freq:587.33,startMs:0,durationMs:200,wave:"sine",gain:.28,overtones:[{mult:2,gain:.3}]},{freq:783.99,startMs:130,durationMs:340,wave:"sine",gain:.26,overtones:[{mult:2,gain:.28}]}],attention:[{freq:196,startMs:0,durationMs:520,wave:"sine",gain:.1},{freq:783.99,startMs:0,durationMs:430,wave:"sine",gain:.14,overtones:[{mult:2,gain:.3},{mult:2.76,gain:.15}]},{freq:987.77,startMs:150,durationMs:400,wave:"sine",gain:.13,overtones:[{mult:2,gain:.28},{mult:2.76,gain:.12}]},{freq:1174.66,startMs:300,durationMs:520,wave:"sine",gain:.13,overtones:[{mult:2,gain:.3},{mult:2.76,gain:.15}]}],alert:[{freq:392,startMs:0,durationMs:240,wave:"triangle",gain:.32,overtones:[{mult:2,gain:.18}]},{freq:311.13,startMs:220,durationMs:380,wave:"triangle",gain:.32,overtones:[{mult:2,gain:.18}]}]},gQ=[{id:"agent-reply-complete",cue:"chime",labelKey:"sounds.events.agentReplyComplete.label",descKey:"sounds.events.agentReplyComplete.desc"},{id:"input-requested",cue:"ask",labelKey:"sounds.events.inputRequested.label",descKey:"sounds.events.inputRequested.desc"},{id:"approval-requested",cue:"attention",labelKey:"sounds.events.approvalRequested.label",descKey:"sounds.events.approvalRequested.desc"},{id:"review-requested",cue:"ding",labelKey:"sounds.events.reviewRequested.label",descKey:"sounds.events.reviewRequested.desc"},{id:"notification",cue:"pop",labelKey:"sounds.events.notification.label",descKey:"sounds.events.notification.desc"},{id:"agent-reply-error",cue:"alert",labelKey:"sounds.events.agentReplyError.label",descKey:"sounds.events.agentReplyError.desc"},{id:"task-failed",cue:"alert",labelKey:"sounds.events.taskFailed.label",descKey:"sounds.events.taskFailed.desc"}],bS=new Map(gQ.map(e=>[e.id,e]));function bQ(e){return bS.get(e).cue}function yQ(e,t){if(!e||e.streaming!==!0||t.streaming||t.source!=="server")return null;const n=(t.status??"").toLowerCase();return n==="cancelled"||n==="canceled"||n==="stopped"?null:n==="error"||n==="failed"?"agent-reply-error":"agent-reply-complete"}function vQ(e){const t=e?.notification,n=typeof t?.type=="string"?t.type.toLowerCase():"";return n?n==="approval_request"||n==="approval_required"?t?.metadata?.askKind==="input"?"input-requested":"approval-requested":n==="task_review"||n==="review_request"||n==="review_requested"?"review-requested":n==="task_failed"?"task-failed":"notification":null}function xQ(e){const t=e?.status;return typeof t!="string"?null:t==="review"?"review-requested":t==="failed"?"task-failed":null}const wQ=["quiet","normal","loud"],yS={quiet:.6,normal:1,loud:1.7},ib="markus-notification-sounds",ag="markus:notification-sounds-changed",Xu={enabled:!0,disabledEvents:[],volume:"normal"};function vS(e){if(!e||typeof e!="object")return{...Xu};const t=e,n=Array.isArray(t.disabledEvents)?t.disabledEvents.filter(i=>bS.has(i)):[],a=wQ.includes(t.volume)?t.volume:"normal";return{enabled:typeof t.enabled=="boolean"?t.enabled:!0,disabledEvents:[...new Set(n)],volume:a}}function xS(){try{return typeof window<"u"?window.localStorage:null}catch{return null}}function Rc(e=xS()){if(!e)return{...Xu};try{const t=e.getItem(ib);return t?vS(JSON.parse(t)):{...Xu}}catch{return{...Xu}}}function Jme(e,t=xS()){const n=vS({...Rc(t),...e});try{t?.setItem(ib,JSON.stringify(n))}catch{}return typeof window<"u"&&window.dispatchEvent(new CustomEvent(ag,{detail:n})),n}function Xme(e){if(typeof window>"u")return()=>{};const t=()=>e(Rc()),n=a=>{a.key===ib&&e(Rc())};return window.addEventListener(ag,t),window.addEventListener("storage",n),()=>{window.removeEventListener(ag,t),window.removeEventListener("storage",n)}}const kQ=4e3,SQ=700;class CQ{constructor(t=()=>Date.now()){this.now=t}lastByEvent=new Map;lastAt=Number.NEGATIVE_INFINITY;shouldPlay(t,n){if(!n.enabled||n.disabledEvents.includes(t))return!1;const a=this.now();return a-(this.lastByEvent.get(t)??Number.NEGATIVE_INFINITY)<kQ||a-this.lastAt<SQ?!1:(this.lastByEvent.set(t,a),this.lastAt=a,!0)}reset(){this.lastByEvent.clear(),this.lastAt=Number.NEGATIVE_INFINITY}}const AQ=new CQ;let w2=null;const TQ=.85;function EQ(e,t){const n=typeof window<"u"?window.AudioContext??window.webkitAudioContext:void 0;if(!n)return;const a=hQ[e];if(!(!a||a.length===0))try{w2??=new n;const i=w2;i.state==="suspended"&&i.resume().catch(()=>{});const l=i.currentTime+.01,c=i.createGain();c.gain.setValueAtTime(t,l);const u=i.createDynamicsCompressor();u.threshold.setValueAtTime(-6,l),u.knee.setValueAtTime(6,l),u.ratio.setValueAtTime(12,l),u.attack.setValueAtTime(.003,l),u.release.setValueAtTime(.15,l),c.connect(u).connect(i.destination);const m=(f,g,h,b,y)=>{const k=i.createOscillator(),C=i.createGain();k.type=g,k.frequency.setValueAtTime(f,b);const T=Math.min(h,TQ);C.gain.setValueAtTime(1e-4,b),C.gain.exponentialRampToValueAtTime(Math.max(T,2e-4),b+.012),C.gain.exponentialRampToValueAtTime(1e-4,y),k.connect(C).connect(c),k.start(b),k.stop(y+.02)};for(const f of a){const g=l+f.startMs/1e3,h=g+f.durationMs/1e3;m(f.freq,f.wave,f.gain,g,h);for(const b of f.overtones??[])m(f.freq*b.mult,f.wave,f.gain*b.gain,g,h)}}catch{}}let wS=EQ;function zh(e,t=Rc(),n=AQ){return n.shouldPlay(e,t)?(wS(bQ(e),yS[t.volume]),!0):!1}function Zme(e,t=Rc().volume){wS(e,yS[t])}function NQ(e){w.useEffect(()=>{if(!e)return;let t=new Map(Lr.entriesSnapshot().map(l=>[l.sessionId,l]));const n=Lr.subscribe(()=>{const l=Lr.entriesSnapshot();for(const c of l){const u=yQ(t.get(c.sessionId),c);u&&zh(u)}t=new Map(l.map(c=>[c.sessionId,c]))}),a=di.on("notification",l=>{const c=vQ(l?.payload);c&&zh(c)}),i=di.on("task:update",l=>{const c=xQ(l?.payload);c&&zh(c)});return()=>{n(),a(),i()}},[e])}let kS=Ec();const rg=new Set;function k2(){kS=Ec(),rg.forEach(e=>e())}typeof window<"u"&&(window.addEventListener("hashchange",k2),window.addEventListener("popstate",k2));function MQ(e){return rg.add(e),()=>rg.delete(e)}function jQ(e){return w.useSyncExternalStore(MQ,()=>kS===e,()=>!1)}var Jo=I4();function $s(e){w.useEffect(()=>VW(),[e])}function xr({title:e,message:t,confirmLabel:n,cancelLabel:a,variant:i="danger",alertOnly:l=!1,checkboxes:c,onConfirm:u,onCancel:m,onCancelClick:f}){const{t:g}=ut("common");$s(!0);const[h,b]=w.useState(()=>{const C={};for(const T of c??[])C[T.id]=T.defaultChecked??!1;return C}),y=i==="primary",k=y?"px-4 py-1.5 text-sm bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg transition-colors":"px-4 py-1.5 text-sm bg-red-600 hover:bg-red-500 text-white rounded-lg transition-colors";return Jo.createPortal(o.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10050] p-4",onClick:m,children:o.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[360px] max-w-[calc(100vw-2rem)] shadow-2xl",onClick:C=>C.stopPropagation(),children:[o.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[o.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center shrink-0 ${y?"bg-brand-500/15":"bg-red-500/15"}`,children:y?o.jsxs("svg",{className:"w-5 h-5 text-brand-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("path",{d:"M12 16v-4"}),o.jsx("path",{d:"M12 8h.01"})]}):o.jsxs("svg",{className:"w-5 h-5 text-red-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),o.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}),o.jsxs("div",{className:"min-w-0 pt-0.5",children:[o.jsx("h3",{className:"font-semibold text-base text-fg-primary",children:e}),o.jsx("p",{className:"text-sm text-fg-secondary mt-1 leading-relaxed",children:t})]})]}),c&&c.length>0&&o.jsx("div",{className:"mb-4 space-y-2",children:c.map(C=>o.jsxs("label",{className:"flex items-center gap-2 text-sm text-fg-secondary cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:h[C.id]??!1,onChange:T=>b(A=>({...A,[C.id]:T.target.checked})),className:"rounded bg-surface-elevated border-border-default"}),C.label]},C.id))}),o.jsxs("div",{className:"flex justify-end gap-2",children:[!l&&o.jsx("button",{type:"button",onClick:()=>{f?f(c?h:void 0):m()},className:"px-4 py-1.5 text-sm border border-border-default rounded-lg text-fg-primary hover:bg-surface-elevated transition-colors",children:a??g("cancel")}),o.jsx("button",{type:"button",onClick:()=>u(c?h:void 0),className:k,children:n??g(l?"ok":"confirm")})]})]})}),document.body)}function SS(e,t){const n=e||t||null;if(!n)return null;if(n.startsWith("http")||n.startsWith("data:")||n.startsWith("/api/"))return n;if(n.startsWith("/")){const a=at.getUrl()?.replace(/\/$/,"")||"";return a?`${a}${n}`:n}return n}function CS({size:e,className:t=""}){const n=Math.max(12,Math.round(e*.55));return o.jsx("div",{className:`rounded-full bg-surface-overlay text-fg-secondary flex items-center justify-center shrink-0 border border-border-default/70 ${t}`,style:{width:e,height:e},"aria-hidden":!0,children:o.jsxs("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),o.jsx("circle",{cx:"12",cy:"7",r:"4"})]})})}function Go({name:e,avatarUrl:t,size:n=28,className:a="",bgClass:i="bg-brand-600 text-on-brand",fallback:l="initials"}){const[c,u]=w.useState(!1);if(w.useEffect(()=>{u(!1)},[t]),!!t&&!c)return o.jsx("img",{src:t,alt:e??"",className:`rounded-full object-cover shrink-0 ${a}`,style:{width:n,height:n},onError:()=>u(!0)});if(l==="icon")return o.jsx(CS,{size:n,className:a});const f=e?.[0]?.toUpperCase()??"?",g=n<=20?"text-[8px]":n<=28?"text-xs":n<=40?"text-sm":"text-lg",h=/\btext-(?!white\b)/.test(i);return o.jsx("div",{className:`rounded-full ${i} flex items-center justify-center ${h?"":"text-white"} ${g} font-bold shrink-0 ${a}`,style:{width:n,height:n},children:f})}function AS({currentUrl:e,name:t,size:n=64,targetType:a="user",targetId:i,onUploaded:l}){const{t:c}=ut("common"),[u,m]=w.useState(null),[f,g]=w.useState(!1),[h,b]=w.useState(!1),[y,k]=w.useState(null),C=w.useRef(null),T=u??e;w.useEffect(()=>{b(!1)},[T]);const A=!!T&&!h,M=w.useCallback(async I=>{if(!I.type.startsWith("image/"))return;if(I.size>2*1024*1024){k(c("imageTooLarge"));return}const B=new FileReader;B.onload=async()=>{const G=B.result;m(G),b(!1),g(!0);try{const{avatarUrl:j}=await Se.auth.uploadAvatar(G,a,i);l?.(j)}catch{m(null)}finally{g(!1)}},B.readAsDataURL(I)},[a,i,l,c]);return o.jsxs("div",{className:"relative inline-block group",children:[o.jsx("input",{ref:C,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",className:"hidden",onChange:I=>{const B=I.target.files?.[0];B&&M(B)}}),o.jsxs("button",{type:"button",onClick:()=>C.current?.click(),className:"relative rounded-full overflow-hidden focus:outline-none focus:ring-2 focus:ring-brand-500/50",style:{width:n,height:n},title:c("clickToSetAvatar",{defaultValue:"Click to set avatar"}),"aria-busy":f,children:[A?o.jsx("img",{src:T,alt:t??"",className:"w-full h-full object-cover",onError:()=>b(!0)}):o.jsx(CS,{size:n}),o.jsx("div",{className:`absolute inset-0 bg-black/45 flex items-center justify-center transition-opacity ${f?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:f?o.jsx("div",{className:"w-5 h-5 border-2 border-white/60 border-t-white rounded-full animate-spin"}):o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"}),o.jsx("circle",{cx:"12",cy:"13",r:"4"})]})})]}),y&&o.jsx(xr,{alertOnly:!0,variant:"danger",title:c("error",{defaultValue:"Error"}),message:y,onConfirm:()=>k(null),onCancel:()=>k(null)})]})}const RQ={total:0,used:0,remaining:0,pct:0,personalLimit:!1};function _Q(e){return e?"billing":"login"}function DQ(e,t){return e?t?"sidebar.hubConnectedAs":"sidebar.hubConnected":"sidebar.hubDisconnected"}function Ro(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function IQ(e,t){const n=e?.memberCuLimit;return n==null||n<=0,!1}function LQ(e,t){if(!e)return RQ;const n=IQ(e),a=e.memberCuLimit!==null&&e.memberCuLimit!==void 0&&e.memberCuLimit>0,i=Ro(e.monthlyQuotaCu)+Ro(e.bonusCu)+Ro(e.purchasedCu),l=n?Ro(e.memberCuLimit):e.creditsBudgetCu??(a?Ro(e.memberCuLimit):i),c=n?Ro(e.memberCuUsed):e.totalConsumedThisPeriod??e.cuUsed??e.memberCuUsed??0,u=Math.max(0,l-c),m=l>0?Math.min(100,Math.round(c/l*100)):0;return{total:l,used:c,remaining:u,pct:m,personalLimit:n}}function TS(e){const[t,n]=w.useState(()=>at.isAuthenticated()),[a,i]=w.useState(()=>Oa()),[l,c]=w.useState(()=>PQ(Oa()?.id??null)),u=w.useCallback(m=>{if(i(Oa()),!at.isAuthenticated()){n(!1),c(null),S2(null,null);return}if(!m?.validate){n(!0);return}sS().then(f=>{n(f),i(Oa())})},[]);return w.useEffect(()=>{u({validate:!0});const m=()=>u(),f=()=>u({validate:!0});return window.addEventListener("markus:hub-auth",m),window.addEventListener("focus",f),()=>{window.removeEventListener("markus:hub-auth",m),window.removeEventListener("focus",f)}},[u]),w.useEffect(()=>{if(!at.isAuthenticated())return;let m=!1;return at.user.plan().then(f=>{if(m)return;const g=LQ(f);c(g),S2(Oa()?.id??null,g)}).catch(()=>{}),()=>{m=!0}},[e,t]),{connected:t,user:a,credits:l,refresh:u}}const ig="markus:hub:credits";function PQ(e){if(!e)return null;try{const t=localStorage.getItem(ig);if(!t)return null;const n=JSON.parse(t);return n.userId!==e||!n.credits?null:n.credits}catch{return null}}function S2(e,t){try{if(!e||!t){localStorage.removeItem(ig);return}localStorage.setItem(ig,JSON.stringify({userId:e,credits:t}))}catch{}}function Ko(){return!!window.markusDesktop}function Or(e){window.markusDesktop?window.markusDesktop.openExternal(e):window.open(e,"_blank","noopener,noreferrer")}function OQ({authUser:e,onNavigate:t,onLogout:n}){const{t:a}=ut(["settings","common","nav"]),[i,l]=w.useState(!1),[c,u]=w.useState(!1),{connected:m,user:f,credits:g}=TS(i);w.useEffect(()=>{const C=()=>l(!0);return window.addEventListener("markus:open-drawer",C),()=>window.removeEventListener("markus:open-drawer",C)},[]),w.useEffect(()=>(i?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[i]);const h=C=>{if(l(!1),C==="__edit_profile"){window.dispatchEvent(new CustomEvent("markus:open-edit-profile"));return}t(C)},b=()=>{if(l(!1),_Q(m)==="login"){Ia().catch(()=>{});return}Or(`${at.getUrl().replace(/\/$/,"")}/settings?tab=billing`)},y=()=>{l(!1),yt.navigate(ce.SETTINGS,{tab:"account"})};if(!i)return null;const k=a(`nav:${DQ(m,!!f?.username)}`,{username:f?.username??""});return o.jsxs("div",{className:"fixed inset-0 z-[100]",children:[o.jsx("div",{className:"absolute inset-0 bg-black/40 animate-fadeIn",onClick:()=>l(!1)}),o.jsxs("aside",{className:"absolute inset-y-0 left-0 w-72 bg-surface-secondary shadow-2xl flex flex-col animate-slideInLeft",children:[o.jsx("div",{className:"px-5 pt-6 pb-4 border-b border-border-default",children:e?o.jsxs("button",{onClick:()=>h("__edit_profile"),className:"flex items-center gap-3 w-full text-left",children:[o.jsx(Go,{name:e.name||"User",avatarUrl:e.avatarUrl,size:40}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:e.name||a("common:userPlaceholder")}),o.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:e.email||e.role})]}),o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-fg-tertiary shrink-0",children:o.jsx("polyline",{points:"9 18 15 12 9 6"})})]}):o.jsx("div",{className:"text-sm text-fg-tertiary",children:a("common:loading")})}),o.jsxs("div",{className:"px-3 pt-3 pb-1 border-b border-border-default space-y-0.5",children:[o.jsxs("button",{onClick:b,title:m?a("common:creditBalanceOpenHub"):void 0,className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-lg hover:bg-surface-overlay active:bg-surface-overlay transition-colors text-left",children:[o.jsx("span",{className:"w-[18px] h-[18px] flex items-center justify-center shrink-0 text-fg-tertiary",children:o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z"}),o.jsx("path",{d:"M12.5 5.5v13",strokeDasharray:"2 2.5"})]})}),o.jsx("span",{className:"flex-1 min-w-0 text-sm text-fg-secondary truncate",children:a("common:creditBalance")}),o.jsx("span",{className:"text-sm font-medium text-fg-primary shrink-0 tabular-nums",children:m?g!==null?g.remaining.toLocaleString():"—":a("nav:sidebar.hubLoginShort")}),o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-fg-tertiary shrink-0",children:o.jsx("polyline",{points:"9 18 15 12 9 6"})})]}),o.jsxs("button",{onClick:y,className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-lg hover:bg-surface-overlay transition-colors text-left",children:[o.jsx("span",{className:"w-[18px] h-[18px] flex items-center justify-center shrink-0",children:o.jsx("span",{className:`w-2 h-2 rounded-full ${m?"bg-emerald-500":"bg-fg-muted"}`})}),o.jsx("span",{className:"flex-1 min-w-0 text-sm text-fg-secondary truncate",children:k}),o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-fg-tertiary shrink-0",children:o.jsx("polyline",{points:"9 18 15 12 9 6"})})]})]}),o.jsxs("nav",{className:"flex-1 overflow-y-auto py-3 px-3 space-y-1",children:[o.jsx(qh,{icon:o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),o.jsx("polyline",{points:"9 22 9 12 15 12 15 22"})]}),label:a("common:home",{defaultValue:"Home"}),onClick:()=>h(ce.HOME)}),o.jsx(qh,{icon:o.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("path",{d:Xm[ce.BUILDER]})}),label:a("nav:builder"),onClick:()=>h(ce.BUILDER)}),o.jsx(qh,{icon:o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("circle",{cx:"12",cy:"12",r:"3"}),o.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),label:a("settings:title"),onClick:()=>h(ce.SETTINGS)})]})]}),c&&n&&o.jsx(xr,{title:a("common:signOutConfirmTitle"),message:a("common:signOutConfirmMessage"),confirmLabel:a("common:signOut"),variant:"primary",onConfirm:()=>{u(!1),l(!1),n()},onCancel:()=>u(!1)})]})}function qh({icon:e,label:t,onClick:n}){return o.jsxs("button",{onClick:n,className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm text-fg-secondary hover:text-fg-primary hover:bg-surface-overlay transition-colors",children:[e,o.jsx("span",{children:t})]})}function HQ(){window.dispatchEvent(new CustomEvent("markus:open-drawer"))}function ES({className:e=""}){const{t}=ut("common");return o.jsx("button",{onClick:HQ,className:`p-1.5 -ml-1 rounded-lg hover:bg-surface-overlay transition-colors shrink-0 ${e}`,"aria-label":t("menu"),children:o.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),o.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),o.jsx("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]})})}function BQ({onClose:e,onClaimed:t}){const{t:n}=ut(["home","common"]);$s(!0);const[a,i]=w.useState("loading"),[l,c]=w.useState(1e3),[u,m]=w.useState(""),f=w.useRef(t);f.current=t;const g=w.useRef(!1),h=()=>`${at.getUrl().replace(/\/$/,"")}/settings?tab=overview&claim=1`,b=w.useCallback(async()=>{i("loading"),m("");try{Tn()||await Ia();const k=await at.user.claimFreeCreditsStatus();if(typeof k.amountCu=="number"&&k.amountCu>0&&c(k.amountCu),k.claimed){i("already"),f.current();return}i("open_hub")}catch(k){m(k instanceof Error?k.message:n("claim.loadFailed")),i("error")}},[n]);w.useEffect(()=>{g.current||(g.current=!0,b())},[b]);const y=()=>{const k=h();Ko()?Or(k):window.open(k,"_blank","noopener,noreferrer")};return o.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60] p-4",onClick:e,children:o.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-2xl p-6 w-full max-w-md shadow-2xl",onClick:k=>k.stopPropagation(),children:[o.jsxs("div",{className:"flex items-start justify-between gap-3 mb-4",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"font-semibold text-lg text-fg-primary",children:n("claim.title")}),o.jsx("p",{className:"text-sm text-fg-secondary mt-1 leading-relaxed",children:n("claim.subtitle")})]}),o.jsx("button",{type:"button",onClick:e,className:"text-fg-tertiary hover:text-fg-primary text-lg leading-none",children:"×"})]}),a==="loading"&&o.jsx("p",{className:"text-sm text-fg-tertiary mb-5",children:n("claim.loading")}),a==="already"&&o.jsxs("div",{className:"space-y-4",children:[o.jsx("p",{className:"text-sm text-emerald-400",children:n("claim.success",{amount:l.toLocaleString()})}),o.jsx("p",{className:"text-sm text-fg-secondary",children:n("claim.startUsing")}),o.jsx("button",{type:"button",onClick:e,className:"w-full py-2.5 text-sm font-medium rounded-xl bg-brand-500 text-on-brand hover:bg-brand-600",children:n("common:close")})]}),a==="open_hub"&&o.jsxs("div",{className:"space-y-4",children:[o.jsx("p",{className:"text-sm text-fg-secondary leading-relaxed",children:n("claim.openHubHint",{amount:l.toLocaleString()})}),o.jsx("button",{type:"button",onClick:y,className:"w-full py-2.5 text-sm font-medium rounded-xl bg-brand-500 text-on-brand hover:bg-brand-600",children:n("claim.openHub")})]}),a==="error"&&o.jsxs("div",{className:"space-y-3",children:[o.jsx("p",{className:"text-sm text-red-400",children:u}),o.jsx("button",{type:"button",onClick:()=>{b()},className:"w-full py-2 text-sm rounded-xl border border-border-default",children:n("claim.retry")})]})]})})}function C2(e){return e.includes(":")?e:`common:${e}`}const _r=[{id:"toggle-left",group:"layout",keys:["B"],label:"Toggle left sidebar",labelKey:"shortcuts.toggleLeft",page:"any"},{id:"nav-l0-jk",group:"navigation",keys:["J / K"],label:"L0: switch page up / down",labelKey:"shortcuts.navL0Jk",page:"any",bare:!0},{id:"nav-l0-l",group:"navigation",keys:["L"],label:"L0: enter page L1",labelKey:"shortcuts.navL0L",page:"any",bare:!0},{id:"nav-l0-h",group:"navigation",keys:["H"],label:"From page L1: focus app rail (L0)",labelKey:"shortcuts.navL0H",page:"any",bare:!0},{id:"search",group:"search",keys:["P"],label:"Global search",labelKey:"shortcuts.search",page:"any"},{id:"help",group:"help",keys:["/"],label:"Show keyboard shortcuts",labelKey:"shortcuts.help",page:"any"},{id:"new-conversation",group:"team",keys:["N"],label:"New conversation",labelKey:"shortcuts.newConversation",page:"team"},{id:"cycle-session-tab",group:"team",keys:["Ctrl","Tab"],label:"Next conversation tab",labelKey:"shortcuts.cycleSessionTab",page:"team"},{id:"cycle-session-tab-prev",group:"team",keys:["Ctrl","Shift","Tab"],label:"Previous conversation tab",labelKey:"shortcuts.cycleSessionTabPrev",page:"team"}];function NS(e){return`markus_shortcut_lesson_${e}`}function km(e){try{const t=localStorage.getItem(NS(e));if(!t)return[];const n=JSON.parse(t);return Array.isArray(n)?n.filter(a=>typeof a=="string"):[]}catch{return[]}}function Sm(e,t){try{localStorage.setItem(NS(e),JSON.stringify(t.filter(Boolean)))}catch{}}function sb(e){const t=new Set(km(e));return _r.every(n=>t.has(n.id))}function zQ(e,t,n){const a=_r.find(l=>MS(e,l.id,n));if(!a)return sb(t);const i=new Set(km(t));return i.add(a.id),Sm(t,[...i]),_r.every(l=>i.has(l.id))}function qQ(e){Sm(e,_r.map(t=>t.id))}function MS(e,t,n){const a=n?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey,i=e.key.toLowerCase();switch(t){case"toggle-left":return a&&!e.altKey&&!e.shiftKey&&i==="b";case"nav-l0-jk":return!e.metaKey&&!e.ctrlKey&&!e.altKey&&(i==="j"||i==="k");case"nav-l0-l":return!e.metaKey&&!e.ctrlKey&&!e.altKey&&i==="l";case"nav-l0-h":return!e.metaKey&&!e.ctrlKey&&!e.altKey&&i==="h";case"search":return a&&!e.altKey&&!e.shiftKey&&i==="p";case"help":return a&&!e.altKey&&(i==="/"||!e.shiftKey&&(e.code==="Slash"||i==="/"));case"new-conversation":return a&&!e.altKey&&!e.shiftKey&&i==="n";case"cycle-session-tab":return e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key==="Tab"&&!e.shiftKey;case"cycle-session-tab-prev":return e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key==="Tab"&&e.shiftKey;default:return!1}}const $Q=[{id:"toggle-left",group:"layout",keys:["B"],label:"Toggle left sidebar (L0 + page L1)",labelKey:"shortcuts.toggleLeft",page:"any"},{id:"help",group:"help",keys:["/"],label:"Show keyboard shortcuts",labelKey:"shortcuts.help",page:"any"},{id:"search",group:"search",keys:["P"],label:"Global search",labelKey:"shortcuts.search",page:"any"},{id:"nav-l0-jk",group:"navigation",keys:["J / K"],label:"L0: switch page up / down",labelKey:"shortcuts.navL0Jk",page:"any",bare:!0},{id:"nav-l0-l",group:"navigation",keys:["L"],label:"L0: enter page L1 (Team / Tasks / Output / Store / Settings)",labelKey:"shortcuts.navL0L",page:"any",bare:!0},{id:"nav-l0-h",group:"navigation",keys:["H"],label:"From page L1: focus app rail (L0)",labelKey:"shortcuts.navL0H",page:"any",bare:!0},{id:"settings-back",group:"navigation",keys:["H"],label:"Settings: go back to previous page",labelKey:"shortcuts.settingsBack",page:"any",bare:!0},{id:"nav-jk-settings",group:"navigation",keys:["J / K"],label:"Settings L1: switch settings tabs",labelKey:"shortcuts.navJkSettings",page:"any",bare:!0},{id:"nav-hl-work",group:"navigation",keys:["H / L"],label:"Tasks: item list ↔ project L1 ↔ app rail",labelKey:"shortcuts.navHlWork",page:"work",bare:!0},{id:"nav-jk-work",group:"navigation",keys:["J / K"],label:"Tasks: move project / item selection",labelKey:"shortcuts.navJkWork",page:"work",bare:!0},{id:"nav-hl-team",group:"navigation",keys:["H / L"],label:"Team: L0 ↔ L1 ↔ L2 (L ignored on deepest pane)",labelKey:"shortcuts.navHlTeam",page:"team",bare:!0},{id:"nav-jk-team",group:"navigation",keys:["J / K"],label:"Team L1: move roster selection",labelKey:"shortcuts.navJkTeam",page:"team",bare:!0},{id:"nav-jk-team-l2",group:"navigation",keys:["J / K"],label:"Team L2: move team member selection",labelKey:"shortcuts.navJkTeamL2",page:"team",bare:!0},{id:"nav-jk-deliverables",group:"navigation",keys:["J / K"],label:"Output L1: move deliverable selection",labelKey:"shortcuts.navJkDeliverables",page:"deliverables",bare:!0},{id:"nav-jk-store",group:"navigation",keys:["J / K"],label:"Store L1: switch store tabs",labelKey:"shortcuts.navJkStore",page:"store",bare:!0},{id:"toggle-project-detail",group:"tasks",keys:["J"],label:"Toggle project detail (Tasks)",labelKey:"shortcuts.toggleProjectDetail",page:"work"},{id:"toggle-item-detail",group:"tasks",keys:["L"],label:"Toggle task / requirement detail (Tasks)",labelKey:"shortcuts.toggleItemDetail",page:"work"},{id:"cycle-board",group:"tasks",keys:["Ctrl","Tab"],label:"Cycle Tasks views",labelKey:"shortcuts.cycleBoard",page:"work",bare:!0},{id:"new-conversation",group:"team",keys:["N"],label:"New conversation",labelKey:"shortcuts.newConversation",page:"team"},{id:"cycle-session-tab",group:"team",keys:["Ctrl","Tab"],label:"Next conversation tab",labelKey:"shortcuts.cycleSessionTab",page:"team"},{id:"cycle-session-tab-prev",group:"team",keys:["Ctrl","Shift","Tab"],label:"Previous conversation tab",labelKey:"shortcuts.cycleSessionTabPrev",page:"team"},{id:"toggle-browser",group:"team",keys:["L"],label:"Toggle right panel · Browser",labelKey:"shortcuts.toggleBrowser",page:"team"},{id:"toggle-terminal",group:"team",keys:["J"],label:"Toggle right panel · Terminal",labelKey:"shortcuts.toggleTerminal",page:"team"},{id:"next-tab",group:"rightPanel",keys:["Shift","]"],label:"Next right-panel tab",labelKey:"shortcuts.nextTab",page:"team"},{id:"prev-tab",group:"rightPanel",keys:["Shift","["],label:"Previous right-panel tab",labelKey:"shortcuts.prevTab",page:"team"},{id:"tab-n",group:"rightPanel",keys:["1…9"],label:"Jump to Nth right-panel tab",labelKey:"shortcuts.tabN",page:"team"},{id:"close-tab",group:"rightPanel",keys:["W"],label:"Close right-panel tab",labelKey:"shortcuts.closeTab",page:"team"},{id:"new-tab",group:"rightPanel",keys:["T"],label:"New browser tab / shell",labelKey:"shortcuts.newTab",page:"team"},{id:"term-search",group:"terminal",keys:["F"],label:"Search in terminal",labelKey:"shortcuts.termSearch",page:"team"},{id:"term-to-chat",group:"terminal",keys:["Shift","A"],label:"Add terminal selection to chat",labelKey:"shortcuts.termToChat",page:"team"}];function jS(e,t,n){return n||e[0]==="Ctrl"||e[0]==="Tab"||e[0]==="J / K"||e[0]==="H / L"?e.join(e[0]==="Ctrl"?"+":" "):e.length===1&&(e[0]==="H"||e[0]==="L"||e[0]==="J"||e[0]==="K")?e[0]:[t?"⌘":"Ctrl",...e].join(t?"":"+")}function A2(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable?!0:e.closest(".xterm")!==null}function T2(e){return e instanceof HTMLElement?e.closest(".xterm")!==null:!1}const FQ=["layout","navigation","search","help","team"];function UQ(e,t){return t&&e.startsWith("⌘")?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-[15px] font-semibold leading-none",children:"⌘"}),o.jsx("span",{className:"text-[13px]",children:e.slice(1)})]}):o.jsx("span",{className:"text-[13px]",children:e})}function GQ({open:e,userId:t,onClose:n,onCompleted:a}){const{t:i}=ut(["home","common"]),l=typeof navigator<"u"&&navigator.platform.toUpperCase().includes("MAC"),[c,u]=w.useState(()=>new Set(t?km(t):[]));w.useEffect(()=>{e&&t&&u(new Set(km(t)))},[e,t]);const m=_r.every(y=>c.has(y.id)),f=c.size;w.useEffect(()=>{!e||!t||m&&sb(t)&&a()},[e,t,m]);const g=w.useMemo(()=>FQ.map(y=>({group:y,items:_r.filter(k=>k.group===y)})).filter(y=>y.items.length>0),[]);if(w.useEffect(()=>{if(!e||!t)return;const y=k=>{if(k.key==="Escape"){n();return}const C={key:k.key,code:k.code,metaKey:k.metaKey,ctrlKey:k.ctrlKey,altKey:k.altKey,shiftKey:k.shiftKey},T=_r.find(A=>MS(C,A.id,l));T&&((k.metaKey||k.ctrlKey||k.altKey)&&k.preventDefault(),k.stopPropagation(),u(A=>{if(A.has(T.id))return A;const M=new Set(A);return M.add(T.id),t&&Sm(t,[...M]),M}))};return window.addEventListener("keydown",y,!0),()=>window.removeEventListener("keydown",y,!0)},[e,t,l,n]),!e)return null;const h=y=>{t&&u(k=>{const C=new Set(k);return C.has(y)?C.delete(y):C.add(y),Sm(t,[...C]),C})},b=()=>{t&&(qQ(t),u(new Set(_r.map(y=>y.id))),a())};return o.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/45 backdrop-blur-[1px] p-4",onMouseDown:y=>{y.target===y.currentTarget&&n()},role:"dialog","aria-modal":"true","aria-label":i("home:checklist.shortcutLesson.title"),children:o.jsxs("div",{className:"w-full max-w-md max-h-[80vh] overflow-auto rounded-xl border border-border-default bg-surface-primary shadow-2xl",children:[o.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between gap-3 px-4 py-3 border-b border-border-default bg-surface-primary",children:[o.jsx("h2",{className:"text-sm font-semibold text-fg-primary",children:i("checklist.shortcutLesson.title")}),o.jsx("button",{type:"button",onClick:n,className:"w-7 h-7 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated","aria-label":i("common:shortcuts.close"),children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsxs("div",{className:"px-4 py-3",children:[o.jsx("p",{className:"text-xs text-fg-secondary mb-3",children:i("checklist.shortcutLesson.subtitle")}),m?o.jsxs("div",{className:"flex items-center gap-2 bg-green-500/10 border border-green-500/30 rounded-xl px-4 py-3 mb-4",children:[o.jsx("span",{className:"text-green-600 text-base",children:"✓"}),o.jsx("span",{className:"text-sm font-medium text-green-600",children:i("checklist.shortcutLesson.allDone")})]}):o.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[o.jsx("div",{className:"flex-1 h-1.5 bg-surface-elevated rounded-full overflow-hidden",children:o.jsx("div",{className:"h-full bg-brand-500 rounded-full transition-all duration-300",style:{width:`${f/_r.length*100}%`}})}),o.jsx("span",{className:"text-[11px] text-fg-secondary font-medium shrink-0",children:i("checklist.progress",{done:f,total:_r.length})})]}),o.jsx("div",{className:"space-y-4",children:g.map(({group:y,items:k})=>o.jsxs("section",{children:[o.jsx("h3",{className:"text-[11px] font-semibold uppercase tracking-wide text-fg-tertiary mb-2",children:i(C2(`shortcuts.groups.${y}`),{defaultValue:y})}),o.jsx("ul",{className:"space-y-1",children:k.map(C=>{const T=c.has(C.id);return o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:()=>h(C.id),className:"w-full flex items-center justify-between gap-3 rounded-lg px-2 py-2 text-left hover:bg-surface-elevated/60 transition-colors",children:[o.jsxs("span",{className:"flex items-center gap-2.5 min-w-0",children:[o.jsx("span",{className:`shrink-0 w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${T?"bg-green-500 border-green-500":"border-border-default"}`,children:T&&o.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),o.jsx("span",{className:`text-sm min-w-0 ${T?"text-fg-tertiary line-through":"text-fg-primary"}`,children:i(C2(C.labelKey))})]}),o.jsx("kbd",{className:"shrink-0 px-2 py-1 rounded bg-surface-elevated border border-border-default font-medium leading-none text-fg-primary font-mono",children:UQ(jS(C.keys,l,C.bare),l)})]})},C.id)})})]},y))})]}),o.jsxs("div",{className:"sticky bottom-0 border-t border-border-default bg-surface-primary px-4 py-3 flex items-center justify-end gap-2",children:[o.jsx("button",{type:"button",onClick:b,className:"px-3 py-2 text-sm rounded-xl border border-border-default text-fg-secondary hover:bg-surface-elevated hover:text-fg-primary transition-colors font-medium",children:i("checklist.shortcutLesson.markAllLearned")}),o.jsx("button",{type:"button",onClick:n,className:`px-4 py-2 text-sm rounded-xl transition-colors font-medium ${m?"bg-green-600 hover:bg-green-500 text-on-brand":"bg-brand-600 hover:bg-brand-500 text-on-brand"}`,children:i(m?"checklist.shortcutLesson.done":"common:close")})]})]})})}function E2(e){const t=e.metadata??{};return e.type==="agent_report"&&!t.creditExhausted&&!t.templateUpdates&&(e.actionType==="open_chat"||!!t.agentId&&e.actionType!=="navigate")}function N2(e){const t=e.metadata??{},n=l=>typeof l=="string"&&l.length>0?l:void 0,a=n(t.taskId),i=n(t.requirementId);return a?`task:${a}`:i?`req:${i}`:null}function RS(e,t){const n=new Set,a=N2(e),i=a?t.filter(l=>!l.read&&N2(l)===a):[e];for(const l of i)l.read||E2(l)||n.add(l.id);!e.read&&!E2(e)&&n.add(e.id);for(const l of n)Se.notifications.markRead(l).catch(()=>{});return n.size>0&&window.dispatchEvent(new CustomEvent("markus:notifications-changed")),n}async function KQ(e){const t=await Se.notifications.markAllRead(e);return RY("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed")),t?.count??0}const M2=6e4,j2=36e5,R2=864e5;function VQ(e){if(!Number.isFinite(e))return"";const t=Date.now()-e;if(t<0||t<M2)return tn.t("common:justNow");if(t<j2)return tn.t("common:time.minutesAgo",{count:Math.floor(t/M2)});if(t<R2)return tn.t("common:time.hoursAgo",{count:Math.floor(t/j2)});const n=Math.floor(t/R2);return n===1?tn.t("common:time.yesterday"):tn.t("common:time.daysAgo",{count:n})}function WQ(e){return typeof e=="number"?e:e?new Date(e).getTime():Number.NaN}function _2(e){return VQ(WQ(e))}const D2={approved:{labelKey:"common:approvalStatus.approved",dot:"bg-fg-muted/30",chip:"bg-green-500/8 text-green-600/70"},rejected:{labelKey:"common:approvalStatus.rejected",dot:"bg-fg-muted/30",chip:"bg-red-500/8 text-red-500/70"},cancelled:{labelKey:"common:approvalStatus.cancelled",dot:"bg-fg-muted/25",chip:"bg-surface-overlay text-fg-tertiary"},expired:{labelKey:"common:approvalStatus.expired",dot:"bg-fg-muted/25",chip:"bg-amber-500/8 text-amber-600/70"}},I2=15,_S="markus_history_ui";function L2(){try{const e=localStorage.getItem(_S);if(!e)return{tab:"all",scrollTop:0};const t=JSON.parse(e);return{tab:t.tab==="approvals"||t.tab==="notices"?t.tab:"all",scrollTop:typeof t.scrollTop=="number"&&t.scrollTop>=0?t.scrollTop:0}}catch{return{tab:"all",scrollTop:0}}}function YQ(e){try{localStorage.setItem(_S,JSON.stringify(e))}catch{}}const P2=200;function QQ(e){w.useEffect(()=>{if(!e)return;const t=[document.documentElement,document.body,document.querySelector("[data-app-scroll]")].filter(l=>!!l),n=t.map(l=>l.style.overflow),a=t.map(l=>l.style.paddingRight),i=window.innerWidth-document.documentElement.clientWidth;return t.forEach((l,c)=>{l.style.overflow="hidden",c===0&&i>0&&(l.style.paddingRight=`${i}px`),a[c]}),()=>{t.forEach((l,c)=>{l.style.overflow=n[c]??"",l.style.paddingRight=a[c]??""})}},[e])}function JQ(e){return e.actionUrl&&!e.actionType?()=>window.open(e.actionUrl,"_blank","noopener"):KY(e)?()=>VY(e):null}function XQ({open:e,onClose:t,userId:n}){const[a,i]=w.useState(()=>L2().tab),l=w.useRef(L2().scrollTop),[c,u]=w.useState([]),m=w.useRef(null),f=w.useRef(null),[g,h]=w.useState(0),[b,y]=w.useState(null),[k,C]=w.useState("loading"),[T,A]=w.useState("loading"),[M,I]=w.useState(0),[B,G]=w.useState([]),[j,O]=w.useState(!1),[F,Y]=w.useState(!1),[q,V]=w.useState(null),{t:z}=ut(["team","common","home"]),[J,D]=w.useState(!1),[ee,R]=w.useState(!1),[te,le]=w.useState(null),ke=w.useRef(null),$=w.useRef({loading:!1,done:!1,count:0});$.current={loading:J,done:ee,count:c.length};const W=w.useCallback(async je=>{if(n){D(!0);try{const Ye=await Se.notifications.list(n,!1,{limit:I2,offset:je}),xt=Ye.notifications??[];u(ft=>{const rt=new Set(ft.map(jt=>jt.id));return[...ft,...xt.filter(jt=>!rt.has(jt.id))].slice(0,P2)}),h(Ye.totalCount??0);const mt=Ye.unreadCount;y(typeof mt=="number"?mt:null),C(typeof mt=="number"?"ok":"error"),(xt.length===0||xt.length<I2||$.current.count+xt.length>=P2)&&R(!0),le(null)}catch(Ye){le(Ye instanceof Error?Ye.message:z("common:loadFailed")),C("error")}finally{D(!1)}}},[n,z]);w.useEffect(()=>{if(!e||!n)return;const je=()=>{W(0),Se.approvals.list().then(Ye=>{G((Ye.approvals??[]).filter(xt=>xt.status==="pending")),A("ok")}).catch(()=>A("error"))};return window.addEventListener("markus:notifications-changed",je),window.addEventListener("markus:data-changed",je),()=>{window.removeEventListener("markus:notifications-changed",je),window.removeEventListener("markus:data-changed",je)}},[e,n,W]);const oe=w.useCallback(()=>{le(null),C("loading"),A("loading"),I(je=>je+1)},[]),L=w.useCallback(async()=>{if(!(!n||F)){Y(!0),V(null);try{await KQ(n),u(je=>je.map(Ye=>Ye.read?Ye:{...Ye,read:!0})),y(0),C("ok")}catch(je){V(je instanceof Error?je.message:String(je))}finally{Y(!1)}}},[n,F]);w.useEffect(()=>{!e||!n||(u([]),h(0),R(!1),le(null),C("loading"),A("loading"),W(0),Se.approvals.list(void 0,{limit:100}).then(je=>{G((je.approvals??[]).filter(Ye=>Ye.status!=="pending")),A("ok")}).catch(()=>A("error")))},[e,n,W,M]),w.useEffect(()=>{if(!e)return;const je=ke.current;if(!je||typeof IntersectionObserver>"u")return;const Ye=new IntersectionObserver(xt=>{const mt=$.current;!xt[0]?.isIntersecting||mt.loading||mt.done||W(mt.count)},{rootMargin:"120px"});return Ye.observe(je),()=>Ye.disconnect()},[e,W,c.length]);const Ne=w.useMemo(()=>{const je=B.map(mt=>({kind:"approval",at:mt.respondedAt??mt.requestedAt,approval:mt})),Ye=c.map(mt=>({kind:"notice",at:mt.createdAt,notice:mt})),xt=[...je,...Ye].sort((mt,ft)=>(ft.at??"").localeCompare(mt.at??""));return j?xt.filter(mt=>mt.kind==="notice"&&!mt.notice.read):a==="approvals"?xt.filter(mt=>mt.kind==="approval"):a==="notices"?xt.filter(mt=>mt.kind==="notice"):xt},[B,c,a,j]),qe=B.length,me=k==="ok"?b:null,ze=Ne.length===0&&!J&&!te&&T!=="error"&&k!=="error",Ue=j&&k==="ok"&&me===0&&(g>0||c.length>0);return QQ(e),w.useEffect(()=>{if(!e)return;const je=window.setTimeout(()=>{const Ye=m.current;Ye&&(Ye.scrollTop=l.current)},60);return()=>window.clearTimeout(je)},[e,a]),e?o.jsx("div",{ref:f,className:"fixed inset-0 z-50 flex items-start justify-center bg-black/40 p-4 sm:p-6 overflow-hidden overscroll-none",onClick:t,children:o.jsxs("div",{className:"w-full max-w-lg h-[78vh] bg-surface-elevated rounded-2xl shadow-xl overflow-hidden flex flex-col mt-4",onClick:je=>je.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-4 pt-3.5 pb-2 shrink-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:z("home:attention.history")}),k==="error"&&o.jsx("span",{className:"text-[10px] font-semibold px-1.5 py-0.5 rounded-full bg-rose-500/10 text-rose-600",children:z("team:history.unreadUnknown")}),k==="loading"&&o.jsx("span",{className:"text-[10px] text-fg-muted",children:z("team:history.unreadLoading")}),me!==null&&me>0&&o.jsx("button",{onClick:()=>O(je=>!je),"aria-pressed":j,title:z(j?"team:history.showAll":"team:history.onlyUnread"),className:`text-[10px] font-semibold px-1.5 py-0.5 rounded-full tabular-nums transition-colors ${j?"bg-brand-500 text-on-brand":"text-brand-400 bg-brand-500/10 hover:bg-brand-500/20"}`,children:z("team:history.unreadCount",{count:me})}),me!==null&&j&&me===0&&o.jsx("button",{onClick:()=>O(!1),className:"text-[10px] font-semibold text-fg-tertiary bg-surface-overlay px-1.5 py-0.5 rounded-full",children:z("team:history.allReadShowAll")}),me!==null&&me>0&&o.jsx("button",{onClick:()=>{L()},disabled:F,"data-mark-all-read":!0,className:"text-[10px] font-medium text-fg-tertiary hover:text-fg-primary px-1.5 py-0.5 rounded-full hover:bg-surface-overlay transition-colors disabled:opacity-50",children:F?"…":z("team:notifications.markAllRead")})]}),o.jsx("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-surface-overlay text-fg-tertiary","aria-label":z("common:close"),children:o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsx("div",{className:"px-4 pb-2.5 shrink-0 flex items-center gap-1",children:[{id:"all",label:z("common:all"),count:qe+c.length},{id:"approvals",label:z("team:history.tabApprovals"),count:qe},{id:"notices",label:z("team:notifications.notifications"),count:c.length}].map(je=>{const Ye=a===je.id;return o.jsxs("button",{onClick:()=>i(je.id),className:`px-2.5 py-1 rounded-full text-[11px] font-medium transition-colors flex items-center gap-1 ${Ye?"bg-surface-overlay text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:[je.label,je.count>0&&o.jsx("span",{className:"tabular-nums text-fg-muted",children:je.count})]},je.id)})}),o.jsxs("div",{ref:m,onScroll:je=>YQ({tab:a,scrollTop:je.currentTarget.scrollTop}),className:"flex-1 min-h-0 overflow-y-auto overscroll-contain scrollbar-thin px-2 pb-2",children:[q&&o.jsxs("div",{"data-mark-all-error":!0,className:"mx-1 mb-2 rounded-lg bg-rose-500/10 text-rose-600 text-[11px] px-3 py-2 flex items-center gap-2",children:[o.jsx("span",{className:"flex-1",children:z("team:notifications.markAllReadFailed")}),o.jsx("button",{onClick:()=>{L()},disabled:F,className:"shrink-0 rounded bg-rose-500/15 px-2 py-0.5 font-semibold hover:bg-rose-500/25 disabled:opacity-50",children:z("common:retry")})]}),(te||T==="error")&&o.jsxs("div",{className:"mx-1 mb-2 rounded-lg bg-rose-500/10 text-rose-600 text-[11px] px-3 py-2 flex items-center gap-2",children:[o.jsx("span",{className:"flex-1",children:[te?z("team:history.noticesLoadFailed",{error:te}):null,T==="error"?z("team:history.approvalsLoadFailed"):null].filter(Boolean).join(" ")}),o.jsx("button",{onClick:oe,className:"shrink-0 rounded bg-rose-500/15 px-2 py-0.5 font-semibold hover:bg-rose-500/25",children:z("common:retry")})]}),ze&&(Ue?o.jsxs("div",{"data-empty-unread":!0,className:"px-3 py-10 text-center",children:[o.jsx("div",{className:"text-[12px] text-fg-secondary",children:z("team:notifications.noUnread")}),o.jsx("button",{onClick:()=>O(!1),className:"mt-2 rounded-full bg-surface-overlay px-2.5 py-1 text-[11px] text-fg-tertiary hover:text-fg-primary transition-colors",children:z("team:notifications.filterAll")})]}):o.jsxs("div",{className:"px-3 py-10 text-center",children:[o.jsx("div",{className:"text-[12px] text-fg-secondary",children:z("team:history.empty")}),o.jsx("div",{className:"text-[11px] text-fg-muted mt-1",children:z("team:history.emptyHint")})]})),Ne.map(je=>je.kind==="approval"?(()=>{const Ye=D2[je.approval.status]??D2.cancelled,xt=je.approval.respondedAt??je.approval.requestedAt;return o.jsxs("div",{onClick:()=>{t(),ng(je.approval)},title:z("team:history.openTarget"),className:"flex items-center gap-2.5 px-2.5 py-2.5 rounded-xl hover:bg-surface-overlay/50 transition-colors cursor-pointer",children:[o.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Ye.dot}`}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:`text-[10px] font-semibold px-1.5 py-0.5 rounded shrink-0 ${Ye.chip}`,children:z(Ye.labelKey)}),o.jsx("span",{className:"text-xs text-fg-secondary truncate",children:je.approval.title})]}),o.jsxs("div",{className:"text-[11px] text-fg-tertiary mt-0.5 truncate",children:[je.approval.agentName," · ",je.approval.status==="approved"?v2(je.approval)?z("team:history.answered"):z("common:approvalStatus.approved"):je.approval.status==="rejected"?v2(je.approval)?z("team:history.unanswered"):z("common:approvalStatus.rejected"):z(Ye.labelKey)," ",z("team:history.atTime",{time:_2(xt)}),je.approval.respondedAt&&je.approval.requestedAt&&o.jsxs(o.Fragment,{children:[" · ",z("team:history.waited",{duration:mS({waitingSince:je.approval.requestedAt,waitingBasis:"requested"},Date.parse(je.approval.respondedAt))})]})]})]})]},`a:${je.approval.id}`)})():(()=>{const Ye=JQ(je.notice);return o.jsxs("div",{title:Ye?void 0:z("team:history.noTargetHint"),className:`flex items-start gap-2.5 px-2.5 py-2.5 rounded-xl transition-colors ${Ye?"hover:bg-surface-overlay/50 cursor-pointer":""}`,onClick:Ye?()=>{const xt=RS(je.notice,c);u(mt=>mt.map(ft=>xt.has(ft.id)?{...ft,read:!0}:ft)),t(),Ye()}:void 0,children:[o.jsx("span",{className:`w-1.5 h-1.5 rounded-full mt-1.5 shrink-0 ${je.notice.read?"bg-fg-muted/40":"bg-brand-500"}`}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:`text-xs truncate ${je.notice.read?"text-fg-tertiary":"text-fg-primary font-medium"}`,children:[je.notice.title,!Ye&&o.jsx("span",{className:"ml-1.5 align-middle text-[10px] font-normal text-fg-muted",children:z("team:history.infoOnly")})]}),je.notice.body&&o.jsx("div",{className:"text-[11px] text-fg-muted mt-0.5 line-clamp-2 leading-relaxed",children:je.notice.body}),o.jsx("div",{className:"text-[10px] text-fg-muted mt-1",children:_2(je.notice.createdAt)})]})]},`n:${je.notice.id}`)})()),o.jsxs("div",{ref:ke,className:"h-8 flex items-center justify-center",children:[J&&o.jsx("span",{className:"text-[11px] text-fg-muted",children:z("common:loading")}),!J&&ee&&c.length>0&&o.jsx("span",{className:"text-[10px] text-fg-muted",children:z("team:history.noMore")})]})]})]})}):null}function DS(e){const t=e.metadata;if(!(!t||typeof t.i18n!="object"||!t.i18n))return t.i18n}function ZQ(e){return e.replace(/_([a-z])/g,(t,n)=>n.toUpperCase())}function eJ(e,t){const n=DS(e);if(!n?.titleKey)return e.title;const a={...n.titleParams??{}};return t(`team:${n.titleKey}`,{...a,defaultValue:e.title})}function epe(e,t){const n=DS(e);if(!n?.bodyKey)return e.body;const a={};for(const[i,l]of Object.entries(n.bodyParams??{}))if(i==="priority")a[i]=t(`common:priority.${l}`,{defaultValue:l});else if(i==="status"||i==="statusKey"){const c=ZQ(l);a[i]=t(`common:status.${l}`,{defaultValue:c===l?l:t(`common:status.${c}`,{defaultValue:l})})}else a[i]=l;return t(`team:${n.bodyKey}`,{...a,defaultValue:e.body})}const IS={code:o.jsxs(o.Fragment,{children:[o.jsx("polyline",{points:"16 18 22 12 16 6"}),o.jsx("polyline",{points:"8 6 2 12 8 18"})]}),search:o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"11",cy:"11",r:"8"}),o.jsx("path",{d:"m21 21-4.3-4.3"})]}),clipboard:o.jsxs(o.Fragment,{children:[o.jsx("rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}),o.jsx("path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"})]}),"check-circle":o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("path",{d:"m9 12 2 2 4-4"})]}),server:o.jsxs(o.Fragment,{children:[o.jsx("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),o.jsx("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),o.jsx("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),o.jsx("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]}),"file-text":o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),o.jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),o.jsx("path",{d:"M10 9H8"}),o.jsx("path",{d:"M16 13H8"}),o.jsx("path",{d:"M16 17H8"})]}),"book-open":o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M12 7v14"}),o.jsx("path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z"})]}),users:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),o.jsx("circle",{cx:"9",cy:"7",r:"4"}),o.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),o.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),"dollar-sign":o.jsxs(o.Fragment,{children:[o.jsx("line",{x1:"12",x2:"12",y1:"2",y2:"22"}),o.jsx("path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"})]}),megaphone:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"m3 11 18-5v12L3 14v-3z"}),o.jsx("path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6"})]}),edit:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M12 20h9"}),o.jsx("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4Z"})]}),headphones:o.jsx(o.Fragment,{children:o.jsx("path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-5a9 9 0 0 1 18 0v5a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3"})}),settings:o.jsxs(o.Fragment,{children:[o.jsx("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"}),o.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),target:o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("circle",{cx:"12",cy:"12",r:"6"}),o.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),zap:o.jsx(o.Fragment,{children:o.jsx("polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2"})}),terminal:o.jsxs(o.Fragment,{children:[o.jsx("polyline",{points:"4 17 10 11 4 5"}),o.jsx("line",{x1:"12",x2:"20",y1:"19",y2:"19"})]}),sparkles:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .962 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.962 0z"}),o.jsx("path",{d:"M20 3v4"}),o.jsx("path",{d:"M22 5h-4"})]}),wrench:o.jsx(o.Fragment,{children:o.jsx("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})}),globe:o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"}),o.jsx("path",{d:"M2 12h20"})]}),link:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),o.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}),bot:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M12 8V4H8"}),o.jsx("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),o.jsx("path",{d:"M2 14h2"}),o.jsx("path",{d:"M20 14h2"}),o.jsx("path",{d:"M15 13v2"}),o.jsx("path",{d:"M9 13v2"})]}),"message-square":o.jsx(o.Fragment,{children:o.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),newspaper:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2"}),o.jsx("path",{d:"M18 14h-8"}),o.jsx("path",{d:"M15 18h-5"}),o.jsx("path",{d:"M10 6h8v4h-8V6Z"})]}),layers:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z"}),o.jsx("path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65"}),o.jsx("path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65"})]}),"bar-chart":o.jsxs(o.Fragment,{children:[o.jsx("line",{x1:"12",x2:"12",y1:"20",y2:"10"}),o.jsx("line",{x1:"18",x2:"18",y1:"20",y2:"4"}),o.jsx("line",{x1:"6",x2:"6",y1:"20",y2:"16"})]}),folder:o.jsx(o.Fragment,{children:o.jsx("path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"})}),"git-branch":o.jsxs(o.Fragment,{children:[o.jsx("line",{x1:"6",x2:"6",y1:"3",y2:"15"}),o.jsx("circle",{cx:"18",cy:"6",r:"3"}),o.jsx("circle",{cx:"6",cy:"18",r:"3"}),o.jsx("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),save:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"}),o.jsx("path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7"}),o.jsx("path",{d:"M7 3v4a1 1 0 0 0 1 1h7"})]}),camera:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z"}),o.jsx("circle",{cx:"12",cy:"13",r:"3"})]}),clock:o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("polyline",{points:"12 6 12 12 16 14"})]}),database:o.jsxs(o.Fragment,{children:[o.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),o.jsx("path",{d:"M3 5v14a9 3 0 0 0 18 0V5"}),o.jsx("path",{d:"M3 12a9 3 0 0 0 18 0"})]}),lightbulb:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"}),o.jsx("path",{d:"M9 18h6"}),o.jsx("path",{d:"M10 22h4"})]}),"alert-circle":o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),o.jsx("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]}),"square-terminal":o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"m7 11 2-2-2-2"}),o.jsx("path",{d:"M11 13h4"}),o.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"})]}),package:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"m7.5 4.27 9 5.15"}),o.jsx("path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"}),o.jsx("path",{d:"m3.3 7 8.7 5 8.7-5"}),o.jsx("path",{d:"M12 22V12"})]}),inbox:o.jsxs(o.Fragment,{children:[o.jsx("polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12"}),o.jsx("path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"})]}),"circle-pause":o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"10",x2:"10",y1:"15",y2:"9"}),o.jsx("line",{x1:"14",x2:"14",y1:"15",y2:"9"})]}),"circle-x":o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("path",{d:"m15 9-6 6"}),o.jsx("path",{d:"m9 9 6 6"})]}),"clipboard-check":o.jsxs(o.Fragment,{children:[o.jsx("rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}),o.jsx("path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"}),o.jsx("path",{d:"m9 14 2 2 4-4"})]}),"file-check":o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),o.jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),o.jsx("path",{d:"m9 15 2 2 4-4"})]}),bell:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"}),o.jsx("path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0"})]}),"help-circle":o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),o.jsx("path",{d:"M12 17h.01"})]})};function tJ(e){return!!e&&e in IS}function LS({name:e,size:t=24,className:n=""}){const a=IS[e];return a?o.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:n,"aria-hidden":!0,children:a}):null}const O2={"coding-tools":"terminal",markitdown:"file-text","markus-admin-cli":"terminal",codex:"code","team-building":"users","claude-code":"code","skill-building":"wrench","workflow-building":"layers","chrome-devtools":"globe","markus-hub-connector":"link","cursor-agent":"bot","agent-building":"bot","feishu-interaction":"message-square","content-publishing":"edit","research-report":"book-open","daily-digest":"newspaper"},H2={development:"code",开发工具:"code",devops:"server",data:"bar-chart",数据分析:"bar-chart",productivity:"zap",效率提升:"zap",communication:"message-square",通讯协作:"message-square",browser:"globe",内容创作:"edit","AI 智能":"sparkles"};function Zu(e,t){const n=(e||"").toLowerCase();return O2[n]?O2[n]:t&&H2[t]?H2[t]:"layers"}const An={attention:{chip:"bg-violet-500/15 text-violet-500",dot:"bg-violet-500",solid:"bg-violet-500",text:"text-violet-500",border:"border-violet-500/40",surface:"bg-violet-500/[0.06]",btn:"bg-violet-500/10 text-violet-500 hover:bg-violet-500/20",hex:"#8b5cf6"},active:{chip:"bg-blue-500/15 text-blue-500",dot:"bg-blue-500",solid:"bg-blue-500",text:"text-blue-500",border:"border-blue-500/40",surface:"bg-blue-500/[0.06]",btn:"bg-blue-500/10 text-blue-500 hover:bg-blue-500/20",hex:"#3b82f6"},blocked:{chip:"bg-orange-500/15 text-orange-500",dot:"bg-orange-500",solid:"bg-orange-500",text:"text-orange-500",border:"border-orange-500/40",surface:"bg-orange-500/[0.06]",btn:"bg-orange-500/10 text-orange-500 hover:bg-orange-500/20",hex:"#f97316"},success:{chip:"bg-green-500/15 text-green-600",dot:"bg-green-500",solid:"bg-green-500",text:"text-green-600",border:"border-green-500/30",surface:"bg-green-500/[0.06]",btn:"bg-green-500/10 text-green-600 hover:bg-green-500/20",hex:"#22c55e"},danger:{chip:"bg-red-500/15 text-red-500",dot:"bg-red-500",solid:"bg-red-500",text:"text-red-500",border:"border-red-500/40",surface:"bg-red-500/[0.06]",btn:"bg-red-500/10 text-red-500 hover:bg-red-500/20",hex:"#ef4444"},neutral:{chip:"bg-gray-500/15 text-fg-tertiary",dot:"bg-gray-400",solid:"bg-gray-500",text:"text-fg-tertiary",border:"border-border-default/60",surface:"bg-surface-elevated/60",btn:"bg-surface-overlay text-fg-secondary hover:bg-surface-overlay/70",hex:"#6b7280"}};function tp(e,t){return t&&e[t]||"neutral"}const nJ={pending:"neutral",in_progress:"active",blocked:"blocked",review:"attention",revision:"active",completed:"success",failed:"danger",rejected:"danger",cancelled:"neutral",archived:"neutral"},aJ={pending:"attention",in_progress:"active",blocked:"blocked",completed:"success",rejected:"danger",cancelled:"neutral",archived:"neutral"},rJ={active:"active",in_progress:"active",planning:"neutral",paused:"blocked",blocked:"blocked",completed:"success",archived:"neutral",cancelled:"neutral"},iJ={draft:"neutral",pending:"neutral",submitted:"attention",in_review:"attention",review:"attention",approved:"success",published:"success",rejected:"danger",archived:"neutral"};function zc(e){return tp(nJ,e)}function sJ(e){return tp(aJ,e)}function oJ(e){return tp(rJ,e)}function lJ(e){return tp(iJ,e)}function cJ(e,t){switch(e){case"task":return zc(t);case"requirement":return sJ(t);case"project":return oJ(t);case"deliverable":return lJ(t);default:return"neutral"}}const dJ={pending:"pending",in_progress:"inProgress",blocked:"blocked",review:"review",completed:"completed",failed:"failed",rejected:"rejected",cancelled:"cancelled",archived:"archived"};function PS(e){return e==="hold"?"hold":e==="workflow"?"workflow":"deps"}const uJ={deps:"waitingDeps",hold:"onHold",workflow:"workflowPaused"},mJ={deps:{chip:An.neutral.chip,dot:An.neutral.dot,bar:An.neutral.dot,card:`${An.neutral.surface} border-border-default/60`},hold:{chip:An.blocked.chip,dot:An.blocked.dot,bar:An.blocked.dot,card:`${An.blocked.surface} border-orange-500/30 ring-1 ring-orange-500/15`},workflow:{chip:An.neutral.chip,dot:An.neutral.dot,bar:An.neutral.dot,card:`${An.neutral.surface} border-border-default/60`}};function sg(e,t,n){if(!e)return"—";if(e==="blocked"&&n!==void 0&&n!==null)return t(`common:taskStatus.${uJ[PS(n)]}`);const a=dJ[e];return a?t(`common:taskStatus.${a}`):e}function OS(e,t,n){const a=sg(e,t,n);return e==="blocked"&&n!==void 0&&n!==null?{label:a,tone:mJ[PS(n)]}:{label:a,tone:null}}function tpe(e,t,n){if(e!=="blocked"||n===void 0||n===null)return null;const a=OS(e,t,n);return{label:a.label,cls:a.tone?.chip??An.neutral.chip}}function npe(e,t){return t(`agent:profilePage.mind.attention.${e}`)}const pJ={idle:"idle",working:"working",online:"online",offline:"offline",paused:"paused",error:"error"};function ape(e,t){const n=pJ[e];return n?t(`common:processStatus.${n}`):e}function HS(e){return e>=1e9?`${(e/1e9).toFixed(1)}B`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function Cm(e){return e.toLocaleString(void 0,{maximumFractionDigits:0})}function fJ(e,t,n){const[a,i]=w.useState([]),[l,c]=w.useState(null),[u,m]=w.useState(null),[f,g]=w.useState(at.isAuthenticated()),h=w.useCallback(async()=>{try{const k=await Se.usage.agents();i(k.agents)}catch{}},[]),b=w.useCallback(async()=>{if(!at.isAuthenticated()){g(!1),m(null);return}g(!0);try{const[k,C]=await Promise.all([at.user.plan(),Se.hubOrgs.mine().catch(()=>null)]);c(k);const T=C?.orgs?.find(A=>A.id===k.orgId)??C?.orgs?.[0];m(T?{role:T.role,memberCount:T.memberCount??1}:null)}catch{}},[]);return w.useEffect(()=>{if(!e)return;h(),b();const k=setInterval(h,3e4),C={at:0},T=15e3,A=()=>{const M=Date.now();M-C.at<T||(C.at=M,h(),b())};return window.addEventListener("markus:data-changed",A),()=>{clearInterval(k),window.removeEventListener("markus:data-changed",A)}},[e,h,b]),{contributors:w.useMemo(()=>{const k=[],C=new Map;for(const A of n)for(const M of A.members)C.set(M.id,A.name);const T=new Map((t?.agentEfficiency??[]).map(A=>[A.agentId,A]));for(const A of a){const M=T.get(A.agentId),I=A.cuUsed??0,B=A.totalTokens,G=M?.taskMetrics.completed??0,j=B>0?G/B*1e3:G>0?1/0:0;k.push({id:A.agentId,name:A.agentName,type:"agent",role:A.role,teamName:C.get(A.agentId),status:A.status,tasksCompleted:G,tasksFailed:M?.taskMetrics.failed??0,cuUsed:I,cuUsedToday:A.cuUsedToday??0,totalTokens:B,tokensToday:A.tokensUsedToday,requestCount:A.requestCount,toolCalls:A.toolCalls,healthScore:M?.healthScore??0,efficiency:j,provider:A.provider})}return k.sort((A,M)=>M.cuUsed+M.tasksCompleted*100-(A.cuUsed+A.tasksCompleted*100)===0?M.totalTokens-A.totalTokens:M.cuUsed+M.tasksCompleted*100-(A.cuUsed+A.tasksCompleted*100)),k},[a,t,n]),hubPlan:l,hubOrgMeta:u,hubConnected:f}}function og({title:e,badge:t,children:n}){const{t:a}=ut("home"),[i,l]=w.useState(!1);return o.jsxs("section",{className:`bg-surface-elevated shadow-sm rounded-2xl ${i?"overflow-visible":"overflow-hidden"}`,children:[o.jsxs("button",{type:"button",onClick:()=>l(c=>!c),className:"w-full px-4 sm:px-5 py-3.5 flex items-center justify-between gap-3 hover:bg-surface-overlay/40 transition-colors text-left rounded-2xl","aria-expanded":i,children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-primary truncate",children:e}),t]}),o.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-fg-tertiary shrink-0",children:[o.jsx("span",{className:"hidden sm:inline",children:a(i?"usage.trends.collapse":"usage.trends.expand")}),o.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`transition-transform ${i?"rotate-180":""}`,children:o.jsx("polyline",{points:"6 9 12 15 18 9"})})]})]}),i&&o.jsx("div",{className:"rounded-b-2xl overflow-visible",children:n})]})}function hJ({hubConnected:e,hubPlan:t,hubOrgMeta:n}){const{t:a}=ut("home"),i=Oa();if(!e)return o.jsxs("div",{className:"px-4 sm:px-5 pb-4 flex flex-wrap items-center justify-between gap-2",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[o.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-500 shrink-0"}),o.jsx("span",{className:"text-sm text-fg-tertiary",children:a("usage.quota.notConnected")})]}),o.jsx("button",{onClick:()=>at.ensureAuth().catch(()=>{}),className:"px-3 py-1.5 text-xs font-medium bg-brand-600 text-on-brand rounded-lg hover:bg-brand-500 transition-colors shrink-0",children:a("usage.quota.connect")})]});if(!t)return o.jsx("div",{className:"px-4 sm:px-5 pb-4 text-sm text-fg-tertiary",children:a("usage.trends.noData")});const l=t.memberCuLimit!=null&&t.memberCuLimit>0,c=!n||n.role==="owner"||n.role==="admin"||n.memberCount<=1,u=l&&!c,m=(t.monthlyQuotaCu??0)+(t.bonusCu??0)+(t.purchasedCu??0),f=u?t.memberCuLimit:t.creditsBudgetCu??(l?t.memberCuLimit:m),g=u?t.memberCuUsed??0:t.totalConsumedThisPeriod??t.memberCuUsed??0,h=f>0?Math.min(100,Math.round(g/f*100)):0,b=h>90?"bg-red-500":h>70?"bg-amber-500":"bg-brand-500",y=()=>{Or(`${at.getUrl().replace(/\/$/,"")}/settings?tab=billing`)};return o.jsxs("div",{className:"px-4 sm:px-5 pb-4",children:[u&&o.jsx("div",{className:"mb-2 px-3 py-1.5 rounded-lg text-[10px] bg-amber-500/8 text-amber-500/80 border border-amber-500/15",children:a("usage.quota.personalLimit")}),o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-2",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:"text-xs font-semibold text-fg-secondary",children:a(l&&!c?"usage.quota.personalLimitLabel":"usage.quota.title")}),o.jsx("span",{className:"px-1.5 py-0.5 rounded-full text-[10px] font-medium bg-brand-500/10 text-brand-500 uppercase shrink-0",children:t.planType}),i?.username&&o.jsx("span",{className:"text-[10px] text-fg-tertiary truncate",children:a("usage.quota.connectedAs",{username:i.username})})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3 text-[10px] text-fg-tertiary",children:[o.jsx("span",{children:t.cuResetAt?a("usage.quota.resetsAt",{date:new Date(t.cuResetAt).toLocaleDateString()}):""}),o.jsx("button",{type:"button",className:"px-2 py-1 bg-brand-600 text-on-brand rounded hover:bg-brand-500 transition-colors font-medium",onClick:k=>{k.stopPropagation(),y()},children:a("usage.quota.topUp")})]})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"flex-1 h-2 bg-surface-overlay rounded-full overflow-hidden",children:o.jsx("div",{className:`h-full rounded-full transition-all ${b}`,style:{width:`${h}%`}})}),o.jsxs("span",{className:"text-xs text-fg-secondary tabular-nums shrink-0",children:[Cm(g)," / ",Cm(f)]})]})]})}function gJ({contributors:e}){const{t}=ut("home"),[n,a]=w.useState("totalTokens"),[i,l]=w.useState(!0),[c,u]=w.useState(!1),m=10,f=A=>{n===A?l(!i):(a(A),l(!0))},g=w.useMemo(()=>[...e].sort((A,M)=>{const I=A[n]===1/0?999999:A[n],B=M[n]===1/0?999999:M[n];return i?B-I:I-B}),[e,n,i]),h=c?g:g.slice(0,m),b=Math.max(1,...e.map(A=>A.totalTokens)),y=e.some(A=>A.cuUsed>0),k=new Set(e.filter(A=>A.provider).map(A=>A.provider)),T=k.size>1||k.size===1&&!k.has("markus")?o.jsx("span",{className:"text-[10px] text-fg-tertiary bg-surface-overlay px-2 py-0.5 rounded shrink-0",children:t("usage.agents.mixedProviders")}):void 0;return e.length===0?o.jsx(og,{title:t("usage.agents.title"),children:o.jsx("div",{className:"px-4 sm:px-5 pb-6 text-center",children:o.jsx("p",{className:"text-sm text-fg-tertiary",children:t("usage.agents.noData")})})}):o.jsxs(og,{title:t("usage.agents.title"),badge:T,children:[o.jsx("div",{className:"overflow-x-auto scrollbar-thin border-t border-border-default",children:o.jsxs("table",{className:"w-full min-w-[520px]",children:[o.jsx("thead",{children:o.jsxs("tr",{className:"border-b border-border-default text-xs text-fg-tertiary uppercase tracking-wider",children:[o.jsx("th",{className:"px-3 sm:px-4 py-3 text-left font-medium w-8",children:"#"}),o.jsx("th",{className:"px-3 sm:px-4 py-3 text-left font-medium",children:t("usage.agents.name")}),o.jsx("th",{className:"px-3 sm:px-4 py-3 text-left font-medium hidden sm:table-cell",children:t("usage.agents.team")}),o.jsx(lu,{label:t("usage.agents.tasks"),col:"tasksCompleted",current:n,desc:i,onSort:f}),o.jsx(lu,{label:t("usage.agents.tokens"),col:"totalTokens",current:n,desc:i,onSort:f}),y&&o.jsx(lu,{label:t("usage.agents.cuUsed"),col:"cuUsed",current:n,desc:i,onSort:f}),o.jsx(lu,{label:t("usage.agents.efficiency"),col:"efficiency",current:n,desc:i,onSort:f,align:"right"})]})}),o.jsx("tbody",{children:h.map((A,M)=>o.jsx(bJ,{contributor:A,rank:M+1,maxTokens:b,showCu:y},A.id))}),o.jsx("tfoot",{children:o.jsxs("tr",{className:"border-t border-border-default bg-surface-elevated/30",children:[o.jsx("td",{colSpan:2,className:"px-3 sm:px-4 py-3 text-sm font-medium text-fg-secondary sm:hidden",children:t("usage.agents.total",{count:e.length})}),o.jsx("td",{colSpan:3,className:"px-3 sm:px-4 py-3 text-sm font-medium text-fg-secondary hidden sm:table-cell",children:t("usage.agents.total",{count:e.length})}),o.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:e.reduce((A,M)=>A+M.tasksCompleted,0)}),o.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:HS(e.reduce((A,M)=>A+M.totalTokens,0))}),y&&o.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:Cm(e.reduce((A,M)=>A+M.cuUsed,0))}),o.jsx("td",{})]})})]})}),g.length>m&&o.jsx("button",{type:"button",onClick:()=>u(A=>!A),className:"w-full px-4 py-2.5 text-xs font-medium text-brand-500 hover:bg-surface-overlay/40 border-t border-border-default transition-colors",children:c?t("usage.agents.showLess"):t("usage.agents.showAll",{count:g.length})})]})}function bJ({contributor:e,rank:t,maxTokens:n,showCu:a}){const i=n>0?Math.min(100,e.totalTokens/n*100):0,l=e.status==="working"?"bg-blue-500":e.status==="idle"?"bg-green-500":e.status==="error"?"bg-red-500":"bg-gray-500",c=e.tasksCompleted===0?"—":e.totalTokens>0?`${e.efficiency.toFixed(1)}`:"∞",u=t<=3?`${t===1?"text-amber-500":t===2?"text-gray-400":"text-amber-700"} font-bold`:"text-fg-tertiary",m=e.provider==="markus"?"":e.provider??"";return o.jsxs("tr",{className:"border-b border-border-default/50 hover:bg-surface-elevated/30 transition-colors cursor-pointer",onClick:()=>yt.navigate(ce.TEAM,{selectAgent:e.id}),children:[o.jsx("td",{className:`px-3 sm:px-4 py-3 text-sm tabular-nums ${u}`,children:t}),o.jsx("td",{className:"px-3 sm:px-4 py-3",children:o.jsxs("div",{className:"flex items-center gap-2.5",children:[o.jsx("div",{className:`w-2 h-2 rounded-full ${l} shrink-0`}),o.jsxs("div",{className:"min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:e.name}),m&&o.jsx("span",{className:"px-1 py-0.5 rounded text-[8px] font-medium bg-surface-overlay text-fg-tertiary shrink-0",children:m})]}),o.jsxs("div",{className:"text-[10px] text-fg-tertiary truncate",children:[e.role,o.jsx("span",{className:"sm:hidden",children:e.teamName?` · ${e.teamName}`:""})]})]})]})}),o.jsx("td",{className:"px-3 sm:px-4 py-3 text-xs text-fg-tertiary hidden sm:table-cell",children:e.teamName||"—"}),o.jsx("td",{className:"px-3 sm:px-4 py-3",children:o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"text-sm text-fg-secondary tabular-nums",children:e.tasksCompleted}),e.tasksFailed>0&&o.jsxs("span",{className:"text-[10px] text-red-500 tabular-nums",children:["(",e.tasksFailed,")"]})]})}),o.jsx("td",{className:"px-3 sm:px-4 py-3",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"flex-1 h-1.5 bg-surface-overlay rounded-full overflow-hidden max-w-[80px] hidden md:block",children:o.jsx("div",{className:"h-full bg-indigo-500 rounded-full transition-all",style:{width:`${i}%`}})}),o.jsx("span",{className:"text-sm text-fg-secondary tabular-nums",children:HS(e.totalTokens)})]})}),a&&o.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm text-fg-secondary tabular-nums",children:e.cuUsed>0?Cm(e.cuUsed):o.jsx("span",{className:"text-fg-tertiary",children:"—"})}),o.jsx("td",{className:"px-3 sm:px-4 py-3 text-right",children:o.jsx("span",{className:`text-sm font-medium tabular-nums ${e.tasksCompleted===0?"text-fg-tertiary":e.efficiency>5?"text-green-500":e.efficiency>1?"text-fg-secondary":"text-amber-500"}`,children:c})})]})}function lu({label:e,col:t,current:n,desc:a,onSort:i,align:l}){const c=n===t?a?"↓":"↑":"↕",u=n===t?"text-brand-500":"text-fg-muted";return o.jsxs("th",{className:`px-3 sm:px-4 py-3 ${l==="right"?"text-right":"text-left"} font-medium cursor-pointer select-none hover:text-fg-secondary`,onClick:()=>i(t),children:[e,o.jsx("span",{className:`ml-1 ${u}`,children:c})]})}function yJ({contributors:e,hubPlan:t,hubOrgMeta:n,hubConnected:a,showMarkusUsage:i}){const{t:l}=ut("home");return o.jsxs("div",{className:"space-y-3",children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-tertiary px-0.5",children:l("usage.sectionTitle")}),i&&o.jsx(og,{title:l("usage.creditsTitle"),children:o.jsx(hJ,{hubConnected:a,hubPlan:t,hubOrgMeta:n})}),o.jsx(gJ,{contributors:e})]})}const vJ="(max-width: 767px)";let $h=null;function BS(){return $h||($h=window.matchMedia(vJ)),$h}function xJ(e){const t=BS();return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function wJ(){return BS().matches}function kJ(){return!1}const SJ=w.createContext(!1);function Xo(){const e=w.useContext(SJ),t=w.useSyncExternalStore(xJ,wJ,kJ);return e?!1:t}const CJ="markus_onboarded";function ob(e){return`markus_onboarded_${e}`}function zS(e){return`markus_checklist_dismissed_${e}`}function lg(e){try{return localStorage.getItem(ob(e))!==null?!0:localStorage.getItem(CJ)!==null}catch{return!1}}function cg(e){try{localStorage.setItem(ob(e),"1")}catch{}}function B2(e){try{localStorage.removeItem(ob(e))}catch{}}function AJ(e){try{return localStorage.getItem(zS(e))==="true"}catch{return!1}}function TJ(e){try{localStorage.setItem(zS(e),"true")}catch{}}function z2(e){return{configured:Object.values(e.providers).some(t=>t.configured),markus:!!e.providers.markus?.configured,providerLabel:e.providers[e.defaultProvider]?.displayName??e.defaultProvider??""}}const EJ=Object.fromEntries(["completed","in_progress","review","pending","failed","blocked","rejected","cancelled"].map(e=>[e,An[zc(e)].hex])),NJ=e=>An[zc(e)].dot,qS=["completed","in_progress","review","pending","failed","blocked","rejected","cancelled"],Fh={agent_question:{tone:"attention",iconName:"help-circle"},approval_request:{tone:"attention",iconName:"check-circle"},requirement_approval:{tone:"attention",iconName:"file-check"},task_review:{tone:"attention",iconName:"clipboard-check"},blocked_hold:{tone:"blocked",iconName:"circle-pause"},task_failed:{tone:"danger",iconName:"circle-x"},unread_message:{tone:"neutral",iconName:"message-square"}},q2={urgent:An.danger.chip,high:"bg-surface-overlay text-fg-secondary font-semibold",medium:"bg-surface-overlay text-fg-secondary",low:"bg-surface-overlay text-fg-tertiary",none:"bg-surface-overlay text-fg-tertiary"},MJ=Object.fromEntries(["completed","in_progress","review","pending","failed","blocked","rejected","cancelled"].map(e=>[e,An[zc(e)].chip])),$2={"Heartbeat check-in":"agentFocus.heartbeatCheckIn","Heartbeat check-in (idle skip)":"agentFocus.heartbeatSkip"},jJ={thinking:`${An.active.dot} animate-pulse`,running:`${An.active.dot} animate-pulse`,"waiting-dependency":`${An.blocked.dot} animate-pulse`,blocked:`${An.danger.dot} animate-pulse`,degraded:`${An.danger.dot} animate-pulse`,error:"bg-red-500 animate-pulse",idle:"bg-green-400",offline:"bg-gray-400"},F2={thinking:"agentFocus.phaseThinking",running:"agentFocus.phaseRunning","waiting-dependency":"agentFocus.phaseWaitingDep",blocked:"agentFocus.phaseBlocked",degraded:"agentFocus.phaseDegraded",error:"agentFocus.phaseError"};function U2({authUser:e,previewMode:t,previewData:n}={}){const{t:a}=ut(["home","common","team"]),i=Xo(),l=jQ(ce.HOME),[c,u]=w.useState(!1);w.useEffect(()=>fY(()=>u(!0)),[]);const[m,f]=w.useState(n?.agents??[]),[g,h]=w.useState(n?.teams??[]),[b,y]=w.useState(n?.board??{}),[k,C]=w.useState(n?.boardCounts??{}),[T,A]=w.useState(n?.ops??null),M="7d",[I,B]=w.useState(n?.requirements??[]),[G,j]=w.useState(n?.projects??[]),[O,F]=w.useState(n?.deliverableTotal??0),[Y,q]=w.useState([]),[V,z]=w.useState(n?.storageInfo??null),[J,D]=w.useState(n?.usageInfo??null),[ee,R]=w.useState(null),[te,le]=w.useState(!1),[ke,$]=w.useState(!1),[W,oe]=w.useState(!1),[L,Ne]=w.useState(null),[qe,me]=w.useState(!1),[ze,Ue]=w.useState(""),[je,Ye]=w.useState(!1),[xt,mt]=w.useState(null),[ft,rt]=w.useState(!1),jt=w.useRef(!1);jt.current=ft;const[ht,He]=w.useState(!1),[Et,Kt]=w.useState(()=>e?.id?sb(e.id):!1),ie=e?.id,[tt,it]=w.useState(()=>e?.id?lg(e.id)||e.preferences?.guideHidden===!0:!0),[,xe]=w.useState(0),Me=ie?AJ(ie):!1,[Ie,ne]=w.useState(!1),[U,re]=w.useState(!1),Ce=w.useRef(null);w.useEffect(()=>{const ge=()=>Kt(!0);return window.addEventListener("markus:shortcut-lesson-complete",ge),()=>window.removeEventListener("markus:shortcut-lesson-complete",ge)},[Kt]);const Pe=w.useCallback(()=>{Ye(!0),Se.cu.status().then(R).catch(()=>{}),Se.settings.getLlm().then(ge=>{const pe=z2(ge);Ne(pe.configured),me(pe.markus),Ue(pe.providerLabel)}).catch(()=>{}),window.dispatchEvent(new CustomEvent("markus:data-changed")),window.setTimeout(()=>{window.dispatchEvent(new CustomEvent("markus:data-changed"))},800)},[]);w.useEffect(()=>{if(!te)return;const ge=pe=>{Ce.current&&!Ce.current.contains(pe.target)&&le(!1)};return document.addEventListener("mousedown",ge),()=>document.removeEventListener("mousedown",ge)},[te]),w.useEffect(()=>{!t||!n||(n.agents&&f(n.agents),n.teams&&h(n.teams),n.board&&y(n.board),n.boardCounts&&C(n.boardCounts),A(n.ops??null),B(n.requirements??[]),j(n.projects??[]),F(n.deliverableTotal??0),n.storageInfo&&z(n.storageInfo),n.usageInfo&&D(n.usageInfo))},[t,n]);const $e=w.useCallback(()=>{const ge=Se.agents.list().then(Dt=>{f(Dt.agents);const dn=Dt.agents.find(Lt=>Lt.role==="secretary")??Dt.agents.find(Lt=>Lt.name?.toLowerCase().includes("secretary"));dn&&Se.sessions.listByAgent(dn.id,20).then(async Lt=>{if(Lt.sessions.length===0){ne(!1);return}const fn=ie?Lt.sessions.filter(gr=>gr.userId===ie):Lt.sessions;if(fn.length===0){ne(!1);return}const Aa=await Se.sessions.getMessages(fn[0].id,1);ne(Aa.messages.length>0)}).catch(()=>{})}).catch(()=>{}),pe=Se.teams.list().then(Dt=>h(Dt.teams)).catch(()=>{});Se.tasks.boardSummary().then(Dt=>{y(Dt.board),C(Dt.counts)}).catch(()=>{}),Se.ops.dashboard(M).then(A).catch(()=>{});const Ze=Se.requirements.list({lean:!0}).then(Dt=>B(Dt.requirements)).catch(()=>{}),St=Se.projects.list().then(Dt=>j(Dt.projects)).catch(()=>{});Se.deliverables.search({limit:18}).then(Dt=>{F(Dt.total);const dn=new Map;for(const Lt of Dt.results){const fn=Lt.reference,Aa=dn.get(fn);(!Aa||Lt.updatedAt>Aa.updatedAt)&&dn.set(fn,Lt)}q([...dn.values()].sort((Lt,fn)=>fn.updatedAt.localeCompare(Lt.updatedAt)).slice(0,6))}).catch(()=>{}),Se.usage.summary().then(Dt=>D(Dt.usage)).catch(()=>{}),Se.cu.status().then(R).catch(()=>{});const Ut=Se.settings.getLlm().then(Dt=>{const dn=z2(Dt);Ne(dn.configured),me(dn.markus),Ue(dn.providerLabel)}).catch(()=>{}),ln=Se.settings.getBrowser().then(Dt=>{mt(Dt.extensionConnected)}).catch(()=>{}),jn=IY().then(Dt=>{if(!Dt&&!Tn()){Ye(!1);return}return at.user.claimFreeCreditsStatus().then(dn=>Ye(!!dn.claimed)).catch(()=>{})}).catch(()=>{});Promise.race([Promise.allSettled([ge,pe,Ze,St,Ut,ln,jn]),new Promise(Dt=>setTimeout(Dt,8e3))]).then(()=>{re(!0)})},[M,ie]);w.useEffect(()=>{!W||V||Se.system.storage().then(z).catch(()=>{})},[W,V]);const ue=w.useCallback(()=>{ie&&(cg(ie),it(!0),Se.auth.updatePreferences({guideHidden:!0}).catch(()=>{}))},[ie]),he=w.useCallback(ge=>{const pe=m.find(Ze=>Ze.role==="secretary")??m.find(Ze=>Ze.name?.toLowerCase().includes("secretary"));yt.navigate(ce.TEAM,{...pe?{agentId:pe.id}:{},prefillMessage:ge})},[m]),dt=!!Tn()||qe,Je=L===!0||qe,ot=[...dt?[{id:"claim",done:je,isSetup:!0,label:a("checklist.setup.claim"),desc:a("checklist.setup.claimDesc"),action:a("checklist.setup.claimAction"),onClick:()=>{rt(!0)}}]:[],{id:"llm",done:Je,isSetup:!0,label:a("checklist.setup.llm"),desc:Je&&ze?a("checklist.setup.llmDescConfigured",{provider:ze}):a(dt?"checklist.setup.llmDescHub":"checklist.setup.llmDesc"),action:a("checklist.setup.llmAction"),onClick:()=>{window.location.hash="#settings/providers"}},{id:"browser",done:xt===!0,isSetup:!0,optional:!0,label:a("checklist.setup.browser"),desc:a("checklist.setup.browserDesc"),action:a("checklist.setup.browserAction"),onClick:()=>{window.location.hash="#settings/browser"}}],Ft=[{id:"greet",done:Ie,label:a("checklist.explore.greet"),desc:a("checklist.explore.greetDesc"),action:a("checklist.explore.greetAction"),onClick:()=>he(a("checklist.explore.greetPrompt"))},{id:"project",done:ie?G.some(ge=>ge.createdBy===ie):G.length>0,label:a("checklist.explore.project"),desc:a("checklist.explore.projectDesc"),action:a("checklist.explore.projectAction"),onClick:()=>he(a("checklist.explore.projectPrompt"))},{id:"requirements",done:ie?I.some(ge=>ge.createdBy===ie):I.length>0,label:a("checklist.explore.requirements"),desc:a("checklist.explore.requirementsDesc"),action:a("checklist.explore.requirementsAction"),onClick:()=>he(a("checklist.explore.requirementsPrompt"))},{id:"team",done:g.length>0,label:a("checklist.explore.team"),desc:a("checklist.explore.teamDesc"),action:a("checklist.explore.teamAction"),onClick:()=>he(a("checklist.explore.teamPrompt"))},{id:"shortcuts",done:Et,label:a("checklist.explore.shortcuts"),desc:a("checklist.explore.shortcutsDesc"),action:a("checklist.explore.shortcutsAction"),onClick:()=>He(!0)}],cn=[...ot,...Ft],Ot=cn.filter(ge=>ge.done).length,Ee=cn.length,_e=ot.filter(ge=>!ge.optional).every(ge=>ge.done)&&Ft.every(ge=>ge.done),De=ot.some(ge=>!ge.optional&&!ge.done),Q=()=>{ie&&(TJ(ie),De?xe(ge=>ge+1):ue())};w.useEffect(()=>{!U||tt||_e&&ue()},[U,tt,_e,ue]),w.useEffect(()=>{if(t||!l)return;$e();const ge=setInterval($e,6e4),pe={at:0},Ze=15e3,St=()=>{const ln=Date.now();ln-pe.at<Ze||(pe.at=ln,$e())},Ut=()=>{if(jt.current){at.user.claimFreeCreditsStatus().then(ln=>Ye(!!ln.claimed)).catch(()=>{});return}$e()};return window.addEventListener("markus:data-changed",St),window.addEventListener("markus:hub-auth",Ut),()=>{clearInterval(ge),window.removeEventListener("markus:data-changed",St),window.removeEventListener("markus:hub-auth",Ut)}},[t,M,l,$e]);const be={},Te=Object.keys(k).length>0?k:Object.fromEntries(Object.entries(b).map(([ge,pe])=>[ge,pe.length]));for(const[ge,pe]of Object.entries(Te))ge!=="archived"&&pe>0&&(be[ge]=pe);const Xe=be.completed??0,wt=Object.values(be).reduce((ge,pe)=>ge+pe,0),lt=m.filter(ge=>{const pe=ge.runtime?.phase;return pe?pe!=="idle"&&pe!=="offline":ge.status==="working"}).length,nt=G.filter(ge=>ge.status==="active").length,Ct=wt>0?Math.round(Xe/wt*100):0,vn=qS.filter(ge=>(be[ge]??0)>0).map(ge=>({status:ge,count:be[ge]})),xn=w.useMemo(()=>{const ge={};return I.forEach(pe=>{ge[pe.status]=(ge[pe.status]??0)+1}),ge},[I]),Xn=w.useMemo(()=>{const ge=new Map(m.map(pe=>[pe.id,pe]));return g.map(pe=>{const Ze=pe.members.filter(St=>St.type==="agent").map(St=>ge.get(St.id)).filter(St=>!!St);return{team:pe,agents:Ze,working:Ze.filter(St=>St.status==="working").length,total:Ze.length}})},[g,m]),ga=m.filter(ge=>{const pe=ge.runtime?.phase;return pe?pe!=="idle"&&pe!=="offline":ge.status==="working"}),yi=!(L===!0&&!qe),ba=fJ(!t&&l,T,g);t||yt.navigate;const Mn=w.useMemo(()=>{const ge=new Map;for(const pe of Object.values(b))for(const Ze of pe)ge.set(Ze.id,Ze);return ge},[b]),[Zn,kr]=w.useState([]),[Sr,Ks]=w.useState([]),[$r]=w.useState(()=>sQ());w.useEffect(()=>{if(t||!l)return;let ge=!0;const pe=()=>{Se.approvals.list().then(Ze=>{ge&&kr(Ze.approvals??[])}).catch(()=>{}),e?.id&&Se.notifications.list(e.id,!0,{limit:20}).then(Ze=>{ge&&Ks(Ze.notifications??[])}).catch(()=>{})};return pe(),window.addEventListener("markus:notifications-changed",pe),()=>{ge=!1,window.removeEventListener("markus:notifications-changed",pe)}},[t,l,e?.id]);const ss=w.useMemo(()=>Object.values(b).flat(),[b]),ra=w.useMemo(()=>uS({tasks:ss,requirements:I,approvals:Zn,notifications:Sr,taskById:ge=>Mn.get(ge),lastSeenAt:$r,notifyTitle:ge=>eJ(ge,a)}),[ss,I,Zn,Sr,Mn,$r,a]),vi=w.useMemo(()=>ra.filter(ge=>ge.isNew).length,[ra]),[ia,fr]=w.useState(()=>Date.now());w.useEffect(()=>{const ge=window.setInterval(()=>fr(Date.now()),6e4);return()=>window.clearInterval(ge)},[]),w.useEffect(()=>{if(t||!l)return;const ge=window.setTimeout(()=>oQ(new Date().toISOString()),3e3);return()=>window.clearTimeout(ge)},[t,l,ra.length]);const Cr=w.useCallback(ge=>{const pe=ge.notices?.[0];pe&&RS(pe,Sr),yt.navigate(ge.target.page==="WORK"?ce.WORK:ce.TEAM,ge.target.params)},[Sr]),Ar=w.useMemo(()=>{const ge=new Map;for(const pe of Object.values(b))for(const Ze of pe)Ze.priority&&ge.set(Ze.id,Ze.priority);return ge},[b]),In=w.useMemo(()=>{const ge=new Map;for(const pe of m)ge.set(pe.id,pe.name);return ge},[m]),{activityLimit:Vs,teamsLimit:hr}=w.useMemo(()=>{const ge=(G.length>0?1:0)+(I.length>0?1:0)+(O>0?1:0),pe=wt>0?6+ge:0,Ze=pe>0?2:0,Ut=pe+Ze+2,ln=Xn.length>0?2+Xn.length:0,jn=Math.max(ln,4),Dt=ga.length,dn=Dt>0?8:12,Lt=Math.max(0,jn-Ut);let fn=Dt>0?Math.max(Dt,Lt):Lt;fn=Math.max(3,Math.min(dn,fn));const Aa=Ut+Math.max(Dt,fn);let gr=Xn.length;if(jn>Aa+2){const Fr=jn-Aa;gr=Math.max(2,Xn.length-Fr)}else if(Aa>jn+2){const Fr=Aa-jn;fn=Math.max(3,fn-Fr)}return{activityLimit:fn,teamsLimit:gr}},[Xn,wt,G,I,O,ga]);return o.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-thin",children:[o.jsxs("div",{"data-electron-drag":!0,className:`flex items-center justify-between px-4 sm:px-6 lg:px-8 h-14 sm:h-16 ${t?"":"max-w-7xl mx-auto"} w-full`,children:[o.jsxs("div",{className:"flex items-center gap-2",children:[i&&o.jsx(ES,{}),o.jsxs("div",{children:[o.jsx("h2",{className:"text-base sm:text-lg font-bold",children:a("title")}),o.jsx("p",{className:"text-xs text-fg-tertiary hidden sm:block",children:a("subtitle")})]})]}),o.jsxs("div",{"data-no-drag":!0,className:"flex items-center gap-1.5",children:[o.jsx("button",{onClick:()=>t?void 0:i?yt.navigate(ce.SEARCH):window.dispatchEvent(new CustomEvent("markus:open-search")),className:"p-2 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary","aria-label":a("search"),children:o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("circle",{cx:"11",cy:"11",r:"8"}),o.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}),o.jsx(HJ,{ref:Ce,show:te,onToggle:()=>le(!te),onClose:()=>le(!1),t:a,isMobile:i})]})]}),o.jsxs("div",{className:`px-4 sm:px-6 lg:px-8 pb-8 space-y-6 ${t?"":"max-w-7xl mx-auto"} w-full`,children:[o.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[o.jsx(cu,{label:a("metricCards.working"),value:String(lt),sub:`/${m.length}`,icon:o.jsx(du,{type:"working"}),pulse:lt>0,onClick:()=>$(!0)}),o.jsx(cu,{label:a("metricCards.tasksDone"),value:`${Xe}`,sub:`/${wt}`,icon:o.jsx(du,{type:"tasks"}),onClick:()=>yt.navigate(ce.WORK)}),o.jsx(cu,{label:a("metricCards.projects"),value:String(nt),icon:o.jsx(du,{type:"projects"}),onClick:()=>yt.navigate(ce.WORK)}),o.jsx(cu,{label:a("metricCards.health"),value:`${L===!1?100:T?.systemHealth.overallScore??"—"}`,sub:L===!1||T?"%":void 0,icon:o.jsx(du,{type:"health"}),color:L===!1?"green":T?T.systemHealth.overallScore>=80?"green":T.systemHealth.overallScore>=50?"amber":"red":void 0,onClick:()=>oe(!0)})]}),!t&&o.jsxs("div",{className:"bg-gradient-to-r from-amber-500/5 via-surface-elevated to-surface-elevated border border-amber-500/20 rounded-2xl overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between px-5 pt-4 pb-2",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-500 shrink-0"}),o.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:a("attention.title")}),ra.length>0&&o.jsx("span",{className:"text-[11px] text-fg-tertiary tabular-nums",children:ra.length}),vi>0&&o.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-semibold bg-brand-500/15 text-brand-500 shrink-0",children:a("attention.newCount",{count:vi})})]}),o.jsx("button",{onClick:()=>u(!0),className:"text-[11px] font-medium text-fg-tertiary hover:text-fg-primary transition-colors shrink-0",children:a("attention.history")})]}),ra.length===0?o.jsx("div",{className:"px-5 pb-4 text-xs text-fg-tertiary",children:a("attention.allClear")}):o.jsxs("div",{className:"px-3 pb-2 space-y-1",children:[ra.slice(0,5).map(ge=>o.jsxs("button",{onClick:()=>Cr(ge),className:"w-full flex items-start gap-2.5 px-3 py-2.5 rounded-xl hover:bg-surface-overlay/40 transition-colors text-left",children:[o.jsx("span",{className:`w-1 self-stretch rounded-full shrink-0 ${ge.isNew?"bg-brand-500":"bg-transparent"}`}),o.jsx("span",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${An[Fh[ge.kind].tone].chip}`,children:o.jsx(LS,{name:Fh[ge.kind].iconName,size:15})}),o.jsxs("span",{className:"flex-1 min-w-0",children:[o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs font-medium text-fg-primary truncate",children:ge.title}),ge.priority!=="none"&&o.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-semibold ${q2[ge.priority]??q2.none}`,children:ge.priority})]}),o.jsxs("span",{className:"mt-0.5 flex items-center gap-1.5 text-[11px] text-fg-tertiary",children:[o.jsx("span",{className:"shrink-0",children:a(`attention.kind.${ge.kind}`)}),o.jsx("span",{children:"·"}),o.jsx("span",{className:"tabular-nums shrink-0",children:mS(ge,ia)}),ge.meta&&o.jsxs(o.Fragment,{children:[o.jsx("span",{children:"·"}),o.jsx("span",{className:"truncate",children:ge.meta})]})]})]}),o.jsx("span",{className:`shrink-0 text-[11px] font-medium px-2.5 py-1 rounded-lg transition-colors ${An[Fh[ge.kind].tone].btn}`,children:a(`attention.act.${ge.kind}`)})]},ge.id)),ra.length>5&&o.jsx("button",{onClick:()=>u(!0),className:"w-full text-[11px] text-fg-tertiary hover:text-fg-primary px-3 py-2 text-left",children:a("attention.more",{count:ra.length-5})})]})]}),!t&&o.jsx(XQ,{open:c,onClose:()=>u(!1),userId:e?.id}),Y.length>0&&o.jsxs("div",{className:"bg-surface-elevated shadow-sm rounded-2xl overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-3",children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:a("recentDeliverables.title")}),o.jsx("button",{onClick:()=>yt.navigate(ce.DELIVERABLES),className:"text-[11px] text-brand-400 hover:text-brand-300 font-medium",children:a("common:viewAll")})]}),o.jsx("div",{className:"px-3 pb-3",children:o.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-1",children:Y.map(ge=>o.jsxs("div",{className:"flex items-start gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay/40 cursor-pointer transition-colors",onClick:()=>yt.navigate(ce.DELIVERABLES,{openDeliverable:ge.id}),children:[o.jsx("span",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 mt-0.5 ${ge.artifactType?"bg-brand-500/10":ge.type==="directory"?"bg-blue-500/10":"bg-green-500/10"}`,children:o.jsx(LJ,{type:ge.type,artifactType:ge.artifactType})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-xs font-medium text-fg-primary truncate",children:ge.title}),o.jsx("div",{className:"text-[11px] text-fg-tertiary truncate mt-0.5",children:ge.summary}),o.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[ge.agentId&&In.get(ge.agentId)&&o.jsx("span",{className:"text-[10px] text-fg-muted",children:In.get(ge.agentId)}),o.jsx("span",{className:"text-[10px] text-fg-muted",children:K2(ge.updatedAt,a)}),ge.status==="verified"&&o.jsx("span",{className:"text-[10px] text-blue-500 font-medium",children:a("common:verified")})]})]}),ge.diffStats&&o.jsxs("div",{className:"text-[10px] text-fg-muted shrink-0 mt-1 tabular-nums",children:[o.jsxs("span",{className:"text-green-500",children:["+",ge.diffStats.additions]})," ",o.jsxs("span",{className:"text-red-500",children:["-",ge.diffStats.deletions]})]})]},ge.id))})})]}),U&&!tt&&!_e&&(()=>{if(Me&&!De)return null;const ge=pe=>o.jsxs("div",{className:"flex items-start gap-3 py-2.5 px-3 rounded-lg hover:bg-surface-elevated/50 transition-colors group",children:[o.jsx("div",{className:`mt-0.5 shrink-0 w-5 h-5 rounded-full flex items-center justify-center ${pe.done?"bg-green-500":"border-2 border-border-default"}`,children:pe.done&&o.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:`text-xs font-medium ${pe.done?"text-fg-tertiary line-through":"text-fg-primary"}`,children:pe.label}),"optional"in pe&&pe.optional&&o.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-surface-elevated text-fg-muted font-medium",children:a("checklist.setup.optional")})]}),o.jsx("p",{className:`text-[11px] mt-0.5 ${pe.done?"text-fg-muted":"text-fg-tertiary"}`,children:pe.desc})]}),pe.done&&pe.isSetup?o.jsx("button",{onClick:pe.onClick,className:"shrink-0 text-[11px] px-3 py-1.5 rounded-lg border border-border-default hover:bg-surface-elevated text-fg-secondary font-medium transition-colors opacity-0 group-hover:opacity-100",children:a("checklist.setup.update")}):pe.done?null:o.jsx("button",{onClick:pe.onClick,className:"shrink-0 text-[11px] px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand font-medium transition-colors opacity-80 group-hover:opacity-100",children:pe.action})]},pe.id);return o.jsxs("div",{className:"bg-gradient-to-br from-brand-600/10 via-surface-secondary to-surface-secondary border border-brand-500/20 rounded-2xl p-5 sm:p-6",children:[o.jsxs("div",{className:"flex items-start justify-between mb-4",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-primary mb-1",children:a("checklist.title")}),o.jsx("p",{className:"text-xs text-fg-secondary",children:a("checklist.subtitle")})]}),o.jsx("button",{onClick:Q,className:"text-fg-muted hover:text-fg-secondary transition-colors p-1 -mr-1 -mt-1",title:a("dismiss"),children:o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),o.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[o.jsx("div",{className:"flex-1 h-1.5 bg-surface-elevated rounded-full overflow-hidden",children:o.jsx("div",{className:"h-full bg-brand-500 rounded-full transition-all duration-500",style:{width:`${Ot/Ee*100}%`}})}),o.jsx("span",{className:"text-[11px] text-fg-secondary font-medium shrink-0",children:a("checklist.progress",{done:Ot,total:Ee})})]}),o.jsxs("div",{className:"mb-4",children:[o.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1 px-3",children:a("checklist.setup.title")}),o.jsx("div",{className:"space-y-0.5",children:ot.map(ge)})]}),o.jsx("div",{className:"border-t border-border-default/50 my-3"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1 px-3",children:a("checklist.explore.title")}),o.jsx("div",{className:"space-y-0.5",children:Ft.map(ge)})]})]})})(),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[o.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[wt>0&&o.jsxs("div",{className:"bg-surface-elevated shadow-sm rounded-2xl overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-3",children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:a("globalOverview.title")}),o.jsx("button",{onClick:()=>yt.navigate(ce.WORK),className:"text-[11px] text-brand-400 hover:text-brand-300 font-medium",children:a("common:viewAll")})]}),o.jsxs("div",{className:"px-5 py-4 flex flex-col sm:flex-row items-center gap-6 border-t border-border-subtle/50",children:[o.jsx(_J,{statusCounts:be,total:wt,completionRate:Ct,completed:Xe}),o.jsx("div",{className:"flex-1 min-w-0",children:o.jsx("div",{className:"grid grid-cols-2 gap-x-5 gap-y-2.5",children:vn.map(({status:ge,count:pe})=>o.jsxs("button",{onClick:()=>yt.navigate(ce.WORK,{statusFilter:ge}),className:"flex items-center gap-2 group cursor-pointer text-left",children:[o.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${NJ(ge)}`}),o.jsx("span",{className:"text-xs text-fg-tertiary group-hover:text-fg-secondary transition-colors",children:sg(ge,a)}),o.jsx("span",{className:"text-sm font-semibold text-fg-primary ml-auto tabular-nums",children:pe})]},ge))})})]}),o.jsxs("div",{className:"divide-y divide-border-subtle/50",children:[G.length>0&&o.jsx(Uh,{icon:"folder",label:a("globalOverview.projects"),value:G.length,onClick:()=>yt.navigate(ce.WORK),children:o.jsxs(G2,{children:[nt," ",a("globalOverview.active")]})}),I.length>0&&o.jsx(Uh,{icon:"edit",label:a("globalOverview.requirements"),value:I.length,onClick:()=>yt.navigate(ce.WORK),children:["in_progress","pending","completed"].map(ge=>(xn[ge]??0)>0&&o.jsxs(G2,{children:[xn[ge]," ",sg(ge,a)]},ge))}),O>0&&o.jsx(Uh,{icon:"book",label:a("globalOverview.deliverables"),value:O,onClick:()=>yt.navigate(ce.DELIVERABLES)})]})]}),(ga.length>0||T&&T.taskKPI.recentActivity.length>0)&&o.jsx("div",{className:"bg-surface-elevated shadow-sm rounded-2xl overflow-hidden",children:o.jsxs("div",{className:`grid grid-cols-1 ${ga.length>0&&T&&T.taskKPI.recentActivity.length>0?"sm:grid-cols-2 divide-y sm:divide-y-0 sm:divide-x divide-border-subtle/50":""}`,children:[ga.length>0&&o.jsxs("div",{className:"p-5",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[o.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 animate-pulse"}),o.jsx("h4",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:a("liveActivity.whosWorking")})]}),o.jsx("div",{className:"space-y-1",children:ga.map(ge=>{const pe=ge.runtime,Ze=pe?.phase??(ge.status==="idle"?"idle":ge.status==="offline"?"offline":"running"),St=jJ[Ze]??"bg-blue-400 animate-pulse";return o.jsxs("div",{className:"flex items-center gap-2.5 px-2 py-2 rounded-lg hover:bg-surface-overlay/40 cursor-pointer transition-colors",onClick:()=>yt.navigate(ce.TEAM,{agentId:ge.id}),children:[o.jsx(Go,{name:ge.name,avatarUrl:ge.avatarUrl,size:24,bgClass:"bg-brand-600/30 text-brand-300"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[o.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${St}`}),o.jsx("span",{className:"text-xs font-medium text-fg-primary truncate",children:ge.name}),F2[Ze]&&o.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:a(F2[Ze])}),pe?.stall?.stalled&&o.jsx("span",{title:pe.stall.stuckReason,className:`text-[10px] font-semibold px-1.5 py-0.5 rounded-full shrink-0 ${pe.stall.stallKind==="dead-dependency"?"bg-amber-500/20 text-amber-400 border border-amber-500/30":"bg-sky-500/15 text-sky-300 border border-sky-500/25"}`,children:pe.stall.stallKind==="dead-dependency"?a("agentFocus.stallDeadBadge"):a("agentFocus.stallStaleBadge")}),pe?.dirty?.dirty&&(()=>{const Ut=pe.dirty.recovery==="human-review";return o.jsx("span",{className:`inline-flex items-center px-1.5 py-px rounded text-[9px] font-medium shrink-0 ${Ut?"bg-amber-500/15 text-amber-300":"bg-emerald-500/15 text-emerald-300"}`,children:a(Ut?"liveActivity.dirtyNeedsHuman":"liveActivity.dirtyRecovered")})})()]}),o.jsx("div",{className:"text-[10px] text-fg-tertiary truncate",children:zJ(ge,a)})]})]},ge.id)})})]}),T&&T.taskKPI.recentActivity.length>0&&o.jsxs("div",{className:"p-5",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsx("h4",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:a("liveActivity.recentChanges")}),o.jsx("button",{onClick:()=>yt.navigate(ce.WORK),className:"text-[11px] text-brand-400 hover:text-brand-300 font-medium",children:a("common:viewAll")})]}),o.jsx("div",{className:`${ga.length>0?"":"grid grid-cols-1 sm:grid-cols-2 gap-x-4"}`,children:T.taskKPI.recentActivity.slice(0,Vs).map(ge=>{const pe=Ar.get(ge.taskId);return o.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg hover:bg-surface-overlay/40 cursor-pointer transition-colors",onClick:()=>yt.navigate(ce.WORK,{openTask:ge.taskId}),children:[o.jsx("span",{className:`w-5 h-5 rounded-full flex items-center justify-center shrink-0 ${MJ[ge.status]??"bg-gray-500/15"}`,children:o.jsx(DJ,{status:ge.status})}),o.jsx("span",{className:"text-[11px] text-fg-secondary truncate flex-1",children:ge.title}),(pe==="urgent"||pe==="high")&&o.jsx(IJ,{priority:pe}),o.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:K2(ge.updatedAt,a)})]},ge.taskId)})})]})]})})]}),o.jsx("div",{className:"space-y-6",children:Xn.length>0&&o.jsx("div",{className:"bg-surface-elevated shadow-sm rounded-2xl overflow-hidden",children:o.jsxs("div",{className:"p-5",children:[o.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:a("teamOverview.title")}),o.jsx("button",{onClick:()=>yt.navigate(ce.TEAM),className:"text-[11px] text-brand-400 hover:text-brand-300 font-medium",children:a("common:viewAll")})]}),o.jsxs("div",{className:"space-y-0.5",children:[Xn.slice(0,hr).map(ge=>o.jsxs("div",{className:"flex items-center gap-3 px-2 py-2 rounded-lg hover:bg-surface-overlay/40 cursor-pointer transition-colors",onClick:()=>yt.navigate(ce.TEAM,{selectTeam:ge.team.id}),children:[o.jsx("div",{className:"w-7 h-7 rounded-md bg-brand-600/15 flex items-center justify-center text-[10px] font-bold text-brand-400 shrink-0",children:ge.team.name.charAt(0)}),o.jsx("div",{className:"flex-1 min-w-0",children:o.jsx("div",{className:"text-xs font-medium text-fg-primary truncate",children:ge.team.name})}),o.jsx("div",{className:"flex items-center -space-x-1 shrink-0",children:ge.agents.slice(0,3).map(pe=>o.jsx(Go,{name:pe.name,avatarUrl:pe.avatarUrl,size:18,bgClass:"bg-surface-overlay text-fg-secondary ring-1 ring-surface-elevated"},pe.id))}),ge.working>0&&o.jsxs("span",{className:"text-[10px] text-green-500 font-medium shrink-0",children:[ge.working,"/",ge.total]})]},ge.team.id)),hr<Xn.length&&o.jsx("button",{onClick:()=>yt.navigate(ce.TEAM),className:"w-full text-center text-[11px] text-brand-400 hover:text-brand-300 font-medium py-1.5",children:a("common:units.more",{count:Xn.length-hr})})]})]})})})]}),!t&&L!==null&&o.jsx(yJ,{contributors:ba.contributors,hubPlan:ba.hubPlan,hubOrgMeta:ba.hubOrgMeta,hubConnected:ba.hubConnected,showMarkusUsage:yi})]}),ke&&o.jsx(PJ,{workingAgents:ga,onClose:()=>$(!1),t:a}),W&&o.jsx(OJ,{ops:T,completed:Xe,totalRootTasks:wt,workingAgents:lt,totalAgents:m.length,usageInfo:J,storageInfo:V,cuQuota:ee,onClose:()=>oe(!1),t:a}),ft&&o.jsx(BQ,{onClose:()=>rt(!1),onClaimed:Pe}),o.jsx(GQ,{open:ht,userId:ie,onClose:()=>He(!1),onCompleted:()=>{Kt(!0),He(!1)}})]})}function cu({label:e,value:t,sub:n,icon:a,pulse:i,color:l,badge:c,onClick:u}){const m=l==="green"?"text-green-500":l==="amber"?"text-amber-500":l==="red"?"text-red-500":"text-fg-primary";return o.jsxs("div",{onClick:u,className:"bg-surface-elevated shadow-sm rounded-2xl p-4 sm:p-5 flex items-start justify-between cursor-pointer hover:shadow-md transition-shadow",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-[11px] text-fg-tertiary mb-2",children:e}),o.jsxs("div",{className:"flex items-baseline gap-0.5",children:[o.jsx("span",{className:`text-2xl sm:text-3xl font-bold ${m} leading-none`,children:t}),n&&o.jsx("span",{className:"text-sm text-fg-muted font-medium",children:n})]}),c&&o.jsx("div",{className:"text-[10px] text-amber-500 font-medium mt-1.5",children:c})]}),o.jsxs("div",{className:"relative",children:[o.jsx("div",{className:"w-10 h-10 rounded-xl bg-surface-overlay/60 flex items-center justify-center text-fg-tertiary",children:a}),i&&o.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-2.5 h-2.5 rounded-full bg-green-500 animate-pulse"})]})]})}function du({type:e}){const t={working:o.jsx(o.Fragment,{children:o.jsx("path",{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z"})}),tasks:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),o.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),projects:o.jsx(o.Fragment,{children:o.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})}),health:o.jsx(o.Fragment,{children:o.jsx("path",{d:"M22 12h-4l-3 9L9 3l-3 9H2"})})};return o.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:t[e]})}function Uh({icon:e,label:t,value:n,onClick:a,children:i}){return o.jsxs("div",{className:"flex items-center gap-3 px-5 py-3 hover:bg-surface-overlay/30 cursor-pointer transition-colors",onClick:a,children:[o.jsx("span",{className:"text-fg-muted",children:o.jsx(RJ,{type:e})}),o.jsx("span",{className:"text-xs text-fg-secondary",children:t}),o.jsx("span",{className:"text-sm font-semibold text-fg-primary",children:n}),o.jsx("div",{className:"flex items-center gap-2 ml-auto text-[11px] text-fg-tertiary",children:i})]})}function G2({children:e}){return o.jsx("span",{className:"px-2 py-0.5 rounded-full bg-surface-overlay/60 text-[11px] text-fg-secondary",children:e})}function RJ({type:e}){const t={folder:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z",edit:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7 M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z",book:"M4 19.5A2.5 2.5 0 0 1 6.5 17H20 M4 19.5A2.5 2.5 0 0 0 6.5 22H20V2H6.5A2.5 2.5 0 0 0 4 4.5v15z"};return o.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("path",{d:t[e]})})}function _J({statusCounts:e,total:t,completionRate:n,completed:a}){const u=2*Math.PI*42,m=qS.filter(h=>(e[h]??0)>0).map(h=>({status:h,value:e[h],color:EJ[h]??"#6b7280"}));let f=0;const g=m.map(h=>{const b=h.value/t*u,y={len:Math.max(b-.8,.5),offset:f,color:h.color,status:h.status};return f+=b,y});return o.jsxs("div",{className:"relative shrink-0",style:{width:120,height:120},children:[o.jsx("svg",{width:120,height:120,viewBox:"0 0 120 120",children:g.map((h,b)=>o.jsx("circle",{cx:"60",cy:"60",r:42,fill:"none",stroke:h.color,strokeWidth:12,strokeDasharray:`${h.len} ${u-h.len}`,strokeDashoffset:-h.offset,transform:"rotate(-90 60 60)",className:"transition-all duration-500 cursor-pointer",onClick:()=>yt.navigate(ce.WORK,{statusFilter:h.status})},b))}),o.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[o.jsxs("span",{className:"text-2xl font-bold text-fg-primary leading-none",children:[n,"%"]}),o.jsxs("span",{className:"text-[10px] text-fg-tertiary mt-0.5",children:[a,"/",t]})]})]})}function DJ({status:e}){const n={completed:"#22c55e",in_progress:"#8b5cf6",pending:"#f59e0b",review:"#3b82f6",failed:"#ef4444",blocked:"#f59e0b",rejected:"#ef4444",cancelled:"#6b7280"}[e]??"#6b7280";return o.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:n,strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e==="completed"&&o.jsx("polyline",{points:"20 6 9 17 4 12"}),e==="in_progress"&&o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("polyline",{points:"12 6 12 12 16 14"})]}),e==="pending"&&o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),o.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),e==="review"&&o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),o.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),(e==="failed"||e==="rejected")&&o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),o.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),e==="blocked"&&o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"4.93",y1:"4.93",x2:"19.07",y2:"19.07"})]}),e==="cancelled"&&o.jsxs(o.Fragment,{children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})]})}function IJ({priority:e}){return e==="urgent"?o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold bg-red-500/15 text-red-500 shrink-0 uppercase tracking-wide",children:"!"}):e==="high"?o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold bg-amber-500/15 text-amber-600 shrink-0 uppercase tracking-wide",children:"H"}):null}function LJ({type:e,artifactType:t}){if(t){const a=t==="agent"?"#8b5cf6":t==="team"?"#3b82f6":"#f59e0b";return o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:a,strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),o.jsx("path",{d:"M2 17l10 5 10-5"}),o.jsx("path",{d:"M2 12l10 5 10-5"})]})}const n=e==="directory"?"#3b82f6":"#22c55e";return o.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:n,strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:e==="directory"?o.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"}):o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),o.jsx("polyline",{points:"14 2 14 8 20 8"})]})})}function PJ({workingAgents:e,onClose:t,t:n}){return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:o.jsxs("div",{className:"bg-surface-elevated rounded-xl border border-border-default shadow-2xl w-[420px] max-w-[90vw] max-h-[80vh] overflow-hidden flex flex-col",onClick:a=>a.stopPropagation(),children:[o.jsxs("div",{className:"px-5 py-4 border-b border-border-default flex items-center justify-between shrink-0",children:[o.jsx("h3",{className:"text-sm font-semibold",children:n("ranking.workingNow")}),o.jsx("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary hover:text-fg-primary",children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsx("div",{className:"overflow-y-auto flex-1 scrollbar-thin px-5 py-4",children:e.length>0?o.jsx("div",{className:"space-y-0.5",children:e.map(a=>o.jsxs("div",{className:"flex items-center gap-2.5 px-2 py-2 rounded-lg hover:bg-surface-overlay/40 cursor-pointer transition-colors",onClick:()=>{t(),yt.navigate(ce.TEAM,{agentId:a.id})},children:[o.jsx(Go,{name:a.name,avatarUrl:a.avatarUrl,size:26,bgClass:"bg-brand-600/30 text-brand-300"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-xs font-medium text-fg-primary truncate",children:a.name}),o.jsx("div",{className:"text-[10px] text-fg-tertiary truncate",children:a.currentActivity?.label??"—"})]}),o.jsx("span",{className:"text-[10px] text-green-500 font-medium shrink-0",children:n("common:processStatus.working")})]},a.id))}):o.jsx("div",{className:"py-8 text-center text-xs text-fg-tertiary",children:n("ranking.noData")})})]})})}function OJ({ops:e,completed:t,totalRootTasks:n,workingAgents:a,totalAgents:i,usageInfo:l,storageInfo:c,cuQuota:u,onClose:m,t:f}){return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:m,children:o.jsxs("div",{className:"bg-surface-elevated rounded-xl border border-border-default shadow-2xl w-[400px] max-w-[90vw] overflow-hidden",onClick:g=>g.stopPropagation(),children:[o.jsxs("div",{className:"px-5 py-4 border-b border-border-default flex items-center justify-between",children:[o.jsx("h3",{className:"text-sm font-semibold",children:f("systemHealth.title")}),o.jsx("button",{onClick:m,className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary hover:text-fg-primary",children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsxs("div",{className:"p-5 space-y-4",children:[e&&o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsx("span",{className:"text-xs text-fg-secondary",children:f("systemHealth.successRate")}),o.jsxs("span",{className:"text-sm font-bold text-fg-primary",children:[Math.round(e.taskKPI.successRate),"%"]})]}),o.jsx("div",{className:"h-2 rounded-full bg-surface-overlay/60 overflow-hidden",children:o.jsx("div",{className:"h-full rounded-full bg-green-500 transition-all duration-500",style:{width:`${Math.round(e.taskKPI.successRate)}%`}})})]}),e&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs text-fg-secondary",children:f("metricCards.health")}),o.jsxs("span",{className:`text-sm font-bold ${e.systemHealth.overallScore>=80?"text-green-500":e.systemHealth.overallScore>=50?"text-amber-500":"text-red-500"}`,children:[e.systemHealth.overallScore,"%"]})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs text-fg-secondary",children:f("systemHealth.tasksTotal")}),o.jsxs("span",{className:"text-xs font-semibold text-fg-primary",children:[t,"/",n]})]}),l&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs text-fg-secondary",children:f("systemHealth.tokenUsage")}),o.jsx("span",{className:"text-xs font-semibold text-fg-primary",children:mu(l.llmTokens)})]}),u?.available&&u.cuLimit>0&&(()=>{const g=u.cuLimit-u.cuRemaining,h=Math.min(100,Math.round(g/u.cuLimit*100)),b=h>=95?"text-red-500":h>=80?"text-amber-500":"text-green-500",y=h>=95?"bg-red-500":h>=80?"bg-amber-500":"bg-green-500";return o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[o.jsx("span",{className:"text-xs text-fg-secondary",children:f("systemHealth.cuQuota")}),o.jsxs("span",{className:`text-xs font-semibold ${b}`,children:[mu(g)," / ",mu(u.cuLimit)," (",h,"%)"]})]}),o.jsx("div",{className:"h-2 rounded-full bg-surface-overlay/60 overflow-hidden",children:o.jsx("div",{className:`h-full rounded-full ${y} transition-all duration-500`,style:{width:`${h}%`}})}),u.cuUsedToday!=null&&u.cuUsedToday>0&&o.jsxs("div",{className:"flex items-center justify-between mt-1.5",children:[o.jsx("span",{className:"text-xs text-fg-tertiary",children:f("systemHealth.cuUsedToday")}),o.jsx("span",{className:"text-xs font-semibold text-fg-secondary",children:mu(u.cuUsedToday)})]})]})})(),a>0&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs text-fg-secondary",children:f("systemHealth.currentWorking")}),o.jsxs("span",{className:"text-xs font-semibold text-green-500",children:[a,"/",i]})]}),c&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs text-fg-secondary",children:f("systemHealth.storage")}),o.jsx("span",{className:"text-xs font-semibold text-fg-primary",children:qJ(c.totalSize)})]})]})]})})}const HJ=w.forwardRef(({show:e,onToggle:t,onClose:n,t:a,isMobile:i},l)=>o.jsxs("div",{ref:l,className:"relative",children:[o.jsx("button",{onClick:t,className:"p-2 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary","aria-label":a("create"),children:o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),o.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}),e&&o.jsx("div",{className:"absolute right-0 top-full mt-2 bg-surface-elevated border border-border-default rounded-xl shadow-xl z-50 overflow-hidden w-48 animate-fadeIn",children:o.jsxs("div",{className:"py-1",children:[o.jsx(uu,{onClick:()=>{n(),yt.navigate(ce.BUILDER,i?{storeTab:"builder"}:void 0)},icon:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2 M9 7a4 4 0 1 0 0-8 4 4 0 0 0 0 8z M19 8v6 M22 11h-6",children:a("home:createMenu.agent")}),o.jsx(uu,{onClick:()=>{n(),yt.navigate(ce.BUILDER)},icon:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2 M9 7a4 4 0 1 0 0-8 4 4 0 0 0 0 8z M23 21v-2a4 4 0 0 0-3-3.87 M16 3.13a4 4 0 0 1 0 7.75",children:a("home:createMenu.team")}),o.jsx(uu,{onClick:()=>{n(),yt.navigate(ce.BUILDER)},icon:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",children:a("home:createMenu.skill")}),o.jsx("div",{className:"border-t border-border-default my-1"}),o.jsx(uu,{onClick:()=>{n(),yt.navigate(ce.STORE)},icon:"M6 2L3 7v13a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V7l-3-5z M3 7h18 M16 11a4 4 0 0 1-8 0",children:a("home:createMenu.discover")})]})})]}));function uu({onClick:e,icon:t,children:n}){return o.jsxs("button",{onClick:e,className:"w-full flex items-center gap-2.5 px-4 py-2.5 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[o.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("path",{d:t})}),n]})}function K2(e,t){const n=Date.now()-new Date(e).getTime(),a=Math.floor(n/6e4);if(a<1)return t("common:time.now");if(a<60)return t("common:time.minutesAgo",{count:a});const i=Math.floor(a/60);return i<24?t("common:time.hoursAgo",{count:i}):t("common:time.daysAgo",{count:Math.floor(i/24)})}function V2(e,t){return e?$2[e]?t($2[e]):e:null}function BJ(e,t=""){if(!e)return t;const n=new Date(e);return Number.isNaN(n.getTime())?t:n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function zJ(e,t){const n=e.runtime,a=[];if(n){if(n.stall?.stalled)if(n.stall.stallKind==="dead-dependency")a.push(t("agentFocus.stallDeadDep",{title:n.stall.stuckOnTitle??n.stall.stuckOnTaskId??""}));else{const i=n.stall.lastActivityAgoMin;a.push(t("agentFocus.stallStale",{minutes:typeof i=="number"?i:0}))}else n.blockedBy&&n.blockedBy.length>0?a.push(t("agentFocus.blockedBy",{title:n.blockedBy[0].title})):n.phase==="idle"||n.phase==="offline"||(n.activityLabel?a.push(V2(n.activityLabel,t)??n.activityLabel):n.activityType==="heartbeat"&&a.push(t("agentFocus.heartbeatCheckIn")));return typeof n.runningMinutes=="number"&&n.runningMinutes>=1&&a.push(t("agentFocus.runningFor",{n:n.runningMinutes})),(n.lastActivityAt||n.lastHeartbeat)&&a.push(t("agentFocus.lastActivity",{time:BJ(n.lastActivityAt??n.lastHeartbeat)})),n.lastError&&a.push(n.lastError),a.join(" · ")}return V2(e.currentActivity?.label,t)??t("agentFocus.working")}function mu(e){return e>=1e9?`${(e/1e9).toFixed(1)}B`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function qJ(e){if(e===0)return"0 B";const t=["B","KB","MB","GB","TB"],n=Math.floor(Math.log(e)/Math.log(1024));return`${(e/Math.pow(1024,n)).toFixed(n>0?1:0)} ${t[n]}`}const $J=["task","requirement","agent","deliverable","work_unit"];function W2(e){const t=(e??"").trim();if(!t)return;const n=new Date(t);if(!Number.isNaN(n.getTime()))return n.toISOString()}function FJ(e){const t=new URLSearchParams,n=(i,l)=>{const c=(l??"").trim();c.length>0&&t.set(i,c)};n("subjectKind",e.subjectKind),n("subjectId",e.subjectId),n("predicate",e.predicate),n("predicatePrefix",e.predicatePrefix),n("since",W2(e.since)),n("until",W2(e.until)),e.includeSuperseded&&t.set("includeSuperseded","1"),Number.isFinite(e.limit)&&t.set("limit",String(e.limit));const a=t.toString();return a.length>0?`?${a}`:""}function UJ(e){const t=new Map;for(const n of e)t.set(n.id,n);return t}function GJ(e){return[...e].sort((t,n)=>t.createdAt===n.createdAt?t.id<n.id?1:-1:t.createdAt<n.createdAt?1:-1)}function KJ(e,t){const n=e.supersededBy?(()=>{const l=t.get(e.supersededBy);return l?{factId:l.id,at:e.supersededAt??l.createdAt,by:l.assertedBy}:{factId:e.supersededBy,at:e.supersededAt??void 0,missing:!0}})():null,a=[...t.values()].find(l=>l.supersededBy===e.id),i=a?{factId:a.id,at:a.createdAt}:null;return{outgoing:n,incoming:i}}function Y2(e){const t=e.verification;if(!t||t.result!=="pass")return!1;const n=(t.verifiedBy??"").trim();return n.length>0&&n!==e.assertedBy}function VJ(e){if(!e)return{kind:"raw",value:""};const t=/^session:[^:]+(?::r(\d+))?$/.exec(e);return t?{kind:"session",round:t[1]??null}:e.startsWith("a2a:")?{kind:"a2a"}:{kind:"raw",value:e}}function WJ(e){const t=e.indexOf(":"),n=t===-1?"":e.slice(0,t),a=t===-1?"":e.slice(t+1);switch(n){case"commit":return{kind:"commit",hash:a.slice(0,8)};case"probe":return{kind:"probe"};case"task":return{kind:"task",id:a};case"deliverable":return{kind:"deliverable",id:a};default:return{kind:"raw",value:e}}}function Am(e){return e==="owner"||e==="admin"}const Q2=["task.completion_evidence","task.rejection_reason","requirement.acceptance_met","work.defect_class","agent.capability_claim","memory.consolidation_suggestion"],pu="rounded-lg border border-border-default bg-surface-primary px-2.5 py-1.5 text-[13px] text-fg-primary placeholder:text-fg-muted outline-none transition-colors focus:border-brand-500/60";function fu(e){const t=new Date(e);if(Number.isNaN(t.getTime()))return e;const n=a=>String(a).padStart(2,"0");return`${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function Gh(e){const t=new Date(Date.now()-e),n=a=>String(a).padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function J2(e,t){switch(e){case"task":return void yt.navigate(ce.WORK,{openTask:t});case"requirement":return void yt.navigate(ce.WORK,{openRequirement:t});case"agent":return void yt.navigate(ce.TEAM,{agentId:t});case"deliverable":return void yt.navigate(ce.DELIVERABLES,{openDeliverable:t});default:return}}const YJ=new Set(["task","requirement","agent","deliverable"]);function QJ(e){const[t,n]=w.useState([]),[a,i]=w.useState(!1);return w.useEffect(()=>{if(!e||!a)return;let l=!1;return(async()=>{const[c,u,m,f]=await Promise.allSettled([Se.tasks.list({lean:!0,pageSize:300}),Se.requirements.list({lean:!0,limit:300}),Se.agents.list({lean:!0}),Se.deliverables.search({limit:300})]);if(l)return;const g=[];if(c.status==="fulfilled")for(const h of c.value.tasks)g.push({kind:"task",id:h.id,label:h.title});if(u.status==="fulfilled")for(const h of u.value.requirements)g.push({kind:"requirement",id:h.id,label:h.title});if(m.status==="fulfilled")for(const h of m.value.agents)g.push({kind:"agent",id:h.id,label:h.name});if(f.status==="fulfilled")for(const h of f.value.results)g.push({kind:"deliverable",id:h.id,label:h.title});n(g)})(),()=>{l=!0}},[e,a]),{index:t,ensure:()=>i(!0)}}function Cs({active:e,onClick:t,children:n}){return o.jsx("button",{type:"button","aria-pressed":e,onClick:t,className:`rounded-lg border px-2.5 py-1 text-[12.5px] transition-colors ${e?"border-selected-border bg-selected-bg font-medium text-selected-fg":"border-border-default bg-surface-primary text-fg-secondary hover:text-fg-primary"}`,children:n})}function hu({children:e}){return o.jsx("span",{className:"w-14 shrink-0 text-[11px] text-fg-tertiary",children:e})}function JJ({role:e,authUser:t}){const{t:n}=ut("common"),a=Am(e??t?.role),i=QJ(a),l=i.index,[c,u]=w.useState(null),[m,f]=w.useState(""),[g,h]=w.useState(!1),[b,y]=w.useState(""),[k,C]=w.useState(""),[T,A]=w.useState("all"),[M,I]=w.useState(""),[B,G]=w.useState(""),[j,O]=w.useState(!1),[F,Y]=w.useState([]),[q,V]=w.useState(!1),[z,J]=w.useState(!1),[D,ee]=w.useState(!1),[R,te]=w.useState(null),le=w.useCallback(async()=>{if(a){ee(!0),te(null);try{const me=FJ({subjectKind:c?c.kind:b,subjectId:c?c.id:"",predicate:k,since:M,until:B,includeSuperseded:j,limit:200}),ze=await _Y.list(me);Y(GJ(ze.facts??[])),V(ze.disabled===!0),J(ze.truncated===!0)}catch(me){te(me instanceof Error?me.message:String(me)),Y([])}finally{ee(!1)}}},[a,c,b,k,M,B,j]);w.useEffect(()=>{le()},[le]);const ke=w.useMemo(()=>UJ(F),[F]),$=w.useMemo(()=>{let me=0,ze=0;for(const Ue of F)Y2(Ue)&&(me+=1),Ue.supersededBy&&(ze+=1);return{total:F.length,verified:me,superseded:ze}},[F]),W=w.useMemo(()=>{const me=m.trim().toLowerCase(),ze=b?l.filter(Ue=>Ue.kind===b):l;return me?ze.filter(Ue=>Ue.label.toLowerCase().includes(me)||Ue.id.toLowerCase().includes(me)).slice(0,30):ze.slice(0,30)},[l,m,b]),oe=me=>{if(A(me),me==="all"){I(""),G("");return}if(me==="24h"){I(Gh(24*36e5)),G("");return}if(me==="7d"){I(Gh(168*36e5)),G("");return}if(me==="30d"){I(Gh(720*36e5)),G("");return}},L=()=>{u(null),f(""),y(""),C(""),A("all"),I(""),G(""),O(!1)};if(!a)return null;const Ne=me=>Q2.includes(me)?n(`factsAudit.predicateName.${me.replace(/\./g,"_")}`,{defaultValue:me}):me,qe=me=>n(`factsAudit.kind.${me}`,{defaultValue:me});return o.jsx("div",{className:"h-full overflow-y-auto","data-testid":"audit-facts",children:o.jsxs("div",{className:"mx-auto max-w-4xl px-6 py-7",children:[o.jsxs("header",{className:"space-y-1.5",children:[o.jsx("h1",{className:"text-lg font-semibold tracking-tight text-fg-primary",children:n("factsAudit.title")}),o.jsx("p",{className:"max-w-2xl text-[13px] leading-relaxed text-fg-secondary",children:n("factsAudit.subtitle")})]}),o.jsxs("div",{className:"mt-4 flex flex-wrap items-baseline gap-x-5 gap-y-1 text-[12px] text-fg-tertiary",children:[o.jsxs("span",{children:[o.jsx("span",{className:"tabular-nums font-medium text-fg-primary",children:$.total})," ",n("factsAudit.statTotal")]}),o.jsxs("span",{children:[o.jsx("span",{className:"tabular-nums font-medium text-status-ok",children:$.verified})," ",n("factsAudit.statVerified")]}),o.jsxs("span",{children:[o.jsx("span",{className:"tabular-nums font-medium text-fg-primary",children:$.superseded})," ",n("factsAudit.statSuperseded")]})]}),o.jsxs("section",{className:"mt-4 space-y-2 rounded-xl border border-border-default bg-surface-secondary/50 p-3","data-testid":"audit-facts-filters",children:[o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(hu,{children:n("factsAudit.fSubject")}),o.jsx("div",{className:"relative min-w-0 flex-1",children:c?o.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg border border-selected-border bg-selected-bg px-2.5 py-1.5",children:[o.jsx("span",{className:"shrink-0 rounded bg-surface-primary/60 px-1.5 py-0.5 text-[10px] text-fg-secondary",children:qe(c.kind)}),o.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] text-selected-fg",children:c.label}),o.jsx("button",{type:"button",onClick:()=>{u(null),f("")},className:"shrink-0 rounded px-1 text-fg-secondary transition-colors hover:text-fg-primary","aria-label":n("factsAudit.clearSubject"),children:"×"})]}):o.jsxs(o.Fragment,{children:[o.jsx("input",{className:`${pu} w-full`,value:m,onChange:me=>{i.ensure(),f(me.target.value),h(!0)},onFocus:()=>{i.ensure(),h(!0)},onBlur:()=>window.setTimeout(()=>h(!1),120),placeholder:n("factsAudit.subjectSearchPlaceholder"),"aria-label":n("factsAudit.subjectSearchPlaceholder")}),g&&o.jsx("div",{className:"absolute z-20 mt-1 max-h-72 w-full overflow-y-auto rounded-lg border border-border-default bg-surface-elevated py-1 shadow-lg",children:W.length===0?o.jsx("p",{className:"px-3 py-2 text-[12px] text-fg-tertiary",children:n("factsAudit.subjectNoMatch")}):W.map(me=>o.jsxs("button",{type:"button",onMouseDown:ze=>ze.preventDefault(),onClick:()=>{u(me),f(""),h(!1)},className:"flex w-full items-center gap-2 px-3 py-1.5 text-left transition-colors hover:bg-surface-overlay",children:[o.jsx("span",{className:"shrink-0 rounded bg-surface-secondary px-1.5 py-0.5 text-[10px] text-fg-tertiary",children:qe(me.kind)}),o.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] text-fg-primary",children:me.label}),o.jsx("span",{className:"shrink-0 font-mono text-[10px] text-fg-muted",children:me.id})]},`${me.kind}:${me.id}`))})]})})]}),o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(hu,{children:n("factsAudit.fKind")}),o.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[o.jsx(Cs,{active:b==="",onClick:()=>{y(""),u(null)},children:n("factsAudit.kindAll")}),$J.map(me=>o.jsx(Cs,{active:b===me,onClick:()=>{y(me),c&&c.kind!==me&&u(null)},children:qe(me)},me))]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(hu,{children:n("factsAudit.fConclusion")}),o.jsxs("select",{className:`${pu} min-w-[220px]`,value:k,onChange:me=>C(me.target.value),"aria-label":n("factsAudit.fConclusion"),children:[o.jsx("option",{value:"",children:n("factsAudit.conclusionAll")}),Q2.map(me=>o.jsxs("option",{value:me,children:[Ne(me),"(",me,")"]},me))]})]}),o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(hu,{children:n("factsAudit.fTime")}),o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[o.jsx(Cs,{active:T==="all",onClick:()=>oe("all"),children:n("factsAudit.rangeAll")}),o.jsx(Cs,{active:T==="24h",onClick:()=>oe("24h"),children:n("factsAudit.range24h")}),o.jsx(Cs,{active:T==="7d",onClick:()=>oe("7d"),children:n("factsAudit.range7d")}),o.jsx(Cs,{active:T==="30d",onClick:()=>oe("30d"),children:n("factsAudit.range30d")}),o.jsx(Cs,{active:T==="custom",onClick:()=>A("custom"),children:n("factsAudit.rangeCustom")})]})]}),T==="custom"&&o.jsxs("div",{className:"flex flex-wrap items-center gap-3 pl-16",children:[o.jsxs("label",{className:"flex items-center gap-2 text-[11px] text-fg-tertiary",children:[n("factsAudit.since"),o.jsx("input",{type:"datetime-local",className:pu,value:M,onChange:me=>I(me.target.value)})]}),o.jsxs("label",{className:"flex items-center gap-2 text-[11px] text-fg-tertiary",children:[n("factsAudit.until"),o.jsx("input",{type:"datetime-local",className:pu,value:B,onChange:me=>G(me.target.value)})]})]}),o.jsxs("div",{className:"flex items-center gap-2 border-t border-border-subtle pt-2",children:[o.jsxs("label",{className:"flex items-center gap-1.5 text-[12px] text-fg-secondary",children:[o.jsx("input",{type:"checkbox",className:"accent-current",checked:j,onChange:me=>O(me.target.checked)}),n("factsAudit.includeSuperseded")]}),o.jsx("button",{type:"button",onClick:L,className:"ml-auto rounded-lg px-2.5 py-1 text-[12.5px] text-fg-tertiary transition-colors hover:text-fg-primary",children:n("factsAudit.reset")})]})]}),q&&o.jsx("p",{className:"mt-3 rounded-lg border border-status-warn/30 bg-status-warn/10 px-3 py-2 text-[12px] leading-relaxed text-fg-primary","data-testid":"audit-facts-disabled",children:n("factsAudit.disabled")}),R&&o.jsx("p",{className:"mt-3 rounded-lg border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-[12px] text-fg-primary","data-testid":"audit-facts-error",children:R}),D&&o.jsx("div",{className:"mt-3 overflow-hidden rounded-xl border border-border-default","data-testid":"audit-facts-loading",children:[0,1,2].map(me=>o.jsxs("div",{className:"border-b border-border-subtle px-4 py-3 last:border-b-0",children:[o.jsx("div",{className:"h-3 w-40 animate-pulse rounded bg-surface-overlay"}),o.jsx("div",{className:"mt-2 h-2.5 w-64 animate-pulse rounded bg-surface-overlay/70"})]},me))}),!q&&!D&&F.length===0&&!R&&o.jsxs("div",{className:"mt-3 rounded-xl border border-dashed border-border-default px-4 py-12 text-center","data-testid":"audit-facts-empty",children:[o.jsx("p",{className:"text-[13px] text-fg-secondary",children:n("factsAudit.empty")}),o.jsx("p",{className:"mt-1 text-[11px] text-fg-tertiary",children:n("factsAudit.emptyHint")})]}),F.length>0&&o.jsxs("div",{className:"mt-3 overflow-hidden rounded-xl border border-border-default bg-surface-primary","data-testid":"audit-facts-table",children:[z&&o.jsx("p",{className:"border-b border-border-subtle bg-surface-secondary/60 px-4 py-1.5 text-[11px] text-fg-tertiary","data-testid":"audit-facts-truncated",children:n("factsAudit.truncated")}),F.map(me=>{const ze=KJ(me,ke),Ue=!!me.supersededBy,je=Y2(me),Ye=me.workUnitRef?VJ(me.workUnitRef):null,xt=YJ.has(me.subjectKind),mt=me.subjectLabel||me.subjectId;return o.jsxs("article",{id:`fact-${me.id}`,className:"border-b border-border-subtle px-4 py-3 transition-colors last:border-b-0 hover:bg-surface-secondary/40","data-testid":"audit-facts-row",children:[o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[o.jsx("span",{className:"text-[13px] font-medium text-fg-primary",children:Ne(me.predicate)}),o.jsx("span",{className:"font-mono text-[11px] text-fg-muted",title:me.predicate,children:me.predicate})]}),o.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-fg-tertiary",children:[o.jsx("span",{className:"shrink-0",children:qe(me.subjectKind)}),xt?o.jsx("button",{type:"button",onClick:()=>J2(me.subjectKind,me.subjectId),title:n("factsAudit.openSubject",{id:me.subjectId}),className:"max-w-[26rem] truncate text-left text-[12px] font-medium text-brand-500 underline decoration-brand-500/30 underline-offset-2 transition-colors hover:decoration-brand-500",children:mt}):o.jsx("span",{className:"max-w-[26rem] truncate text-fg-secondary",title:me.subjectId,children:mt}),o.jsx("span",{"aria-hidden":!0,children:"·"}),o.jsx("span",{children:n("factsAudit.by",{name:me.assertedByName||me.assertedBy})}),o.jsx("span",{"aria-hidden":!0,children:"·"}),o.jsx("span",{title:me.createdAt,children:fu(me.createdAt)}),Ye&&o.jsxs(o.Fragment,{children:[o.jsx("span",{"aria-hidden":!0,children:"·"}),o.jsx("span",{title:me.workUnitRef,children:Ye.kind==="session"?Ye.round?n("factsAudit.wu.sessionRound",{round:Ye.round}):n("factsAudit.wu.session"):Ye.kind==="a2a"?n("factsAudit.wu.a2a"):Ye.value})]}),o.jsx("span",{"aria-hidden":!0,children:"·"}),o.jsx("span",{className:"tabular-nums",title:n("factsAudit.confidence"),children:n("factsAudit.confidenceShort",{pct:Math.round((me.confidence??0)*100)})})]})]}),o.jsxs("div",{className:"flex shrink-0 flex-col items-end gap-1",children:[Ue?o.jsx("span",{className:"rounded-full border border-status-danger/30 bg-status-danger/10 px-2 py-0.5 text-[11px] font-medium text-status-danger",children:n("factsAudit.superseded")}):me.verification?o.jsxs("span",{className:`rounded-full border px-2 py-0.5 text-[11px] font-medium ${je?"border-status-ok/30 bg-status-ok/10 text-status-ok":"border-status-warn/30 bg-status-warn/10 text-status-warn"}`,title:n("factsAudit.verificationTitle"),children:[me.verification.result," · ",me.verification.verifiedByName||me.verification.verifiedBy,me.verification.verifiedAt?` · ${fu(me.verification.verifiedAt)}`:""]}):o.jsx("span",{className:"rounded-full border border-border-default bg-surface-secondary px-2 py-0.5 text-[11px] text-fg-tertiary",children:n("factsAudit.unverified")}),ze.outgoing&&o.jsx("span",{className:"text-[10.5px] text-fg-tertiary",title:ze.outgoing.factId,"data-testid":"audit-facts-chain-out",children:ze.outgoing.missing?n("factsAudit.chain.replacedByUnknown"):n("factsAudit.chain.replacedBy",{time:fu(ze.outgoing.at??"")})}),ze.incoming&&o.jsx("span",{className:"text-[10.5px] text-fg-tertiary",title:ze.incoming.factId,"data-testid":"audit-facts-chain-in",children:n("factsAudit.chain.replaces",{time:fu(ze.incoming.at??"")})})]})]}),me.sourceRefs?.length>0&&o.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5",children:[o.jsx("span",{className:"text-[10.5px] uppercase tracking-wide text-fg-muted",children:n("factsAudit.evidence")}),me.sourceRefs.map(ft=>{const rt=WJ(ft),jt=rt.kind==="commit"?n("factsAudit.src.commit",{hash:rt.hash}):rt.kind==="probe"?n("factsAudit.src.probe"):rt.kind==="task"?n("factsAudit.src.task"):rt.kind==="deliverable"?n("factsAudit.src.deliverable"):rt.value,ht=rt.kind==="task"&&ft.startsWith("task:")||rt.kind==="deliverable"&&ft.startsWith("deliverable:"),He=ft.slice(ft.indexOf(":")+1),Et="rounded border border-border-subtle bg-surface-secondary px-1.5 py-0.5 text-[10.5px] text-fg-secondary";return ht?o.jsx("button",{type:"button",title:ft,onClick:()=>J2(rt.kind,He),className:`${Et} underline decoration-fg-muted/40 underline-offset-2 transition-colors hover:text-fg-primary`,children:jt},ft):o.jsx("span",{title:ft,className:Et,children:jt},ft)})]}),o.jsxs("details",{className:"group mt-1.5",children:[o.jsx("summary",{className:"cursor-pointer select-none text-[11px] text-fg-tertiary transition-colors hover:text-fg-secondary",children:n("factsAudit.colValue")}),o.jsx("pre",{className:"mt-1.5 max-h-64 overflow-auto rounded-lg border border-border-subtle bg-surface-secondary/60 p-2.5 font-mono text-[11px] leading-relaxed text-fg-secondary",children:JSON.stringify(me.value,null,2)})]})]},me.id)})]})]})})}const XJ=Object.freeze(Object.defineProperty({__proto__:null,canViewFactsAudit:Am,default:JJ},Symbol.toStringTag,{value:"Module"}));class ZJ extends w.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t){this.state.error&&this.props.resetKeys&&!eX(t.resetKeys,this.props.resetKeys)&&this.setState({error:null})}componentDidCatch(t,n){this.props.onError?.(t,n),console.error("[ErrorBoundary] caught render error:",t,n.componentStack)}reset=()=>this.setState({error:null});render(){const{error:t}=this.state;if(t){const{fallback:n}=this.props;return typeof n=="function"?n(t,this.reset):n??null}return this.props.children}}function eX(e,t){if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}const Tm=5,$S=5*1024*1024,tX=["image/png","image/jpeg","image/webp","image/gif"];function nX(e,t){const n=[],a=[],i=tX;let l=t;for(const c of e){if(!i.includes(c.type)){a.push({name:c.name,reason:"not_image"});continue}if(c.size>$S){a.push({name:c.name,reason:"too_large"});continue}if(l>=Tm){a.push({name:c.name,reason:"too_many"});continue}n.push(c),l+=1}return{accepted:n,rejected:a}}function aX(e){if(!Number.isFinite(e)||e<=0)return"0 B";const t=["B","KB","MB","GB"],n=Math.min(t.length-1,Math.floor(Math.log(e)/Math.log(1024))),a=e/1024**n;return`${a>=10||n===0?Math.round(a):Math.round(a*10)/10} ${t[n]}`}function rX(e){return e.title.trim()?null:"title_required"}function iX(e,t){return t==="not_image"?e("feedback.rejectNotImage"):t==="too_large"?e("feedback.rejectTooLarge",{size:aX($S)}):e("feedback.rejectTooMany",{max:Tm})}function sX({defaultContact:e,initialTitle:t,initialBody:n,onClose:a}){const{t:i}=ut("common");$s(!0);const[l,c]=w.useState(t??""),[u,m]=w.useState(n??""),[f,g]=w.useState(e??""),[h,b]=w.useState([]),[y,k]=w.useState([]),[C,T]=w.useState(""),[A,M]=w.useState(!1),[I,B]=w.useState(!1),[G,j]=w.useState(!1),O=w.useRef(null),F=w.useRef([]);F.current=h;const Y=at.isAuthenticated();w.useEffect(()=>()=>{for(const D of F.current)URL.revokeObjectURL(D.previewUrl)},[]),w.useEffect(()=>{const D=ee=>{ee.key==="Escape"&&!A&&a()};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[A,a]);const q=w.useCallback(D=>{if(!D)return;const ee=Array.from(D);if(ee.length===0)return;const{accepted:R,rejected:te}=nX(ee,F.current.length);te.length?k(te.map(le=>`${le.name}:${iX(i,le.reason)}`)):k([]),R.length&&b(le=>[...le,...R.map(ke=>({id:`${ke.name}-${ke.size}-${Math.random().toString(36).slice(2)}`,file:ke,previewUrl:URL.createObjectURL(ke)}))])},[i]),V=D=>{b(ee=>{const R=ee.find(te=>te.id===D);return R&&URL.revokeObjectURL(R.previewUrl),ee.filter(te=>te.id!==D)}),k([])},z=async D=>{if(D.preventDefault(),T(""),rX({title:l})){T(i("feedback.titleRequired"));return}M(!0);try{const ee=[];for(const R of h){const te=await at.uploadImage(R.file);if(!te?.url)throw new Error("upload_failed");ee.push(te.url)}await at.feedback.create({title:l.trim(),content:u.trim()||void 0,contact:f.trim()||void 0,images:ee.length?ee:void 0,appVersion:"0.12.5-rc.2",platform:typeof navigator<"u"?navigator.platform:void 0,locale:typeof navigator<"u"?navigator.language:void 0}),B(!0)}catch(ee){const R=ee.status,te=ee instanceof Error?ee.message:String(ee);T(i(R===404?"feedback.hubUnsupported":te==="upload_failed"?"feedback.uploadFailed":"feedback.submitFailed"))}finally{M(!1)}},J=o.jsx("div",{"data-testid":"feedback-modal",className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10000] p-4",onClick:()=>{A||a()},children:o.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl w-[540px] max-w-full max-h-[calc(100vh-2rem)] overflow-y-auto shadow-2xl",onClick:D=>D.stopPropagation(),onDragOver:D=>{D.preventDefault(),Y&&j(!0)},onDragLeave:()=>j(!1),onDrop:D=>{D.preventDefault(),j(!1),Y&&q(D.dataTransfer.files)},children:I?o.jsxs("div",{className:"p-6 text-center",children:[o.jsx("div",{className:"text-3xl mb-3",children:"✅"}),o.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-2",children:i("feedback.successTitle")}),o.jsx("p",{className:"text-sm text-fg-tertiary mb-5",children:i("feedback.successDesc")}),o.jsx("button",{type:"button",onClick:a,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg",children:i("feedback.successClose")})]}):o.jsxs("form",{onSubmit:z,className:"p-6",children:[o.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:i("feedback.modalTitle")}),o.jsx("p",{className:"text-xs text-fg-tertiary mt-1 mb-4",children:i("feedback.modalSubtitle")}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:[i("feedback.fieldTitle")," ",o.jsx("span",{className:"text-red-400",children:"*"})]}),o.jsx("input",{value:l,onChange:D=>c(D.target.value),maxLength:120,autoFocus:!0,placeholder:i("feedback.titlePlaceholder"),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:i("feedback.fieldContent")}),o.jsx("textarea",{value:u,onChange:D=>m(D.target.value),maxLength:4e3,rows:5,placeholder:i("feedback.contentPlaceholder"),onPaste:D=>{if(!Y)return;const ee=Array.from(D.clipboardData?.files??[]);ee.length&&(D.preventDefault(),q(ee))},className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none resize-y"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:i("feedback.fieldImages",{max:Tm})}),Y?o.jsxs("div",{className:`rounded-lg border border-dashed p-3 transition-colors ${G?"border-brand-500 bg-brand-500/5":"border-border-default"}`,children:[o.jsxs("div",{className:"flex flex-wrap gap-2",children:[h.map(D=>o.jsxs("div",{className:"relative group",children:[o.jsx("img",{src:D.previewUrl,alt:D.file.name,className:"w-20 h-16 object-cover rounded-md border border-border-default"}),o.jsx("button",{type:"button",onClick:()=>V(D.id),title:i("remove"),className:"absolute -top-1.5 -right-1.5 w-5 h-5 rounded-full bg-black/70 text-white text-[11px] leading-none opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]},D.id)),h.length<Tm&&o.jsx("button",{type:"button",onClick:()=>O.current?.click(),className:"w-20 h-16 rounded-md border border-dashed border-border-default text-fg-muted hover:text-fg-secondary hover:border-brand-500 transition-colors text-lg",children:"+"})]}),o.jsx("p",{className:"text-[10px] text-fg-muted mt-2",children:i("feedback.dropHint")}),o.jsx("input",{ref:O,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",multiple:!0,className:"hidden",onChange:D=>{q(D.target.files),D.target.value=""}})]}):o.jsx("p",{className:"text-[11px] text-amber-500/90 bg-amber-500/10 border border-amber-500/30 rounded-lg px-3 py-2",children:i("feedback.loginForImages")}),y.length>0&&o.jsx("ul",{className:"mt-1.5 space-y-0.5",children:y.map((D,ee)=>o.jsx("li",{className:"text-[11px] text-red-400",children:D},ee))})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:i("feedback.fieldContact")}),o.jsx("input",{value:f,onChange:D=>g(D.target.value),placeholder:i("feedback.contactPlaceholder"),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none"})]}),C&&o.jsx("div",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:C})]}),o.jsxs("div",{className:"flex justify-end gap-3 mt-5",children:[o.jsx("button",{type:"button",onClick:a,disabled:A,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated disabled:opacity-50",children:i("cancel")}),o.jsx("button",{type:"submit",disabled:A,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-on-brand rounded-lg",children:i(A?"feedback.submitting":"feedback.submit")})]})]})})});return typeof document<"u"?Jo.createPortal(J,document.body):J}function Kh({label:e,value:t}){return o.jsxs("div",{className:"rounded-lg px-2 py-2.5 text-center bg-surface-elevated",children:[o.jsx("div",{className:"text-lg font-semibold tabular-nums text-fg-primary",children:t.toLocaleString()}),o.jsx("div",{className:"text-[10px] uppercase tracking-wider mt-0.5 text-fg-muted",children:e})]})}function oX({onClose:e}){const{t}=ut("common");$s(!0);const[n,a]=w.useState(null),[i,l]=w.useState(!0),[c,u]=w.useState(""),[m,f]=w.useState(null),g=at.isAuthenticated(),h=w.useCallback(async()=>{if(!g){l(!1);return}l(!0),u("");try{const y=await at.user.referral();a({code:y.code,shareUrl:y.shareUrl,invitedCount:y.invitedCount,paidCount:y.paidCount,rewardCuTotal:y.rewardCuTotal,rewardCuPerPaid:y.rewardCuPerPaid,claimBonusCu:y.claimBonusCu})}catch(y){u(y.status===404?t("ambassador.unsupported"):t("ambassador.loadFailed"))}finally{l(!1)}},[g,t]);w.useEffect(()=>{h()},[h]),w.useEffect(()=>{const y=k=>{k.key==="Escape"&&e()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[e]);const b=async y=>{if(n)try{await navigator.clipboard.writeText(y==="code"?n.code:n.shareUrl),f(y),setTimeout(()=>f(null),2e3)}catch{}};return o.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10000] p-4",onClick:e,children:o.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl w-[460px] max-w-full max-h-[calc(100vh-2rem)] overflow-y-auto shadow-2xl p-6",onClick:y=>y.stopPropagation(),children:[o.jsxs("div",{className:"flex items-start gap-2 mb-4",children:[o.jsx("span",{className:"text-xl leading-none",children:"🎁"}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:t("ambassador.title")}),o.jsx("p",{className:"text-xs text-fg-tertiary mt-1 leading-relaxed",children:n?t("ambassador.desc",{claimAmount:n.claimBonusCu.toLocaleString(),rewardAmount:n.rewardCuPerPaid.toLocaleString()}):t("ambassador.descGeneric")})]})]}),g?i?o.jsx("p",{className:"text-sm text-fg-tertiary py-6 text-center",children:t("ambassador.loading")}):c?o.jsx("p",{className:"text-xs text-red-400 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:c}):n?o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:t("ambassador.codeLabel")}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("code",{className:"flex-1 px-3 py-2 rounded-lg text-sm font-mono tracking-widest bg-surface-elevated text-fg-primary select-all",children:n.code}),o.jsx("button",{type:"button",onClick:()=>{b("code")},className:"px-3 py-2 text-xs font-medium rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand shrink-0",children:t(m==="code"?"ambassador.copied":"ambassador.copyCode")})]})]}),o.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[o.jsx(Kh,{label:t("ambassador.statInvited"),value:n.invitedCount}),o.jsx(Kh,{label:t("ambassador.statPaid"),value:n.paidCount}),o.jsx(Kh,{label:t("ambassador.statReward"),value:n.rewardCuTotal})]}),o.jsx("button",{type:"button",onClick:()=>{b("link")},className:"w-full px-3 py-2 text-xs border border-border-default rounded-lg hover:bg-surface-elevated text-fg-secondary",children:t(m==="link"?"ambassador.copied":"ambassador.copyLink")})]}):null:o.jsxs("div",{className:"rounded-lg border border-border-default p-4 text-center",children:[o.jsx("p",{className:"text-sm text-fg-secondary mb-3",children:t("ambassador.loginPrompt")}),o.jsx("button",{type:"button",onClick:()=>{at.ensureAuth().then(()=>h()).catch(()=>{})},className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg",children:t("ambassador.login")})]}),o.jsxs("div",{className:"flex justify-end gap-3 mt-5",children:[g&&n&&o.jsx("button",{type:"button",onClick:()=>{const y=at.getUrl().replace(/\/$/,"");Or(`${y}/settings`)},className:"px-3 py-2 text-xs border border-border-default rounded-lg hover:bg-surface-elevated text-fg-secondary",children:t("ambassador.openHub")}),o.jsx("button",{type:"button",onClick:e,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:t("close")})]})]})})}function _o({d:e,size:t=14}){return o.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:o.jsx("path",{d:e})})}const Vh=200;function lX({authUser:e,onLogout:t,onEditProfile:n,showSettingsLink:a=!1,collapsed:i=!1,showVersion:l=!1}){const{t:c}=ut(["nav","common"]),[u,m]=w.useState(!1),[f,g]=w.useState(!1),[h,b]=w.useState(!1),[y,k]=w.useState(!1),[C,T]=w.useState({top:0,left:0}),A=w.useRef(null),M=w.useRef(null),{connected:I,user:B,credits:G,refresh:j}=TS(u),O=w.useCallback(()=>{if(!A.current)return;const R=A.current.getBoundingClientRect(),te=window.innerWidth,le=window.innerHeight,ke=M.current?.offsetHeight??220;let $=R.right+8;$+Vh>te-8&&($=Math.max(8,R.left-Vh-8));let W=R.top-ke-8;W<8&&(W=Math.min(R.bottom+8,le-ke-8)),T({top:Math.max(8,W),left:$})},[]);w.useLayoutEffect(()=>{if(!u)return;O();const R=requestAnimationFrame(()=>O());return()=>cancelAnimationFrame(R)},[u,O,i]),w.useEffect(()=>{if(!u)return;const R=le=>{const ke=le.target;A.current?.contains(ke)||M.current?.contains(ke)||m(!1)},te=()=>O();return document.addEventListener("mousedown",R),window.addEventListener("resize",te),window.addEventListener("scroll",te,!0),()=>{document.removeEventListener("mousedown",R),window.removeEventListener("resize",te),window.removeEventListener("scroll",te,!0)}},[u,O]);const F=e?.name||B?.displayName||B?.username||c("common:userPlaceholder"),Y=e?.email||B?.email||"",q=SS(e?.avatarUrl,B?.avatarUrl),V=I?"bg-emerald-500":"bg-fg-muted",z=I?B?.username?c("sidebar.hubConnectedAs",{username:B.username}):c("sidebar.hubConnected"):c("sidebar.hubDisconnected"),J=!!(I&&B?.username&&e?.name&&B.username.toLowerCase()!==e.name.toLowerCase()&&B.email?.toLowerCase()!==e.email?.toLowerCase()),D=()=>{m(!1),j({validate:!0}),yt.navigate(ce.SETTINGS,{tab:"account"})},ee=u&&Jo.createPortal(o.jsxs("div",{ref:M,className:"fixed bg-surface-elevated border border-border-default rounded-xl shadow-xl z-[9999] overflow-hidden",style:{top:C.top,left:C.left,width:Vh},children:[o.jsxs("div",{className:"px-3.5 py-3 border-b border-border-default flex items-start gap-2",children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:F}),Y&&o.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5 truncate",children:Y}),G!==null&&o.jsxs("button",{type:"button",onClick:()=>{m(!1),Or(`${at.getUrl().replace(/\/$/,"")}/settings?tab=billing`)},title:c("common:creditBalanceOpenHub"),className:"text-xs text-fg-secondary mt-0.5 -mx-1 px-1 max-w-full flex items-center gap-1 rounded transition-colors hover:text-brand-500 hover:bg-surface-overlay",children:[o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:[o.jsx("path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z"}),o.jsx("path",{d:"M12.5 5.5v13",strokeDasharray:"2 2.5"})]}),o.jsxs("span",{className:"truncate",children:[c("common:creditBalance"),": ",G.remaining.toLocaleString()]})]})]}),n&&o.jsx("button",{type:"button",onClick:()=>{m(!1),n()},title:c("common:profile.editProfile"),className:"shrink-0 mt-0.5 p-1.5 rounded-md text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay transition-colors",children:o.jsx(_o,{d:"M12 20h9M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z",size:14})})]}),o.jsxs("button",{type:"button",onClick:D,className:"w-full px-3.5 py-2.5 border-b border-border-default flex items-center gap-2 hover:bg-surface-overlay transition-colors text-left",children:[o.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${V}`}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsx("span",{className:"text-xs text-fg-secondary block truncate",children:z}),J&&B?.username&&o.jsx("span",{className:"text-[10px] text-amber-500/90 block truncate mt-0.5",children:c("sidebar.hubAccountMismatch",{username:B.username})})]}),o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-fg-muted shrink-0",children:o.jsx("path",{d:"m9 18 6-6-6-6"})})]}),o.jsxs("div",{className:"py-1",children:[o.jsxs("button",{type:"button",onClick:()=>{m(!1),b(!0)},className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[o.jsx(_o,{d:"M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5Z"}),c("common:feedback.entry")]}),o.jsxs("button",{type:"button",onClick:()=>{m(!1),k(!0)},className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[o.jsx(_o,{d:"M20 12v10H4V12M2 7h20v5H2zM12 22V7M12 7H7.5a2.5 2.5 0 0 1 0-5C11 2 12 7 12 7ZM12 7h4.5a2.5 2.5 0 0 0 0-5C13 2 12 7 12 7Z"}),c("common:ambassador.entry")]}),a&&o.jsxs("button",{type:"button",onClick:()=>{m(!1),yt.navigate(ce.SETTINGS)},className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[o.jsx(_o,{d:Xm[ce.SETTINGS]}),c("settings")]}),window.markusDesktop&&o.jsxs("button",{type:"button",onClick:()=>{m(!1),window.markusDesktop?.openInBrowser()},className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[o.jsx(_o,{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6M15 3h6v6M10 14 21 3"}),c("common:openInBrowser")]}),t&&o.jsxs("button",{type:"button",onClick:()=>{m(!1),g(!0)},className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[o.jsx(_o,{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9"}),c("common:signOut")]})]})]}),document.body);return o.jsxs("div",{className:`relative ${i?"flex justify-center":"flex items-center justify-between gap-2 w-full"}`,children:[o.jsxs("button",{ref:A,type:"button",onClick:()=>m(R=>!R),title:F,className:`relative inline-flex items-center justify-center rounded-full transition-opacity hover:opacity-90 ${i?"p-0.5":""}`,children:[o.jsx(Go,{name:F,avatarUrl:q,size:i?28:32,fallback:"icon"}),o.jsx("span",{className:`absolute bottom-0 right-0 w-2.5 h-2.5 rounded-full border-2 border-surface-secondary ${V}`,title:z})]}),l&&!i&&o.jsxs("span",{className:"text-[10px] text-fg-muted select-none shrink-0",children:["v","0.12.5-rc.2"]}),ee,h&&o.jsx(sX,{defaultContact:Y,onClose:()=>b(!1)}),y&&o.jsx(oX,{onClose:()=>k(!1)}),f&&t&&o.jsx(xr,{title:c("common:signOutConfirmTitle"),message:c("common:signOutConfirmMessage"),confirmLabel:c("common:signOut"),variant:"primary",onConfirm:()=>{g(!1),t()},onCancel:()=>g(!1)})]})}function cX({d:e,size:t=18}){return o.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:o.jsx("path",{d:e})})}function dX({currentPage:e,onNavigate:t,authUser:n,collapsed:a,onToggleCollapse:i,onLogout:l,keyboardFocusPageId:c,keyboardPaneActive:u}){const{t:m}=ut(["nav","common"]),[f,g]=w.useState(ep);return w.useEffect(()=>gS(g),[]),o.jsxs("aside",{"data-keyboard-pane":"l0",className:"markus-app-sidebar h-dvh bg-surface-secondary flex flex-col shrink-0 overflow-hidden",children:[o.jsx("div",{"data-electron-drag":!0,className:`electron-mac-sidebar-header flex items-center ${a?"px-2 py-3.5 justify-center":"px-4 h-14 justify-between"}`,children:o.jsxs("button",{"data-no-drag":!0,onClick:i,title:m(a?"sidebar.expandSidebar":"sidebar.collapseSidebar"),className:"flex items-center gap-2.5 min-w-0 group",children:[o.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-8 h-8 rounded-lg shrink-0"}),!a&&o.jsx("span",{className:"text-[15px] font-bold tracking-tight text-fg-primary whitespace-nowrap",children:"Markus"})]})}),o.jsx("nav",{className:`${a?"p-1":"px-3 py-2"} flex-1 overflow-y-auto scrollbar-thin`,children:UW.map((h,b)=>{const y=Y4.filter(C=>C.section===h.key);if(y.length===0)return null;const k=m(`sections.${h.key}`);return o.jsx("div",{children:o.jsxs("div",{className:b>0?"mt-3":"",children:[!a&&k&&o.jsx("div",{className:"px-3 py-1.5 mb-1 text-[10px] font-semibold text-fg-muted uppercase tracking-[0.1em]",children:k}),a&&b>0&&o.jsx("div",{className:"my-3"}),y.map(C=>{const T=e===C.id,A=u&&c===C.id;return o.jsxs("button",{"data-l0-page-id":C.id,onClick:()=>t(C.id),title:a?m(C.id):void 0,className:`relative w-full flex items-center ${a?"flex-col justify-center px-1 py-1.5 gap-0.5":"gap-3 px-3 py-[7px]"} rounded-lg text-[13px] font-medium mb-0.5 transition-colors text-fg-primary ${A?"bg-brand-500/25 ring-1 ring-inset ring-brand-500/40":T?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[o.jsx(cX,{d:Xm[C.id]??"",size:a?16:18}),a?o.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:m(C.id)}):o.jsx("span",{className:"truncate",children:m(C.id)}),C.id===ce.HOME&&f>0&&(a?o.jsx("span",{className:"absolute top-0.5 right-1.5 min-w-[13px] h-[13px] px-[3px] rounded-full bg-red-500 text-white text-[8px] font-bold flex items-center justify-center tabular-nums",children:f>9?"9+":f}):o.jsx("span",{className:"ml-auto shrink-0 text-[10px] px-1.5 py-0.5 rounded-full bg-red-500 text-white font-semibold tabular-nums",children:f>99?"99+":f}))]},C.id)})]})},h.key)})}),o.jsx("div",{className:`shrink-0 border-t border-border-subtle ${a?"p-1.5 flex justify-center":"px-3 py-2.5"}`,children:o.jsx(lX,{authUser:n,onLogout:l,onEditProfile:()=>{window.dispatchEvent(new Event("markus:open-edit-profile"))},showSettingsLink:!1,collapsed:a,showVersion:!a})})]})}const uX=100;function mX(e,t){const n=uX,a=((f,g)=>setTimeout(f,g)),i=(f=>clearTimeout(f)),l=new Map;let c=null,u=!1;function m(){if(c=null,u=!1,l.size===0)return;const f=[];for(const[g,h]of l)f.push({conversationKey:g,lastReadAt:h});l.clear(),e(f)}return{queue(f,g){let h=!1;for(const b of f)b&&(l.set(b,g),h=!0);h&&(u||(u=!0,c=a(m,n)))},flushNow(){u&&(i(c),u=!1,c=null),m()},pendingCount(){return l.size}}}const pX=6e4,fX=2e3;let cr={},Yi={};const dg=new Set,Em=new Set;let FS=0;const ug=new Map;let gc=null,gu=0,em=null;function _c(){for(const e of dg)e()}function X2(e,t){const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const a of n)if(e[a]!==t[a])return!1;return!0}function hX(e,t){const n={},a=[];for(const[i,l]of Object.entries(e)){if(t.has(i)){l>0&&a.push(i);continue}n[i]=l}return{counts:n,staleActiveKeys:a}}function gX(e,t){Nm([e],t)}function bX(e,t,n,a){const i=[];for(const l of e){const c=t.get(l)??0;!a?.force&&n-c<fX||i.push(l)}return i}const US=mX(e=>{(e.length===1?Se.unread.markRead(e[0].conversationKey,e[0].lastReadAt):Se.unread.markReadBatch(e)).catch(()=>{})});typeof window<"u"&&typeof window.addEventListener=="function"&&window.addEventListener("pagehide",()=>US.flushNow(),{passive:!0});function Nm(e,t){const n=Date.now(),a=bX(e,ug,n,t);let i=!1;for(const l of a)ug.set(l,n),l in cr&&(delete cr[l],i=!0);i&&_c(),a.length!==0&&US.queue(a,new Date(n).toISOString())}async function mg(){try{const e=await Se.unread.getCounts(),{counts:t,staleActiveKeys:n}=hX(e.counts??{},Em);cr=t,Yi=e.sessionAgentMap??{},_c(),Nm(n)}catch{}}function yX(){gc||(mg(),gc=setInterval(mg,pX),em=di.on("chat:unread_update",e=>{const t=e.payload?.conversationKey;if(t){if(Em.has(t)){gX(t);return}Date.now()>FS&&(cr[t]=(cr[t]??0)+1,_c())}}))}function vX(){gc&&(clearInterval(gc),gc=null),em&&(em(),em=null)}function xX(e){const t=e?.enabled??!0,[n,a]=w.useState(cr),[i,l]=w.useState(Yi),c=w.useCallback(async()=>{await mg()},[]),u=w.useCallback(async T=>{if(T.length===0)return;let A=!1;for(const M of T)M in cr&&(delete cr[M],A=!0);A&&_c(),Nm(T,{force:!0})},[]),m=w.useCallback(async T=>{await u([T])},[u]),f=w.useCallback(async()=>{cr={},_c();try{await Se.unread.markAllRead()}catch{}},[]),g=w.useCallback(T=>{Em.add(T)},[]),h=w.useCallback(T=>{if(T.length!==0){for(const A of T)Em.delete(A),ug.delete(A);FS=Date.now()+150,Nm(T,{force:!0})}},[]),b=w.useCallback(T=>{h([T])},[h]);w.useEffect(()=>{if(!t)return;gu++,yX();let T=Yi;const A=()=>{a(M=>X2(M,cr)?M:{...cr}),T!==Yi&&(T=Yi,l(M=>X2(M,Yi)?M:{...Yi}))};return dg.add(A),a({...cr}),l({...Yi}),()=>{dg.delete(A),gu--,gu<=0&&(gu=0,vX())}},[t]);const y=w.useMemo(()=>Object.values(n).reduce((T,A)=>T+A,0),[n]),k=w.useCallback(T=>n[`session:${T}`]??0,[n]),C=w.useCallback(T=>n[`channel:${T}`]??0,[n]);return{counts:n,totalUnread:y,sessionAgentMap:i,getSessionUnread:k,getChannelUnread:C,markRead:m,markReadMany:u,markAllRead:f,refresh:c,setActiveKey:g,clearActiveKey:b,clearActiveKeys:h}}function rpe(e,t){return w.useMemo(()=>{const n=new Map;for(const[a,i]of Object.entries(t))if(a.startsWith("session:")){const l=a.slice(8),c=e[l];c&&n.set(c,(n.get(c)??0)+i)}return n},[e,t])}function wX(e){return e.startsWith("channel:dm:a2a:")}function kX(e,t){let n=0;for(const[a,i]of Object.entries(e))if(a.startsWith("session:")){const l=a.slice(8);t[l]&&(n+=i)}else if(a.startsWith("channel:")){if(wX(a))continue;n+=i}return n}const SX=6,CX=56;function AX({currentPage:e,onNavigate:t}){const{t:n}=ut("nav"),[a,i]=w.useState(ep);w.useEffect(()=>gS(i),[]);const[l,c]=w.useState(!1),u=w.useRef(!1),m=w.useCallback(b=>{u.current!==b&&(u.current=b,c(b))},[]);w.useEffect(()=>{let b=window.scrollY,y=0;const k=()=>{y||(y=requestAnimationFrame(()=>{y=0;const C=window.scrollY,T=C-b;if(b=C,C<=CX){m(!1);return}T>SX?m(!0):T<-6&&m(!1)}))};return window.addEventListener("scroll",k,{passive:!0}),()=>{window.removeEventListener("scroll",k),y&&cancelAnimationFrame(y)}},[m]),w.useEffect(()=>{m(!1)},[e,m]);const{counts:f,sessionAgentMap:g}=xX({enabled:!0}),h=w.useMemo(()=>kX(f,g),[f,g]);return o.jsx("nav",{"data-mobile-bottom-nav":!0,className:`fixed bottom-0 left-0 right-0 z-50 bg-surface-secondary flex items-stretch h-14 safe-area-bottom transition-transform duration-300 ease-out will-change-transform ${l?"translate-y-[calc(100%+1px)]":"translate-y-0"}`,children:KW.map(b=>{const y=b.group.includes(e),k=b.id===ce.HOME,C=b.id===ce.TEAM;return o.jsxs("button",{onClick:()=>t(b.id),className:`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${y?"text-fg-primary":"text-fg-tertiary active:text-fg-secondary"}`,children:[o.jsxs("div",{className:"relative",children:[o.jsx("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:y?2:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:o.jsx("path",{d:Xm[b.id]})}),k&&a>0&&o.jsx("span",{className:"absolute -top-1.5 -right-2 min-w-[16px] h-4 px-1 flex items-center justify-center bg-red-500 text-white text-[9px] font-bold rounded-full leading-none",children:a>99?"99+":a}),C&&h>0&&o.jsx("span",{className:"absolute -top-1.5 -right-2 min-w-[16px] h-4 px-1 flex items-center justify-center bg-red-500 text-white text-[9px] font-bold rounded-full leading-none",children:h>99?"99+":h})]}),o.jsx("span",{className:`text-[10px] leading-tight ${y?"font-semibold":""}`,children:n(b.id)})]},b.id)})})}const Mm=new Map;function As(e,t){Mm.has(e)||Mm.set(e,t().catch(()=>{}))}function Ls(e){const t=Mm.get(e);return Mm.delete(e),t}const La={builderArtifacts:"builder.artifacts",builderAgents:"builder.agents",builderHubMyItems:"builder.hubMyItems",builderInstalled:"builder.installed",hubAgents:"hub.agents",hubTeams:"hub.teams",hubSkills:"hub.skills"};function Z2(e){const t=[],n=String(e||"");let a=n.indexOf(","),i=0,l=!1;for(;!l;){a===-1&&(a=n.length,l=!0);const c=n.slice(i,a).trim();(c||!l)&&t.push(c),i=a+1,a=n.indexOf(",",i)}return t}function TX(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const EX=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,NX=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,MX={};function ew(e,t){return(MX.jsx?NX:EX).test(e)}const jX=/[ \t\n\f\r]/g;function RX(e){return typeof e=="object"?e.type==="text"?tw(e.value):!1:tw(e)}function tw(e){return e.replace(jX,"")===""}class qc{constructor(t,n,a){this.normal=n,this.property=t,a&&(this.space=a)}}qc.prototype.normal={};qc.prototype.property={};qc.prototype.space=void 0;function GS(e,t){const n={},a={};for(const i of e)Object.assign(n,i.property),Object.assign(a,i.normal);return new qc(n,a,t)}function Dc(e){return e.toLowerCase()}class za{constructor(t,n){this.attribute=n,this.property=t}}za.prototype.attribute="";za.prototype.booleanish=!1;za.prototype.boolean=!1;za.prototype.commaOrSpaceSeparated=!1;za.prototype.commaSeparated=!1;za.prototype.defined=!1;za.prototype.mustUseProperty=!1;za.prototype.number=!1;za.prototype.overloadedBoolean=!1;za.prototype.property="";za.prototype.spaceSeparated=!1;za.prototype.space=void 0;let _X=0;const qt=Fs(),Wn=Fs(),pg=Fs(),We=Fs(),Cn=Fs(),$o=Fs(),Wa=Fs();function Fs(){return 2**++_X}const fg=Object.freeze(Object.defineProperty({__proto__:null,boolean:qt,booleanish:Wn,commaOrSpaceSeparated:Wa,commaSeparated:$o,number:We,overloadedBoolean:pg,spaceSeparated:Cn},Symbol.toStringTag,{value:"Module"})),Wh=Object.keys(fg);class lb extends za{constructor(t,n,a,i){let l=-1;if(super(t,n),nw(this,"space",i),typeof a=="number")for(;++l<Wh.length;){const c=Wh[l];nw(this,Wh[l],(a&fg[c])===fg[c])}}}lb.prototype.defined=!0;function nw(e,t,n){n&&(e[t]=n)}function Zo(e){const t={},n={};for(const[a,i]of Object.entries(e.properties)){const l=new lb(a,e.transform(e.attributes||{},a),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(a)&&(l.mustUseProperty=!0),t[a]=l,n[Dc(a)]=a,n[Dc(l.attribute)]=a}return new qc(t,n,e.space)}const KS=Zo({properties:{ariaActiveDescendant:null,ariaAtomic:Wn,ariaAutoComplete:null,ariaBusy:Wn,ariaChecked:Wn,ariaColCount:We,ariaColIndex:We,ariaColSpan:We,ariaControls:Cn,ariaCurrent:null,ariaDescribedBy:Cn,ariaDetails:null,ariaDisabled:Wn,ariaDropEffect:Cn,ariaErrorMessage:null,ariaExpanded:Wn,ariaFlowTo:Cn,ariaGrabbed:Wn,ariaHasPopup:null,ariaHidden:Wn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Cn,ariaLevel:We,ariaLive:null,ariaModal:Wn,ariaMultiLine:Wn,ariaMultiSelectable:Wn,ariaOrientation:null,ariaOwns:Cn,ariaPlaceholder:null,ariaPosInSet:We,ariaPressed:Wn,ariaReadOnly:Wn,ariaRelevant:null,ariaRequired:Wn,ariaRoleDescription:Cn,ariaRowCount:We,ariaRowIndex:We,ariaRowSpan:We,ariaSelected:Wn,ariaSetSize:We,ariaSort:null,ariaValueMax:We,ariaValueMin:We,ariaValueNow:We,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function VS(e,t){return t in e?e[t]:t}function WS(e,t){return VS(e,t.toLowerCase())}const DX=Zo({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:$o,acceptCharset:Cn,accessKey:Cn,action:null,allow:null,allowFullScreen:qt,allowPaymentRequest:qt,allowUserMedia:qt,alt:null,as:null,async:qt,autoCapitalize:null,autoComplete:Cn,autoFocus:qt,autoPlay:qt,blocking:Cn,capture:null,charSet:null,checked:qt,cite:null,className:Cn,cols:We,colSpan:null,content:null,contentEditable:Wn,controls:qt,controlsList:Cn,coords:We|$o,crossOrigin:null,data:null,dateTime:null,decoding:null,default:qt,defer:qt,dir:null,dirName:null,disabled:qt,download:pg,draggable:Wn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:qt,formTarget:null,headers:Cn,height:We,hidden:pg,high:We,href:null,hrefLang:null,htmlFor:Cn,httpEquiv:Cn,id:null,imageSizes:null,imageSrcSet:null,inert:qt,inputMode:null,integrity:null,is:null,isMap:qt,itemId:null,itemProp:Cn,itemRef:Cn,itemScope:qt,itemType:Cn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:qt,low:We,manifest:null,max:null,maxLength:We,media:null,method:null,min:null,minLength:We,multiple:qt,muted:qt,name:null,nonce:null,noModule:qt,noValidate:qt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:qt,optimum:We,pattern:null,ping:Cn,placeholder:null,playsInline:qt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:qt,referrerPolicy:null,rel:Cn,required:qt,reversed:qt,rows:We,rowSpan:We,sandbox:Cn,scope:null,scoped:qt,seamless:qt,selected:qt,shadowRootClonable:qt,shadowRootDelegatesFocus:qt,shadowRootMode:null,shape:null,size:We,sizes:null,slot:null,span:We,spellCheck:Wn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:We,step:null,style:null,tabIndex:We,target:null,title:null,translate:null,type:null,typeMustMatch:qt,useMap:null,value:Wn,width:We,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Cn,axis:null,background:null,bgColor:null,border:We,borderColor:null,bottomMargin:We,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:qt,declare:qt,event:null,face:null,frame:null,frameBorder:null,hSpace:We,leftMargin:We,link:null,longDesc:null,lowSrc:null,marginHeight:We,marginWidth:We,noResize:qt,noHref:qt,noShade:qt,noWrap:qt,object:null,profile:null,prompt:null,rev:null,rightMargin:We,rules:null,scheme:null,scrolling:Wn,standby:null,summary:null,text:null,topMargin:We,valueType:null,version:null,vAlign:null,vLink:null,vSpace:We,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:qt,disableRemotePlayback:qt,prefix:null,property:null,results:We,security:null,unselectable:null},space:"html",transform:WS}),IX=Zo({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Wa,accentHeight:We,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:We,amplitude:We,arabicForm:null,ascent:We,attributeName:null,attributeType:null,azimuth:We,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:We,by:null,calcMode:null,capHeight:We,className:Cn,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:We,diffuseConstant:We,direction:null,display:null,dur:null,divisor:We,dominantBaseline:null,download:qt,dx:null,dy:null,edgeMode:null,editable:null,elevation:We,enableBackground:null,end:null,event:null,exponent:We,externalResourcesRequired:null,fill:null,fillOpacity:We,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:$o,g2:$o,glyphName:$o,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:We,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:We,horizOriginX:We,horizOriginY:We,id:null,ideographic:We,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:We,k:We,k1:We,k2:We,k3:We,k4:We,kernelMatrix:Wa,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:We,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:We,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:We,overlineThickness:We,paintOrder:null,panose1:null,path:null,pathLength:We,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Cn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:We,pointsAtY:We,pointsAtZ:We,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Wa,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Wa,rev:Wa,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Wa,requiredFeatures:Wa,requiredFonts:Wa,requiredFormats:Wa,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:We,specularExponent:We,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:We,strikethroughThickness:We,string:null,stroke:null,strokeDashArray:Wa,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:We,strokeOpacity:We,strokeWidth:null,style:null,surfaceScale:We,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Wa,tabIndex:We,tableValues:null,target:null,targetX:We,targetY:We,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Wa,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:We,underlineThickness:We,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:We,values:null,vAlphabetic:We,vMathematical:We,vectorEffect:null,vHanging:We,vIdeographic:We,version:null,vertAdvY:We,vertOriginX:We,vertOriginY:We,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:We,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:VS}),YS=Zo({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),QS=Zo({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:WS}),JS=Zo({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),LX={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},PX=/[A-Z]/g,aw=/-[a-z]/g,OX=/^data[-\w.:]+$/i;function XS(e,t){const n=Dc(t);let a=t,i=za;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&OX.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(aw,BX);a="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!aw.test(l)){let c=l.replace(PX,HX);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}i=lb}return new i(a,t)}function HX(e){return"-"+e.toLowerCase()}function BX(e){return e.charAt(1).toUpperCase()}const ZS=GS([KS,DX,YS,QS,JS],"html"),np=GS([KS,IX,YS,QS,JS],"svg");function rw(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function zX(e){return e.join(" ").trim()}var Do={},Yh,iw;function qX(){if(iw)return Yh;iw=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,u=/^\s+|\s+$/g,m=`
|
|
520
|
+
`);C=I.pop()??"";for(const B of I){const G=B.trim();if(G.startsWith("data: "))try{const j=JSON.parse(G.slice(6)),O=j.type;if(O==="snapshot"){const F=j.segments??[],Y=typeof j.content=="string"?j.content:"";u=Y,F.length&&(f=F),n.onSnapshot?.({content:Y,segments:F})}else if(O==="text_delta"&&typeof j.text=="string")u+=j.text,n.onChunk?.(j.text);else if(O==="thinking_delta"&&typeof j.thinking=="string")f2(n,j.thinking);else if(O==="done"){u=j.content||u,typeof j.sessionId=="string"&&(m=j.sessionId),typeof j.messageId=="string"&&(g=j.messageId);const F=j.segments;F&&(f=F),T=!0,l({content:u,sessionId:m,segments:f,messageId:g,attached:!0,terminal:!0}),y.cancel().catch(()=>{}),h?.stop();return}else if(O==="error"){c(new Error(j.message??j.error??"Stream error")),y.cancel().catch(()=>{}),h?.stop();return}else O==="thinking_commit"&&typeof j.thinking=="string"?n.onCommit?.({type:"thinking_commit",content:j.thinking,createdAt:j.createdAt??new Date().toISOString()}):O==="text_commit"&&typeof j.text=="string"?n.onCommit?.({type:"text_commit",content:j.text,createdAt:j.createdAt??new Date().toISOString()}):O==="agent_tool"&&j.tool&&j.phase?j.phase==="start"?n.onActivity?.({tool:j.tool,phase:"start",arguments:j.arguments}):j.phase==="end"&&n.onActivity?.({tool:j.tool,phase:"end",success:j.success,arguments:j.arguments,result:j.result,error:j.error,durationMs:j.durationMs}):O==="subagent_progress"&&j.tool?n.onActivity?.({tool:j.tool,phase:"subagent_progress",subagentEvent:j.subagentEvent}):O==="heartbeat"&&n.onActivity?.({tool:"",phase:"heartbeat"})}catch{}}}h?.stop(),l({content:u,sessionId:m,segments:f,messageId:g,attached:!0,terminal:T})}catch(b){h?.stop(),c(b)}})},channels:{getMessages:(e,t=30,n)=>K(`/channels/${encodeURIComponent(e)}/messages?limit=${t}${n?`&before=${n}`:""}`),sendMessage:(e,t)=>K(`/channels/${encodeURIComponent(e)}/messages`,{method:"POST",body:JSON.stringify(t)})},governance:{getSystemStatus:()=>K("/system/status"),emergencyStop:e=>K("/system/emergency-stop",{method:"POST",body:JSON.stringify({reason:e})}),getAnnouncements:()=>K("/system/announcements"),createAnnouncement:e=>K("/system/announcements",{method:"POST",body:JSON.stringify(e)}),getPolicy:()=>K("/governance/policy"),setPolicy:e=>K("/governance/policy",{method:"PUT",body:JSON.stringify(e)})},approvals:{list:(e,t)=>{const n=new URLSearchParams;e&&n.set("status",e),t?.limit!==void 0&&n.set("limit",String(t.limit)),t?.offset!==void 0&&n.set("offset",String(t.offset));const a=n.toString();return K(`/approvals${a?`?${a}`:""}`)},respond:(e,t,n,a,i,l)=>K(`/approvals/${e}`,{method:"POST",body:JSON.stringify({approved:t,respondedBy:n,comment:a,selectedOption:i,answers:l})})},notifications:{list:(e,t,n)=>{const a=new URLSearchParams;return e&&a.set("userId",e),t&&a.set("unread","true"),n?.type&&a.set("type",n.type),n?.limit&&a.set("limit",String(n.limit)),n?.offset&&a.set("offset",String(n.offset)),K(`/notifications?${a}`)},create:e=>K("/notifications",{method:"POST",body:JSON.stringify(e)}),markRead:e=>K(`/notifications/${e}`,{method:"POST"}),markAllRead:e=>K("/notifications/mark-all-read",{method:"POST",body:JSON.stringify({userId:e})})},unread:{getCounts:()=>K("/unread"),markRead:(e,t,n)=>K("/unread/mark-read",{method:"POST",body:JSON.stringify({conversationKey:e,lastReadAt:t,lastReadId:n})}),markReadBatch:e=>K("/unread/mark-read-batch",{method:"POST",body:JSON.stringify({items:e})}),markAllRead:()=>K("/unread/mark-all-read",{method:"POST"})},messages:{search:(e,t)=>{const n=new URLSearchParams({q:e});return t?.scope&&n.set("scope",t.scope),t?.channel&&n.set("channel",t.channel),t?.limit&&n.set("limit",String(t.limit)),K(`/messages/search?${n}`)}},activity:{list:e=>{const t=new URLSearchParams;e?.limit&&t.set("limit",String(e.limit)),e?.type&&t.set("type",e.type);const n=t.toString();return K(`/activity${n?`?${n}`:""}`)}},projects:{list:e=>{const t=e?`?orgId=${e}`:"";return K(`/projects${t}`)},get:e=>K(`/projects/${e}`),create:e=>K("/projects",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>K(`/projects/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>K(`/projects/${e}`,{method:"DELETE"}),syncKnowledge:(e,t)=>K(`/projects/${e}/knowledge/sync`,{method:"POST",body:JSON.stringify({knowledgeRoots:t})})},knowledge:{search:(e,t,n)=>{const a=new URLSearchParams;return e&&a.set("query",e),t&&a.set("scope",t),n&&a.set("category",n),K(`/knowledge/search?${a}`)},contribute:e=>K("/knowledge",{method:"POST",body:JSON.stringify(e)}),flagOutdated:(e,t)=>K(`/knowledge/${e}/flag-outdated`,{method:"POST",body:JSON.stringify({reason:t})}),verify:e=>K(`/knowledge/${e}/verify`,{method:"POST",body:JSON.stringify({verifiedBy:"human"})}),remove:e=>K(`/knowledge/${e}`,{method:"DELETE"})},deliverables:{search:e=>{const t=new URLSearchParams;return e?.q&&t.set("q",e.q),e?.projectId&&t.set("projectId",e.projectId),e?.agentId&&t.set("agentId",e.agentId),e?.taskId&&t.set("taskId",e.taskId),e?.type&&t.set("type",e.type),e?.status&&t.set("status",e.status),e?.artifactType&&t.set("artifactType",e.artifactType),e?.source&&t.set("source",e.source),e?.offset&&t.set("offset",String(e.offset)),e?.limit&&t.set("limit",String(e.limit)),K(`/deliverables?${t}`)},get:e=>K(`/deliverables/${e}`).then(t=>({...t,deliverable:gY(t.deliverable)})),create:e=>K("/deliverables",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>K(`/deliverables/${e}`,{method:"PUT",body:JSON.stringify(t)}),remove:e=>K(`/deliverables/${e}`,{method:"DELETE"}),verify:e=>K(`/deliverables/${e}`,{method:"PUT",body:JSON.stringify({status:"verified"})}),checkHealth:e=>{const t=new URLSearchParams;return e&&t.set("agentId",e),K(`/deliverables/health?${t}`)}},codeReviews:{list:(e,t=20)=>{const n=new URLSearchParams;return e&&n.set("taskId",e),n.set("limit",String(t)),K(`/reviews?${n}`)},get:e=>K(`/reviews/${e}`),run:e=>K("/reviews",{method:"POST",body:JSON.stringify(e)})},reports:{list:()=>K("/reports"),get:e=>K(`/reports/${e}`),generate:e=>K("/reports/generate",{method:"POST",body:JSON.stringify(e)}),approvePlan:(e,t)=>K(`/reports/${e}/plan/approve`,{method:"POST",body:JSON.stringify(t)}),rejectPlan:(e,t)=>K(`/reports/${e}/plan/reject`,{method:"POST",body:JSON.stringify(t)}),addFeedback:(e,t)=>K(`/reports/${e}/feedback`,{method:"POST",body:JSON.stringify(t)}),getFeedback:e=>K(`/reports/${e}/feedback`)},executionLogs:{get:(e,t)=>K(`/execution-logs?sourceType=${encodeURIComponent(e)}&sourceId=${encodeURIComponent(t)}`)},groupChats:{list:()=>K("/group-chats"),create:e=>K("/group-chats",{method:"POST",body:JSON.stringify(e)}),getById:e=>K(`/group-chats/${e}`),update:(e,t)=>K(`/group-chats/${e}`,{method:"PATCH",body:JSON.stringify(t)}),delete:e=>K(`/group-chats/${e}`,{method:"DELETE"}),addMember:(e,t,n,a)=>K(`/group-chats/${e}/members`,{method:"POST",body:JSON.stringify({memberId:t,memberType:n,memberName:a})}),removeMember:(e,t)=>K(`/group-chats/${e}/members/${t}`,{method:"DELETE"})},uploads:{upload:(e,t)=>K("/uploads",{method:"POST",body:JSON.stringify({files:e,prefix:t})})},hubOrgs:{mine:()=>Gt("/orgs/mine"),get:e=>Gt(`/orgs/${e}`),update:(e,t)=>Gt(`/orgs/${e}`,{method:"PUT",body:JSON.stringify(t)}),create:e=>Gt("/orgs",{method:"POST",body:JSON.stringify({name:e})}),members:e=>Gt(`/orgs/${e}/members`),invite:(e,t)=>Gt(`/orgs/${e}/members`,{method:"POST",body:JSON.stringify(t)}),removeMember:(e,t)=>Gt(`/orgs/${e}/members/${t}`,{method:"DELETE"}),updateMemberRole:(e,t,n)=>Gt(`/orgs/${e}/members/${t}`,{method:"PATCH",body:JSON.stringify({role:n})}),invitations:()=>Gt("/orgs/invitations"),acceptInvitation:e=>Gt(`/orgs/${e}/members/accept`,{method:"POST"}),leave:e=>Gt(`/orgs/${e}/leave`,{method:"POST"})},workflows:{list:e=>K(`/teams/${e}/workflows`),get:(e,t)=>K(`/teams/${e}/workflows/${encodeURIComponent(t)}`),create:(e,t,n)=>K(`/teams/${e}/workflows`,{method:"POST",body:JSON.stringify({name:t,yaml:n})}),update:(e,t,n)=>K(`/teams/${e}/workflows/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({yaml:n})}),remove:(e,t)=>K(`/teams/${e}/workflows/${encodeURIComponent(t)}`,{method:"DELETE"}),roles:(e,t)=>K(`/teams/${e}/workflows/${encodeURIComponent(t)}/roles`),listRuns:(e,t,n)=>K(`/teams/${e}/workflows/${encodeURIComponent(t)}/runs${n?`?limit=${n}`:""}`),startRun:(e,t,n,a,i)=>K(`/teams/${e}/workflows/${encodeURIComponent(t)}/runs`,{method:"POST",body:JSON.stringify({projectId:n,params:a,roleMapping:i})}),getRun:e=>K(`/workflow-runs/${e}`),cancelRun:e=>K(`/workflow-runs/${e}`,{method:"DELETE"}),pauseRun:e=>K(`/workflow-runs/${e}/pause`,{method:"POST"}),resumeRun:e=>K(`/workflow-runs/${e}/resume`,{method:"POST"})}};function Kme(e){return{id:e.id,sourceType:"task",sourceId:e.taskId,agentId:e.agentId,seq:e.seq,type:e.type,content:e.content,metadata:e.metadata,executionRound:e.executionRound,createdAt:e.createdAt}}function Vme(e,t,n){return e.type==="llm_request"?null:{id:`alog_${t}_${e.seq}`,sourceType:"activity",sourceId:t,agentId:n,seq:e.seq,type:e.type,content:e.content,metadata:e.metadata,createdAt:e.createdAt}}class hc{ws=null;handlers=new Map;reconnectTimer=null;heartbeatTimer=null;intentionalClose=!1;currentUserId;reconnectAttempts=0;lastEventTimestamp=null;static BACKOFF_BASE=1e3;static BACKOFF_MAX=3e4;static HEARTBEAT_INTERVAL=25e3;connect(t){if(t!==void 0&&(this.currentUserId=t),this.ws&&(this.ws.readyState===WebSocket.CONNECTING||this.ws.readyState===WebSocket.OPEN))if(t!==void 0&&this.ws.url&&!this.ws.url.includes(`userId=${t}`))this.ws.onclose=null,this.ws.close(),this.ws=null;else return;this.intentionalClose=!1;const n=window.location.protocol==="https:"?"wss:":"ws:",a=new URLSearchParams;this.currentUserId&&a.set("userId",this.currentUserId),this.lastEventTimestamp&&a.set("since",this.lastEventTimestamp);const i=a.toString(),l=`${n}//${window.location.host}/ws${i?`?${i}`:""}`,c=new WebSocket(l);this.ws=c,c.onopen=()=>{this.reconnectAttempts=0,this.startHeartbeat(c)},c.onmessage=u=>{if(this.ws===c)try{const m=JSON.parse(u.data);if(m.timestamp&&(this.lastEventTimestamp=m.timestamp),m.type==="pong")return;const f=this.handlers.get(m.type);if(f)for(const h of f)h(m);const g=this.handlers.get("*");if(g)for(const h of g)h(m)}catch{}},c.onclose=()=>{if(this.stopHeartbeat(),this.intentionalClose)return;const u=Math.min(hc.BACKOFF_BASE*Math.pow(2,this.reconnectAttempts),hc.BACKOFF_MAX);this.reconnectAttempts++,this.reconnectTimer=setTimeout(()=>this.connect(this.currentUserId),u)},c.onerror=()=>{c.close()}}startHeartbeat(t){this.stopHeartbeat(),this.heartbeatTimer=setInterval(()=>{t.readyState===WebSocket.OPEN&&t.send(JSON.stringify({type:"ping"}))},hc.HEARTBEAT_INTERVAL)}stopHeartbeat(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null)}disconnect(){this.intentionalClose=!0,this.stopHeartbeat(),this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.ws&&(this.ws.onclose=null,this.ws.close(),this.ws=null)}on(t,n){return this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t).add(n),()=>this.handlers.get(t)?.delete(n)}}const di=new hc;let Zm=typeof window<"u"?window.__MARKUS_HUB_URL__??"https://markus.global":"https://markus.global",Qu=null;async function eg(){if(!Tn())return null;try{const e=await Gt("/auth/me");if(e?.user?.id){const t=Tn();return ym(t,e.user),e.user}}catch{}return Oa()}async function aS(){if(!window.__MARKUS_PREVIEW__)try{const e=await K("/settings/hub");e.hubUrl&&(Zm=e.hubUrl)}catch{}}function DY(){return Qu||(Qu=aS().finally(()=>{})),Qu}window.__MARKUS_PREVIEW__||(Qu=aS().then(async()=>{const e=localStorage.getItem("markus_hub_token");if(e)K("/settings/hub-token",{method:"POST",body:JSON.stringify({token:e})}).catch(()=>{}),eg();else try{await Se.auth.me();const t=await K("/settings/hub-token");t.token&&(localStorage.setItem("markus_hub_token",t.token),await eg())}catch{}}).catch(()=>{}));const Mc="markus_hub_token",gm="markus_hub_user";function Tn(){return localStorage.getItem(Mc)}async function IY(){const e=Tn();if(e)return e;try{await Se.auth.me()}catch{return null}try{const t=await K("/settings/hub-token");if(t.token)return localStorage.setItem(Mc,t.token),eg(),t.token}catch{}return null}function Oa(){try{const e=localStorage.getItem(gm);return e?JSON.parse(e):null}catch{return null}}function bm(e,t){if(e.purchasedByCurrentUser||t?.has(e.id))return!0;const n=Oa();if(!n?.id)return!1;const a=e.author?.id??e.authorId;return!!a&&a===n.id}function Is(){localStorage.removeItem(Mc),localStorage.removeItem(gm),rS(null),window.dispatchEvent(new CustomEvent("markus:hub-auth"))}function ym(e,t){const n=localStorage.getItem(Mc),a=localStorage.getItem(gm),i=JSON.stringify(t);n===e&&a===i||(localStorage.setItem(Mc,e),localStorage.setItem(gm,i),rS(e),window.dispatchEvent(new CustomEvent("markus:hub-auth")))}function rS(e){K("/settings/hub-token",{method:"POST",body:JSON.stringify({token:e})}).catch(()=>{})}async function LY(e){e.openrouter?.key&&await K("/settings/subscription-key",{method:"POST",body:JSON.stringify({openrouter:e.openrouter})}).catch(()=>{})}async function ab(e){try{return await K(`/auth/hub-connect-status?session=${encodeURIComponent(e)}&_t=${Date.now()}`)}catch{return null}}async function rb(e){!e.token||!e.user||(ym(e.token,e.user),e.openrouter?.key&&await LY({openrouter:e.openrouter}),PY())}async function PY(){if(Tn())try{const{org:e}=await K("/settings/org"),t=e?.name?.trim();if(!t||t==="My Organization")return;const a=((await Gt("/orgs/mine")).orgs??[]).find(i=>i.role==="owner");if(!a||a.name===t)return;await Gt(`/orgs/${a.id}`,{method:"PUT",body:JSON.stringify({name:t})})}catch{}}function iS(){return window.markusDesktop}async function OY(e,t=12e4){const n=Date.now()+t;for(;Date.now()<n;){const a=await ab(e);if(a?.ready&&a.token&&a.user)return await rb(a),!0;await new Promise(i=>setTimeout(i,1200))}return!1}let Ju=null;iS()?.onDeepLinkAuth?.(e=>{Ju?.(e?.session??"")});let vm=null;function HY(){vm?.(),Ms=null}function BY(e,t,n){return new Promise((a,i)=>{let l=!1,c=!1;const u=(C,T)=>{l||(l=!0,vm=null,clearInterval(y),clearTimeout(k),window.removeEventListener("focus",g),document.removeEventListener("visibilitychange",h),Ju===f&&(Ju=null),C?(n.focusWindow?.(),a()):i(T))};vm=()=>u(!1,new Error("Hub login cancelled"));const m=async()=>{if(!(l||c)){c=!0;try{const C=await ab(e);C?.ready&&C.token&&C.user&&(await rb(C),u(!0))}finally{c=!1}}},f=C=>{(!C||C===e)&&m()};Ju=f;const g=()=>{m()},h=()=>{document.visibilityState==="visible"&&m()};window.addEventListener("focus",g),document.addEventListener("visibilitychange",h);let b=`${Zm}/auth/connect?session=${encodeURIComponent(e)}&redirect=${encodeURIComponent("markus://auth")}`;t&&(b+=`&method=${encodeURIComponent(t)}`),Promise.resolve(n.openExternal(b)).then(()=>{m()}).catch(C=>{u(!1,C instanceof Error?C:new Error("Failed to open browser"))});const y=setInterval(()=>{m()},1500),k=setTimeout(()=>u(!1,new Error("Hub login timed out")),5*6e4)})}function zY(e,t){return new Promise((n,a)=>{let i=`${Zm}/auth/connect?session=${encodeURIComponent(e)}`;t&&(i+=`&method=${encodeURIComponent(t)}`);const l=460,c=580,u=Math.round(window.screenX+(window.outerWidth-l)/2),m=Math.round(window.screenY+(window.outerHeight-c)/2),f=window.open(i,"markus_hub_auth",`popup=yes,width=${l},height=${c},left=${u},top=${m}`);if(!f){a(new Error("Popup blocked by browser. Please allow popups for this site."));return}let g=!1,h=null;const b=()=>{clearInterval(k),clearInterval(T),h&&clearInterval(h),document.removeEventListener("visibilitychange",C)},y=async()=>{if(g)return;const A=await ab(e);A?.ready&&A.token&&A.user&&(g=!0,await rb(A),b(),f?.close(),n())},k=setInterval(()=>{y()},1500),C=()=>{!g&&document.visibilityState==="visible"&&y()};document.addEventListener("visibilitychange",C);const T=setInterval(()=>{if(!g&&f?.closed){clearInterval(T);let A=0;h=setInterval(async()=>{if(g){clearInterval(h);return}A++,await y(),A>=5&&!g&&(g=!0,b(),Tn()?n():a(new Error("Hub login cancelled")))},1e3)}},500)})}let Ms=null;function Ia(e){const t=typeof e=="string"?{method:e}:e??{};if(t.force)vm?.(),Ms=null,(Tn()||Oa())&&Is();else if(Tn())return Promise.resolve();if(Ms)return Ms;const n=`cs_${Date.now()}_${Math.random().toString(36).slice(2,10)}`,a=iS(),i=(async()=>{await DY(),a?await BY(n,t.method,a):await zY(n,t.method)})();return Ms=i,i.catch(()=>{}).finally(()=>{Ms===i&&(Ms=null)}),i}async function Gt(e,t){const n=Tn(),a={"Content-Type":"application/json",...t?.headers};n&&(a.Authorization=`Bearer ${n}`);const i=await fetch(`${Rs}/hub${e}`,{...t,headers:a,credentials:"include"}),l=await i.json();if(i.status===401&&n&&Is(),!i.ok){const c=new Error(l.error??`Hub HTTP ${i.status}`);throw c.code=typeof l.code=="string"?l.code:void 0,c.retryAfterSeconds=typeof l.retryAfterSeconds=="number"?l.retryAfterSeconds:void 0,c.status=i.status,c}return l}async function sS(){if(!Tn())return!1;try{return await Gt("/user/plan"),!0}catch{return!1}}const at={getUrl:()=>Zm,isAuthenticated:()=>!!Tn(),getUser:Oa,logout:()=>{Is()},ensureAuth:Ia,validateSession:sS,login:async(e,t)=>{const n=await Gt("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:t})});return ym(n.token,n.user),n},register:async(e,t,n)=>{const a=await Gt("/auth/register",{method:"POST",body:JSON.stringify({username:e,email:t,password:n})});return ym(a.token,a.user),a},search:e=>{const t=new URLSearchParams;e?.type&&t.set("type",e.type),e?.subtype&&t.set("subtype",e.subtype),e?.q&&t.set("q",e.q),e?.category&&t.set("category",e.category),e?.sort&&t.set("sort",e.sort),e?.page&&t.set("page",String(e.page)),e?.limit&&t.set("limit",String(e.limit));const n=t.toString();return Gt(`/items${n?`?${n}`:""}`)},getItem:e=>Gt(`/items/${e}`),download:async e=>{await Ia();try{return await Gt(`/items/${e}/download`,{method:"POST"})}catch(t){if(!Tn())return await Ia(),Gt(`/items/${e}/download`,{method:"POST"});throw t}},publish:async e=>{await Ia();try{return await Gt("/items",{method:"POST",body:JSON.stringify(e)})}catch(t){if(!Tn())return await Ia(),Gt("/items",{method:"POST",body:JSON.stringify(e)});throw t}},uploadImage:async e=>{await Ia();try{const t=new FormData;t.append("file",e);const n=await fetch("/api/hub/upload",{method:"POST",credentials:"include",headers:{Authorization:`Bearer ${Tn()}`},body:t});return n.ok?await n.json():null}catch{return null}},uploadMediaBatch:async e=>{await Ia();try{const t=await fetch("/api/hub/deliverables/media",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Tn()}`},body:JSON.stringify({files:e})});return t.ok?await t.json():{files:[],errors:[{filename:"batch",error:`HTTP ${t.status}`}]}}catch(t){return{files:[],errors:[{filename:"batch",error:String(t)}]}}},publishViaProxy:async e=>{await Ia();try{return await Gt("/items",{method:"POST",body:JSON.stringify(e)})}catch(t){if(!Tn())return await Ia(),Gt("/items",{method:"POST",body:JSON.stringify(e)});throw t}},updateItem:async(e,t)=>(await Ia(),Gt(`/items/${e}`,{method:"PUT",body:JSON.stringify(t)})),myItems:async()=>Tn()?Gt("/items/mine"):{items:[]},browseItems:async e=>{const t=new URLSearchParams;e?.type&&t.set("type",e.type),e?.orgId&&t.set("orgId",e.orgId),e?.q&&t.set("q",e.q),e?.page&&t.set("page",String(e.page)),e?.limit&&t.set("limit",String(e.limit??50));const n=t.toString();return Gt(`/items${n?`?${n}`:""}`)},myOrgs:async()=>Tn()?Gt("/orgs/mine").then(e=>({memberships:(e.orgs??[]).map(t=>({id:t.id,name:t.name,slug:t.slug,role:t.role}))})):{memberships:[]},deleteItem:async e=>(await Ia(),Gt(`/items/${e}`,{method:"DELETE"})),purchases:{checkout:e=>Gt("/purchases/checkout",{method:"POST",body:JSON.stringify({itemId:e})}),payWithEarnings:e=>Gt("/purchases/pay-with-earnings",{method:"POST",body:JSON.stringify({itemId:e})}),mine:()=>Gt("/purchases/mine")},creator:{getBalance:()=>Gt("/creator/balance")},feedback:{create:e=>Gt("/feedback",{method:"POST",body:JSON.stringify(e)})},user:{plan:()=>Gt("/user/plan"),cuStats:(e=30,t="day")=>Gt(`/user/cu/stats?days=${e}&granularity=${t}`),claimFreeCreditsStatus:()=>Gt("/user/claim-free-credits"),claimFreeCredits:()=>Gt("/user/claim-free-credits",{method:"POST"}),referral:()=>Gt("/user/referral")}},qY=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;function oS(e){return typeof e=="string"&&e.length>=2&&e.length<=64&&qY.test(e)}function jc(e){const t=e.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-+|-+$/g,"");return oS(t)?t:null}function xm(e,t){const n=jc(e);if(n)return n;if(t){const i=jc(t);if(i)return i;if(oS(t))return t}let a=0;for(let i=0;i<e.length;i++)a=(a<<5)-a+e.charCodeAt(i)|0;return`pkg-${Math.abs(a).toString(36)}`}function $Y(e,t){if(e.blockedReason==="deps"||e.blockedReason==="hold"||e.blockedReason==="workflow")return e.blockedReason;const n=e.blockedBy??[];return n.length===0||t&&n.every(i=>t(i)?.status==="completed")?"hold":"deps"}let h2=null,ou=ce.HOME;const yt={setHandler(e){h2=e},navigate(e,t){t&&Object.entries(t).forEach(([n,a])=>localStorage.setItem(`markus_nav_${n}`,a)),h2?.(e,t),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:e,params:t}}))},setSettingsReturnPage(e){e!==ce.SETTINGS&&(ou=e)},getSettingsReturnPage(){return ou},leaveSettings(){const e=ou!==ce.SETTINGS?ou:ce.HOME;this.navigate(e)}};function lS(e){if(!e||e.status&&e.status!=="pending"||e.type!=="action"||Array.isArray(e.questions)&&e.questions.length>0)return!1;const t=e.details?.toolName;return typeof t=="string"&&t.length>0}function FY(e){return e.details?.agentId??e.agentId}function UY(e){const t=e.details??{};return[t.chatSessionId,t.sessionId].filter(n=>typeof n=="string"&&n.length>0)}function Wme(e,t){const n=e.filter(l=>lS(l)&&FY(l)===t.agentId);if(!t.sessionId)return n;const a=[],i=[];for(const l of n)(UY(l).includes(t.sessionId)?a:i).push(l);return[...a,...i]}function GY(e){return Array.isArray(e.questions)&&e.questions.length>0}function tg(e){if(!e)return null;try{const t=JSON.parse(e);return t&&typeof t=="object"?t:null}catch{return null}}function g2(e){const t={},n=e.split("?")[1];if(!n)return t;for(const[a,i]of new URLSearchParams(n).entries())t[a]=i;return t}function KY(e){if(e.actionType==="open_chat"||e.actionType==="navigate")return!0;const t=e.metadata??{};return!!(t.agentId||t.taskId||t.requirementId||t.projectId||t.channel||t.senderId||t.approvalId||t.sessionId)}function ng(e,t={}){if(GY(e)){if(t.onOpenApproval){t.onOpenApproval(e);return}const a=e.details?.sessionId,i={};e.agentId&&(i.agentId=e.agentId),a&&(i.sessionId=a),yt.navigate(ce.TEAM,Object.keys(i).length>0?i:void 0);return}const n=e.details;if(lS(e)&&e.agentId)return void yt.navigate(ce.TEAM,{agentId:e.agentId});if(n?.taskId)return void yt.navigate(ce.WORK,{openTask:n.taskId});if(n?.requirementId)return void yt.navigate(ce.WORK,{openRequirement:n.requirementId});if(e.agentId)return void yt.navigate(ce.TEAM,{agentId:e.agentId,preferMain:"1"});yt.navigate(ce.WORK)}function cS(e){const t=e.metadata??{},n=a=>typeof a=="string"&&a.length>0?a:void 0;if(e.actionType==="open_chat"){const a=n(t.taskId),i=n(t.requirementId);if(a)return{page:"WORK",params:{openTask:a}};if(i)return{page:"WORK",params:{openRequirement:i}};const l=tg(e.actionTarget),c=n(l?.agentId);if(c){const u={agentId:c},m=n(l?.sessionId);return m&&(u.sessionId=m),{page:"TEAM",params:u}}}if(e.actionType==="navigate"){const a=tg(e.actionTarget),i=n(a?.path);if(i){if(i.startsWith("/team"))return{page:"TEAM",params:g2(i)};if(i.startsWith("/work"))return{page:"WORK",params:g2(i)};if(i.startsWith("/approvals/"))return null}}switch(e.type){case"approval_request":return null;case"task_completed":case"task_created":case"task_review":case"task_failed":{const a=n(t.taskId);return{page:"WORK",params:a?{openTask:a}:{}}}case"requirement_created":case"requirement_decision":{const a=n(t.requirementId);return{page:"WORK",params:a?{openRequirement:a}:{}}}case"agent_report":case"system":{if(t.creditExhausted||t.templateUpdates)return null;const a=n(t.agentId),i={};a&&(i.agentId=a);const l=n(t.sessionId);return l?i.sessionId=l:a&&(i.preferMain="1"),{page:"TEAM",params:i}}case"direct_message":{const a=n(t.senderId);return{page:"TEAM",params:a?{dm:a}:{}}}case"group_message":{const a=n(t.channel);return{page:"TEAM",params:a?{channel:a}:{}}}default:{const a=n(t.taskId);if(a)return{page:"WORK",params:{openTask:a}};const i=n(t.requirementId);if(i)return{page:"WORK",params:{openRequirement:i}};const l=n(t.projectId);if(l)return{page:"WORK",params:{projectId:l}};const c=n(t.agentId);return c?{page:"TEAM",params:{agentId:c}}:{page:"WORK",params:{}}}}}function VY(e,t={}){const n=cS(e);if(n){const l=Object.keys(n.params).length>0?n.params:void 0;return void yt.navigate(n.page==="WORK"?ce.WORK:ce.TEAM,l)}const a=e.metadata??{},i=l=>typeof l=="string"&&l.length>0?l:void 0;if(e.actionType==="navigate"){const l=tg(e.actionTarget),c=i(l?.path);if(c?.startsWith("/approvals/")){const u=c.split("?")[0].split("/")[2],m=u?t.approvals?.find(f=>f.id===u):void 0;if(m)return ng(m,t)}}if(e.type==="approval_request"){const l=i(a.approvalId),c=l?t.approvals?.find(g=>g.id===l):void 0;if(c)return ng(c,t);const u=i(a.taskId);if(u)return void yt.navigate(ce.WORK,{openTask:u});const m=i(a.requirementId);if(m)return void yt.navigate(ce.WORK,{openRequirement:m});const f=i(a.agentId);return f?void yt.navigate(ce.TEAM,{agentId:f,preferMain:"1"}):void yt.navigate(ce.WORK)}if(a.creditExhausted){t.onCreditExhausted?.();return}if(a.templateUpdates){t.onTemplateUpdates?.();return}yt.navigate(ce.WORK)}const WY={answer:!0,approve:!0,unblock:!0,resolve_failure:!1,review:!0,read:!1},YY={answer:0,approve:1,unblock:2,resolve_failure:3,review:5,read:6},QY=4;function b2(e,t,n){return`${e}:${t}:${n}`}const dS="1970-01-01T00:00:00.000Z",JY={urgent:0,high:1,medium:2,low:3};function y2(e){return JY[(e??"").toLowerCase()]??4}function Zl(e){return e&&e.length>0?e:dS}function jo(e,t){return e==="approve"&&t==="requirement"?QY:YY[e]}function XY(e){return Array.isArray(e.questions)&&e.questions.length>0}function ZY(){return"read"}function eQ(e,t){const n=t.params.openTask;if(n)return{kind:"task",id:n};const a=t.params.openRequirement;return a?{kind:"requirement",id:a}:{kind:"notification",id:e.id}}function tQ(e,t,n={}){const{lastSeenAt:a=null,includeUnread:i=!0}=n,l=[],c=[],u=b=>e.tasks.find(y=>y.id===b)?.title??b,m=b=>e.requirements.find(y=>y.id===b)?.title??b;for(const b of e.approvals){if(b.status!=="pending")continue;const y=b.details??{},k={};let C="TEAM",T="approval",A=b.id;y.taskId?(C="WORK",k.openTask=y.taskId,T="task",A=y.taskId):y.requirementId&&(C="WORK",k.openRequirement=y.requirementId,T="requirement",A=y.requirementId),b.agentId&&(k.agentId=b.agentId),C==="TEAM"&&(k.preferMain="1");const M=C==="WORK"?{page:C,params:k}:b.agentId?{page:C,params:k}:null;if(!M){c.push({source:"approval",ref:b.id,reason:"no_action"});continue}l.push({subjectKind:T,subjectId:A,need:XY(b)?"answer":"approve",title:b.title,priority:"none",waitingSince:Zl(b.requestedAt),waitingBasis:"requested",action:M,source:{kind:"approval",ref:b.id},...b.agentName?{meta:b.agentName}:{}})}for(const b of e.requirements)b.status==="pending"&&l.push({subjectKind:"requirement",subjectId:b.id,need:"approve",title:b.title,priority:b.priority??"none",waitingSince:Zl(b.createdAt),waitingBasis:"created",action:{page:"WORK",params:{openRequirement:b.id}},source:{kind:"fsm",ref:b.id}});for(const b of e.tasks){let y=null,k="approximate",C=Zl(b.statusChangedAt??b.updatedAt??b.createdAt);b.status==="review"&&b.reviewerType==="human"?(y="review",k=b.statusChangedAt?"status":"approximate"):b.status==="blocked"&&t.resolveBlockedReason(b)==="hold"?(y="unblock",k=b.statusChangedAt?"status":"approximate"):b.status==="failed"&&(y="resolve_failure",k=b.statusChangedAt?"status":"approximate"),y&&(C=Zl(b.statusChangedAt??b.updatedAt??b.createdAt),l.push({subjectKind:"task",subjectId:b.id,need:y,title:b.title,priority:b.priority??"none",waitingSince:C,waitingBasis:k,action:{page:"WORK",params:{openTask:b.id}},source:{kind:"fsm",ref:b.id}}))}for(const b of e.stages??[]){let y=null;if(b.stage==="waiting_human"?y="answer":b.stage==="failed"&&(y="resolve_failure"),!y)continue;const k=b.subjectKind==="task"?{page:"WORK",params:{openTask:b.subjectId}}:{page:"WORK",params:{openRequirement:b.subjectId}};l.push({subjectKind:b.subjectKind,subjectId:b.subjectId,need:y,title:b.subjectKind==="task"?u(b.subjectId):m(b.subjectId),priority:"none",waitingSince:dS,waitingBasis:"approximate",action:k,source:{kind:"stage",ref:b.subjectId}})}if(i)for(const b of e.notifications){if(b.read)continue;const y=t.resolveNotificationTarget(b);if(!y){c.push({source:"notification",ref:b.id,reason:"no_action"});continue}const k=eQ(b,y);l.push({subjectKind:k.kind,subjectId:k.id,need:ZY(),title:t.renderNotificationTitle?t.renderNotificationTitle(b):b.title,priority:b.priority??"none",waitingSince:Zl(b.createdAt),waitingBasis:"created",action:y,source:{kind:"notification",ref:b.id},noticeId:b.id,alwaysNew:!0})}const f=new Map;for(const b of l){const y=b2(b.subjectKind,b.subjectId,b.need),k=f.get(y);k?k.push(b):f.set(y,[b])}const g=new Map;for(const b of f.values()){const y=b[0],k=`${y.subjectKind}:${y.subjectId}`,C=g.get(k);C?C.members.push(...b):g.set(k,{subjectKind:y.subjectKind,subjectId:y.subjectId,members:[...b]})}const h=[];for(const b of g.values()){const y=[...b.members].sort((G,j)=>jo(G.need,G.subjectKind)-jo(j.need,j.subjectKind)),k=y[0],C=[],T=[],A=[];let M=k.waitingSince,I=!1,B=k.meta;for(const G of y)C.some(j=>j.kind===G.source.kind&&j.ref===G.source.ref)||C.push(G.source),G.noticeId&&!T.includes(G.noticeId)&&T.push(G.noticeId),G.need!==k.need&&!A.includes(G.need)&&A.push(G.need),G.waitingSince<M&&(M=G.waitingSince),WY[G.need]&&(I=!0),!B&&G.meta&&(B=G.meta);h.push({key:b2(k.subjectKind,k.subjectId,k.need),subjectKind:k.subjectKind,subjectId:k.subjectId,needKind:k.need,mergedNeeds:A.sort((G,j)=>jo(G,k.subjectKind)-jo(j,k.subjectKind)),title:k.title,priority:k.priority,waitingSince:M,waitingBasis:M===k.waitingSince?k.waitingBasis:"approximate",action:k.action,blocking:I,sources:C,anchor:k.source,noticeIds:T,isNew:k.alwaysNew===!0?!0:a!==null&&k.waitingSince>a,...B?{meta:B}:{}})}return h.sort((b,y)=>{if(b.waitingSince!==y.waitingSince)return b.waitingSince<y.waitingSince?-1:1;const k=y2(b.priority)-y2(y.priority);if(k!==0)return k;const C=jo(b.needKind,b.subjectKind)-jo(y.needKind,y.subjectKind);return C!==0?C:b.key<y.key?-1:b.key>y.key?1:0}),{items:h,dropped:c}}function v2(e){return Array.isArray(e?.questions)&&e.questions.length>0}function ec(e){return typeof e=="string"&&e.length>0?e:void 0}function nQ(e,t){if(e.type==="approval_request"){const u=e.metadata??{},m=ec(u.approvalId),g=(m?t?.find(y=>y.id===m):void 0)?.details??{},h=ec(g.taskId);if(h)return{page:"WORK",params:{openTask:h}};const b=ec(g.requirementId);if(b)return{page:"WORK",params:{openRequirement:b}}}const n=cS(e);if(n)return n;const a=e.metadata??{},i=ec(a.agentId),l=ec(a.sessionId),c={};return i&&(c.agentId=i),l?c.sessionId=l:i&&(c.preferMain="1"),Object.keys(c).length>0?{page:"TEAM",params:c}:null}function aQ(e){switch(e.needKind){case"answer":return"agent_question";case"approve":return e.subjectKind==="requirement"?"requirement_approval":"approval_request";case"review":return"task_review";case"unblock":return"blocked_hold";case"resolve_failure":return"task_failed";case"read":return"unread_message"}}function rQ(e){switch(e.needKind){case"answer":case"approve":return e.anchor.kind==="approval"?`approval:${e.anchor.ref}`:e.subjectKind==="requirement"?`requirement:${e.subjectId}`:`approval:${e.anchor.ref}`;case"review":return`task:${e.subjectId}`;case"unblock":return`blocked:${e.subjectId}`;case"resolve_failure":return`failed:${e.subjectId}`;case"read":return`notice:${e.anchor.ref}`}}function uS(e){const{tasks:t,requirements:n,approvals:a,notifications:i,taskById:l,lastSeenAt:c=null,includeUnread:u=!0,notifyTitle:m}=e,f={approvals:a,notifications:i,tasks:t,requirements:n},g={resolveNotificationTarget:y=>nQ(y,a),resolveBlockedReason:y=>$Y(y,k=>l?.(k)),...m?{renderNotificationTitle:y=>m(y)}:{}},{items:h}=tQ(f,g,{lastSeenAt:c,includeUnread:u}),b=new Map(i.map(y=>[y.id,y]));return h.map(y=>{const k=y.noticeIds.map(C=>b.get(C)).filter(C=>!!C);return{id:rQ(y),kind:aQ(y),title:y.title,priority:y.priority,waitingSince:y.waitingSince,waitingBasis:y.waitingBasis,target:y.action,isNew:y.isNew,...y.meta?{meta:y.meta}:{},...k.length>0?{notices:k}:{}}})}function iQ(e){return e.filter(t=>t.kind!=="unread_message").length}function mS(e,t=Date.now()){const n=Date.parse(e.waitingSince);if(!Number.isFinite(n))return"—";const a=Math.max(0,t-n),i=Math.floor(a/6e4),l=Math.floor(i/60),c=Math.floor(l/24);let u;return i<1?u=tn.t("common:duration.lessThan1Minute"):i<60?u=tn.t("common:duration.minutes",{count:i}):l<24?u=tn.t("common:duration.hours",{count:l}):c<30?u=l%24>0?tn.t("common:duration.daysHours",{days:c,hours:l%24}):tn.t("common:duration.days",{count:c}):u=tn.t("common:duration.moreThan30Days"),e.waitingBasis==="approximate"?tn.t("common:duration.approximate",{duration:u}):u}const pS="markus_attention_count",wm="markus:attention-count",fS="markus_attention_last_seen";function sQ(){try{return localStorage.getItem(fS)}catch{return null}}function oQ(e){try{localStorage.setItem(fS,e)}catch{}}function lQ(e){try{localStorage.setItem(pS,String(e))}catch{}window.dispatchEvent(new CustomEvent(wm,{detail:{count:e}}))}function ep(){return x2(pS)+x2(hS)}const hS="markus_unread_count";function x2(e){try{const t=localStorage.getItem(e),n=t===null?0:Number(t);return Number.isFinite(n)&&n>0?n:0}catch{return 0}}function cQ(e){try{localStorage.setItem(hS,String(Math.max(0,e)))}catch{}window.dispatchEvent(new CustomEvent(wm,{detail:{count:ep()}}))}function gS(e){const t=n=>{const a=n.detail;e(typeof a?.count=="number"?a.count:ep())};return window.addEventListener(wm,t),()=>window.removeEventListener(wm,t)}const dQ=1e3,uQ=6e4;function mQ(e){w.useEffect(()=>{if(!e)return;let t=!0,n;const a=()=>{(async()=>{try{const[c,u,m,f]=await Promise.all([Se.tasks.boardSummary(),Se.requirements.list({lean:!0}),Se.approvals.list(),Se.notifications.list(e,!0,{limit:20})]);if(!t)return;const g=Object.values(c.board).flat(),h=new Map(g.map(y=>[y.id,y])),b=uS({tasks:g,requirements:u.requirements,approvals:m.approvals??[],notifications:f.notifications??[],taskById:y=>h.get(y),lastSeenAt:null});lQ(iQ(b)),cQ(f.unreadCount??0)}catch{}})()},i=()=>{n!==void 0&&window.clearTimeout(n),n=window.setTimeout(a,dQ)};a();const l=window.setInterval(a,uQ);return window.addEventListener("markus:notifications-changed",i),window.addEventListener("markus:data-changed",i),()=>{t=!1,window.clearInterval(l),n!==void 0&&window.clearTimeout(n),window.removeEventListener("markus:notifications-changed",i),window.removeEventListener("markus:data-changed",i)}},[e])}const pQ=10*6e4;class fQ{bySession=new Map;listeners=new Set;_revision=0;getRevision=()=>this._revision;subscribe=t=>(this.listeners.add(t),()=>{this.listeners.delete(t)});applyServerState(t,n,a,i=Date.now(),l,c){const u=this.bySession.get(n);if(u&&u.source==="server"&&u.at>i)return;const m=l??null,f=!u||u.streaming!==a||u.assistantMessageId!==m;this.bySession.set(n,{agentId:t,streaming:a,source:"server",at:i,assistantMessageId:m,status:c}),f&&this.bump()}reconcileFromServer(t,n,a=Date.now()){for(const[i,l]of Object.entries(n))this.applyServerState(t,i,l,a)}applyLocalOptimistic(t,n,a){const i=this.bySession.get(n),l=Date.now();if(i&&i.source==="server"&&i.at>=l)return;const c=!i||i.streaming!==a;this.bySession.set(n,{agentId:t,streaming:a,source:"local",at:l,assistantMessageId:i?.assistantMessageId??null,status:i?.status}),c&&this.bump()}isStreaming(t){return t?this.bySession.get(t)?.streaming??!1:!1}isServerConfirmedStreaming(t){if(!t)return!1;const n=this.bySession.get(t);return!!n&&n.source==="server"&&n.streaming}liveBubbleId(t){if(!t)return null;const n=this.bySession.get(t);return!n||!n.streaming?null:n.assistantMessageId}isAgentStreaming(t){if(!t)return!1;for(const n of this.bySession.values())if(n.agentId===t&&n.streaming)return!0;return!1}streamingAgentIds(){const t=new Set;for(const n of this.bySession.values())n.streaming&&t.add(n.agentId);return t}hasEntry(t){return this.bySession.has(t)}entriesSnapshot(){return[...this.bySession].map(([t,n])=>({sessionId:t,...n}))}prune(t=Date.now(),n=pQ){for(const[a,i]of this.bySession)!i.streaming&&t-i.at>n&&this.bySession.delete(a)}bump(){this._revision+=1;for(const t of this.listeners)try{t()}catch{}}}const Lr=new fQ;function Yme(){return w.useSyncExternalStore(Lr.subscribe,Lr.getRevision,Lr.getRevision)}function Qme(e){return w.useSyncExternalStore(Lr.subscribe,Lr.getRevision,Lr.getRevision),Lr.isAgentStreaming(e)}const hQ={chime:[{freq:698.46,startMs:0,durationMs:170,wave:"sine",gain:.3,overtones:[{mult:2,gain:.35}]},{freq:880,startMs:120,durationMs:320,wave:"sine",gain:.28,overtones:[{mult:2,gain:.3},{mult:3,gain:.1}]}],ding:[{freq:261.63,startMs:0,durationMs:760,wave:"sine",gain:.09},{freq:523.25,startMs:0,durationMs:700,wave:"sine",gain:.08},{freq:1046.5,startMs:0,durationMs:650,wave:"sine",gain:.16,overtones:[{mult:2,gain:.32},{mult:2.76,gain:.16},{mult:4,gain:.08}]},{freq:1567.98,startMs:0,durationMs:320,wave:"sine",gain:.05}],pop:[{freq:523.25,startMs:0,durationMs:150,wave:"sine",gain:.3,overtones:[{mult:2,gain:.3}]},{freq:659.25,startMs:80,durationMs:190,wave:"sine",gain:.26,overtones:[{mult:2,gain:.25}]}],ask:[{freq:587.33,startMs:0,durationMs:200,wave:"sine",gain:.28,overtones:[{mult:2,gain:.3}]},{freq:783.99,startMs:130,durationMs:340,wave:"sine",gain:.26,overtones:[{mult:2,gain:.28}]}],attention:[{freq:196,startMs:0,durationMs:520,wave:"sine",gain:.1},{freq:783.99,startMs:0,durationMs:430,wave:"sine",gain:.14,overtones:[{mult:2,gain:.3},{mult:2.76,gain:.15}]},{freq:987.77,startMs:150,durationMs:400,wave:"sine",gain:.13,overtones:[{mult:2,gain:.28},{mult:2.76,gain:.12}]},{freq:1174.66,startMs:300,durationMs:520,wave:"sine",gain:.13,overtones:[{mult:2,gain:.3},{mult:2.76,gain:.15}]}],alert:[{freq:392,startMs:0,durationMs:240,wave:"triangle",gain:.32,overtones:[{mult:2,gain:.18}]},{freq:311.13,startMs:220,durationMs:380,wave:"triangle",gain:.32,overtones:[{mult:2,gain:.18}]}]},gQ=[{id:"agent-reply-complete",cue:"chime",labelKey:"sounds.events.agentReplyComplete.label",descKey:"sounds.events.agentReplyComplete.desc"},{id:"input-requested",cue:"ask",labelKey:"sounds.events.inputRequested.label",descKey:"sounds.events.inputRequested.desc"},{id:"approval-requested",cue:"attention",labelKey:"sounds.events.approvalRequested.label",descKey:"sounds.events.approvalRequested.desc"},{id:"review-requested",cue:"ding",labelKey:"sounds.events.reviewRequested.label",descKey:"sounds.events.reviewRequested.desc"},{id:"notification",cue:"pop",labelKey:"sounds.events.notification.label",descKey:"sounds.events.notification.desc"},{id:"agent-reply-error",cue:"alert",labelKey:"sounds.events.agentReplyError.label",descKey:"sounds.events.agentReplyError.desc"},{id:"task-failed",cue:"alert",labelKey:"sounds.events.taskFailed.label",descKey:"sounds.events.taskFailed.desc"}],bS=new Map(gQ.map(e=>[e.id,e]));function bQ(e){return bS.get(e).cue}function yQ(e,t){if(!e||e.streaming!==!0||t.streaming||t.source!=="server")return null;const n=(t.status??"").toLowerCase();return n==="cancelled"||n==="canceled"||n==="stopped"?null:n==="error"||n==="failed"?"agent-reply-error":"agent-reply-complete"}function vQ(e){const t=e?.notification,n=typeof t?.type=="string"?t.type.toLowerCase():"";return n?n==="approval_request"||n==="approval_required"?t?.metadata?.askKind==="input"?"input-requested":"approval-requested":n==="task_review"||n==="review_request"||n==="review_requested"?"review-requested":n==="task_failed"?"task-failed":"notification":null}function xQ(e){const t=e?.status;return typeof t!="string"?null:t==="review"?"review-requested":t==="failed"?"task-failed":null}const wQ=["quiet","normal","loud"],yS={quiet:.6,normal:1,loud:1.7},ib="markus-notification-sounds",ag="markus:notification-sounds-changed",Xu={enabled:!0,disabledEvents:[],volume:"normal"};function vS(e){if(!e||typeof e!="object")return{...Xu};const t=e,n=Array.isArray(t.disabledEvents)?t.disabledEvents.filter(i=>bS.has(i)):[],a=wQ.includes(t.volume)?t.volume:"normal";return{enabled:typeof t.enabled=="boolean"?t.enabled:!0,disabledEvents:[...new Set(n)],volume:a}}function xS(){try{return typeof window<"u"?window.localStorage:null}catch{return null}}function Rc(e=xS()){if(!e)return{...Xu};try{const t=e.getItem(ib);return t?vS(JSON.parse(t)):{...Xu}}catch{return{...Xu}}}function Jme(e,t=xS()){const n=vS({...Rc(t),...e});try{t?.setItem(ib,JSON.stringify(n))}catch{}return typeof window<"u"&&window.dispatchEvent(new CustomEvent(ag,{detail:n})),n}function Xme(e){if(typeof window>"u")return()=>{};const t=()=>e(Rc()),n=a=>{a.key===ib&&e(Rc())};return window.addEventListener(ag,t),window.addEventListener("storage",n),()=>{window.removeEventListener(ag,t),window.removeEventListener("storage",n)}}const kQ=4e3,SQ=700;class CQ{constructor(t=()=>Date.now()){this.now=t}lastByEvent=new Map;lastAt=Number.NEGATIVE_INFINITY;shouldPlay(t,n){if(!n.enabled||n.disabledEvents.includes(t))return!1;const a=this.now();return a-(this.lastByEvent.get(t)??Number.NEGATIVE_INFINITY)<kQ||a-this.lastAt<SQ?!1:(this.lastByEvent.set(t,a),this.lastAt=a,!0)}reset(){this.lastByEvent.clear(),this.lastAt=Number.NEGATIVE_INFINITY}}const AQ=new CQ;let w2=null;const TQ=.85;function EQ(e,t){const n=typeof window<"u"?window.AudioContext??window.webkitAudioContext:void 0;if(!n)return;const a=hQ[e];if(!(!a||a.length===0))try{w2??=new n;const i=w2;i.state==="suspended"&&i.resume().catch(()=>{});const l=i.currentTime+.01,c=i.createGain();c.gain.setValueAtTime(t,l);const u=i.createDynamicsCompressor();u.threshold.setValueAtTime(-6,l),u.knee.setValueAtTime(6,l),u.ratio.setValueAtTime(12,l),u.attack.setValueAtTime(.003,l),u.release.setValueAtTime(.15,l),c.connect(u).connect(i.destination);const m=(f,g,h,b,y)=>{const k=i.createOscillator(),C=i.createGain();k.type=g,k.frequency.setValueAtTime(f,b);const T=Math.min(h,TQ);C.gain.setValueAtTime(1e-4,b),C.gain.exponentialRampToValueAtTime(Math.max(T,2e-4),b+.012),C.gain.exponentialRampToValueAtTime(1e-4,y),k.connect(C).connect(c),k.start(b),k.stop(y+.02)};for(const f of a){const g=l+f.startMs/1e3,h=g+f.durationMs/1e3;m(f.freq,f.wave,f.gain,g,h);for(const b of f.overtones??[])m(f.freq*b.mult,f.wave,f.gain*b.gain,g,h)}}catch{}}let wS=EQ;function zh(e,t=Rc(),n=AQ){return n.shouldPlay(e,t)?(wS(bQ(e),yS[t.volume]),!0):!1}function Zme(e,t=Rc().volume){wS(e,yS[t])}function NQ(e){w.useEffect(()=>{if(!e)return;let t=new Map(Lr.entriesSnapshot().map(l=>[l.sessionId,l]));const n=Lr.subscribe(()=>{const l=Lr.entriesSnapshot();for(const c of l){const u=yQ(t.get(c.sessionId),c);u&&zh(u)}t=new Map(l.map(c=>[c.sessionId,c]))}),a=di.on("notification",l=>{const c=vQ(l?.payload);c&&zh(c)}),i=di.on("task:update",l=>{const c=xQ(l?.payload);c&&zh(c)});return()=>{n(),a(),i()}},[e])}let kS=Ec();const rg=new Set;function k2(){kS=Ec(),rg.forEach(e=>e())}typeof window<"u"&&(window.addEventListener("hashchange",k2),window.addEventListener("popstate",k2));function MQ(e){return rg.add(e),()=>rg.delete(e)}function jQ(e){return w.useSyncExternalStore(MQ,()=>kS===e,()=>!1)}var Jo=I4();function $s(e){w.useEffect(()=>VW(),[e])}function xr({title:e,message:t,confirmLabel:n,cancelLabel:a,variant:i="danger",alertOnly:l=!1,checkboxes:c,onConfirm:u,onCancel:m,onCancelClick:f}){const{t:g}=ut("common");$s(!0);const[h,b]=w.useState(()=>{const C={};for(const T of c??[])C[T.id]=T.defaultChecked??!1;return C}),y=i==="primary",k=y?"px-4 py-1.5 text-sm bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg transition-colors":"px-4 py-1.5 text-sm bg-red-600 hover:bg-red-500 text-white rounded-lg transition-colors";return Jo.createPortal(o.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10050] p-4",onClick:m,children:o.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[360px] max-w-[calc(100vw-2rem)] shadow-2xl",onClick:C=>C.stopPropagation(),children:[o.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[o.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center shrink-0 ${y?"bg-brand-500/15":"bg-red-500/15"}`,children:y?o.jsxs("svg",{className:"w-5 h-5 text-brand-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("path",{d:"M12 16v-4"}),o.jsx("path",{d:"M12 8h.01"})]}):o.jsxs("svg",{className:"w-5 h-5 text-red-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),o.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}),o.jsxs("div",{className:"min-w-0 pt-0.5",children:[o.jsx("h3",{className:"font-semibold text-base text-fg-primary",children:e}),o.jsx("p",{className:"text-sm text-fg-secondary mt-1 leading-relaxed",children:t})]})]}),c&&c.length>0&&o.jsx("div",{className:"mb-4 space-y-2",children:c.map(C=>o.jsxs("label",{className:"flex items-center gap-2 text-sm text-fg-secondary cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:h[C.id]??!1,onChange:T=>b(A=>({...A,[C.id]:T.target.checked})),className:"rounded bg-surface-elevated border-border-default"}),C.label]},C.id))}),o.jsxs("div",{className:"flex justify-end gap-2",children:[!l&&o.jsx("button",{type:"button",onClick:()=>{f?f(c?h:void 0):m()},className:"px-4 py-1.5 text-sm border border-border-default rounded-lg text-fg-primary hover:bg-surface-elevated transition-colors",children:a??g("cancel")}),o.jsx("button",{type:"button",onClick:()=>u(c?h:void 0),className:k,children:n??g(l?"ok":"confirm")})]})]})}),document.body)}function SS(e,t){const n=e||t||null;if(!n)return null;if(n.startsWith("http")||n.startsWith("data:")||n.startsWith("/api/"))return n;if(n.startsWith("/")){const a=at.getUrl()?.replace(/\/$/,"")||"";return a?`${a}${n}`:n}return n}function CS({size:e,className:t=""}){const n=Math.max(12,Math.round(e*.55));return o.jsx("div",{className:`rounded-full bg-surface-overlay text-fg-secondary flex items-center justify-center shrink-0 border border-border-default/70 ${t}`,style:{width:e,height:e},"aria-hidden":!0,children:o.jsxs("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),o.jsx("circle",{cx:"12",cy:"7",r:"4"})]})})}function Go({name:e,avatarUrl:t,size:n=28,className:a="",bgClass:i="bg-brand-600 text-on-brand",fallback:l="initials"}){const[c,u]=w.useState(!1);if(w.useEffect(()=>{u(!1)},[t]),!!t&&!c)return o.jsx("img",{src:t,alt:e??"",className:`rounded-full object-cover shrink-0 ${a}`,style:{width:n,height:n},onError:()=>u(!0)});if(l==="icon")return o.jsx(CS,{size:n,className:a});const f=e?.[0]?.toUpperCase()??"?",g=n<=20?"text-[8px]":n<=28?"text-xs":n<=40?"text-sm":"text-lg",h=/\btext-(?!white\b)/.test(i);return o.jsx("div",{className:`rounded-full ${i} flex items-center justify-center ${h?"":"text-white"} ${g} font-bold shrink-0 ${a}`,style:{width:n,height:n},children:f})}function AS({currentUrl:e,name:t,size:n=64,targetType:a="user",targetId:i,onUploaded:l}){const{t:c}=ut("common"),[u,m]=w.useState(null),[f,g]=w.useState(!1),[h,b]=w.useState(!1),[y,k]=w.useState(null),C=w.useRef(null),T=u??e;w.useEffect(()=>{b(!1)},[T]);const A=!!T&&!h,M=w.useCallback(async I=>{if(!I.type.startsWith("image/"))return;if(I.size>2*1024*1024){k(c("imageTooLarge"));return}const B=new FileReader;B.onload=async()=>{const G=B.result;m(G),b(!1),g(!0);try{const{avatarUrl:j}=await Se.auth.uploadAvatar(G,a,i);l?.(j)}catch{m(null)}finally{g(!1)}},B.readAsDataURL(I)},[a,i,l,c]);return o.jsxs("div",{className:"relative inline-block group",children:[o.jsx("input",{ref:C,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",className:"hidden",onChange:I=>{const B=I.target.files?.[0];B&&M(B)}}),o.jsxs("button",{type:"button",onClick:()=>C.current?.click(),className:"relative rounded-full overflow-hidden focus:outline-none focus:ring-2 focus:ring-brand-500/50",style:{width:n,height:n},title:c("clickToSetAvatar",{defaultValue:"Click to set avatar"}),"aria-busy":f,children:[A?o.jsx("img",{src:T,alt:t??"",className:"w-full h-full object-cover",onError:()=>b(!0)}):o.jsx(CS,{size:n}),o.jsx("div",{className:`absolute inset-0 bg-black/45 flex items-center justify-center transition-opacity ${f?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:f?o.jsx("div",{className:"w-5 h-5 border-2 border-white/60 border-t-white rounded-full animate-spin"}):o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"}),o.jsx("circle",{cx:"12",cy:"13",r:"4"})]})})]}),y&&o.jsx(xr,{alertOnly:!0,variant:"danger",title:c("error",{defaultValue:"Error"}),message:y,onConfirm:()=>k(null),onCancel:()=>k(null)})]})}const RQ={total:0,used:0,remaining:0,pct:0,personalLimit:!1};function _Q(e){return e?"billing":"login"}function DQ(e,t){return e?t?"sidebar.hubConnectedAs":"sidebar.hubConnected":"sidebar.hubDisconnected"}function Ro(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function IQ(e,t){const n=e?.memberCuLimit;return n==null||n<=0,!1}function LQ(e,t){if(!e)return RQ;const n=IQ(e),a=e.memberCuLimit!==null&&e.memberCuLimit!==void 0&&e.memberCuLimit>0,i=Ro(e.monthlyQuotaCu)+Ro(e.bonusCu)+Ro(e.purchasedCu),l=n?Ro(e.memberCuLimit):e.creditsBudgetCu??(a?Ro(e.memberCuLimit):i),c=n?Ro(e.memberCuUsed):e.totalConsumedThisPeriod??e.cuUsed??e.memberCuUsed??0,u=Math.max(0,l-c),m=l>0?Math.min(100,Math.round(c/l*100)):0;return{total:l,used:c,remaining:u,pct:m,personalLimit:n}}function TS(e){const[t,n]=w.useState(()=>at.isAuthenticated()),[a,i]=w.useState(()=>Oa()),[l,c]=w.useState(()=>PQ(Oa()?.id??null)),u=w.useCallback(m=>{if(i(Oa()),!at.isAuthenticated()){n(!1),c(null),S2(null,null);return}if(!m?.validate){n(!0);return}sS().then(f=>{n(f),i(Oa())})},[]);return w.useEffect(()=>{u({validate:!0});const m=()=>u(),f=()=>u({validate:!0});return window.addEventListener("markus:hub-auth",m),window.addEventListener("focus",f),()=>{window.removeEventListener("markus:hub-auth",m),window.removeEventListener("focus",f)}},[u]),w.useEffect(()=>{if(!at.isAuthenticated())return;let m=!1;return at.user.plan().then(f=>{if(m)return;const g=LQ(f);c(g),S2(Oa()?.id??null,g)}).catch(()=>{}),()=>{m=!0}},[e,t]),{connected:t,user:a,credits:l,refresh:u}}const ig="markus:hub:credits";function PQ(e){if(!e)return null;try{const t=localStorage.getItem(ig);if(!t)return null;const n=JSON.parse(t);return n.userId!==e||!n.credits?null:n.credits}catch{return null}}function S2(e,t){try{if(!e||!t){localStorage.removeItem(ig);return}localStorage.setItem(ig,JSON.stringify({userId:e,credits:t}))}catch{}}function Ko(){return!!window.markusDesktop}function Or(e){window.markusDesktop?window.markusDesktop.openExternal(e):window.open(e,"_blank","noopener,noreferrer")}function OQ({authUser:e,onNavigate:t,onLogout:n}){const{t:a}=ut(["settings","common","nav"]),[i,l]=w.useState(!1),[c,u]=w.useState(!1),{connected:m,user:f,credits:g}=TS(i);w.useEffect(()=>{const C=()=>l(!0);return window.addEventListener("markus:open-drawer",C),()=>window.removeEventListener("markus:open-drawer",C)},[]),w.useEffect(()=>(i?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[i]);const h=C=>{if(l(!1),C==="__edit_profile"){window.dispatchEvent(new CustomEvent("markus:open-edit-profile"));return}t(C)},b=()=>{if(l(!1),_Q(m)==="login"){Ia().catch(()=>{});return}Or(`${at.getUrl().replace(/\/$/,"")}/settings?tab=billing`)},y=()=>{l(!1),yt.navigate(ce.SETTINGS,{tab:"account"})};if(!i)return null;const k=a(`nav:${DQ(m,!!f?.username)}`,{username:f?.username??""});return o.jsxs("div",{className:"fixed inset-0 z-[100]",children:[o.jsx("div",{className:"absolute inset-0 bg-black/40 animate-fadeIn",onClick:()=>l(!1)}),o.jsxs("aside",{className:"absolute inset-y-0 left-0 w-72 bg-surface-secondary shadow-2xl flex flex-col animate-slideInLeft",children:[o.jsx("div",{className:"px-5 pt-6 pb-4 border-b border-border-default",children:e?o.jsxs("button",{onClick:()=>h("__edit_profile"),className:"flex items-center gap-3 w-full text-left",children:[o.jsx(Go,{name:e.name||"User",avatarUrl:e.avatarUrl,size:40}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:e.name||a("common:userPlaceholder")}),o.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:e.email||e.role})]}),o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-fg-tertiary shrink-0",children:o.jsx("polyline",{points:"9 18 15 12 9 6"})})]}):o.jsx("div",{className:"text-sm text-fg-tertiary",children:a("common:loading")})}),o.jsxs("div",{className:"px-3 pt-3 pb-1 border-b border-border-default space-y-0.5",children:[o.jsxs("button",{onClick:b,title:m?a("common:creditBalanceOpenHub"):void 0,className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-lg hover:bg-surface-overlay active:bg-surface-overlay transition-colors text-left",children:[o.jsx("span",{className:"w-[18px] h-[18px] flex items-center justify-center shrink-0 text-fg-tertiary",children:o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z"}),o.jsx("path",{d:"M12.5 5.5v13",strokeDasharray:"2 2.5"})]})}),o.jsx("span",{className:"flex-1 min-w-0 text-sm text-fg-secondary truncate",children:a("common:creditBalance")}),o.jsx("span",{className:"text-sm font-medium text-fg-primary shrink-0 tabular-nums",children:m?g!==null?g.remaining.toLocaleString():"—":a("nav:sidebar.hubLoginShort")}),o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-fg-tertiary shrink-0",children:o.jsx("polyline",{points:"9 18 15 12 9 6"})})]}),o.jsxs("button",{onClick:y,className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-lg hover:bg-surface-overlay transition-colors text-left",children:[o.jsx("span",{className:"w-[18px] h-[18px] flex items-center justify-center shrink-0",children:o.jsx("span",{className:`w-2 h-2 rounded-full ${m?"bg-emerald-500":"bg-fg-muted"}`})}),o.jsx("span",{className:"flex-1 min-w-0 text-sm text-fg-secondary truncate",children:k}),o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-fg-tertiary shrink-0",children:o.jsx("polyline",{points:"9 18 15 12 9 6"})})]})]}),o.jsxs("nav",{className:"flex-1 overflow-y-auto py-3 px-3 space-y-1",children:[o.jsx(qh,{icon:o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),o.jsx("polyline",{points:"9 22 9 12 15 12 15 22"})]}),label:a("common:home",{defaultValue:"Home"}),onClick:()=>h(ce.HOME)}),o.jsx(qh,{icon:o.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("path",{d:Xm[ce.BUILDER]})}),label:a("nav:builder"),onClick:()=>h(ce.BUILDER)}),o.jsx(qh,{icon:o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("circle",{cx:"12",cy:"12",r:"3"}),o.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),label:a("settings:title"),onClick:()=>h(ce.SETTINGS)})]})]}),c&&n&&o.jsx(xr,{title:a("common:signOutConfirmTitle"),message:a("common:signOutConfirmMessage"),confirmLabel:a("common:signOut"),variant:"primary",onConfirm:()=>{u(!1),l(!1),n()},onCancel:()=>u(!1)})]})}function qh({icon:e,label:t,onClick:n}){return o.jsxs("button",{onClick:n,className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm text-fg-secondary hover:text-fg-primary hover:bg-surface-overlay transition-colors",children:[e,o.jsx("span",{children:t})]})}function HQ(){window.dispatchEvent(new CustomEvent("markus:open-drawer"))}function ES({className:e=""}){const{t}=ut("common");return o.jsx("button",{onClick:HQ,className:`p-1.5 -ml-1 rounded-lg hover:bg-surface-overlay transition-colors shrink-0 ${e}`,"aria-label":t("menu"),children:o.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),o.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),o.jsx("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]})})}function BQ({onClose:e,onClaimed:t}){const{t:n}=ut(["home","common"]);$s(!0);const[a,i]=w.useState("loading"),[l,c]=w.useState(1e3),[u,m]=w.useState(""),f=w.useRef(t);f.current=t;const g=w.useRef(!1),h=()=>`${at.getUrl().replace(/\/$/,"")}/settings?tab=overview&claim=1`,b=w.useCallback(async()=>{i("loading"),m("");try{Tn()||await Ia();const k=await at.user.claimFreeCreditsStatus();if(typeof k.amountCu=="number"&&k.amountCu>0&&c(k.amountCu),k.claimed){i("already"),f.current();return}i("open_hub")}catch(k){m(k instanceof Error?k.message:n("claim.loadFailed")),i("error")}},[n]);w.useEffect(()=>{g.current||(g.current=!0,b())},[b]);const y=()=>{const k=h();Ko()?Or(k):window.open(k,"_blank","noopener,noreferrer")};return o.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60] p-4",onClick:e,children:o.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-2xl p-6 w-full max-w-md shadow-2xl",onClick:k=>k.stopPropagation(),children:[o.jsxs("div",{className:"flex items-start justify-between gap-3 mb-4",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"font-semibold text-lg text-fg-primary",children:n("claim.title")}),o.jsx("p",{className:"text-sm text-fg-secondary mt-1 leading-relaxed",children:n("claim.subtitle")})]}),o.jsx("button",{type:"button",onClick:e,className:"text-fg-tertiary hover:text-fg-primary text-lg leading-none",children:"×"})]}),a==="loading"&&o.jsx("p",{className:"text-sm text-fg-tertiary mb-5",children:n("claim.loading")}),a==="already"&&o.jsxs("div",{className:"space-y-4",children:[o.jsx("p",{className:"text-sm text-emerald-400",children:n("claim.success",{amount:l.toLocaleString()})}),o.jsx("p",{className:"text-sm text-fg-secondary",children:n("claim.startUsing")}),o.jsx("button",{type:"button",onClick:e,className:"w-full py-2.5 text-sm font-medium rounded-xl bg-brand-500 text-on-brand hover:bg-brand-600",children:n("common:close")})]}),a==="open_hub"&&o.jsxs("div",{className:"space-y-4",children:[o.jsx("p",{className:"text-sm text-fg-secondary leading-relaxed",children:n("claim.openHubHint",{amount:l.toLocaleString()})}),o.jsx("button",{type:"button",onClick:y,className:"w-full py-2.5 text-sm font-medium rounded-xl bg-brand-500 text-on-brand hover:bg-brand-600",children:n("claim.openHub")})]}),a==="error"&&o.jsxs("div",{className:"space-y-3",children:[o.jsx("p",{className:"text-sm text-red-400",children:u}),o.jsx("button",{type:"button",onClick:()=>{b()},className:"w-full py-2 text-sm rounded-xl border border-border-default",children:n("claim.retry")})]})]})})}function C2(e){return e.includes(":")?e:`common:${e}`}const _r=[{id:"toggle-left",group:"layout",keys:["B"],label:"Toggle left sidebar",labelKey:"shortcuts.toggleLeft",page:"any"},{id:"nav-l0-jk",group:"navigation",keys:["J / K"],label:"L0: switch page up / down",labelKey:"shortcuts.navL0Jk",page:"any",bare:!0},{id:"nav-l0-l",group:"navigation",keys:["L"],label:"L0: enter page L1",labelKey:"shortcuts.navL0L",page:"any",bare:!0},{id:"nav-l0-h",group:"navigation",keys:["H"],label:"From page L1: focus app rail (L0)",labelKey:"shortcuts.navL0H",page:"any",bare:!0},{id:"search",group:"search",keys:["P"],label:"Global search",labelKey:"shortcuts.search",page:"any"},{id:"help",group:"help",keys:["/"],label:"Show keyboard shortcuts",labelKey:"shortcuts.help",page:"any"},{id:"new-conversation",group:"team",keys:["N"],label:"New conversation",labelKey:"shortcuts.newConversation",page:"team"},{id:"cycle-session-tab",group:"team",keys:["Ctrl","Tab"],label:"Next conversation tab",labelKey:"shortcuts.cycleSessionTab",page:"team"},{id:"cycle-session-tab-prev",group:"team",keys:["Ctrl","Shift","Tab"],label:"Previous conversation tab",labelKey:"shortcuts.cycleSessionTabPrev",page:"team"}];function NS(e){return`markus_shortcut_lesson_${e}`}function km(e){try{const t=localStorage.getItem(NS(e));if(!t)return[];const n=JSON.parse(t);return Array.isArray(n)?n.filter(a=>typeof a=="string"):[]}catch{return[]}}function Sm(e,t){try{localStorage.setItem(NS(e),JSON.stringify(t.filter(Boolean)))}catch{}}function sb(e){const t=new Set(km(e));return _r.every(n=>t.has(n.id))}function zQ(e,t,n){const a=_r.find(l=>MS(e,l.id,n));if(!a)return sb(t);const i=new Set(km(t));return i.add(a.id),Sm(t,[...i]),_r.every(l=>i.has(l.id))}function qQ(e){Sm(e,_r.map(t=>t.id))}function MS(e,t,n){const a=n?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey,i=e.key.toLowerCase();switch(t){case"toggle-left":return a&&!e.altKey&&!e.shiftKey&&i==="b";case"nav-l0-jk":return!e.metaKey&&!e.ctrlKey&&!e.altKey&&(i==="j"||i==="k");case"nav-l0-l":return!e.metaKey&&!e.ctrlKey&&!e.altKey&&i==="l";case"nav-l0-h":return!e.metaKey&&!e.ctrlKey&&!e.altKey&&i==="h";case"search":return a&&!e.altKey&&!e.shiftKey&&i==="p";case"help":return a&&!e.altKey&&(i==="/"||!e.shiftKey&&(e.code==="Slash"||i==="/"));case"new-conversation":return a&&!e.altKey&&!e.shiftKey&&i==="n";case"cycle-session-tab":return e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key==="Tab"&&!e.shiftKey;case"cycle-session-tab-prev":return e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key==="Tab"&&e.shiftKey;default:return!1}}const $Q=[{id:"toggle-left",group:"layout",keys:["B"],label:"Toggle left sidebar (L0 + page L1)",labelKey:"shortcuts.toggleLeft",page:"any"},{id:"help",group:"help",keys:["/"],label:"Show keyboard shortcuts",labelKey:"shortcuts.help",page:"any"},{id:"search",group:"search",keys:["P"],label:"Global search",labelKey:"shortcuts.search",page:"any"},{id:"nav-l0-jk",group:"navigation",keys:["J / K"],label:"L0: switch page up / down",labelKey:"shortcuts.navL0Jk",page:"any",bare:!0},{id:"nav-l0-l",group:"navigation",keys:["L"],label:"L0: enter page L1 (Team / Tasks / Output / Store / Settings)",labelKey:"shortcuts.navL0L",page:"any",bare:!0},{id:"nav-l0-h",group:"navigation",keys:["H"],label:"From page L1: focus app rail (L0)",labelKey:"shortcuts.navL0H",page:"any",bare:!0},{id:"settings-back",group:"navigation",keys:["H"],label:"Settings: go back to previous page",labelKey:"shortcuts.settingsBack",page:"any",bare:!0},{id:"nav-jk-settings",group:"navigation",keys:["J / K"],label:"Settings L1: switch settings tabs",labelKey:"shortcuts.navJkSettings",page:"any",bare:!0},{id:"nav-hl-work",group:"navigation",keys:["H / L"],label:"Tasks: item list ↔ project L1 ↔ app rail",labelKey:"shortcuts.navHlWork",page:"work",bare:!0},{id:"nav-jk-work",group:"navigation",keys:["J / K"],label:"Tasks: move project / item selection",labelKey:"shortcuts.navJkWork",page:"work",bare:!0},{id:"nav-hl-team",group:"navigation",keys:["H / L"],label:"Team: L0 ↔ L1 ↔ L2 (L ignored on deepest pane)",labelKey:"shortcuts.navHlTeam",page:"team",bare:!0},{id:"nav-jk-team",group:"navigation",keys:["J / K"],label:"Team L1: move roster selection",labelKey:"shortcuts.navJkTeam",page:"team",bare:!0},{id:"nav-jk-team-l2",group:"navigation",keys:["J / K"],label:"Team L2: move team member selection",labelKey:"shortcuts.navJkTeamL2",page:"team",bare:!0},{id:"nav-jk-deliverables",group:"navigation",keys:["J / K"],label:"Output L1: move deliverable selection",labelKey:"shortcuts.navJkDeliverables",page:"deliverables",bare:!0},{id:"nav-jk-store",group:"navigation",keys:["J / K"],label:"Store L1: switch store tabs",labelKey:"shortcuts.navJkStore",page:"store",bare:!0},{id:"toggle-project-detail",group:"tasks",keys:["J"],label:"Toggle project detail (Tasks)",labelKey:"shortcuts.toggleProjectDetail",page:"work"},{id:"toggle-item-detail",group:"tasks",keys:["L"],label:"Toggle task / requirement detail (Tasks)",labelKey:"shortcuts.toggleItemDetail",page:"work"},{id:"cycle-board",group:"tasks",keys:["Ctrl","Tab"],label:"Cycle Tasks views",labelKey:"shortcuts.cycleBoard",page:"work",bare:!0},{id:"new-conversation",group:"team",keys:["N"],label:"New conversation",labelKey:"shortcuts.newConversation",page:"team"},{id:"cycle-session-tab",group:"team",keys:["Ctrl","Tab"],label:"Next conversation tab",labelKey:"shortcuts.cycleSessionTab",page:"team"},{id:"cycle-session-tab-prev",group:"team",keys:["Ctrl","Shift","Tab"],label:"Previous conversation tab",labelKey:"shortcuts.cycleSessionTabPrev",page:"team"},{id:"toggle-browser",group:"team",keys:["L"],label:"Toggle right panel · Browser",labelKey:"shortcuts.toggleBrowser",page:"team"},{id:"toggle-terminal",group:"team",keys:["J"],label:"Toggle right panel · Terminal",labelKey:"shortcuts.toggleTerminal",page:"team"},{id:"next-tab",group:"rightPanel",keys:["Shift","]"],label:"Next right-panel tab",labelKey:"shortcuts.nextTab",page:"team"},{id:"prev-tab",group:"rightPanel",keys:["Shift","["],label:"Previous right-panel tab",labelKey:"shortcuts.prevTab",page:"team"},{id:"tab-n",group:"rightPanel",keys:["1…9"],label:"Jump to Nth right-panel tab",labelKey:"shortcuts.tabN",page:"team"},{id:"close-tab",group:"rightPanel",keys:["W"],label:"Close right-panel tab",labelKey:"shortcuts.closeTab",page:"team"},{id:"new-tab",group:"rightPanel",keys:["T"],label:"New browser tab / shell",labelKey:"shortcuts.newTab",page:"team"},{id:"term-search",group:"terminal",keys:["F"],label:"Search in terminal",labelKey:"shortcuts.termSearch",page:"team"},{id:"term-to-chat",group:"terminal",keys:["Shift","A"],label:"Add terminal selection to chat",labelKey:"shortcuts.termToChat",page:"team"}];function jS(e,t,n){return n||e[0]==="Ctrl"||e[0]==="Tab"||e[0]==="J / K"||e[0]==="H / L"?e.join(e[0]==="Ctrl"?"+":" "):e.length===1&&(e[0]==="H"||e[0]==="L"||e[0]==="J"||e[0]==="K")?e[0]:[t?"⌘":"Ctrl",...e].join(t?"":"+")}function A2(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable?!0:e.closest(".xterm")!==null}function T2(e){return e instanceof HTMLElement?e.closest(".xterm")!==null:!1}const FQ=["layout","navigation","search","help","team"];function UQ(e,t){return t&&e.startsWith("⌘")?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-[15px] font-semibold leading-none",children:"⌘"}),o.jsx("span",{className:"text-[13px]",children:e.slice(1)})]}):o.jsx("span",{className:"text-[13px]",children:e})}function GQ({open:e,userId:t,onClose:n,onCompleted:a}){const{t:i}=ut(["home","common"]),l=typeof navigator<"u"&&navigator.platform.toUpperCase().includes("MAC"),[c,u]=w.useState(()=>new Set(t?km(t):[]));w.useEffect(()=>{e&&t&&u(new Set(km(t)))},[e,t]);const m=_r.every(y=>c.has(y.id)),f=c.size;w.useEffect(()=>{!e||!t||m&&sb(t)&&a()},[e,t,m]);const g=w.useMemo(()=>FQ.map(y=>({group:y,items:_r.filter(k=>k.group===y)})).filter(y=>y.items.length>0),[]);if(w.useEffect(()=>{if(!e||!t)return;const y=k=>{if(k.key==="Escape"){n();return}const C={key:k.key,code:k.code,metaKey:k.metaKey,ctrlKey:k.ctrlKey,altKey:k.altKey,shiftKey:k.shiftKey},T=_r.find(A=>MS(C,A.id,l));T&&((k.metaKey||k.ctrlKey||k.altKey)&&k.preventDefault(),k.stopPropagation(),u(A=>{if(A.has(T.id))return A;const M=new Set(A);return M.add(T.id),t&&Sm(t,[...M]),M}))};return window.addEventListener("keydown",y,!0),()=>window.removeEventListener("keydown",y,!0)},[e,t,l,n]),!e)return null;const h=y=>{t&&u(k=>{const C=new Set(k);return C.has(y)?C.delete(y):C.add(y),Sm(t,[...C]),C})},b=()=>{t&&(qQ(t),u(new Set(_r.map(y=>y.id))),a())};return o.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/45 backdrop-blur-[1px] p-4",onMouseDown:y=>{y.target===y.currentTarget&&n()},role:"dialog","aria-modal":"true","aria-label":i("home:checklist.shortcutLesson.title"),children:o.jsxs("div",{className:"w-full max-w-md max-h-[80vh] overflow-auto rounded-xl border border-border-default bg-surface-primary shadow-2xl",children:[o.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between gap-3 px-4 py-3 border-b border-border-default bg-surface-primary",children:[o.jsx("h2",{className:"text-sm font-semibold text-fg-primary",children:i("checklist.shortcutLesson.title")}),o.jsx("button",{type:"button",onClick:n,className:"w-7 h-7 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated","aria-label":i("common:shortcuts.close"),children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsxs("div",{className:"px-4 py-3",children:[o.jsx("p",{className:"text-xs text-fg-secondary mb-3",children:i("checklist.shortcutLesson.subtitle")}),m?o.jsxs("div",{className:"flex items-center gap-2 bg-green-500/10 border border-green-500/30 rounded-xl px-4 py-3 mb-4",children:[o.jsx("span",{className:"text-green-600 text-base",children:"✓"}),o.jsx("span",{className:"text-sm font-medium text-green-600",children:i("checklist.shortcutLesson.allDone")})]}):o.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[o.jsx("div",{className:"flex-1 h-1.5 bg-surface-elevated rounded-full overflow-hidden",children:o.jsx("div",{className:"h-full bg-brand-500 rounded-full transition-all duration-300",style:{width:`${f/_r.length*100}%`}})}),o.jsx("span",{className:"text-[11px] text-fg-secondary font-medium shrink-0",children:i("checklist.progress",{done:f,total:_r.length})})]}),o.jsx("div",{className:"space-y-4",children:g.map(({group:y,items:k})=>o.jsxs("section",{children:[o.jsx("h3",{className:"text-[11px] font-semibold uppercase tracking-wide text-fg-tertiary mb-2",children:i(C2(`shortcuts.groups.${y}`),{defaultValue:y})}),o.jsx("ul",{className:"space-y-1",children:k.map(C=>{const T=c.has(C.id);return o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:()=>h(C.id),className:"w-full flex items-center justify-between gap-3 rounded-lg px-2 py-2 text-left hover:bg-surface-elevated/60 transition-colors",children:[o.jsxs("span",{className:"flex items-center gap-2.5 min-w-0",children:[o.jsx("span",{className:`shrink-0 w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${T?"bg-green-500 border-green-500":"border-border-default"}`,children:T&&o.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),o.jsx("span",{className:`text-sm min-w-0 ${T?"text-fg-tertiary line-through":"text-fg-primary"}`,children:i(C2(C.labelKey))})]}),o.jsx("kbd",{className:"shrink-0 px-2 py-1 rounded bg-surface-elevated border border-border-default font-medium leading-none text-fg-primary font-mono",children:UQ(jS(C.keys,l,C.bare),l)})]})},C.id)})})]},y))})]}),o.jsxs("div",{className:"sticky bottom-0 border-t border-border-default bg-surface-primary px-4 py-3 flex items-center justify-end gap-2",children:[o.jsx("button",{type:"button",onClick:b,className:"px-3 py-2 text-sm rounded-xl border border-border-default text-fg-secondary hover:bg-surface-elevated hover:text-fg-primary transition-colors font-medium",children:i("checklist.shortcutLesson.markAllLearned")}),o.jsx("button",{type:"button",onClick:n,className:`px-4 py-2 text-sm rounded-xl transition-colors font-medium ${m?"bg-green-600 hover:bg-green-500 text-on-brand":"bg-brand-600 hover:bg-brand-500 text-on-brand"}`,children:i(m?"checklist.shortcutLesson.done":"common:close")})]})]})})}function E2(e){const t=e.metadata??{};return e.type==="agent_report"&&!t.creditExhausted&&!t.templateUpdates&&(e.actionType==="open_chat"||!!t.agentId&&e.actionType!=="navigate")}function N2(e){const t=e.metadata??{},n=l=>typeof l=="string"&&l.length>0?l:void 0,a=n(t.taskId),i=n(t.requirementId);return a?`task:${a}`:i?`req:${i}`:null}function RS(e,t){const n=new Set,a=N2(e),i=a?t.filter(l=>!l.read&&N2(l)===a):[e];for(const l of i)l.read||E2(l)||n.add(l.id);!e.read&&!E2(e)&&n.add(e.id);for(const l of n)Se.notifications.markRead(l).catch(()=>{});return n.size>0&&window.dispatchEvent(new CustomEvent("markus:notifications-changed")),n}async function KQ(e){const t=await Se.notifications.markAllRead(e);return RY("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed")),t?.count??0}const M2=6e4,j2=36e5,R2=864e5;function VQ(e){if(!Number.isFinite(e))return"";const t=Date.now()-e;if(t<0||t<M2)return tn.t("common:justNow");if(t<j2)return tn.t("common:time.minutesAgo",{count:Math.floor(t/M2)});if(t<R2)return tn.t("common:time.hoursAgo",{count:Math.floor(t/j2)});const n=Math.floor(t/R2);return n===1?tn.t("common:time.yesterday"):tn.t("common:time.daysAgo",{count:n})}function WQ(e){return typeof e=="number"?e:e?new Date(e).getTime():Number.NaN}function _2(e){return VQ(WQ(e))}const D2={approved:{labelKey:"common:approvalStatus.approved",dot:"bg-fg-muted/30",chip:"bg-green-500/8 text-green-600/70"},rejected:{labelKey:"common:approvalStatus.rejected",dot:"bg-fg-muted/30",chip:"bg-red-500/8 text-red-500/70"},cancelled:{labelKey:"common:approvalStatus.cancelled",dot:"bg-fg-muted/25",chip:"bg-surface-overlay text-fg-tertiary"},expired:{labelKey:"common:approvalStatus.expired",dot:"bg-fg-muted/25",chip:"bg-amber-500/8 text-amber-600/70"}},I2=15,_S="markus_history_ui";function L2(){try{const e=localStorage.getItem(_S);if(!e)return{tab:"all",scrollTop:0};const t=JSON.parse(e);return{tab:t.tab==="approvals"||t.tab==="notices"?t.tab:"all",scrollTop:typeof t.scrollTop=="number"&&t.scrollTop>=0?t.scrollTop:0}}catch{return{tab:"all",scrollTop:0}}}function YQ(e){try{localStorage.setItem(_S,JSON.stringify(e))}catch{}}const P2=200;function QQ(e){w.useEffect(()=>{if(!e)return;const t=[document.documentElement,document.body,document.querySelector("[data-app-scroll]")].filter(l=>!!l),n=t.map(l=>l.style.overflow),a=t.map(l=>l.style.paddingRight),i=window.innerWidth-document.documentElement.clientWidth;return t.forEach((l,c)=>{l.style.overflow="hidden",c===0&&i>0&&(l.style.paddingRight=`${i}px`),a[c]}),()=>{t.forEach((l,c)=>{l.style.overflow=n[c]??"",l.style.paddingRight=a[c]??""})}},[e])}function JQ(e){return e.actionUrl&&!e.actionType?()=>window.open(e.actionUrl,"_blank","noopener"):KY(e)?()=>VY(e):null}function XQ({open:e,onClose:t,userId:n}){const[a,i]=w.useState(()=>L2().tab),l=w.useRef(L2().scrollTop),[c,u]=w.useState([]),m=w.useRef(null),f=w.useRef(null),[g,h]=w.useState(0),[b,y]=w.useState(null),[k,C]=w.useState("loading"),[T,A]=w.useState("loading"),[M,I]=w.useState(0),[B,G]=w.useState([]),[j,O]=w.useState(!1),[F,Y]=w.useState(!1),[q,V]=w.useState(null),{t:z}=ut(["team","common","home"]),[J,D]=w.useState(!1),[ee,R]=w.useState(!1),[te,le]=w.useState(null),ke=w.useRef(null),$=w.useRef({loading:!1,done:!1,count:0});$.current={loading:J,done:ee,count:c.length};const W=w.useCallback(async je=>{if(n){D(!0);try{const Ye=await Se.notifications.list(n,!1,{limit:I2,offset:je}),xt=Ye.notifications??[];u(ft=>{const rt=new Set(ft.map(jt=>jt.id));return[...ft,...xt.filter(jt=>!rt.has(jt.id))].slice(0,P2)}),h(Ye.totalCount??0);const mt=Ye.unreadCount;y(typeof mt=="number"?mt:null),C(typeof mt=="number"?"ok":"error"),(xt.length===0||xt.length<I2||$.current.count+xt.length>=P2)&&R(!0),le(null)}catch(Ye){le(Ye instanceof Error?Ye.message:z("common:loadFailed")),C("error")}finally{D(!1)}}},[n,z]);w.useEffect(()=>{if(!e||!n)return;const je=()=>{W(0),Se.approvals.list().then(Ye=>{G((Ye.approvals??[]).filter(xt=>xt.status==="pending")),A("ok")}).catch(()=>A("error"))};return window.addEventListener("markus:notifications-changed",je),window.addEventListener("markus:data-changed",je),()=>{window.removeEventListener("markus:notifications-changed",je),window.removeEventListener("markus:data-changed",je)}},[e,n,W]);const oe=w.useCallback(()=>{le(null),C("loading"),A("loading"),I(je=>je+1)},[]),L=w.useCallback(async()=>{if(!(!n||F)){Y(!0),V(null);try{await KQ(n),u(je=>je.map(Ye=>Ye.read?Ye:{...Ye,read:!0})),y(0),C("ok")}catch(je){V(je instanceof Error?je.message:String(je))}finally{Y(!1)}}},[n,F]);w.useEffect(()=>{!e||!n||(u([]),h(0),R(!1),le(null),C("loading"),A("loading"),W(0),Se.approvals.list(void 0,{limit:100}).then(je=>{G((je.approvals??[]).filter(Ye=>Ye.status!=="pending")),A("ok")}).catch(()=>A("error")))},[e,n,W,M]),w.useEffect(()=>{if(!e)return;const je=ke.current;if(!je||typeof IntersectionObserver>"u")return;const Ye=new IntersectionObserver(xt=>{const mt=$.current;!xt[0]?.isIntersecting||mt.loading||mt.done||W(mt.count)},{rootMargin:"120px"});return Ye.observe(je),()=>Ye.disconnect()},[e,W,c.length]);const Ne=w.useMemo(()=>{const je=B.map(mt=>({kind:"approval",at:mt.respondedAt??mt.requestedAt,approval:mt})),Ye=c.map(mt=>({kind:"notice",at:mt.createdAt,notice:mt})),xt=[...je,...Ye].sort((mt,ft)=>(ft.at??"").localeCompare(mt.at??""));return j?xt.filter(mt=>mt.kind==="notice"&&!mt.notice.read):a==="approvals"?xt.filter(mt=>mt.kind==="approval"):a==="notices"?xt.filter(mt=>mt.kind==="notice"):xt},[B,c,a,j]),qe=B.length,me=k==="ok"?b:null,ze=Ne.length===0&&!J&&!te&&T!=="error"&&k!=="error",Ue=j&&k==="ok"&&me===0&&(g>0||c.length>0);return QQ(e),w.useEffect(()=>{if(!e)return;const je=window.setTimeout(()=>{const Ye=m.current;Ye&&(Ye.scrollTop=l.current)},60);return()=>window.clearTimeout(je)},[e,a]),e?o.jsx("div",{ref:f,className:"fixed inset-0 z-50 flex items-start justify-center bg-black/40 p-4 sm:p-6 overflow-hidden overscroll-none",onClick:t,children:o.jsxs("div",{className:"w-full max-w-lg h-[78vh] bg-surface-elevated rounded-2xl shadow-xl overflow-hidden flex flex-col mt-4",onClick:je=>je.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-4 pt-3.5 pb-2 shrink-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:z("home:attention.history")}),k==="error"&&o.jsx("span",{className:"text-[10px] font-semibold px-1.5 py-0.5 rounded-full bg-rose-500/10 text-rose-600",children:z("team:history.unreadUnknown")}),k==="loading"&&o.jsx("span",{className:"text-[10px] text-fg-muted",children:z("team:history.unreadLoading")}),me!==null&&me>0&&o.jsx("button",{onClick:()=>O(je=>!je),"aria-pressed":j,title:z(j?"team:history.showAll":"team:history.onlyUnread"),className:`text-[10px] font-semibold px-1.5 py-0.5 rounded-full tabular-nums transition-colors ${j?"bg-brand-500 text-on-brand":"text-brand-400 bg-brand-500/10 hover:bg-brand-500/20"}`,children:z("team:history.unreadCount",{count:me})}),me!==null&&j&&me===0&&o.jsx("button",{onClick:()=>O(!1),className:"text-[10px] font-semibold text-fg-tertiary bg-surface-overlay px-1.5 py-0.5 rounded-full",children:z("team:history.allReadShowAll")}),me!==null&&me>0&&o.jsx("button",{onClick:()=>{L()},disabled:F,"data-mark-all-read":!0,className:"text-[10px] font-medium text-fg-tertiary hover:text-fg-primary px-1.5 py-0.5 rounded-full hover:bg-surface-overlay transition-colors disabled:opacity-50",children:F?"…":z("team:notifications.markAllRead")})]}),o.jsx("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-surface-overlay text-fg-tertiary","aria-label":z("common:close"),children:o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsx("div",{className:"px-4 pb-2.5 shrink-0 flex items-center gap-1",children:[{id:"all",label:z("common:all"),count:qe+c.length},{id:"approvals",label:z("team:history.tabApprovals"),count:qe},{id:"notices",label:z("team:notifications.notifications"),count:c.length}].map(je=>{const Ye=a===je.id;return o.jsxs("button",{onClick:()=>i(je.id),className:`px-2.5 py-1 rounded-full text-[11px] font-medium transition-colors flex items-center gap-1 ${Ye?"bg-surface-overlay text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:[je.label,je.count>0&&o.jsx("span",{className:"tabular-nums text-fg-muted",children:je.count})]},je.id)})}),o.jsxs("div",{ref:m,onScroll:je=>YQ({tab:a,scrollTop:je.currentTarget.scrollTop}),className:"flex-1 min-h-0 overflow-y-auto overscroll-contain scrollbar-thin px-2 pb-2",children:[q&&o.jsxs("div",{"data-mark-all-error":!0,className:"mx-1 mb-2 rounded-lg bg-rose-500/10 text-rose-600 text-[11px] px-3 py-2 flex items-center gap-2",children:[o.jsx("span",{className:"flex-1",children:z("team:notifications.markAllReadFailed")}),o.jsx("button",{onClick:()=>{L()},disabled:F,className:"shrink-0 rounded bg-rose-500/15 px-2 py-0.5 font-semibold hover:bg-rose-500/25 disabled:opacity-50",children:z("common:retry")})]}),(te||T==="error")&&o.jsxs("div",{className:"mx-1 mb-2 rounded-lg bg-rose-500/10 text-rose-600 text-[11px] px-3 py-2 flex items-center gap-2",children:[o.jsx("span",{className:"flex-1",children:[te?z("team:history.noticesLoadFailed",{error:te}):null,T==="error"?z("team:history.approvalsLoadFailed"):null].filter(Boolean).join(" ")}),o.jsx("button",{onClick:oe,className:"shrink-0 rounded bg-rose-500/15 px-2 py-0.5 font-semibold hover:bg-rose-500/25",children:z("common:retry")})]}),ze&&(Ue?o.jsxs("div",{"data-empty-unread":!0,className:"px-3 py-10 text-center",children:[o.jsx("div",{className:"text-[12px] text-fg-secondary",children:z("team:notifications.noUnread")}),o.jsx("button",{onClick:()=>O(!1),className:"mt-2 rounded-full bg-surface-overlay px-2.5 py-1 text-[11px] text-fg-tertiary hover:text-fg-primary transition-colors",children:z("team:notifications.filterAll")})]}):o.jsxs("div",{className:"px-3 py-10 text-center",children:[o.jsx("div",{className:"text-[12px] text-fg-secondary",children:z("team:history.empty")}),o.jsx("div",{className:"text-[11px] text-fg-muted mt-1",children:z("team:history.emptyHint")})]})),Ne.map(je=>je.kind==="approval"?(()=>{const Ye=D2[je.approval.status]??D2.cancelled,xt=je.approval.respondedAt??je.approval.requestedAt;return o.jsxs("div",{onClick:()=>{t(),ng(je.approval)},title:z("team:history.openTarget"),className:"flex items-center gap-2.5 px-2.5 py-2.5 rounded-xl hover:bg-surface-overlay/50 transition-colors cursor-pointer",children:[o.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Ye.dot}`}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:`text-[10px] font-semibold px-1.5 py-0.5 rounded shrink-0 ${Ye.chip}`,children:z(Ye.labelKey)}),o.jsx("span",{className:"text-xs text-fg-secondary truncate",children:je.approval.title})]}),o.jsxs("div",{className:"text-[11px] text-fg-tertiary mt-0.5 truncate",children:[je.approval.agentName," · ",je.approval.status==="approved"?v2(je.approval)?z("team:history.answered"):z("common:approvalStatus.approved"):je.approval.status==="rejected"?v2(je.approval)?z("team:history.unanswered"):z("common:approvalStatus.rejected"):z(Ye.labelKey)," ",z("team:history.atTime",{time:_2(xt)}),je.approval.respondedAt&&je.approval.requestedAt&&o.jsxs(o.Fragment,{children:[" · ",z("team:history.waited",{duration:mS({waitingSince:je.approval.requestedAt,waitingBasis:"requested"},Date.parse(je.approval.respondedAt))})]})]})]})]},`a:${je.approval.id}`)})():(()=>{const Ye=JQ(je.notice);return o.jsxs("div",{title:Ye?void 0:z("team:history.noTargetHint"),className:`flex items-start gap-2.5 px-2.5 py-2.5 rounded-xl transition-colors ${Ye?"hover:bg-surface-overlay/50 cursor-pointer":""}`,onClick:Ye?()=>{const xt=RS(je.notice,c);u(mt=>mt.map(ft=>xt.has(ft.id)?{...ft,read:!0}:ft)),t(),Ye()}:void 0,children:[o.jsx("span",{className:`w-1.5 h-1.5 rounded-full mt-1.5 shrink-0 ${je.notice.read?"bg-fg-muted/40":"bg-brand-500"}`}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:`text-xs truncate ${je.notice.read?"text-fg-tertiary":"text-fg-primary font-medium"}`,children:[je.notice.title,!Ye&&o.jsx("span",{className:"ml-1.5 align-middle text-[10px] font-normal text-fg-muted",children:z("team:history.infoOnly")})]}),je.notice.body&&o.jsx("div",{className:"text-[11px] text-fg-muted mt-0.5 line-clamp-2 leading-relaxed",children:je.notice.body}),o.jsx("div",{className:"text-[10px] text-fg-muted mt-1",children:_2(je.notice.createdAt)})]})]},`n:${je.notice.id}`)})()),o.jsxs("div",{ref:ke,className:"h-8 flex items-center justify-center",children:[J&&o.jsx("span",{className:"text-[11px] text-fg-muted",children:z("common:loading")}),!J&&ee&&c.length>0&&o.jsx("span",{className:"text-[10px] text-fg-muted",children:z("team:history.noMore")})]})]})]})}):null}function DS(e){const t=e.metadata;if(!(!t||typeof t.i18n!="object"||!t.i18n))return t.i18n}function ZQ(e){return e.replace(/_([a-z])/g,(t,n)=>n.toUpperCase())}function eJ(e,t){const n=DS(e);if(!n?.titleKey)return e.title;const a={...n.titleParams??{}};return t(`team:${n.titleKey}`,{...a,defaultValue:e.title})}function epe(e,t){const n=DS(e);if(!n?.bodyKey)return e.body;const a={};for(const[i,l]of Object.entries(n.bodyParams??{}))if(i==="priority")a[i]=t(`common:priority.${l}`,{defaultValue:l});else if(i==="status"||i==="statusKey"){const c=ZQ(l);a[i]=t(`common:status.${l}`,{defaultValue:c===l?l:t(`common:status.${c}`,{defaultValue:l})})}else a[i]=l;return t(`team:${n.bodyKey}`,{...a,defaultValue:e.body})}const IS={code:o.jsxs(o.Fragment,{children:[o.jsx("polyline",{points:"16 18 22 12 16 6"}),o.jsx("polyline",{points:"8 6 2 12 8 18"})]}),search:o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"11",cy:"11",r:"8"}),o.jsx("path",{d:"m21 21-4.3-4.3"})]}),clipboard:o.jsxs(o.Fragment,{children:[o.jsx("rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}),o.jsx("path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"})]}),"check-circle":o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("path",{d:"m9 12 2 2 4-4"})]}),server:o.jsxs(o.Fragment,{children:[o.jsx("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),o.jsx("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),o.jsx("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),o.jsx("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]}),"file-text":o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),o.jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),o.jsx("path",{d:"M10 9H8"}),o.jsx("path",{d:"M16 13H8"}),o.jsx("path",{d:"M16 17H8"})]}),"book-open":o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M12 7v14"}),o.jsx("path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z"})]}),users:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),o.jsx("circle",{cx:"9",cy:"7",r:"4"}),o.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),o.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),"dollar-sign":o.jsxs(o.Fragment,{children:[o.jsx("line",{x1:"12",x2:"12",y1:"2",y2:"22"}),o.jsx("path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"})]}),megaphone:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"m3 11 18-5v12L3 14v-3z"}),o.jsx("path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6"})]}),edit:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M12 20h9"}),o.jsx("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4Z"})]}),headphones:o.jsx(o.Fragment,{children:o.jsx("path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-5a9 9 0 0 1 18 0v5a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3"})}),settings:o.jsxs(o.Fragment,{children:[o.jsx("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"}),o.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),target:o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("circle",{cx:"12",cy:"12",r:"6"}),o.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),zap:o.jsx(o.Fragment,{children:o.jsx("polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2"})}),terminal:o.jsxs(o.Fragment,{children:[o.jsx("polyline",{points:"4 17 10 11 4 5"}),o.jsx("line",{x1:"12",x2:"20",y1:"19",y2:"19"})]}),sparkles:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .962 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.962 0z"}),o.jsx("path",{d:"M20 3v4"}),o.jsx("path",{d:"M22 5h-4"})]}),wrench:o.jsx(o.Fragment,{children:o.jsx("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})}),globe:o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"}),o.jsx("path",{d:"M2 12h20"})]}),link:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),o.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}),bot:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M12 8V4H8"}),o.jsx("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),o.jsx("path",{d:"M2 14h2"}),o.jsx("path",{d:"M20 14h2"}),o.jsx("path",{d:"M15 13v2"}),o.jsx("path",{d:"M9 13v2"})]}),"message-square":o.jsx(o.Fragment,{children:o.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),newspaper:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2"}),o.jsx("path",{d:"M18 14h-8"}),o.jsx("path",{d:"M15 18h-5"}),o.jsx("path",{d:"M10 6h8v4h-8V6Z"})]}),layers:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z"}),o.jsx("path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65"}),o.jsx("path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65"})]}),"bar-chart":o.jsxs(o.Fragment,{children:[o.jsx("line",{x1:"12",x2:"12",y1:"20",y2:"10"}),o.jsx("line",{x1:"18",x2:"18",y1:"20",y2:"4"}),o.jsx("line",{x1:"6",x2:"6",y1:"20",y2:"16"})]}),folder:o.jsx(o.Fragment,{children:o.jsx("path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"})}),"git-branch":o.jsxs(o.Fragment,{children:[o.jsx("line",{x1:"6",x2:"6",y1:"3",y2:"15"}),o.jsx("circle",{cx:"18",cy:"6",r:"3"}),o.jsx("circle",{cx:"6",cy:"18",r:"3"}),o.jsx("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),save:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"}),o.jsx("path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7"}),o.jsx("path",{d:"M7 3v4a1 1 0 0 0 1 1h7"})]}),camera:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z"}),o.jsx("circle",{cx:"12",cy:"13",r:"3"})]}),clock:o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("polyline",{points:"12 6 12 12 16 14"})]}),database:o.jsxs(o.Fragment,{children:[o.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),o.jsx("path",{d:"M3 5v14a9 3 0 0 0 18 0V5"}),o.jsx("path",{d:"M3 12a9 3 0 0 0 18 0"})]}),lightbulb:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"}),o.jsx("path",{d:"M9 18h6"}),o.jsx("path",{d:"M10 22h4"})]}),"alert-circle":o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),o.jsx("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]}),"square-terminal":o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"m7 11 2-2-2-2"}),o.jsx("path",{d:"M11 13h4"}),o.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"})]}),package:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"m7.5 4.27 9 5.15"}),o.jsx("path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"}),o.jsx("path",{d:"m3.3 7 8.7 5 8.7-5"}),o.jsx("path",{d:"M12 22V12"})]}),inbox:o.jsxs(o.Fragment,{children:[o.jsx("polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12"}),o.jsx("path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"})]}),"circle-pause":o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"10",x2:"10",y1:"15",y2:"9"}),o.jsx("line",{x1:"14",x2:"14",y1:"15",y2:"9"})]}),"circle-x":o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("path",{d:"m15 9-6 6"}),o.jsx("path",{d:"m9 9 6 6"})]}),"clipboard-check":o.jsxs(o.Fragment,{children:[o.jsx("rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}),o.jsx("path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"}),o.jsx("path",{d:"m9 14 2 2 4-4"})]}),"file-check":o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),o.jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),o.jsx("path",{d:"m9 15 2 2 4-4"})]}),bell:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"}),o.jsx("path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0"})]}),"help-circle":o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),o.jsx("path",{d:"M12 17h.01"})]})};function tJ(e){return!!e&&e in IS}function LS({name:e,size:t=24,className:n=""}){const a=IS[e];return a?o.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:n,"aria-hidden":!0,children:a}):null}const O2={"coding-tools":"terminal",markitdown:"file-text","markus-admin-cli":"terminal",codex:"code","team-building":"users","claude-code":"code","skill-building":"wrench","workflow-building":"layers","chrome-devtools":"globe","markus-hub-connector":"link","cursor-agent":"bot","agent-building":"bot","feishu-interaction":"message-square","content-publishing":"edit","research-report":"book-open","daily-digest":"newspaper"},H2={development:"code",开发工具:"code",devops:"server",data:"bar-chart",数据分析:"bar-chart",productivity:"zap",效率提升:"zap",communication:"message-square",通讯协作:"message-square",browser:"globe",内容创作:"edit","AI 智能":"sparkles"};function Zu(e,t){const n=(e||"").toLowerCase();return O2[n]?O2[n]:t&&H2[t]?H2[t]:"layers"}const An={attention:{chip:"bg-violet-500/15 text-violet-500",dot:"bg-violet-500",solid:"bg-violet-500",text:"text-violet-500",border:"border-violet-500/40",surface:"bg-violet-500/[0.06]",btn:"bg-violet-500/10 text-violet-500 hover:bg-violet-500/20",hex:"#8b5cf6"},active:{chip:"bg-blue-500/15 text-blue-500",dot:"bg-blue-500",solid:"bg-blue-500",text:"text-blue-500",border:"border-blue-500/40",surface:"bg-blue-500/[0.06]",btn:"bg-blue-500/10 text-blue-500 hover:bg-blue-500/20",hex:"#3b82f6"},blocked:{chip:"bg-orange-500/15 text-orange-500",dot:"bg-orange-500",solid:"bg-orange-500",text:"text-orange-500",border:"border-orange-500/40",surface:"bg-orange-500/[0.06]",btn:"bg-orange-500/10 text-orange-500 hover:bg-orange-500/20",hex:"#f97316"},success:{chip:"bg-green-500/15 text-green-600",dot:"bg-green-500",solid:"bg-green-500",text:"text-green-600",border:"border-green-500/30",surface:"bg-green-500/[0.06]",btn:"bg-green-500/10 text-green-600 hover:bg-green-500/20",hex:"#22c55e"},danger:{chip:"bg-red-500/15 text-red-500",dot:"bg-red-500",solid:"bg-red-500",text:"text-red-500",border:"border-red-500/40",surface:"bg-red-500/[0.06]",btn:"bg-red-500/10 text-red-500 hover:bg-red-500/20",hex:"#ef4444"},neutral:{chip:"bg-gray-500/15 text-fg-tertiary",dot:"bg-gray-400",solid:"bg-gray-500",text:"text-fg-tertiary",border:"border-border-default/60",surface:"bg-surface-elevated/60",btn:"bg-surface-overlay text-fg-secondary hover:bg-surface-overlay/70",hex:"#6b7280"}};function tp(e,t){return t&&e[t]||"neutral"}const nJ={pending:"neutral",in_progress:"active",blocked:"blocked",review:"attention",revision:"active",completed:"success",failed:"danger",rejected:"danger",cancelled:"neutral",archived:"neutral"},aJ={pending:"attention",in_progress:"active",blocked:"blocked",completed:"success",rejected:"danger",cancelled:"neutral",archived:"neutral"},rJ={active:"active",in_progress:"active",planning:"neutral",paused:"blocked",blocked:"blocked",completed:"success",archived:"neutral",cancelled:"neutral"},iJ={draft:"neutral",pending:"neutral",submitted:"attention",in_review:"attention",review:"attention",approved:"success",published:"success",rejected:"danger",archived:"neutral"};function zc(e){return tp(nJ,e)}function sJ(e){return tp(aJ,e)}function oJ(e){return tp(rJ,e)}function lJ(e){return tp(iJ,e)}function cJ(e,t){switch(e){case"task":return zc(t);case"requirement":return sJ(t);case"project":return oJ(t);case"deliverable":return lJ(t);default:return"neutral"}}const dJ={pending:"pending",in_progress:"inProgress",blocked:"blocked",review:"review",completed:"completed",failed:"failed",rejected:"rejected",cancelled:"cancelled",archived:"archived"};function PS(e){return e==="hold"?"hold":e==="workflow"?"workflow":"deps"}const uJ={deps:"waitingDeps",hold:"onHold",workflow:"workflowPaused"},mJ={deps:{chip:An.neutral.chip,dot:An.neutral.dot,bar:An.neutral.dot,card:`${An.neutral.surface} border-border-default/60`},hold:{chip:An.blocked.chip,dot:An.blocked.dot,bar:An.blocked.dot,card:`${An.blocked.surface} border-orange-500/30 ring-1 ring-orange-500/15`},workflow:{chip:An.neutral.chip,dot:An.neutral.dot,bar:An.neutral.dot,card:`${An.neutral.surface} border-border-default/60`}};function sg(e,t,n){if(!e)return"—";if(e==="blocked"&&n!==void 0&&n!==null)return t(`common:taskStatus.${uJ[PS(n)]}`);const a=dJ[e];return a?t(`common:taskStatus.${a}`):e}function OS(e,t,n){const a=sg(e,t,n);return e==="blocked"&&n!==void 0&&n!==null?{label:a,tone:mJ[PS(n)]}:{label:a,tone:null}}function tpe(e,t,n){if(e!=="blocked"||n===void 0||n===null)return null;const a=OS(e,t,n);return{label:a.label,cls:a.tone?.chip??An.neutral.chip}}function npe(e,t){return t(`agent:profilePage.mind.attention.${e}`)}const pJ={idle:"idle",working:"working",online:"online",offline:"offline",paused:"paused",error:"error"};function ape(e,t){const n=pJ[e];return n?t(`common:processStatus.${n}`):e}function HS(e){return e>=1e9?`${(e/1e9).toFixed(1)}B`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function Cm(e){return e.toLocaleString(void 0,{maximumFractionDigits:0})}function fJ(e,t,n){const[a,i]=w.useState([]),[l,c]=w.useState(null),[u,m]=w.useState(null),[f,g]=w.useState(at.isAuthenticated()),h=w.useCallback(async()=>{try{const k=await Se.usage.agents();i(k.agents)}catch{}},[]),b=w.useCallback(async()=>{if(!at.isAuthenticated()){g(!1),m(null);return}g(!0);try{const[k,C]=await Promise.all([at.user.plan(),Se.hubOrgs.mine().catch(()=>null)]);c(k);const T=C?.orgs?.find(A=>A.id===k.orgId)??C?.orgs?.[0];m(T?{role:T.role,memberCount:T.memberCount??1}:null)}catch{}},[]);return w.useEffect(()=>{if(!e)return;h(),b();const k=setInterval(h,3e4),C={at:0},T=15e3,A=()=>{const M=Date.now();M-C.at<T||(C.at=M,h(),b())};return window.addEventListener("markus:data-changed",A),()=>{clearInterval(k),window.removeEventListener("markus:data-changed",A)}},[e,h,b]),{contributors:w.useMemo(()=>{const k=[],C=new Map;for(const A of n)for(const M of A.members)C.set(M.id,A.name);const T=new Map((t?.agentEfficiency??[]).map(A=>[A.agentId,A]));for(const A of a){const M=T.get(A.agentId),I=A.cuUsed??0,B=A.totalTokens,G=M?.taskMetrics.completed??0,j=B>0?G/B*1e3:G>0?1/0:0;k.push({id:A.agentId,name:A.agentName,type:"agent",role:A.role,teamName:C.get(A.agentId),status:A.status,tasksCompleted:G,tasksFailed:M?.taskMetrics.failed??0,cuUsed:I,cuUsedToday:A.cuUsedToday??0,totalTokens:B,tokensToday:A.tokensUsedToday,requestCount:A.requestCount,toolCalls:A.toolCalls,healthScore:M?.healthScore??0,efficiency:j,provider:A.provider})}return k.sort((A,M)=>M.cuUsed+M.tasksCompleted*100-(A.cuUsed+A.tasksCompleted*100)===0?M.totalTokens-A.totalTokens:M.cuUsed+M.tasksCompleted*100-(A.cuUsed+A.tasksCompleted*100)),k},[a,t,n]),hubPlan:l,hubOrgMeta:u,hubConnected:f}}function og({title:e,badge:t,children:n}){const{t:a}=ut("home"),[i,l]=w.useState(!1);return o.jsxs("section",{className:`bg-surface-elevated shadow-sm rounded-2xl ${i?"overflow-visible":"overflow-hidden"}`,children:[o.jsxs("button",{type:"button",onClick:()=>l(c=>!c),className:"w-full px-4 sm:px-5 py-3.5 flex items-center justify-between gap-3 hover:bg-surface-overlay/40 transition-colors text-left rounded-2xl","aria-expanded":i,children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-primary truncate",children:e}),t]}),o.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-fg-tertiary shrink-0",children:[o.jsx("span",{className:"hidden sm:inline",children:a(i?"usage.trends.collapse":"usage.trends.expand")}),o.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`transition-transform ${i?"rotate-180":""}`,children:o.jsx("polyline",{points:"6 9 12 15 18 9"})})]})]}),i&&o.jsx("div",{className:"rounded-b-2xl overflow-visible",children:n})]})}function hJ({hubConnected:e,hubPlan:t,hubOrgMeta:n}){const{t:a}=ut("home"),i=Oa();if(!e)return o.jsxs("div",{className:"px-4 sm:px-5 pb-4 flex flex-wrap items-center justify-between gap-2",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[o.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-500 shrink-0"}),o.jsx("span",{className:"text-sm text-fg-tertiary",children:a("usage.quota.notConnected")})]}),o.jsx("button",{onClick:()=>at.ensureAuth().catch(()=>{}),className:"px-3 py-1.5 text-xs font-medium bg-brand-600 text-on-brand rounded-lg hover:bg-brand-500 transition-colors shrink-0",children:a("usage.quota.connect")})]});if(!t)return o.jsx("div",{className:"px-4 sm:px-5 pb-4 text-sm text-fg-tertiary",children:a("usage.trends.noData")});const l=t.memberCuLimit!=null&&t.memberCuLimit>0,c=!n||n.role==="owner"||n.role==="admin"||n.memberCount<=1,u=l&&!c,m=(t.monthlyQuotaCu??0)+(t.bonusCu??0)+(t.purchasedCu??0),f=u?t.memberCuLimit:t.creditsBudgetCu??(l?t.memberCuLimit:m),g=u?t.memberCuUsed??0:t.totalConsumedThisPeriod??t.memberCuUsed??0,h=f>0?Math.min(100,Math.round(g/f*100)):0,b=h>90?"bg-red-500":h>70?"bg-amber-500":"bg-brand-500",y=()=>{Or(`${at.getUrl().replace(/\/$/,"")}/settings?tab=billing`)};return o.jsxs("div",{className:"px-4 sm:px-5 pb-4",children:[u&&o.jsx("div",{className:"mb-2 px-3 py-1.5 rounded-lg text-[10px] bg-amber-500/8 text-amber-500/80 border border-amber-500/15",children:a("usage.quota.personalLimit")}),o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-2",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:"text-xs font-semibold text-fg-secondary",children:a(l&&!c?"usage.quota.personalLimitLabel":"usage.quota.title")}),o.jsx("span",{className:"px-1.5 py-0.5 rounded-full text-[10px] font-medium bg-brand-500/10 text-brand-500 uppercase shrink-0",children:t.planType}),i?.username&&o.jsx("span",{className:"text-[10px] text-fg-tertiary truncate",children:a("usage.quota.connectedAs",{username:i.username})})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3 text-[10px] text-fg-tertiary",children:[o.jsx("span",{children:t.cuResetAt?a("usage.quota.resetsAt",{date:new Date(t.cuResetAt).toLocaleDateString()}):""}),o.jsx("button",{type:"button",className:"px-2 py-1 bg-brand-600 text-on-brand rounded hover:bg-brand-500 transition-colors font-medium",onClick:k=>{k.stopPropagation(),y()},children:a("usage.quota.topUp")})]})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"flex-1 h-2 bg-surface-overlay rounded-full overflow-hidden",children:o.jsx("div",{className:`h-full rounded-full transition-all ${b}`,style:{width:`${h}%`}})}),o.jsxs("span",{className:"text-xs text-fg-secondary tabular-nums shrink-0",children:[Cm(g)," / ",Cm(f)]})]})]})}function gJ({contributors:e}){const{t}=ut("home"),[n,a]=w.useState("totalTokens"),[i,l]=w.useState(!0),[c,u]=w.useState(!1),m=10,f=A=>{n===A?l(!i):(a(A),l(!0))},g=w.useMemo(()=>[...e].sort((A,M)=>{const I=A[n]===1/0?999999:A[n],B=M[n]===1/0?999999:M[n];return i?B-I:I-B}),[e,n,i]),h=c?g:g.slice(0,m),b=Math.max(1,...e.map(A=>A.totalTokens)),y=e.some(A=>A.cuUsed>0),k=new Set(e.filter(A=>A.provider).map(A=>A.provider)),T=k.size>1||k.size===1&&!k.has("markus")?o.jsx("span",{className:"text-[10px] text-fg-tertiary bg-surface-overlay px-2 py-0.5 rounded shrink-0",children:t("usage.agents.mixedProviders")}):void 0;return e.length===0?o.jsx(og,{title:t("usage.agents.title"),children:o.jsx("div",{className:"px-4 sm:px-5 pb-6 text-center",children:o.jsx("p",{className:"text-sm text-fg-tertiary",children:t("usage.agents.noData")})})}):o.jsxs(og,{title:t("usage.agents.title"),badge:T,children:[o.jsx("div",{className:"overflow-x-auto scrollbar-thin border-t border-border-default",children:o.jsxs("table",{className:"w-full min-w-[520px]",children:[o.jsx("thead",{children:o.jsxs("tr",{className:"border-b border-border-default text-xs text-fg-tertiary uppercase tracking-wider",children:[o.jsx("th",{className:"px-3 sm:px-4 py-3 text-left font-medium w-8",children:"#"}),o.jsx("th",{className:"px-3 sm:px-4 py-3 text-left font-medium",children:t("usage.agents.name")}),o.jsx("th",{className:"px-3 sm:px-4 py-3 text-left font-medium hidden sm:table-cell",children:t("usage.agents.team")}),o.jsx(lu,{label:t("usage.agents.tasks"),col:"tasksCompleted",current:n,desc:i,onSort:f}),o.jsx(lu,{label:t("usage.agents.tokens"),col:"totalTokens",current:n,desc:i,onSort:f}),y&&o.jsx(lu,{label:t("usage.agents.cuUsed"),col:"cuUsed",current:n,desc:i,onSort:f}),o.jsx(lu,{label:t("usage.agents.efficiency"),col:"efficiency",current:n,desc:i,onSort:f,align:"right"})]})}),o.jsx("tbody",{children:h.map((A,M)=>o.jsx(bJ,{contributor:A,rank:M+1,maxTokens:b,showCu:y},A.id))}),o.jsx("tfoot",{children:o.jsxs("tr",{className:"border-t border-border-default bg-surface-elevated/30",children:[o.jsx("td",{colSpan:2,className:"px-3 sm:px-4 py-3 text-sm font-medium text-fg-secondary sm:hidden",children:t("usage.agents.total",{count:e.length})}),o.jsx("td",{colSpan:3,className:"px-3 sm:px-4 py-3 text-sm font-medium text-fg-secondary hidden sm:table-cell",children:t("usage.agents.total",{count:e.length})}),o.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:e.reduce((A,M)=>A+M.tasksCompleted,0)}),o.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:HS(e.reduce((A,M)=>A+M.totalTokens,0))}),y&&o.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:Cm(e.reduce((A,M)=>A+M.cuUsed,0))}),o.jsx("td",{})]})})]})}),g.length>m&&o.jsx("button",{type:"button",onClick:()=>u(A=>!A),className:"w-full px-4 py-2.5 text-xs font-medium text-brand-500 hover:bg-surface-overlay/40 border-t border-border-default transition-colors",children:c?t("usage.agents.showLess"):t("usage.agents.showAll",{count:g.length})})]})}function bJ({contributor:e,rank:t,maxTokens:n,showCu:a}){const i=n>0?Math.min(100,e.totalTokens/n*100):0,l=e.status==="working"?"bg-blue-500":e.status==="idle"?"bg-green-500":e.status==="error"?"bg-red-500":"bg-gray-500",c=e.tasksCompleted===0?"—":e.totalTokens>0?`${e.efficiency.toFixed(1)}`:"∞",u=t<=3?`${t===1?"text-amber-500":t===2?"text-gray-400":"text-amber-700"} font-bold`:"text-fg-tertiary",m=e.provider==="markus"?"":e.provider??"";return o.jsxs("tr",{className:"border-b border-border-default/50 hover:bg-surface-elevated/30 transition-colors cursor-pointer",onClick:()=>yt.navigate(ce.TEAM,{selectAgent:e.id}),children:[o.jsx("td",{className:`px-3 sm:px-4 py-3 text-sm tabular-nums ${u}`,children:t}),o.jsx("td",{className:"px-3 sm:px-4 py-3",children:o.jsxs("div",{className:"flex items-center gap-2.5",children:[o.jsx("div",{className:`w-2 h-2 rounded-full ${l} shrink-0`}),o.jsxs("div",{className:"min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:e.name}),m&&o.jsx("span",{className:"px-1 py-0.5 rounded text-[8px] font-medium bg-surface-overlay text-fg-tertiary shrink-0",children:m})]}),o.jsxs("div",{className:"text-[10px] text-fg-tertiary truncate",children:[e.role,o.jsx("span",{className:"sm:hidden",children:e.teamName?` · ${e.teamName}`:""})]})]})]})}),o.jsx("td",{className:"px-3 sm:px-4 py-3 text-xs text-fg-tertiary hidden sm:table-cell",children:e.teamName||"—"}),o.jsx("td",{className:"px-3 sm:px-4 py-3",children:o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"text-sm text-fg-secondary tabular-nums",children:e.tasksCompleted}),e.tasksFailed>0&&o.jsxs("span",{className:"text-[10px] text-red-500 tabular-nums",children:["(",e.tasksFailed,")"]})]})}),o.jsx("td",{className:"px-3 sm:px-4 py-3",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"flex-1 h-1.5 bg-surface-overlay rounded-full overflow-hidden max-w-[80px] hidden md:block",children:o.jsx("div",{className:"h-full bg-indigo-500 rounded-full transition-all",style:{width:`${i}%`}})}),o.jsx("span",{className:"text-sm text-fg-secondary tabular-nums",children:HS(e.totalTokens)})]})}),a&&o.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm text-fg-secondary tabular-nums",children:e.cuUsed>0?Cm(e.cuUsed):o.jsx("span",{className:"text-fg-tertiary",children:"—"})}),o.jsx("td",{className:"px-3 sm:px-4 py-3 text-right",children:o.jsx("span",{className:`text-sm font-medium tabular-nums ${e.tasksCompleted===0?"text-fg-tertiary":e.efficiency>5?"text-green-500":e.efficiency>1?"text-fg-secondary":"text-amber-500"}`,children:c})})]})}function lu({label:e,col:t,current:n,desc:a,onSort:i,align:l}){const c=n===t?a?"↓":"↑":"↕",u=n===t?"text-brand-500":"text-fg-muted";return o.jsxs("th",{className:`px-3 sm:px-4 py-3 ${l==="right"?"text-right":"text-left"} font-medium cursor-pointer select-none hover:text-fg-secondary`,onClick:()=>i(t),children:[e,o.jsx("span",{className:`ml-1 ${u}`,children:c})]})}function yJ({contributors:e,hubPlan:t,hubOrgMeta:n,hubConnected:a,showMarkusUsage:i}){const{t:l}=ut("home");return o.jsxs("div",{className:"space-y-3",children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-tertiary px-0.5",children:l("usage.sectionTitle")}),i&&o.jsx(og,{title:l("usage.creditsTitle"),children:o.jsx(hJ,{hubConnected:a,hubPlan:t,hubOrgMeta:n})}),o.jsx(gJ,{contributors:e})]})}const vJ="(max-width: 767px)";let $h=null;function BS(){return $h||($h=window.matchMedia(vJ)),$h}function xJ(e){const t=BS();return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function wJ(){return BS().matches}function kJ(){return!1}const SJ=w.createContext(!1);function Xo(){const e=w.useContext(SJ),t=w.useSyncExternalStore(xJ,wJ,kJ);return e?!1:t}const CJ="markus_onboarded";function ob(e){return`markus_onboarded_${e}`}function zS(e){return`markus_checklist_dismissed_${e}`}function lg(e){try{return localStorage.getItem(ob(e))!==null?!0:localStorage.getItem(CJ)!==null}catch{return!1}}function cg(e){try{localStorage.setItem(ob(e),"1")}catch{}}function B2(e){try{localStorage.removeItem(ob(e))}catch{}}function AJ(e){try{return localStorage.getItem(zS(e))==="true"}catch{return!1}}function TJ(e){try{localStorage.setItem(zS(e),"true")}catch{}}function z2(e){return{configured:Object.values(e.providers).some(t=>t.configured),markus:!!e.providers.markus?.configured,providerLabel:e.providers[e.defaultProvider]?.displayName??e.defaultProvider??""}}const EJ=Object.fromEntries(["completed","in_progress","review","pending","failed","blocked","rejected","cancelled"].map(e=>[e,An[zc(e)].hex])),NJ=e=>An[zc(e)].dot,qS=["completed","in_progress","review","pending","failed","blocked","rejected","cancelled"],Fh={agent_question:{tone:"attention",iconName:"help-circle"},approval_request:{tone:"attention",iconName:"check-circle"},requirement_approval:{tone:"attention",iconName:"file-check"},task_review:{tone:"attention",iconName:"clipboard-check"},blocked_hold:{tone:"blocked",iconName:"circle-pause"},task_failed:{tone:"danger",iconName:"circle-x"},unread_message:{tone:"neutral",iconName:"message-square"}},q2={urgent:An.danger.chip,high:"bg-surface-overlay text-fg-secondary font-semibold",medium:"bg-surface-overlay text-fg-secondary",low:"bg-surface-overlay text-fg-tertiary",none:"bg-surface-overlay text-fg-tertiary"},MJ=Object.fromEntries(["completed","in_progress","review","pending","failed","blocked","rejected","cancelled"].map(e=>[e,An[zc(e)].chip])),$2={"Heartbeat check-in":"agentFocus.heartbeatCheckIn","Heartbeat check-in (idle skip)":"agentFocus.heartbeatSkip"},jJ={thinking:`${An.active.dot} animate-pulse`,running:`${An.active.dot} animate-pulse`,"waiting-dependency":`${An.blocked.dot} animate-pulse`,blocked:`${An.danger.dot} animate-pulse`,degraded:`${An.danger.dot} animate-pulse`,error:"bg-red-500 animate-pulse",idle:"bg-green-400",offline:"bg-gray-400"},F2={thinking:"agentFocus.phaseThinking",running:"agentFocus.phaseRunning","waiting-dependency":"agentFocus.phaseWaitingDep",blocked:"agentFocus.phaseBlocked",degraded:"agentFocus.phaseDegraded",error:"agentFocus.phaseError"};function U2({authUser:e,previewMode:t,previewData:n}={}){const{t:a}=ut(["home","common","team"]),i=Xo(),l=jQ(ce.HOME),[c,u]=w.useState(!1);w.useEffect(()=>fY(()=>u(!0)),[]);const[m,f]=w.useState(n?.agents??[]),[g,h]=w.useState(n?.teams??[]),[b,y]=w.useState(n?.board??{}),[k,C]=w.useState(n?.boardCounts??{}),[T,A]=w.useState(n?.ops??null),M="7d",[I,B]=w.useState(n?.requirements??[]),[G,j]=w.useState(n?.projects??[]),[O,F]=w.useState(n?.deliverableTotal??0),[Y,q]=w.useState([]),[V,z]=w.useState(n?.storageInfo??null),[J,D]=w.useState(n?.usageInfo??null),[ee,R]=w.useState(null),[te,le]=w.useState(!1),[ke,$]=w.useState(!1),[W,oe]=w.useState(!1),[L,Ne]=w.useState(null),[qe,me]=w.useState(!1),[ze,Ue]=w.useState(""),[je,Ye]=w.useState(!1),[xt,mt]=w.useState(null),[ft,rt]=w.useState(!1),jt=w.useRef(!1);jt.current=ft;const[ht,He]=w.useState(!1),[Et,Kt]=w.useState(()=>e?.id?sb(e.id):!1),ie=e?.id,[tt,it]=w.useState(()=>e?.id?lg(e.id)||e.preferences?.guideHidden===!0:!0),[,xe]=w.useState(0),Me=ie?AJ(ie):!1,[Ie,ne]=w.useState(!1),[U,re]=w.useState(!1),Ce=w.useRef(null);w.useEffect(()=>{const ge=()=>Kt(!0);return window.addEventListener("markus:shortcut-lesson-complete",ge),()=>window.removeEventListener("markus:shortcut-lesson-complete",ge)},[Kt]);const Pe=w.useCallback(()=>{Ye(!0),Se.cu.status().then(R).catch(()=>{}),Se.settings.getLlm().then(ge=>{const pe=z2(ge);Ne(pe.configured),me(pe.markus),Ue(pe.providerLabel)}).catch(()=>{}),window.dispatchEvent(new CustomEvent("markus:data-changed")),window.setTimeout(()=>{window.dispatchEvent(new CustomEvent("markus:data-changed"))},800)},[]);w.useEffect(()=>{if(!te)return;const ge=pe=>{Ce.current&&!Ce.current.contains(pe.target)&&le(!1)};return document.addEventListener("mousedown",ge),()=>document.removeEventListener("mousedown",ge)},[te]),w.useEffect(()=>{!t||!n||(n.agents&&f(n.agents),n.teams&&h(n.teams),n.board&&y(n.board),n.boardCounts&&C(n.boardCounts),A(n.ops??null),B(n.requirements??[]),j(n.projects??[]),F(n.deliverableTotal??0),n.storageInfo&&z(n.storageInfo),n.usageInfo&&D(n.usageInfo))},[t,n]);const $e=w.useCallback(()=>{const ge=Se.agents.list().then(Dt=>{f(Dt.agents);const dn=Dt.agents.find(Lt=>Lt.role==="secretary")??Dt.agents.find(Lt=>Lt.name?.toLowerCase().includes("secretary"));dn&&Se.sessions.listByAgent(dn.id,20).then(async Lt=>{if(Lt.sessions.length===0){ne(!1);return}const fn=ie?Lt.sessions.filter(gr=>gr.userId===ie):Lt.sessions;if(fn.length===0){ne(!1);return}const Aa=await Se.sessions.getMessages(fn[0].id,1);ne(Aa.messages.length>0)}).catch(()=>{})}).catch(()=>{}),pe=Se.teams.list().then(Dt=>h(Dt.teams)).catch(()=>{});Se.tasks.boardSummary().then(Dt=>{y(Dt.board),C(Dt.counts)}).catch(()=>{}),Se.ops.dashboard(M).then(A).catch(()=>{});const Ze=Se.requirements.list({lean:!0}).then(Dt=>B(Dt.requirements)).catch(()=>{}),St=Se.projects.list().then(Dt=>j(Dt.projects)).catch(()=>{});Se.deliverables.search({limit:18}).then(Dt=>{F(Dt.total);const dn=new Map;for(const Lt of Dt.results){const fn=Lt.reference,Aa=dn.get(fn);(!Aa||Lt.updatedAt>Aa.updatedAt)&&dn.set(fn,Lt)}q([...dn.values()].sort((Lt,fn)=>fn.updatedAt.localeCompare(Lt.updatedAt)).slice(0,6))}).catch(()=>{}),Se.usage.summary().then(Dt=>D(Dt.usage)).catch(()=>{}),Se.cu.status().then(R).catch(()=>{});const Ut=Se.settings.getLlm().then(Dt=>{const dn=z2(Dt);Ne(dn.configured),me(dn.markus),Ue(dn.providerLabel)}).catch(()=>{}),ln=Se.settings.getBrowser().then(Dt=>{mt(Dt.extensionConnected)}).catch(()=>{}),jn=IY().then(Dt=>{if(!Dt&&!Tn()){Ye(!1);return}return at.user.claimFreeCreditsStatus().then(dn=>Ye(!!dn.claimed)).catch(()=>{})}).catch(()=>{});Promise.race([Promise.allSettled([ge,pe,Ze,St,Ut,ln,jn]),new Promise(Dt=>setTimeout(Dt,8e3))]).then(()=>{re(!0)})},[M,ie]);w.useEffect(()=>{!W||V||Se.system.storage().then(z).catch(()=>{})},[W,V]);const ue=w.useCallback(()=>{ie&&(cg(ie),it(!0),Se.auth.updatePreferences({guideHidden:!0}).catch(()=>{}))},[ie]),he=w.useCallback(ge=>{const pe=m.find(Ze=>Ze.role==="secretary")??m.find(Ze=>Ze.name?.toLowerCase().includes("secretary"));yt.navigate(ce.TEAM,{...pe?{agentId:pe.id}:{},prefillMessage:ge})},[m]),dt=!!Tn()||qe,Je=L===!0||qe,ot=[...dt?[{id:"claim",done:je,isSetup:!0,label:a("checklist.setup.claim"),desc:a("checklist.setup.claimDesc"),action:a("checklist.setup.claimAction"),onClick:()=>{rt(!0)}}]:[],{id:"llm",done:Je,isSetup:!0,label:a("checklist.setup.llm"),desc:Je&&ze?a("checklist.setup.llmDescConfigured",{provider:ze}):a(dt?"checklist.setup.llmDescHub":"checklist.setup.llmDesc"),action:a("checklist.setup.llmAction"),onClick:()=>{window.location.hash="#settings/providers"}},{id:"browser",done:xt===!0,isSetup:!0,optional:!0,label:a("checklist.setup.browser"),desc:a("checklist.setup.browserDesc"),action:a("checklist.setup.browserAction"),onClick:()=>{window.location.hash="#settings/browser"}}],Ft=[{id:"greet",done:Ie,label:a("checklist.explore.greet"),desc:a("checklist.explore.greetDesc"),action:a("checklist.explore.greetAction"),onClick:()=>he(a("checklist.explore.greetPrompt"))},{id:"project",done:ie?G.some(ge=>ge.createdBy===ie):G.length>0,label:a("checklist.explore.project"),desc:a("checklist.explore.projectDesc"),action:a("checklist.explore.projectAction"),onClick:()=>he(a("checklist.explore.projectPrompt"))},{id:"requirements",done:ie?I.some(ge=>ge.createdBy===ie):I.length>0,label:a("checklist.explore.requirements"),desc:a("checklist.explore.requirementsDesc"),action:a("checklist.explore.requirementsAction"),onClick:()=>he(a("checklist.explore.requirementsPrompt"))},{id:"team",done:g.length>0,label:a("checklist.explore.team"),desc:a("checklist.explore.teamDesc"),action:a("checklist.explore.teamAction"),onClick:()=>he(a("checklist.explore.teamPrompt"))},{id:"shortcuts",done:Et,label:a("checklist.explore.shortcuts"),desc:a("checklist.explore.shortcutsDesc"),action:a("checklist.explore.shortcutsAction"),onClick:()=>He(!0)}],cn=[...ot,...Ft],Ot=cn.filter(ge=>ge.done).length,Ee=cn.length,_e=ot.filter(ge=>!ge.optional).every(ge=>ge.done)&&Ft.every(ge=>ge.done),De=ot.some(ge=>!ge.optional&&!ge.done),Q=()=>{ie&&(TJ(ie),De?xe(ge=>ge+1):ue())};w.useEffect(()=>{!U||tt||_e&&ue()},[U,tt,_e,ue]),w.useEffect(()=>{if(t||!l)return;$e();const ge=setInterval($e,6e4),pe={at:0},Ze=15e3,St=()=>{const ln=Date.now();ln-pe.at<Ze||(pe.at=ln,$e())},Ut=()=>{if(jt.current){at.user.claimFreeCreditsStatus().then(ln=>Ye(!!ln.claimed)).catch(()=>{});return}$e()};return window.addEventListener("markus:data-changed",St),window.addEventListener("markus:hub-auth",Ut),()=>{clearInterval(ge),window.removeEventListener("markus:data-changed",St),window.removeEventListener("markus:hub-auth",Ut)}},[t,M,l,$e]);const be={},Te=Object.keys(k).length>0?k:Object.fromEntries(Object.entries(b).map(([ge,pe])=>[ge,pe.length]));for(const[ge,pe]of Object.entries(Te))ge!=="archived"&&pe>0&&(be[ge]=pe);const Xe=be.completed??0,wt=Object.values(be).reduce((ge,pe)=>ge+pe,0),lt=m.filter(ge=>{const pe=ge.runtime?.phase;return pe?pe!=="idle"&&pe!=="offline":ge.status==="working"}).length,nt=G.filter(ge=>ge.status==="active").length,Ct=wt>0?Math.round(Xe/wt*100):0,vn=qS.filter(ge=>(be[ge]??0)>0).map(ge=>({status:ge,count:be[ge]})),xn=w.useMemo(()=>{const ge={};return I.forEach(pe=>{ge[pe.status]=(ge[pe.status]??0)+1}),ge},[I]),Xn=w.useMemo(()=>{const ge=new Map(m.map(pe=>[pe.id,pe]));return g.map(pe=>{const Ze=pe.members.filter(St=>St.type==="agent").map(St=>ge.get(St.id)).filter(St=>!!St);return{team:pe,agents:Ze,working:Ze.filter(St=>St.status==="working").length,total:Ze.length}})},[g,m]),ga=m.filter(ge=>{const pe=ge.runtime?.phase;return pe?pe!=="idle"&&pe!=="offline":ge.status==="working"}),yi=!(L===!0&&!qe),ba=fJ(!t&&l,T,g);t||yt.navigate;const Mn=w.useMemo(()=>{const ge=new Map;for(const pe of Object.values(b))for(const Ze of pe)ge.set(Ze.id,Ze);return ge},[b]),[Zn,kr]=w.useState([]),[Sr,Ks]=w.useState([]),[$r]=w.useState(()=>sQ());w.useEffect(()=>{if(t||!l)return;let ge=!0;const pe=()=>{Se.approvals.list().then(Ze=>{ge&&kr(Ze.approvals??[])}).catch(()=>{}),e?.id&&Se.notifications.list(e.id,!0,{limit:20}).then(Ze=>{ge&&Ks(Ze.notifications??[])}).catch(()=>{})};return pe(),window.addEventListener("markus:notifications-changed",pe),()=>{ge=!1,window.removeEventListener("markus:notifications-changed",pe)}},[t,l,e?.id]);const ss=w.useMemo(()=>Object.values(b).flat(),[b]),ra=w.useMemo(()=>uS({tasks:ss,requirements:I,approvals:Zn,notifications:Sr,taskById:ge=>Mn.get(ge),lastSeenAt:$r,notifyTitle:ge=>eJ(ge,a)}),[ss,I,Zn,Sr,Mn,$r,a]),vi=w.useMemo(()=>ra.filter(ge=>ge.isNew).length,[ra]),[ia,fr]=w.useState(()=>Date.now());w.useEffect(()=>{const ge=window.setInterval(()=>fr(Date.now()),6e4);return()=>window.clearInterval(ge)},[]),w.useEffect(()=>{if(t||!l)return;const ge=window.setTimeout(()=>oQ(new Date().toISOString()),3e3);return()=>window.clearTimeout(ge)},[t,l,ra.length]);const Cr=w.useCallback(ge=>{const pe=ge.notices?.[0];pe&&RS(pe,Sr),yt.navigate(ge.target.page==="WORK"?ce.WORK:ce.TEAM,ge.target.params)},[Sr]),Ar=w.useMemo(()=>{const ge=new Map;for(const pe of Object.values(b))for(const Ze of pe)Ze.priority&&ge.set(Ze.id,Ze.priority);return ge},[b]),In=w.useMemo(()=>{const ge=new Map;for(const pe of m)ge.set(pe.id,pe.name);return ge},[m]),{activityLimit:Vs,teamsLimit:hr}=w.useMemo(()=>{const ge=(G.length>0?1:0)+(I.length>0?1:0)+(O>0?1:0),pe=wt>0?6+ge:0,Ze=pe>0?2:0,Ut=pe+Ze+2,ln=Xn.length>0?2+Xn.length:0,jn=Math.max(ln,4),Dt=ga.length,dn=Dt>0?8:12,Lt=Math.max(0,jn-Ut);let fn=Dt>0?Math.max(Dt,Lt):Lt;fn=Math.max(3,Math.min(dn,fn));const Aa=Ut+Math.max(Dt,fn);let gr=Xn.length;if(jn>Aa+2){const Fr=jn-Aa;gr=Math.max(2,Xn.length-Fr)}else if(Aa>jn+2){const Fr=Aa-jn;fn=Math.max(3,fn-Fr)}return{activityLimit:fn,teamsLimit:gr}},[Xn,wt,G,I,O,ga]);return o.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-thin",children:[o.jsxs("div",{"data-electron-drag":!0,className:`flex items-center justify-between px-4 sm:px-6 lg:px-8 h-14 sm:h-16 ${t?"":"max-w-7xl mx-auto"} w-full`,children:[o.jsxs("div",{className:"flex items-center gap-2",children:[i&&o.jsx(ES,{}),o.jsxs("div",{children:[o.jsx("h2",{className:"text-base sm:text-lg font-bold",children:a("title")}),o.jsx("p",{className:"text-xs text-fg-tertiary hidden sm:block",children:a("subtitle")})]})]}),o.jsxs("div",{"data-no-drag":!0,className:"flex items-center gap-1.5",children:[o.jsx("button",{onClick:()=>t?void 0:i?yt.navigate(ce.SEARCH):window.dispatchEvent(new CustomEvent("markus:open-search")),className:"p-2 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary","aria-label":a("search"),children:o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("circle",{cx:"11",cy:"11",r:"8"}),o.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}),o.jsx(HJ,{ref:Ce,show:te,onToggle:()=>le(!te),onClose:()=>le(!1),t:a,isMobile:i})]})]}),o.jsxs("div",{className:`px-4 sm:px-6 lg:px-8 pb-8 space-y-6 ${t?"":"max-w-7xl mx-auto"} w-full`,children:[o.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[o.jsx(cu,{label:a("metricCards.working"),value:String(lt),sub:`/${m.length}`,icon:o.jsx(du,{type:"working"}),pulse:lt>0,onClick:()=>$(!0)}),o.jsx(cu,{label:a("metricCards.tasksDone"),value:`${Xe}`,sub:`/${wt}`,icon:o.jsx(du,{type:"tasks"}),onClick:()=>yt.navigate(ce.WORK)}),o.jsx(cu,{label:a("metricCards.projects"),value:String(nt),icon:o.jsx(du,{type:"projects"}),onClick:()=>yt.navigate(ce.WORK)}),o.jsx(cu,{label:a("metricCards.health"),value:`${L===!1?100:T?.systemHealth.overallScore??"—"}`,sub:L===!1||T?"%":void 0,icon:o.jsx(du,{type:"health"}),color:L===!1?"green":T?T.systemHealth.overallScore>=80?"green":T.systemHealth.overallScore>=50?"amber":"red":void 0,onClick:()=>oe(!0)})]}),!t&&o.jsxs("div",{className:"bg-gradient-to-r from-amber-500/5 via-surface-elevated to-surface-elevated border border-amber-500/20 rounded-2xl overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between px-5 pt-4 pb-2",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-500 shrink-0"}),o.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:a("attention.title")}),ra.length>0&&o.jsx("span",{className:"text-[11px] text-fg-tertiary tabular-nums",children:ra.length}),vi>0&&o.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-semibold bg-brand-500/15 text-brand-500 shrink-0",children:a("attention.newCount",{count:vi})})]}),o.jsx("button",{onClick:()=>u(!0),className:"text-[11px] font-medium text-fg-tertiary hover:text-fg-primary transition-colors shrink-0",children:a("attention.history")})]}),ra.length===0?o.jsx("div",{className:"px-5 pb-4 text-xs text-fg-tertiary",children:a("attention.allClear")}):o.jsxs("div",{className:"px-3 pb-2 space-y-1",children:[ra.slice(0,5).map(ge=>o.jsxs("button",{onClick:()=>Cr(ge),className:"w-full flex items-start gap-2.5 px-3 py-2.5 rounded-xl hover:bg-surface-overlay/40 transition-colors text-left",children:[o.jsx("span",{className:`w-1 self-stretch rounded-full shrink-0 ${ge.isNew?"bg-brand-500":"bg-transparent"}`}),o.jsx("span",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${An[Fh[ge.kind].tone].chip}`,children:o.jsx(LS,{name:Fh[ge.kind].iconName,size:15})}),o.jsxs("span",{className:"flex-1 min-w-0",children:[o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs font-medium text-fg-primary truncate",children:ge.title}),ge.priority!=="none"&&o.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-semibold ${q2[ge.priority]??q2.none}`,children:ge.priority})]}),o.jsxs("span",{className:"mt-0.5 flex items-center gap-1.5 text-[11px] text-fg-tertiary",children:[o.jsx("span",{className:"shrink-0",children:a(`attention.kind.${ge.kind}`)}),o.jsx("span",{children:"·"}),o.jsx("span",{className:"tabular-nums shrink-0",children:mS(ge,ia)}),ge.meta&&o.jsxs(o.Fragment,{children:[o.jsx("span",{children:"·"}),o.jsx("span",{className:"truncate",children:ge.meta})]})]})]}),o.jsx("span",{className:`shrink-0 text-[11px] font-medium px-2.5 py-1 rounded-lg transition-colors ${An[Fh[ge.kind].tone].btn}`,children:a(`attention.act.${ge.kind}`)})]},ge.id)),ra.length>5&&o.jsx("button",{onClick:()=>u(!0),className:"w-full text-[11px] text-fg-tertiary hover:text-fg-primary px-3 py-2 text-left",children:a("attention.more",{count:ra.length-5})})]})]}),!t&&o.jsx(XQ,{open:c,onClose:()=>u(!1),userId:e?.id}),Y.length>0&&o.jsxs("div",{className:"bg-surface-elevated shadow-sm rounded-2xl overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-3",children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:a("recentDeliverables.title")}),o.jsx("button",{onClick:()=>yt.navigate(ce.DELIVERABLES),className:"text-[11px] text-brand-400 hover:text-brand-300 font-medium",children:a("common:viewAll")})]}),o.jsx("div",{className:"px-3 pb-3",children:o.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-1",children:Y.map(ge=>o.jsxs("div",{className:"flex items-start gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay/40 cursor-pointer transition-colors",onClick:()=>yt.navigate(ce.DELIVERABLES,{openDeliverable:ge.id}),children:[o.jsx("span",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 mt-0.5 ${ge.artifactType?"bg-brand-500/10":ge.type==="directory"?"bg-blue-500/10":"bg-green-500/10"}`,children:o.jsx(LJ,{type:ge.type,artifactType:ge.artifactType})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-xs font-medium text-fg-primary truncate",children:ge.title}),o.jsx("div",{className:"text-[11px] text-fg-tertiary truncate mt-0.5",children:ge.summary}),o.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[ge.agentId&&In.get(ge.agentId)&&o.jsx("span",{className:"text-[10px] text-fg-muted",children:In.get(ge.agentId)}),o.jsx("span",{className:"text-[10px] text-fg-muted",children:K2(ge.updatedAt,a)}),ge.status==="verified"&&o.jsx("span",{className:"text-[10px] text-blue-500 font-medium",children:a("common:verified")})]})]}),ge.diffStats&&o.jsxs("div",{className:"text-[10px] text-fg-muted shrink-0 mt-1 tabular-nums",children:[o.jsxs("span",{className:"text-green-500",children:["+",ge.diffStats.additions]})," ",o.jsxs("span",{className:"text-red-500",children:["-",ge.diffStats.deletions]})]})]},ge.id))})})]}),U&&!tt&&!_e&&(()=>{if(Me&&!De)return null;const ge=pe=>o.jsxs("div",{className:"flex items-start gap-3 py-2.5 px-3 rounded-lg hover:bg-surface-elevated/50 transition-colors group",children:[o.jsx("div",{className:`mt-0.5 shrink-0 w-5 h-5 rounded-full flex items-center justify-center ${pe.done?"bg-green-500":"border-2 border-border-default"}`,children:pe.done&&o.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:`text-xs font-medium ${pe.done?"text-fg-tertiary line-through":"text-fg-primary"}`,children:pe.label}),"optional"in pe&&pe.optional&&o.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-surface-elevated text-fg-muted font-medium",children:a("checklist.setup.optional")})]}),o.jsx("p",{className:`text-[11px] mt-0.5 ${pe.done?"text-fg-muted":"text-fg-tertiary"}`,children:pe.desc})]}),pe.done&&pe.isSetup?o.jsx("button",{onClick:pe.onClick,className:"shrink-0 text-[11px] px-3 py-1.5 rounded-lg border border-border-default hover:bg-surface-elevated text-fg-secondary font-medium transition-colors opacity-0 group-hover:opacity-100",children:a("checklist.setup.update")}):pe.done?null:o.jsx("button",{onClick:pe.onClick,className:"shrink-0 text-[11px] px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand font-medium transition-colors opacity-80 group-hover:opacity-100",children:pe.action})]},pe.id);return o.jsxs("div",{className:"bg-gradient-to-br from-brand-600/10 via-surface-secondary to-surface-secondary border border-brand-500/20 rounded-2xl p-5 sm:p-6",children:[o.jsxs("div",{className:"flex items-start justify-between mb-4",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-primary mb-1",children:a("checklist.title")}),o.jsx("p",{className:"text-xs text-fg-secondary",children:a("checklist.subtitle")})]}),o.jsx("button",{onClick:Q,className:"text-fg-muted hover:text-fg-secondary transition-colors p-1 -mr-1 -mt-1",title:a("dismiss"),children:o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),o.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[o.jsx("div",{className:"flex-1 h-1.5 bg-surface-elevated rounded-full overflow-hidden",children:o.jsx("div",{className:"h-full bg-brand-500 rounded-full transition-all duration-500",style:{width:`${Ot/Ee*100}%`}})}),o.jsx("span",{className:"text-[11px] text-fg-secondary font-medium shrink-0",children:a("checklist.progress",{done:Ot,total:Ee})})]}),o.jsxs("div",{className:"mb-4",children:[o.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1 px-3",children:a("checklist.setup.title")}),o.jsx("div",{className:"space-y-0.5",children:ot.map(ge)})]}),o.jsx("div",{className:"border-t border-border-default/50 my-3"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1 px-3",children:a("checklist.explore.title")}),o.jsx("div",{className:"space-y-0.5",children:Ft.map(ge)})]})]})})(),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[o.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[wt>0&&o.jsxs("div",{className:"bg-surface-elevated shadow-sm rounded-2xl overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-3",children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:a("globalOverview.title")}),o.jsx("button",{onClick:()=>yt.navigate(ce.WORK),className:"text-[11px] text-brand-400 hover:text-brand-300 font-medium",children:a("common:viewAll")})]}),o.jsxs("div",{className:"px-5 py-4 flex flex-col sm:flex-row items-center gap-6 border-t border-border-subtle/50",children:[o.jsx(_J,{statusCounts:be,total:wt,completionRate:Ct,completed:Xe}),o.jsx("div",{className:"flex-1 min-w-0",children:o.jsx("div",{className:"grid grid-cols-2 gap-x-5 gap-y-2.5",children:vn.map(({status:ge,count:pe})=>o.jsxs("button",{onClick:()=>yt.navigate(ce.WORK,{statusFilter:ge}),className:"flex items-center gap-2 group cursor-pointer text-left",children:[o.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${NJ(ge)}`}),o.jsx("span",{className:"text-xs text-fg-tertiary group-hover:text-fg-secondary transition-colors",children:sg(ge,a)}),o.jsx("span",{className:"text-sm font-semibold text-fg-primary ml-auto tabular-nums",children:pe})]},ge))})})]}),o.jsxs("div",{className:"divide-y divide-border-subtle/50",children:[G.length>0&&o.jsx(Uh,{icon:"folder",label:a("globalOverview.projects"),value:G.length,onClick:()=>yt.navigate(ce.WORK),children:o.jsxs(G2,{children:[nt," ",a("globalOverview.active")]})}),I.length>0&&o.jsx(Uh,{icon:"edit",label:a("globalOverview.requirements"),value:I.length,onClick:()=>yt.navigate(ce.WORK),children:["in_progress","pending","completed"].map(ge=>(xn[ge]??0)>0&&o.jsxs(G2,{children:[xn[ge]," ",sg(ge,a)]},ge))}),O>0&&o.jsx(Uh,{icon:"book",label:a("globalOverview.deliverables"),value:O,onClick:()=>yt.navigate(ce.DELIVERABLES)})]})]}),(ga.length>0||T&&T.taskKPI.recentActivity.length>0)&&o.jsx("div",{className:"bg-surface-elevated shadow-sm rounded-2xl overflow-hidden",children:o.jsxs("div",{className:`grid grid-cols-1 ${ga.length>0&&T&&T.taskKPI.recentActivity.length>0?"sm:grid-cols-2 divide-y sm:divide-y-0 sm:divide-x divide-border-subtle/50":""}`,children:[ga.length>0&&o.jsxs("div",{className:"p-5",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[o.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 animate-pulse"}),o.jsx("h4",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:a("liveActivity.whosWorking")})]}),o.jsx("div",{className:"space-y-1",children:ga.map(ge=>{const pe=ge.runtime,Ze=pe?.phase??(ge.status==="idle"?"idle":ge.status==="offline"?"offline":"running"),St=jJ[Ze]??"bg-blue-400 animate-pulse";return o.jsxs("div",{className:"flex items-center gap-2.5 px-2 py-2 rounded-lg hover:bg-surface-overlay/40 cursor-pointer transition-colors",onClick:()=>yt.navigate(ce.TEAM,{agentId:ge.id}),children:[o.jsx(Go,{name:ge.name,avatarUrl:ge.avatarUrl,size:24,bgClass:"bg-brand-600/30 text-brand-300"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[o.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${St}`}),o.jsx("span",{className:"text-xs font-medium text-fg-primary truncate",children:ge.name}),F2[Ze]&&o.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:a(F2[Ze])}),pe?.stall?.stalled&&o.jsx("span",{title:pe.stall.stuckReason,className:`text-[10px] font-semibold px-1.5 py-0.5 rounded-full shrink-0 ${pe.stall.stallKind==="dead-dependency"?"bg-amber-500/20 text-amber-400 border border-amber-500/30":"bg-sky-500/15 text-sky-300 border border-sky-500/25"}`,children:pe.stall.stallKind==="dead-dependency"?a("agentFocus.stallDeadBadge"):a("agentFocus.stallStaleBadge")}),pe?.dirty?.dirty&&(()=>{const Ut=pe.dirty.recovery==="human-review";return o.jsx("span",{className:`inline-flex items-center px-1.5 py-px rounded text-[9px] font-medium shrink-0 ${Ut?"bg-amber-500/15 text-amber-300":"bg-emerald-500/15 text-emerald-300"}`,children:a(Ut?"liveActivity.dirtyNeedsHuman":"liveActivity.dirtyRecovered")})})()]}),o.jsx("div",{className:"text-[10px] text-fg-tertiary truncate",children:zJ(ge,a)})]})]},ge.id)})})]}),T&&T.taskKPI.recentActivity.length>0&&o.jsxs("div",{className:"p-5",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsx("h4",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:a("liveActivity.recentChanges")}),o.jsx("button",{onClick:()=>yt.navigate(ce.WORK),className:"text-[11px] text-brand-400 hover:text-brand-300 font-medium",children:a("common:viewAll")})]}),o.jsx("div",{className:`${ga.length>0?"":"grid grid-cols-1 sm:grid-cols-2 gap-x-4"}`,children:T.taskKPI.recentActivity.slice(0,Vs).map(ge=>{const pe=Ar.get(ge.taskId);return o.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg hover:bg-surface-overlay/40 cursor-pointer transition-colors",onClick:()=>yt.navigate(ce.WORK,{openTask:ge.taskId}),children:[o.jsx("span",{className:`w-5 h-5 rounded-full flex items-center justify-center shrink-0 ${MJ[ge.status]??"bg-gray-500/15"}`,children:o.jsx(DJ,{status:ge.status})}),o.jsx("span",{className:"text-[11px] text-fg-secondary truncate flex-1",children:ge.title}),(pe==="urgent"||pe==="high")&&o.jsx(IJ,{priority:pe}),o.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:K2(ge.updatedAt,a)})]},ge.taskId)})})]})]})})]}),o.jsx("div",{className:"space-y-6",children:Xn.length>0&&o.jsx("div",{className:"bg-surface-elevated shadow-sm rounded-2xl overflow-hidden",children:o.jsxs("div",{className:"p-5",children:[o.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:a("teamOverview.title")}),o.jsx("button",{onClick:()=>yt.navigate(ce.TEAM),className:"text-[11px] text-brand-400 hover:text-brand-300 font-medium",children:a("common:viewAll")})]}),o.jsxs("div",{className:"space-y-0.5",children:[Xn.slice(0,hr).map(ge=>o.jsxs("div",{className:"flex items-center gap-3 px-2 py-2 rounded-lg hover:bg-surface-overlay/40 cursor-pointer transition-colors",onClick:()=>yt.navigate(ce.TEAM,{selectTeam:ge.team.id}),children:[o.jsx("div",{className:"w-7 h-7 rounded-md bg-brand-600/15 flex items-center justify-center text-[10px] font-bold text-brand-400 shrink-0",children:ge.team.name.charAt(0)}),o.jsx("div",{className:"flex-1 min-w-0",children:o.jsx("div",{className:"text-xs font-medium text-fg-primary truncate",children:ge.team.name})}),o.jsx("div",{className:"flex items-center -space-x-1 shrink-0",children:ge.agents.slice(0,3).map(pe=>o.jsx(Go,{name:pe.name,avatarUrl:pe.avatarUrl,size:18,bgClass:"bg-surface-overlay text-fg-secondary ring-1 ring-surface-elevated"},pe.id))}),ge.working>0&&o.jsxs("span",{className:"text-[10px] text-green-500 font-medium shrink-0",children:[ge.working,"/",ge.total]})]},ge.team.id)),hr<Xn.length&&o.jsx("button",{onClick:()=>yt.navigate(ce.TEAM),className:"w-full text-center text-[11px] text-brand-400 hover:text-brand-300 font-medium py-1.5",children:a("common:units.more",{count:Xn.length-hr})})]})]})})})]}),!t&&L!==null&&o.jsx(yJ,{contributors:ba.contributors,hubPlan:ba.hubPlan,hubOrgMeta:ba.hubOrgMeta,hubConnected:ba.hubConnected,showMarkusUsage:yi})]}),ke&&o.jsx(PJ,{workingAgents:ga,onClose:()=>$(!1),t:a}),W&&o.jsx(OJ,{ops:T,completed:Xe,totalRootTasks:wt,workingAgents:lt,totalAgents:m.length,usageInfo:J,storageInfo:V,cuQuota:ee,onClose:()=>oe(!1),t:a}),ft&&o.jsx(BQ,{onClose:()=>rt(!1),onClaimed:Pe}),o.jsx(GQ,{open:ht,userId:ie,onClose:()=>He(!1),onCompleted:()=>{Kt(!0),He(!1)}})]})}function cu({label:e,value:t,sub:n,icon:a,pulse:i,color:l,badge:c,onClick:u}){const m=l==="green"?"text-green-500":l==="amber"?"text-amber-500":l==="red"?"text-red-500":"text-fg-primary";return o.jsxs("div",{onClick:u,className:"bg-surface-elevated shadow-sm rounded-2xl p-4 sm:p-5 flex items-start justify-between cursor-pointer hover:shadow-md transition-shadow",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-[11px] text-fg-tertiary mb-2",children:e}),o.jsxs("div",{className:"flex items-baseline gap-0.5",children:[o.jsx("span",{className:`text-2xl sm:text-3xl font-bold ${m} leading-none`,children:t}),n&&o.jsx("span",{className:"text-sm text-fg-muted font-medium",children:n})]}),c&&o.jsx("div",{className:"text-[10px] text-amber-500 font-medium mt-1.5",children:c})]}),o.jsxs("div",{className:"relative",children:[o.jsx("div",{className:"w-10 h-10 rounded-xl bg-surface-overlay/60 flex items-center justify-center text-fg-tertiary",children:a}),i&&o.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-2.5 h-2.5 rounded-full bg-green-500 animate-pulse"})]})]})}function du({type:e}){const t={working:o.jsx(o.Fragment,{children:o.jsx("path",{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z"})}),tasks:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),o.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),projects:o.jsx(o.Fragment,{children:o.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})}),health:o.jsx(o.Fragment,{children:o.jsx("path",{d:"M22 12h-4l-3 9L9 3l-3 9H2"})})};return o.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:t[e]})}function Uh({icon:e,label:t,value:n,onClick:a,children:i}){return o.jsxs("div",{className:"flex items-center gap-3 px-5 py-3 hover:bg-surface-overlay/30 cursor-pointer transition-colors",onClick:a,children:[o.jsx("span",{className:"text-fg-muted",children:o.jsx(RJ,{type:e})}),o.jsx("span",{className:"text-xs text-fg-secondary",children:t}),o.jsx("span",{className:"text-sm font-semibold text-fg-primary",children:n}),o.jsx("div",{className:"flex items-center gap-2 ml-auto text-[11px] text-fg-tertiary",children:i})]})}function G2({children:e}){return o.jsx("span",{className:"px-2 py-0.5 rounded-full bg-surface-overlay/60 text-[11px] text-fg-secondary",children:e})}function RJ({type:e}){const t={folder:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z",edit:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7 M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z",book:"M4 19.5A2.5 2.5 0 0 1 6.5 17H20 M4 19.5A2.5 2.5 0 0 0 6.5 22H20V2H6.5A2.5 2.5 0 0 0 4 4.5v15z"};return o.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("path",{d:t[e]})})}function _J({statusCounts:e,total:t,completionRate:n,completed:a}){const u=2*Math.PI*42,m=qS.filter(h=>(e[h]??0)>0).map(h=>({status:h,value:e[h],color:EJ[h]??"#6b7280"}));let f=0;const g=m.map(h=>{const b=h.value/t*u,y={len:Math.max(b-.8,.5),offset:f,color:h.color,status:h.status};return f+=b,y});return o.jsxs("div",{className:"relative shrink-0",style:{width:120,height:120},children:[o.jsx("svg",{width:120,height:120,viewBox:"0 0 120 120",children:g.map((h,b)=>o.jsx("circle",{cx:"60",cy:"60",r:42,fill:"none",stroke:h.color,strokeWidth:12,strokeDasharray:`${h.len} ${u-h.len}`,strokeDashoffset:-h.offset,transform:"rotate(-90 60 60)",className:"transition-all duration-500 cursor-pointer",onClick:()=>yt.navigate(ce.WORK,{statusFilter:h.status})},b))}),o.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[o.jsxs("span",{className:"text-2xl font-bold text-fg-primary leading-none",children:[n,"%"]}),o.jsxs("span",{className:"text-[10px] text-fg-tertiary mt-0.5",children:[a,"/",t]})]})]})}function DJ({status:e}){const n={completed:"#22c55e",in_progress:"#8b5cf6",pending:"#f59e0b",review:"#3b82f6",failed:"#ef4444",blocked:"#f59e0b",rejected:"#ef4444",cancelled:"#6b7280"}[e]??"#6b7280";return o.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:n,strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e==="completed"&&o.jsx("polyline",{points:"20 6 9 17 4 12"}),e==="in_progress"&&o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("polyline",{points:"12 6 12 12 16 14"})]}),e==="pending"&&o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),o.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),e==="review"&&o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),o.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),(e==="failed"||e==="rejected")&&o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),o.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),e==="blocked"&&o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"4.93",y1:"4.93",x2:"19.07",y2:"19.07"})]}),e==="cancelled"&&o.jsxs(o.Fragment,{children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})]})}function IJ({priority:e}){return e==="urgent"?o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold bg-red-500/15 text-red-500 shrink-0 uppercase tracking-wide",children:"!"}):e==="high"?o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold bg-amber-500/15 text-amber-600 shrink-0 uppercase tracking-wide",children:"H"}):null}function LJ({type:e,artifactType:t}){if(t){const a=t==="agent"?"#8b5cf6":t==="team"?"#3b82f6":"#f59e0b";return o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:a,strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),o.jsx("path",{d:"M2 17l10 5 10-5"}),o.jsx("path",{d:"M2 12l10 5 10-5"})]})}const n=e==="directory"?"#3b82f6":"#22c55e";return o.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:n,strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:e==="directory"?o.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"}):o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),o.jsx("polyline",{points:"14 2 14 8 20 8"})]})})}function PJ({workingAgents:e,onClose:t,t:n}){return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:o.jsxs("div",{className:"bg-surface-elevated rounded-xl border border-border-default shadow-2xl w-[420px] max-w-[90vw] max-h-[80vh] overflow-hidden flex flex-col",onClick:a=>a.stopPropagation(),children:[o.jsxs("div",{className:"px-5 py-4 border-b border-border-default flex items-center justify-between shrink-0",children:[o.jsx("h3",{className:"text-sm font-semibold",children:n("ranking.workingNow")}),o.jsx("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary hover:text-fg-primary",children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsx("div",{className:"overflow-y-auto flex-1 scrollbar-thin px-5 py-4",children:e.length>0?o.jsx("div",{className:"space-y-0.5",children:e.map(a=>o.jsxs("div",{className:"flex items-center gap-2.5 px-2 py-2 rounded-lg hover:bg-surface-overlay/40 cursor-pointer transition-colors",onClick:()=>{t(),yt.navigate(ce.TEAM,{agentId:a.id})},children:[o.jsx(Go,{name:a.name,avatarUrl:a.avatarUrl,size:26,bgClass:"bg-brand-600/30 text-brand-300"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-xs font-medium text-fg-primary truncate",children:a.name}),o.jsx("div",{className:"text-[10px] text-fg-tertiary truncate",children:a.currentActivity?.label??"—"})]}),o.jsx("span",{className:"text-[10px] text-green-500 font-medium shrink-0",children:n("common:processStatus.working")})]},a.id))}):o.jsx("div",{className:"py-8 text-center text-xs text-fg-tertiary",children:n("ranking.noData")})})]})})}function OJ({ops:e,completed:t,totalRootTasks:n,workingAgents:a,totalAgents:i,usageInfo:l,storageInfo:c,cuQuota:u,onClose:m,t:f}){return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:m,children:o.jsxs("div",{className:"bg-surface-elevated rounded-xl border border-border-default shadow-2xl w-[400px] max-w-[90vw] overflow-hidden",onClick:g=>g.stopPropagation(),children:[o.jsxs("div",{className:"px-5 py-4 border-b border-border-default flex items-center justify-between",children:[o.jsx("h3",{className:"text-sm font-semibold",children:f("systemHealth.title")}),o.jsx("button",{onClick:m,className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary hover:text-fg-primary",children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsxs("div",{className:"p-5 space-y-4",children:[e&&o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsx("span",{className:"text-xs text-fg-secondary",children:f("systemHealth.successRate")}),o.jsxs("span",{className:"text-sm font-bold text-fg-primary",children:[Math.round(e.taskKPI.successRate),"%"]})]}),o.jsx("div",{className:"h-2 rounded-full bg-surface-overlay/60 overflow-hidden",children:o.jsx("div",{className:"h-full rounded-full bg-green-500 transition-all duration-500",style:{width:`${Math.round(e.taskKPI.successRate)}%`}})})]}),e&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs text-fg-secondary",children:f("metricCards.health")}),o.jsxs("span",{className:`text-sm font-bold ${e.systemHealth.overallScore>=80?"text-green-500":e.systemHealth.overallScore>=50?"text-amber-500":"text-red-500"}`,children:[e.systemHealth.overallScore,"%"]})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs text-fg-secondary",children:f("systemHealth.tasksTotal")}),o.jsxs("span",{className:"text-xs font-semibold text-fg-primary",children:[t,"/",n]})]}),l&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs text-fg-secondary",children:f("systemHealth.tokenUsage")}),o.jsx("span",{className:"text-xs font-semibold text-fg-primary",children:mu(l.llmTokens)})]}),u?.available&&u.cuLimit>0&&(()=>{const g=u.cuLimit-u.cuRemaining,h=Math.min(100,Math.round(g/u.cuLimit*100)),b=h>=95?"text-red-500":h>=80?"text-amber-500":"text-green-500",y=h>=95?"bg-red-500":h>=80?"bg-amber-500":"bg-green-500";return o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[o.jsx("span",{className:"text-xs text-fg-secondary",children:f("systemHealth.cuQuota")}),o.jsxs("span",{className:`text-xs font-semibold ${b}`,children:[mu(g)," / ",mu(u.cuLimit)," (",h,"%)"]})]}),o.jsx("div",{className:"h-2 rounded-full bg-surface-overlay/60 overflow-hidden",children:o.jsx("div",{className:`h-full rounded-full ${y} transition-all duration-500`,style:{width:`${h}%`}})}),u.cuUsedToday!=null&&u.cuUsedToday>0&&o.jsxs("div",{className:"flex items-center justify-between mt-1.5",children:[o.jsx("span",{className:"text-xs text-fg-tertiary",children:f("systemHealth.cuUsedToday")}),o.jsx("span",{className:"text-xs font-semibold text-fg-secondary",children:mu(u.cuUsedToday)})]})]})})(),a>0&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs text-fg-secondary",children:f("systemHealth.currentWorking")}),o.jsxs("span",{className:"text-xs font-semibold text-green-500",children:[a,"/",i]})]}),c&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs text-fg-secondary",children:f("systemHealth.storage")}),o.jsx("span",{className:"text-xs font-semibold text-fg-primary",children:qJ(c.totalSize)})]})]})]})})}const HJ=w.forwardRef(({show:e,onToggle:t,onClose:n,t:a,isMobile:i},l)=>o.jsxs("div",{ref:l,className:"relative",children:[o.jsx("button",{onClick:t,className:"p-2 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary","aria-label":a("create"),children:o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),o.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}),e&&o.jsx("div",{className:"absolute right-0 top-full mt-2 bg-surface-elevated border border-border-default rounded-xl shadow-xl z-50 overflow-hidden w-48 animate-fadeIn",children:o.jsxs("div",{className:"py-1",children:[o.jsx(uu,{onClick:()=>{n(),yt.navigate(ce.BUILDER,i?{storeTab:"builder"}:void 0)},icon:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2 M9 7a4 4 0 1 0 0-8 4 4 0 0 0 0 8z M19 8v6 M22 11h-6",children:a("home:createMenu.agent")}),o.jsx(uu,{onClick:()=>{n(),yt.navigate(ce.BUILDER)},icon:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2 M9 7a4 4 0 1 0 0-8 4 4 0 0 0 0 8z M23 21v-2a4 4 0 0 0-3-3.87 M16 3.13a4 4 0 0 1 0 7.75",children:a("home:createMenu.team")}),o.jsx(uu,{onClick:()=>{n(),yt.navigate(ce.BUILDER)},icon:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",children:a("home:createMenu.skill")}),o.jsx("div",{className:"border-t border-border-default my-1"}),o.jsx(uu,{onClick:()=>{n(),yt.navigate(ce.STORE)},icon:"M6 2L3 7v13a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V7l-3-5z M3 7h18 M16 11a4 4 0 0 1-8 0",children:a("home:createMenu.discover")})]})})]}));function uu({onClick:e,icon:t,children:n}){return o.jsxs("button",{onClick:e,className:"w-full flex items-center gap-2.5 px-4 py-2.5 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[o.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("path",{d:t})}),n]})}function K2(e,t){const n=Date.now()-new Date(e).getTime(),a=Math.floor(n/6e4);if(a<1)return t("common:time.now");if(a<60)return t("common:time.minutesAgo",{count:a});const i=Math.floor(a/60);return i<24?t("common:time.hoursAgo",{count:i}):t("common:time.daysAgo",{count:Math.floor(i/24)})}function V2(e,t){return e?$2[e]?t($2[e]):e:null}function BJ(e,t=""){if(!e)return t;const n=new Date(e);return Number.isNaN(n.getTime())?t:n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function zJ(e,t){const n=e.runtime,a=[];if(n){if(n.stall?.stalled)if(n.stall.stallKind==="dead-dependency")a.push(t("agentFocus.stallDeadDep",{title:n.stall.stuckOnTitle??n.stall.stuckOnTaskId??""}));else{const i=n.stall.lastActivityAgoMin;a.push(t("agentFocus.stallStale",{minutes:typeof i=="number"?i:0}))}else n.blockedBy&&n.blockedBy.length>0?a.push(t("agentFocus.blockedBy",{title:n.blockedBy[0].title})):n.phase==="idle"||n.phase==="offline"||(n.activityLabel?a.push(V2(n.activityLabel,t)??n.activityLabel):n.activityType==="heartbeat"&&a.push(t("agentFocus.heartbeatCheckIn")));return typeof n.runningMinutes=="number"&&n.runningMinutes>=1&&a.push(t("agentFocus.runningFor",{n:n.runningMinutes})),(n.lastActivityAt||n.lastHeartbeat)&&a.push(t("agentFocus.lastActivity",{time:BJ(n.lastActivityAt??n.lastHeartbeat)})),n.lastError&&a.push(n.lastError),a.join(" · ")}return V2(e.currentActivity?.label,t)??t("agentFocus.working")}function mu(e){return e>=1e9?`${(e/1e9).toFixed(1)}B`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function qJ(e){if(e===0)return"0 B";const t=["B","KB","MB","GB","TB"],n=Math.floor(Math.log(e)/Math.log(1024));return`${(e/Math.pow(1024,n)).toFixed(n>0?1:0)} ${t[n]}`}const $J=["task","requirement","agent","deliverable","work_unit"];function W2(e){const t=(e??"").trim();if(!t)return;const n=new Date(t);if(!Number.isNaN(n.getTime()))return n.toISOString()}function FJ(e){const t=new URLSearchParams,n=(i,l)=>{const c=(l??"").trim();c.length>0&&t.set(i,c)};n("subjectKind",e.subjectKind),n("subjectId",e.subjectId),n("predicate",e.predicate),n("predicatePrefix",e.predicatePrefix),n("since",W2(e.since)),n("until",W2(e.until)),e.includeSuperseded&&t.set("includeSuperseded","1"),Number.isFinite(e.limit)&&t.set("limit",String(e.limit));const a=t.toString();return a.length>0?`?${a}`:""}function UJ(e){const t=new Map;for(const n of e)t.set(n.id,n);return t}function GJ(e){return[...e].sort((t,n)=>t.createdAt===n.createdAt?t.id<n.id?1:-1:t.createdAt<n.createdAt?1:-1)}function KJ(e,t){const n=e.supersededBy?(()=>{const l=t.get(e.supersededBy);return l?{factId:l.id,at:e.supersededAt??l.createdAt,by:l.assertedBy}:{factId:e.supersededBy,at:e.supersededAt??void 0,missing:!0}})():null,a=[...t.values()].find(l=>l.supersededBy===e.id),i=a?{factId:a.id,at:a.createdAt}:null;return{outgoing:n,incoming:i}}function Y2(e){const t=e.verification;if(!t||t.result!=="pass")return!1;const n=(t.verifiedBy??"").trim();return n.length>0&&n!==e.assertedBy}function VJ(e){if(!e)return{kind:"raw",value:""};const t=/^session:[^:]+(?::r(\d+))?$/.exec(e);return t?{kind:"session",round:t[1]??null}:e.startsWith("a2a:")?{kind:"a2a"}:{kind:"raw",value:e}}function WJ(e){const t=e.indexOf(":"),n=t===-1?"":e.slice(0,t),a=t===-1?"":e.slice(t+1);switch(n){case"commit":return{kind:"commit",hash:a.slice(0,8)};case"probe":return{kind:"probe"};case"task":return{kind:"task",id:a};case"deliverable":return{kind:"deliverable",id:a};default:return{kind:"raw",value:e}}}function Am(e){return e==="owner"||e==="admin"}const Q2=["task.completion_evidence","task.rejection_reason","requirement.acceptance_met","work.defect_class","agent.capability_claim","memory.consolidation_suggestion"],pu="rounded-lg border border-border-default bg-surface-primary px-2.5 py-1.5 text-[13px] text-fg-primary placeholder:text-fg-muted outline-none transition-colors focus:border-brand-500/60";function fu(e){const t=new Date(e);if(Number.isNaN(t.getTime()))return e;const n=a=>String(a).padStart(2,"0");return`${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function Gh(e){const t=new Date(Date.now()-e),n=a=>String(a).padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function J2(e,t){switch(e){case"task":return void yt.navigate(ce.WORK,{openTask:t});case"requirement":return void yt.navigate(ce.WORK,{openRequirement:t});case"agent":return void yt.navigate(ce.TEAM,{agentId:t});case"deliverable":return void yt.navigate(ce.DELIVERABLES,{openDeliverable:t});default:return}}const YJ=new Set(["task","requirement","agent","deliverable"]);function QJ(e){const[t,n]=w.useState([]),[a,i]=w.useState(!1);return w.useEffect(()=>{if(!e||!a)return;let l=!1;return(async()=>{const[c,u,m,f]=await Promise.allSettled([Se.tasks.list({lean:!0,pageSize:300}),Se.requirements.list({lean:!0,limit:300}),Se.agents.list({lean:!0}),Se.deliverables.search({limit:300})]);if(l)return;const g=[];if(c.status==="fulfilled")for(const h of c.value.tasks)g.push({kind:"task",id:h.id,label:h.title});if(u.status==="fulfilled")for(const h of u.value.requirements)g.push({kind:"requirement",id:h.id,label:h.title});if(m.status==="fulfilled")for(const h of m.value.agents)g.push({kind:"agent",id:h.id,label:h.name});if(f.status==="fulfilled")for(const h of f.value.results)g.push({kind:"deliverable",id:h.id,label:h.title});n(g)})(),()=>{l=!0}},[e,a]),{index:t,ensure:()=>i(!0)}}function Cs({active:e,onClick:t,children:n}){return o.jsx("button",{type:"button","aria-pressed":e,onClick:t,className:`rounded-lg border px-2.5 py-1 text-[12.5px] transition-colors ${e?"border-selected-border bg-selected-bg font-medium text-selected-fg":"border-border-default bg-surface-primary text-fg-secondary hover:text-fg-primary"}`,children:n})}function hu({children:e}){return o.jsx("span",{className:"w-14 shrink-0 text-[11px] text-fg-tertiary",children:e})}function JJ({role:e,authUser:t}){const{t:n}=ut("common"),a=Am(e??t?.role),i=QJ(a),l=i.index,[c,u]=w.useState(null),[m,f]=w.useState(""),[g,h]=w.useState(!1),[b,y]=w.useState(""),[k,C]=w.useState(""),[T,A]=w.useState("all"),[M,I]=w.useState(""),[B,G]=w.useState(""),[j,O]=w.useState(!1),[F,Y]=w.useState([]),[q,V]=w.useState(!1),[z,J]=w.useState(!1),[D,ee]=w.useState(!1),[R,te]=w.useState(null),le=w.useCallback(async()=>{if(a){ee(!0),te(null);try{const me=FJ({subjectKind:c?c.kind:b,subjectId:c?c.id:"",predicate:k,since:M,until:B,includeSuperseded:j,limit:200}),ze=await _Y.list(me);Y(GJ(ze.facts??[])),V(ze.disabled===!0),J(ze.truncated===!0)}catch(me){te(me instanceof Error?me.message:String(me)),Y([])}finally{ee(!1)}}},[a,c,b,k,M,B,j]);w.useEffect(()=>{le()},[le]);const ke=w.useMemo(()=>UJ(F),[F]),$=w.useMemo(()=>{let me=0,ze=0;for(const Ue of F)Y2(Ue)&&(me+=1),Ue.supersededBy&&(ze+=1);return{total:F.length,verified:me,superseded:ze}},[F]),W=w.useMemo(()=>{const me=m.trim().toLowerCase(),ze=b?l.filter(Ue=>Ue.kind===b):l;return me?ze.filter(Ue=>Ue.label.toLowerCase().includes(me)||Ue.id.toLowerCase().includes(me)).slice(0,30):ze.slice(0,30)},[l,m,b]),oe=me=>{if(A(me),me==="all"){I(""),G("");return}if(me==="24h"){I(Gh(24*36e5)),G("");return}if(me==="7d"){I(Gh(168*36e5)),G("");return}if(me==="30d"){I(Gh(720*36e5)),G("");return}},L=()=>{u(null),f(""),y(""),C(""),A("all"),I(""),G(""),O(!1)};if(!a)return null;const Ne=me=>Q2.includes(me)?n(`factsAudit.predicateName.${me.replace(/\./g,"_")}`,{defaultValue:me}):me,qe=me=>n(`factsAudit.kind.${me}`,{defaultValue:me});return o.jsx("div",{className:"h-full overflow-y-auto","data-testid":"audit-facts",children:o.jsxs("div",{className:"mx-auto max-w-4xl px-6 py-7",children:[o.jsxs("header",{className:"space-y-1.5",children:[o.jsx("h1",{className:"text-lg font-semibold tracking-tight text-fg-primary",children:n("factsAudit.title")}),o.jsx("p",{className:"max-w-2xl text-[13px] leading-relaxed text-fg-secondary",children:n("factsAudit.subtitle")})]}),o.jsxs("div",{className:"mt-4 flex flex-wrap items-baseline gap-x-5 gap-y-1 text-[12px] text-fg-tertiary",children:[o.jsxs("span",{children:[o.jsx("span",{className:"tabular-nums font-medium text-fg-primary",children:$.total})," ",n("factsAudit.statTotal")]}),o.jsxs("span",{children:[o.jsx("span",{className:"tabular-nums font-medium text-status-ok",children:$.verified})," ",n("factsAudit.statVerified")]}),o.jsxs("span",{children:[o.jsx("span",{className:"tabular-nums font-medium text-fg-primary",children:$.superseded})," ",n("factsAudit.statSuperseded")]})]}),o.jsxs("section",{className:"mt-4 space-y-2 rounded-xl border border-border-default bg-surface-secondary/50 p-3","data-testid":"audit-facts-filters",children:[o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(hu,{children:n("factsAudit.fSubject")}),o.jsx("div",{className:"relative min-w-0 flex-1",children:c?o.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg border border-selected-border bg-selected-bg px-2.5 py-1.5",children:[o.jsx("span",{className:"shrink-0 rounded bg-surface-primary/60 px-1.5 py-0.5 text-[10px] text-fg-secondary",children:qe(c.kind)}),o.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] text-selected-fg",children:c.label}),o.jsx("button",{type:"button",onClick:()=>{u(null),f("")},className:"shrink-0 rounded px-1 text-fg-secondary transition-colors hover:text-fg-primary","aria-label":n("factsAudit.clearSubject"),children:"×"})]}):o.jsxs(o.Fragment,{children:[o.jsx("input",{className:`${pu} w-full`,value:m,onChange:me=>{i.ensure(),f(me.target.value),h(!0)},onFocus:()=>{i.ensure(),h(!0)},onBlur:()=>window.setTimeout(()=>h(!1),120),placeholder:n("factsAudit.subjectSearchPlaceholder"),"aria-label":n("factsAudit.subjectSearchPlaceholder")}),g&&o.jsx("div",{className:"absolute z-20 mt-1 max-h-72 w-full overflow-y-auto rounded-lg border border-border-default bg-surface-elevated py-1 shadow-lg",children:W.length===0?o.jsx("p",{className:"px-3 py-2 text-[12px] text-fg-tertiary",children:n("factsAudit.subjectNoMatch")}):W.map(me=>o.jsxs("button",{type:"button",onMouseDown:ze=>ze.preventDefault(),onClick:()=>{u(me),f(""),h(!1)},className:"flex w-full items-center gap-2 px-3 py-1.5 text-left transition-colors hover:bg-surface-overlay",children:[o.jsx("span",{className:"shrink-0 rounded bg-surface-secondary px-1.5 py-0.5 text-[10px] text-fg-tertiary",children:qe(me.kind)}),o.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] text-fg-primary",children:me.label}),o.jsx("span",{className:"shrink-0 font-mono text-[10px] text-fg-muted",children:me.id})]},`${me.kind}:${me.id}`))})]})})]}),o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(hu,{children:n("factsAudit.fKind")}),o.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[o.jsx(Cs,{active:b==="",onClick:()=>{y(""),u(null)},children:n("factsAudit.kindAll")}),$J.map(me=>o.jsx(Cs,{active:b===me,onClick:()=>{y(me),c&&c.kind!==me&&u(null)},children:qe(me)},me))]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(hu,{children:n("factsAudit.fConclusion")}),o.jsxs("select",{className:`${pu} min-w-[220px]`,value:k,onChange:me=>C(me.target.value),"aria-label":n("factsAudit.fConclusion"),children:[o.jsx("option",{value:"",children:n("factsAudit.conclusionAll")}),Q2.map(me=>o.jsxs("option",{value:me,children:[Ne(me),"(",me,")"]},me))]})]}),o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(hu,{children:n("factsAudit.fTime")}),o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[o.jsx(Cs,{active:T==="all",onClick:()=>oe("all"),children:n("factsAudit.rangeAll")}),o.jsx(Cs,{active:T==="24h",onClick:()=>oe("24h"),children:n("factsAudit.range24h")}),o.jsx(Cs,{active:T==="7d",onClick:()=>oe("7d"),children:n("factsAudit.range7d")}),o.jsx(Cs,{active:T==="30d",onClick:()=>oe("30d"),children:n("factsAudit.range30d")}),o.jsx(Cs,{active:T==="custom",onClick:()=>A("custom"),children:n("factsAudit.rangeCustom")})]})]}),T==="custom"&&o.jsxs("div",{className:"flex flex-wrap items-center gap-3 pl-16",children:[o.jsxs("label",{className:"flex items-center gap-2 text-[11px] text-fg-tertiary",children:[n("factsAudit.since"),o.jsx("input",{type:"datetime-local",className:pu,value:M,onChange:me=>I(me.target.value)})]}),o.jsxs("label",{className:"flex items-center gap-2 text-[11px] text-fg-tertiary",children:[n("factsAudit.until"),o.jsx("input",{type:"datetime-local",className:pu,value:B,onChange:me=>G(me.target.value)})]})]}),o.jsxs("div",{className:"flex items-center gap-2 border-t border-border-subtle pt-2",children:[o.jsxs("label",{className:"flex items-center gap-1.5 text-[12px] text-fg-secondary",children:[o.jsx("input",{type:"checkbox",className:"accent-current",checked:j,onChange:me=>O(me.target.checked)}),n("factsAudit.includeSuperseded")]}),o.jsx("button",{type:"button",onClick:L,className:"ml-auto rounded-lg px-2.5 py-1 text-[12.5px] text-fg-tertiary transition-colors hover:text-fg-primary",children:n("factsAudit.reset")})]})]}),q&&o.jsx("p",{className:"mt-3 rounded-lg border border-status-warn/30 bg-status-warn/10 px-3 py-2 text-[12px] leading-relaxed text-fg-primary","data-testid":"audit-facts-disabled",children:n("factsAudit.disabled")}),R&&o.jsx("p",{className:"mt-3 rounded-lg border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-[12px] text-fg-primary","data-testid":"audit-facts-error",children:R}),D&&o.jsx("div",{className:"mt-3 overflow-hidden rounded-xl border border-border-default","data-testid":"audit-facts-loading",children:[0,1,2].map(me=>o.jsxs("div",{className:"border-b border-border-subtle px-4 py-3 last:border-b-0",children:[o.jsx("div",{className:"h-3 w-40 animate-pulse rounded bg-surface-overlay"}),o.jsx("div",{className:"mt-2 h-2.5 w-64 animate-pulse rounded bg-surface-overlay/70"})]},me))}),!q&&!D&&F.length===0&&!R&&o.jsxs("div",{className:"mt-3 rounded-xl border border-dashed border-border-default px-4 py-12 text-center","data-testid":"audit-facts-empty",children:[o.jsx("p",{className:"text-[13px] text-fg-secondary",children:n("factsAudit.empty")}),o.jsx("p",{className:"mt-1 text-[11px] text-fg-tertiary",children:n("factsAudit.emptyHint")})]}),F.length>0&&o.jsxs("div",{className:"mt-3 overflow-hidden rounded-xl border border-border-default bg-surface-primary","data-testid":"audit-facts-table",children:[z&&o.jsx("p",{className:"border-b border-border-subtle bg-surface-secondary/60 px-4 py-1.5 text-[11px] text-fg-tertiary","data-testid":"audit-facts-truncated",children:n("factsAudit.truncated")}),F.map(me=>{const ze=KJ(me,ke),Ue=!!me.supersededBy,je=Y2(me),Ye=me.workUnitRef?VJ(me.workUnitRef):null,xt=YJ.has(me.subjectKind),mt=me.subjectLabel||me.subjectId;return o.jsxs("article",{id:`fact-${me.id}`,className:"border-b border-border-subtle px-4 py-3 transition-colors last:border-b-0 hover:bg-surface-secondary/40","data-testid":"audit-facts-row",children:[o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[o.jsx("span",{className:"text-[13px] font-medium text-fg-primary",children:Ne(me.predicate)}),o.jsx("span",{className:"font-mono text-[11px] text-fg-muted",title:me.predicate,children:me.predicate})]}),o.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-fg-tertiary",children:[o.jsx("span",{className:"shrink-0",children:qe(me.subjectKind)}),xt?o.jsx("button",{type:"button",onClick:()=>J2(me.subjectKind,me.subjectId),title:n("factsAudit.openSubject",{id:me.subjectId}),className:"max-w-[26rem] truncate text-left text-[12px] font-medium text-brand-500 underline decoration-brand-500/30 underline-offset-2 transition-colors hover:decoration-brand-500",children:mt}):o.jsx("span",{className:"max-w-[26rem] truncate text-fg-secondary",title:me.subjectId,children:mt}),o.jsx("span",{"aria-hidden":!0,children:"·"}),o.jsx("span",{children:n("factsAudit.by",{name:me.assertedByName||me.assertedBy})}),o.jsx("span",{"aria-hidden":!0,children:"·"}),o.jsx("span",{title:me.createdAt,children:fu(me.createdAt)}),Ye&&o.jsxs(o.Fragment,{children:[o.jsx("span",{"aria-hidden":!0,children:"·"}),o.jsx("span",{title:me.workUnitRef,children:Ye.kind==="session"?Ye.round?n("factsAudit.wu.sessionRound",{round:Ye.round}):n("factsAudit.wu.session"):Ye.kind==="a2a"?n("factsAudit.wu.a2a"):Ye.value})]}),o.jsx("span",{"aria-hidden":!0,children:"·"}),o.jsx("span",{className:"tabular-nums",title:n("factsAudit.confidence"),children:n("factsAudit.confidenceShort",{pct:Math.round((me.confidence??0)*100)})})]})]}),o.jsxs("div",{className:"flex shrink-0 flex-col items-end gap-1",children:[Ue?o.jsx("span",{className:"rounded-full border border-status-danger/30 bg-status-danger/10 px-2 py-0.5 text-[11px] font-medium text-status-danger",children:n("factsAudit.superseded")}):me.verification?o.jsxs("span",{className:`rounded-full border px-2 py-0.5 text-[11px] font-medium ${je?"border-status-ok/30 bg-status-ok/10 text-status-ok":"border-status-warn/30 bg-status-warn/10 text-status-warn"}`,title:n("factsAudit.verificationTitle"),children:[me.verification.result," · ",me.verification.verifiedByName||me.verification.verifiedBy,me.verification.verifiedAt?` · ${fu(me.verification.verifiedAt)}`:""]}):o.jsx("span",{className:"rounded-full border border-border-default bg-surface-secondary px-2 py-0.5 text-[11px] text-fg-tertiary",children:n("factsAudit.unverified")}),ze.outgoing&&o.jsx("span",{className:"text-[10.5px] text-fg-tertiary",title:ze.outgoing.factId,"data-testid":"audit-facts-chain-out",children:ze.outgoing.missing?n("factsAudit.chain.replacedByUnknown"):n("factsAudit.chain.replacedBy",{time:fu(ze.outgoing.at??"")})}),ze.incoming&&o.jsx("span",{className:"text-[10.5px] text-fg-tertiary",title:ze.incoming.factId,"data-testid":"audit-facts-chain-in",children:n("factsAudit.chain.replaces",{time:fu(ze.incoming.at??"")})})]})]}),me.sourceRefs?.length>0&&o.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5",children:[o.jsx("span",{className:"text-[10.5px] uppercase tracking-wide text-fg-muted",children:n("factsAudit.evidence")}),me.sourceRefs.map(ft=>{const rt=WJ(ft),jt=rt.kind==="commit"?n("factsAudit.src.commit",{hash:rt.hash}):rt.kind==="probe"?n("factsAudit.src.probe"):rt.kind==="task"?n("factsAudit.src.task"):rt.kind==="deliverable"?n("factsAudit.src.deliverable"):rt.value,ht=rt.kind==="task"&&ft.startsWith("task:")||rt.kind==="deliverable"&&ft.startsWith("deliverable:"),He=ft.slice(ft.indexOf(":")+1),Et="rounded border border-border-subtle bg-surface-secondary px-1.5 py-0.5 text-[10.5px] text-fg-secondary";return ht?o.jsx("button",{type:"button",title:ft,onClick:()=>J2(rt.kind,He),className:`${Et} underline decoration-fg-muted/40 underline-offset-2 transition-colors hover:text-fg-primary`,children:jt},ft):o.jsx("span",{title:ft,className:Et,children:jt},ft)})]}),o.jsxs("details",{className:"group mt-1.5",children:[o.jsx("summary",{className:"cursor-pointer select-none text-[11px] text-fg-tertiary transition-colors hover:text-fg-secondary",children:n("factsAudit.colValue")}),o.jsx("pre",{className:"mt-1.5 max-h-64 overflow-auto rounded-lg border border-border-subtle bg-surface-secondary/60 p-2.5 font-mono text-[11px] leading-relaxed text-fg-secondary",children:JSON.stringify(me.value,null,2)})]})]},me.id)})]})]})})}const XJ=Object.freeze(Object.defineProperty({__proto__:null,canViewFactsAudit:Am,default:JJ},Symbol.toStringTag,{value:"Module"}));class ZJ extends w.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t){this.state.error&&this.props.resetKeys&&!eX(t.resetKeys,this.props.resetKeys)&&this.setState({error:null})}componentDidCatch(t,n){this.props.onError?.(t,n),console.error("[ErrorBoundary] caught render error:",t,n.componentStack)}reset=()=>this.setState({error:null});render(){const{error:t}=this.state;if(t){const{fallback:n}=this.props;return typeof n=="function"?n(t,this.reset):n??null}return this.props.children}}function eX(e,t){if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}const Tm=5,$S=5*1024*1024,tX=["image/png","image/jpeg","image/webp","image/gif"];function nX(e,t){const n=[],a=[],i=tX;let l=t;for(const c of e){if(!i.includes(c.type)){a.push({name:c.name,reason:"not_image"});continue}if(c.size>$S){a.push({name:c.name,reason:"too_large"});continue}if(l>=Tm){a.push({name:c.name,reason:"too_many"});continue}n.push(c),l+=1}return{accepted:n,rejected:a}}function aX(e){if(!Number.isFinite(e)||e<=0)return"0 B";const t=["B","KB","MB","GB"],n=Math.min(t.length-1,Math.floor(Math.log(e)/Math.log(1024))),a=e/1024**n;return`${a>=10||n===0?Math.round(a):Math.round(a*10)/10} ${t[n]}`}function rX(e){return e.title.trim()?null:"title_required"}function iX(e,t){return t==="not_image"?e("feedback.rejectNotImage"):t==="too_large"?e("feedback.rejectTooLarge",{size:aX($S)}):e("feedback.rejectTooMany",{max:Tm})}function sX({defaultContact:e,initialTitle:t,initialBody:n,onClose:a}){const{t:i}=ut("common");$s(!0);const[l,c]=w.useState(t??""),[u,m]=w.useState(n??""),[f,g]=w.useState(e??""),[h,b]=w.useState([]),[y,k]=w.useState([]),[C,T]=w.useState(""),[A,M]=w.useState(!1),[I,B]=w.useState(!1),[G,j]=w.useState(!1),O=w.useRef(null),F=w.useRef([]);F.current=h;const Y=at.isAuthenticated();w.useEffect(()=>()=>{for(const D of F.current)URL.revokeObjectURL(D.previewUrl)},[]),w.useEffect(()=>{const D=ee=>{ee.key==="Escape"&&!A&&a()};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[A,a]);const q=w.useCallback(D=>{if(!D)return;const ee=Array.from(D);if(ee.length===0)return;const{accepted:R,rejected:te}=nX(ee,F.current.length);te.length?k(te.map(le=>`${le.name}:${iX(i,le.reason)}`)):k([]),R.length&&b(le=>[...le,...R.map(ke=>({id:`${ke.name}-${ke.size}-${Math.random().toString(36).slice(2)}`,file:ke,previewUrl:URL.createObjectURL(ke)}))])},[i]),V=D=>{b(ee=>{const R=ee.find(te=>te.id===D);return R&&URL.revokeObjectURL(R.previewUrl),ee.filter(te=>te.id!==D)}),k([])},z=async D=>{if(D.preventDefault(),T(""),rX({title:l})){T(i("feedback.titleRequired"));return}M(!0);try{const ee=[];for(const R of h){const te=await at.uploadImage(R.file);if(!te?.url)throw new Error("upload_failed");ee.push(te.url)}await at.feedback.create({title:l.trim(),content:u.trim()||void 0,contact:f.trim()||void 0,images:ee.length?ee:void 0,appVersion:"0.12.5-rc.4",platform:typeof navigator<"u"?navigator.platform:void 0,locale:typeof navigator<"u"?navigator.language:void 0}),B(!0)}catch(ee){const R=ee.status,te=ee instanceof Error?ee.message:String(ee);T(i(R===404?"feedback.hubUnsupported":te==="upload_failed"?"feedback.uploadFailed":"feedback.submitFailed"))}finally{M(!1)}},J=o.jsx("div",{"data-testid":"feedback-modal",className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10000] p-4",onClick:()=>{A||a()},children:o.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl w-[540px] max-w-full max-h-[calc(100vh-2rem)] overflow-y-auto shadow-2xl",onClick:D=>D.stopPropagation(),onDragOver:D=>{D.preventDefault(),Y&&j(!0)},onDragLeave:()=>j(!1),onDrop:D=>{D.preventDefault(),j(!1),Y&&q(D.dataTransfer.files)},children:I?o.jsxs("div",{className:"p-6 text-center",children:[o.jsx("div",{className:"text-3xl mb-3",children:"✅"}),o.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-2",children:i("feedback.successTitle")}),o.jsx("p",{className:"text-sm text-fg-tertiary mb-5",children:i("feedback.successDesc")}),o.jsx("button",{type:"button",onClick:a,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg",children:i("feedback.successClose")})]}):o.jsxs("form",{onSubmit:z,className:"p-6",children:[o.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:i("feedback.modalTitle")}),o.jsx("p",{className:"text-xs text-fg-tertiary mt-1 mb-4",children:i("feedback.modalSubtitle")}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:[i("feedback.fieldTitle")," ",o.jsx("span",{className:"text-red-400",children:"*"})]}),o.jsx("input",{value:l,onChange:D=>c(D.target.value),maxLength:120,autoFocus:!0,placeholder:i("feedback.titlePlaceholder"),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:i("feedback.fieldContent")}),o.jsx("textarea",{value:u,onChange:D=>m(D.target.value),maxLength:4e3,rows:5,placeholder:i("feedback.contentPlaceholder"),onPaste:D=>{if(!Y)return;const ee=Array.from(D.clipboardData?.files??[]);ee.length&&(D.preventDefault(),q(ee))},className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none resize-y"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:i("feedback.fieldImages",{max:Tm})}),Y?o.jsxs("div",{className:`rounded-lg border border-dashed p-3 transition-colors ${G?"border-brand-500 bg-brand-500/5":"border-border-default"}`,children:[o.jsxs("div",{className:"flex flex-wrap gap-2",children:[h.map(D=>o.jsxs("div",{className:"relative group",children:[o.jsx("img",{src:D.previewUrl,alt:D.file.name,className:"w-20 h-16 object-cover rounded-md border border-border-default"}),o.jsx("button",{type:"button",onClick:()=>V(D.id),title:i("remove"),className:"absolute -top-1.5 -right-1.5 w-5 h-5 rounded-full bg-black/70 text-white text-[11px] leading-none opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]},D.id)),h.length<Tm&&o.jsx("button",{type:"button",onClick:()=>O.current?.click(),className:"w-20 h-16 rounded-md border border-dashed border-border-default text-fg-muted hover:text-fg-secondary hover:border-brand-500 transition-colors text-lg",children:"+"})]}),o.jsx("p",{className:"text-[10px] text-fg-muted mt-2",children:i("feedback.dropHint")}),o.jsx("input",{ref:O,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",multiple:!0,className:"hidden",onChange:D=>{q(D.target.files),D.target.value=""}})]}):o.jsx("p",{className:"text-[11px] text-amber-500/90 bg-amber-500/10 border border-amber-500/30 rounded-lg px-3 py-2",children:i("feedback.loginForImages")}),y.length>0&&o.jsx("ul",{className:"mt-1.5 space-y-0.5",children:y.map((D,ee)=>o.jsx("li",{className:"text-[11px] text-red-400",children:D},ee))})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:i("feedback.fieldContact")}),o.jsx("input",{value:f,onChange:D=>g(D.target.value),placeholder:i("feedback.contactPlaceholder"),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none"})]}),C&&o.jsx("div",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:C})]}),o.jsxs("div",{className:"flex justify-end gap-3 mt-5",children:[o.jsx("button",{type:"button",onClick:a,disabled:A,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated disabled:opacity-50",children:i("cancel")}),o.jsx("button",{type:"submit",disabled:A,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-on-brand rounded-lg",children:i(A?"feedback.submitting":"feedback.submit")})]})]})})});return typeof document<"u"?Jo.createPortal(J,document.body):J}function Kh({label:e,value:t}){return o.jsxs("div",{className:"rounded-lg px-2 py-2.5 text-center bg-surface-elevated",children:[o.jsx("div",{className:"text-lg font-semibold tabular-nums text-fg-primary",children:t.toLocaleString()}),o.jsx("div",{className:"text-[10px] uppercase tracking-wider mt-0.5 text-fg-muted",children:e})]})}function oX({onClose:e}){const{t}=ut("common");$s(!0);const[n,a]=w.useState(null),[i,l]=w.useState(!0),[c,u]=w.useState(""),[m,f]=w.useState(null),g=at.isAuthenticated(),h=w.useCallback(async()=>{if(!g){l(!1);return}l(!0),u("");try{const y=await at.user.referral();a({code:y.code,shareUrl:y.shareUrl,invitedCount:y.invitedCount,paidCount:y.paidCount,rewardCuTotal:y.rewardCuTotal,rewardCuPerPaid:y.rewardCuPerPaid,claimBonusCu:y.claimBonusCu})}catch(y){u(y.status===404?t("ambassador.unsupported"):t("ambassador.loadFailed"))}finally{l(!1)}},[g,t]);w.useEffect(()=>{h()},[h]),w.useEffect(()=>{const y=k=>{k.key==="Escape"&&e()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[e]);const b=async y=>{if(n)try{await navigator.clipboard.writeText(y==="code"?n.code:n.shareUrl),f(y),setTimeout(()=>f(null),2e3)}catch{}};return o.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10000] p-4",onClick:e,children:o.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl w-[460px] max-w-full max-h-[calc(100vh-2rem)] overflow-y-auto shadow-2xl p-6",onClick:y=>y.stopPropagation(),children:[o.jsxs("div",{className:"flex items-start gap-2 mb-4",children:[o.jsx("span",{className:"text-xl leading-none",children:"🎁"}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:t("ambassador.title")}),o.jsx("p",{className:"text-xs text-fg-tertiary mt-1 leading-relaxed",children:n?t("ambassador.desc",{claimAmount:n.claimBonusCu.toLocaleString(),rewardAmount:n.rewardCuPerPaid.toLocaleString()}):t("ambassador.descGeneric")})]})]}),g?i?o.jsx("p",{className:"text-sm text-fg-tertiary py-6 text-center",children:t("ambassador.loading")}):c?o.jsx("p",{className:"text-xs text-red-400 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:c}):n?o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:t("ambassador.codeLabel")}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("code",{className:"flex-1 px-3 py-2 rounded-lg text-sm font-mono tracking-widest bg-surface-elevated text-fg-primary select-all",children:n.code}),o.jsx("button",{type:"button",onClick:()=>{b("code")},className:"px-3 py-2 text-xs font-medium rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand shrink-0",children:t(m==="code"?"ambassador.copied":"ambassador.copyCode")})]})]}),o.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[o.jsx(Kh,{label:t("ambassador.statInvited"),value:n.invitedCount}),o.jsx(Kh,{label:t("ambassador.statPaid"),value:n.paidCount}),o.jsx(Kh,{label:t("ambassador.statReward"),value:n.rewardCuTotal})]}),o.jsx("button",{type:"button",onClick:()=>{b("link")},className:"w-full px-3 py-2 text-xs border border-border-default rounded-lg hover:bg-surface-elevated text-fg-secondary",children:t(m==="link"?"ambassador.copied":"ambassador.copyLink")})]}):null:o.jsxs("div",{className:"rounded-lg border border-border-default p-4 text-center",children:[o.jsx("p",{className:"text-sm text-fg-secondary mb-3",children:t("ambassador.loginPrompt")}),o.jsx("button",{type:"button",onClick:()=>{at.ensureAuth().then(()=>h()).catch(()=>{})},className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg",children:t("ambassador.login")})]}),o.jsxs("div",{className:"flex justify-end gap-3 mt-5",children:[g&&n&&o.jsx("button",{type:"button",onClick:()=>{const y=at.getUrl().replace(/\/$/,"");Or(`${y}/settings`)},className:"px-3 py-2 text-xs border border-border-default rounded-lg hover:bg-surface-elevated text-fg-secondary",children:t("ambassador.openHub")}),o.jsx("button",{type:"button",onClick:e,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:t("close")})]})]})})}function _o({d:e,size:t=14}){return o.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:o.jsx("path",{d:e})})}const Vh=200;function lX({authUser:e,onLogout:t,onEditProfile:n,showSettingsLink:a=!1,collapsed:i=!1,showVersion:l=!1}){const{t:c}=ut(["nav","common"]),[u,m]=w.useState(!1),[f,g]=w.useState(!1),[h,b]=w.useState(!1),[y,k]=w.useState(!1),[C,T]=w.useState({top:0,left:0}),A=w.useRef(null),M=w.useRef(null),{connected:I,user:B,credits:G,refresh:j}=TS(u),O=w.useCallback(()=>{if(!A.current)return;const R=A.current.getBoundingClientRect(),te=window.innerWidth,le=window.innerHeight,ke=M.current?.offsetHeight??220;let $=R.right+8;$+Vh>te-8&&($=Math.max(8,R.left-Vh-8));let W=R.top-ke-8;W<8&&(W=Math.min(R.bottom+8,le-ke-8)),T({top:Math.max(8,W),left:$})},[]);w.useLayoutEffect(()=>{if(!u)return;O();const R=requestAnimationFrame(()=>O());return()=>cancelAnimationFrame(R)},[u,O,i]),w.useEffect(()=>{if(!u)return;const R=le=>{const ke=le.target;A.current?.contains(ke)||M.current?.contains(ke)||m(!1)},te=()=>O();return document.addEventListener("mousedown",R),window.addEventListener("resize",te),window.addEventListener("scroll",te,!0),()=>{document.removeEventListener("mousedown",R),window.removeEventListener("resize",te),window.removeEventListener("scroll",te,!0)}},[u,O]);const F=e?.name||B?.displayName||B?.username||c("common:userPlaceholder"),Y=e?.email||B?.email||"",q=SS(e?.avatarUrl,B?.avatarUrl),V=I?"bg-emerald-500":"bg-fg-muted",z=I?B?.username?c("sidebar.hubConnectedAs",{username:B.username}):c("sidebar.hubConnected"):c("sidebar.hubDisconnected"),J=!!(I&&B?.username&&e?.name&&B.username.toLowerCase()!==e.name.toLowerCase()&&B.email?.toLowerCase()!==e.email?.toLowerCase()),D=()=>{m(!1),j({validate:!0}),yt.navigate(ce.SETTINGS,{tab:"account"})},ee=u&&Jo.createPortal(o.jsxs("div",{ref:M,className:"fixed bg-surface-elevated border border-border-default rounded-xl shadow-xl z-[9999] overflow-hidden",style:{top:C.top,left:C.left,width:Vh},children:[o.jsxs("div",{className:"px-3.5 py-3 border-b border-border-default flex items-start gap-2",children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:F}),Y&&o.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5 truncate",children:Y}),G!==null&&o.jsxs("button",{type:"button",onClick:()=>{m(!1),Or(`${at.getUrl().replace(/\/$/,"")}/settings?tab=billing`)},title:c("common:creditBalanceOpenHub"),className:"text-xs text-fg-secondary mt-0.5 -mx-1 px-1 max-w-full flex items-center gap-1 rounded transition-colors hover:text-brand-500 hover:bg-surface-overlay",children:[o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:[o.jsx("path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z"}),o.jsx("path",{d:"M12.5 5.5v13",strokeDasharray:"2 2.5"})]}),o.jsxs("span",{className:"truncate",children:[c("common:creditBalance"),": ",G.remaining.toLocaleString()]})]})]}),n&&o.jsx("button",{type:"button",onClick:()=>{m(!1),n()},title:c("common:profile.editProfile"),className:"shrink-0 mt-0.5 p-1.5 rounded-md text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay transition-colors",children:o.jsx(_o,{d:"M12 20h9M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z",size:14})})]}),o.jsxs("button",{type:"button",onClick:D,className:"w-full px-3.5 py-2.5 border-b border-border-default flex items-center gap-2 hover:bg-surface-overlay transition-colors text-left",children:[o.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${V}`}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsx("span",{className:"text-xs text-fg-secondary block truncate",children:z}),J&&B?.username&&o.jsx("span",{className:"text-[10px] text-amber-500/90 block truncate mt-0.5",children:c("sidebar.hubAccountMismatch",{username:B.username})})]}),o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-fg-muted shrink-0",children:o.jsx("path",{d:"m9 18 6-6-6-6"})})]}),o.jsxs("div",{className:"py-1",children:[o.jsxs("button",{type:"button",onClick:()=>{m(!1),b(!0)},className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[o.jsx(_o,{d:"M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5Z"}),c("common:feedback.entry")]}),o.jsxs("button",{type:"button",onClick:()=>{m(!1),k(!0)},className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[o.jsx(_o,{d:"M20 12v10H4V12M2 7h20v5H2zM12 22V7M12 7H7.5a2.5 2.5 0 0 1 0-5C11 2 12 7 12 7ZM12 7h4.5a2.5 2.5 0 0 0 0-5C13 2 12 7 12 7Z"}),c("common:ambassador.entry")]}),a&&o.jsxs("button",{type:"button",onClick:()=>{m(!1),yt.navigate(ce.SETTINGS)},className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[o.jsx(_o,{d:Xm[ce.SETTINGS]}),c("settings")]}),window.markusDesktop&&o.jsxs("button",{type:"button",onClick:()=>{m(!1),window.markusDesktop?.openInBrowser()},className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[o.jsx(_o,{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6M15 3h6v6M10 14 21 3"}),c("common:openInBrowser")]}),t&&o.jsxs("button",{type:"button",onClick:()=>{m(!1),g(!0)},className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[o.jsx(_o,{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9"}),c("common:signOut")]})]})]}),document.body);return o.jsxs("div",{className:`relative ${i?"flex justify-center":"flex items-center justify-between gap-2 w-full"}`,children:[o.jsxs("button",{ref:A,type:"button",onClick:()=>m(R=>!R),title:F,className:`relative inline-flex items-center justify-center rounded-full transition-opacity hover:opacity-90 ${i?"p-0.5":""}`,children:[o.jsx(Go,{name:F,avatarUrl:q,size:i?28:32,fallback:"icon"}),o.jsx("span",{className:`absolute bottom-0 right-0 w-2.5 h-2.5 rounded-full border-2 border-surface-secondary ${V}`,title:z})]}),l&&!i&&o.jsxs("span",{className:"text-[10px] text-fg-muted select-none shrink-0",children:["v","0.12.5-rc.4"]}),ee,h&&o.jsx(sX,{defaultContact:Y,onClose:()=>b(!1)}),y&&o.jsx(oX,{onClose:()=>k(!1)}),f&&t&&o.jsx(xr,{title:c("common:signOutConfirmTitle"),message:c("common:signOutConfirmMessage"),confirmLabel:c("common:signOut"),variant:"primary",onConfirm:()=>{g(!1),t()},onCancel:()=>g(!1)})]})}function cX({d:e,size:t=18}){return o.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:o.jsx("path",{d:e})})}function dX({currentPage:e,onNavigate:t,authUser:n,collapsed:a,onToggleCollapse:i,onLogout:l,keyboardFocusPageId:c,keyboardPaneActive:u}){const{t:m}=ut(["nav","common"]),[f,g]=w.useState(ep);return w.useEffect(()=>gS(g),[]),o.jsxs("aside",{"data-keyboard-pane":"l0",className:"markus-app-sidebar h-dvh bg-surface-secondary flex flex-col shrink-0 overflow-hidden",children:[o.jsx("div",{"data-electron-drag":!0,className:`electron-mac-sidebar-header flex items-center ${a?"px-2 py-3.5 justify-center":"px-4 h-14 justify-between"}`,children:o.jsxs("button",{"data-no-drag":!0,onClick:i,title:m(a?"sidebar.expandSidebar":"sidebar.collapseSidebar"),className:"flex items-center gap-2.5 min-w-0 group",children:[o.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-8 h-8 rounded-lg shrink-0"}),!a&&o.jsx("span",{className:"text-[15px] font-bold tracking-tight text-fg-primary whitespace-nowrap",children:"Markus"})]})}),o.jsx("nav",{className:`${a?"p-1":"px-3 py-2"} flex-1 overflow-y-auto scrollbar-thin`,children:UW.map((h,b)=>{const y=Y4.filter(C=>C.section===h.key);if(y.length===0)return null;const k=m(`sections.${h.key}`);return o.jsx("div",{children:o.jsxs("div",{className:b>0?"mt-3":"",children:[!a&&k&&o.jsx("div",{className:"px-3 py-1.5 mb-1 text-[10px] font-semibold text-fg-muted uppercase tracking-[0.1em]",children:k}),a&&b>0&&o.jsx("div",{className:"my-3"}),y.map(C=>{const T=e===C.id,A=u&&c===C.id;return o.jsxs("button",{"data-l0-page-id":C.id,onClick:()=>t(C.id),title:a?m(C.id):void 0,className:`relative w-full flex items-center ${a?"flex-col justify-center px-1 py-1.5 gap-0.5":"gap-3 px-3 py-[7px]"} rounded-lg text-[13px] font-medium mb-0.5 transition-colors text-fg-primary ${A?"bg-brand-500/25 ring-1 ring-inset ring-brand-500/40":T?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[o.jsx(cX,{d:Xm[C.id]??"",size:a?16:18}),a?o.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:m(C.id)}):o.jsx("span",{className:"truncate",children:m(C.id)}),C.id===ce.HOME&&f>0&&(a?o.jsx("span",{className:"absolute top-0.5 right-1.5 min-w-[13px] h-[13px] px-[3px] rounded-full bg-red-500 text-white text-[8px] font-bold flex items-center justify-center tabular-nums",children:f>9?"9+":f}):o.jsx("span",{className:"ml-auto shrink-0 text-[10px] px-1.5 py-0.5 rounded-full bg-red-500 text-white font-semibold tabular-nums",children:f>99?"99+":f}))]},C.id)})]})},h.key)})}),o.jsx("div",{className:`shrink-0 border-t border-border-subtle ${a?"p-1.5 flex justify-center":"px-3 py-2.5"}`,children:o.jsx(lX,{authUser:n,onLogout:l,onEditProfile:()=>{window.dispatchEvent(new Event("markus:open-edit-profile"))},showSettingsLink:!1,collapsed:a,showVersion:!a})})]})}const uX=100;function mX(e,t){const n=uX,a=((f,g)=>setTimeout(f,g)),i=(f=>clearTimeout(f)),l=new Map;let c=null,u=!1;function m(){if(c=null,u=!1,l.size===0)return;const f=[];for(const[g,h]of l)f.push({conversationKey:g,lastReadAt:h});l.clear(),e(f)}return{queue(f,g){let h=!1;for(const b of f)b&&(l.set(b,g),h=!0);h&&(u||(u=!0,c=a(m,n)))},flushNow(){u&&(i(c),u=!1,c=null),m()},pendingCount(){return l.size}}}const pX=6e4,fX=2e3;let cr={},Yi={};const dg=new Set,Em=new Set;let FS=0;const ug=new Map;let gc=null,gu=0,em=null;function _c(){for(const e of dg)e()}function X2(e,t){const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const a of n)if(e[a]!==t[a])return!1;return!0}function hX(e,t){const n={},a=[];for(const[i,l]of Object.entries(e)){if(t.has(i)){l>0&&a.push(i);continue}n[i]=l}return{counts:n,staleActiveKeys:a}}function gX(e,t){Nm([e],t)}function bX(e,t,n,a){const i=[];for(const l of e){const c=t.get(l)??0;!a?.force&&n-c<fX||i.push(l)}return i}const US=mX(e=>{(e.length===1?Se.unread.markRead(e[0].conversationKey,e[0].lastReadAt):Se.unread.markReadBatch(e)).catch(()=>{})});typeof window<"u"&&typeof window.addEventListener=="function"&&window.addEventListener("pagehide",()=>US.flushNow(),{passive:!0});function Nm(e,t){const n=Date.now(),a=bX(e,ug,n,t);let i=!1;for(const l of a)ug.set(l,n),l in cr&&(delete cr[l],i=!0);i&&_c(),a.length!==0&&US.queue(a,new Date(n).toISOString())}async function mg(){try{const e=await Se.unread.getCounts(),{counts:t,staleActiveKeys:n}=hX(e.counts??{},Em);cr=t,Yi=e.sessionAgentMap??{},_c(),Nm(n)}catch{}}function yX(){gc||(mg(),gc=setInterval(mg,pX),em=di.on("chat:unread_update",e=>{const t=e.payload?.conversationKey;if(t){if(Em.has(t)){gX(t);return}Date.now()>FS&&(cr[t]=(cr[t]??0)+1,_c())}}))}function vX(){gc&&(clearInterval(gc),gc=null),em&&(em(),em=null)}function xX(e){const t=e?.enabled??!0,[n,a]=w.useState(cr),[i,l]=w.useState(Yi),c=w.useCallback(async()=>{await mg()},[]),u=w.useCallback(async T=>{if(T.length===0)return;let A=!1;for(const M of T)M in cr&&(delete cr[M],A=!0);A&&_c(),Nm(T,{force:!0})},[]),m=w.useCallback(async T=>{await u([T])},[u]),f=w.useCallback(async()=>{cr={},_c();try{await Se.unread.markAllRead()}catch{}},[]),g=w.useCallback(T=>{Em.add(T)},[]),h=w.useCallback(T=>{if(T.length!==0){for(const A of T)Em.delete(A),ug.delete(A);FS=Date.now()+150,Nm(T,{force:!0})}},[]),b=w.useCallback(T=>{h([T])},[h]);w.useEffect(()=>{if(!t)return;gu++,yX();let T=Yi;const A=()=>{a(M=>X2(M,cr)?M:{...cr}),T!==Yi&&(T=Yi,l(M=>X2(M,Yi)?M:{...Yi}))};return dg.add(A),a({...cr}),l({...Yi}),()=>{dg.delete(A),gu--,gu<=0&&(gu=0,vX())}},[t]);const y=w.useMemo(()=>Object.values(n).reduce((T,A)=>T+A,0),[n]),k=w.useCallback(T=>n[`session:${T}`]??0,[n]),C=w.useCallback(T=>n[`channel:${T}`]??0,[n]);return{counts:n,totalUnread:y,sessionAgentMap:i,getSessionUnread:k,getChannelUnread:C,markRead:m,markReadMany:u,markAllRead:f,refresh:c,setActiveKey:g,clearActiveKey:b,clearActiveKeys:h}}function rpe(e,t){return w.useMemo(()=>{const n=new Map;for(const[a,i]of Object.entries(t))if(a.startsWith("session:")){const l=a.slice(8),c=e[l];c&&n.set(c,(n.get(c)??0)+i)}return n},[e,t])}function wX(e){return e.startsWith("channel:dm:a2a:")}function kX(e,t){let n=0;for(const[a,i]of Object.entries(e))if(a.startsWith("session:")){const l=a.slice(8);t[l]&&(n+=i)}else if(a.startsWith("channel:")){if(wX(a))continue;n+=i}return n}const SX=6,CX=56;function AX({currentPage:e,onNavigate:t}){const{t:n}=ut("nav"),[a,i]=w.useState(ep);w.useEffect(()=>gS(i),[]);const[l,c]=w.useState(!1),u=w.useRef(!1),m=w.useCallback(b=>{u.current!==b&&(u.current=b,c(b))},[]);w.useEffect(()=>{let b=window.scrollY,y=0;const k=()=>{y||(y=requestAnimationFrame(()=>{y=0;const C=window.scrollY,T=C-b;if(b=C,C<=CX){m(!1);return}T>SX?m(!0):T<-6&&m(!1)}))};return window.addEventListener("scroll",k,{passive:!0}),()=>{window.removeEventListener("scroll",k),y&&cancelAnimationFrame(y)}},[m]),w.useEffect(()=>{m(!1)},[e,m]);const{counts:f,sessionAgentMap:g}=xX({enabled:!0}),h=w.useMemo(()=>kX(f,g),[f,g]);return o.jsx("nav",{"data-mobile-bottom-nav":!0,className:`fixed bottom-0 left-0 right-0 z-50 bg-surface-secondary flex items-stretch h-14 safe-area-bottom transition-transform duration-300 ease-out will-change-transform ${l?"translate-y-[calc(100%+1px)]":"translate-y-0"}`,children:KW.map(b=>{const y=b.group.includes(e),k=b.id===ce.HOME,C=b.id===ce.TEAM;return o.jsxs("button",{onClick:()=>t(b.id),className:`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${y?"text-fg-primary":"text-fg-tertiary active:text-fg-secondary"}`,children:[o.jsxs("div",{className:"relative",children:[o.jsx("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:y?2:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:o.jsx("path",{d:Xm[b.id]})}),k&&a>0&&o.jsx("span",{className:"absolute -top-1.5 -right-2 min-w-[16px] h-4 px-1 flex items-center justify-center bg-red-500 text-white text-[9px] font-bold rounded-full leading-none",children:a>99?"99+":a}),C&&h>0&&o.jsx("span",{className:"absolute -top-1.5 -right-2 min-w-[16px] h-4 px-1 flex items-center justify-center bg-red-500 text-white text-[9px] font-bold rounded-full leading-none",children:h>99?"99+":h})]}),o.jsx("span",{className:`text-[10px] leading-tight ${y?"font-semibold":""}`,children:n(b.id)})]},b.id)})})}const Mm=new Map;function As(e,t){Mm.has(e)||Mm.set(e,t().catch(()=>{}))}function Ls(e){const t=Mm.get(e);return Mm.delete(e),t}const La={builderArtifacts:"builder.artifacts",builderAgents:"builder.agents",builderHubMyItems:"builder.hubMyItems",builderInstalled:"builder.installed",hubAgents:"hub.agents",hubTeams:"hub.teams",hubSkills:"hub.skills"};function Z2(e){const t=[],n=String(e||"");let a=n.indexOf(","),i=0,l=!1;for(;!l;){a===-1&&(a=n.length,l=!0);const c=n.slice(i,a).trim();(c||!l)&&t.push(c),i=a+1,a=n.indexOf(",",i)}return t}function TX(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const EX=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,NX=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,MX={};function ew(e,t){return(MX.jsx?NX:EX).test(e)}const jX=/[ \t\n\f\r]/g;function RX(e){return typeof e=="object"?e.type==="text"?tw(e.value):!1:tw(e)}function tw(e){return e.replace(jX,"")===""}class qc{constructor(t,n,a){this.normal=n,this.property=t,a&&(this.space=a)}}qc.prototype.normal={};qc.prototype.property={};qc.prototype.space=void 0;function GS(e,t){const n={},a={};for(const i of e)Object.assign(n,i.property),Object.assign(a,i.normal);return new qc(n,a,t)}function Dc(e){return e.toLowerCase()}class za{constructor(t,n){this.attribute=n,this.property=t}}za.prototype.attribute="";za.prototype.booleanish=!1;za.prototype.boolean=!1;za.prototype.commaOrSpaceSeparated=!1;za.prototype.commaSeparated=!1;za.prototype.defined=!1;za.prototype.mustUseProperty=!1;za.prototype.number=!1;za.prototype.overloadedBoolean=!1;za.prototype.property="";za.prototype.spaceSeparated=!1;za.prototype.space=void 0;let _X=0;const qt=Fs(),Wn=Fs(),pg=Fs(),We=Fs(),Cn=Fs(),$o=Fs(),Wa=Fs();function Fs(){return 2**++_X}const fg=Object.freeze(Object.defineProperty({__proto__:null,boolean:qt,booleanish:Wn,commaOrSpaceSeparated:Wa,commaSeparated:$o,number:We,overloadedBoolean:pg,spaceSeparated:Cn},Symbol.toStringTag,{value:"Module"})),Wh=Object.keys(fg);class lb extends za{constructor(t,n,a,i){let l=-1;if(super(t,n),nw(this,"space",i),typeof a=="number")for(;++l<Wh.length;){const c=Wh[l];nw(this,Wh[l],(a&fg[c])===fg[c])}}}lb.prototype.defined=!0;function nw(e,t,n){n&&(e[t]=n)}function Zo(e){const t={},n={};for(const[a,i]of Object.entries(e.properties)){const l=new lb(a,e.transform(e.attributes||{},a),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(a)&&(l.mustUseProperty=!0),t[a]=l,n[Dc(a)]=a,n[Dc(l.attribute)]=a}return new qc(t,n,e.space)}const KS=Zo({properties:{ariaActiveDescendant:null,ariaAtomic:Wn,ariaAutoComplete:null,ariaBusy:Wn,ariaChecked:Wn,ariaColCount:We,ariaColIndex:We,ariaColSpan:We,ariaControls:Cn,ariaCurrent:null,ariaDescribedBy:Cn,ariaDetails:null,ariaDisabled:Wn,ariaDropEffect:Cn,ariaErrorMessage:null,ariaExpanded:Wn,ariaFlowTo:Cn,ariaGrabbed:Wn,ariaHasPopup:null,ariaHidden:Wn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Cn,ariaLevel:We,ariaLive:null,ariaModal:Wn,ariaMultiLine:Wn,ariaMultiSelectable:Wn,ariaOrientation:null,ariaOwns:Cn,ariaPlaceholder:null,ariaPosInSet:We,ariaPressed:Wn,ariaReadOnly:Wn,ariaRelevant:null,ariaRequired:Wn,ariaRoleDescription:Cn,ariaRowCount:We,ariaRowIndex:We,ariaRowSpan:We,ariaSelected:Wn,ariaSetSize:We,ariaSort:null,ariaValueMax:We,ariaValueMin:We,ariaValueNow:We,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function VS(e,t){return t in e?e[t]:t}function WS(e,t){return VS(e,t.toLowerCase())}const DX=Zo({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:$o,acceptCharset:Cn,accessKey:Cn,action:null,allow:null,allowFullScreen:qt,allowPaymentRequest:qt,allowUserMedia:qt,alt:null,as:null,async:qt,autoCapitalize:null,autoComplete:Cn,autoFocus:qt,autoPlay:qt,blocking:Cn,capture:null,charSet:null,checked:qt,cite:null,className:Cn,cols:We,colSpan:null,content:null,contentEditable:Wn,controls:qt,controlsList:Cn,coords:We|$o,crossOrigin:null,data:null,dateTime:null,decoding:null,default:qt,defer:qt,dir:null,dirName:null,disabled:qt,download:pg,draggable:Wn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:qt,formTarget:null,headers:Cn,height:We,hidden:pg,high:We,href:null,hrefLang:null,htmlFor:Cn,httpEquiv:Cn,id:null,imageSizes:null,imageSrcSet:null,inert:qt,inputMode:null,integrity:null,is:null,isMap:qt,itemId:null,itemProp:Cn,itemRef:Cn,itemScope:qt,itemType:Cn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:qt,low:We,manifest:null,max:null,maxLength:We,media:null,method:null,min:null,minLength:We,multiple:qt,muted:qt,name:null,nonce:null,noModule:qt,noValidate:qt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:qt,optimum:We,pattern:null,ping:Cn,placeholder:null,playsInline:qt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:qt,referrerPolicy:null,rel:Cn,required:qt,reversed:qt,rows:We,rowSpan:We,sandbox:Cn,scope:null,scoped:qt,seamless:qt,selected:qt,shadowRootClonable:qt,shadowRootDelegatesFocus:qt,shadowRootMode:null,shape:null,size:We,sizes:null,slot:null,span:We,spellCheck:Wn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:We,step:null,style:null,tabIndex:We,target:null,title:null,translate:null,type:null,typeMustMatch:qt,useMap:null,value:Wn,width:We,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Cn,axis:null,background:null,bgColor:null,border:We,borderColor:null,bottomMargin:We,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:qt,declare:qt,event:null,face:null,frame:null,frameBorder:null,hSpace:We,leftMargin:We,link:null,longDesc:null,lowSrc:null,marginHeight:We,marginWidth:We,noResize:qt,noHref:qt,noShade:qt,noWrap:qt,object:null,profile:null,prompt:null,rev:null,rightMargin:We,rules:null,scheme:null,scrolling:Wn,standby:null,summary:null,text:null,topMargin:We,valueType:null,version:null,vAlign:null,vLink:null,vSpace:We,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:qt,disableRemotePlayback:qt,prefix:null,property:null,results:We,security:null,unselectable:null},space:"html",transform:WS}),IX=Zo({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Wa,accentHeight:We,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:We,amplitude:We,arabicForm:null,ascent:We,attributeName:null,attributeType:null,azimuth:We,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:We,by:null,calcMode:null,capHeight:We,className:Cn,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:We,diffuseConstant:We,direction:null,display:null,dur:null,divisor:We,dominantBaseline:null,download:qt,dx:null,dy:null,edgeMode:null,editable:null,elevation:We,enableBackground:null,end:null,event:null,exponent:We,externalResourcesRequired:null,fill:null,fillOpacity:We,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:$o,g2:$o,glyphName:$o,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:We,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:We,horizOriginX:We,horizOriginY:We,id:null,ideographic:We,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:We,k:We,k1:We,k2:We,k3:We,k4:We,kernelMatrix:Wa,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:We,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:We,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:We,overlineThickness:We,paintOrder:null,panose1:null,path:null,pathLength:We,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Cn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:We,pointsAtY:We,pointsAtZ:We,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Wa,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Wa,rev:Wa,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Wa,requiredFeatures:Wa,requiredFonts:Wa,requiredFormats:Wa,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:We,specularExponent:We,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:We,strikethroughThickness:We,string:null,stroke:null,strokeDashArray:Wa,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:We,strokeOpacity:We,strokeWidth:null,style:null,surfaceScale:We,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Wa,tabIndex:We,tableValues:null,target:null,targetX:We,targetY:We,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Wa,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:We,underlineThickness:We,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:We,values:null,vAlphabetic:We,vMathematical:We,vectorEffect:null,vHanging:We,vIdeographic:We,version:null,vertAdvY:We,vertOriginX:We,vertOriginY:We,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:We,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:VS}),YS=Zo({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),QS=Zo({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:WS}),JS=Zo({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),LX={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},PX=/[A-Z]/g,aw=/-[a-z]/g,OX=/^data[-\w.:]+$/i;function XS(e,t){const n=Dc(t);let a=t,i=za;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&OX.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(aw,BX);a="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!aw.test(l)){let c=l.replace(PX,HX);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}i=lb}return new i(a,t)}function HX(e){return"-"+e.toLowerCase()}function BX(e){return e.charAt(1).toUpperCase()}const ZS=GS([KS,DX,YS,QS,JS],"html"),np=GS([KS,IX,YS,QS,JS],"svg");function rw(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function zX(e){return e.join(" ").trim()}var Do={},Yh,iw;function qX(){if(iw)return Yh;iw=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,u=/^\s+|\s+$/g,m=`
|
|
521
521
|
`,f="/",g="*",h="",b="comment",y="declaration";function k(T,A){if(typeof T!="string")throw new TypeError("First argument must be a string");if(!T)return[];A=A||{};var M=1,I=1;function B(D){var ee=D.match(t);ee&&(M+=ee.length);var R=D.lastIndexOf(m);I=~R?D.length-R:I+D.length}function G(){var D={line:M,column:I};return function(ee){return ee.position=new j(D),Y(),ee}}function j(D){this.start=D,this.end={line:M,column:I},this.source=A.source}j.prototype.content=T;function O(D){var ee=new Error(A.source+":"+M+":"+I+": "+D);if(ee.reason=D,ee.filename=A.source,ee.line=M,ee.column=I,ee.source=T,!A.silent)throw ee}function F(D){var ee=D.exec(T);if(ee){var R=ee[0];return B(R),T=T.slice(R.length),ee}}function Y(){F(n)}function q(D){var ee;for(D=D||[];ee=V();)ee!==!1&&D.push(ee);return D}function V(){var D=G();if(!(f!=T.charAt(0)||g!=T.charAt(1))){for(var ee=2;h!=T.charAt(ee)&&(g!=T.charAt(ee)||f!=T.charAt(ee+1));)++ee;if(ee+=2,h===T.charAt(ee-1))return O("End of comment missing");var R=T.slice(2,ee-2);return I+=2,B(R),T=T.slice(ee),I+=2,D({type:b,comment:R})}}function z(){var D=G(),ee=F(a);if(ee){if(V(),!F(i))return O("property missing ':'");var R=F(l),te=D({type:y,property:C(ee[0].replace(e,h)),value:R?C(R[0].replace(e,h)):h});return F(c),te}}function J(){var D=[];q(D);for(var ee;ee=z();)ee!==!1&&(D.push(ee),q(D));return D}return Y(),J()}function C(T){return T?T.replace(u,h):h}return Yh=k,Yh}var sw;function $X(){if(sw)return Do;sw=1;var e=Do&&Do.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(Do,"__esModule",{value:!0}),Do.default=n;const t=e(qX());function n(a,i){let l=null;if(!a||typeof a!="string")return l;const c=(0,t.default)(a),u=typeof i=="function";return c.forEach(m=>{if(m.type!=="declaration")return;const{property:f,value:g}=m;u?i(f,g,m):g&&(l=l||{},l[f]=g)}),l}return Do}var tc={},ow;function FX(){if(ow)return tc;ow=1,Object.defineProperty(tc,"__esModule",{value:!0}),tc.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,a=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,l=function(f){return!f||n.test(f)||e.test(f)},c=function(f,g){return g.toUpperCase()},u=function(f,g){return"".concat(g,"-")},m=function(f,g){return g===void 0&&(g={}),l(f)?f:(f=f.toLowerCase(),g.reactCompat?f=f.replace(i,u):f=f.replace(a,u),f.replace(t,c))};return tc.camelCase=m,tc}var nc,lw;function UX(){if(lw)return nc;lw=1;var e=nc&&nc.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e($X()),n=FX();function a(i,l){var c={};return!i||typeof i!="string"||(0,t.default)(i,function(u,m){u&&m&&(c[(0,n.camelCase)(u,l)]=m)}),c}return a.default=a,nc=a,nc}var GX=UX();const KX=Bc(GX),e5=t5("end"),cb=t5("start");function t5(e){return t;function t(n){const a=n&&n.position&&n.position[e]||{};if(typeof a.line=="number"&&a.line>0&&typeof a.column=="number"&&a.column>0)return{line:a.line,column:a.column,offset:typeof a.offset=="number"&&a.offset>-1?a.offset:void 0}}}function VX(e){const t=cb(e),n=e5(e);if(t&&n)return{start:t,end:n}}function bc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?cw(e.position):"start"in e||"end"in e?cw(e):"line"in e||"column"in e?hg(e):""}function hg(e){return dw(e&&e.line)+":"+dw(e&&e.column)}function cw(e){return hg(e&&e.start)+"-"+hg(e&&e.end)}function dw(e){return e&&typeof e=="number"?e:1}class ha extends Error{constructor(t,n,a){super(),typeof n=="string"&&(a=n,n=void 0);let i="",l={},c=!1;if(n&&("line"in n&&"column"in n?l={place:n}:"start"in n&&"end"in n?l={place:n}:"type"in n?l={ancestors:[n],place:n.position}:l={...n}),typeof t=="string"?i=t:!l.cause&&t&&(c=!0,i=t.message,l.cause=t),!l.ruleId&&!l.source&&typeof a=="string"){const m=a.indexOf(":");m===-1?l.ruleId=a:(l.source=a.slice(0,m),l.ruleId=a.slice(m+1))}if(!l.place&&l.ancestors&&l.ancestors){const m=l.ancestors[l.ancestors.length-1];m&&(l.place=m.position)}const u=l.place&&"start"in l.place?l.place.start:l.place;this.ancestors=l.ancestors||void 0,this.cause=l.cause||void 0,this.column=u?u.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=u?u.line:void 0,this.name=bc(l.place)||"1:1",this.place=l.place||void 0,this.reason=this.message,this.ruleId=l.ruleId||void 0,this.source=l.source||void 0,this.stack=c&&l.cause&&typeof l.cause.stack=="string"?l.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}ha.prototype.file="";ha.prototype.name="";ha.prototype.reason="";ha.prototype.message="";ha.prototype.stack="";ha.prototype.column=void 0;ha.prototype.line=void 0;ha.prototype.ancestors=void 0;ha.prototype.cause=void 0;ha.prototype.fatal=void 0;ha.prototype.place=void 0;ha.prototype.ruleId=void 0;ha.prototype.source=void 0;const db={}.hasOwnProperty,WX=new Map,YX=/[A-Z]/g,QX=new Set(["table","tbody","thead","tfoot","tr"]),JX=new Set(["td","th"]),n5="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function XX(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let a;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");a=sZ(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");a=iZ(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:a,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?np:ZS,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},l=a5(i,e,void 0);return l&&typeof l!="string"?l:i.create(e,i.Fragment,{children:l||void 0},void 0)}function a5(e,t,n){if(t.type==="element")return ZX(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return eZ(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return nZ(e,t,n);if(t.type==="mdxjsEsm")return tZ(e,t);if(t.type==="root")return aZ(e,t,n);if(t.type==="text")return rZ(e,t)}function ZX(e,t,n){const a=e.schema;let i=a;t.tagName.toLowerCase()==="svg"&&a.space==="html"&&(i=np,e.schema=i),e.ancestors.push(t);const l=i5(e,t.tagName,!1),c=oZ(e,t);let u=mb(e,t);return QX.has(t.tagName)&&(u=u.filter(function(m){return typeof m=="string"?!RX(m):!0})),r5(e,c,l,t),ub(c,u),e.ancestors.pop(),e.schema=a,e.create(t,l,c,n)}function eZ(e,t){if(t.data&&t.data.estree&&e.evaluater){const a=t.data.estree.body[0];return a.type,e.evaluater.evaluateExpression(a.expression)}Ic(e,t.position)}function tZ(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Ic(e,t.position)}function nZ(e,t,n){const a=e.schema;let i=a;t.name==="svg"&&a.space==="html"&&(i=np,e.schema=i),e.ancestors.push(t);const l=t.name===null?e.Fragment:i5(e,t.name,!0),c=lZ(e,t),u=mb(e,t);return r5(e,c,l,t),ub(c,u),e.ancestors.pop(),e.schema=a,e.create(t,l,c,n)}function aZ(e,t,n){const a={};return ub(a,mb(e,t)),e.create(t,e.Fragment,a,n)}function rZ(e,t){return t.value}function r5(e,t,n,a){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=a)}function ub(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function iZ(e,t,n){return a;function a(i,l,c,u){const f=Array.isArray(c.children)?n:t;return u?f(l,c,u):f(l,c)}}function sZ(e,t){return n;function n(a,i,l,c){const u=Array.isArray(l.children),m=cb(a);return t(i,l,c,u,{columnNumber:m?m.column-1:void 0,fileName:e,lineNumber:m?m.line:void 0},void 0)}}function oZ(e,t){const n={};let a,i;for(i in t.properties)if(i!=="children"&&db.call(t.properties,i)){const l=cZ(e,i,t.properties[i]);if(l){const[c,u]=l;e.tableCellAlignToStyle&&c==="align"&&typeof u=="string"&&JX.has(t.tagName)?a=u:n[c]=u}}if(a){const l=n.style||(n.style={});l[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=a}return n}function lZ(e,t){const n={};for(const a of t.attributes)if(a.type==="mdxJsxExpressionAttribute")if(a.data&&a.data.estree&&e.evaluater){const l=a.data.estree.body[0];l.type;const c=l.expression;c.type;const u=c.properties[0];u.type,Object.assign(n,e.evaluater.evaluateExpression(u.argument))}else Ic(e,t.position);else{const i=a.name;let l;if(a.value&&typeof a.value=="object")if(a.value.data&&a.value.data.estree&&e.evaluater){const u=a.value.data.estree.body[0];u.type,l=e.evaluater.evaluateExpression(u.expression)}else Ic(e,t.position);else l=a.value===null?!0:a.value;n[i]=l}return n}function mb(e,t){const n=[];let a=-1;const i=e.passKeys?new Map:WX;for(;++a<t.children.length;){const l=t.children[a];let c;if(e.passKeys){const m=l.type==="element"?l.tagName:l.type==="mdxJsxFlowElement"||l.type==="mdxJsxTextElement"?l.name:void 0;if(m){const f=i.get(m)||0;c=m+"-"+f,i.set(m,f+1)}}const u=a5(e,l,c);u!==void 0&&n.push(u)}return n}function cZ(e,t,n){const a=XS(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=a.commaSeparated?TX(n):zX(n)),a.property==="style"){let i=typeof n=="object"?n:dZ(e,String(n));return e.stylePropertyNameCase==="css"&&(i=uZ(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&a.space?LX[a.property]||a.property:a.attribute,n]}}function dZ(e,t){try{return KX(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const a=n,i=new ha("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:a,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=n5+"#cannot-parse-style-attribute",i}}function i5(e,t,n){let a;if(!n)a={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let l=-1,c;for(;++l<i.length;){const u=ew(i[l])?{type:"Identifier",name:i[l]}:{type:"Literal",value:i[l]};c=c?{type:"MemberExpression",object:c,property:u,computed:!!(l&&u.type==="Literal"),optional:!1}:u}a=c}else a=ew(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(a.type==="Literal"){const i=a.value;return db.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(a);Ic(e)}function Ic(e,t){const n=new ha("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=n5+"#cannot-handle-mdx-estrees-without-createevaluater",n}function uZ(e){const t={};let n;for(n in e)db.call(e,n)&&(t[mZ(n)]=e[n]);return t}function mZ(e){let t=e.replace(YX,pZ);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function pZ(e){return"-"+e.toLowerCase()}const Qh={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},fZ={};function pb(e,t){const n=fZ,a=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return s5(e,a,i)}function s5(e,t,n){if(hZ(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return uw(e.children,t,n)}return Array.isArray(e)?uw(e,t,n):""}function uw(e,t,n){const a=[];let i=-1;for(;++i<e.length;)a[i]=s5(e[i],t,n);return a.join("")}function hZ(e){return!!(e&&typeof e=="object")}const mw=document.createElement("i");function fb(e){const t="&"+e+";";mw.innerHTML=t;const n=mw.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Ya(e,t,n,a){const i=e.length;let l=0,c;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,a.length<1e4)c=Array.from(a),c.unshift(t,n),e.splice(...c);else for(n&&e.splice(t,n);l<a.length;)c=a.slice(l,l+1e4),c.unshift(t,0),e.splice(...c),l+=1e4,t+=1e4}function dr(e,t){return e.length>0?(Ya(e,e.length,0,t),e):t}const pw={}.hasOwnProperty;function o5(e){const t={};let n=-1;for(;++n<e.length;)gZ(t,e[n]);return t}function gZ(e,t){let n;for(n in t){const i=(pw.call(e,n)?e[n]:void 0)||(e[n]={}),l=t[n];let c;if(l)for(c in l){pw.call(i,c)||(i[c]=[]);const u=l[c];bZ(i[c],Array.isArray(u)?u:u?[u]:[])}}}function bZ(e,t){let n=-1;const a=[];for(;++n<t.length;)(t[n].add==="after"?e:a).push(t[n]);Ya(e,0,0,a)}function l5(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function wr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ka=rs(/[A-Za-z]/),ma=rs(/[\dA-Za-z]/),yZ=rs(/[#-'*+\--9=?A-Z^-~]/);function jm(e){return e!==null&&(e<32||e===127)}const gg=rs(/\d/),vZ=rs(/[\dA-Fa-f]/),xZ=rs(/[!-/:-@[-`{-~]/);function vt(e){return e!==null&&e<-2}function kn(e){return e!==null&&(e<0||e===32)}function Qt(e){return e===-2||e===-1||e===32}const ap=rs(new RegExp("\\p{P}|\\p{S}","u")),zs=rs(/\s/);function rs(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function el(e){const t=[];let n=-1,a=0,i=0;for(;++n<e.length;){const l=e.charCodeAt(n);let c="";if(l===37&&ma(e.charCodeAt(n+1))&&ma(e.charCodeAt(n+2)))i=2;else if(l<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(l))||(c=String.fromCharCode(l));else if(l>55295&&l<57344){const u=e.charCodeAt(n+1);l<56320&&u>56319&&u<57344?(c=String.fromCharCode(l,u),i=1):c="�"}else c=String.fromCharCode(l);c&&(t.push(e.slice(a,n),encodeURIComponent(c)),a=n+i+1,c=""),i&&(n+=i,i=0)}return t.join("")+e.slice(a)}function Vt(e,t,n,a){const i=a?a-1:Number.POSITIVE_INFINITY;let l=0;return c;function c(m){return Qt(m)?(e.enter(n),u(m)):t(m)}function u(m){return Qt(m)&&l++<i?(e.consume(m),u):(e.exit(n),t(m))}}const wZ={tokenize:kZ};function kZ(e){const t=e.attempt(this.parser.constructs.contentInitial,a,i);let n;return t;function a(u){if(u===null){e.consume(u);return}return e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),Vt(e,t,"linePrefix")}function i(u){return e.enter("paragraph"),l(u)}function l(u){const m=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=m),n=m,c(u)}function c(u){if(u===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(u);return}return vt(u)?(e.consume(u),e.exit("chunkText"),l):(e.consume(u),c)}}const SZ={tokenize:CZ},fw={tokenize:AZ};function CZ(e){const t=this,n=[];let a=0,i,l,c;return u;function u(I){if(a<n.length){const B=n[a];return t.containerState=B[1],e.attempt(B[0].continuation,m,f)(I)}return f(I)}function m(I){if(a++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&M();const B=t.events.length;let G=B,j;for(;G--;)if(t.events[G][0]==="exit"&&t.events[G][1].type==="chunkFlow"){j=t.events[G][1].end;break}A(a);let O=B;for(;O<t.events.length;)t.events[O][1].end={...j},O++;return Ya(t.events,G+1,0,t.events.slice(B)),t.events.length=O,f(I)}return u(I)}function f(I){if(a===n.length){if(!i)return b(I);if(i.currentConstruct&&i.currentConstruct.concrete)return k(I);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(fw,g,h)(I)}function g(I){return i&&M(),A(a),b(I)}function h(I){return t.parser.lazy[t.now().line]=a!==n.length,c=t.now().offset,k(I)}function b(I){return t.containerState={},e.attempt(fw,y,k)(I)}function y(I){return a++,n.push([t.currentConstruct,t.containerState]),b(I)}function k(I){if(I===null){i&&M(),A(0),e.consume(I);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:l}),C(I)}function C(I){if(I===null){T(e.exit("chunkFlow"),!0),A(0),e.consume(I);return}return vt(I)?(e.consume(I),T(e.exit("chunkFlow")),a=0,t.interrupt=void 0,u):(e.consume(I),C)}function T(I,B){const G=t.sliceStream(I);if(B&&G.push(null),I.previous=l,l&&(l.next=I),l=I,i.defineSkip(I.start),i.write(G),t.parser.lazy[I.start.line]){let j=i.events.length;for(;j--;)if(i.events[j][1].start.offset<c&&(!i.events[j][1].end||i.events[j][1].end.offset>c))return;const O=t.events.length;let F=O,Y,q;for(;F--;)if(t.events[F][0]==="exit"&&t.events[F][1].type==="chunkFlow"){if(Y){q=t.events[F][1].end;break}Y=!0}for(A(a),j=O;j<t.events.length;)t.events[j][1].end={...q},j++;Ya(t.events,F+1,0,t.events.slice(O)),t.events.length=j}}function A(I){let B=n.length;for(;B-- >I;){const G=n[B];t.containerState=G[1],G[0].exit.call(t,e)}n.length=I}function M(){i.write([null]),l=void 0,i=void 0,t.containerState._closeFlow=void 0}}function AZ(e,t,n){return Vt(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Vo(e){if(e===null||kn(e)||zs(e))return 1;if(ap(e))return 2}function rp(e,t,n){const a=[];let i=-1;for(;++i<e.length;){const l=e[i].resolveAll;l&&!a.includes(l)&&(t=l(t,n),a.push(l))}return t}const bg={name:"attention",resolveAll:TZ,tokenize:EZ};function TZ(e,t){let n=-1,a,i,l,c,u,m,f,g;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(a=n;a--;)if(e[a][0]==="exit"&&e[a][1].type==="attentionSequence"&&e[a][1]._open&&t.sliceSerialize(e[a][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[a][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[a][1].end.offset-e[a][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;m=e[a][1].end.offset-e[a][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const h={...e[a][1].end},b={...e[n][1].start};hw(h,-m),hw(b,m),c={type:m>1?"strongSequence":"emphasisSequence",start:h,end:{...e[a][1].end}},u={type:m>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:b},l={type:m>1?"strongText":"emphasisText",start:{...e[a][1].end},end:{...e[n][1].start}},i={type:m>1?"strong":"emphasis",start:{...c.start},end:{...u.end}},e[a][1].end={...c.start},e[n][1].start={...u.end},f=[],e[a][1].end.offset-e[a][1].start.offset&&(f=dr(f,[["enter",e[a][1],t],["exit",e[a][1],t]])),f=dr(f,[["enter",i,t],["enter",c,t],["exit",c,t],["enter",l,t]]),f=dr(f,rp(t.parser.constructs.insideSpan.null,e.slice(a+1,n),t)),f=dr(f,[["exit",l,t],["enter",u,t],["exit",u,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(g=2,f=dr(f,[["enter",e[n][1],t],["exit",e[n][1],t]])):g=0,Ya(e,a-1,n-a+3,f),n=a+f.length-g-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function EZ(e,t){const n=this.parser.constructs.attentionMarkers.null,a=this.previous,i=Vo(a);let l;return c;function c(m){return l=m,e.enter("attentionSequence"),u(m)}function u(m){if(m===l)return e.consume(m),u;const f=e.exit("attentionSequence"),g=Vo(m),h=!g||g===2&&i||n.includes(m),b=!i||i===2&&g||n.includes(a);return f._open=!!(l===42?h:h&&(i||!b)),f._close=!!(l===42?b:b&&(g||!h)),t(m)}}function hw(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const NZ={name:"autolink",tokenize:MZ};function MZ(e,t,n){let a=0;return i;function i(y){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),l}function l(y){return ka(y)?(e.consume(y),c):y===64?n(y):f(y)}function c(y){return y===43||y===45||y===46||ma(y)?(a=1,u(y)):f(y)}function u(y){return y===58?(e.consume(y),a=0,m):(y===43||y===45||y===46||ma(y))&&a++<32?(e.consume(y),u):(a=0,f(y))}function m(y){return y===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),t):y===null||y===32||y===60||jm(y)?n(y):(e.consume(y),m)}function f(y){return y===64?(e.consume(y),g):yZ(y)?(e.consume(y),f):n(y)}function g(y){return ma(y)?h(y):n(y)}function h(y){return y===46?(e.consume(y),a=0,g):y===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),t):b(y)}function b(y){if((y===45||ma(y))&&a++<63){const k=y===45?b:h;return e.consume(y),k}return n(y)}}const $c={partial:!0,tokenize:jZ};function jZ(e,t,n){return a;function a(l){return Qt(l)?Vt(e,i,"linePrefix")(l):i(l)}function i(l){return l===null||vt(l)?t(l):n(l)}}const c5={continuation:{tokenize:_Z},exit:DZ,name:"blockQuote",tokenize:RZ};function RZ(e,t,n){const a=this;return i;function i(c){if(c===62){const u=a.containerState;return u.open||(e.enter("blockQuote",{_container:!0}),u.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(c),e.exit("blockQuoteMarker"),l}return n(c)}function l(c){return Qt(c)?(e.enter("blockQuotePrefixWhitespace"),e.consume(c),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(c))}}function _Z(e,t,n){const a=this;return i;function i(c){return Qt(c)?Vt(e,l,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):l(c)}function l(c){return e.attempt(c5,t,n)(c)}}function DZ(e){e.exit("blockQuote")}const d5={name:"characterEscape",tokenize:IZ};function IZ(e,t,n){return a;function a(l){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(l),e.exit("escapeMarker"),i}function i(l){return xZ(l)?(e.enter("characterEscapeValue"),e.consume(l),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(l)}}const u5={name:"characterReference",tokenize:LZ};function LZ(e,t,n){const a=this;let i=0,l,c;return u;function u(h){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),m}function m(h){return h===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(h),e.exit("characterReferenceMarkerNumeric"),f):(e.enter("characterReferenceValue"),l=31,c=ma,g(h))}function f(h){return h===88||h===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(h),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),l=6,c=vZ,g):(e.enter("characterReferenceValue"),l=7,c=gg,g(h))}function g(h){if(h===59&&i){const b=e.exit("characterReferenceValue");return c===ma&&!fb(a.sliceSerialize(b))?n(h):(e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return c(h)&&i++<l?(e.consume(h),g):n(h)}}const gw={partial:!0,tokenize:OZ},bw={concrete:!0,name:"codeFenced",tokenize:PZ};function PZ(e,t,n){const a=this,i={partial:!0,tokenize:G};let l=0,c=0,u;return m;function m(j){return f(j)}function f(j){const O=a.events[a.events.length-1];return l=O&&O[1].type==="linePrefix"?O[2].sliceSerialize(O[1],!0).length:0,u=j,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),g(j)}function g(j){return j===u?(c++,e.consume(j),g):c<3?n(j):(e.exit("codeFencedFenceSequence"),Qt(j)?Vt(e,h,"whitespace")(j):h(j))}function h(j){return j===null||vt(j)?(e.exit("codeFencedFence"),a.interrupt?t(j):e.check(gw,C,B)(j)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),b(j))}function b(j){return j===null||vt(j)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),h(j)):Qt(j)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Vt(e,y,"whitespace")(j)):j===96&&j===u?n(j):(e.consume(j),b)}function y(j){return j===null||vt(j)?h(j):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),k(j))}function k(j){return j===null||vt(j)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),h(j)):j===96&&j===u?n(j):(e.consume(j),k)}function C(j){return e.attempt(i,B,T)(j)}function T(j){return e.enter("lineEnding"),e.consume(j),e.exit("lineEnding"),A}function A(j){return l>0&&Qt(j)?Vt(e,M,"linePrefix",l+1)(j):M(j)}function M(j){return j===null||vt(j)?e.check(gw,C,B)(j):(e.enter("codeFlowValue"),I(j))}function I(j){return j===null||vt(j)?(e.exit("codeFlowValue"),M(j)):(e.consume(j),I)}function B(j){return e.exit("codeFenced"),t(j)}function G(j,O,F){let Y=0;return q;function q(ee){return j.enter("lineEnding"),j.consume(ee),j.exit("lineEnding"),V}function V(ee){return j.enter("codeFencedFence"),Qt(ee)?Vt(j,z,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(ee):z(ee)}function z(ee){return ee===u?(j.enter("codeFencedFenceSequence"),J(ee)):F(ee)}function J(ee){return ee===u?(Y++,j.consume(ee),J):Y>=c?(j.exit("codeFencedFenceSequence"),Qt(ee)?Vt(j,D,"whitespace")(ee):D(ee)):F(ee)}function D(ee){return ee===null||vt(ee)?(j.exit("codeFencedFence"),O(ee)):F(ee)}}}function OZ(e,t,n){const a=this;return i;function i(c){return c===null?n(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),l)}function l(c){return a.parser.lazy[a.now().line]?n(c):t(c)}}const Jh={name:"codeIndented",tokenize:BZ},HZ={partial:!0,tokenize:zZ};function BZ(e,t,n){const a=this;return i;function i(f){return e.enter("codeIndented"),Vt(e,l,"linePrefix",5)(f)}function l(f){const g=a.events[a.events.length-1];return g&&g[1].type==="linePrefix"&&g[2].sliceSerialize(g[1],!0).length>=4?c(f):n(f)}function c(f){return f===null?m(f):vt(f)?e.attempt(HZ,c,m)(f):(e.enter("codeFlowValue"),u(f))}function u(f){return f===null||vt(f)?(e.exit("codeFlowValue"),c(f)):(e.consume(f),u)}function m(f){return e.exit("codeIndented"),t(f)}}function zZ(e,t,n){const a=this;return i;function i(c){return a.parser.lazy[a.now().line]?n(c):vt(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),i):Vt(e,l,"linePrefix",5)(c)}function l(c){const u=a.events[a.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?t(c):vt(c)?i(c):n(c)}}const qZ={name:"codeText",previous:FZ,resolve:$Z,tokenize:UZ};function $Z(e){let t=e.length-4,n=3,a,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(a=n;++a<t;)if(e[a][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(a=n-1,t++;++a<=t;)i===void 0?a!==t&&e[a][1].type!=="lineEnding"&&(i=a):(a===t||e[a][1].type==="lineEnding")&&(e[i][1].type="codeTextData",a!==i+2&&(e[i][1].end=e[a-1][1].end,e.splice(i+2,a-i-2),t-=a-i-2,a=i+2),i=void 0);return e}function FZ(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function UZ(e,t,n){let a=0,i,l;return c;function c(h){return e.enter("codeText"),e.enter("codeTextSequence"),u(h)}function u(h){return h===96?(e.consume(h),a++,u):(e.exit("codeTextSequence"),m(h))}function m(h){return h===null?n(h):h===32?(e.enter("space"),e.consume(h),e.exit("space"),m):h===96?(l=e.enter("codeTextSequence"),i=0,g(h)):vt(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),m):(e.enter("codeTextData"),f(h))}function f(h){return h===null||h===32||h===96||vt(h)?(e.exit("codeTextData"),m(h)):(e.consume(h),f)}function g(h){return h===96?(e.consume(h),i++,g):i===a?(e.exit("codeTextSequence"),e.exit("codeText"),t(h)):(l.type="codeTextData",f(h))}}class GZ{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const a=n??Number.POSITIVE_INFINITY;return a<this.left.length?this.left.slice(t,a):t>this.left.length?this.right.slice(this.right.length-a+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-a+this.left.length).reverse())}splice(t,n,a){const i=n||0;this.setCursor(Math.trunc(t));const l=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return a&&ac(this.left,a),l.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),ac(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),ac(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);ac(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);ac(this.left,n.reverse())}}}function ac(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function m5(e){const t={};let n=-1,a,i,l,c,u,m,f;const g=new GZ(e);for(;++n<g.length;){for(;n in t;)n=t[n];if(a=g.get(n),n&&a[1].type==="chunkFlow"&&g.get(n-1)[1].type==="listItemPrefix"&&(m=a[1]._tokenizer.events,l=0,l<m.length&&m[l][1].type==="lineEndingBlank"&&(l+=2),l<m.length&&m[l][1].type==="content"))for(;++l<m.length&&m[l][1].type!=="content";)m[l][1].type==="chunkText"&&(m[l][1]._isInFirstContentOfListItem=!0,l++);if(a[0]==="enter")a[1].contentType&&(Object.assign(t,KZ(g,n)),n=t[n],f=!0);else if(a[1]._container){for(l=n,i=void 0;l--;)if(c=g.get(l),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(i&&(g.get(i)[1].type="lineEndingBlank"),c[1].type="lineEnding",i=l);else if(!(c[1].type==="linePrefix"||c[1].type==="listItemIndent"))break;i&&(a[1].end={...g.get(i)[1].start},u=g.slice(i,n),u.unshift(a),g.splice(i,n-i+1,u))}}return Ya(e,0,Number.POSITIVE_INFINITY,g.slice(0)),!f}function KZ(e,t){const n=e.get(t)[1],a=e.get(t)[2];let i=t-1;const l=[];let c=n._tokenizer;c||(c=a.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));const u=c.events,m=[],f={};let g,h,b=-1,y=n,k=0,C=0;const T=[C];for(;y;){for(;e.get(++i)[1]!==y;);l.push(i),y._tokenizer||(g=a.sliceStream(y),y.next||g.push(null),h&&c.defineSkip(y.start),y._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(g),y._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),h=y,y=y.next}for(y=n;++b<u.length;)u[b][0]==="exit"&&u[b-1][0]==="enter"&&u[b][1].type===u[b-1][1].type&&u[b][1].start.line!==u[b][1].end.line&&(C=b+1,T.push(C),y._tokenizer=void 0,y.previous=void 0,y=y.next);for(c.events=[],y?(y._tokenizer=void 0,y.previous=void 0):T.pop(),b=T.length;b--;){const A=u.slice(T[b],T[b+1]),M=l.pop();m.push([M,M+A.length-1]),e.splice(M,2,A)}for(m.reverse(),b=-1;++b<m.length;)f[k+m[b][0]]=k+m[b][1],k+=m[b][1]-m[b][0]-1;return f}const VZ={resolve:YZ,tokenize:QZ},WZ={partial:!0,tokenize:JZ};function YZ(e){return m5(e),e}function QZ(e,t){let n;return a;function a(u){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(u)}function i(u){return u===null?l(u):vt(u)?e.check(WZ,c,l)(u):(e.consume(u),i)}function l(u){return e.exit("chunkContent"),e.exit("content"),t(u)}function c(u){return e.consume(u),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function JZ(e,t,n){const a=this;return i;function i(c){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),Vt(e,l,"linePrefix")}function l(c){if(c===null||vt(c))return n(c);const u=a.events[a.events.length-1];return!a.parser.constructs.disable.null.includes("codeIndented")&&u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?t(c):e.interrupt(a.parser.constructs.flow,n,t)(c)}}function p5(e,t,n,a,i,l,c,u,m){const f=m||Number.POSITIVE_INFINITY;let g=0;return h;function h(A){return A===60?(e.enter(a),e.enter(i),e.enter(l),e.consume(A),e.exit(l),b):A===null||A===32||A===41||jm(A)?n(A):(e.enter(a),e.enter(c),e.enter(u),e.enter("chunkString",{contentType:"string"}),C(A))}function b(A){return A===62?(e.enter(l),e.consume(A),e.exit(l),e.exit(i),e.exit(a),t):(e.enter(u),e.enter("chunkString",{contentType:"string"}),y(A))}function y(A){return A===62?(e.exit("chunkString"),e.exit(u),b(A)):A===null||A===60||vt(A)?n(A):(e.consume(A),A===92?k:y)}function k(A){return A===60||A===62||A===92?(e.consume(A),y):y(A)}function C(A){return!g&&(A===null||A===41||kn(A))?(e.exit("chunkString"),e.exit(u),e.exit(c),e.exit(a),t(A)):g<f&&A===40?(e.consume(A),g++,C):A===41?(e.consume(A),g--,C):A===null||A===32||A===40||jm(A)?n(A):(e.consume(A),A===92?T:C)}function T(A){return A===40||A===41||A===92?(e.consume(A),C):C(A)}}function f5(e,t,n,a,i,l){const c=this;let u=0,m;return f;function f(y){return e.enter(a),e.enter(i),e.consume(y),e.exit(i),e.enter(l),g}function g(y){return u>999||y===null||y===91||y===93&&!m||y===94&&!u&&"_hiddenFootnoteSupport"in c.parser.constructs?n(y):y===93?(e.exit(l),e.enter(i),e.consume(y),e.exit(i),e.exit(a),t):vt(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),g):(e.enter("chunkString",{contentType:"string"}),h(y))}function h(y){return y===null||y===91||y===93||vt(y)||u++>999?(e.exit("chunkString"),g(y)):(e.consume(y),m||(m=!Qt(y)),y===92?b:h)}function b(y){return y===91||y===92||y===93?(e.consume(y),u++,h):h(y)}}function h5(e,t,n,a,i,l){let c;return u;function u(b){return b===34||b===39||b===40?(e.enter(a),e.enter(i),e.consume(b),e.exit(i),c=b===40?41:b,m):n(b)}function m(b){return b===c?(e.enter(i),e.consume(b),e.exit(i),e.exit(a),t):(e.enter(l),f(b))}function f(b){return b===c?(e.exit(l),m(c)):b===null?n(b):vt(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),Vt(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),g(b))}function g(b){return b===c||b===null||vt(b)?(e.exit("chunkString"),f(b)):(e.consume(b),b===92?h:g)}function h(b){return b===c||b===92?(e.consume(b),g):g(b)}}function yc(e,t){let n;return a;function a(i){return vt(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,a):Qt(i)?Vt(e,a,n?"linePrefix":"lineSuffix")(i):t(i)}}const XZ={name:"definition",tokenize:eee},ZZ={partial:!0,tokenize:tee};function eee(e,t,n){const a=this;let i;return l;function l(y){return e.enter("definition"),c(y)}function c(y){return f5.call(a,e,u,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function u(y){return i=wr(a.sliceSerialize(a.events[a.events.length-1][1]).slice(1,-1)),y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),m):n(y)}function m(y){return kn(y)?yc(e,f)(y):f(y)}function f(y){return p5(e,g,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function g(y){return e.attempt(ZZ,h,h)(y)}function h(y){return Qt(y)?Vt(e,b,"whitespace")(y):b(y)}function b(y){return y===null||vt(y)?(e.exit("definition"),a.parser.defined.push(i),t(y)):n(y)}}function tee(e,t,n){return a;function a(u){return kn(u)?yc(e,i)(u):n(u)}function i(u){return h5(e,l,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(u)}function l(u){return Qt(u)?Vt(e,c,"whitespace")(u):c(u)}function c(u){return u===null||vt(u)?t(u):n(u)}}const nee={name:"hardBreakEscape",tokenize:aee};function aee(e,t,n){return a;function a(l){return e.enter("hardBreakEscape"),e.consume(l),i}function i(l){return vt(l)?(e.exit("hardBreakEscape"),t(l)):n(l)}}const ree={name:"headingAtx",resolve:iee,tokenize:see};function iee(e,t){let n=e.length-2,a=3,i,l;return e[a][1].type==="whitespace"&&(a+=2),n-2>a&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(a===n-1||n-4>a&&e[n-2][1].type==="whitespace")&&(n-=a+1===n?2:4),n>a&&(i={type:"atxHeadingText",start:e[a][1].start,end:e[n][1].end},l={type:"chunkText",start:e[a][1].start,end:e[n][1].end,contentType:"text"},Ya(e,a,n-a+1,[["enter",i,t],["enter",l,t],["exit",l,t],["exit",i,t]])),e}function see(e,t,n){let a=0;return i;function i(g){return e.enter("atxHeading"),l(g)}function l(g){return e.enter("atxHeadingSequence"),c(g)}function c(g){return g===35&&a++<6?(e.consume(g),c):g===null||kn(g)?(e.exit("atxHeadingSequence"),u(g)):n(g)}function u(g){return g===35?(e.enter("atxHeadingSequence"),m(g)):g===null||vt(g)?(e.exit("atxHeading"),t(g)):Qt(g)?Vt(e,u,"whitespace")(g):(e.enter("atxHeadingText"),f(g))}function m(g){return g===35?(e.consume(g),m):(e.exit("atxHeadingSequence"),u(g))}function f(g){return g===null||g===35||kn(g)?(e.exit("atxHeadingText"),u(g)):(e.consume(g),f)}}const oee=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],yw=["pre","script","style","textarea"],lee={concrete:!0,name:"htmlFlow",resolveTo:uee,tokenize:mee},cee={partial:!0,tokenize:fee},dee={partial:!0,tokenize:pee};function uee(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function mee(e,t,n){const a=this;let i,l,c,u,m;return f;function f(L){return g(L)}function g(L){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(L),h}function h(L){return L===33?(e.consume(L),b):L===47?(e.consume(L),l=!0,C):L===63?(e.consume(L),i=3,a.interrupt?t:$):ka(L)?(e.consume(L),c=String.fromCharCode(L),T):n(L)}function b(L){return L===45?(e.consume(L),i=2,y):L===91?(e.consume(L),i=5,u=0,k):ka(L)?(e.consume(L),i=4,a.interrupt?t:$):n(L)}function y(L){return L===45?(e.consume(L),a.interrupt?t:$):n(L)}function k(L){const Ne="CDATA[";return L===Ne.charCodeAt(u++)?(e.consume(L),u===Ne.length?a.interrupt?t:z:k):n(L)}function C(L){return ka(L)?(e.consume(L),c=String.fromCharCode(L),T):n(L)}function T(L){if(L===null||L===47||L===62||kn(L)){const Ne=L===47,qe=c.toLowerCase();return!Ne&&!l&&yw.includes(qe)?(i=1,a.interrupt?t(L):z(L)):oee.includes(c.toLowerCase())?(i=6,Ne?(e.consume(L),A):a.interrupt?t(L):z(L)):(i=7,a.interrupt&&!a.parser.lazy[a.now().line]?n(L):l?M(L):I(L))}return L===45||ma(L)?(e.consume(L),c+=String.fromCharCode(L),T):n(L)}function A(L){return L===62?(e.consume(L),a.interrupt?t:z):n(L)}function M(L){return Qt(L)?(e.consume(L),M):q(L)}function I(L){return L===47?(e.consume(L),q):L===58||L===95||ka(L)?(e.consume(L),B):Qt(L)?(e.consume(L),I):q(L)}function B(L){return L===45||L===46||L===58||L===95||ma(L)?(e.consume(L),B):G(L)}function G(L){return L===61?(e.consume(L),j):Qt(L)?(e.consume(L),G):I(L)}function j(L){return L===null||L===60||L===61||L===62||L===96?n(L):L===34||L===39?(e.consume(L),m=L,O):Qt(L)?(e.consume(L),j):F(L)}function O(L){return L===m?(e.consume(L),m=null,Y):L===null||vt(L)?n(L):(e.consume(L),O)}function F(L){return L===null||L===34||L===39||L===47||L===60||L===61||L===62||L===96||kn(L)?G(L):(e.consume(L),F)}function Y(L){return L===47||L===62||Qt(L)?I(L):n(L)}function q(L){return L===62?(e.consume(L),V):n(L)}function V(L){return L===null||vt(L)?z(L):Qt(L)?(e.consume(L),V):n(L)}function z(L){return L===45&&i===2?(e.consume(L),R):L===60&&i===1?(e.consume(L),te):L===62&&i===4?(e.consume(L),W):L===63&&i===3?(e.consume(L),$):L===93&&i===5?(e.consume(L),ke):vt(L)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(cee,oe,J)(L)):L===null||vt(L)?(e.exit("htmlFlowData"),J(L)):(e.consume(L),z)}function J(L){return e.check(dee,D,oe)(L)}function D(L){return e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),ee}function ee(L){return L===null||vt(L)?J(L):(e.enter("htmlFlowData"),z(L))}function R(L){return L===45?(e.consume(L),$):z(L)}function te(L){return L===47?(e.consume(L),c="",le):z(L)}function le(L){if(L===62){const Ne=c.toLowerCase();return yw.includes(Ne)?(e.consume(L),W):z(L)}return ka(L)&&c.length<8?(e.consume(L),c+=String.fromCharCode(L),le):z(L)}function ke(L){return L===93?(e.consume(L),$):z(L)}function $(L){return L===62?(e.consume(L),W):L===45&&i===2?(e.consume(L),$):z(L)}function W(L){return L===null||vt(L)?(e.exit("htmlFlowData"),oe(L)):(e.consume(L),W)}function oe(L){return e.exit("htmlFlow"),t(L)}}function pee(e,t,n){const a=this;return i;function i(c){return vt(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),l):n(c)}function l(c){return a.parser.lazy[a.now().line]?n(c):t(c)}}function fee(e,t,n){return a;function a(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt($c,t,n)}}const hee={name:"htmlText",tokenize:gee};function gee(e,t,n){const a=this;let i,l,c;return u;function u($){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume($),m}function m($){return $===33?(e.consume($),f):$===47?(e.consume($),G):$===63?(e.consume($),I):ka($)?(e.consume($),F):n($)}function f($){return $===45?(e.consume($),g):$===91?(e.consume($),l=0,k):ka($)?(e.consume($),M):n($)}function g($){return $===45?(e.consume($),y):n($)}function h($){return $===null?n($):$===45?(e.consume($),b):vt($)?(c=h,te($)):(e.consume($),h)}function b($){return $===45?(e.consume($),y):h($)}function y($){return $===62?R($):$===45?b($):h($)}function k($){const W="CDATA[";return $===W.charCodeAt(l++)?(e.consume($),l===W.length?C:k):n($)}function C($){return $===null?n($):$===93?(e.consume($),T):vt($)?(c=C,te($)):(e.consume($),C)}function T($){return $===93?(e.consume($),A):C($)}function A($){return $===62?R($):$===93?(e.consume($),A):C($)}function M($){return $===null||$===62?R($):vt($)?(c=M,te($)):(e.consume($),M)}function I($){return $===null?n($):$===63?(e.consume($),B):vt($)?(c=I,te($)):(e.consume($),I)}function B($){return $===62?R($):I($)}function G($){return ka($)?(e.consume($),j):n($)}function j($){return $===45||ma($)?(e.consume($),j):O($)}function O($){return vt($)?(c=O,te($)):Qt($)?(e.consume($),O):R($)}function F($){return $===45||ma($)?(e.consume($),F):$===47||$===62||kn($)?Y($):n($)}function Y($){return $===47?(e.consume($),R):$===58||$===95||ka($)?(e.consume($),q):vt($)?(c=Y,te($)):Qt($)?(e.consume($),Y):R($)}function q($){return $===45||$===46||$===58||$===95||ma($)?(e.consume($),q):V($)}function V($){return $===61?(e.consume($),z):vt($)?(c=V,te($)):Qt($)?(e.consume($),V):Y($)}function z($){return $===null||$===60||$===61||$===62||$===96?n($):$===34||$===39?(e.consume($),i=$,J):vt($)?(c=z,te($)):Qt($)?(e.consume($),z):(e.consume($),D)}function J($){return $===i?(e.consume($),i=void 0,ee):$===null?n($):vt($)?(c=J,te($)):(e.consume($),J)}function D($){return $===null||$===34||$===39||$===60||$===61||$===96?n($):$===47||$===62||kn($)?Y($):(e.consume($),D)}function ee($){return $===47||$===62||kn($)?Y($):n($)}function R($){return $===62?(e.consume($),e.exit("htmlTextData"),e.exit("htmlText"),t):n($)}function te($){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume($),e.exit("lineEnding"),le}function le($){return Qt($)?Vt(e,ke,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)($):ke($)}function ke($){return e.enter("htmlTextData"),c($)}}const hb={name:"labelEnd",resolveAll:xee,resolveTo:wee,tokenize:kee},bee={tokenize:See},yee={tokenize:Cee},vee={tokenize:Aee};function xee(e){let t=-1;const n=[];for(;++t<e.length;){const a=e[t][1];if(n.push(e[t]),a.type==="labelImage"||a.type==="labelLink"||a.type==="labelEnd"){const i=a.type==="labelImage"?4:2;a.type="data",t+=i}}return e.length!==n.length&&Ya(e,0,e.length,n),e}function wee(e,t){let n=e.length,a=0,i,l,c,u;for(;n--;)if(i=e[n][1],l){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(c){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(l=n,i.type!=="labelLink")){a=2;break}}else i.type==="labelEnd"&&(c=n);const m={type:e[l][1].type==="labelLink"?"link":"image",start:{...e[l][1].start},end:{...e[e.length-1][1].end}},f={type:"label",start:{...e[l][1].start},end:{...e[c][1].end}},g={type:"labelText",start:{...e[l+a+2][1].end},end:{...e[c-2][1].start}};return u=[["enter",m,t],["enter",f,t]],u=dr(u,e.slice(l+1,l+a+3)),u=dr(u,[["enter",g,t]]),u=dr(u,rp(t.parser.constructs.insideSpan.null,e.slice(l+a+4,c-3),t)),u=dr(u,[["exit",g,t],e[c-2],e[c-1],["exit",f,t]]),u=dr(u,e.slice(c+1)),u=dr(u,[["exit",m,t]]),Ya(e,l,e.length,u),e}function kee(e,t,n){const a=this;let i=a.events.length,l,c;for(;i--;)if((a.events[i][1].type==="labelImage"||a.events[i][1].type==="labelLink")&&!a.events[i][1]._balanced){l=a.events[i][1];break}return u;function u(b){return l?l._inactive?h(b):(c=a.parser.defined.includes(wr(a.sliceSerialize({start:l.end,end:a.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(b),e.exit("labelMarker"),e.exit("labelEnd"),m):n(b)}function m(b){return b===40?e.attempt(bee,g,c?g:h)(b):b===91?e.attempt(yee,g,c?f:h)(b):c?g(b):h(b)}function f(b){return e.attempt(vee,g,h)(b)}function g(b){return t(b)}function h(b){return l._balanced=!0,n(b)}}function See(e,t,n){return a;function a(h){return e.enter("resource"),e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),i}function i(h){return kn(h)?yc(e,l)(h):l(h)}function l(h){return h===41?g(h):p5(e,c,u,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(h)}function c(h){return kn(h)?yc(e,m)(h):g(h)}function u(h){return n(h)}function m(h){return h===34||h===39||h===40?h5(e,f,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(h):g(h)}function f(h){return kn(h)?yc(e,g)(h):g(h)}function g(h){return h===41?(e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),e.exit("resource"),t):n(h)}}function Cee(e,t,n){const a=this;return i;function i(u){return f5.call(a,e,l,c,"reference","referenceMarker","referenceString")(u)}function l(u){return a.parser.defined.includes(wr(a.sliceSerialize(a.events[a.events.length-1][1]).slice(1,-1)))?t(u):n(u)}function c(u){return n(u)}}function Aee(e,t,n){return a;function a(l){return e.enter("reference"),e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),i}function i(l){return l===93?(e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),e.exit("reference"),t):n(l)}}const Tee={name:"labelStartImage",resolveAll:hb.resolveAll,tokenize:Eee};function Eee(e,t,n){const a=this;return i;function i(u){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(u),e.exit("labelImageMarker"),l}function l(u){return u===91?(e.enter("labelMarker"),e.consume(u),e.exit("labelMarker"),e.exit("labelImage"),c):n(u)}function c(u){return u===94&&"_hiddenFootnoteSupport"in a.parser.constructs?n(u):t(u)}}const Nee={name:"labelStartLink",resolveAll:hb.resolveAll,tokenize:Mee};function Mee(e,t,n){const a=this;return i;function i(c){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelLink"),l}function l(c){return c===94&&"_hiddenFootnoteSupport"in a.parser.constructs?n(c):t(c)}}const Xh={name:"lineEnding",tokenize:jee};function jee(e,t){return n;function n(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Vt(e,t,"linePrefix")}}const tm={name:"thematicBreak",tokenize:Ree};function Ree(e,t,n){let a=0,i;return l;function l(f){return e.enter("thematicBreak"),c(f)}function c(f){return i=f,u(f)}function u(f){return f===i?(e.enter("thematicBreakSequence"),m(f)):a>=3&&(f===null||vt(f))?(e.exit("thematicBreak"),t(f)):n(f)}function m(f){return f===i?(e.consume(f),a++,m):(e.exit("thematicBreakSequence"),Qt(f)?Vt(e,u,"whitespace")(f):u(f))}}const Da={continuation:{tokenize:Lee},exit:Oee,name:"list",tokenize:Iee},_ee={partial:!0,tokenize:Hee},Dee={partial:!0,tokenize:Pee};function Iee(e,t,n){const a=this,i=a.events[a.events.length-1];let l=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,c=0;return u;function u(y){const k=a.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(k==="listUnordered"?!a.containerState.marker||y===a.containerState.marker:gg(y)){if(a.containerState.type||(a.containerState.type=k,e.enter(k,{_container:!0})),k==="listUnordered")return e.enter("listItemPrefix"),y===42||y===45?e.check(tm,n,f)(y):f(y);if(!a.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),m(y)}return n(y)}function m(y){return gg(y)&&++c<10?(e.consume(y),m):(!a.interrupt||c<2)&&(a.containerState.marker?y===a.containerState.marker:y===41||y===46)?(e.exit("listItemValue"),f(y)):n(y)}function f(y){return e.enter("listItemMarker"),e.consume(y),e.exit("listItemMarker"),a.containerState.marker=a.containerState.marker||y,e.check($c,a.interrupt?n:g,e.attempt(_ee,b,h))}function g(y){return a.containerState.initialBlankLine=!0,l++,b(y)}function h(y){return Qt(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),b):n(y)}function b(y){return a.containerState.size=l+a.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(y)}}function Lee(e,t,n){const a=this;return a.containerState._closeFlow=void 0,e.check($c,i,l);function i(u){return a.containerState.furtherBlankLines=a.containerState.furtherBlankLines||a.containerState.initialBlankLine,Vt(e,t,"listItemIndent",a.containerState.size+1)(u)}function l(u){return a.containerState.furtherBlankLines||!Qt(u)?(a.containerState.furtherBlankLines=void 0,a.containerState.initialBlankLine=void 0,c(u)):(a.containerState.furtherBlankLines=void 0,a.containerState.initialBlankLine=void 0,e.attempt(Dee,t,c)(u))}function c(u){return a.containerState._closeFlow=!0,a.interrupt=void 0,Vt(e,e.attempt(Da,t,n),"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u)}}function Pee(e,t,n){const a=this;return Vt(e,i,"listItemIndent",a.containerState.size+1);function i(l){const c=a.events[a.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===a.containerState.size?t(l):n(l)}}function Oee(e){e.exit(this.containerState.type)}function Hee(e,t,n){const a=this;return Vt(e,i,"listItemPrefixWhitespace",a.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(l){const c=a.events[a.events.length-1];return!Qt(l)&&c&&c[1].type==="listItemPrefixWhitespace"?t(l):n(l)}}const vw={name:"setextUnderline",resolveTo:Bee,tokenize:zee};function Bee(e,t){let n=e.length,a,i,l;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){a=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!l&&e[n][1].type==="definition"&&(l=n);const c={type:"setextHeading",start:{...e[a][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",l?(e.splice(i,0,["enter",c,t]),e.splice(l+1,0,["exit",e[a][1],t]),e[a][1].end={...e[l][1].end}):e[a][1]=c,e.push(["exit",c,t]),e}function zee(e,t,n){const a=this;let i;return l;function l(f){let g=a.events.length,h;for(;g--;)if(a.events[g][1].type!=="lineEnding"&&a.events[g][1].type!=="linePrefix"&&a.events[g][1].type!=="content"){h=a.events[g][1].type==="paragraph";break}return!a.parser.lazy[a.now().line]&&(a.interrupt||h)?(e.enter("setextHeadingLine"),i=f,c(f)):n(f)}function c(f){return e.enter("setextHeadingLineSequence"),u(f)}function u(f){return f===i?(e.consume(f),u):(e.exit("setextHeadingLineSequence"),Qt(f)?Vt(e,m,"lineSuffix")(f):m(f))}function m(f){return f===null||vt(f)?(e.exit("setextHeadingLine"),t(f)):n(f)}}const qee={tokenize:$ee};function $ee(e){const t=this,n=e.attempt($c,a,e.attempt(this.parser.constructs.flowInitial,i,Vt(e,e.attempt(this.parser.constructs.flow,i,e.attempt(VZ,i)),"linePrefix")));return n;function a(l){if(l===null){e.consume(l);return}return e.enter("lineEndingBlank"),e.consume(l),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const Fee={resolveAll:b5()},Uee=g5("string"),Gee=g5("text");function g5(e){return{resolveAll:b5(e==="text"?Kee:void 0),tokenize:t};function t(n){const a=this,i=this.parser.constructs[e],l=n.attempt(i,c,u);return c;function c(g){return f(g)?l(g):u(g)}function u(g){if(g===null){n.consume(g);return}return n.enter("data"),n.consume(g),m}function m(g){return f(g)?(n.exit("data"),l(g)):(n.consume(g),m)}function f(g){if(g===null)return!0;const h=i[g];let b=-1;if(h)for(;++b<h.length;){const y=h[b];if(!y.previous||y.previous.call(a,a.previous))return!0}return!1}}}function b5(e){return t;function t(n,a){let i=-1,l;for(;++i<=n.length;)l===void 0?n[i]&&n[i][1].type==="data"&&(l=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==l+2&&(n[l][1].end=n[i-1][1].end,n.splice(l+2,i-l-2),i=l+2),l=void 0);return e?e(n,a):n}}function Kee(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const a=e[n-1][1],i=t.sliceStream(a);let l=i.length,c=-1,u=0,m;for(;l--;){const f=i[l];if(typeof f=="string"){for(c=f.length;f.charCodeAt(c-1)===32;)u++,c--;if(c)break;c=-1}else if(f===-2)m=!0,u++;else if(f!==-1){l++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(u=0),u){const f={type:n===e.length||m||u<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:l?c:a.start._bufferIndex+c,_index:a.start._index+l,line:a.end.line,column:a.end.column-u,offset:a.end.offset-u},end:{...a.end}};a.end={...f.start},a.start.offset===a.end.offset?Object.assign(a,f):(e.splice(n,0,["enter",f,t],["exit",f,t]),n+=2)}n++}return e}const Vee={42:Da,43:Da,45:Da,48:Da,49:Da,50:Da,51:Da,52:Da,53:Da,54:Da,55:Da,56:Da,57:Da,62:c5},Wee={91:XZ},Yee={[-2]:Jh,[-1]:Jh,32:Jh},Qee={35:ree,42:tm,45:[vw,tm],60:lee,61:vw,95:tm,96:bw,126:bw},Jee={38:u5,92:d5},Xee={[-5]:Xh,[-4]:Xh,[-3]:Xh,33:Tee,38:u5,42:bg,60:[NZ,hee],91:Nee,92:[nee,d5],93:hb,95:bg,96:qZ},Zee={null:[bg,Fee]},ete={null:[42,95]},tte={null:[]},nte=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:ete,contentInitial:Wee,disable:tte,document:Vee,flow:Qee,flowInitial:Yee,insideSpan:Zee,string:Jee,text:Xee},Symbol.toStringTag,{value:"Module"}));function ate(e,t,n){let a={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},l=[];let c=[],u=[];const m={attempt:O(G),check:O(j),consume:M,enter:I,exit:B,interrupt:O(j,{interrupt:!0})},f={code:null,containerState:{},defineSkip:C,events:[],now:k,parser:e,previous:null,sliceSerialize:b,sliceStream:y,write:h};let g=t.tokenize.call(f,m);return t.resolveAll&&l.push(t),f;function h(V){return c=dr(c,V),T(),c[c.length-1]!==null?[]:(F(t,0),f.events=rp(l,f.events,f),f.events)}function b(V,z){return ite(y(V),z)}function y(V){return rte(c,V)}function k(){const{_bufferIndex:V,_index:z,line:J,column:D,offset:ee}=a;return{_bufferIndex:V,_index:z,line:J,column:D,offset:ee}}function C(V){i[V.line]=V.column,q()}function T(){let V;for(;a._index<c.length;){const z=c[a._index];if(typeof z=="string")for(V=a._index,a._bufferIndex<0&&(a._bufferIndex=0);a._index===V&&a._bufferIndex<z.length;)A(z.charCodeAt(a._bufferIndex));else A(z)}}function A(V){g=g(V)}function M(V){vt(V)?(a.line++,a.column=1,a.offset+=V===-3?2:1,q()):V!==-1&&(a.column++,a.offset++),a._bufferIndex<0?a._index++:(a._bufferIndex++,a._bufferIndex===c[a._index].length&&(a._bufferIndex=-1,a._index++)),f.previous=V}function I(V,z){const J=z||{};return J.type=V,J.start=k(),f.events.push(["enter",J,f]),u.push(J),J}function B(V){const z=u.pop();return z.end=k(),f.events.push(["exit",z,f]),z}function G(V,z){F(V,z.from)}function j(V,z){z.restore()}function O(V,z){return J;function J(D,ee,R){let te,le,ke,$;return Array.isArray(D)?oe(D):"tokenize"in D?oe([D]):W(D);function W(me){return ze;function ze(Ue){const je=Ue!==null&&me[Ue],Ye=Ue!==null&&me.null,xt=[...Array.isArray(je)?je:je?[je]:[],...Array.isArray(Ye)?Ye:Ye?[Ye]:[]];return oe(xt)(Ue)}}function oe(me){return te=me,le=0,me.length===0?R:L(me[le])}function L(me){return ze;function ze(Ue){return $=Y(),ke=me,me.partial||(f.currentConstruct=me),me.name&&f.parser.constructs.disable.null.includes(me.name)?qe():me.tokenize.call(z?Object.assign(Object.create(f),z):f,m,Ne,qe)(Ue)}}function Ne(me){return V(ke,$),ee}function qe(me){return $.restore(),++le<te.length?L(te[le]):R}}}function F(V,z){V.resolveAll&&!l.includes(V)&&l.push(V),V.resolve&&Ya(f.events,z,f.events.length-z,V.resolve(f.events.slice(z),f)),V.resolveTo&&(f.events=V.resolveTo(f.events,f))}function Y(){const V=k(),z=f.previous,J=f.currentConstruct,D=f.events.length,ee=Array.from(u);return{from:D,restore:R};function R(){a=V,f.previous=z,f.currentConstruct=J,f.events.length=D,u=ee,q()}}function q(){a.line in i&&a.column<2&&(a.column=i[a.line],a.offset+=i[a.line]-1)}}function rte(e,t){const n=t.start._index,a=t.start._bufferIndex,i=t.end._index,l=t.end._bufferIndex;let c;if(n===i)c=[e[n].slice(a,l)];else{if(c=e.slice(n,i),a>-1){const u=c[0];typeof u=="string"?c[0]=u.slice(a):c.shift()}l>0&&c.push(e[i].slice(0,l))}return c}function ite(e,t){let n=-1;const a=[];let i;for(;++n<e.length;){const l=e[n];let c;if(typeof l=="string")c=l;else switch(l){case-5:{c="\r";break}case-4:{c=`
|
|
522
522
|
`;break}case-3:{c=`\r
|
|
523
523
|
`;break}case-2:{c=t?" ":" ";break}case-1:{if(!t&&i)continue;c=" ";break}default:c=String.fromCharCode(l)}i=l===-2,a.push(c)}return a.join("")}function ste(e){const a={constructs:o5([nte,...(e||{}).extensions||[]]),content:i(wZ),defined:[],document:i(SZ),flow:i(qee),lazy:{},string:i(Uee),text:i(Gee)};return a;function i(l){return c;function c(u){return ate(a,l,u)}}}function ote(e){for(;!m5(e););return e}const xw=/[\0\t\n\r]/g;function lte(){let e=1,t="",n=!0,a;return i;function i(l,c,u){const m=[];let f,g,h,b,y;for(l=t+(typeof l=="string"?l.toString():new TextDecoder(c||void 0).decode(l)),h=0,t="",n&&(l.charCodeAt(0)===65279&&h++,n=void 0);h<l.length;){if(xw.lastIndex=h,f=xw.exec(l),b=f&&f.index!==void 0?f.index:l.length,y=l.charCodeAt(b),!f){t=l.slice(h);break}if(y===10&&h===b&&a)m.push(-3),a=void 0;else switch(a&&(m.push(-5),a=void 0),h<b&&(m.push(l.slice(h,b)),e+=b-h),y){case 0:{m.push(65533),e++;break}case 9:{for(g=Math.ceil(e/4)*4,m.push(-2);e++<g;)m.push(-1);break}case 10:{m.push(-4),e=1;break}default:a=!0,e=1}h=b+1}return u&&(a&&m.push(-5),t&&m.push(t),m.push(null)),m}}const cte=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function dte(e){return e.replace(cte,ute)}function ute(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),l=i===120||i===88;return l5(n.slice(l?2:1),l?16:10)}return fb(n)||e}const y5={}.hasOwnProperty;function mte(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),pte(n)(ote(ste(n).document().write(lte()(e,t,!0))))}function pte(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:l(Kt),autolinkProtocol:Y,autolinkEmail:Y,atxHeading:l(jt),blockQuote:l(Ye),characterEscape:Y,characterReference:Y,codeFenced:l(xt),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:l(xt,c),codeText:l(mt,c),codeTextData:Y,data:Y,codeFlowValue:Y,definition:l(ft),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:l(rt),hardBreakEscape:l(ht),hardBreakTrailing:l(ht),htmlFlow:l(He,c),htmlFlowData:Y,htmlText:l(He,c),htmlTextData:Y,image:l(Et),label:c,link:l(Kt),listItem:l(tt),listItemValue:b,listOrdered:l(ie,h),listUnordered:l(ie),paragraph:l(it),reference:L,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:l(jt),strong:l(xe),thematicBreak:l(Ie)},exit:{atxHeading:m(),atxHeadingSequence:G,autolink:m(),autolinkEmail:je,autolinkProtocol:Ue,blockQuote:m(),characterEscapeValue:q,characterReferenceMarkerHexadecimal:qe,characterReferenceMarkerNumeric:qe,characterReferenceValue:me,characterReference:ze,codeFenced:m(T),codeFencedFence:C,codeFencedFenceInfo:y,codeFencedFenceMeta:k,codeFlowValue:q,codeIndented:m(A),codeText:m(ee),codeTextData:q,data:q,definition:m(),definitionDestinationString:B,definitionLabelString:M,definitionTitleString:I,emphasis:m(),hardBreakEscape:m(z),hardBreakTrailing:m(z),htmlFlow:m(J),htmlFlowData:q,htmlText:m(D),htmlTextData:q,image:m(te),label:ke,labelText:le,lineEnding:V,link:m(R),listItem:m(),listOrdered:m(),listUnordered:m(),paragraph:m(),referenceString:Ne,resourceDestinationString:$,resourceTitleString:W,resource:oe,setextHeading:m(F),setextHeadingLineSequence:O,setextHeadingText:j,strong:m(),thematicBreak:m()}};v5(t,(e||{}).mdastExtensions||[]);const n={};return a;function a(ne){let U={type:"root",children:[]};const re={stack:[U],tokenStack:[],config:t,enter:u,exit:f,buffer:c,resume:g,data:n},Ce=[];let Pe=-1;for(;++Pe<ne.length;)if(ne[Pe][1].type==="listOrdered"||ne[Pe][1].type==="listUnordered")if(ne[Pe][0]==="enter")Ce.push(Pe);else{const $e=Ce.pop();Pe=i(ne,$e,Pe)}for(Pe=-1;++Pe<ne.length;){const $e=t[ne[Pe][0]];y5.call($e,ne[Pe][1].type)&&$e[ne[Pe][1].type].call(Object.assign({sliceSerialize:ne[Pe][2].sliceSerialize},re),ne[Pe][1])}if(re.tokenStack.length>0){const $e=re.tokenStack[re.tokenStack.length-1];($e[1]||ww).call(re,void 0,$e[0])}for(U.position={start:Ki(ne.length>0?ne[0][1].start:{line:1,column:1,offset:0}),end:Ki(ne.length>0?ne[ne.length-2][1].end:{line:1,column:1,offset:0})},Pe=-1;++Pe<t.transforms.length;)U=t.transforms[Pe](U)||U;return U}function i(ne,U,re){let Ce=U-1,Pe=-1,$e=!1,ue,he,Ve,dt;for(;++Ce<=re;){const Je=ne[Ce];switch(Je[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Je[0]==="enter"?Pe++:Pe--,dt=void 0;break}case"lineEndingBlank":{Je[0]==="enter"&&(ue&&!dt&&!Pe&&!Ve&&(Ve=Ce),dt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:dt=void 0}if(!Pe&&Je[0]==="enter"&&Je[1].type==="listItemPrefix"||Pe===-1&&Je[0]==="exit"&&(Je[1].type==="listUnordered"||Je[1].type==="listOrdered")){if(ue){let ot=Ce;for(he=void 0;ot--;){const Ft=ne[ot];if(Ft[1].type==="lineEnding"||Ft[1].type==="lineEndingBlank"){if(Ft[0]==="exit")continue;he&&(ne[he][1].type="lineEndingBlank",$e=!0),Ft[1].type="lineEnding",he=ot}else if(!(Ft[1].type==="linePrefix"||Ft[1].type==="blockQuotePrefix"||Ft[1].type==="blockQuotePrefixWhitespace"||Ft[1].type==="blockQuoteMarker"||Ft[1].type==="listItemIndent"))break}Ve&&(!he||Ve<he)&&(ue._spread=!0),ue.end=Object.assign({},he?ne[he][1].start:Je[1].end),ne.splice(he||Ce,0,["exit",ue,Je[2]]),Ce++,re++}if(Je[1].type==="listItemPrefix"){const ot={type:"listItem",_spread:!1,start:Object.assign({},Je[1].start),end:void 0};ue=ot,ne.splice(Ce,0,["enter",ot,Je[2]]),Ce++,re++,Ve=void 0,dt=!0}}}return ne[U][1]._spread=$e,re}function l(ne,U){return re;function re(Ce){u.call(this,ne(Ce),Ce),U&&U.call(this,Ce)}}function c(){this.stack.push({type:"fragment",children:[]})}function u(ne,U,re){this.stack[this.stack.length-1].children.push(ne),this.stack.push(ne),this.tokenStack.push([U,re||void 0]),ne.position={start:Ki(U.start),end:void 0}}function m(ne){return U;function U(re){ne&&ne.call(this,re),f.call(this,re)}}function f(ne,U){const re=this.stack.pop(),Ce=this.tokenStack.pop();if(Ce)Ce[0].type!==ne.type&&(U?U.call(this,ne,Ce[0]):(Ce[1]||ww).call(this,ne,Ce[0]));else throw new Error("Cannot close `"+ne.type+"` ("+bc({start:ne.start,end:ne.end})+"): it’s not open");re.position.end=Ki(ne.end)}function g(){return pb(this.stack.pop())}function h(){this.data.expectingFirstListItemValue=!0}function b(ne){if(this.data.expectingFirstListItemValue){const U=this.stack[this.stack.length-2];U.start=Number.parseInt(this.sliceSerialize(ne),10),this.data.expectingFirstListItemValue=void 0}}function y(){const ne=this.resume(),U=this.stack[this.stack.length-1];U.lang=ne}function k(){const ne=this.resume(),U=this.stack[this.stack.length-1];U.meta=ne}function C(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function T(){const ne=this.resume(),U=this.stack[this.stack.length-1];U.value=ne.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function A(){const ne=this.resume(),U=this.stack[this.stack.length-1];U.value=ne.replace(/(\r?\n|\r)$/g,"")}function M(ne){const U=this.resume(),re=this.stack[this.stack.length-1];re.label=U,re.identifier=wr(this.sliceSerialize(ne)).toLowerCase()}function I(){const ne=this.resume(),U=this.stack[this.stack.length-1];U.title=ne}function B(){const ne=this.resume(),U=this.stack[this.stack.length-1];U.url=ne}function G(ne){const U=this.stack[this.stack.length-1];if(!U.depth){const re=this.sliceSerialize(ne).length;U.depth=re}}function j(){this.data.setextHeadingSlurpLineEnding=!0}function O(ne){const U=this.stack[this.stack.length-1];U.depth=this.sliceSerialize(ne).codePointAt(0)===61?1:2}function F(){this.data.setextHeadingSlurpLineEnding=void 0}function Y(ne){const re=this.stack[this.stack.length-1].children;let Ce=re[re.length-1];(!Ce||Ce.type!=="text")&&(Ce=Me(),Ce.position={start:Ki(ne.start),end:void 0},re.push(Ce)),this.stack.push(Ce)}function q(ne){const U=this.stack.pop();U.value+=this.sliceSerialize(ne),U.position.end=Ki(ne.end)}function V(ne){const U=this.stack[this.stack.length-1];if(this.data.atHardBreak){const re=U.children[U.children.length-1];re.position.end=Ki(ne.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(U.type)&&(Y.call(this,ne),q.call(this,ne))}function z(){this.data.atHardBreak=!0}function J(){const ne=this.resume(),U=this.stack[this.stack.length-1];U.value=ne}function D(){const ne=this.resume(),U=this.stack[this.stack.length-1];U.value=ne}function ee(){const ne=this.resume(),U=this.stack[this.stack.length-1];U.value=ne}function R(){const ne=this.stack[this.stack.length-1];if(this.data.inReference){const U=this.data.referenceType||"shortcut";ne.type+="Reference",ne.referenceType=U,delete ne.url,delete ne.title}else delete ne.identifier,delete ne.label;this.data.referenceType=void 0}function te(){const ne=this.stack[this.stack.length-1];if(this.data.inReference){const U=this.data.referenceType||"shortcut";ne.type+="Reference",ne.referenceType=U,delete ne.url,delete ne.title}else delete ne.identifier,delete ne.label;this.data.referenceType=void 0}function le(ne){const U=this.sliceSerialize(ne),re=this.stack[this.stack.length-2];re.label=dte(U),re.identifier=wr(U).toLowerCase()}function ke(){const ne=this.stack[this.stack.length-1],U=this.resume(),re=this.stack[this.stack.length-1];if(this.data.inReference=!0,re.type==="link"){const Ce=ne.children;re.children=Ce}else re.alt=U}function $(){const ne=this.resume(),U=this.stack[this.stack.length-1];U.url=ne}function W(){const ne=this.resume(),U=this.stack[this.stack.length-1];U.title=ne}function oe(){this.data.inReference=void 0}function L(){this.data.referenceType="collapsed"}function Ne(ne){const U=this.resume(),re=this.stack[this.stack.length-1];re.label=U,re.identifier=wr(this.sliceSerialize(ne)).toLowerCase(),this.data.referenceType="full"}function qe(ne){this.data.characterReferenceType=ne.type}function me(ne){const U=this.sliceSerialize(ne),re=this.data.characterReferenceType;let Ce;re?(Ce=l5(U,re==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ce=fb(U);const Pe=this.stack[this.stack.length-1];Pe.value+=Ce}function ze(ne){const U=this.stack.pop();U.position.end=Ki(ne.end)}function Ue(ne){q.call(this,ne);const U=this.stack[this.stack.length-1];U.url=this.sliceSerialize(ne)}function je(ne){q.call(this,ne);const U=this.stack[this.stack.length-1];U.url="mailto:"+this.sliceSerialize(ne)}function Ye(){return{type:"blockquote",children:[]}}function xt(){return{type:"code",lang:null,meta:null,value:""}}function mt(){return{type:"inlineCode",value:""}}function ft(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function rt(){return{type:"emphasis",children:[]}}function jt(){return{type:"heading",depth:0,children:[]}}function ht(){return{type:"break"}}function He(){return{type:"html",value:""}}function Et(){return{type:"image",title:null,url:"",alt:null}}function Kt(){return{type:"link",title:null,url:"",children:[]}}function ie(ne){return{type:"list",ordered:ne.type==="listOrdered",start:null,spread:ne._spread,children:[]}}function tt(ne){return{type:"listItem",spread:ne._spread,checked:null,children:[]}}function it(){return{type:"paragraph",children:[]}}function xe(){return{type:"strong",children:[]}}function Me(){return{type:"text",value:""}}function Ie(){return{type:"thematicBreak"}}}function Ki(e){return{line:e.line,column:e.column,offset:e.offset}}function v5(e,t){let n=-1;for(;++n<t.length;){const a=t[n];Array.isArray(a)?v5(e,a):fte(e,a)}}function fte(e,t){let n;for(n in t)if(y5.call(t,n))switch(n){case"canContainEols":{const a=t[n];a&&e[n].push(...a);break}case"transforms":{const a=t[n];a&&e[n].push(...a);break}case"enter":case"exit":{const a=t[n];a&&Object.assign(e[n],a);break}}}function ww(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+bc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+bc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+bc({start:t.start,end:t.end})+") is still open")}function hte(e){const t=this;t.parser=n;function n(a){return mte(a,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function gte(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function bte(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
@@ -811,7 +811,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
811
811
|
`},f]}}const Koe=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),Voe=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],Woe=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],Yoe=[...Voe,...Woe],Qoe=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),mC=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),pC=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),Joe=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse(),Xoe=mC.concat(pC).sort().reverse();function Zoe(e){const t=Koe(e),n=Xoe,a="and or not only",i="[\\w-]+",l="("+i+"|@\\{"+i+"\\})",c=[],u=[],m=function(I){return{className:"string",begin:"~?"+I+".*?"+I}},f=function(I,B,G){return{className:I,begin:B,relevance:G}},g={$pattern:/[a-z-]+/,keyword:a,attribute:Qoe.join(" ")},h={begin:"\\(",end:"\\)",contains:u,keywords:g,relevance:0};u.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,m("'"),m('"'),t.CSS_NUMBER_MODE,{begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",excludeEnd:!0}},t.HEXCOLOR,h,f("variable","@@?"+i,10),f("variable","@\\{"+i+"\\}"),f("built_in","~?`[^`]*?`"),{className:"attribute",begin:i+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0},t.IMPORTANT,{beginKeywords:"and not"},t.FUNCTION_DISPATCH);const b=u.concat({begin:/\{/,end:/\}/,contains:c}),y={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(u)},k={begin:l+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+Joe.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:u}}]},C={className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:g,returnEnd:!0,contains:u,relevance:0}},T={className:"variable",variants:[{begin:"@"+i+"\\s*:",relevance:15},{begin:"@"+i}],starts:{end:"[;}]",returnEnd:!0,contains:b}},A={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:l,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:`[<='$"]`,relevance:0,contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,y,f("keyword","all\\b"),f("variable","@\\{"+i+"\\}"),{begin:"\\b("+Yoe.join("|")+")\\b",className:"selector-tag"},t.CSS_NUMBER_MODE,f("selector-tag",l,0),f("selector-id","#"+l),f("selector-class","\\."+l,0),f("selector-tag","&",0),t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+mC.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+pC.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:b},{begin:"!important"},t.FUNCTION_DISPATCH]},M={begin:i+`:(:)?(${n.join("|")})`,returnBegin:!0,contains:[A]};return c.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,C,T,M,k,A,y,t.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:`[=>'/<($"]`,contains:c}}function ele(e){const t="\\[=*\\[",n="\\]=*\\]",a={begin:t,end:n,contains:["self"]},i=[e.COMMENT("--(?!"+t+")","$"),e.COMMENT("--"+t,n,{contains:[a],relevance:10})];return{name:"Lua",aliases:["pluto"],keywords:{$pattern:e.UNDERSCORE_IDENT_RE,literal:"true false nil",keyword:"and break do else elseif end for goto if in local not or repeat return then until while",built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove"},contains:i.concat([{className:"function",beginKeywords:"function",end:"\\)",contains:[e.inherit(e.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",begin:"\\(",endsWithParent:!0,contains:i}].concat(i)},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:"string",begin:t,end:n,contains:[a],relevance:5}])}}function tle(e){const t={className:"variable",variants:[{begin:"\\$\\("+e.UNDERSCORE_IDENT_RE+"\\)",contains:[e.BACKSLASH_ESCAPE]},{begin:/\$[@%<?\^\+\*]/}]},n={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,t]},a={className:"variable",begin:/\$\([\w-]+\s/,end:/\)/,keywords:{built_in:"subst patsubst strip findstring filter filter-out sort word wordlist firstword lastword dir notdir suffix basename addsuffix addprefix join wildcard realpath abspath error warning shell origin flavor foreach if or and call eval file value"},contains:[t,n]},i={begin:"^"+e.UNDERSCORE_IDENT_RE+"\\s*(?=[:+?]?=)"},l={className:"meta",begin:/^\.PHONY:/,end:/$/,keywords:{$pattern:/[\.\w]+/,keyword:".PHONY"}},c={className:"section",begin:/^[^\s]+:/,end:/$/,contains:[t]};return{name:"Makefile",aliases:["mk","mak","make"],keywords:{$pattern:/[\w-]+/,keyword:"define endef undefine ifdef ifndef ifeq ifneq else endif include -include sinclude override export unexport private vpath"},contains:[e.HASH_COMMENT_MODE,t,n,a,i,l,c]}}function nle(e){const t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},a={begin:"^[-\\*]{3,}",end:"$"},i={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},l={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},c={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},u=/[A-Za-z][A-Za-z0-9+.-]*/,m={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,u,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},f={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},g={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},h=e.inherit(f,{contains:[]}),b=e.inherit(g,{contains:[]});f.contains.push(b),g.contains.push(h);let y=[n,m];return[f,g,h,b].forEach(A=>{A.contains=A.contains.concat(y)}),y=y.concat(f,g),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:y},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:y}]}]},n,l,f,g,{className:"quote",begin:"^>\\s+",contains:y,end:"$"},i,a,m,c,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function ale(e){const t={className:"built_in",begin:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},n=/[a-zA-Z@][a-zA-Z0-9_]*/,u={"variable.language":["this","super"],$pattern:n,keyword:["while","export","sizeof","typedef","const","struct","for","union","volatile","static","mutable","if","do","return","goto","enum","else","break","extern","asm","case","default","register","explicit","typename","switch","continue","inline","readonly","assign","readwrite","self","@synchronized","id","typeof","nonatomic","IBOutlet","IBAction","strong","weak","copy","in","out","inout","bycopy","byref","oneway","__strong","__weak","__block","__autoreleasing","@private","@protected","@public","@try","@property","@end","@throw","@catch","@finally","@autoreleasepool","@synthesize","@dynamic","@selector","@optional","@required","@encode","@package","@import","@defs","@compatibility_alias","__bridge","__bridge_transfer","__bridge_retained","__bridge_retain","__covariant","__contravariant","__kindof","_Nonnull","_Nullable","_Null_unspecified","__FUNCTION__","__PRETTY_FUNCTION__","__attribute__","getter","setter","retain","unsafe_unretained","nonnull","nullable","null_unspecified","null_resettable","class","instancetype","NS_DESIGNATED_INITIALIZER","NS_UNAVAILABLE","NS_REQUIRES_SUPER","NS_RETURNS_INNER_POINTER","NS_INLINE","NS_AVAILABLE","NS_DEPRECATED","NS_ENUM","NS_OPTIONS","NS_SWIFT_UNAVAILABLE","NS_ASSUME_NONNULL_BEGIN","NS_ASSUME_NONNULL_END","NS_REFINED_FOR_SWIFT","NS_SWIFT_NAME","NS_SWIFT_NOTHROW","NS_DURING","NS_HANDLER","NS_ENDHANDLER","NS_VALUERETURN","NS_VOIDRETURN"],literal:["false","true","FALSE","TRUE","nil","YES","NO","NULL"],built_in:["dispatch_once_t","dispatch_queue_t","dispatch_sync","dispatch_async","dispatch_once"],type:["int","float","char","unsigned","signed","short","long","double","wchar_t","unichar","void","bool","BOOL","id|0","_Bool"]},m={$pattern:n,keyword:["@interface","@class","@protocol","@implementation"]};return{name:"Objective-C",aliases:["mm","objc","obj-c","obj-c++","objective-c++"],keywords:u,illegal:"</",contains:[t,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.C_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{className:"string",variants:[{begin:'@"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]}]},{className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),{className:"string",begin:/<.*?>/,end:/$/,illegal:"\\n"},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"class",begin:"("+m.keyword.join("|")+")\\b",end:/(\{|$)/,excludeEnd:!0,keywords:m,contains:[e.UNDERSCORE_TITLE_MODE]},{begin:"\\."+e.UNDERSCORE_IDENT_RE,relevance:0}]}}function rle(e){const t=e.regex,n=["abs","accept","alarm","and","atan2","bind","binmode","bless","break","caller","chdir","chmod","chomp","chop","chown","chr","chroot","class","close","closedir","connect","continue","cos","crypt","dbmclose","dbmopen","defined","delete","die","do","dump","each","else","elsif","endgrent","endhostent","endnetent","endprotoent","endpwent","endservent","eof","eval","exec","exists","exit","exp","fcntl","field","fileno","flock","for","foreach","fork","format","formline","getc","getgrent","getgrgid","getgrnam","gethostbyaddr","gethostbyname","gethostent","getlogin","getnetbyaddr","getnetbyname","getnetent","getpeername","getpgrp","getpriority","getprotobyname","getprotobynumber","getprotoent","getpwent","getpwnam","getpwuid","getservbyname","getservbyport","getservent","getsockname","getsockopt","given","glob","gmtime","goto","grep","gt","hex","if","index","int","ioctl","join","keys","kill","last","lc","lcfirst","length","link","listen","local","localtime","log","lstat","lt","ma","map","method","mkdir","msgctl","msgget","msgrcv","msgsnd","my","ne","next","no","not","oct","open","opendir","or","ord","our","pack","package","pipe","pop","pos","print","printf","prototype","push","q|0","qq","quotemeta","qw","qx","rand","read","readdir","readline","readlink","readpipe","recv","redo","ref","rename","require","reset","return","reverse","rewinddir","rindex","rmdir","say","scalar","seek","seekdir","select","semctl","semget","semop","send","setgrent","sethostent","setnetent","setpgrp","setpriority","setprotoent","setpwent","setservent","setsockopt","shift","shmctl","shmget","shmread","shmwrite","shutdown","sin","sleep","socket","socketpair","sort","splice","split","sprintf","sqrt","srand","stat","state","study","sub","substr","symlink","syscall","sysopen","sysread","sysseek","system","syswrite","tell","telldir","tie","tied","time","times","tr","truncate","uc","ucfirst","umask","undef","unless","unlink","unpack","unshift","untie","until","use","utime","values","vec","wait","waitpid","wantarray","warn","when","while","write","x|0","xor","y|0"],a=/[dualxmsipngr]{0,12}/,i={$pattern:/[\w.]+/,keyword:n.join(" ")},l={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:i},c={begin:/->\{/,end:/\}/},u={scope:"attr",match:/\s+:\s*\w+(\s*\(.*?\))?/},m={scope:"variable",variants:[{begin:/\$\d/},{begin:t.concat(/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")},{begin:/[$%@](?!")[^\s\w{=]|\$=/,relevance:0}],contains:[u]},f={className:"number",variants:[{match:/0?\.[0-9][0-9_]+\b/},{match:/\bv?(0|[1-9][0-9_]*(\.[0-9_]+)?|[1-9][0-9_]*)\b/},{match:/\b0[0-7][0-7_]*\b/},{match:/\b0x[0-9a-fA-F][0-9a-fA-F_]*\b/},{match:/\b0b[0-1][0-1_]*\b/}],relevance:0},g=[e.BACKSLASH_ESCAPE,l,m],h=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],b=(C,T,A="\\1")=>{const M=A==="\\1"?A:t.concat(A,T);return t.concat(t.concat("(?:",C,")"),T,/(?:\\.|[^\\\/])*?/,M,/(?:\\.|[^\\\/])*?/,A,a)},y=(C,T,A)=>t.concat(t.concat("(?:",C,")"),T,/(?:\\.|[^\\\/])*?/,A,a),k=[m,e.HASH_COMMENT_MODE,e.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),c,{className:"string",contains:g,variants:[{begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[",end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*<",end:">",relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'",contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{begin:"-?\\w+\\s*=>",relevance:0}]},f,{begin:"(\\/\\/|"+e.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",keywords:"split return print reverse grep",relevance:0,contains:[e.HASH_COMMENT_MODE,{className:"regexp",variants:[{begin:b("s|tr|y",t.either(...h,{capture:!0}))},{begin:b("s|tr|y","\\(","\\)")},{begin:b("s|tr|y","\\[","\\]")},{begin:b("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:y("(?:m|qr)?",/\//,/\//)},{begin:y("m|qr",t.either(...h,{capture:!0}),/\1/)},{begin:y("m|qr",/\(/,/\)/)},{begin:y("m|qr",/\[/,/\]/)},{begin:y("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub method",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,u]},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,u,f]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return l.contains=k,c.contains=k,{name:"Perl",aliases:["pl","pm"],keywords:i,contains:k}}function ile(e){const t=e.regex,n=/(?![A-Za-z0-9])(?![$])/,a=t.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,n),i=t.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,n),l=t.concat(/[A-Z]+/,n),c={scope:"variable",match:"\\$+"+a},u={scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},m={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},f=e.inherit(e.APOS_STRING_MODE,{illegal:null}),g=e.inherit(e.QUOTE_STRING_MODE,{illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(m)}),h={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:e.QUOTE_STRING_MODE.contains.concat(m),"on:begin":(D,ee)=>{ee.data._beginMatch=D[1]||D[2]},"on:end":(D,ee)=>{ee.data._beginMatch!==D[1]&&ee.ignoreMatch()}},b=e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),y=`[
|
|
812
812
|
]`,k={scope:"string",variants:[g,f,h,b]},C={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},T=["false","null","true"],A=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],M=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],B={keyword:A,literal:(D=>{const ee=[];return D.forEach(R=>{ee.push(R),R.toLowerCase()===R?ee.push(R.toUpperCase()):ee.push(R.toLowerCase())}),ee})(T),built_in:M},G=D=>D.map(ee=>ee.replace(/\|\d+$/,"")),j={variants:[{match:[/new/,t.concat(y,"+"),t.concat("(?!",G(M).join("\\b|"),"\\b)"),i],scope:{1:"keyword",4:"title.class"}}]},O=t.concat(a,"\\b(?!\\()"),F={variants:[{match:[t.concat(/::/,t.lookahead(/(?!class\b)/)),O],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[i,t.concat(/::/,t.lookahead(/(?!class\b)/)),O],scope:{1:"title.class",3:"variable.constant"}},{match:[i,t.concat("::",t.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[i,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},Y={scope:"attr",match:t.concat(a,t.lookahead(":"),t.lookahead(/(?!::)/))},q={relevance:0,begin:/\(/,end:/\)/,keywords:B,contains:[Y,c,F,e.C_BLOCK_COMMENT_MODE,k,C,j]},V={relevance:0,match:[/\b/,t.concat("(?!fn\\b|function\\b|",G(A).join("\\b|"),"|",G(M).join("\\b|"),"\\b)"),a,t.concat(y,"*"),t.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[q]};q.contains.push(V);const z=[Y,F,e.C_BLOCK_COMMENT_MODE,k,C,j],J={begin:t.concat(/#\[\s*\\?/,t.either(i,l)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:T,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:T,keyword:["new","array"]},contains:["self",...z]},...z,{scope:"meta",variants:[{match:i},{match:l}]}]};return{case_insensitive:!1,keywords:B,contains:[J,e.HASH_COMMENT_MODE,e.COMMENT("//","$"),e.COMMENT("/\\*","\\*/",{contains:[{scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,keywords:"__halt_compiler",starts:{scope:"comment",end:e.MATCH_NOTHING_RE,contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},u,{scope:"variable.language",match:/\$this\b/},c,V,F,{match:[/const/,/\s/,a],scope:{1:"keyword",3:"variable.constant"}},j,{scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"},e.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:B,contains:["self",J,c,F,e.C_BLOCK_COMMENT_MODE,k,C]}]},{scope:"class",variants:[{beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,contains:[e.inherit(e.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{beginKeywords:"use",relevance:0,end:";",contains:[{match:/\b(as|const|function)\b/,scope:"keyword"},e.UNDERSCORE_TITLE_MODE]},k,C]}}function sle(e){return{name:"PHP template",subLanguage:"xml",contains:[{begin:/<\?(php|=)?/,end:/\?>/,subLanguage:"php",contains:[{begin:"/\\*",end:"\\*/",skip:!0},{begin:'b"',end:'"',skip:!0},{begin:"b'",end:"'",skip:!0},e.inherit(e.APOS_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0}),e.inherit(e.QUOTE_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0})]}]}}function ole(e){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}function lle(e){const t=e.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),a=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],u={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:a,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},m={className:"meta",begin:/^(>>>|\.\.\.) /},f={className:"subst",begin:/\{/,end:/\}/,keywords:u,illegal:/#/},g={begin:/\{\{/,relevance:0},h={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,m],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,m],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,m,g,f]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,m,g,f]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,g,f]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,g,f]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},b="[0-9](_?[0-9])*",y=`(\\b(${b}))?\\.(${b})|\\b(${b})\\.`,k=`\\b|${a.join("|")}`,C={className:"number",relevance:0,variants:[{begin:`(\\b(${b})|(${y}))[eE][+-]?(${b})[jJ]?(?=${k})`},{begin:`(${y})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${k})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${k})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${k})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${k})`},{begin:`\\b(${b})[jJ](?=${k})`}]},T={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:u,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},A={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:["self",m,C,h,e.HASH_COMMENT_MODE]}]};return f.contains=[h,C,m],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:u,illegal:/(<\/|\?)|=>/,contains:[m,C,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},h,T,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[A]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[C,A,h]}]}}function cle(e){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function dle(e){const t=e.regex,n=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,a=t.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),i=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,l=t.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:n,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[e.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:t.lookahead(t.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:n},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),e.HASH_COMMENT_MODE,{scope:"string",contains:[e.BACKSLASH_ESCAPE],variants:[e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[i,a]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,a]},{scope:{1:"punctuation",2:"number"},match:[l,a]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,a]}]},{scope:{3:"operator"},match:[n,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:i},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:l},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}}function ule(e){const t=e.regex,n="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",a=t.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),i=t.concat(a,/(::\w+)*/),c={"variable.constant":["__FILE__","__LINE__","__ENCODING__"],"variable.language":["self","super"],keyword:["alias","and","begin","BEGIN","break","case","class","defined","do","else","elsif","end","END","ensure","for","if","in","module","next","not","or","redo","require","rescue","retry","return","then","undef","unless","until","when","while","yield",...["include","extend","prepend","public","private","protected","raise","throw"]],built_in:["proc","lambda","attr_accessor","attr_reader","attr_writer","define_method","private_constant","module_function"],literal:["true","false","nil"]},u={className:"doctag",begin:"@[A-Za-z]+"},m={begin:"#<",end:">"},f=[e.COMMENT("#","$",{contains:[u]}),e.COMMENT("^=begin","^=end",{contains:[u],relevance:10}),e.COMMENT("^__END__",e.MATCH_NOTHING_RE)],g={className:"subst",begin:/#\{/,end:/\}/,keywords:c},h={className:"string",contains:[e.BACKSLASH_ESCAPE,g],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?</,end:/>/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:t.concat(/<<[-~]?'?/,t.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[e.BACKSLASH_ESCAPE,g]})]}]},b="[1-9](_?[0-9])*|0",y="[0-9](_?[0-9])*",k={className:"number",relevance:0,variants:[{begin:`\\b(${b})(\\.(${y}))?([eE][+-]?(${y})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},C={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:c}]},j=[h,{variants:[{match:[/class\s+/,i,/\s+<\s+/,i]},{match:[/\b(class|module)\s+/,i]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:c},{match:[/(include|extend)\s+/,i],scope:{2:"title.class"},keywords:c},{relevance:0,match:[i,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:a,scope:"title.class"},{match:[/def/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[C]},{begin:e.IDENT_RE+"::"},{className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[h,{begin:n}],relevance:0},k,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:c},{begin:"("+e.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[e.BACKSLASH_ESCAPE,g],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(m,f),relevance:0}].concat(m,f);g.contains=j,C.contains=j;const q=[{begin:/^\s*=>/,starts:{end:"$",contains:j}},{className:"meta.prompt",begin:"^("+"[>?]>"+"|"+"[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]"+"|"+"(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>"+")(?=[ ])",starts:{end:"$",keywords:c,contains:j}}];return f.unshift(m),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:c,illegal:/\/\*/,contains:[e.SHEBANG({binary:"ruby"})].concat(q).concat(f).concat(j)}}function mle(e){const t=e.regex,n=/(r#)?/,a=t.concat(n,e.UNDERSCORE_IDENT_RE),i=t.concat(n,e.IDENT_RE),l={className:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!let|for|while|if|else|match\b)/,i,t.lookahead(/\s*\(/))},c="([ui](8|16|32|64|128|size)|f(32|64))?",u=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],m=["true","false","Some","None","Ok","Err"],f=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],g=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:g,keyword:u,literal:m,built_in:f},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:"number",variants:[{begin:"\\b0b([01_]+)"+c},{begin:"\\b0o([0-7_]+)"+c},{begin:"\\b0x([A-Fa-f0-9_]+)"+c},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+c}],relevance:0},{begin:[/fn/,/\s+/,a],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,a],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,a,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,a],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,a],className:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:f,type:g}},{className:"punctuation",begin:"->"},l]}}const ple=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),fle=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],hle=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],gle=[...fle,...hle],ble=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),yle=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),vle=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),xle=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function wle(e){const t=ple(e),n=vle,a=yle,i="@[a-z-]+",l="and or not only",u={className:"variable",begin:"(\\$"+"[a-zA-Z-][a-zA-Z0-9_-]*"+")\\b",relevance:0};return{name:"SCSS",case_insensitive:!0,illegal:"[=/|']",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,t.CSS_NUMBER_MODE,{className:"selector-id",begin:"#[A-Za-z0-9_-]+",relevance:0},{className:"selector-class",begin:"\\.[A-Za-z0-9_-]+",relevance:0},t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-tag",begin:"\\b("+gle.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+a.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+n.join("|")+")"},u,{begin:/\(/,end:/\)/,contains:[t.CSS_NUMBER_MODE]},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+xle.join("|")+")\\b"},{begin:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{begin:/:/,end:/[;}{]/,relevance:0,contains:[t.BLOCK_COMMENT,u,t.HEXCOLOR,t.CSS_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.IMPORTANT,t.FUNCTION_DISPATCH]},{begin:"@(page|font-face)",keywords:{$pattern:i,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:l,attribute:ble.join(" ")},contains:[{begin:i,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},u,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.HEXCOLOR,t.CSS_NUMBER_MODE]},t.FUNCTION_DISPATCH]}}function kle(e){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function Sle(e){const t=e.regex,n=e.COMMENT("--","$"),a={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},i={begin:/"/,end:/"/,contains:[{match:/""/}]},l=["true","false","unknown"],c=["double precision","large object","with timezone","without timezone"],u=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],m=["add","asc","collation","desc","final","first","last","view"],f=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],g=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],h=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],b=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],y=g,k=[...f,...m].filter(G=>!g.includes(G)),C={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},T={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},A={match:t.concat(/\b/,t.either(...y),/\s*\(/),relevance:0,keywords:{built_in:y}};function M(G){return t.concat(/\b/,t.either(...G.map(j=>j.replace(/\s+/,"\\s+"))),/\b/)}const I={scope:"keyword",match:M(b),relevance:0};function B(G,{exceptions:j,when:O}={}){const F=O;return j=j||[],G.map(Y=>Y.match(/\|\d+$/)||j.includes(Y)?Y:F(Y)?`${Y}|0`:Y)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:B(k,{when:G=>G.length<3}),literal:l,type:u,built_in:h},contains:[{scope:"type",match:M(c)},I,A,C,a,i,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,T]}}function fC(e){return e?typeof e=="string"?e:e.source:null}function ic(e){return yn("(?=",e,")")}function yn(...e){return e.map(n=>fC(n)).join("")}function Cle(e){const t=e[e.length-1];return typeof t=="object"&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function xa(...e){return"("+(Cle(e).capture?"":"?:")+e.map(a=>fC(a)).join("|")+")"}const $b=e=>yn(/\b/,e,/\w$/.test(e)?/\b/:/\B/),Ale=["Protocol","Type"].map($b),Dk=["init","self"].map($b),Tle=["Any","Self"],N0=["actor","any","associatedtype","async","await",/as\?/,/as!/,"as","borrowing","break","case","catch","class","consume","consuming","continue","convenience","copy","default","defer","deinit","didSet","distributed","do","dynamic","each","else","enum","extension","fallthrough",/fileprivate\(set\)/,"fileprivate","final","for","func","get","guard","if","import","indirect","infix",/init\?/,/init!/,"inout",/internal\(set\)/,"internal","in","is","isolated","nonisolated","lazy","let","macro","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","package","postfix","precedencegroup","prefix",/private\(set\)/,"private","protocol",/public\(set\)/,"public","repeat","required","rethrows","return","set","some","static","struct","subscript","super","switch","throws","throw",/try\?/,/try!/,"try","typealias",/unowned\(safe\)/,/unowned\(unsafe\)/,"unowned","var","weak","where","while","willSet"],Ik=["false","nil","true"],Ele=["assignment","associativity","higherThan","left","lowerThan","none","right"],Nle=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],Lk=["abs","all","any","assert","assertionFailure","debugPrint","dump","fatalError","getVaList","isKnownUniquelyReferenced","max","min","numericCast","pointwiseMax","pointwiseMin","precondition","preconditionFailure","print","readLine","repeatElement","sequence","stride","swap","swift_unboxFromSwiftValueWithType","transcode","type","unsafeBitCast","unsafeDowncast","withExtendedLifetime","withUnsafeMutablePointer","withUnsafePointer","withVaList","withoutActuallyEscaping","zip"],hC=xa(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),gC=xa(hC,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),M0=yn(hC,gC,"*"),bC=xa(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),zm=xa(bC,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),jr=yn(bC,zm,"*"),Iu=yn(/[A-Z]/,zm,"*"),Mle=["attached","autoclosure",yn(/convention\(/,xa("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",yn(/objc\(/,jr,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],jle=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function Rle(e){const t={match:/\s+/,relevance:0},n=e.COMMENT("/\\*","\\*/",{contains:["self"]}),a=[e.C_LINE_COMMENT_MODE,n],i={match:[/\./,xa(...Ale,...Dk)],className:{2:"keyword"}},l={match:yn(/\./,xa(...N0)),relevance:0},c=N0.filter(ht=>typeof ht=="string").concat(["_|0"]),u=N0.filter(ht=>typeof ht!="string").concat(Tle).map($b),m={variants:[{className:"keyword",match:xa(...u,...Dk)}]},f={$pattern:xa(/\b\w+/,/#\w+/),keyword:c.concat(Nle),literal:Ik},g=[i,l,m],h={match:yn(/\./,xa(...Lk)),relevance:0},b={className:"built_in",match:yn(/\b/,xa(...Lk),/(?=\()/)},y=[h,b],k={match:/->/,relevance:0},C={className:"operator",relevance:0,variants:[{match:M0},{match:`\\.(\\.|${gC})+`}]},T=[k,C],A="([0-9]_*)+",M="([0-9a-fA-F]_*)+",I={className:"number",relevance:0,variants:[{match:`\\b(${A})(\\.(${A}))?([eE][+-]?(${A}))?\\b`},{match:`\\b0x(${M})(\\.(${M}))?([pP][+-]?(${A}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},B=(ht="")=>({className:"subst",variants:[{match:yn(/\\/,ht,/[0\\tnr"']/)},{match:yn(/\\/,ht,/u\{[0-9a-fA-F]{1,8}\}/)}]}),G=(ht="")=>({className:"subst",match:yn(/\\/,ht,/[\t ]*(?:[\r\n]|\r\n)/)}),j=(ht="")=>({className:"subst",label:"interpol",begin:yn(/\\/,ht,/\(/),end:/\)/}),O=(ht="")=>({begin:yn(ht,/"""/),end:yn(/"""/,ht),contains:[B(ht),G(ht),j(ht)]}),F=(ht="")=>({begin:yn(ht,/"/),end:yn(/"/,ht),contains:[B(ht),j(ht)]}),Y={className:"string",variants:[O(),O("#"),O("##"),O("###"),F(),F("#"),F("##"),F("###")]},q=[e.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[e.BACKSLASH_ESCAPE]}],V={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:q},z=ht=>{const He=yn(ht,/\//),Et=yn(/\//,ht);return{begin:He,end:Et,contains:[...q,{scope:"comment",begin:`#(?!.*${Et})`,end:/$/}]}},J={scope:"regexp",variants:[z("###"),z("##"),z("#"),V]},D={match:yn(/`/,jr,/`/)},ee={className:"variable",match:/\$\d+/},R={className:"variable",match:`\\$${zm}+`},te=[D,ee,R],le={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:jle,contains:[...T,I,Y]}]}},ke={scope:"keyword",match:yn(/@/,xa(...Mle),ic(xa(/\(/,/\s+/)))},$={scope:"meta",match:yn(/@/,jr)},W=[le,ke,$],oe={match:ic(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:yn(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,zm,"+")},{className:"type",match:Iu,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:yn(/\s+&\s+/,ic(Iu)),relevance:0}]},L={begin:/</,end:/>/,keywords:f,contains:[...a,...g,...W,k,oe]};oe.contains.push(L);const Ne={match:yn(jr,/\s*:/),keywords:"_|0",relevance:0},qe={begin:/\(/,end:/\)/,relevance:0,keywords:f,contains:["self",Ne,...a,J,...g,...y,...T,I,Y,...te,...W,oe]},me={begin:/</,end:/>/,keywords:"repeat each",contains:[...a,oe]},ze={begin:xa(ic(yn(jr,/\s*:/)),ic(yn(jr,/\s+/,jr,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:jr}]},Ue={begin:/\(/,end:/\)/,keywords:f,contains:[ze,...a,...g,...T,I,Y,...W,oe,qe],endsParent:!0,illegal:/["']/},je={match:[/(func|macro)/,/\s+/,xa(D.match,jr,M0)],className:{1:"keyword",3:"title.function"},contains:[me,Ue,t],illegal:[/\[/,/%/]},Ye={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[me,Ue,t],illegal:/\[|%/},xt={match:[/operator/,/\s+/,M0],className:{1:"keyword",3:"title"}},mt={begin:[/precedencegroup/,/\s+/,Iu],className:{1:"keyword",3:"title"},contains:[oe],keywords:[...Ele,...Ik],end:/}/},ft={match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},rt={match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},jt={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,jr,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:f,contains:[me,...g,{begin:/:/,end:/\{/,keywords:f,contains:[{scope:"title.class.inherited",match:Iu},...g],relevance:0}]};for(const ht of Y.variants){const He=ht.contains.find(Kt=>Kt.label==="interpol");He.keywords=f;const Et=[...g,...y,...T,I,Y,...te];He.contains=[...Et,{begin:/\(/,end:/\)/,contains:["self",...Et]}]}return{name:"Swift",keywords:f,contains:[...a,je,Ye,ft,rt,jt,xt,mt,{beginKeywords:"import",end:/$/,contains:[...a],relevance:0},J,...g,...y,...T,I,Y,...te,...W,oe,qe]}}const qm="[A-Za-z$_][0-9A-Za-z$_]*",yC=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],vC=["true","false","null","undefined","NaN","Infinity"],xC=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],wC=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],kC=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],SC=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],CC=[].concat(kC,xC,wC);function _le(e){const t=e.regex,n=(le,{after:ke})=>{const $="</"+le[0].slice(1);return le.input.indexOf($,ke)!==-1},a=qm,i={begin:"<>",end:"</>"},l=/<[A-Za-z0-9\\._:-]+\s*\/>/,c={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(le,ke)=>{const $=le[0].length+le.index,W=le.input[$];if(W==="<"||W===","){ke.ignoreMatch();return}W===">"&&(n(le,{after:$})||ke.ignoreMatch());let oe;const L=le.input.substring($);if(oe=L.match(/^\s*=/)){ke.ignoreMatch();return}if((oe=L.match(/^\s+extends\s+/))&&oe.index===0){ke.ignoreMatch();return}}},u={$pattern:qm,keyword:yC,literal:vC,built_in:CC,"variable.language":SC},m="[0-9](_?[0-9])*",f=`\\.(${m})`,g="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",h={className:"number",variants:[{begin:`(\\b(${g})((${f})|\\.)?|(${f}))[eE][+-]?(${m})\\b`},{begin:`\\b(${g})\\b((${f})\\b|\\.)?|(${f})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},b={className:"subst",begin:"\\$\\{",end:"\\}",keywords:u,contains:[]},y={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,b],subLanguage:"xml"}},k={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,b],subLanguage:"css"}},C={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,b],subLanguage:"graphql"}},T={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,b]},M={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:a+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},I=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,k,C,T,{match:/\$\d+/},h];b.contains=I.concat({begin:/\{/,end:/\}/,keywords:u,contains:["self"].concat(I)});const B=[].concat(M,b.contains),G=B.concat([{begin:/(\s*)\(/,end:/\)/,keywords:u,contains:["self"].concat(B)}]),j={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:G},O={variants:[{match:[/class/,/\s+/,a,/\s+/,/extends/,/\s+/,t.concat(a,"(",t.concat(/\./,a),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,a],scope:{1:"keyword",3:"title.class"}}]},F={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...xC,...wC]}},Y={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},q={variants:[{match:[/function/,/\s+/,a,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[j],illegal:/%/},V={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function z(le){return t.concat("(?!",le.join("|"),")")}const J={match:t.concat(/\b/,z([...kC,"super","import"].map(le=>`${le}\\s*\\(`)),a,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},D={begin:t.concat(/\./,t.lookahead(t.concat(a,/(?![0-9A-Za-z$_(])/))),end:a,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},ee={match:[/get|set/,/\s+/,a,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},j]},R="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",te={match:[/const|var|let/,/\s+/,a,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(R)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[j]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:u,exports:{PARAMS_CONTAINS:G,CLASS_REFERENCE:F},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),Y,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,k,C,T,M,{match:/\$\d+/},h,F,{scope:"attr",match:a+t.lookahead(":"),relevance:0},te,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[M,e.REGEXP_MODE,{className:"function",begin:R,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:G}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:l},{begin:c.begin,"on:begin":c.isTrulyOpeningTag,end:c.end}],subLanguage:"xml",contains:[{begin:c.begin,end:c.end,skip:!0,contains:["self"]}]}]},q,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[j,e.inherit(e.TITLE_MODE,{begin:a,className:"title.function"})]},{match:/\.\.\./,relevance:0},D,{match:"\\$"+a,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[j]},J,V,O,ee,{match:/\$[(.]/}]}}function Dle(e){const t=e.regex,n=_le(e),a=qm,i=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],l={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},c={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:i},contains:[n.exports.CLASS_REFERENCE]},u={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},m=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],f={$pattern:qm,keyword:yC.concat(m),literal:vC,built_in:CC.concat(i),"variable.language":SC},g={className:"meta",begin:"@"+a},h=(C,T,A)=>{const M=C.contains.findIndex(I=>I.label===T);if(M===-1)throw new Error("can not find mode to replace");C.contains.splice(M,1,A)};Object.assign(n.keywords,f),n.exports.PARAMS_CONTAINS.push(g);const b=n.contains.find(C=>C.scope==="attr"),y=Object.assign({},b,{match:t.concat(a,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,b,y]),n.contains=n.contains.concat([g,l,c,y]),h(n,"shebang",e.SHEBANG()),h(n,"use_strict",u);const k=n.contains.find(C=>C.label==="func.def");return k.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function Ile(e){const t=e.regex,n={className:"string",begin:/"(""|[^/n])"C\b/},a={className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},i=/\d{1,2}\/\d{1,2}\/\d{4}/,l=/\d{4}-\d{1,2}-\d{1,2}/,c=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,u=/\d{1,2}(:\d{1,2}){1,2}/,m={className:"literal",variants:[{begin:t.concat(/# */,t.either(l,i),/ *#/)},{begin:t.concat(/# */,u,/ *#/)},{begin:t.concat(/# */,c,/ *#/)},{begin:t.concat(/# */,t.either(l,i),/ +/,t.either(c,u),/ *#/)}]},f={className:"number",relevance:0,variants:[{begin:/\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/},{begin:/\b\d[\d_]*((U?[SIL])|[%&])?/},{begin:/&H[\dA-F_]+((U?[SIL])|[%&])?/},{begin:/&O[0-7_]+((U?[SIL])|[%&])?/},{begin:/&B[01_]+((U?[SIL])|[%&])?/}]},g={className:"label",begin:/^\w+:/},h=e.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),b=e.COMMENT(null,/$/,{variants:[{begin:/'/},{begin:/([\t ]|^)REM(?=\s)/}]});return{name:"Visual Basic .NET",aliases:["vb"],case_insensitive:!0,classNameAliases:{label:"symbol"},keywords:{keyword:"addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield",built_in:"addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort",type:"boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort",literal:"true false nothing"},illegal:"//|\\{|\\}|endif|gosub|variant|wend|^\\$ ",contains:[n,a,m,f,g,h,b,{className:"meta",begin:/[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,end:/$/,keywords:{keyword:"const disable else elseif enable end externalsource if region then"},contains:[b]}]}}function Lle(e){e.regex;const t=e.COMMENT(/\(;/,/;\)/);t.contains.push("self");const n=e.COMMENT(/;;/,/$/),a=["anyfunc","block","br","br_if","br_table","call","call_indirect","data","drop","elem","else","end","export","func","global.get","global.set","local.get","local.set","local.tee","get_global","get_local","global","if","import","local","loop","memory","memory.grow","memory.size","module","mut","nop","offset","param","result","return","select","set_global","set_local","start","table","tee_local","then","type","unreachable"],i={begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword",3:"title.function"}},l={className:"variable",begin:/\$[\w_]+/},c={match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},u={className:"number",relevance:0,match:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/},m={match:/(i32|i64|f32|f64)(?!\.)/,className:"type"},f={className:"keyword",match:/\b(f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))\b/};return{name:"WebAssembly",keywords:{$pattern:/[\w.]+/,keyword:a},contains:[n,t,{match:[/(?:offset|align)/,/\s*/,/=/],className:{1:"keyword",3:"operator"}},l,c,i,e.QUOTE_STRING_MODE,m,f,u]}}function Ple(e){const t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),a=/[\p{L}0-9._:-]+/u,i={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},l={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},c=e.inherit(l,{begin:/\(/,end:/\)/}),u=e.inherit(e.APOS_STRING_MODE,{className:"string"}),m=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),f={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:a,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[i]},{begin:/'/,end:/'/,contains:[i]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[l,m,u,c,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[l,c,m,u]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},i,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[m]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[f],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[f],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:f}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function Ole(e){const t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",a={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},i={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},l={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},c={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,i]},u=e.inherit(c,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),b={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},y={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},k={begin:/\{/,end:/\}/,contains:[y],illegal:"\\n",relevance:0},C={begin:"\\[",end:"\\]",contains:[y],illegal:"\\n",relevance:0},T=[a,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},b,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},k,C,l,c],A=[...T];return A.pop(),A.push(u),y.contains=A,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:T}}const Hle={arduino:voe,bash:xoe,c:woe,cpp:koe,csharp:Soe,css:_oe,diff:Doe,go:Ioe,graphql:Loe,ini:Poe,java:Ooe,javascript:$oe,json:Foe,kotlin:Goe,less:Zoe,lua:ele,makefile:tle,markdown:nle,objectivec:ale,perl:rle,php:ile,"php-template":sle,plaintext:ole,python:lle,"python-repl":cle,r:dle,ruby:ule,rust:mle,scss:wle,shell:kle,sql:Sle,swift:Rle,typescript:Dle,vbnet:Ile,wasm:Lle,xml:Ple,yaml:Ole};var j0,Pk;function Ble(){if(Pk)return j0;Pk=1;function e(Q){return Q instanceof Map?Q.clear=Q.delete=Q.set=function(){throw new Error("map is read-only")}:Q instanceof Set&&(Q.add=Q.clear=Q.delete=function(){throw new Error("set is read-only")}),Object.freeze(Q),Object.getOwnPropertyNames(Q).forEach(be=>{const Te=Q[be],Xe=typeof Te;(Xe==="object"||Xe==="function")&&!Object.isFrozen(Te)&&e(Te)}),Q}class t{constructor(be){be.data===void 0&&(be.data={}),this.data=be.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(Q){return Q.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function a(Q,...be){const Te=Object.create(null);for(const Xe in Q)Te[Xe]=Q[Xe];return be.forEach(function(Xe){for(const wt in Xe)Te[wt]=Xe[wt]}),Te}const i="</span>",l=Q=>!!Q.scope,c=(Q,{prefix:be})=>{if(Q.startsWith("language:"))return Q.replace("language:","language-");if(Q.includes(".")){const Te=Q.split(".");return[`${be}${Te.shift()}`,...Te.map((Xe,wt)=>`${Xe}${"_".repeat(wt+1)}`)].join(" ")}return`${be}${Q}`};class u{constructor(be,Te){this.buffer="",this.classPrefix=Te.classPrefix,be.walk(this)}addText(be){this.buffer+=n(be)}openNode(be){if(!l(be))return;const Te=c(be.scope,{prefix:this.classPrefix});this.span(Te)}closeNode(be){l(be)&&(this.buffer+=i)}value(){return this.buffer}span(be){this.buffer+=`<span class="${be}">`}}const m=(Q={})=>{const be={children:[]};return Object.assign(be,Q),be};class f{constructor(){this.rootNode=m(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(be){this.top.children.push(be)}openNode(be){const Te=m({scope:be});this.add(Te),this.stack.push(Te)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(be){return this.constructor._walk(be,this.rootNode)}static _walk(be,Te){return typeof Te=="string"?be.addText(Te):Te.children&&(be.openNode(Te),Te.children.forEach(Xe=>this._walk(be,Xe)),be.closeNode(Te)),be}static _collapse(be){typeof be!="string"&&be.children&&(be.children.every(Te=>typeof Te=="string")?be.children=[be.children.join("")]:be.children.forEach(Te=>{f._collapse(Te)}))}}class g extends f{constructor(be){super(),this.options=be}addText(be){be!==""&&this.add(be)}startScope(be){this.openNode(be)}endScope(){this.closeNode()}__addSublanguage(be,Te){const Xe=be.root;Te&&(Xe.scope=`language:${Te}`),this.add(Xe)}toHTML(){return new u(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function h(Q){return Q?typeof Q=="string"?Q:Q.source:null}function b(Q){return C("(?=",Q,")")}function y(Q){return C("(?:",Q,")*")}function k(Q){return C("(?:",Q,")?")}function C(...Q){return Q.map(Te=>h(Te)).join("")}function T(Q){const be=Q[Q.length-1];return typeof be=="object"&&be.constructor===Object?(Q.splice(Q.length-1,1),be):{}}function A(...Q){return"("+(T(Q).capture?"":"?:")+Q.map(Xe=>h(Xe)).join("|")+")"}function M(Q){return new RegExp(Q.toString()+"|").exec("").length-1}function I(Q,be){const Te=Q&&Q.exec(be);return Te&&Te.index===0}const B=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function G(Q,{joinWith:be}){let Te=0;return Q.map(Xe=>{Te+=1;const wt=Te;let Ht=h(Xe),lt="";for(;Ht.length>0;){const nt=B.exec(Ht);if(!nt){lt+=Ht;break}lt+=Ht.substring(0,nt.index),Ht=Ht.substring(nt.index+nt[0].length),nt[0][0]==="\\"&&nt[1]?lt+="\\"+String(Number(nt[1])+wt):(lt+=nt[0],nt[0]==="("&&Te++)}return lt}).map(Xe=>`(${Xe})`).join(be)}const j=/\b\B/,O="[a-zA-Z]\\w*",F="[a-zA-Z_]\\w*",Y="\\b\\d+(\\.\\d+)?",q="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",V="\\b(0b[01]+)",z="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",J=(Q={})=>{const be=/^#![ ]*\//;return Q.binary&&(Q.begin=C(be,/.*\b/,Q.binary,/\b.*/)),a({scope:"meta",begin:be,end:/$/,relevance:0,"on:begin":(Te,Xe)=>{Te.index!==0&&Xe.ignoreMatch()}},Q)},D={begin:"\\\\[\\s\\S]",relevance:0},ee={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[D]},R={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[D]},te={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},le=function(Q,be,Te={}){const Xe=a({scope:"comment",begin:Q,end:be,contains:[]},Te);Xe.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const wt=A("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return Xe.contains.push({begin:C(/[ ]+/,"(",wt,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),Xe},ke=le("//","$"),$=le("/\\*","\\*/"),W=le("#","$"),oe={scope:"number",begin:Y,relevance:0},L={scope:"number",begin:q,relevance:0},Ne={scope:"number",begin:V,relevance:0},qe={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[D,{begin:/\[/,end:/\]/,relevance:0,contains:[D]}]},me={scope:"title",begin:O,relevance:0},ze={scope:"title",begin:F,relevance:0},Ue={begin:"\\.\\s*"+F,relevance:0};var Ye=Object.freeze({__proto__:null,APOS_STRING_MODE:ee,BACKSLASH_ESCAPE:D,BINARY_NUMBER_MODE:Ne,BINARY_NUMBER_RE:V,COMMENT:le,C_BLOCK_COMMENT_MODE:$,C_LINE_COMMENT_MODE:ke,C_NUMBER_MODE:L,C_NUMBER_RE:q,END_SAME_AS_BEGIN:function(Q){return Object.assign(Q,{"on:begin":(be,Te)=>{Te.data._beginMatch=be[1]},"on:end":(be,Te)=>{Te.data._beginMatch!==be[1]&&Te.ignoreMatch()}})},HASH_COMMENT_MODE:W,IDENT_RE:O,MATCH_NOTHING_RE:j,METHOD_GUARD:Ue,NUMBER_MODE:oe,NUMBER_RE:Y,PHRASAL_WORDS_MODE:te,QUOTE_STRING_MODE:R,REGEXP_MODE:qe,RE_STARTERS_RE:z,SHEBANG:J,TITLE_MODE:me,UNDERSCORE_IDENT_RE:F,UNDERSCORE_TITLE_MODE:ze});function xt(Q,be){Q.input[Q.index-1]==="."&&be.ignoreMatch()}function mt(Q,be){Q.className!==void 0&&(Q.scope=Q.className,delete Q.className)}function ft(Q,be){be&&Q.beginKeywords&&(Q.begin="\\b("+Q.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",Q.__beforeBegin=xt,Q.keywords=Q.keywords||Q.beginKeywords,delete Q.beginKeywords,Q.relevance===void 0&&(Q.relevance=0))}function rt(Q,be){Array.isArray(Q.illegal)&&(Q.illegal=A(...Q.illegal))}function jt(Q,be){if(Q.match){if(Q.begin||Q.end)throw new Error("begin & end are not supported with match");Q.begin=Q.match,delete Q.match}}function ht(Q,be){Q.relevance===void 0&&(Q.relevance=1)}const He=(Q,be)=>{if(!Q.beforeMatch)return;if(Q.starts)throw new Error("beforeMatch cannot be used with starts");const Te=Object.assign({},Q);Object.keys(Q).forEach(Xe=>{delete Q[Xe]}),Q.keywords=Te.keywords,Q.begin=C(Te.beforeMatch,b(Te.begin)),Q.starts={relevance:0,contains:[Object.assign(Te,{endsParent:!0})]},Q.relevance=0,delete Te.beforeMatch},Et=["of","and","for","in","not","or","if","then","parent","list","value"],Kt="keyword";function ie(Q,be,Te=Kt){const Xe=Object.create(null);return typeof Q=="string"?wt(Te,Q.split(" ")):Array.isArray(Q)?wt(Te,Q):Object.keys(Q).forEach(function(Ht){Object.assign(Xe,ie(Q[Ht],be,Ht))}),Xe;function wt(Ht,lt){be&&(lt=lt.map(nt=>nt.toLowerCase())),lt.forEach(function(nt){const Ct=nt.split("|");Xe[Ct[0]]=[Ht,tt(Ct[0],Ct[1])]})}}function tt(Q,be){return be?Number(be):it(Q)?0:1}function it(Q){return Et.includes(Q.toLowerCase())}const xe={},Me=Q=>{console.error(Q)},Ie=(Q,...be)=>{console.log(`WARN: ${Q}`,...be)},ne=(Q,be)=>{xe[`${Q}/${be}`]||(console.log(`Deprecated as of ${Q}. ${be}`),xe[`${Q}/${be}`]=!0)},U=new Error;function re(Q,be,{key:Te}){let Xe=0;const wt=Q[Te],Ht={},lt={};for(let nt=1;nt<=be.length;nt++)lt[nt+Xe]=wt[nt],Ht[nt+Xe]=!0,Xe+=M(be[nt-1]);Q[Te]=lt,Q[Te]._emit=Ht,Q[Te]._multi=!0}function Ce(Q){if(Array.isArray(Q.begin)){if(Q.skip||Q.excludeBegin||Q.returnBegin)throw Me("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),U;if(typeof Q.beginScope!="object"||Q.beginScope===null)throw Me("beginScope must be object"),U;re(Q,Q.begin,{key:"beginScope"}),Q.begin=G(Q.begin,{joinWith:""})}}function Pe(Q){if(Array.isArray(Q.end)){if(Q.skip||Q.excludeEnd||Q.returnEnd)throw Me("skip, excludeEnd, returnEnd not compatible with endScope: {}"),U;if(typeof Q.endScope!="object"||Q.endScope===null)throw Me("endScope must be object"),U;re(Q,Q.end,{key:"endScope"}),Q.end=G(Q.end,{joinWith:""})}}function $e(Q){Q.scope&&typeof Q.scope=="object"&&Q.scope!==null&&(Q.beginScope=Q.scope,delete Q.scope)}function ue(Q){$e(Q),typeof Q.beginScope=="string"&&(Q.beginScope={_wrap:Q.beginScope}),typeof Q.endScope=="string"&&(Q.endScope={_wrap:Q.endScope}),Ce(Q),Pe(Q)}function he(Q){function be(lt,nt){return new RegExp(h(lt),"m"+(Q.case_insensitive?"i":"")+(Q.unicodeRegex?"u":"")+(nt?"g":""))}class Te{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(nt,Ct){Ct.position=this.position++,this.matchIndexes[this.matchAt]=Ct,this.regexes.push([Ct,nt]),this.matchAt+=M(nt)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const nt=this.regexes.map(Ct=>Ct[1]);this.matcherRe=be(G(nt,{joinWith:"|"}),!0),this.lastIndex=0}exec(nt){this.matcherRe.lastIndex=this.lastIndex;const Ct=this.matcherRe.exec(nt);if(!Ct)return null;const vn=Ct.findIndex((Xn,ga)=>ga>0&&Xn!==void 0),xn=this.matchIndexes[vn];return Ct.splice(0,vn),Object.assign(Ct,xn)}}class Xe{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(nt){if(this.multiRegexes[nt])return this.multiRegexes[nt];const Ct=new Te;return this.rules.slice(nt).forEach(([vn,xn])=>Ct.addRule(vn,xn)),Ct.compile(),this.multiRegexes[nt]=Ct,Ct}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(nt,Ct){this.rules.push([nt,Ct]),Ct.type==="begin"&&this.count++}exec(nt){const Ct=this.getMatcher(this.regexIndex);Ct.lastIndex=this.lastIndex;let vn=Ct.exec(nt);if(this.resumingScanAtSamePosition()&&!(vn&&vn.index===this.lastIndex)){const xn=this.getMatcher(0);xn.lastIndex=this.lastIndex+1,vn=xn.exec(nt)}return vn&&(this.regexIndex+=vn.position+1,this.regexIndex===this.count&&this.considerAll()),vn}}function wt(lt){const nt=new Xe;return lt.contains.forEach(Ct=>nt.addRule(Ct.begin,{rule:Ct,type:"begin"})),lt.terminatorEnd&&nt.addRule(lt.terminatorEnd,{type:"end"}),lt.illegal&&nt.addRule(lt.illegal,{type:"illegal"}),nt}function Ht(lt,nt){const Ct=lt;if(lt.isCompiled)return Ct;[mt,jt,ue,He].forEach(xn=>xn(lt,nt)),Q.compilerExtensions.forEach(xn=>xn(lt,nt)),lt.__beforeBegin=null,[ft,rt,ht].forEach(xn=>xn(lt,nt)),lt.isCompiled=!0;let vn=null;return typeof lt.keywords=="object"&<.keywords.$pattern&&(lt.keywords=Object.assign({},lt.keywords),vn=lt.keywords.$pattern,delete lt.keywords.$pattern),vn=vn||/\w+/,lt.keywords&&(lt.keywords=ie(lt.keywords,Q.case_insensitive)),Ct.keywordPatternRe=be(vn,!0),nt&&(lt.begin||(lt.begin=/\B|\b/),Ct.beginRe=be(Ct.begin),!lt.end&&!lt.endsWithParent&&(lt.end=/\B|\b/),lt.end&&(Ct.endRe=be(Ct.end)),Ct.terminatorEnd=h(Ct.end)||"",lt.endsWithParent&&nt.terminatorEnd&&(Ct.terminatorEnd+=(lt.end?"|":"")+nt.terminatorEnd)),lt.illegal&&(Ct.illegalRe=be(lt.illegal)),lt.contains||(lt.contains=[]),lt.contains=[].concat(...lt.contains.map(function(xn){return dt(xn==="self"?lt:xn)})),lt.contains.forEach(function(xn){Ht(xn,Ct)}),lt.starts&&Ht(lt.starts,nt),Ct.matcher=wt(Ct),Ct}if(Q.compilerExtensions||(Q.compilerExtensions=[]),Q.contains&&Q.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return Q.classNameAliases=a(Q.classNameAliases||{}),Ht(Q)}function Ve(Q){return Q?Q.endsWithParent||Ve(Q.starts):!1}function dt(Q){return Q.variants&&!Q.cachedVariants&&(Q.cachedVariants=Q.variants.map(function(be){return a(Q,{variants:null},be)})),Q.cachedVariants?Q.cachedVariants:Ve(Q)?a(Q,{starts:Q.starts?a(Q.starts):null}):Object.isFrozen(Q)?a(Q):Q}var Je="11.11.1";class ot extends Error{constructor(be,Te){super(be),this.name="HTMLInjectionError",this.html=Te}}const Ft=n,cn=a,Ot=Symbol("nomatch"),Ee=7,_e=function(Q){const be=Object.create(null),Te=Object.create(null),Xe=[];let wt=!0;const Ht="Could not find the language '{}', did you forget to load/include a language module?",lt={disableAutodetect:!0,name:"Plain text",contains:[]};let nt={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:g};function Ct(pe){return nt.noHighlightRe.test(pe)}function vn(pe){let Ze=pe.className+" ";Ze+=pe.parentNode?pe.parentNode.className:"";const St=nt.languageDetectRe.exec(Ze);if(St){const Ut=ia(St[1]);return Ut||(Ie(Ht.replace("{}",St[1])),Ie("Falling back to no-highlight mode for this block.",pe)),Ut?St[1]:"no-highlight"}return Ze.split(/\s+/).find(Ut=>Ct(Ut)||ia(Ut))}function xn(pe,Ze,St){let Ut="",ln="";typeof Ze=="object"?(Ut=pe,St=Ze.ignoreIllegals,ln=Ze.language):(ne("10.7.0","highlight(lang, code, ...args) has been deprecated."),ne("10.7.0",`Please use highlight(code, options) instead.
|
|
813
813
|
https://github.com/highlightjs/highlight.js/issues/2277`),ln=pe,Ut=Ze),St===void 0&&(St=!0);const jn={code:Ut,language:ln};hr("before:highlight",jn);const Dt=jn.result?jn.result:Xn(jn.language,jn.code,St);return Dt.code=jn.code,hr("after:highlight",Dt),Dt}function Xn(pe,Ze,St,Ut){const ln=Object.create(null);function jn(et,gt){return et.keywords[gt]}function Dt(){if(!Nt.keywords){Fn.addText(un);return}let et=0;Nt.keywordPatternRe.lastIndex=0;let gt=Nt.keywordPatternRe.exec(un),Pt="";for(;gt;){Pt+=un.substring(et,gt.index);const Jt=sa.case_insensitive?gt[0].toLowerCase():gt[0],Ln=jn(Nt,Jt);if(Ln){const[er,ll]=Ln;if(Fn.addText(Pt),Pt="",ln[Jt]=(ln[Jt]||0)+1,ln[Jt]<=Ee&&(xi+=ll),er.startsWith("_"))Pt+=gt[0];else{const Qc=sa.classNameAliases[er]||er;fn(gt[0],Qc)}}else Pt+=gt[0];et=Nt.keywordPatternRe.lastIndex,gt=Nt.keywordPatternRe.exec(un)}Pt+=un.substring(et),Fn.addText(Pt)}function dn(){if(un==="")return;let et=null;if(typeof Nt.subLanguage=="string"){if(!be[Nt.subLanguage]){Fn.addText(un);return}et=Xn(Nt.subLanguage,un,!0,Yc[Nt.subLanguage]),Yc[Nt.subLanguage]=et._top}else et=yi(un,Nt.subLanguage.length?Nt.subLanguage:null);Nt.relevance>0&&(xi+=et.relevance),Fn.__addSublanguage(et._emitter,et.language)}function Lt(){Nt.subLanguage!=null?dn():Dt(),un=""}function fn(et,gt){et!==""&&(Fn.startScope(gt),Fn.addText(et),Fn.endScope())}function Aa(et,gt){let Pt=1;const Jt=gt.length-1;for(;Pt<=Jt;){if(!et._emit[Pt]){Pt++;continue}const Ln=sa.classNameAliases[et[Pt]]||et[Pt],er=gt[Pt];Ln?fn(er,Ln):(un=er,Dt(),un=""),Pt++}}function gr(et,gt){return et.scope&&typeof et.scope=="string"&&Fn.openNode(sa.classNameAliases[et.scope]||et.scope),et.beginScope&&(et.beginScope._wrap?(fn(un,sa.classNameAliases[et.beginScope._wrap]||et.beginScope._wrap),un=""):et.beginScope._multi&&(Aa(et.beginScope,gt),un="")),Nt=Object.create(et,{parent:{value:Nt}}),Nt}function Fr(et,gt,Pt){let Jt=I(et.endRe,Pt);if(Jt){if(et["on:end"]){const Ln=new t(et);et["on:end"](gt,Ln),Ln.isMatchIgnored&&(Jt=!1)}if(Jt){for(;et.endsParent&&et.parent;)et=et.parent;return et}}if(et.endsWithParent)return Fr(et.parent,gt,Pt)}function Ws(et){return Nt.matcher.regexIndex===0?(un+=et[0],1):(wi=!0,0)}function Sp(et){const gt=et[0],Pt=et.rule,Jt=new t(Pt),Ln=[Pt.__beforeBegin,Pt["on:begin"]];for(const er of Ln)if(er&&(er(et,Jt),Jt.isMatchIgnored))return Ws(gt);return Pt.skip?un+=gt:(Pt.excludeBegin&&(un+=gt),Lt(),!Pt.returnBegin&&!Pt.excludeBegin&&(un=gt)),gr(Pt,et),Pt.returnBegin?0:gt.length}function Ta(et){const gt=et[0],Pt=Ze.substring(et.index),Jt=Fr(Nt,et,Pt);if(!Jt)return Ot;const Ln=Nt;Nt.endScope&&Nt.endScope._wrap?(Lt(),fn(gt,Nt.endScope._wrap)):Nt.endScope&&Nt.endScope._multi?(Lt(),Aa(Nt.endScope,et)):Ln.skip?un+=gt:(Ln.returnEnd||Ln.excludeEnd||(un+=gt),Lt(),Ln.excludeEnd&&(un=gt));do Nt.scope&&Fn.closeNode(),!Nt.skip&&!Nt.subLanguage&&(xi+=Nt.relevance),Nt=Nt.parent;while(Nt!==Jt.parent);return Jt.starts&&gr(Jt.starts,et),Ln.returnEnd?0:gt.length}function sl(){const et=[];for(let gt=Nt;gt!==sa;gt=gt.parent)gt.scope&&et.unshift(gt.scope);et.forEach(gt=>Fn.openNode(gt))}let os={};function Ys(et,gt){const Pt=gt&>[0];if(un+=et,Pt==null)return Lt(),0;if(os.type==="begin"&>.type==="end"&&os.index===gt.index&&Pt===""){if(un+=Ze.slice(gt.index,gt.index+1),!wt){const Jt=new Error(`0 width match regex (${pe})`);throw Jt.languageName=pe,Jt.badRule=os.rule,Jt}return 1}if(os=gt,gt.type==="begin")return Sp(gt);if(gt.type==="illegal"&&!St){const Jt=new Error('Illegal lexeme "'+Pt+'" for mode "'+(Nt.scope||"<unnamed>")+'"');throw Jt.mode=Nt,Jt}else if(gt.type==="end"){const Jt=Ta(gt);if(Jt!==Ot)return Jt}if(gt.type==="illegal"&&Pt==="")return un+=`
|
|
814
|
-
`,1;if(ol>1e5&&ol>gt.index*3)throw new Error("potential infinite loop, way more iterations than matches");return un+=Pt,Pt.length}const sa=ia(pe);if(!sa)throw Me(Ht.replace("{}",pe)),new Error('Unknown language: "'+pe+'"');const Wc=he(sa);let Qs="",Nt=Ut||Wc;const Yc={},Fn=new nt.__emitter(nt);sl();let un="",xi=0,Ur=0,ol=0,wi=!1;try{if(sa.__emitTokens)sa.__emitTokens(Ze,Fn);else{for(Nt.matcher.considerAll();;){ol++,wi?wi=!1:Nt.matcher.considerAll(),Nt.matcher.lastIndex=Ur;const et=Nt.matcher.exec(Ze);if(!et)break;const gt=Ze.substring(Ur,et.index),Pt=Ys(gt,et);Ur=et.index+Pt}Ys(Ze.substring(Ur))}return Fn.finalize(),Qs=Fn.toHTML(),{language:pe,value:Qs,relevance:xi,illegal:!1,_emitter:Fn,_top:Nt}}catch(et){if(et.message&&et.message.includes("Illegal"))return{language:pe,value:Ft(Ze),illegal:!0,relevance:0,_illegalBy:{message:et.message,index:Ur,context:Ze.slice(Ur-100,Ur+100),mode:et.mode,resultSoFar:Qs},_emitter:Fn};if(wt)return{language:pe,value:Ft(Ze),illegal:!1,relevance:0,errorRaised:et,_emitter:Fn,_top:Nt};throw et}}function ga(pe){const Ze={value:Ft(pe),illegal:!1,relevance:0,_top:lt,_emitter:new nt.__emitter(nt)};return Ze._emitter.addText(pe),Ze}function yi(pe,Ze){Ze=Ze||nt.languages||Object.keys(be);const St=ga(pe),Ut=Ze.filter(ia).filter(Cr).map(Lt=>Xn(Lt,pe,!1));Ut.unshift(St);const ln=Ut.sort((Lt,fn)=>{if(Lt.relevance!==fn.relevance)return fn.relevance-Lt.relevance;if(Lt.language&&fn.language){if(ia(Lt.language).supersetOf===fn.language)return 1;if(ia(fn.language).supersetOf===Lt.language)return-1}return 0}),[jn,Dt]=ln,dn=jn;return dn.secondBest=Dt,dn}function ba(pe,Ze,St){const Ut=Ze&&Te[Ze]||St;pe.classList.add("hljs"),pe.classList.add(`language-${Ut}`)}function Mn(pe){let Ze=null;const St=vn(pe);if(Ct(St))return;if(hr("before:highlightElement",{el:pe,language:St}),pe.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",pe);return}if(pe.children.length>0&&(nt.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(pe)),nt.throwUnescapedHTML))throw new ot("One of your code blocks includes unescaped HTML.",pe.innerHTML);Ze=pe;const Ut=Ze.textContent,ln=St?xn(Ut,{language:St,ignoreIllegals:!0}):yi(Ut);pe.innerHTML=ln.value,pe.dataset.highlighted="yes",ba(pe,St,ln.language),pe.result={language:ln.language,re:ln.relevance,relevance:ln.relevance},ln.secondBest&&(pe.secondBest={language:ln.secondBest.language,relevance:ln.secondBest.relevance}),hr("after:highlightElement",{el:pe,result:ln,text:Ut})}function Zn(pe){nt=cn(nt,pe)}const kr=()=>{$r(),ne("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Sr(){$r(),ne("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Ks=!1;function $r(){function pe(){$r()}if(document.readyState==="loading"){Ks||window.addEventListener("DOMContentLoaded",pe,!1),Ks=!0;return}document.querySelectorAll(nt.cssSelector).forEach(Mn)}function ss(pe,Ze){let St=null;try{St=Ze(Q)}catch(Ut){if(Me("Language definition for '{}' could not be registered.".replace("{}",pe)),wt)Me(Ut);else throw Ut;St=lt}St.name||(St.name=pe),be[pe]=St,St.rawDefinition=Ze.bind(null,Q),St.aliases&&fr(St.aliases,{languageName:pe})}function ra(pe){delete be[pe];for(const Ze of Object.keys(Te))Te[Ze]===pe&&delete Te[Ze]}function vi(){return Object.keys(be)}function ia(pe){return pe=(pe||"").toLowerCase(),be[pe]||be[Te[pe]]}function fr(pe,{languageName:Ze}){typeof pe=="string"&&(pe=[pe]),pe.forEach(St=>{Te[St.toLowerCase()]=Ze})}function Cr(pe){const Ze=ia(pe);return Ze&&!Ze.disableAutodetect}function Ar(pe){pe["before:highlightBlock"]&&!pe["before:highlightElement"]&&(pe["before:highlightElement"]=Ze=>{pe["before:highlightBlock"](Object.assign({block:Ze.el},Ze))}),pe["after:highlightBlock"]&&!pe["after:highlightElement"]&&(pe["after:highlightElement"]=Ze=>{pe["after:highlightBlock"](Object.assign({block:Ze.el},Ze))})}function In(pe){Ar(pe),Xe.push(pe)}function Vs(pe){const Ze=Xe.indexOf(pe);Ze!==-1&&Xe.splice(Ze,1)}function hr(pe,Ze){const St=pe;Xe.forEach(function(Ut){Ut[St]&&Ut[St](Ze)})}function ge(pe){return ne("10.7.0","highlightBlock will be removed entirely in v12.0"),ne("10.7.0","Please use highlightElement now."),Mn(pe)}Object.assign(Q,{highlight:xn,highlightAuto:yi,highlightAll:$r,highlightElement:Mn,highlightBlock:ge,configure:Zn,initHighlighting:kr,initHighlightingOnLoad:Sr,registerLanguage:ss,unregisterLanguage:ra,listLanguages:vi,getLanguage:ia,registerAliases:fr,autoDetection:Cr,inherit:cn,addPlugin:In,removePlugin:Vs}),Q.debugMode=function(){wt=!1},Q.safeMode=function(){wt=!0},Q.versionString=Je,Q.regex={concat:C,lookahead:b,either:A,optional:k,anyNumberOfTimes:y};for(const pe in Ye)typeof Ye[pe]=="object"&&e(Ye[pe]);return Object.assign(Q,Ye),Q},De=_e({});return De.newInstance=()=>_e({}),j0=De,De.HighlightJS=De,De.default=De,j0}var zle=Ble();const qle=Bc(zle),Ok={},$le="hljs-";function Fle(e){const t=qle.newInstance();return e&&l(e),{highlight:n,highlightAuto:a,listLanguages:i,register:l,registerAlias:c,registered:u};function n(m,f,g){const h=g||Ok,b=typeof h.prefix=="string"?h.prefix:$le;if(!t.getLanguage(m))throw new Error("Unknown language: `"+m+"` is not registered");t.configure({__emitter:Ule,classPrefix:b});const y=t.highlight(f,{ignoreIllegals:!0,language:m});if(y.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:y.errorRaised});const k=y._emitter.root,C=k.data;return C.language=y.language,C.relevance=y.relevance,k}function a(m,f){const h=(f||Ok).subset||i();let b=-1,y=0,k;for(;++b<h.length;){const C=h[b];if(!t.getLanguage(C))continue;const T=n(C,m,f);T.data&&T.data.relevance!==void 0&&T.data.relevance>y&&(y=T.data.relevance,k=T)}return k||{type:"root",children:[],data:{language:void 0,relevance:y}}}function i(){return t.listLanguages()}function l(m,f){if(typeof m=="string")t.registerLanguage(m,f);else{let g;for(g in m)Object.hasOwn(m,g)&&t.registerLanguage(g,m[g])}}function c(m,f){if(typeof m=="string")t.registerAliases(typeof f=="string"?f:[...f],{languageName:m});else{let g;for(g in m)if(Object.hasOwn(m,g)){const h=m[g];t.registerAliases(typeof h=="string"?h:[...h],{languageName:g})}}}function u(m){return!!t.getLanguage(m)}}class Ule{constructor(t){this.options=t,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(t){if(t==="")return;const n=this.stack[this.stack.length-1],a=n.children[n.children.length-1];a&&a.type==="text"?a.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const a=this.stack[this.stack.length-1],i=t.root.children;n?a.children.push({type:"element",tagName:"span",properties:{className:[n]},children:i}):a.children.push(...i)}openNode(t){const n=this,a=t.split(".").map(function(c,u){return u?c+"_".repeat(u):n.options.classPrefix+c}),i=this.stack[this.stack.length-1],l={type:"element",tagName:"span",properties:{className:a},children:[]};i.children.push(l),this.stack.push(l)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const Gle={};function Kle(e){const t=e||Gle,n=t.aliases,a=t.detect||!1,i=t.languages||Hle,l=t.plainText,c=t.prefix,u=t.subset;let m="hljs";const f=Fle(i);if(n&&f.registerAlias(n),c){const g=c.indexOf("-");m=g===-1?c:c.slice(0,g)}return function(g,h){op(g,"element",function(b,y,k){if(b.tagName!=="code"||!k||k.type!=="element"||k.tagName!=="pre")return;const C=Vle(b);if(C===!1||!C&&!a||C&&l&&l.includes(C))return;Array.isArray(b.properties.className)||(b.properties.className=[]),b.properties.className.includes(m)||b.properties.className.unshift(m);const T=rC(b,{whitespace:"pre"});let A;try{A=C?f.highlight(C,T,{prefix:c}):f.highlightAuto(T,{prefix:c,subset:u})}catch(M){const I=M;if(C&&/Unknown language/.test(I.message)){h.message("Cannot highlight as `"+C+"`, it’s not registered",{ancestors:[k,b],cause:I,place:b.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw I}!C&&A.data&&A.data.language&&b.properties.className.push("language-"+A.data.language),A.children.length>0&&(b.children=A.children)})}}function Vle(e){const t=e.properties.className;let n=-1;if(!Array.isArray(t))return;let a;for(;++n<t.length;){const i=String(t[n]);if(i==="no-highlight"||i==="nohighlight")return!1;!a&&i.slice(0,5)==="lang-"&&(a=i.slice(5)),!a&&i.slice(0,9)==="language-"&&(a=i.slice(9))}return a}const Bs={agent:{label:"Agent",labelZh:"智能体",gradient:"from-violet-500 to-indigo-600",accent:"#8b5cf6",covers:[["#7c3aed","#4f46e5"],["#8b5cf6","#6366f1"],["#a855f7","#4338ca"],["#6d28d9","#2563eb"]]},team:{label:"Team",labelZh:"AI 小队",gradient:"from-cyan-500 to-blue-600",accent:"#06b6d4",covers:[["#0891b2","#2563eb"],["#06b6d4","#3b82f6"],["#0e7490","#1d4ed8"],["#22d3ee","#4f46e5"]]},skill:{label:"Skill",labelZh:"技能",gradient:"from-amber-500 to-orange-600",accent:"#f59e0b",covers:[["#f59e0b","#ea580c"],["#d97706","#dc2626"],["#fbbf24","#f97316"],["#f59e0b","#b45309"]]},connector:{label:"Connector",labelZh:"连接器",gradient:"from-emerald-500 to-teal-600",accent:"#10b981",covers:[["#10b981","#0d9488"],["#059669","#0891b2"],["#34d399","#14b8a6"],["#16a34a","#0f766e"]]}};function il(e){const t=(e||"").toLowerCase();return t==="team"?"team":t==="skill"?"skill":t==="connector"||t==="mcp"?"connector":"agent"}function AC(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}const Wle={agent:258,team:205,skill:32,connector:162};function Fb(e,t){const n=Wle[e],a=AC(t),i=((n+(a%68-34))%360+360)%360,l=(i+22+(a>>>8)%24)%360;return`linear-gradient(${120+a%44}deg, hsl(${i} 72% 56%), hsl(${l} 66% 43%))`}const Hk=["M12 2l2.4 6.9L21 9l-5.4 4 2 7-5.6-4.1L6.4 20l2-7L3 9l6.6-.1z","M12 2a10 10 0 100 20 10 10 0 000-20zm0 4a6 6 0 110 12 6 6 0 010-12z","M4 4h7v7H4zM13 4h7v7h-7zM4 13h7v7H4zM13 13h7v7h-7z","M12 2l9 5v10l-9 5-9-5V7z","M3 12a9 9 0 019-9v9h9a9 9 0 11-18 0z","M6 3h12l3 6-9 12L3 9z","M12 3l3 6 6 .9-4.5 4.3 1 6.3L12 18l-5.5 2.5 1-6.3L3 9.9 9 9z","M4 12a8 8 0 018-8v4a4 4 0 00-4 4zm8 8a8 8 0 01-8-8h4a4 4 0 004 4z","M12 2l7 4v12l-7 4-7-4V6z M12 6l-3 1.7v3.4L12 13l3-1.9V7.7z","M3 6h18M3 12h18M3 18h18","M12 2a10 10 0 100 20A6 6 0 0112 8a6 6 0 010 12","M12 2l4 8h-8zM4 12h16l-8 10z"];function TC(e){return Hk[AC(e+"g")%Hk.length]}function EC(e){return e?e.startsWith("http://")||e.startsWith("https://")||e.startsWith("/")||e.startsWith("data:")||/\.(png|jpe?g|gif|webp|svg)$/i.test(e):!1}function Yle(e){return!e||EC(e)?!1:[...e].length<=4&&new RegExp("\\p{Extended_Pictographic}","u").test(e)}function Qle(e,t="user"){const n=t==="org"?"shapes":"thumbs",a=encodeURIComponent(e);return`https://api.dicebear.com/9.x/${n}/svg?seed=${a}&radius=50&backgroundType=gradientLinear`}function qo(e){const t=e??0;return t<1e3?String(t):t<1e6?`${(t/1e3).toFixed(t<1e4?1:0)}k`.replace(".0k","k"):`${(t/1e6).toFixed(1)}M`.replace(".0M","M")}function Bk(e,t="usd"){return!e||e<=0?"Free":`${t.toLowerCase()==="usd"?"$":""}${(e/100).toFixed(e%100===0?0:2)}`}const NC=/^(?:\/|~\/|[A-Za-z]:[\\/]|\\\\)/,MC=/^\.{1,2}\//,Jle=/\.[a-zA-Z0-9]{1,12}(?:$|[?#])/,jC=/^[A-Za-z]:[\\/]/,RC=/^\\\\[^\\]/;function Xle(e){const t=e.trim();return t?!!(/^file:/i.test(t)||jC.test(t)||RC.test(t)||t.startsWith("~/")||t.startsWith("/")||MC.test(t)):!1}const Zle=/(?:%[0-9A-Fa-f]{2})+/g;function _C(e){return e.includes("%")?e.replace(Zle,t=>{const n=new Uint8Array(t.length/3);for(let a=0;a<n.length;a++)n[a]=Number.parseInt(t.slice(a*3+1,a*3+3),16);try{const a=new TextDecoder("utf-8",{fatal:!0}).decode(n);return/[^\x00-\x7F]/.test(a)?a:t}catch{return t}}):e}function Ub(e){let t=e.trim();if(/^file:/i.test(t)){try{t=decodeURIComponent(t.replace(/^file:\/\//i,""))}catch{t=t.replace(/^file:\/\//i,"")}/^\/[A-Za-z]:\//.test(t)&&(t=t.slice(1))}return t=_C(t),t=t.replace(/\\+/g,"/"),t}function ope(e){return e.replace(/(!?\[[^\]]*]\()((?:[A-Za-z]:|\\\\)[^)\n]*)(\))/g,(t,n,a,i)=>`${n}${a.replace(/\\+/g,"/")}${i}`)}const ece=/^(?:(?:\/|~\/|\.\.?\/)[\p{L}\p{N}\p{M}\w.@+\-\u3000-\u303f\uff00-\uffef]+(?:\/[\p{L}\p{N}\p{M}\w.@+\- \u3000-\u303f\uff00-\uffef]*)*|[A-Za-z]:[\\/][\p{L}\p{N}\p{M}\w.@+\- \u3000-\u303f\uff00-\uffef]+(?:(?:\\|\/)[\p{L}\p{N}\p{M}\w.@+\- \u3000-\u303f\uff00-\uffef]*)*)$/u;function tce(e){return e.length<2||e.length>500?!1:ece.test(e)}function DC(e){return e.trim().toLowerCase().replace(/[^\p{L}\p{N}\p{M}\s\-_]/gu,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function Lu(e,t){if(!e)return e;if(NC.test(e))return e.startsWith("~/")?e:e.replace(/\\/g,"/");if(!t)return e;const a=`${t.replace(/\\/g,"/").replace(/\/+$/,"")}/${e.replace(/^\.\//,"")}`,i=a.split("/"),l=[];for(const u of i)!u||u==="."||(u===".."?l.pop():l.push(u));const c=l.join("/");return a.startsWith("/")?`/${c}`.replace(/^\/+/,"/"):c}function zk(e){const t=e.indexOf("#");return t<0?{path:e}:{path:e.slice(0,t),fragment:decodeURIComponent(e.slice(t+1))}}function qk(e,t){if(!e)return{kind:"passthrough"};const n=e.trim();if(!n||n==="#")return{kind:"passthrough"};if(n.startsWith("#")&&!n.startsWith("#mention:")&&!n.startsWith("#entity:"))return{kind:"fragment",id:decodeURIComponent(n.slice(1))};if(jC.test(n)||RC.test(n)){const{path:c,fragment:u}=zk(n);return{kind:"file",path:Lu(c,t),fragment:u}}if(/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(n))return/^https?:\/\//i.test(n)||/^mailto:/i.test(n)?{kind:"external",url:n}:/^file:\/\//i.test(n)?{kind:"file",path:Ub(n)}:{kind:"passthrough"};const a=zk(n),i=_C(a.path),l=a.fragment;return NC.test(i)?{kind:"file",path:Lu(i,t),fragment:l}:MC.test(i)?{kind:"file",path:Lu(i,t),fragment:l}:i&&Jle.test(i)&&!i.includes("://")?{kind:"file",path:Lu(i,t),fragment:l}:{kind:"passthrough"}}function nce(e,t){if(!e||!t)return!1;let n=null;try{n=e.querySelector(`#${CSS.escape(t)}`)}catch{n=null}if(n||(n=e.querySelector(`[id="${t.replace(/"/g,'\\"')}"]`)),!n){const a=e.querySelectorAll("h1,h2,h3,h4,h5,h6");for(const i of a)if(DC(i.textContent||"")===t||i.id===t){n=i;break}}return n?(n.scrollIntoView({behavior:"smooth",block:"start"}),!0):!1}function IC(e){return e.type==="text"?e.value??"":(e.children??[]).map(IC).join("")}function ace(){return e=>{const t=new Map,n=a=>{if(a.type==="element"&&a.tagName&&/^h[1-6]$/.test(a.tagName)){const i=IC(a).trim();let l=DC(i);if(l){const c=t.get(l)??0;t.set(l,c+1),c>0&&(l=`${l}-${c}`),a.properties={...a.properties??{},id:l}}}for(const i of a.children??[])n(i)};n(e)}}function $k(e,t){const n=/```[\s\S]*?```|`[^`\n]+`/g;let a=0,i="";for(const l of e.matchAll(n))i+=t(e.slice(a,l.index)),i+=l[0],a=l.index+l[0].length;return i+=t(e.slice(a)),i}function lpe(e){let t=e.replace(/\\\[([\s\S]*?)\\\]/g,(n,a)=>`$$${a}$$`);return t=t.replace(/\\\((.+?)\\\)/g,(n,a)=>`$${a}$`),t}function rce(e){return e.replace(/[$](?=[0-9])/g,(n,a,i)=>a>0&&i.charCodeAt(a-1)===92?n:"\\"+n)}const Pu="#mention:";function cpe(e,t){if(!t||t.length===0)return e.replace(/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu,(l,c,u)=>{const m=c??u;return`[@${m}](${Pu}${encodeURIComponent(m)})`});const n=[...t].sort((l,c)=>c.length-l.length);let a="",i=0;for(;i<e.length;){const l=e.indexOf("@",i);if(l<0){a+=e.slice(i);break}if(a+=e.slice(i,l),e[l+1]==="["){const g=e.indexOf("]",l+2);if(g>l+2){const h=e.slice(l+2,g);a+=`[@${h}](${Pu}${encodeURIComponent(h)})`,i=g+1;continue}}const c=e.slice(l+1),u=c.toLowerCase(),m=n.find(g=>u.startsWith(g.toLowerCase()));if(m){const g=c.slice(0,m.length);a+=`[@${g}](${Pu}${encodeURIComponent(g)})`,i=l+1+m.length;continue}const f=c.match(/^([\w\p{L}\p{N}]+)/u);if(f){const g=f[1];a+=`[@${g}](${Pu}${encodeURIComponent(g)})`,i=l+1+g.length;continue}a+="@",i=l+1}return a}const LC="#entity:",ice=new RegExp("(?<!\\[)(?<!\\()(?<!:)(?<!\\/)(?<!\\\\)\\b(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}\\b(?!\\]\\(#entity:)","gi"),sce=/`\[([^\]]+)\]\(#entity:((?:tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)`/gi;function PC(e,t){const n=e.slice(0,t),a=n.lastIndexOf("](");return a===-1?!1:n.indexOf(")",a+2)===-1}function dpe(e){return e.replace(sce,(t,n,a)=>`[${n}](${LC}${a})`)}function upe(e){return e.replace(ice,(t,n,a)=>PC(e,a)?t:`[${t}](${LC}${t})`)}const oce=["\\s","<",">","`","\\u4e00-\\u9fff","\\u3000-\\u303f","\\uff00-\\uffef"].join(""),OC=new RegExp(`https?://[^${oce}]+`,"gi"),lce=/(\*{1,3}|_{1,3}|~{1,2})$/;function cce(e,t,n){const a=n.match(lce);if(!a)return null;const i=a[1];return e.slice(Math.max(0,t-i.length),t)===i?i:null}const dce=/[.,;:!?\]\)"']+$/;function HC(e){return e.replace(dce,"")}function mpe(e){const t=[],n=new RegExp(OC.source,"gi");let a=0;for(let i=n.exec(e);i;i=n.exec(e)){const l=HC(i[0]);if(!l)continue;const c=i.index;c>a&&t.push({kind:"text",value:e.slice(a,c)}),t.push({kind:"link",value:l}),a=c+l.length}return a<e.length&&t.push({kind:"text",value:e.slice(a)}),t}function uce(e){return e.replace(OC,(t,n)=>{if(PC(e,n))return t;let a=HC(t);if(!a)return t;const i=cce(e,n,a);if(i&&(a=a.slice(0,a.length-i.length)),!a)return t;const l=t.slice(a.length);return/[()[\]]/.test(a)?t:`[${a}](${a})${l}`})}function mce(e){const t=e.trim();return t.startsWith("@startuml")&&t.endsWith("@enduml")}const pce={js:"JavaScript",javascript:"JavaScript",ts:"TypeScript",typescript:"TypeScript",tsx:"TSX",jsx:"JSX",py:"Python",python:"Python",rb:"Ruby",ruby:"Ruby",rs:"Rust",rust:"Rust",go:"Go",java:"Java",kotlin:"Kotlin",swift:"Swift",cpp:"C++",c:"C",cs:"C#",csharp:"C#",php:"PHP",sql:"SQL",sh:"Shell",bash:"Bash",zsh:"Zsh",shell:"Shell",html:"HTML",css:"CSS",scss:"SCSS",less:"LESS",json:"JSON",yaml:"YAML",yml:"YAML",xml:"XML",toml:"TOML",ini:"INI",md:"Markdown",markdown:"Markdown",dockerfile:"Dockerfile",docker:"Dockerfile",graphql:"GraphQL",gql:"GraphQL",lua:"Lua",perl:"Perl",r:"R",scala:"Scala",elixir:"Elixir",erlang:"Erlang",haskell:"Haskell",clojure:"Clojure",dart:"Dart",zig:"Zig",nim:"Nim",powershell:"PowerShell",ps1:"PowerShell",vue:"Vue",svelte:"Svelte",plaintext:"Text",text:"Text",txt:"Text"};function fce(e){return pce[e.toLowerCase()]??e.charAt(0).toUpperCase()+e.slice(1)}function hce(e){const t=e.match(/language-(\S+)/);return t?t[1]:null}const gce=24;function bce(e){const t=e.indexOf("_");return t<0?!1:e.length>=t+1+gce}const BC={tsk:{load:async()=>(await Se.tasks.list({lean:!0,pageSize:500})).tasks.map(e=>e.id)},req:{load:async()=>(await Se.requirements.list({lean:!0})).requirements.map(e=>e.id)},proj:{load:async()=>(await Se.projects.list()).projects.map(e=>e.id)},dlv:{load:async()=>(await Se.deliverables.search({limit:500})).results.map(e=>e.id)},agt:{load:async()=>(await Se.agents.list({lean:!0})).agents.map(e=>e.id)},team:{load:async()=>(await Se.teams.list()).teams.map(e=>e.id)}},R0=new Map,Fk=new Map;function yce(e){const t=BC[e];if(!t)return null;let n=R0.get(e);return n||(n=t.load().catch(a=>{throw R0.delete(e),a}),R0.set(e,n)),n}async function vce(e){if(!e)return null;const t=e.indexOf("_");if(t<0)return null;const n=e.slice(0,t);if(!BC[n])return null;if(bce(e))return e;const a=Fk.get(e);if(a!==void 0)return a;const i=(await yce(n)??[]).filter(c=>c.startsWith(e)),l=i.length===1?i[0]:null;return Fk.set(e,l),l}const xce=w.lazy(()=>fa(()=>import("./MarkdownMessage-B-9NMrYX.js"),[]).then(e=>({default:e.MarkdownMessage}))),wce={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},Uk={active:{color:"text-green-600 bg-green-500/10"},verified:{color:"text-blue-600 bg-blue-500/10"},outdated:{color:"text-fg-tertiary bg-surface-elevated/50"}};function kce({item:e,onClose:t,onOpenInPage:n}){const{t:a}=ut(["agent","common"]),i=wce[e.type]??{icon:"📎",color:"bg-surface-elevated text-fg-secondary"},l=Uk[e.status]??Uk.active,c=/^https?:\/\//i.test(e.reference??"");w.useEffect(()=>{const m=f=>{f.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]);const u=o.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:t,children:[o.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),o.jsxs("div",{className:"relative bg-surface-primary rounded-2xl shadow-2xl border border-border-default w-full max-w-lg max-h-[85vh] overflow-y-auto",onClick:m=>m.stopPropagation(),children:[o.jsxs("div",{className:"sticky top-0 bg-surface-primary/95 backdrop-blur-sm border-b border-border-default px-5 py-4 flex items-start gap-3 rounded-t-2xl z-10",children:[o.jsx("span",{className:`inline-flex items-center justify-center w-10 h-10 rounded-xl text-lg shrink-0 ${i.color}`,children:i.icon}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:e.title}),o.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[o.jsx("span",{className:`px-1.5 py-0.5 text-[10px] rounded font-medium ${l.color}`,children:e.status}),o.jsx("span",{className:"text-[10px] text-fg-tertiary",children:e.type}),e.format&&o.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-elevated rounded text-fg-secondary",children:e.format})]})]}),o.jsx("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors shrink-0 text-fg-tertiary hover:text-fg-primary",children:o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsxs("div",{className:"px-5 py-4 space-y-4",children:[e.summary&&e.summary.trim()!==e.title.trim()&&o.jsxs("div",{children:[o.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:a("agent:deliverables.summary")}),o.jsx("div",{className:"mt-1.5",children:o.jsx(w.Suspense,{fallback:o.jsx("p",{className:"text-sm text-fg-secondary",children:e.summary}),children:o.jsx(xce,{content:e.summary,className:"text-sm text-fg-secondary"})})})]}),e.reference&&o.jsxs("div",{children:[o.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:a("agent:deliverables.reference")}),o.jsxs("div",{className:"mt-1.5 flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[o.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all flex-1 select-all",children:e.reference}),c?o.jsx("button",{onClick:()=>window.open(e.reference,"_blank","noopener,noreferrer"),className:"px-2 py-1 text-[10px] rounded bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",children:a("common:open")}):o.jsx("button",{onClick:()=>{Se.files.reveal(e.reference).catch(()=>{})},className:"px-2 py-1 text-[10px] rounded bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",children:a("common:open")})]})]}),e.diffStats&&o.jsxs("div",{className:"flex items-center gap-3 text-xs bg-surface-elevated rounded-lg px-3 py-2",children:[o.jsxs("span",{className:"text-fg-tertiary font-medium",children:[a("agent:deliverables.diff"),":"]}),o.jsx("span",{className:"text-fg-secondary",children:a("agent:deliverables.fileCount",{count:e.diffStats.filesChanged})}),o.jsxs("span",{className:"text-green-500",children:["+",e.diffStats.additions]}),o.jsxs("span",{className:"text-red-500",children:["-",e.diffStats.deletions]})]}),e.testResults&&o.jsxs("div",{className:"flex items-center gap-3 text-xs bg-surface-elevated rounded-lg px-3 py-2",children:[o.jsxs("span",{className:"text-fg-tertiary font-medium",children:[a("deliverables:testResults.title"),":"]}),o.jsx("span",{className:"text-green-500",children:a("agent:deliverables.testsPassed",{n:e.testResults.passed})}),e.testResults.failed>0&&o.jsx("span",{className:"text-red-500",children:a("agent:deliverables.testsFailed",{n:e.testResults.failed})}),e.testResults.skipped>0&&o.jsx("span",{className:"text-fg-tertiary",children:a("agent:deliverables.testsSkipped",{n:e.testResults.skipped})})]}),e.tags.length>0&&o.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.tags.map(m=>o.jsx("span",{className:"px-2 py-0.5 text-[11px] bg-surface-elevated rounded-md text-fg-tertiary",children:m},m))}),o.jsxs("div",{className:"flex items-center gap-4 text-[10px] text-fg-tertiary flex-wrap pt-1 border-t border-border-default/50",children:[o.jsxs("span",{children:[a("agent:deliverables.created"),": ",new Date(e.createdAt).toLocaleString()]}),o.jsxs("span",{children:[a("agent:deliverables.updated"),": ",new Date(e.updatedAt).toLocaleString()]}),e.accessCount>0&&o.jsx("span",{children:a("agent:deliverables.accessed",{count:e.accessCount})})]})]}),o.jsxs("div",{className:"sticky bottom-0 bg-surface-primary/95 backdrop-blur-sm border-t border-border-default px-5 py-3 flex items-center justify-end gap-2 rounded-b-2xl",children:[o.jsxs("button",{onClick:()=>n(e.id),className:"px-3 py-1.5 text-xs font-medium text-brand-500 hover:bg-brand-500/10 rounded-lg transition-colors flex items-center gap-1.5",children:[o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),o.jsx("polyline",{points:"15 3 21 3 21 9"}),o.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),a("agent:deliverables.openInPage")]}),o.jsx("button",{onClick:t,className:"px-3 py-1.5 text-xs font-medium text-fg-secondary bg-surface-elevated hover:bg-surface-overlay rounded-lg transition-colors",children:a("common:close")})]})]})]});return typeof document<"u"?Jo.createPortal(u,document.body):u}const Gb=new Set;function _s(e){e&&Gb.add(e)}function Bg(e){e&&Gb.delete(e)}const Kb="markus:browser-history",zC=300;function zg(e){return`${e.kind}:${e.target}`}function $m(e,t){const n=(t||"").trim();return n?e!=="url"?!0:n!=="about:blank"&&n!=="about:newtab":!1}function qC(e){const t=(e||"").trim();return t?t.startsWith("//")?`https:${t}`:t:""}function Sce(e){return e.replace(/^[a-z][a-z0-9+.-]*:\/\//i,"")}function Vb(e){return(e||"").trim()}function $C(e){const t=(e.id||"").trim();if(t)return t;const n=`${e.reference||""}|${e.title||""}|${(e.summary||"").slice(0,48)}`;return n==="||"?"":n}function Cce(e){if(e.kind==="file"){const t=Vb(e.path||"");return $m("file",t)?{kind:"file",target:t,title:(e.title||"").trim()||void 0}:null}if(e.kind==="deliverable"){const t=e.deliverable;if(!t)return null;const n=$C(t);return $m("deliverable",n)?{kind:"deliverable",target:n,title:(t.title||"").trim()||void 0,location:(t.reference||"").trim()||void 0}:null}return null}function Ace(e){return e.kind==="url"?Sce(e.target):e.kind==="deliverable"&&e.location||e.target}function Gk(e){return typeof e=="string"&&e.trim()?e:void 0}function Tce(e){if(!e||typeof e!="object")return null;const t=e,n=t.kind==="file"||t.kind==="deliverable"?t.kind:"url",a=typeof t.target=="string"?t.target:n==="url"&&typeof t.url=="string"?t.url:"",i=n==="url"?qC(a):Vb(a);return $m(n,i)?{kind:n,target:i,title:Gk(t.title),location:n==="deliverable"?Gk(t.location):void 0,visitedAt:typeof t.visitedAt=="number"&&Number.isFinite(t.visitedAt)?t.visitedAt:0,visitCount:typeof t.visitCount=="number"&&t.visitCount>0?t.visitCount:1}:null}function Wb(){try{const e=localStorage.getItem(Kb);if(!e)return[];const t=JSON.parse(e);if(!Array.isArray(t))return[];const n=[];for(const a of t){const i=Tce(a);i&&n.push(i)}return n}catch{return[]}}function Yb(e){try{localStorage.setItem(Kb,JSON.stringify(e.slice(0,zC)))}catch{}}function Qb(){return Wb().sort((e,t)=>t.visitedAt-e.visitedAt)}const qg=new Set;function Jb(e){for(const t of qg)try{t(e)}catch{}}function ppe(e){qg.add(e);const t=n=>{n.key!==null&&n.key!==Kb||e(Qb())};return typeof window<"u"&&window.addEventListener("storage",t),()=>{qg.delete(e),typeof window<"u"&&window.removeEventListener("storage",t)}}function FC(e,t=Date.now()){const n=e.kind==="url"?qC(e.target):Vb(e.target);if(!$m(e.kind,n))return Qb();const a=`${e.kind}:${n}`,i=Wb(),l=i.find(m=>zg(m)===a),c=i.filter(m=>zg(m)!==a),u=[{kind:e.kind,target:n,title:(e.title||"").trim()||l?.title,location:(e.location||"").trim()||l?.location,visitedAt:t,visitCount:(l?.visitCount??0)+1},...c].sort((m,f)=>f.visitedAt-m.visitedAt).slice(0,zC);return Yb(u),Jb(u),u}function fpe(e,t,n=Date.now()){return FC({kind:"url",target:e,title:t},n)}function hpe(e){const t=Wb().filter(n=>zg(n)!==e);return Yb(t),Jb(t),t}function gpe(){return Yb([]),Jb([]),[]}function bpe(e,t=8){const n=Qb(),a=(e||"").trim().toLowerCase();if(!a)return n.slice(0,t);const i=a.split(/\s+/).filter(Boolean),l=[];for(const c of n){const u=c.target.toLowerCase(),m=(c.title||"").toLowerCase(),f=Ace(c).toLowerCase(),g=`${f} ${m}`;let h=0,b=!0;for(const k of i){if(!g.includes(k)){b=!1;break}f.startsWith(k)?h+=120:u.startsWith(k)?h+=100:new RegExp(`(^|[./:?&=_-])${Ece(k)}`).test(f)?h+=60:m.startsWith(k)?h+=50:h+=20}if(!b)continue;const y=Math.max(0,(Date.now()-c.visitedAt)/864e5);h+=Math.max(0,30-y*2),h+=Math.min(30,c.visitCount*3),l.push({entry:c,score:h})}return l.sort((c,u)=>u.score-c.score||u.entry.visitedAt-c.entry.visitedAt).slice(0,t).map(c=>c.entry)}function Ece(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ype(e){if(!e.ctrlKey||e.metaKey||e.altKey)return null;const t=(e.key||"").toLowerCase();return t==="n"?"next":t==="p"?"prev":null}function vpe(e,t,n){return t<=0?-1:e<0?n==="next"?0:t-1:(e+(n==="next"?1:-1)+t)%t}const UC="markus_right_panel_v1",Nce=10,$g=new Map;function Mce(e,t=3e3){$g.set(e,Date.now()+t)}function jce(e){const t=$g.get(e);return t==null?!1:Date.now()>t?($g.delete(e),!1):!0}function Rce(e){return e.kind==="terminal"}function sc(e){return e.kind==="file"?`file:${e.path}`:e.kind==="url"?`url:${e.browserId||e.url}`:e.kind==="terminal"?`terminal:${e.terminalId}`:`deliverable:${$C(e.deliverable)||"unknown"}`}function Kk(e){return e.kind==="deliverable"?e.deliverable.title||e.deliverable.reference||"Deliverable":e.kind==="url"?e.title||e.url:e.kind==="terminal"?e.title||"Terminal":e.title||e.path.split(/[/\\]/).pop()||e.path}function Qi(){return`tab_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function Ou(e){let t=e;for(;t.length>Nce;){let n=-1;for(let i=t.length-1;i>=0;i--)if(!t[i].pinned){n=i;break}if(n<0)break;const a=t[n];a&&(Fg(a.payload),Ug(a.payload)),t=t.filter((i,l)=>l!==n)}return t}function Fg(e){e?.kind==="url"&&e.browserId&&(Mce(e.browserId),window.markusDesktop?.browser?.destroy(e.browserId))}function Ug(e){e?.kind==="terminal"&&e.terminalId&&(Bg(e.terminalId),window.markusDesktop?.terminal?.destroy(e.terminalId))}function _ce(e){const t=e.payload;return t.kind==="terminal"?null:t.kind==="url"?Nc(t.url||"")||Nc(t.title||"")?null:{id:e.id,title:e.title,pinned:e.pinned,payload:{kind:"url",url:t.url||"about:blank",title:t.title||e.title}}:t.kind==="file"?{id:e.id,title:e.title,pinned:e.pinned,payload:{kind:"file",path:t.path,title:t.title}}:{id:e.id,title:e.title,pinned:e.pinned,payload:{kind:"deliverable",deliverable:t.deliverable}}}function Dce(e,t=0){if(e.payload.kind==="url"){const n=`eb_${Date.now().toString(36)}_${t.toString(36)}_${Math.random().toString(36).slice(2,7)}`;return{...e,payload:{kind:"url",url:e.payload.url||"about:blank",title:e.payload.title||e.title,browserId:n}}}return e}function Ice(){try{const e=localStorage.getItem(UC);if(!e)return null;const t=JSON.parse(e);return!t||t.mode!=="browser"&&t.mode!=="terminal"||!Array.isArray(t.browserTabs)?null:t}catch{return null}}function Lce(){const e={mode:"browser",browserTabs:[],browserActiveId:null,terminalTabs:[],terminalActiveId:null,stashedBrowserTabs:[],stashedBrowserActiveId:null,stashedTerminalTabs:[],stashedTerminalActiveId:null},t=Ice();if(!t)return e;const n=t.browserTabs.map((y,k)=>{try{return Dce(y,k)}catch{return null}}).filter(y=>!(!y||y.payload.kind==="terminal"||y.payload.kind==="url"&&Nc(y.payload.url||""))),a=n.some(y=>y.id===t.browserActiveId)?t.browserActiveId:n[0]?.id??null,i=(t.terminalTabs||[]).map((y,k)=>{const C=`term_${Date.now().toString(36)}_${k.toString(36)}_${Math.random().toString(36).slice(2,7)}`;return _s(C),{id:y.id||Qi(),title:y.title||"Terminal",payload:{kind:"terminal",terminalId:C,title:y.title||"Terminal",cwd:y.cwd}}}),l=i.some(y=>y.id===t.terminalActiveId)?t.terminalActiveId:i[0]?.id??null,c=!!t.browserCollapsed&&n.length>0,u=!!t.terminalCollapsed&&i.length>0,m=c?[]:n,f=c?null:a,g=u?[]:i,h=u?null:l;let b=t.mode;return b==="terminal"&&g.length===0&&!u&&(b="browser"),b==="browser"&&m.length===0&&g.length>0&&(b="terminal"),{mode:b,browserTabs:m,browserActiveId:f,terminalTabs:g,terminalActiveId:h,stashedBrowserTabs:n,stashedBrowserActiveId:a,stashedTerminalTabs:i,stashedTerminalActiveId:l}}const GC=w.createContext(null);function Pce({children:e}){const[t,n]=w.useState(()=>{try{return localStorage.getItem("markus_sidebar_c")==="1"}catch{return!1}}),a=w.useMemo(()=>Lce(),[]),[i,l]=w.useState(a.mode),[c,u]=w.useState(a.browserTabs),[m,f]=w.useState(a.terminalTabs),[g,h]=w.useState(a.browserActiveId),[b,y]=w.useState(a.terminalActiveId),[k,C]=w.useState(!1),[T,A]=w.useState(!1),[M,I]=w.useState("l0"),[B,G]=w.useState(null),j=w.useCallback(xe=>I(xe),[]),O=w.useCallback(xe=>G(xe),[]);w.useEffect(()=>{const xe=Ie=>{if(!(Ie instanceof HTMLElement))return!1;const ne=Ie.tagName;return ne==="INPUT"||ne==="TEXTAREA"||ne==="SELECT"?!0:Ie.isContentEditable},Me=Ie=>{if(!(Ie.target instanceof Element))return;const ne=document.activeElement;if(xe(ne)){const Ce=ne===Ie.target||ne.contains(Ie.target),Pe=!!Ie.target.closest("[data-keep-edit-focus]"),$e=xe(Ie.target)||!!Ie.target.closest('input, textarea, select, [contenteditable="true"]'),ue=!!Ie.target.closest(".xterm");!Ce&&!Pe&&!$e&&!ue&&ne.blur()}const U=Ie.target.closest("[data-keyboard-pane]");if(!U)return;const re=U.getAttribute("data-keyboard-pane");if(!(re!=="l0"&&re!=="l1"&&re!=="l2"&&re!=="content")&&(I(re),re==="l0")){const Pe=Ie.target.closest("[data-l0-page-id]")?.getAttribute("data-l0-page-id");Pe&&G(Pe)}};return document.addEventListener("pointerdown",Me,!0),()=>document.removeEventListener("pointerdown",Me,!0)},[]);const F=w.useRef(a.stashedBrowserTabs.length>0?a.stashedBrowserTabs:a.browserTabs),Y=w.useRef(a.stashedBrowserActiveId??a.browserActiveId),q=w.useRef(a.stashedTerminalTabs.length>0?a.stashedTerminalTabs:a.terminalTabs),V=w.useRef(a.stashedTerminalActiveId??a.terminalActiveId),z=w.useRef(a.browserActiveId),J=w.useRef(a.terminalActiveId),D=w.useRef(a.browserTabs),ee=w.useRef(a.terminalTabs),R=w.useRef(a.mode);z.current=g,J.current=b,D.current=c,ee.current=m,R.current=i,w.useEffect(()=>{(a.mode==="terminal"||a.browserTabs.length===0)&&window.markusDesktop?.browser?.hideAll?.()},[]),w.useEffect(()=>{const xe=c.length===0&&F.current.length>0,Me=m.length===0&&q.current.length>0,Ie=xe?F.current:c,ne=Me?q.current:m,U=Ie.map(_ce).filter(Pe=>!!Pe),re=ne.filter(Pe=>Pe.payload.kind==="terminal").map(Pe=>({id:Pe.id,title:Pe.title,cwd:Pe.payload.kind==="terminal"?Pe.payload.cwd:void 0})),Ce={mode:i,browserTabs:U,browserActiveId:xe?Y.current:g,terminalTabs:re,terminalActiveId:Me?V.current:b,browserCollapsed:xe,terminalCollapsed:Me};try{localStorage.setItem(UC,JSON.stringify(Ce))}catch{}},[i,c,g,m,b]);const te=w.useCallback(xe=>n(xe),[]),le=w.useCallback(()=>n(xe=>!xe),[]),ke=w.useCallback(()=>{window.markusDesktop?.browser?.hideAll?.()},[]),$=w.useCallback(xe=>{l(Me=>Me===xe?Me:(xe==="terminal"&&ke(),xe))},[ke]),W=w.useCallback(xe=>{if(xe==="terminal"){if(ke(),l("terminal"),n(!0),m.length>0)return;if(q.current.length>0){const Pe=q.current,$e=V.current&&Pe.some(ue=>ue.id===V.current)?V.current:Pe[0].id;f(Pe),y($e),V.current=$e;return}const U=Qi(),re=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;_s(re);const Ce={id:U,title:"Terminal",payload:{kind:"terminal",terminalId:re,title:"Terminal"}};q.current=[Ce],f([Ce]),y(Ce.id),V.current=Ce.id;return}if(l("browser"),n(!0),c.length>0)return;if(F.current.length>0){const U=F.current,re=Y.current&&U.some(Ce=>Ce.id===Y.current)?Y.current:U[0].id;u(U),h(re),Y.current=re;return}const Me=Qi(),Ie=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,ne={id:Me,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:Ie}};F.current=[ne],u([ne]),h(ne.id),Y.current=ne.id},[c.length,m.length,ke]),oe=w.useCallback(xe=>{const Me=sc(xe),Ie=Qi(),ne=Rce(xe),U=Cce(xe);if(U&&FC(U),ne){xe.kind==="terminal"&&_s(xe.terminalId),l("terminal"),ke();const re=ee.current,Ce=re.find(ue=>sc(ue.payload)===Me)??q.current.find(ue=>sc(ue.payload)===Me);let Pe,$e;if(Ce)$e=Ce.id,Pe=re.some(ue=>ue.id===Ce.id)?re:Ou([Ce,...re]);else{const ue={id:Ie,title:Kk(xe),payload:xe};Pe=Ou([ue,...re]),$e=Ie}q.current=Pe,ee.current=Pe,f(Pe),y($e),V.current=$e,J.current=$e}else{l("browser");const re=D.current,Ce=re.find(ue=>sc(ue.payload)===Me)??F.current.find(ue=>sc(ue.payload)===Me);let Pe,$e;if(Ce)$e=Ce.id,Pe=re.some(ue=>ue.id===Ce.id)?re:Ou([Ce,...re]);else{const ue={id:Ie,title:Kk(xe),payload:xe};Pe=Ou([ue,...re]),$e=Ie}F.current=Pe,D.current=Pe,u(Pe),h($e),Y.current=$e,z.current=$e}n(!0)},[ke]),L=w.useCallback(xe=>{const Me=D.current,Ie=Me.findIndex(he=>he.id===xe);if(Ie>=0){const he=Me[Ie]?.payload,Ve=Me.filter(Ft=>Ft.id!==xe),dt=z.current,ot=(Me.some(Ft=>Ft.id===dt)?dt:Me[0]?.id??null)===xe||Ve.length===0?Ve[Math.min(Ie,Ve.length-1)]?.id??null:void 0;F.current=Ve,D.current=Ve,u(Ve),Ve.length===0&&R.current==="browser"&&C(!1),ot!==void 0&&(h(ot),Y.current=ot,z.current=ot),Fg(he);return}const ne=ee.current,U=ne.findIndex(he=>he.id===xe);if(U<0)return;const re=ne[U]?.payload,Ce=ne.filter(he=>he.id!==xe),Pe=J.current,ue=(ne.some(he=>he.id===Pe)?Pe:ne[0]?.id??null)===xe||Ce.length===0?Ce[Math.min(U,Ce.length-1)]?.id??null:void 0;q.current=Ce,ee.current=Ce,f(Ce),Ce.length===0&&R.current==="terminal"&&C(!1),ue!==void 0&&(y(ue),V.current=ue,J.current=ue),Ug(re)},[]),Ne=w.useCallback(()=>{const xe=D.current.map(Ie=>Ie.payload),Me=ee.current.map(Ie=>Ie.payload);D.current=[],ee.current=[],F.current=[],Y.current=null,q.current=[],V.current=null,z.current=null,J.current=null,u([]),f([]),h(null),y(null),C(!1);for(const Ie of xe)Fg(Ie);for(const Ie of Me)Ug(Ie)},[]),qe=w.useCallback(xe=>{R.current==="terminal"?(y(xe),V.current=xe):(h(xe),Y.current=xe)},[]),me=w.useCallback((xe,Me)=>{u(Ie=>{let ne=!1;const U=Ie.map(re=>{if(re.payload.kind!=="url"||re.payload.browserId!==xe)return re;const Ce=Me.url??re.payload.url,Pe=Me.title||re.payload.title||Ce,$e=Me.pageId??re.payload.pageId;return Ce===re.payload.url&&Pe===(re.payload.title||re.title)&&$e===re.payload.pageId&&Pe===re.title?re:(ne=!0,{...re,title:Pe,payload:{...re.payload,url:Ce,title:Pe,...$e!=null?{pageId:$e}:{}}})});return ne&&(F.current=U),ne?U:Ie})},[]),ze=w.useCallback((xe,Me)=>{f(Ie=>{let ne=!1;const U=Ie.map(re=>{if(re.payload.kind!=="terminal"||re.payload.terminalId!==xe)return re;const Ce=Me.title||re.payload.title||re.title,Pe=Me.cwd??re.payload.cwd;return Ce===re.title&&Pe===re.payload.cwd&&Ce===(re.payload.title||re.title)?re:(ne=!0,{...re,title:Ce,payload:{...re.payload,title:Ce,...Pe!=null?{cwd:Pe}:{}}})});return ne&&(q.current=U),ne?U:Ie})},[]),Ue=w.useCallback(()=>{R.current==="terminal"?(f(xe=>xe.length===0?xe:(q.current=xe,J.current&&(V.current=J.current),[])),y(null)):(u(xe=>xe.length===0?xe:(F.current=xe,z.current&&(Y.current=z.current),[])),h(null),ke()),C(!1)},[ke]),je=w.useCallback(()=>{if(R.current==="terminal"&&m.length>0){if(l("browser"),c.length>0){n(!0);return}if(F.current.length>0){const $e=F.current,ue=Y.current&&$e.some(he=>he.id===Y.current)?Y.current:$e[0].id;u($e),h(ue),Y.current=ue,n(!0);return}const re=Qi(),Ce=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,Pe={id:re,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:Ce}};F.current=[Pe],u([Pe]),h(Pe.id),Y.current=Pe.id,n(!0);return}const xe=Qi(),Me=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;let Ie,ne=!1,U=!1;l("browser"),u(re=>{if(re.length>0)return F.current=re,z.current&&(Y.current=z.current),U=!0,Ie=null,[];if(F.current.length>0){ne=!0;const Pe=F.current;return Ie=Y.current&&Pe.some(ue=>ue.id===Y.current)?Y.current:Pe[0].id,Pe}ne=!0;const Ce={id:xe,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:Me}};return F.current=[Ce],Ie=Ce.id,[Ce]}),ne&&n(!0),U?(h(null),C(!1),ke()):Ie!=null&&(h(Ie),Y.current=Ie)},[c.length,m.length,ke]),Ye=w.useCallback(()=>{if(R.current==="browser"&&c.length>0){if(l("terminal"),ke(),m.length>0){n(!0);return}if(q.current.length>0){const $e=q.current,ue=V.current&&$e.some(he=>he.id===V.current)?V.current:$e[0].id;f($e),y(ue),V.current=ue,n(!0);return}const re=Qi(),Ce=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;_s(Ce);const Pe={id:re,title:"Terminal",payload:{kind:"terminal",terminalId:Ce,title:"Terminal"}};q.current=[Pe],f([Pe]),y(Pe.id),V.current=Pe.id,n(!0);return}const xe=Qi(),Me=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;_s(Me);let Ie,ne=!1,U=!1;l("terminal"),ke(),f(re=>{if(re.length>0)return q.current=re,J.current&&(V.current=J.current),U=!0,Ie=null,[];if(q.current.length>0){ne=!0;const Pe=q.current;return Ie=V.current&&Pe.some(ue=>ue.id===V.current)?V.current:Pe[0].id,Pe}ne=!0;const Ce={id:xe,title:"Terminal",payload:{kind:"terminal",terminalId:Me,title:"Terminal"}};return q.current=[Ce],Ie=Ce.id,[Ce]}),ne&&n(!0),U?(y(null),C(!1)):Ie!=null&&(y(Ie),V.current=Ie)},[c.length,m.length,ke]),xt=w.useCallback(xe=>{const Me=R.current==="terminal"?m:c;if(Me.length<2)return;const Ie=R.current==="terminal"?J.current:z.current,U=(Math.max(0,Me.findIndex(Ce=>Ce.id===Ie))+xe+Me.length)%Me.length,re=Me[U].id;R.current==="terminal"?(y(re),V.current=re):(h(re),Y.current=re)},[c,m]),mt=w.useCallback(xe=>{const Ie=(R.current==="terminal"?m:c)[xe];Ie&&(R.current==="terminal"?(y(Ie.id),V.current=Ie.id):(h(Ie.id),Y.current=Ie.id))},[c,m]),ft=w.useCallback(()=>{if(R.current==="terminal"){const Me=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;oe({kind:"terminal",terminalId:Me,title:"Terminal"});return}const xe=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;oe({kind:"url",url:"about:blank",title:"New Tab",browserId:xe})},[oe]),rt=w.useCallback(xe=>{const Me=ee.current,Ie=Me.findIndex($e=>$e.payload.kind==="terminal"&&$e.payload.terminalId===xe);if(Ie<0){Bg(xe),window.markusDesktop?.terminal?.destroy(xe);return}const ne=Me[Ie];if(Me.length>1){L(ne.id);return}Bg(xe),window.markusDesktop?.terminal?.destroy(xe);const U=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;_s(U);const re=ne.payload.kind==="terminal"&&(ne.payload.title||ne.title)||"Terminal",Ce=ne.payload.kind==="terminal"?ne.payload.cwd:void 0,Pe={id:ne.id,title:re,payload:{kind:"terminal",terminalId:U,title:re,cwd:Ce}};q.current=[Pe],f([Pe]),y(Pe.id),V.current=Pe.id,R.current!=="terminal"&&l("terminal")},[L]),jt=w.useCallback(xe=>C(xe),[]),ht=w.useCallback(()=>C(xe=>!xe),[]),He=i==="terminal"?m:c,Et=i==="terminal"?b:g,Kt=He.find(xe=>xe.id===Et)??He[0]??null,ie=Kt?.payload??null,tt=He.length>0,it=w.useMemo(()=>({leftCollapsed:t,setLeftCollapsed:te,toggleLeftCollapsed:le,keyboardPane:M,setKeyboardPane:j,l0FocusPageId:B,setL0FocusPageId:O,rightPanelMode:i,setRightPanelMode:$,switchRightPanelMode:W,rightPanel:ie,rightPanelOpen:tt,rightPanelTabs:He,activeRightPanelTabId:Kt?.id??null,openRightPanel:oe,closeRightPanel:Ne,closeRightPanelTab:L,setActiveRightPanelTab:qe,updateRightPanelBrowserTab:me,updateRightPanelTerminalTab:ze,toggleRightPanel:je,toggleTerminalPanel:Ye,collapseRightPanelOnly:Ue,cycleRightPanelTab:xt,activateRightPanelTabAt:mt,openNewRightPanelTab:ft,handleTerminalExit:rt,rightPanelFullscreen:k,setRightPanelFullscreen:jt,toggleRightPanelFullscreen:ht,hostAvailable:T,setHostAvailable:A}),[t,te,le,M,j,B,O,i,$,W,ie,tt,He,Kt,oe,Ne,L,qe,me,ze,je,Ye,Ue,xt,mt,ft,rt,k,jt,ht,T]);return o.jsx(GC.Provider,{value:it,children:e})}function kp(){return w.useContext(GC)}const Oce={tsk:"task",req:"requirement",proj:"project",dlv:"deliverable",agt:"agent",team:"team"};function KC(e){return{task:"task",requirement:"requirement",project:"project",deliverable:"deliverable",agent:"agent",team:"team"}[e]}const VC={task:"☑️",requirement:"🎯",project:"📁",deliverable:"📦",agent:"🤖",team:"👥"},WC={task:"Task",requirement:"Requirement",project:"Project",deliverable:"Deliverable",agent:"Agent",team:"Team"},Hce=/^(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}$/i;function Fm(e){return Hce.test(e.trim())}function Bce(e){const t=e.split("_")[0]?.toLowerCase();return t?Oce[t]:void 0}async function YC(e){const t=await vce(e)??e;t.startsWith("tsk_")?yt.navigate(ce.WORK,{openTask:t}):t.startsWith("req_")?yt.navigate(ce.WORK,{openRequirement:t}):t.startsWith("proj_")?yt.navigate(ce.WORK,{projectId:t}):t.startsWith("dlv_")?yt.navigate(ce.DELIVERABLES,{openDeliverable:t}):t.startsWith("agt_")?yt.navigate(ce.TEAM,{agentId:t}):t.startsWith("team_")&&yt.navigate(ce.TEAM,{selectTeam:t})}const rm=new Map,Hu=new Map,im=new Map;function zce(e,t){const n=im.get(e)??new Set;return n.add(t),im.set(e,n),()=>{n.delete(t),n.size===0&&im.delete(e)}}function qce(e){rm.delete(e);for(const t of im.get(e)??[])t()}const $ce=["task:update","task:create","requirement:update","requirement:updated","deliverable:update","deliverable:updated","project:update","team:update"];function Fce(e){const t=e?.payload??{};for(const n of["taskId","requirementId","deliverableId","projectId","teamId","id"]){const a=t[n];if(typeof a=="string")return a}for(const n of["requirement","deliverable","task","project","team"]){const a=t[n];if(a&&typeof a.id=="string")return a.id}}let Vk=!1;function Uce(){if(Vk)return;Vk=!0;const e=t=>{const n=Fce(t);n&&qce(n)};for(const t of $ce)try{di.on(t,e)}catch{}}async function Gce(e,t){const n={id:e,type:t,title:e,loading:!1};try{switch(t){case"task":{const a=await Se.tasks.get(e);return{...n,title:a.task.title,status:a.task.status,blockedReason:a.task.blockedReason??null}}case"requirement":{const a=await Se.requirements.get(e),i=a.requirement;return{...n,title:a.requirement.title,status:a.requirement.status,blockedReason:i.blockedReason??null}}case"project":{const a=await Se.projects.get(e);return{...n,title:a.project.name,status:a.project.status,summary:a.project.description}}case"deliverable":{const a=await Se.deliverables.get(e);return{...n,title:a.deliverable.title,status:a.deliverable.status,summary:a.deliverable.summary,deliverable:a.deliverable}}case"agent":{const a=await Se.agents.get(e);return{...n,title:a.name,summary:a.role}}case"team":{const i=(await Se.teams.list()).teams.find(l=>l.id===e);return{...n,title:i?.name??e,notFound:!i}}}}catch{}return{...n,notFound:!0}}function QC(e,t){const n=t??Bce(e),[a,i]=w.useState(()=>rm.get(e)??{id:e,type:n??"task",title:e,loading:!!n});return w.useEffect(()=>{if(!n){i({id:e,type:"task",title:e,loading:!1,notFound:!0});return}let l=!0;const c=m=>{const f=m?rm.get(e):void 0;if(f){i(f);return}m&&i(h=>({...h,type:n,loading:!0}));let g=Hu.get(e);g||(g=Gce(e,n),Hu.set(e,g)),g.then(h=>{rm.set(e,h),Hu.delete(e),l&&i(h)}).catch(()=>{Hu.delete(e),l&&i({id:e,type:n,title:e,loading:!1,notFound:!0})})};c(!0),Uce();const u=zce(e,()=>c(!1));return()=>{l=!1,u()}},[e,n]),a}function JC(e){const t=(e.split("_")[0]?.length??3)+1;return e.length>t+8?`${e.slice(0,t+8)}…`:e}function wc({id:e,type:t,label:n}){const a=QC(e,t),i=kp(),l=VC[a.type]??"🔗",c=n??(a.loading||a.notFound?JC(e):a.title),u=m=>{if(m.preventDefault(),m.stopPropagation(),a.type==="deliverable"&&a.deliverable&&i?.hostAvailable){i.openRightPanel({kind:"deliverable",deliverable:a.deliverable});return}YC(e)};return o.jsxs("span",{"data-entity-link":e,className:"inline-flex items-center gap-0.5 px-1 py-0.5 rounded bg-brand-500/10 text-brand-500 text-xs font-medium cursor-pointer hover:bg-brand-500/20 transition-colors align-baseline",onClick:u,title:`${WC[a.type]}: ${a.notFound?e:a.title} (${e})`,children:[o.jsx("span",{className:"text-[10px]",children:l}),o.jsx("span",{className:"truncate max-w-[240px] align-baseline",children:c})]})}function Kce({id:e,type:t,label:n}){const{t:a}=ut(["common"]),i=QC(e,t),[l,c]=w.useState(!1),u=kp(),m=VC[i.type]??"🔗",f=()=>{if(i.type==="deliverable"&&i.deliverable){if(u?.hostAvailable){u.openRightPanel({kind:"deliverable",deliverable:i.deliverable});return}c(!0);return}YC(e)},g=i.loading?JC(e):n||(i.notFound?e:i.title);return o.jsxs("span",{className:"not-prose block my-2",children:[o.jsxs("button",{type:"button",onClick:f,className:"w-full max-w-md text-left rounded-xl border border-border-default bg-surface-elevated/30 hover:border-brand-500/40 hover:bg-surface-elevated/50 transition-colors px-3 py-2.5 flex items-start gap-2.5",children:[o.jsx("span",{className:"inline-flex items-center justify-center w-8 h-8 rounded-lg text-sm shrink-0 bg-brand-500/10",children:m}),o.jsxs("span",{className:"flex-1 min-w-0 block",children:[o.jsxs("span",{className:"flex items-center gap-2 flex-wrap",children:[o.jsx("span",{className:"text-[10px] uppercase tracking-wide text-fg-tertiary font-medium",children:WC[i.type]}),i.status&&(()=>{const h=i.type==="task"||i.type==="requirement"?OS(i.status,a,i.blockedReason):null;return o.jsx("span",{"data-testid":"entity-status","data-status":i.status,className:`px-1.5 py-0.5 text-[10px] rounded font-medium ${h?.tone?.chip??An[cJ(i.type,i.status)].chip}`,children:h?.label??i.status})})()]}),o.jsx("span",{className:`block text-sm font-medium truncate mt-0.5 ${i.notFound?"font-mono text-fg-tertiary":"text-fg-primary"}`,children:g}),i.summary&&i.summary.trim()!==i.title.trim()&&o.jsx("span",{className:"block text-xs text-fg-tertiary mt-0.5 line-clamp-1",children:i.summary})]}),o.jsx("svg",{className:"w-4 h-4 text-fg-tertiary shrink-0 mt-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),l&&i.deliverable&&o.jsx(kce,{item:i.deliverable,onClose:()=>c(!1),onOpenInPage:h=>{c(!1),yt.navigate(ce.DELIVERABLES,{openDeliverable:h})}})]})}function Vce(e){return e==null||!Number.isFinite(e)?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Wce(e){if((e.includes("\\")?"\\":"/")==="/")return{segments:e.split("/").filter(Boolean),root:"/"};const n=e.match(/^([A-Za-z]:\\)(.*)$/);return n?{segments:n[2].split("\\").filter(Boolean),root:n[1]}:{segments:e.split("\\").filter(Boolean),root:""}}function Yce(e,t,n){if(t.length===0)return e||".";const a=t.join(n);return n==="/"?e==="/"?`/${a}`:`${e}${a}`:`${e}${a}`}const Wk={md:"MD",markdown:"MD",html:"HTML",htm:"HTML",json:"JSON",csv:"CSV",pdf:"PDF",docx:"DOCX",doc:"DOC",xlsx:"XLSX",xls:"XLS",pptx:"PPTX",ppt:"PPT",txt:"TXT",ts:"TS",tsx:"TSX",js:"JS",jsx:"JSX",py:"PY",css:"CSS"},Gg={png:"IMG",jpg:"IMG",jpeg:"IMG",gif:"IMG",webp:"IMG",svg:"IMG",bmp:"IMG",ico:"IMG",avif:"IMG",mp3:"AUDIO",wav:"AUDIO",ogg:"AUDIO",flac:"AUDIO",aac:"AUDIO",m4a:"AUDIO",mp4:"VIDEO",webm:"VIDEO",mov:"VIDEO",mkv:"VIDEO",avi:"VIDEO",m4v:"VIDEO"};function Qce(e,t=!1){if(t)return tn.t("home:recentDeliverables.directory");if(!e)return tn.t("home:recentDeliverables.file");const n=e.replace(/^\./,"").toLowerCase();return Gg[n]?Gg[n]:Wk[n]?Wk[n]:n.slice(0,6).toUpperCase()||tn.t("home:recentDeliverables.file")}function Jce({path:e,entries:t,onNavigate:n,onOpenFile:a,onReveal:i,onCopyPath:l,emptyText:c}){const{t:u}=ut(["common"]),{segments:m,root:f}=w.useMemo(()=>Wce(e),[e]),g=e.includes("\\")?"\\":"/",[h,b]=w.useState(!1),y=async()=>{const C=l?.(e);try{if(C&&typeof C.then=="function"&&await C===!1)return}catch{return}b(!0),window.setTimeout(()=>b(!1),2e3)},k=w.useMemo(()=>{const C=[];f&&C.push({label:f.replace(/[\\/]$/,""),path:f});let T=f;for(let A=0;A<m.length;A++)T=Yce(f,m.slice(0,A+1),g),C.push({label:m[A],path:T});return C},[f,m,g]);return o.jsxs("div",{className:"flex flex-col min-h-0 h-full",children:[(i||l)&&o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border-subtle bg-surface-secondary/50 shrink-0","data-testid":"dir-top-actions",children:[o.jsx("span",{className:"flex-1 min-w-0 text-[11px] font-mono text-fg-tertiary truncate",title:e,children:e}),l&&o.jsx("button",{className:`shrink-0 text-[11px] cursor-pointer transition-colors ${h?"text-green-500 font-medium":"text-fg-secondary hover:text-fg-primary hover:underline"}`,onClick:()=>{y()},title:u(h?"common:ambassador.copied":"common:copyPath"),children:h?`✓ ${u("common:ambassador.copied")}`:u("common:copyPath")}),i&&o.jsx("button",{className:"shrink-0 text-[11px] text-fg-secondary hover:text-fg-primary hover:underline cursor-pointer",onClick:()=>i(e),children:u("common:revealInFileBrowser")})]}),o.jsx("div",{className:"flex items-center gap-1 flex-wrap px-3 py-2 border-b border-border-subtle bg-surface-secondary/50 text-xs shrink-0","data-testid":"dir-breadcrumb",children:k.map((C,T)=>{const A=T===k.length-1;return o.jsxs("span",{className:"flex items-center gap-1 min-w-0",children:[T>0&&o.jsx("span",{className:"text-fg-tertiary select-none",children:"/"}),A?o.jsx("span",{className:"text-fg-primary font-medium truncate max-w-[180px]",children:C.label}):o.jsx("button",{className:"text-fg-secondary hover:text-brand-500 hover:underline truncate max-w-[140px] cursor-pointer",onClick:()=>n(C.path),title:C.path,children:C.label})]},C.path)})}),o.jsx("div",{className:"flex-1 overflow-y-auto py-1",children:t.length===0?o.jsx("p",{className:"px-4 py-8 text-center text-xs text-fg-tertiary",children:c??u("common:emptyDirectory")}):t.map(C=>{const T=C.isDirectory?void 0:Qce(C.ext),A=!!C.ext&&!!Gg[C.ext.replace(/^\./,"").toLowerCase()];return o.jsxs("button",{className:"w-full flex items-center gap-2.5 px-3 py-1.5 text-left hover:bg-surface-overlay/60 transition-colors cursor-pointer group",onClick:()=>C.isDirectory?n(C.path):a(C.path),title:C.path,children:[C.isDirectory?o.jsx("svg",{className:"w-4 h-4 shrink-0 text-blue-400",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{d:"M3.5 3A1.5 1.5 0 002 4.5v11A1.5 1.5 0 003.5 17h13a1.5 1.5 0 001.5-1.5v-8A1.5 1.5 0 0016.5 6h-6.53a.5.5 0 01-.354-.146L8.706 4.854A1.5 1.5 0 007.586 4H3.5z"})}):A?o.jsx("svg",{className:"w-4 h-4 shrink-0 text-purple-400",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M4 5a2 2 0 012-2h3.5a1.5 1.5 0 011.06.44l1.5 1.5c.14.14.331.22.53.22H14a2 2 0 012 2v7a2 2 0 01-2 2H6a2 2 0 01-2-2V5zm4.5 4.5a.75.75 0 00-1.5 0v3a.75.75 0 001.06.68l2.5-1.5a.75.75 0 000-1.32l-2.5-1.5a.75.75 0 00-.56-.06z",clipRule:"evenodd"})}):o.jsx("svg",{className:"w-4 h-4 shrink-0 text-fg-tertiary group-hover:text-fg-secondary",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})}),o.jsx("span",{className:"flex-1 min-w-0 text-sm text-fg-primary truncate",children:C.name}),T&&o.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded text-[10px] font-mono uppercase bg-surface-overlay/60 text-fg-tertiary border border-border-subtle",children:T}),!C.isDirectory&&o.jsx("span",{className:"shrink-0 text-[11px] text-fg-tertiary tabular-nums",children:Vce(C.size)})]},C.path)})})]})}const Yk=new Set(["pdf","docx","xlsx"]),Xce=30*1024*1024;function Zce({data:e,reference:t,onFallback:n}){const{t:a}=ut("deliverables"),i=(e.format||"").toLowerCase().replace(/^\./,""),l=w.useRef(null),[c,u]=w.useState("loading"),[m,f]=w.useState(""),[g,h]=w.useState(0),[b,y]=w.useState(null),[k,C]=w.useState(1),[T,A]=w.useState(1),M=w.useCallback(()=>{n?.()},[n]),I=w.useCallback(async()=>{if(t)try{await Se.files.reveal(t);return}catch{}M()},[t,M]),B=w.useCallback(j=>{const O=l.current?.querySelector(`canvas[data-page="${j}"]`);O&&(O.scrollIntoView({behavior:"smooth",block:"start"}),C(j))},[]);w.useEffect(()=>{const j=l.current;if(!j||!Yk.has(i)){u("ready");return}let O=!1,F;return u("loading"),f(""),j.innerHTML="",(async()=>{try{i==="pdf"?F=await rde(e.streamUrl,j,{onReady:Y=>{y(Y),C(1)},zoom:T}):i==="docx"?F=await ide(e.streamUrl,j):i==="xlsx"&&(F=await sde(e.streamUrl,j)),O||u("ready")}catch(Y){O||(u("error"),f(String(Y)))}})(),()=>{O=!0,F&&F(),j.innerHTML=""}},[e.streamUrl,i,g,T]);const G=!Yk.has(i);return o.jsx("div",{className:"flex flex-col h-full min-h-0",children:G?o.jsx(ede,{format:i,size:e.size,onOpenSystem:I,onDownload:()=>M()}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-3 py-1.5 border-b border-border-default/60 bg-surface-elevated/40",children:[o.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wide",children:i}),e.name&&o.jsx("span",{className:"text-[11px] text-fg-secondary truncate flex-1 min-w-0",title:e.name,children:e.name}),e.size!=null&&e.size>Xce&&o.jsx("span",{className:"text-[10px] text-amber-500 shrink-0",children:a("officeLargeFile")}),i==="pdf"&&b!=null&&o.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[o.jsx("button",{onClick:()=>B(Math.max(1,k-1)),disabled:k<=1,className:"w-6 h-6 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary disabled:opacity-30",children:"‹"}),o.jsxs("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:[k,"/",b]}),o.jsx("button",{onClick:()=>B(Math.min(b??1,k+1)),disabled:k>=(b??1),className:"w-6 h-6 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary disabled:opacity-30",children:"›"})]}),i==="pdf"&&o.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[o.jsx("button",{onClick:()=>A(j=>Math.max(.5,+(j-.25).toFixed(2))),disabled:T<=.5,className:"w-6 h-6 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary disabled:opacity-30",children:"−"}),o.jsxs("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:[Math.round(T*100),"%"]}),o.jsx("button",{onClick:()=>A(j=>Math.min(3,+(j+.25).toFixed(2))),disabled:T>=3,className:"w-6 h-6 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary disabled:opacity-30",children:"+"})]}),o.jsx("button",{onClick:I,className:"shrink-0 text-[10px] text-fg-tertiary hover:text-fg-secondary px-1.5 py-0.5 rounded hover:bg-surface-overlay transition-colors",children:a("officeOpenSystem")})]}),o.jsxs("div",{className:"flex-1 min-h-0 overflow-auto p-3",children:[c==="loading"&&o.jsxs("div",{className:"flex items-center justify-center h-full text-fg-tertiary",children:[o.jsxs("svg",{className:"animate-spin w-4 h-4 mr-2",viewBox:"0 0 24 24",fill:"none",children:[o.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),o.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),o.jsx("span",{className:"text-xs",children:a("officeLoading")})]}),c==="error"&&o.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[o.jsx("span",{className:"text-[11px] text-fg-tertiary",children:a("officeFailed")}),o.jsx("span",{className:"text-[10px] text-fg-muted max-w-xs truncate",children:m}),o.jsxs("div",{className:"flex gap-2 mt-1",children:[o.jsx("button",{onClick:()=>h(j=>j+1),className:"px-3 py-1.5 text-xs bg-brand-600 text-on-brand rounded-lg hover:bg-brand-500 transition-colors",children:a("officeRetry")}),o.jsx("button",{onClick:I,className:"px-3 py-1.5 text-xs border border-border-default text-fg-secondary rounded-lg hover:bg-surface-elevated transition-colors",children:a("officeOpenSystem")})]})]}),o.jsx("div",{ref:l,className:c==="loading"?"hidden":""})]})]})})}function ede({format:e,size:t,onOpenSystem:n,onDownload:a}){const{t:i}=ut("deliverables");return o.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-center px-6",children:[o.jsx("div",{className:"w-12 h-12 rounded-xl bg-surface-elevated flex items-center justify-center text-xl",children:"📄"}),o.jsx("div",{className:"text-xs text-fg-secondary",children:i("officeNoInlinePreview",{format:e})}),t!=null&&o.jsx("div",{className:"text-[10px] text-fg-tertiary",children:i("officeSize",{size:tde(t)})}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("button",{onClick:n,className:"px-3 py-1.5 text-xs bg-brand-600 text-on-brand rounded-lg hover:bg-brand-500 transition-colors",children:i("officeOpenSystem")}),o.jsx("button",{onClick:a,className:"px-3 py-1.5 text-xs border border-border-default text-fg-secondary rounded-lg hover:bg-surface-elevated transition-colors",children:i("officeDownload")})]})]})}function tde(e){return e==null||!Number.isFinite(e)?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function nde(){const e=Uint8Array.prototype;typeof e.toHex!="function"&&(e.toHex=function(){let i="",l=0,c=this.length,u;for(;l<c;++l)u=this[l],i+=(u>>>4).toString(16)+(u&15).toString(16);return i});const t=Map.prototype;typeof t.getOrInsertComputed!="function"&&(t.getOrInsertComputed=function(i,l){if(this.has(i))return this.get(i);const c=l(i);return this.set(i,c),c}),typeof t.getOrInsert!="function"&&(t.getOrInsert=function(i,l){return this.has(i)?this.get(i):(this.set(i,l),l)});const n=Promise;typeof n.try!="function"&&(n.try=function(i){return new Promise(l=>l(i()))});const a=typeof Iterator<"u"?Iterator.prototype:null;a&&typeof a.join!="function"&&(a.join=function(i=","){let l="",c=!0;for(const u of this)c||(l+=i),l+=String(u),c=!1;return l})}nde();let _0=null;function ade(){if(!_0){const t=`
|
|
814
|
+
`,1;if(ol>1e5&&ol>gt.index*3)throw new Error("potential infinite loop, way more iterations than matches");return un+=Pt,Pt.length}const sa=ia(pe);if(!sa)throw Me(Ht.replace("{}",pe)),new Error('Unknown language: "'+pe+'"');const Wc=he(sa);let Qs="",Nt=Ut||Wc;const Yc={},Fn=new nt.__emitter(nt);sl();let un="",xi=0,Ur=0,ol=0,wi=!1;try{if(sa.__emitTokens)sa.__emitTokens(Ze,Fn);else{for(Nt.matcher.considerAll();;){ol++,wi?wi=!1:Nt.matcher.considerAll(),Nt.matcher.lastIndex=Ur;const et=Nt.matcher.exec(Ze);if(!et)break;const gt=Ze.substring(Ur,et.index),Pt=Ys(gt,et);Ur=et.index+Pt}Ys(Ze.substring(Ur))}return Fn.finalize(),Qs=Fn.toHTML(),{language:pe,value:Qs,relevance:xi,illegal:!1,_emitter:Fn,_top:Nt}}catch(et){if(et.message&&et.message.includes("Illegal"))return{language:pe,value:Ft(Ze),illegal:!0,relevance:0,_illegalBy:{message:et.message,index:Ur,context:Ze.slice(Ur-100,Ur+100),mode:et.mode,resultSoFar:Qs},_emitter:Fn};if(wt)return{language:pe,value:Ft(Ze),illegal:!1,relevance:0,errorRaised:et,_emitter:Fn,_top:Nt};throw et}}function ga(pe){const Ze={value:Ft(pe),illegal:!1,relevance:0,_top:lt,_emitter:new nt.__emitter(nt)};return Ze._emitter.addText(pe),Ze}function yi(pe,Ze){Ze=Ze||nt.languages||Object.keys(be);const St=ga(pe),Ut=Ze.filter(ia).filter(Cr).map(Lt=>Xn(Lt,pe,!1));Ut.unshift(St);const ln=Ut.sort((Lt,fn)=>{if(Lt.relevance!==fn.relevance)return fn.relevance-Lt.relevance;if(Lt.language&&fn.language){if(ia(Lt.language).supersetOf===fn.language)return 1;if(ia(fn.language).supersetOf===Lt.language)return-1}return 0}),[jn,Dt]=ln,dn=jn;return dn.secondBest=Dt,dn}function ba(pe,Ze,St){const Ut=Ze&&Te[Ze]||St;pe.classList.add("hljs"),pe.classList.add(`language-${Ut}`)}function Mn(pe){let Ze=null;const St=vn(pe);if(Ct(St))return;if(hr("before:highlightElement",{el:pe,language:St}),pe.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",pe);return}if(pe.children.length>0&&(nt.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(pe)),nt.throwUnescapedHTML))throw new ot("One of your code blocks includes unescaped HTML.",pe.innerHTML);Ze=pe;const Ut=Ze.textContent,ln=St?xn(Ut,{language:St,ignoreIllegals:!0}):yi(Ut);pe.innerHTML=ln.value,pe.dataset.highlighted="yes",ba(pe,St,ln.language),pe.result={language:ln.language,re:ln.relevance,relevance:ln.relevance},ln.secondBest&&(pe.secondBest={language:ln.secondBest.language,relevance:ln.secondBest.relevance}),hr("after:highlightElement",{el:pe,result:ln,text:Ut})}function Zn(pe){nt=cn(nt,pe)}const kr=()=>{$r(),ne("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Sr(){$r(),ne("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Ks=!1;function $r(){function pe(){$r()}if(document.readyState==="loading"){Ks||window.addEventListener("DOMContentLoaded",pe,!1),Ks=!0;return}document.querySelectorAll(nt.cssSelector).forEach(Mn)}function ss(pe,Ze){let St=null;try{St=Ze(Q)}catch(Ut){if(Me("Language definition for '{}' could not be registered.".replace("{}",pe)),wt)Me(Ut);else throw Ut;St=lt}St.name||(St.name=pe),be[pe]=St,St.rawDefinition=Ze.bind(null,Q),St.aliases&&fr(St.aliases,{languageName:pe})}function ra(pe){delete be[pe];for(const Ze of Object.keys(Te))Te[Ze]===pe&&delete Te[Ze]}function vi(){return Object.keys(be)}function ia(pe){return pe=(pe||"").toLowerCase(),be[pe]||be[Te[pe]]}function fr(pe,{languageName:Ze}){typeof pe=="string"&&(pe=[pe]),pe.forEach(St=>{Te[St.toLowerCase()]=Ze})}function Cr(pe){const Ze=ia(pe);return Ze&&!Ze.disableAutodetect}function Ar(pe){pe["before:highlightBlock"]&&!pe["before:highlightElement"]&&(pe["before:highlightElement"]=Ze=>{pe["before:highlightBlock"](Object.assign({block:Ze.el},Ze))}),pe["after:highlightBlock"]&&!pe["after:highlightElement"]&&(pe["after:highlightElement"]=Ze=>{pe["after:highlightBlock"](Object.assign({block:Ze.el},Ze))})}function In(pe){Ar(pe),Xe.push(pe)}function Vs(pe){const Ze=Xe.indexOf(pe);Ze!==-1&&Xe.splice(Ze,1)}function hr(pe,Ze){const St=pe;Xe.forEach(function(Ut){Ut[St]&&Ut[St](Ze)})}function ge(pe){return ne("10.7.0","highlightBlock will be removed entirely in v12.0"),ne("10.7.0","Please use highlightElement now."),Mn(pe)}Object.assign(Q,{highlight:xn,highlightAuto:yi,highlightAll:$r,highlightElement:Mn,highlightBlock:ge,configure:Zn,initHighlighting:kr,initHighlightingOnLoad:Sr,registerLanguage:ss,unregisterLanguage:ra,listLanguages:vi,getLanguage:ia,registerAliases:fr,autoDetection:Cr,inherit:cn,addPlugin:In,removePlugin:Vs}),Q.debugMode=function(){wt=!1},Q.safeMode=function(){wt=!0},Q.versionString=Je,Q.regex={concat:C,lookahead:b,either:A,optional:k,anyNumberOfTimes:y};for(const pe in Ye)typeof Ye[pe]=="object"&&e(Ye[pe]);return Object.assign(Q,Ye),Q},De=_e({});return De.newInstance=()=>_e({}),j0=De,De.HighlightJS=De,De.default=De,j0}var zle=Ble();const qle=Bc(zle),Ok={},$le="hljs-";function Fle(e){const t=qle.newInstance();return e&&l(e),{highlight:n,highlightAuto:a,listLanguages:i,register:l,registerAlias:c,registered:u};function n(m,f,g){const h=g||Ok,b=typeof h.prefix=="string"?h.prefix:$le;if(!t.getLanguage(m))throw new Error("Unknown language: `"+m+"` is not registered");t.configure({__emitter:Ule,classPrefix:b});const y=t.highlight(f,{ignoreIllegals:!0,language:m});if(y.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:y.errorRaised});const k=y._emitter.root,C=k.data;return C.language=y.language,C.relevance=y.relevance,k}function a(m,f){const h=(f||Ok).subset||i();let b=-1,y=0,k;for(;++b<h.length;){const C=h[b];if(!t.getLanguage(C))continue;const T=n(C,m,f);T.data&&T.data.relevance!==void 0&&T.data.relevance>y&&(y=T.data.relevance,k=T)}return k||{type:"root",children:[],data:{language:void 0,relevance:y}}}function i(){return t.listLanguages()}function l(m,f){if(typeof m=="string")t.registerLanguage(m,f);else{let g;for(g in m)Object.hasOwn(m,g)&&t.registerLanguage(g,m[g])}}function c(m,f){if(typeof m=="string")t.registerAliases(typeof f=="string"?f:[...f],{languageName:m});else{let g;for(g in m)if(Object.hasOwn(m,g)){const h=m[g];t.registerAliases(typeof h=="string"?h:[...h],{languageName:g})}}}function u(m){return!!t.getLanguage(m)}}class Ule{constructor(t){this.options=t,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(t){if(t==="")return;const n=this.stack[this.stack.length-1],a=n.children[n.children.length-1];a&&a.type==="text"?a.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const a=this.stack[this.stack.length-1],i=t.root.children;n?a.children.push({type:"element",tagName:"span",properties:{className:[n]},children:i}):a.children.push(...i)}openNode(t){const n=this,a=t.split(".").map(function(c,u){return u?c+"_".repeat(u):n.options.classPrefix+c}),i=this.stack[this.stack.length-1],l={type:"element",tagName:"span",properties:{className:a},children:[]};i.children.push(l),this.stack.push(l)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const Gle={};function Kle(e){const t=e||Gle,n=t.aliases,a=t.detect||!1,i=t.languages||Hle,l=t.plainText,c=t.prefix,u=t.subset;let m="hljs";const f=Fle(i);if(n&&f.registerAlias(n),c){const g=c.indexOf("-");m=g===-1?c:c.slice(0,g)}return function(g,h){op(g,"element",function(b,y,k){if(b.tagName!=="code"||!k||k.type!=="element"||k.tagName!=="pre")return;const C=Vle(b);if(C===!1||!C&&!a||C&&l&&l.includes(C))return;Array.isArray(b.properties.className)||(b.properties.className=[]),b.properties.className.includes(m)||b.properties.className.unshift(m);const T=rC(b,{whitespace:"pre"});let A;try{A=C?f.highlight(C,T,{prefix:c}):f.highlightAuto(T,{prefix:c,subset:u})}catch(M){const I=M;if(C&&/Unknown language/.test(I.message)){h.message("Cannot highlight as `"+C+"`, it’s not registered",{ancestors:[k,b],cause:I,place:b.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw I}!C&&A.data&&A.data.language&&b.properties.className.push("language-"+A.data.language),A.children.length>0&&(b.children=A.children)})}}function Vle(e){const t=e.properties.className;let n=-1;if(!Array.isArray(t))return;let a;for(;++n<t.length;){const i=String(t[n]);if(i==="no-highlight"||i==="nohighlight")return!1;!a&&i.slice(0,5)==="lang-"&&(a=i.slice(5)),!a&&i.slice(0,9)==="language-"&&(a=i.slice(9))}return a}const Bs={agent:{label:"Agent",labelZh:"智能体",gradient:"from-violet-500 to-indigo-600",accent:"#8b5cf6",covers:[["#7c3aed","#4f46e5"],["#8b5cf6","#6366f1"],["#a855f7","#4338ca"],["#6d28d9","#2563eb"]]},team:{label:"Team",labelZh:"AI 小队",gradient:"from-cyan-500 to-blue-600",accent:"#06b6d4",covers:[["#0891b2","#2563eb"],["#06b6d4","#3b82f6"],["#0e7490","#1d4ed8"],["#22d3ee","#4f46e5"]]},skill:{label:"Skill",labelZh:"技能",gradient:"from-amber-500 to-orange-600",accent:"#f59e0b",covers:[["#f59e0b","#ea580c"],["#d97706","#dc2626"],["#fbbf24","#f97316"],["#f59e0b","#b45309"]]},connector:{label:"Connector",labelZh:"连接器",gradient:"from-emerald-500 to-teal-600",accent:"#10b981",covers:[["#10b981","#0d9488"],["#059669","#0891b2"],["#34d399","#14b8a6"],["#16a34a","#0f766e"]]}};function il(e){const t=(e||"").toLowerCase();return t==="team"?"team":t==="skill"?"skill":t==="connector"||t==="mcp"?"connector":"agent"}function AC(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}const Wle={agent:258,team:205,skill:32,connector:162};function Fb(e,t){const n=Wle[e],a=AC(t),i=((n+(a%68-34))%360+360)%360,l=(i+22+(a>>>8)%24)%360;return`linear-gradient(${120+a%44}deg, hsl(${i} 72% 56%), hsl(${l} 66% 43%))`}const Hk=["M12 2l2.4 6.9L21 9l-5.4 4 2 7-5.6-4.1L6.4 20l2-7L3 9l6.6-.1z","M12 2a10 10 0 100 20 10 10 0 000-20zm0 4a6 6 0 110 12 6 6 0 010-12z","M4 4h7v7H4zM13 4h7v7h-7zM4 13h7v7H4zM13 13h7v7h-7z","M12 2l9 5v10l-9 5-9-5V7z","M3 12a9 9 0 019-9v9h9a9 9 0 11-18 0z","M6 3h12l3 6-9 12L3 9z","M12 3l3 6 6 .9-4.5 4.3 1 6.3L12 18l-5.5 2.5 1-6.3L3 9.9 9 9z","M4 12a8 8 0 018-8v4a4 4 0 00-4 4zm8 8a8 8 0 01-8-8h4a4 4 0 004 4z","M12 2l7 4v12l-7 4-7-4V6z M12 6l-3 1.7v3.4L12 13l3-1.9V7.7z","M3 6h18M3 12h18M3 18h18","M12 2a10 10 0 100 20A6 6 0 0112 8a6 6 0 010 12","M12 2l4 8h-8zM4 12h16l-8 10z"];function TC(e){return Hk[AC(e+"g")%Hk.length]}function EC(e){return e?e.startsWith("http://")||e.startsWith("https://")||e.startsWith("/")||e.startsWith("data:")||/\.(png|jpe?g|gif|webp|svg)$/i.test(e):!1}function Yle(e){return!e||EC(e)?!1:[...e].length<=4&&new RegExp("\\p{Extended_Pictographic}","u").test(e)}function Qle(e,t="user"){const n=t==="org"?"shapes":"thumbs",a=encodeURIComponent(e);return`https://api.dicebear.com/9.x/${n}/svg?seed=${a}&radius=50&backgroundType=gradientLinear`}function qo(e){const t=e??0;return t<1e3?String(t):t<1e6?`${(t/1e3).toFixed(t<1e4?1:0)}k`.replace(".0k","k"):`${(t/1e6).toFixed(1)}M`.replace(".0M","M")}function Bk(e,t="usd"){return!e||e<=0?"Free":`${t.toLowerCase()==="usd"?"$":""}${(e/100).toFixed(e%100===0?0:2)}`}const NC=/^(?:\/|~\/|[A-Za-z]:[\\/]|\\\\)/,MC=/^\.{1,2}\//,Jle=/\.[a-zA-Z0-9]{1,12}(?:$|[?#])/,jC=/^[A-Za-z]:[\\/]/,RC=/^\\\\[^\\]/;function Xle(e){const t=e.trim();return t?!!(/^file:/i.test(t)||jC.test(t)||RC.test(t)||t.startsWith("~/")||t.startsWith("/")||MC.test(t)):!1}const Zle=/(?:%[0-9A-Fa-f]{2})+/g;function _C(e){return e.includes("%")?e.replace(Zle,t=>{const n=new Uint8Array(t.length/3);for(let a=0;a<n.length;a++)n[a]=Number.parseInt(t.slice(a*3+1,a*3+3),16);try{const a=new TextDecoder("utf-8",{fatal:!0}).decode(n);return/[^\x00-\x7F]/.test(a)?a:t}catch{return t}}):e}function Ub(e){let t=e.trim();if(/^file:/i.test(t)){try{t=decodeURIComponent(t.replace(/^file:\/\//i,""))}catch{t=t.replace(/^file:\/\//i,"")}/^\/[A-Za-z]:\//.test(t)&&(t=t.slice(1))}return t=_C(t),t=t.replace(/\\+/g,"/"),t}function ope(e){return e.replace(/(!?\[[^\]]*]\()((?:[A-Za-z]:|\\\\)[^)\n]*)(\))/g,(t,n,a,i)=>`${n}${a.replace(/\\+/g,"/")}${i}`)}const ece=/^(?:(?:\/|~\/|\.\.?\/)[\p{L}\p{N}\p{M}\w.@+\-\u3000-\u303f\uff00-\uffef]+(?:\/[\p{L}\p{N}\p{M}\w.@+\- \u3000-\u303f\uff00-\uffef]*)*|[A-Za-z]:[\\/][\p{L}\p{N}\p{M}\w.@+\- \u3000-\u303f\uff00-\uffef]+(?:(?:\\|\/)[\p{L}\p{N}\p{M}\w.@+\- \u3000-\u303f\uff00-\uffef]*)*)$/u;function tce(e){return e.length<2||e.length>500?!1:ece.test(e)}function DC(e){return e.trim().toLowerCase().replace(/[^\p{L}\p{N}\p{M}\s\-_]/gu,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function Lu(e,t){if(!e)return e;if(NC.test(e))return e.startsWith("~/")?e:e.replace(/\\/g,"/");if(!t)return e;const a=`${t.replace(/\\/g,"/").replace(/\/+$/,"")}/${e.replace(/^\.\//,"")}`,i=a.split("/"),l=[];for(const u of i)!u||u==="."||(u===".."?l.pop():l.push(u));const c=l.join("/");return a.startsWith("/")?`/${c}`.replace(/^\/+/,"/"):c}function zk(e){const t=e.indexOf("#");return t<0?{path:e}:{path:e.slice(0,t),fragment:decodeURIComponent(e.slice(t+1))}}function qk(e,t){if(!e)return{kind:"passthrough"};const n=e.trim();if(!n||n==="#")return{kind:"passthrough"};if(n.startsWith("#")&&!n.startsWith("#mention:")&&!n.startsWith("#entity:"))return{kind:"fragment",id:decodeURIComponent(n.slice(1))};if(jC.test(n)||RC.test(n)){const{path:c,fragment:u}=zk(n);return{kind:"file",path:Lu(c,t),fragment:u}}if(/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(n))return/^https?:\/\//i.test(n)||/^mailto:/i.test(n)?{kind:"external",url:n}:/^file:\/\//i.test(n)?{kind:"file",path:Ub(n)}:{kind:"passthrough"};const a=zk(n),i=_C(a.path),l=a.fragment;return NC.test(i)?{kind:"file",path:Lu(i,t),fragment:l}:MC.test(i)?{kind:"file",path:Lu(i,t),fragment:l}:i&&Jle.test(i)&&!i.includes("://")?{kind:"file",path:Lu(i,t),fragment:l}:{kind:"passthrough"}}function nce(e,t){if(!e||!t)return!1;let n=null;try{n=e.querySelector(`#${CSS.escape(t)}`)}catch{n=null}if(n||(n=e.querySelector(`[id="${t.replace(/"/g,'\\"')}"]`)),!n){const a=e.querySelectorAll("h1,h2,h3,h4,h5,h6");for(const i of a)if(DC(i.textContent||"")===t||i.id===t){n=i;break}}return n?(n.scrollIntoView({behavior:"smooth",block:"start"}),!0):!1}function IC(e){return e.type==="text"?e.value??"":(e.children??[]).map(IC).join("")}function ace(){return e=>{const t=new Map,n=a=>{if(a.type==="element"&&a.tagName&&/^h[1-6]$/.test(a.tagName)){const i=IC(a).trim();let l=DC(i);if(l){const c=t.get(l)??0;t.set(l,c+1),c>0&&(l=`${l}-${c}`),a.properties={...a.properties??{},id:l}}}for(const i of a.children??[])n(i)};n(e)}}function $k(e,t){const n=/```[\s\S]*?```|`[^`\n]+`/g;let a=0,i="";for(const l of e.matchAll(n))i+=t(e.slice(a,l.index)),i+=l[0],a=l.index+l[0].length;return i+=t(e.slice(a)),i}function lpe(e){let t=e.replace(/\\\[([\s\S]*?)\\\]/g,(n,a)=>`$$${a}$$`);return t=t.replace(/\\\((.+?)\\\)/g,(n,a)=>`$${a}$`),t}function rce(e){return e.replace(/[$](?=[0-9])/g,(n,a,i)=>a>0&&i.charCodeAt(a-1)===92?n:"\\"+n)}const Pu="#mention:";function cpe(e,t){if(!t||t.length===0)return e.replace(/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu,(l,c,u)=>{const m=c??u;return`[@${m}](${Pu}${encodeURIComponent(m)})`});const n=[...t].sort((l,c)=>c.length-l.length);let a="",i=0;for(;i<e.length;){const l=e.indexOf("@",i);if(l<0){a+=e.slice(i);break}if(a+=e.slice(i,l),e[l+1]==="["){const g=e.indexOf("]",l+2);if(g>l+2){const h=e.slice(l+2,g);a+=`[@${h}](${Pu}${encodeURIComponent(h)})`,i=g+1;continue}}const c=e.slice(l+1),u=c.toLowerCase(),m=n.find(g=>u.startsWith(g.toLowerCase()));if(m){const g=c.slice(0,m.length);a+=`[@${g}](${Pu}${encodeURIComponent(g)})`,i=l+1+m.length;continue}const f=c.match(/^([\w\p{L}\p{N}]+)/u);if(f){const g=f[1];a+=`[@${g}](${Pu}${encodeURIComponent(g)})`,i=l+1+g.length;continue}a+="@",i=l+1}return a}const LC="#entity:",ice=new RegExp("(?<!\\[)(?<!\\()(?<!:)(?<!\\/)(?<!\\\\)\\b(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}\\b(?!\\]\\(#entity:)","gi"),sce=/`\[([^\]]+)\]\(#entity:((?:tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)`/gi;function PC(e,t){const n=e.slice(0,t),a=n.lastIndexOf("](");return a===-1?!1:n.indexOf(")",a+2)===-1}function dpe(e){return e.replace(sce,(t,n,a)=>`[${n}](${LC}${a})`)}function upe(e){return e.replace(ice,(t,n,a)=>PC(e,a)?t:`[${t}](${LC}${t})`)}const oce=["\\s","<",">","`","\\u4e00-\\u9fff","\\u3000-\\u303f","\\uff00-\\uffef"].join(""),OC=new RegExp(`https?://[^${oce}]+`,"gi"),lce=/(\*{1,3}|_{1,3}|~{1,2})$/;function cce(e,t,n){const a=n.match(lce);if(!a)return null;const i=a[1];return e.slice(Math.max(0,t-i.length),t)===i?i:null}const dce=/[.,;:!?\]\)"']+$/;function HC(e){return e.replace(dce,"")}function mpe(e){const t=[],n=new RegExp(OC.source,"gi");let a=0;for(let i=n.exec(e);i;i=n.exec(e)){const l=HC(i[0]);if(!l)continue;const c=i.index;c>a&&t.push({kind:"text",value:e.slice(a,c)}),t.push({kind:"link",value:l}),a=c+l.length}return a<e.length&&t.push({kind:"text",value:e.slice(a)}),t}function uce(e){return e.replace(OC,(t,n)=>{if(PC(e,n))return t;let a=HC(t);if(!a)return t;const i=cce(e,n,a);if(i&&(a=a.slice(0,a.length-i.length)),!a)return t;const l=t.slice(a.length);return/[()[\]]/.test(a)?t:`[${a}](${a})${l}`})}function mce(e){const t=e.trim();return t.startsWith("@startuml")&&t.endsWith("@enduml")}const pce={js:"JavaScript",javascript:"JavaScript",ts:"TypeScript",typescript:"TypeScript",tsx:"TSX",jsx:"JSX",py:"Python",python:"Python",rb:"Ruby",ruby:"Ruby",rs:"Rust",rust:"Rust",go:"Go",java:"Java",kotlin:"Kotlin",swift:"Swift",cpp:"C++",c:"C",cs:"C#",csharp:"C#",php:"PHP",sql:"SQL",sh:"Shell",bash:"Bash",zsh:"Zsh",shell:"Shell",html:"HTML",css:"CSS",scss:"SCSS",less:"LESS",json:"JSON",yaml:"YAML",yml:"YAML",xml:"XML",toml:"TOML",ini:"INI",md:"Markdown",markdown:"Markdown",dockerfile:"Dockerfile",docker:"Dockerfile",graphql:"GraphQL",gql:"GraphQL",lua:"Lua",perl:"Perl",r:"R",scala:"Scala",elixir:"Elixir",erlang:"Erlang",haskell:"Haskell",clojure:"Clojure",dart:"Dart",zig:"Zig",nim:"Nim",powershell:"PowerShell",ps1:"PowerShell",vue:"Vue",svelte:"Svelte",plaintext:"Text",text:"Text",txt:"Text"};function fce(e){return pce[e.toLowerCase()]??e.charAt(0).toUpperCase()+e.slice(1)}function hce(e){const t=e.match(/language-(\S+)/);return t?t[1]:null}const gce=24;function bce(e){const t=e.indexOf("_");return t<0?!1:e.length>=t+1+gce}const BC={tsk:{load:async()=>(await Se.tasks.list({lean:!0,pageSize:500})).tasks.map(e=>e.id)},req:{load:async()=>(await Se.requirements.list({lean:!0})).requirements.map(e=>e.id)},proj:{load:async()=>(await Se.projects.list()).projects.map(e=>e.id)},dlv:{load:async()=>(await Se.deliverables.search({limit:500})).results.map(e=>e.id)},agt:{load:async()=>(await Se.agents.list({lean:!0})).agents.map(e=>e.id)},team:{load:async()=>(await Se.teams.list()).teams.map(e=>e.id)}},R0=new Map,Fk=new Map;function yce(e){const t=BC[e];if(!t)return null;let n=R0.get(e);return n||(n=t.load().catch(a=>{throw R0.delete(e),a}),R0.set(e,n)),n}async function vce(e){if(!e)return null;const t=e.indexOf("_");if(t<0)return null;const n=e.slice(0,t);if(!BC[n])return null;if(bce(e))return e;const a=Fk.get(e);if(a!==void 0)return a;const i=(await yce(n)??[]).filter(c=>c.startsWith(e)),l=i.length===1?i[0]:null;return Fk.set(e,l),l}const xce=w.lazy(()=>fa(()=>import("./MarkdownMessage-BX6YVVx8.js"),[]).then(e=>({default:e.MarkdownMessage}))),wce={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},Uk={active:{color:"text-green-600 bg-green-500/10"},verified:{color:"text-blue-600 bg-blue-500/10"},outdated:{color:"text-fg-tertiary bg-surface-elevated/50"}};function kce({item:e,onClose:t,onOpenInPage:n}){const{t:a}=ut(["agent","common"]),i=wce[e.type]??{icon:"📎",color:"bg-surface-elevated text-fg-secondary"},l=Uk[e.status]??Uk.active,c=/^https?:\/\//i.test(e.reference??"");w.useEffect(()=>{const m=f=>{f.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]);const u=o.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:t,children:[o.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),o.jsxs("div",{className:"relative bg-surface-primary rounded-2xl shadow-2xl border border-border-default w-full max-w-lg max-h-[85vh] overflow-y-auto",onClick:m=>m.stopPropagation(),children:[o.jsxs("div",{className:"sticky top-0 bg-surface-primary/95 backdrop-blur-sm border-b border-border-default px-5 py-4 flex items-start gap-3 rounded-t-2xl z-10",children:[o.jsx("span",{className:`inline-flex items-center justify-center w-10 h-10 rounded-xl text-lg shrink-0 ${i.color}`,children:i.icon}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:e.title}),o.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[o.jsx("span",{className:`px-1.5 py-0.5 text-[10px] rounded font-medium ${l.color}`,children:e.status}),o.jsx("span",{className:"text-[10px] text-fg-tertiary",children:e.type}),e.format&&o.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-elevated rounded text-fg-secondary",children:e.format})]})]}),o.jsx("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors shrink-0 text-fg-tertiary hover:text-fg-primary",children:o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsxs("div",{className:"px-5 py-4 space-y-4",children:[e.summary&&e.summary.trim()!==e.title.trim()&&o.jsxs("div",{children:[o.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:a("agent:deliverables.summary")}),o.jsx("div",{className:"mt-1.5",children:o.jsx(w.Suspense,{fallback:o.jsx("p",{className:"text-sm text-fg-secondary",children:e.summary}),children:o.jsx(xce,{content:e.summary,className:"text-sm text-fg-secondary"})})})]}),e.reference&&o.jsxs("div",{children:[o.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:a("agent:deliverables.reference")}),o.jsxs("div",{className:"mt-1.5 flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[o.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all flex-1 select-all",children:e.reference}),c?o.jsx("button",{onClick:()=>window.open(e.reference,"_blank","noopener,noreferrer"),className:"px-2 py-1 text-[10px] rounded bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",children:a("common:open")}):o.jsx("button",{onClick:()=>{Se.files.reveal(e.reference).catch(()=>{})},className:"px-2 py-1 text-[10px] rounded bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",children:a("common:open")})]})]}),e.diffStats&&o.jsxs("div",{className:"flex items-center gap-3 text-xs bg-surface-elevated rounded-lg px-3 py-2",children:[o.jsxs("span",{className:"text-fg-tertiary font-medium",children:[a("agent:deliverables.diff"),":"]}),o.jsx("span",{className:"text-fg-secondary",children:a("agent:deliverables.fileCount",{count:e.diffStats.filesChanged})}),o.jsxs("span",{className:"text-green-500",children:["+",e.diffStats.additions]}),o.jsxs("span",{className:"text-red-500",children:["-",e.diffStats.deletions]})]}),e.testResults&&o.jsxs("div",{className:"flex items-center gap-3 text-xs bg-surface-elevated rounded-lg px-3 py-2",children:[o.jsxs("span",{className:"text-fg-tertiary font-medium",children:[a("deliverables:testResults.title"),":"]}),o.jsx("span",{className:"text-green-500",children:a("agent:deliverables.testsPassed",{n:e.testResults.passed})}),e.testResults.failed>0&&o.jsx("span",{className:"text-red-500",children:a("agent:deliverables.testsFailed",{n:e.testResults.failed})}),e.testResults.skipped>0&&o.jsx("span",{className:"text-fg-tertiary",children:a("agent:deliverables.testsSkipped",{n:e.testResults.skipped})})]}),e.tags.length>0&&o.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.tags.map(m=>o.jsx("span",{className:"px-2 py-0.5 text-[11px] bg-surface-elevated rounded-md text-fg-tertiary",children:m},m))}),o.jsxs("div",{className:"flex items-center gap-4 text-[10px] text-fg-tertiary flex-wrap pt-1 border-t border-border-default/50",children:[o.jsxs("span",{children:[a("agent:deliverables.created"),": ",new Date(e.createdAt).toLocaleString()]}),o.jsxs("span",{children:[a("agent:deliverables.updated"),": ",new Date(e.updatedAt).toLocaleString()]}),e.accessCount>0&&o.jsx("span",{children:a("agent:deliverables.accessed",{count:e.accessCount})})]})]}),o.jsxs("div",{className:"sticky bottom-0 bg-surface-primary/95 backdrop-blur-sm border-t border-border-default px-5 py-3 flex items-center justify-end gap-2 rounded-b-2xl",children:[o.jsxs("button",{onClick:()=>n(e.id),className:"px-3 py-1.5 text-xs font-medium text-brand-500 hover:bg-brand-500/10 rounded-lg transition-colors flex items-center gap-1.5",children:[o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),o.jsx("polyline",{points:"15 3 21 3 21 9"}),o.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),a("agent:deliverables.openInPage")]}),o.jsx("button",{onClick:t,className:"px-3 py-1.5 text-xs font-medium text-fg-secondary bg-surface-elevated hover:bg-surface-overlay rounded-lg transition-colors",children:a("common:close")})]})]})]});return typeof document<"u"?Jo.createPortal(u,document.body):u}const Gb=new Set;function _s(e){e&&Gb.add(e)}function Bg(e){e&&Gb.delete(e)}const Kb="markus:browser-history",zC=300;function zg(e){return`${e.kind}:${e.target}`}function $m(e,t){const n=(t||"").trim();return n?e!=="url"?!0:n!=="about:blank"&&n!=="about:newtab":!1}function qC(e){const t=(e||"").trim();return t?t.startsWith("//")?`https:${t}`:t:""}function Sce(e){return e.replace(/^[a-z][a-z0-9+.-]*:\/\//i,"")}function Vb(e){return(e||"").trim()}function $C(e){const t=(e.id||"").trim();if(t)return t;const n=`${e.reference||""}|${e.title||""}|${(e.summary||"").slice(0,48)}`;return n==="||"?"":n}function Cce(e){if(e.kind==="file"){const t=Vb(e.path||"");return $m("file",t)?{kind:"file",target:t,title:(e.title||"").trim()||void 0}:null}if(e.kind==="deliverable"){const t=e.deliverable;if(!t)return null;const n=$C(t);return $m("deliverable",n)?{kind:"deliverable",target:n,title:(t.title||"").trim()||void 0,location:(t.reference||"").trim()||void 0}:null}return null}function Ace(e){return e.kind==="url"?Sce(e.target):e.kind==="deliverable"&&e.location||e.target}function Gk(e){return typeof e=="string"&&e.trim()?e:void 0}function Tce(e){if(!e||typeof e!="object")return null;const t=e,n=t.kind==="file"||t.kind==="deliverable"?t.kind:"url",a=typeof t.target=="string"?t.target:n==="url"&&typeof t.url=="string"?t.url:"",i=n==="url"?qC(a):Vb(a);return $m(n,i)?{kind:n,target:i,title:Gk(t.title),location:n==="deliverable"?Gk(t.location):void 0,visitedAt:typeof t.visitedAt=="number"&&Number.isFinite(t.visitedAt)?t.visitedAt:0,visitCount:typeof t.visitCount=="number"&&t.visitCount>0?t.visitCount:1}:null}function Wb(){try{const e=localStorage.getItem(Kb);if(!e)return[];const t=JSON.parse(e);if(!Array.isArray(t))return[];const n=[];for(const a of t){const i=Tce(a);i&&n.push(i)}return n}catch{return[]}}function Yb(e){try{localStorage.setItem(Kb,JSON.stringify(e.slice(0,zC)))}catch{}}function Qb(){return Wb().sort((e,t)=>t.visitedAt-e.visitedAt)}const qg=new Set;function Jb(e){for(const t of qg)try{t(e)}catch{}}function ppe(e){qg.add(e);const t=n=>{n.key!==null&&n.key!==Kb||e(Qb())};return typeof window<"u"&&window.addEventListener("storage",t),()=>{qg.delete(e),typeof window<"u"&&window.removeEventListener("storage",t)}}function FC(e,t=Date.now()){const n=e.kind==="url"?qC(e.target):Vb(e.target);if(!$m(e.kind,n))return Qb();const a=`${e.kind}:${n}`,i=Wb(),l=i.find(m=>zg(m)===a),c=i.filter(m=>zg(m)!==a),u=[{kind:e.kind,target:n,title:(e.title||"").trim()||l?.title,location:(e.location||"").trim()||l?.location,visitedAt:t,visitCount:(l?.visitCount??0)+1},...c].sort((m,f)=>f.visitedAt-m.visitedAt).slice(0,zC);return Yb(u),Jb(u),u}function fpe(e,t,n=Date.now()){return FC({kind:"url",target:e,title:t},n)}function hpe(e){const t=Wb().filter(n=>zg(n)!==e);return Yb(t),Jb(t),t}function gpe(){return Yb([]),Jb([]),[]}function bpe(e,t=8){const n=Qb(),a=(e||"").trim().toLowerCase();if(!a)return n.slice(0,t);const i=a.split(/\s+/).filter(Boolean),l=[];for(const c of n){const u=c.target.toLowerCase(),m=(c.title||"").toLowerCase(),f=Ace(c).toLowerCase(),g=`${f} ${m}`;let h=0,b=!0;for(const k of i){if(!g.includes(k)){b=!1;break}f.startsWith(k)?h+=120:u.startsWith(k)?h+=100:new RegExp(`(^|[./:?&=_-])${Ece(k)}`).test(f)?h+=60:m.startsWith(k)?h+=50:h+=20}if(!b)continue;const y=Math.max(0,(Date.now()-c.visitedAt)/864e5);h+=Math.max(0,30-y*2),h+=Math.min(30,c.visitCount*3),l.push({entry:c,score:h})}return l.sort((c,u)=>u.score-c.score||u.entry.visitedAt-c.entry.visitedAt).slice(0,t).map(c=>c.entry)}function Ece(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ype(e){if(!e.ctrlKey||e.metaKey||e.altKey)return null;const t=(e.key||"").toLowerCase();return t==="n"?"next":t==="p"?"prev":null}function vpe(e,t,n){return t<=0?-1:e<0?n==="next"?0:t-1:(e+(n==="next"?1:-1)+t)%t}const UC="markus_right_panel_v1",Nce=10,$g=new Map;function Mce(e,t=3e3){$g.set(e,Date.now()+t)}function jce(e){const t=$g.get(e);return t==null?!1:Date.now()>t?($g.delete(e),!1):!0}function Rce(e){return e.kind==="terminal"}function sc(e){return e.kind==="file"?`file:${e.path}`:e.kind==="url"?`url:${e.browserId||e.url}`:e.kind==="terminal"?`terminal:${e.terminalId}`:`deliverable:${$C(e.deliverable)||"unknown"}`}function Kk(e){return e.kind==="deliverable"?e.deliverable.title||e.deliverable.reference||"Deliverable":e.kind==="url"?e.title||e.url:e.kind==="terminal"?e.title||"Terminal":e.title||e.path.split(/[/\\]/).pop()||e.path}function Qi(){return`tab_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function Ou(e){let t=e;for(;t.length>Nce;){let n=-1;for(let i=t.length-1;i>=0;i--)if(!t[i].pinned){n=i;break}if(n<0)break;const a=t[n];a&&(Fg(a.payload),Ug(a.payload)),t=t.filter((i,l)=>l!==n)}return t}function Fg(e){e?.kind==="url"&&e.browserId&&(Mce(e.browserId),window.markusDesktop?.browser?.destroy(e.browserId))}function Ug(e){e?.kind==="terminal"&&e.terminalId&&(Bg(e.terminalId),window.markusDesktop?.terminal?.destroy(e.terminalId))}function _ce(e){const t=e.payload;return t.kind==="terminal"?null:t.kind==="url"?Nc(t.url||"")||Nc(t.title||"")?null:{id:e.id,title:e.title,pinned:e.pinned,payload:{kind:"url",url:t.url||"about:blank",title:t.title||e.title}}:t.kind==="file"?{id:e.id,title:e.title,pinned:e.pinned,payload:{kind:"file",path:t.path,title:t.title}}:{id:e.id,title:e.title,pinned:e.pinned,payload:{kind:"deliverable",deliverable:t.deliverable}}}function Dce(e,t=0){if(e.payload.kind==="url"){const n=`eb_${Date.now().toString(36)}_${t.toString(36)}_${Math.random().toString(36).slice(2,7)}`;return{...e,payload:{kind:"url",url:e.payload.url||"about:blank",title:e.payload.title||e.title,browserId:n}}}return e}function Ice(){try{const e=localStorage.getItem(UC);if(!e)return null;const t=JSON.parse(e);return!t||t.mode!=="browser"&&t.mode!=="terminal"||!Array.isArray(t.browserTabs)?null:t}catch{return null}}function Lce(){const e={mode:"browser",browserTabs:[],browserActiveId:null,terminalTabs:[],terminalActiveId:null,stashedBrowserTabs:[],stashedBrowserActiveId:null,stashedTerminalTabs:[],stashedTerminalActiveId:null},t=Ice();if(!t)return e;const n=t.browserTabs.map((y,k)=>{try{return Dce(y,k)}catch{return null}}).filter(y=>!(!y||y.payload.kind==="terminal"||y.payload.kind==="url"&&Nc(y.payload.url||""))),a=n.some(y=>y.id===t.browserActiveId)?t.browserActiveId:n[0]?.id??null,i=(t.terminalTabs||[]).map((y,k)=>{const C=`term_${Date.now().toString(36)}_${k.toString(36)}_${Math.random().toString(36).slice(2,7)}`;return _s(C),{id:y.id||Qi(),title:y.title||"Terminal",payload:{kind:"terminal",terminalId:C,title:y.title||"Terminal",cwd:y.cwd}}}),l=i.some(y=>y.id===t.terminalActiveId)?t.terminalActiveId:i[0]?.id??null,c=!!t.browserCollapsed&&n.length>0,u=!!t.terminalCollapsed&&i.length>0,m=c?[]:n,f=c?null:a,g=u?[]:i,h=u?null:l;let b=t.mode;return b==="terminal"&&g.length===0&&!u&&(b="browser"),b==="browser"&&m.length===0&&g.length>0&&(b="terminal"),{mode:b,browserTabs:m,browserActiveId:f,terminalTabs:g,terminalActiveId:h,stashedBrowserTabs:n,stashedBrowserActiveId:a,stashedTerminalTabs:i,stashedTerminalActiveId:l}}const GC=w.createContext(null);function Pce({children:e}){const[t,n]=w.useState(()=>{try{return localStorage.getItem("markus_sidebar_c")==="1"}catch{return!1}}),a=w.useMemo(()=>Lce(),[]),[i,l]=w.useState(a.mode),[c,u]=w.useState(a.browserTabs),[m,f]=w.useState(a.terminalTabs),[g,h]=w.useState(a.browserActiveId),[b,y]=w.useState(a.terminalActiveId),[k,C]=w.useState(!1),[T,A]=w.useState(!1),[M,I]=w.useState("l0"),[B,G]=w.useState(null),j=w.useCallback(xe=>I(xe),[]),O=w.useCallback(xe=>G(xe),[]);w.useEffect(()=>{const xe=Ie=>{if(!(Ie instanceof HTMLElement))return!1;const ne=Ie.tagName;return ne==="INPUT"||ne==="TEXTAREA"||ne==="SELECT"?!0:Ie.isContentEditable},Me=Ie=>{if(!(Ie.target instanceof Element))return;const ne=document.activeElement;if(xe(ne)){const Ce=ne===Ie.target||ne.contains(Ie.target),Pe=!!Ie.target.closest("[data-keep-edit-focus]"),$e=xe(Ie.target)||!!Ie.target.closest('input, textarea, select, [contenteditable="true"]'),ue=!!Ie.target.closest(".xterm");!Ce&&!Pe&&!$e&&!ue&&ne.blur()}const U=Ie.target.closest("[data-keyboard-pane]");if(!U)return;const re=U.getAttribute("data-keyboard-pane");if(!(re!=="l0"&&re!=="l1"&&re!=="l2"&&re!=="content")&&(I(re),re==="l0")){const Pe=Ie.target.closest("[data-l0-page-id]")?.getAttribute("data-l0-page-id");Pe&&G(Pe)}};return document.addEventListener("pointerdown",Me,!0),()=>document.removeEventListener("pointerdown",Me,!0)},[]);const F=w.useRef(a.stashedBrowserTabs.length>0?a.stashedBrowserTabs:a.browserTabs),Y=w.useRef(a.stashedBrowserActiveId??a.browserActiveId),q=w.useRef(a.stashedTerminalTabs.length>0?a.stashedTerminalTabs:a.terminalTabs),V=w.useRef(a.stashedTerminalActiveId??a.terminalActiveId),z=w.useRef(a.browserActiveId),J=w.useRef(a.terminalActiveId),D=w.useRef(a.browserTabs),ee=w.useRef(a.terminalTabs),R=w.useRef(a.mode);z.current=g,J.current=b,D.current=c,ee.current=m,R.current=i,w.useEffect(()=>{(a.mode==="terminal"||a.browserTabs.length===0)&&window.markusDesktop?.browser?.hideAll?.()},[]),w.useEffect(()=>{const xe=c.length===0&&F.current.length>0,Me=m.length===0&&q.current.length>0,Ie=xe?F.current:c,ne=Me?q.current:m,U=Ie.map(_ce).filter(Pe=>!!Pe),re=ne.filter(Pe=>Pe.payload.kind==="terminal").map(Pe=>({id:Pe.id,title:Pe.title,cwd:Pe.payload.kind==="terminal"?Pe.payload.cwd:void 0})),Ce={mode:i,browserTabs:U,browserActiveId:xe?Y.current:g,terminalTabs:re,terminalActiveId:Me?V.current:b,browserCollapsed:xe,terminalCollapsed:Me};try{localStorage.setItem(UC,JSON.stringify(Ce))}catch{}},[i,c,g,m,b]);const te=w.useCallback(xe=>n(xe),[]),le=w.useCallback(()=>n(xe=>!xe),[]),ke=w.useCallback(()=>{window.markusDesktop?.browser?.hideAll?.()},[]),$=w.useCallback(xe=>{l(Me=>Me===xe?Me:(xe==="terminal"&&ke(),xe))},[ke]),W=w.useCallback(xe=>{if(xe==="terminal"){if(ke(),l("terminal"),n(!0),m.length>0)return;if(q.current.length>0){const Pe=q.current,$e=V.current&&Pe.some(ue=>ue.id===V.current)?V.current:Pe[0].id;f(Pe),y($e),V.current=$e;return}const U=Qi(),re=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;_s(re);const Ce={id:U,title:"Terminal",payload:{kind:"terminal",terminalId:re,title:"Terminal"}};q.current=[Ce],f([Ce]),y(Ce.id),V.current=Ce.id;return}if(l("browser"),n(!0),c.length>0)return;if(F.current.length>0){const U=F.current,re=Y.current&&U.some(Ce=>Ce.id===Y.current)?Y.current:U[0].id;u(U),h(re),Y.current=re;return}const Me=Qi(),Ie=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,ne={id:Me,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:Ie}};F.current=[ne],u([ne]),h(ne.id),Y.current=ne.id},[c.length,m.length,ke]),oe=w.useCallback(xe=>{const Me=sc(xe),Ie=Qi(),ne=Rce(xe),U=Cce(xe);if(U&&FC(U),ne){xe.kind==="terminal"&&_s(xe.terminalId),l("terminal"),ke();const re=ee.current,Ce=re.find(ue=>sc(ue.payload)===Me)??q.current.find(ue=>sc(ue.payload)===Me);let Pe,$e;if(Ce)$e=Ce.id,Pe=re.some(ue=>ue.id===Ce.id)?re:Ou([Ce,...re]);else{const ue={id:Ie,title:Kk(xe),payload:xe};Pe=Ou([ue,...re]),$e=Ie}q.current=Pe,ee.current=Pe,f(Pe),y($e),V.current=$e,J.current=$e}else{l("browser");const re=D.current,Ce=re.find(ue=>sc(ue.payload)===Me)??F.current.find(ue=>sc(ue.payload)===Me);let Pe,$e;if(Ce)$e=Ce.id,Pe=re.some(ue=>ue.id===Ce.id)?re:Ou([Ce,...re]);else{const ue={id:Ie,title:Kk(xe),payload:xe};Pe=Ou([ue,...re]),$e=Ie}F.current=Pe,D.current=Pe,u(Pe),h($e),Y.current=$e,z.current=$e}n(!0)},[ke]),L=w.useCallback(xe=>{const Me=D.current,Ie=Me.findIndex(he=>he.id===xe);if(Ie>=0){const he=Me[Ie]?.payload,Ve=Me.filter(Ft=>Ft.id!==xe),dt=z.current,ot=(Me.some(Ft=>Ft.id===dt)?dt:Me[0]?.id??null)===xe||Ve.length===0?Ve[Math.min(Ie,Ve.length-1)]?.id??null:void 0;F.current=Ve,D.current=Ve,u(Ve),Ve.length===0&&R.current==="browser"&&C(!1),ot!==void 0&&(h(ot),Y.current=ot,z.current=ot),Fg(he);return}const ne=ee.current,U=ne.findIndex(he=>he.id===xe);if(U<0)return;const re=ne[U]?.payload,Ce=ne.filter(he=>he.id!==xe),Pe=J.current,ue=(ne.some(he=>he.id===Pe)?Pe:ne[0]?.id??null)===xe||Ce.length===0?Ce[Math.min(U,Ce.length-1)]?.id??null:void 0;q.current=Ce,ee.current=Ce,f(Ce),Ce.length===0&&R.current==="terminal"&&C(!1),ue!==void 0&&(y(ue),V.current=ue,J.current=ue),Ug(re)},[]),Ne=w.useCallback(()=>{const xe=D.current.map(Ie=>Ie.payload),Me=ee.current.map(Ie=>Ie.payload);D.current=[],ee.current=[],F.current=[],Y.current=null,q.current=[],V.current=null,z.current=null,J.current=null,u([]),f([]),h(null),y(null),C(!1);for(const Ie of xe)Fg(Ie);for(const Ie of Me)Ug(Ie)},[]),qe=w.useCallback(xe=>{R.current==="terminal"?(y(xe),V.current=xe):(h(xe),Y.current=xe)},[]),me=w.useCallback((xe,Me)=>{u(Ie=>{let ne=!1;const U=Ie.map(re=>{if(re.payload.kind!=="url"||re.payload.browserId!==xe)return re;const Ce=Me.url??re.payload.url,Pe=Me.title||re.payload.title||Ce,$e=Me.pageId??re.payload.pageId;return Ce===re.payload.url&&Pe===(re.payload.title||re.title)&&$e===re.payload.pageId&&Pe===re.title?re:(ne=!0,{...re,title:Pe,payload:{...re.payload,url:Ce,title:Pe,...$e!=null?{pageId:$e}:{}}})});return ne&&(F.current=U),ne?U:Ie})},[]),ze=w.useCallback((xe,Me)=>{f(Ie=>{let ne=!1;const U=Ie.map(re=>{if(re.payload.kind!=="terminal"||re.payload.terminalId!==xe)return re;const Ce=Me.title||re.payload.title||re.title,Pe=Me.cwd??re.payload.cwd;return Ce===re.title&&Pe===re.payload.cwd&&Ce===(re.payload.title||re.title)?re:(ne=!0,{...re,title:Ce,payload:{...re.payload,title:Ce,...Pe!=null?{cwd:Pe}:{}}})});return ne&&(q.current=U),ne?U:Ie})},[]),Ue=w.useCallback(()=>{R.current==="terminal"?(f(xe=>xe.length===0?xe:(q.current=xe,J.current&&(V.current=J.current),[])),y(null)):(u(xe=>xe.length===0?xe:(F.current=xe,z.current&&(Y.current=z.current),[])),h(null),ke()),C(!1)},[ke]),je=w.useCallback(()=>{if(R.current==="terminal"&&m.length>0){if(l("browser"),c.length>0){n(!0);return}if(F.current.length>0){const $e=F.current,ue=Y.current&&$e.some(he=>he.id===Y.current)?Y.current:$e[0].id;u($e),h(ue),Y.current=ue,n(!0);return}const re=Qi(),Ce=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,Pe={id:re,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:Ce}};F.current=[Pe],u([Pe]),h(Pe.id),Y.current=Pe.id,n(!0);return}const xe=Qi(),Me=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;let Ie,ne=!1,U=!1;l("browser"),u(re=>{if(re.length>0)return F.current=re,z.current&&(Y.current=z.current),U=!0,Ie=null,[];if(F.current.length>0){ne=!0;const Pe=F.current;return Ie=Y.current&&Pe.some(ue=>ue.id===Y.current)?Y.current:Pe[0].id,Pe}ne=!0;const Ce={id:xe,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:Me}};return F.current=[Ce],Ie=Ce.id,[Ce]}),ne&&n(!0),U?(h(null),C(!1),ke()):Ie!=null&&(h(Ie),Y.current=Ie)},[c.length,m.length,ke]),Ye=w.useCallback(()=>{if(R.current==="browser"&&c.length>0){if(l("terminal"),ke(),m.length>0){n(!0);return}if(q.current.length>0){const $e=q.current,ue=V.current&&$e.some(he=>he.id===V.current)?V.current:$e[0].id;f($e),y(ue),V.current=ue,n(!0);return}const re=Qi(),Ce=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;_s(Ce);const Pe={id:re,title:"Terminal",payload:{kind:"terminal",terminalId:Ce,title:"Terminal"}};q.current=[Pe],f([Pe]),y(Pe.id),V.current=Pe.id,n(!0);return}const xe=Qi(),Me=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;_s(Me);let Ie,ne=!1,U=!1;l("terminal"),ke(),f(re=>{if(re.length>0)return q.current=re,J.current&&(V.current=J.current),U=!0,Ie=null,[];if(q.current.length>0){ne=!0;const Pe=q.current;return Ie=V.current&&Pe.some(ue=>ue.id===V.current)?V.current:Pe[0].id,Pe}ne=!0;const Ce={id:xe,title:"Terminal",payload:{kind:"terminal",terminalId:Me,title:"Terminal"}};return q.current=[Ce],Ie=Ce.id,[Ce]}),ne&&n(!0),U?(y(null),C(!1)):Ie!=null&&(y(Ie),V.current=Ie)},[c.length,m.length,ke]),xt=w.useCallback(xe=>{const Me=R.current==="terminal"?m:c;if(Me.length<2)return;const Ie=R.current==="terminal"?J.current:z.current,U=(Math.max(0,Me.findIndex(Ce=>Ce.id===Ie))+xe+Me.length)%Me.length,re=Me[U].id;R.current==="terminal"?(y(re),V.current=re):(h(re),Y.current=re)},[c,m]),mt=w.useCallback(xe=>{const Ie=(R.current==="terminal"?m:c)[xe];Ie&&(R.current==="terminal"?(y(Ie.id),V.current=Ie.id):(h(Ie.id),Y.current=Ie.id))},[c,m]),ft=w.useCallback(()=>{if(R.current==="terminal"){const Me=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;oe({kind:"terminal",terminalId:Me,title:"Terminal"});return}const xe=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;oe({kind:"url",url:"about:blank",title:"New Tab",browserId:xe})},[oe]),rt=w.useCallback(xe=>{const Me=ee.current,Ie=Me.findIndex($e=>$e.payload.kind==="terminal"&&$e.payload.terminalId===xe);if(Ie<0){Bg(xe),window.markusDesktop?.terminal?.destroy(xe);return}const ne=Me[Ie];if(Me.length>1){L(ne.id);return}Bg(xe),window.markusDesktop?.terminal?.destroy(xe);const U=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;_s(U);const re=ne.payload.kind==="terminal"&&(ne.payload.title||ne.title)||"Terminal",Ce=ne.payload.kind==="terminal"?ne.payload.cwd:void 0,Pe={id:ne.id,title:re,payload:{kind:"terminal",terminalId:U,title:re,cwd:Ce}};q.current=[Pe],f([Pe]),y(Pe.id),V.current=Pe.id,R.current!=="terminal"&&l("terminal")},[L]),jt=w.useCallback(xe=>C(xe),[]),ht=w.useCallback(()=>C(xe=>!xe),[]),He=i==="terminal"?m:c,Et=i==="terminal"?b:g,Kt=He.find(xe=>xe.id===Et)??He[0]??null,ie=Kt?.payload??null,tt=He.length>0,it=w.useMemo(()=>({leftCollapsed:t,setLeftCollapsed:te,toggleLeftCollapsed:le,keyboardPane:M,setKeyboardPane:j,l0FocusPageId:B,setL0FocusPageId:O,rightPanelMode:i,setRightPanelMode:$,switchRightPanelMode:W,rightPanel:ie,rightPanelOpen:tt,rightPanelTabs:He,activeRightPanelTabId:Kt?.id??null,openRightPanel:oe,closeRightPanel:Ne,closeRightPanelTab:L,setActiveRightPanelTab:qe,updateRightPanelBrowserTab:me,updateRightPanelTerminalTab:ze,toggleRightPanel:je,toggleTerminalPanel:Ye,collapseRightPanelOnly:Ue,cycleRightPanelTab:xt,activateRightPanelTabAt:mt,openNewRightPanelTab:ft,handleTerminalExit:rt,rightPanelFullscreen:k,setRightPanelFullscreen:jt,toggleRightPanelFullscreen:ht,hostAvailable:T,setHostAvailable:A}),[t,te,le,M,j,B,O,i,$,W,ie,tt,He,Kt,oe,Ne,L,qe,me,ze,je,Ye,Ue,xt,mt,ft,rt,k,jt,ht,T]);return o.jsx(GC.Provider,{value:it,children:e})}function kp(){return w.useContext(GC)}const Oce={tsk:"task",req:"requirement",proj:"project",dlv:"deliverable",agt:"agent",team:"team"};function KC(e){return{task:"task",requirement:"requirement",project:"project",deliverable:"deliverable",agent:"agent",team:"team"}[e]}const VC={task:"☑️",requirement:"🎯",project:"📁",deliverable:"📦",agent:"🤖",team:"👥"},WC={task:"Task",requirement:"Requirement",project:"Project",deliverable:"Deliverable",agent:"Agent",team:"Team"},Hce=/^(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}$/i;function Fm(e){return Hce.test(e.trim())}function Bce(e){const t=e.split("_")[0]?.toLowerCase();return t?Oce[t]:void 0}async function YC(e){const t=await vce(e)??e;t.startsWith("tsk_")?yt.navigate(ce.WORK,{openTask:t}):t.startsWith("req_")?yt.navigate(ce.WORK,{openRequirement:t}):t.startsWith("proj_")?yt.navigate(ce.WORK,{projectId:t}):t.startsWith("dlv_")?yt.navigate(ce.DELIVERABLES,{openDeliverable:t}):t.startsWith("agt_")?yt.navigate(ce.TEAM,{agentId:t}):t.startsWith("team_")&&yt.navigate(ce.TEAM,{selectTeam:t})}const rm=new Map,Hu=new Map,im=new Map;function zce(e,t){const n=im.get(e)??new Set;return n.add(t),im.set(e,n),()=>{n.delete(t),n.size===0&&im.delete(e)}}function qce(e){rm.delete(e);for(const t of im.get(e)??[])t()}const $ce=["task:update","task:create","requirement:update","requirement:updated","deliverable:update","deliverable:updated","project:update","team:update"];function Fce(e){const t=e?.payload??{};for(const n of["taskId","requirementId","deliverableId","projectId","teamId","id"]){const a=t[n];if(typeof a=="string")return a}for(const n of["requirement","deliverable","task","project","team"]){const a=t[n];if(a&&typeof a.id=="string")return a.id}}let Vk=!1;function Uce(){if(Vk)return;Vk=!0;const e=t=>{const n=Fce(t);n&&qce(n)};for(const t of $ce)try{di.on(t,e)}catch{}}async function Gce(e,t){const n={id:e,type:t,title:e,loading:!1};try{switch(t){case"task":{const a=await Se.tasks.get(e);return{...n,title:a.task.title,status:a.task.status,blockedReason:a.task.blockedReason??null}}case"requirement":{const a=await Se.requirements.get(e),i=a.requirement;return{...n,title:a.requirement.title,status:a.requirement.status,blockedReason:i.blockedReason??null}}case"project":{const a=await Se.projects.get(e);return{...n,title:a.project.name,status:a.project.status,summary:a.project.description}}case"deliverable":{const a=await Se.deliverables.get(e);return{...n,title:a.deliverable.title,status:a.deliverable.status,summary:a.deliverable.summary,deliverable:a.deliverable}}case"agent":{const a=await Se.agents.get(e);return{...n,title:a.name,summary:a.role}}case"team":{const i=(await Se.teams.list()).teams.find(l=>l.id===e);return{...n,title:i?.name??e,notFound:!i}}}}catch{}return{...n,notFound:!0}}function QC(e,t){const n=t??Bce(e),[a,i]=w.useState(()=>rm.get(e)??{id:e,type:n??"task",title:e,loading:!!n});return w.useEffect(()=>{if(!n){i({id:e,type:"task",title:e,loading:!1,notFound:!0});return}let l=!0;const c=m=>{const f=m?rm.get(e):void 0;if(f){i(f);return}m&&i(h=>({...h,type:n,loading:!0}));let g=Hu.get(e);g||(g=Gce(e,n),Hu.set(e,g)),g.then(h=>{rm.set(e,h),Hu.delete(e),l&&i(h)}).catch(()=>{Hu.delete(e),l&&i({id:e,type:n,title:e,loading:!1,notFound:!0})})};c(!0),Uce();const u=zce(e,()=>c(!1));return()=>{l=!1,u()}},[e,n]),a}function JC(e){const t=(e.split("_")[0]?.length??3)+1;return e.length>t+8?`${e.slice(0,t+8)}…`:e}function wc({id:e,type:t,label:n}){const a=QC(e,t),i=kp(),l=VC[a.type]??"🔗",c=n??(a.loading||a.notFound?JC(e):a.title),u=m=>{if(m.preventDefault(),m.stopPropagation(),a.type==="deliverable"&&a.deliverable&&i?.hostAvailable){i.openRightPanel({kind:"deliverable",deliverable:a.deliverable});return}YC(e)};return o.jsxs("span",{"data-entity-link":e,className:"inline-flex items-center gap-0.5 px-1 py-0.5 rounded bg-brand-500/10 text-brand-500 text-xs font-medium cursor-pointer hover:bg-brand-500/20 transition-colors align-baseline",onClick:u,title:`${WC[a.type]}: ${a.notFound?e:a.title} (${e})`,children:[o.jsx("span",{className:"text-[10px]",children:l}),o.jsx("span",{className:"truncate max-w-[240px] align-baseline",children:c})]})}function Kce({id:e,type:t,label:n}){const{t:a}=ut(["common"]),i=QC(e,t),[l,c]=w.useState(!1),u=kp(),m=VC[i.type]??"🔗",f=()=>{if(i.type==="deliverable"&&i.deliverable){if(u?.hostAvailable){u.openRightPanel({kind:"deliverable",deliverable:i.deliverable});return}c(!0);return}YC(e)},g=i.loading?JC(e):n||(i.notFound?e:i.title);return o.jsxs("span",{className:"not-prose block my-2",children:[o.jsxs("button",{type:"button",onClick:f,className:"w-full max-w-md text-left rounded-xl border border-border-default bg-surface-elevated/30 hover:border-brand-500/40 hover:bg-surface-elevated/50 transition-colors px-3 py-2.5 flex items-start gap-2.5",children:[o.jsx("span",{className:"inline-flex items-center justify-center w-8 h-8 rounded-lg text-sm shrink-0 bg-brand-500/10",children:m}),o.jsxs("span",{className:"flex-1 min-w-0 block",children:[o.jsxs("span",{className:"flex items-center gap-2 flex-wrap",children:[o.jsx("span",{className:"text-[10px] uppercase tracking-wide text-fg-tertiary font-medium",children:WC[i.type]}),i.status&&(()=>{const h=i.type==="task"||i.type==="requirement"?OS(i.status,a,i.blockedReason):null;return o.jsx("span",{"data-testid":"entity-status","data-status":i.status,className:`px-1.5 py-0.5 text-[10px] rounded font-medium ${h?.tone?.chip??An[cJ(i.type,i.status)].chip}`,children:h?.label??i.status})})()]}),o.jsx("span",{className:`block text-sm font-medium truncate mt-0.5 ${i.notFound?"font-mono text-fg-tertiary":"text-fg-primary"}`,children:g}),i.summary&&i.summary.trim()!==i.title.trim()&&o.jsx("span",{className:"block text-xs text-fg-tertiary mt-0.5 line-clamp-1",children:i.summary})]}),o.jsx("svg",{className:"w-4 h-4 text-fg-tertiary shrink-0 mt-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),l&&i.deliverable&&o.jsx(kce,{item:i.deliverable,onClose:()=>c(!1),onOpenInPage:h=>{c(!1),yt.navigate(ce.DELIVERABLES,{openDeliverable:h})}})]})}function Vce(e){return e==null||!Number.isFinite(e)?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Wce(e){if((e.includes("\\")?"\\":"/")==="/")return{segments:e.split("/").filter(Boolean),root:"/"};const n=e.match(/^([A-Za-z]:\\)(.*)$/);return n?{segments:n[2].split("\\").filter(Boolean),root:n[1]}:{segments:e.split("\\").filter(Boolean),root:""}}function Yce(e,t,n){if(t.length===0)return e||".";const a=t.join(n);return n==="/"?e==="/"?`/${a}`:`${e}${a}`:`${e}${a}`}const Wk={md:"MD",markdown:"MD",html:"HTML",htm:"HTML",json:"JSON",csv:"CSV",pdf:"PDF",docx:"DOCX",doc:"DOC",xlsx:"XLSX",xls:"XLS",pptx:"PPTX",ppt:"PPT",txt:"TXT",ts:"TS",tsx:"TSX",js:"JS",jsx:"JSX",py:"PY",css:"CSS"},Gg={png:"IMG",jpg:"IMG",jpeg:"IMG",gif:"IMG",webp:"IMG",svg:"IMG",bmp:"IMG",ico:"IMG",avif:"IMG",mp3:"AUDIO",wav:"AUDIO",ogg:"AUDIO",flac:"AUDIO",aac:"AUDIO",m4a:"AUDIO",mp4:"VIDEO",webm:"VIDEO",mov:"VIDEO",mkv:"VIDEO",avi:"VIDEO",m4v:"VIDEO"};function Qce(e,t=!1){if(t)return tn.t("home:recentDeliverables.directory");if(!e)return tn.t("home:recentDeliverables.file");const n=e.replace(/^\./,"").toLowerCase();return Gg[n]?Gg[n]:Wk[n]?Wk[n]:n.slice(0,6).toUpperCase()||tn.t("home:recentDeliverables.file")}function Jce({path:e,entries:t,onNavigate:n,onOpenFile:a,onReveal:i,onCopyPath:l,emptyText:c}){const{t:u}=ut(["common"]),{segments:m,root:f}=w.useMemo(()=>Wce(e),[e]),g=e.includes("\\")?"\\":"/",[h,b]=w.useState(!1),y=async()=>{const C=l?.(e);try{if(C&&typeof C.then=="function"&&await C===!1)return}catch{return}b(!0),window.setTimeout(()=>b(!1),2e3)},k=w.useMemo(()=>{const C=[];f&&C.push({label:f.replace(/[\\/]$/,""),path:f});let T=f;for(let A=0;A<m.length;A++)T=Yce(f,m.slice(0,A+1),g),C.push({label:m[A],path:T});return C},[f,m,g]);return o.jsxs("div",{className:"flex flex-col min-h-0 h-full",children:[(i||l)&&o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border-subtle bg-surface-secondary/50 shrink-0","data-testid":"dir-top-actions",children:[o.jsx("span",{className:"flex-1 min-w-0 text-[11px] font-mono text-fg-tertiary truncate",title:e,children:e}),l&&o.jsx("button",{className:`shrink-0 text-[11px] cursor-pointer transition-colors ${h?"text-green-500 font-medium":"text-fg-secondary hover:text-fg-primary hover:underline"}`,onClick:()=>{y()},title:u(h?"common:ambassador.copied":"common:copyPath"),children:h?`✓ ${u("common:ambassador.copied")}`:u("common:copyPath")}),i&&o.jsx("button",{className:"shrink-0 text-[11px] text-fg-secondary hover:text-fg-primary hover:underline cursor-pointer",onClick:()=>i(e),children:u("common:revealInFileBrowser")})]}),o.jsx("div",{className:"flex items-center gap-1 flex-wrap px-3 py-2 border-b border-border-subtle bg-surface-secondary/50 text-xs shrink-0","data-testid":"dir-breadcrumb",children:k.map((C,T)=>{const A=T===k.length-1;return o.jsxs("span",{className:"flex items-center gap-1 min-w-0",children:[T>0&&o.jsx("span",{className:"text-fg-tertiary select-none",children:"/"}),A?o.jsx("span",{className:"text-fg-primary font-medium truncate max-w-[180px]",children:C.label}):o.jsx("button",{className:"text-fg-secondary hover:text-brand-500 hover:underline truncate max-w-[140px] cursor-pointer",onClick:()=>n(C.path),title:C.path,children:C.label})]},C.path)})}),o.jsx("div",{className:"flex-1 overflow-y-auto py-1",children:t.length===0?o.jsx("p",{className:"px-4 py-8 text-center text-xs text-fg-tertiary",children:c??u("common:emptyDirectory")}):t.map(C=>{const T=C.isDirectory?void 0:Qce(C.ext),A=!!C.ext&&!!Gg[C.ext.replace(/^\./,"").toLowerCase()];return o.jsxs("button",{className:"w-full flex items-center gap-2.5 px-3 py-1.5 text-left hover:bg-surface-overlay/60 transition-colors cursor-pointer group",onClick:()=>C.isDirectory?n(C.path):a(C.path),title:C.path,children:[C.isDirectory?o.jsx("svg",{className:"w-4 h-4 shrink-0 text-blue-400",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{d:"M3.5 3A1.5 1.5 0 002 4.5v11A1.5 1.5 0 003.5 17h13a1.5 1.5 0 001.5-1.5v-8A1.5 1.5 0 0016.5 6h-6.53a.5.5 0 01-.354-.146L8.706 4.854A1.5 1.5 0 007.586 4H3.5z"})}):A?o.jsx("svg",{className:"w-4 h-4 shrink-0 text-purple-400",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M4 5a2 2 0 012-2h3.5a1.5 1.5 0 011.06.44l1.5 1.5c.14.14.331.22.53.22H14a2 2 0 012 2v7a2 2 0 01-2 2H6a2 2 0 01-2-2V5zm4.5 4.5a.75.75 0 00-1.5 0v3a.75.75 0 001.06.68l2.5-1.5a.75.75 0 000-1.32l-2.5-1.5a.75.75 0 00-.56-.06z",clipRule:"evenodd"})}):o.jsx("svg",{className:"w-4 h-4 shrink-0 text-fg-tertiary group-hover:text-fg-secondary",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})}),o.jsx("span",{className:"flex-1 min-w-0 text-sm text-fg-primary truncate",children:C.name}),T&&o.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded text-[10px] font-mono uppercase bg-surface-overlay/60 text-fg-tertiary border border-border-subtle",children:T}),!C.isDirectory&&o.jsx("span",{className:"shrink-0 text-[11px] text-fg-tertiary tabular-nums",children:Vce(C.size)})]},C.path)})})]})}const Yk=new Set(["pdf","docx","xlsx"]),Xce=30*1024*1024;function Zce({data:e,reference:t,onFallback:n}){const{t:a}=ut("deliverables"),i=(e.format||"").toLowerCase().replace(/^\./,""),l=w.useRef(null),[c,u]=w.useState("loading"),[m,f]=w.useState(""),[g,h]=w.useState(0),[b,y]=w.useState(null),[k,C]=w.useState(1),[T,A]=w.useState(1),M=w.useCallback(()=>{n?.()},[n]),I=w.useCallback(async()=>{if(t)try{await Se.files.reveal(t);return}catch{}M()},[t,M]),B=w.useCallback(j=>{const O=l.current?.querySelector(`canvas[data-page="${j}"]`);O&&(O.scrollIntoView({behavior:"smooth",block:"start"}),C(j))},[]);w.useEffect(()=>{const j=l.current;if(!j||!Yk.has(i)){u("ready");return}let O=!1,F;return u("loading"),f(""),j.innerHTML="",(async()=>{try{i==="pdf"?F=await rde(e.streamUrl,j,{onReady:Y=>{y(Y),C(1)},zoom:T}):i==="docx"?F=await ide(e.streamUrl,j):i==="xlsx"&&(F=await sde(e.streamUrl,j)),O||u("ready")}catch(Y){O||(u("error"),f(String(Y)))}})(),()=>{O=!0,F&&F(),j.innerHTML=""}},[e.streamUrl,i,g,T]);const G=!Yk.has(i);return o.jsx("div",{className:"flex flex-col h-full min-h-0",children:G?o.jsx(ede,{format:i,size:e.size,onOpenSystem:I,onDownload:()=>M()}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-3 py-1.5 border-b border-border-default/60 bg-surface-elevated/40",children:[o.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wide",children:i}),e.name&&o.jsx("span",{className:"text-[11px] text-fg-secondary truncate flex-1 min-w-0",title:e.name,children:e.name}),e.size!=null&&e.size>Xce&&o.jsx("span",{className:"text-[10px] text-amber-500 shrink-0",children:a("officeLargeFile")}),i==="pdf"&&b!=null&&o.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[o.jsx("button",{onClick:()=>B(Math.max(1,k-1)),disabled:k<=1,className:"w-6 h-6 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary disabled:opacity-30",children:"‹"}),o.jsxs("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:[k,"/",b]}),o.jsx("button",{onClick:()=>B(Math.min(b??1,k+1)),disabled:k>=(b??1),className:"w-6 h-6 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary disabled:opacity-30",children:"›"})]}),i==="pdf"&&o.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[o.jsx("button",{onClick:()=>A(j=>Math.max(.5,+(j-.25).toFixed(2))),disabled:T<=.5,className:"w-6 h-6 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary disabled:opacity-30",children:"−"}),o.jsxs("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:[Math.round(T*100),"%"]}),o.jsx("button",{onClick:()=>A(j=>Math.min(3,+(j+.25).toFixed(2))),disabled:T>=3,className:"w-6 h-6 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary disabled:opacity-30",children:"+"})]}),o.jsx("button",{onClick:I,className:"shrink-0 text-[10px] text-fg-tertiary hover:text-fg-secondary px-1.5 py-0.5 rounded hover:bg-surface-overlay transition-colors",children:a("officeOpenSystem")})]}),o.jsxs("div",{className:"flex-1 min-h-0 overflow-auto p-3",children:[c==="loading"&&o.jsxs("div",{className:"flex items-center justify-center h-full text-fg-tertiary",children:[o.jsxs("svg",{className:"animate-spin w-4 h-4 mr-2",viewBox:"0 0 24 24",fill:"none",children:[o.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),o.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),o.jsx("span",{className:"text-xs",children:a("officeLoading")})]}),c==="error"&&o.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[o.jsx("span",{className:"text-[11px] text-fg-tertiary",children:a("officeFailed")}),o.jsx("span",{className:"text-[10px] text-fg-muted max-w-xs truncate",children:m}),o.jsxs("div",{className:"flex gap-2 mt-1",children:[o.jsx("button",{onClick:()=>h(j=>j+1),className:"px-3 py-1.5 text-xs bg-brand-600 text-on-brand rounded-lg hover:bg-brand-500 transition-colors",children:a("officeRetry")}),o.jsx("button",{onClick:I,className:"px-3 py-1.5 text-xs border border-border-default text-fg-secondary rounded-lg hover:bg-surface-elevated transition-colors",children:a("officeOpenSystem")})]})]}),o.jsx("div",{ref:l,className:c==="loading"?"hidden":""})]})]})})}function ede({format:e,size:t,onOpenSystem:n,onDownload:a}){const{t:i}=ut("deliverables");return o.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-center px-6",children:[o.jsx("div",{className:"w-12 h-12 rounded-xl bg-surface-elevated flex items-center justify-center text-xl",children:"📄"}),o.jsx("div",{className:"text-xs text-fg-secondary",children:i("officeNoInlinePreview",{format:e})}),t!=null&&o.jsx("div",{className:"text-[10px] text-fg-tertiary",children:i("officeSize",{size:tde(t)})}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("button",{onClick:n,className:"px-3 py-1.5 text-xs bg-brand-600 text-on-brand rounded-lg hover:bg-brand-500 transition-colors",children:i("officeOpenSystem")}),o.jsx("button",{onClick:a,className:"px-3 py-1.5 text-xs border border-border-default text-fg-secondary rounded-lg hover:bg-surface-elevated transition-colors",children:i("officeDownload")})]})]})}function tde(e){return e==null||!Number.isFinite(e)?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function nde(){const e=Uint8Array.prototype;typeof e.toHex!="function"&&(e.toHex=function(){let i="",l=0,c=this.length,u;for(;l<c;++l)u=this[l],i+=(u>>>4).toString(16)+(u&15).toString(16);return i});const t=Map.prototype;typeof t.getOrInsertComputed!="function"&&(t.getOrInsertComputed=function(i,l){if(this.has(i))return this.get(i);const c=l(i);return this.set(i,c),c}),typeof t.getOrInsert!="function"&&(t.getOrInsert=function(i,l){return this.has(i)?this.get(i):(this.set(i,l),l)});const n=Promise;typeof n.try!="function"&&(n.try=function(i){return new Promise(l=>l(i()))});const a=typeof Iterator<"u"?Iterator.prototype:null;a&&typeof a.join!="function"&&(a.join=function(i=","){let l="",c=!0;for(const u of this)c||(l+=i),l+=String(u),c=!1;return l})}nde();let _0=null;function ade(){if(!_0){const t=`
|
|
815
815
|
if (typeof Uint8Array.prototype.toHex !== 'function') {
|
|
816
816
|
Uint8Array.prototype.toHex = function() {
|
|
817
817
|
var s = '', i = 0, n = this.length, b;
|
|
@@ -844,14 +844,14 @@ if (ip && typeof ip.join !== 'function') {
|
|
|
844
844
|
};
|
|
845
845
|
}
|
|
846
846
|
await import("${new URL("/assets/pdf.worker.min-CHFwMXne.mjs",import.meta.url).toString()}");
|
|
847
|
-
`;_0=URL.createObjectURL(new Blob([t],{type:"text/javascript"}))}return _0}async function rde(e,t,n){const a=await fa(()=>import("./pdf-DMRcuM1e.js"),[]);a.GlobalWorkerOptions.workerSrc=ade();const i=await a.getDocument({url:e}).promise,l=[];for(let c=1;c<=i.numPages;c++){const u=await i.getPage(c),m=u.getViewport({scale:1.5*n.zoom}),f=document.createElement("canvas");f.width=Math.floor(m.width),f.height=Math.floor(m.height),f.style.width=`${Math.floor(m.width)}px`,f.style.height=`${Math.floor(m.height)}px`,f.style.marginBottom="8px",f.style.boxShadow="0 1px 4px rgba(0,0,0,0.15)",f.style.borderRadius="2px";const g=f.getContext("2d");if(!g)throw new Error("canvas 2d context unavailable");await u.render({canvas:f,canvasContext:g,viewport:m}).promise,f.dataset.page=String(c),t.appendChild(f),l.push(f)}return n.onReady(i.numPages),()=>{for(const c of l)c.remove();i.cleanup()}}async function ide(e,t){const{renderAsync:n}=await fa(async()=>{const{renderAsync:i}=await import("./docx-preview-
|
|
847
|
+
`;_0=URL.createObjectURL(new Blob([t],{type:"text/javascript"}))}return _0}async function rde(e,t,n){const a=await fa(()=>import("./pdf-DMRcuM1e.js"),[]);a.GlobalWorkerOptions.workerSrc=ade();const i=await a.getDocument({url:e}).promise,l=[];for(let c=1;c<=i.numPages;c++){const u=await i.getPage(c),m=u.getViewport({scale:1.5*n.zoom}),f=document.createElement("canvas");f.width=Math.floor(m.width),f.height=Math.floor(m.height),f.style.width=`${Math.floor(m.width)}px`,f.style.height=`${Math.floor(m.height)}px`,f.style.marginBottom="8px",f.style.boxShadow="0 1px 4px rgba(0,0,0,0.15)",f.style.borderRadius="2px";const g=f.getContext("2d");if(!g)throw new Error("canvas 2d context unavailable");await u.render({canvas:f,canvasContext:g,viewport:m}).promise,f.dataset.page=String(c),t.appendChild(f),l.push(f)}return n.onReady(i.numPages),()=>{for(const c of l)c.remove();i.cleanup()}}async function ide(e,t){const{renderAsync:n}=await fa(async()=>{const{renderAsync:i}=await import("./docx-preview-YtzS0xMU.js");return{renderAsync:i}},[]),a=await fetch(e).then(i=>{if(!i.ok)throw new Error(`HTTP ${i.status}`);return i.blob()});if(a.size===0)throw new Error("empty docx");return await n(a,t,void 0,{inWrapper:!0,ignoreWidth:!0,ignoreHeight:!1,breakPages:!0,className:"office-docx"}),()=>{t.innerHTML=""}}async function sde(e,t){const n=await fa(()=>import("./xlsx-CNerDvZX.js"),[]),a=await fetch(e).then(u=>{if(!u.ok)throw new Error(`HTTP ${u.status}`);return u.arrayBuffer()});if(a.byteLength===0)throw new Error("empty xlsx");const i=n.read(a,{type:"array"});if(!i.SheetNames||i.SheetNames.length===0)throw new Error("no sheets");const l=n.utils.sheet_to_html(i.Sheets[i.SheetNames[0]],{id:"office-xlsx-sheet",editable:!1});t.innerHTML=l;const c=document.createElement("style");return c.textContent=`
|
|
848
848
|
#office-xlsx-sheet { border-collapse: collapse; font-size: 12px; color: var(--fg-primary, #333); }
|
|
849
849
|
#office-xlsx-sheet td, #office-xlsx-sheet th {
|
|
850
850
|
border: 1px solid var(--border-default, #ddd); padding: 4px 8px; white-space: nowrap;
|
|
851
851
|
background: var(--surface-primary, #fff);
|
|
852
852
|
}
|
|
853
853
|
#office-xlsx-sheet th { background: var(--surface-elevated, #f3f4f6); font-weight: 600; }
|
|
854
|
-
`,t.prepend(c),()=>{t.innerHTML=""}}let Hc=null;const Kg=new Set;function XC(){for(const e of Kg)e()}function ode(e){Hc!==e&&(Hc=e,XC())}function lde(){Hc!==null&&(Hc=null,XC())}function Qk(){return Hc}function cde(e){return Kg.add(e),()=>{Kg.delete(e)}}w.lazy(()=>fa(()=>import("./MarkdownMessage-B-9NMrYX.js"),[]).then(e=>({default:e.MarkdownMessage})));const dde=w.lazy(()=>fa(()=>import("./ContentRenderer-iGJdjFvn.js"),[]).then(e=>({default:e.ContentRenderer})));let Po=[],Jk=60;function ude(e){const t=w.useRef(e);t.current=e;const[n]=w.useState(()=>++Jk);return w.useEffect(()=>{const a=()=>t.current();Po.push(a);const i=l=>{l.key==="Escape"&&Po[Po.length-1]===a&&(l.preventDefault(),a())};return window.addEventListener("keydown",i,!0),()=>{window.removeEventListener("keydown",i,!0),Po=Po.filter(l=>l!==a),Po.length===0&&(Jk=60)}},[]),n}const Xk=500,Zi=new Map,Um=new Set,sm=new Map;let om=null;function mde(){if(Zi.size<=Xk)return;const e=Zi.size-Xk,t=Zi.keys();for(let n=0;n<e;n++){const{value:a,done:i}=t.next();if(i)break;Zi.delete(a)}}function Zk(e,t){Zi.delete(e),Zi.set(e,t),mde()}function e4(e){const t=sm.get(e);if(t)for(const n of t)n()}function pde(){om=null;const e=[...Um];Um.clear(),e.length!==0&&Se.files.check(e).then(({results:t})=>{for(const[n,a]of Object.entries(t))Zk(n,a),e4(n)}).catch(()=>{for(const t of e)Zk(t,{exists:!1,isFile:!1,type:"unknown"}),e4(t)})}function fde(e){Zi.has(e)||Um.has(e)||(Um.add(e),om&&clearTimeout(om),om=setTimeout(pde,30))}function hde(e,t){let n=sm.get(e);return n||(n=new Set,sm.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&sm.delete(e)}}function gde(e){const t=w.useCallback(i=>hde(e,i),[e]),n=w.useCallback(()=>Zi.get(e),[e]),a=w.useSyncExternalStore(t,n,n);return w.useEffect(()=>{fde(e)},[e]),a}function bde(e){const t=e.includes("\\")?"\\":"/",n=e.lastIndexOf(t);return n<=0?t==="/"?"/":e.slice(0,2):e.slice(0,n)}function yde({filePath:e,onClose:t}){const{t:n}=ut("common"),a=ude(t),[i,l]=w.useState(e),[c,u]=w.useState(!0),[m,f]=w.useState(null),[g,h]=w.useState(""),[b,y]=w.useState(""),[k,C]=w.useState(""),[T,A]=w.useState(""),[M,I]=w.useState(""),[B,G]=w.useState(null),[j,O]=w.useState(!1);w.useEffect(()=>{u(!0),f(null),h(""),G(null),Se.files.preview(i).then(z=>{if(z.type==="directory"&&Array.isArray(z.entries)){y("directory"),C(z.name),G(z.entries);return}y(z.type),C(z.name),A(z.mimeType||""),h(typeof z.content=="string"?z.content:""),I(z.streamUrl||(z.path?Se.files.streamUrl(z.path):"")||(z.type==="audio"||z.type==="video"?Se.files.streamUrl(i):""))}).catch(z=>{f(String(z?.message||z))}).finally(()=>{u(!1)})},[i]);const F=k||i.split(/[/\\]/).pop()||i,Y=b==="directory"||i!==e,q=()=>l(z=>bde(z)),V=()=>{navigator.clipboard?.writeText(i).then(()=>{O(!0),setTimeout(()=>O(!1),1500)}).catch(()=>{})};return Jo.createPortal(o.jsx("div",{className:"fixed inset-0 bg-black/40 flex items-center justify-center",style:{zIndex:a},onClick:t,children:o.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl shadow-2xl w-[90vw] max-w-3xl max-h-[85vh] flex flex-col overflow-hidden",onClick:z=>z.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-default bg-surface-elevated/50 shrink-0",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[b==="directory"&&o.jsx("svg",{className:"w-4 h-4 shrink-0 text-blue-400",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{d:"M3.5 3A1.5 1.5 0 002 4.5v11A1.5 1.5 0 003.5 17h13a1.5 1.5 0 001.5-1.5v-8A1.5 1.5 0 0016.5 6h-6.53a.5.5 0 01-.354-.146L8.706 4.854A1.5 1.5 0 007.586 4H3.5z"})}),b!=="directory"&&o.jsx("svg",{className:"w-4 h-4 shrink-0 text-fg-secondary",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})}),o.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:F}),o.jsx("span",{className:"text-xs text-fg-tertiary truncate hidden sm:inline",children:i})]}),o.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[Y&&o.jsxs("button",{className:"text-xs text-fg-secondary hover:text-fg-primary px-2 py-1 rounded hover:bg-surface-elevated transition-colors",onClick:q,title:n("backToParentDir"),children:["← ",n("goUp")]}),o.jsx("button",{className:"text-xs text-fg-secondary hover:text-fg-primary px-2 py-1 rounded hover:bg-surface-elevated transition-colors",onClick:V,title:n("copyPath"),children:j?`✓ ${n("ambassador.copied")}`:n("copyPath")}),o.jsx("button",{className:"text-xs text-fg-secondary hover:text-fg-primary px-2 py-1 rounded hover:bg-surface-elevated transition-colors",onClick:()=>Se.files.reveal(i),title:n("revealInFileExplorer"),children:o.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{d:"M4.5 17a2.5 2.5 0 01-2.5-2.5v-9A2.5 2.5 0 014.5 3h3.672a1.5 1.5 0 011.06.44L10.56 4.77a.5.5 0 00.354.147H15.5A2.5 2.5 0 0118 7.417v7.083A2.5 2.5 0 0115.5 17h-11z"})})}),o.jsx("button",{className:"text-fg-secondary hover:text-fg-primary p-1 rounded hover:bg-surface-elevated transition-colors",onClick:t,children:o.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[c&&o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx("div",{className:"w-5 h-5 border-2 border-brand-500/30 border-t-brand-500 rounded-full animate-spin"})}),m&&o.jsxs("div",{className:"text-center py-12 text-fg-secondary text-sm",children:[o.jsx("p",{className:"text-red-400 mb-1",children:n("filePreview.loadFailed")}),o.jsx("p",{className:"text-xs text-fg-tertiary",children:m})]}),!c&&!m&&b==="directory"&&B&&o.jsx(Jce,{path:i,entries:B,onNavigate:z=>l(z),onOpenFile:z=>l(z),onReveal:z=>Se.files.reveal(z),onCopyPath:z=>{navigator.clipboard?.writeText(z).then(()=>{O(!0),setTimeout(()=>O(!1),1500)}).catch(()=>{})}}),!c&&!m&&b==="office"&&M&&o.jsx(Zce,{data:{format:(i.split(".").pop()||"pdf").toLowerCase(),streamUrl:M,name:F},reference:i,onFallback:()=>{Se.files.reveal(i)}}),!c&&!m&&b==="image"&&g&&o.jsx("div",{className:"flex justify-center",children:o.jsx("img",{src:`data:${T||"image/png"};base64,${g}`,alt:F,className:"max-w-full rounded"})}),!c&&!m&&b==="audio"&&M&&o.jsx("audio",{controls:!0,preload:"metadata",src:M,className:"w-full"}),!c&&!m&&b==="video"&&M&&o.jsx("video",{controls:!0,preload:"metadata",src:M,className:"w-full max-h-[60vh] rounded-lg bg-black"}),!c&&!m&&(b==="binary"||!g&&b!=="image"&&b!=="audio"&&b!=="video"&&b!=="directory")&&o.jsxs("div",{className:"text-center py-8 space-y-3",children:[o.jsx("p",{className:"text-sm text-fg-secondary",children:n("filePreview.unsupported")}),o.jsx("button",{className:"px-3 py-2 text-xs rounded-lg bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors",onClick:()=>{Se.files.reveal(i)},children:n("revealInFileExplorer")})]}),!c&&!m&&g&&b!=="image"&&b!=="audio"&&b!=="video"&&b!=="binary"&&b!=="directory"&&o.jsx(w.Suspense,{fallback:o.jsx("div",{className:"text-xs text-fg-tertiary",children:n("loading")}),children:o.jsx(dde,{content:g,format:b==="text"?"text":b,className:"text-sm"})})]})]})}),document.body)}function vde({path:e}){const{t}=ut("common"),n=gde(e),a=kp(),i=n?.exists??!1,l=n?.type==="markdown"||n?.type==="html"||n?.type==="json"||n?.type==="text"||n?.type==="image"||n?.type==="audio"||n?.type==="video"||n?.type==="office"||n?.type==="directory",c=w.useCallback(f=>{if(f.preventDefault(),f.stopPropagation(),!!i)if(l){if(a?.hostAvailable){a.openRightPanel({kind:"file",path:e});return}ode(e)}else Se.files.reveal(e)},[i,l,e,a]),u="inline w-3 h-3 align-[-0.125em]",m=l?o.jsx("svg",{className:u,viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4zm2 6a1 1 0 011-1h6a1 1 0 110 2H7a1 1 0 01-1-1zm1 3a1 1 0 100 2h6a1 1 0 100-2H7z",clipRule:"evenodd"})}):o.jsx("svg",{className:u,viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})});return n?i?o.jsxs("code",{"data-file-path-link":"ready",className:"bg-brand-500/10 px-1.5 py-0.5 rounded text-xs font-mono text-brand-500 cursor-pointer hover:bg-brand-500/20 transition-colors border border-brand-500/20 hover:border-brand-500/40 break-all",onClick:c,title:t(l?"clickToPreview":"clickToRevealInExplorer"),role:"button",tabIndex:0,children:[o.jsxs("span",{className:"whitespace-nowrap",children:[m,e.charAt(0)]}),e.slice(1)]}):o.jsx("code",{"data-file-path-link":"missing",className:"bg-surface-secondary/50 px-1.5 py-0.5 rounded text-xs font-mono text-fg-tertiary border border-border-default/30 line-through decoration-fg-tertiary/30 break-all",title:t("fileNotFound"),children:e}):o.jsx("code",{"data-file-path-link":"loading",className:"bg-surface-secondary px-1.5 py-0.5 rounded text-xs font-mono text-fg-secondary break-all",children:e})}function xde(){const e=w.useSyncExternalStore(cde,Qk,Qk);return e?o.jsx(yde,{filePath:e,onClose:lde},e):null}let D0=null;function wde(){return D0||(D0=fa(()=>import("./mermaid.core-BlPZWkyC.js").then(e=>e.b9),__vite__mapDeps([0,1])).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:"loose",fontFamily:"inherit"}),e))),D0}function kde(){const e=document.documentElement;return e.classList.contains("light")?!1:e.classList.contains("dark")||e.classList.contains("cyberpunk")||e.classList.contains("mono")?!0:!window.matchMedia("(prefers-color-scheme: light)").matches}function Sde(e){const t=window.matchMedia("(prefers-color-scheme: dark)");t.addEventListener("change",e);const n=new MutationObserver(e);return n.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>{t.removeEventListener("change",e),n.disconnect()}}function Cde(){return kde()}function Ade(){return w.useSyncExternalStore(Sde,Cde)}function ZC({code:e}){const{t}=ut("common"),n=w.useRef(null),[a,i]=w.useState(null),[l,c]=w.useState(!0),u=w.useId(),m=w.useRef(0),f=w.useRef(null),g=Ade();return w.useEffect(()=>{if(!e.trim()||f.current&&f.current.code===e&&f.current.dark===g)return;let h=!1;return c(!0),i(null),m.current+=1,(async()=>{try{const b=await wde();if(h)return;b.default.initialize({startOnLoad:!1,theme:g?"dark":"default",securityLevel:"loose",fontFamily:"inherit"});const y=`mermaid-${u.replace(/:/g,"")}-${m.current}`,{svg:k}=await b.default.render(y,e.trim());if(h)return;n.current&&(n.current.innerHTML=k,f.current={code:e,dark:g})}catch(b){h||i(b instanceof Error?b.message:String(b))}finally{h||c(!1)}})(),()=>{h=!0}},[e,u,g]),a?o.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[o.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-red-500/10 border-b border-red-500/20",children:[o.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})}),o.jsx("span",{className:"text-[10px] font-medium text-red-400",children:t("markdown.mermaidRenderError")})]}),a&&o.jsx("div",{className:"px-3 py-2 bg-surface-secondary/60 text-[11px] font-mono text-red-300/90 whitespace-pre-wrap break-words border-b border-red-500/10 max-h-40 overflow-y-auto",children:a}),o.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):o.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[l&&o.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[o.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),t("markdown.renderingDiagram")]}),o.jsx("div",{ref:n,className:`flex justify-center [&>svg]:max-w-full${l?" hidden":""}`})]})}const Tde="/assets/viz-global-C_AyN6D9.js";let Bu=!1,I0=null;function Ede(){return Bu?Promise.resolve():new Promise((e,t)=>{const n=document.querySelector("script[data-plantuml-viz]");if(n){globalThis.Viz?(Bu=!0,e()):(n.addEventListener("load",()=>{Bu=!0,e()}),n.addEventListener("error",()=>t(new Error("Failed to load viz-global.js"))));return}const a=document.createElement("script");a.setAttribute("data-plantuml-viz",""),a.src=Tde,a.onload=()=>{Bu=!0,e()},a.onerror=()=>t(new Error("Failed to load viz-global.js")),document.head.appendChild(a)})}function Nde(){return I0||(I0=Ede().then(()=>fa(()=>import("./plantuml-DezRDxd4.js"),[]))),I0}let t4=Promise.resolve();function Mde(e,t){const n=t4.then(()=>new Promise((a,i)=>{Nde().then(({renderToString:l})=>{const c=e.split(/\r\n|\r|\n/);l(c,a,i,{dark:t})}).catch(i)}));return t4=n.then(()=>{},()=>{}),n}function jde(){const e=document.documentElement;return e.classList.contains("light")?!1:e.classList.contains("dark")||e.classList.contains("cyberpunk")||e.classList.contains("mono")?!0:!window.matchMedia("(prefers-color-scheme: light)").matches}function Rde(e){const t=window.matchMedia("(prefers-color-scheme: dark)");t.addEventListener("change",e);const n=new MutationObserver(e);return n.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>{t.removeEventListener("change",e),n.disconnect()}}function _de(){return w.useSyncExternalStore(Rde,()=>jde())}function eA({code:e}){const{t}=ut("common"),[n,a]=w.useState(null),[i,l]=w.useState(null),[c,u]=w.useState(!0),m=w.useRef(null),f=_de();return w.useEffect(()=>{if(!e.trim()||m.current&&m.current.code===e&&m.current.dark===f)return;let g=!1;return u(!0),l(null),Mde(e.trim(),f).then(h=>{g||(a(h),m.current={code:e,dark:f})}).catch(h=>{g||l(h instanceof Error?h.message:String(h))}).finally(()=>{g||u(!1)}),()=>{g=!0}},[e,f]),i?o.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[o.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-red-500/10 border-b border-red-500/20",children:[o.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})}),o.jsx("span",{className:"text-[10px] font-medium text-red-400",children:t("markdown.plantumlRenderError")})]}),i&&o.jsx("div",{className:"px-3 py-2 bg-surface-secondary/60 text-[11px] font-mono text-red-300/90 whitespace-pre-wrap break-words border-b border-red-500/10 max-h-40 overflow-y-auto",children:i}),o.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):o.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[c&&o.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[o.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),t("markdown.renderingDiagram")]}),n&&o.jsx("div",{className:`flex justify-center [&>svg]:max-w-full${c?" hidden":""}`,dangerouslySetInnerHTML:{__html:n}})]})}function Dde(e,t,n){const a=e.cloneNode(!0),i=n?.fontFamily??"-apple-system,BlinkMacSystemFont,'Segoe UI','Noto Sans',Helvetica,Arial,sans-serif",l=n?.fontSize??"15px",c=n?.headingScales??{h1:1.6,h2:1.35,h3:1.15,h4:1},u=t==="light"?{bg:"#ffffff",text:"#24292f",heading:"#1f2328",strong:"#1f2328",link:"#0969da",codeBg:"#eff1f3",codeText:"#24292f",preBg:"#f6f8fa",preText:"#24292f",preBorder:"#d0d7de",border:"#d0d7de",blockquoteBorder:"#d0d7de",blockquoteText:"#656d76",tableBorder:"#d0d7de",tableHeaderBg:"#f6f8fa",tableHeaderText:"#24292f",hrColor:"#d8dee4"}:{bg:"#0d1117",text:"#e6edf3",heading:"#f0f6fc",strong:"#f0f6fc",link:"#58a6ff",codeBg:"#161b22",codeText:"#e6edf3",preBg:"#161b22",preText:"#e6edf3",preBorder:"#30363d",border:"#30363d",blockquoteBorder:"#3b82f6",blockquoteText:"#8b949e",tableBorder:"#30363d",tableHeaderBg:"#161b22",tableHeaderText:"#e6edf3",hrColor:"#21262d"},m={p:`margin:0 0 10px;color:${u.text};line-height:1.7;`,h1:`font-size:${c.h1}em;font-weight:700;color:${u.heading};margin:20px 0 10px;line-height:1.3;border-bottom:1px solid ${u.border};padding-bottom:6px;`,h2:`font-size:${c.h2}em;font-weight:700;color:${u.heading};margin:18px 0 8px;line-height:1.3;`,h3:`font-size:${c.h3}em;font-weight:600;color:${u.heading};margin:14px 0 6px;line-height:1.3;`,h4:`font-size:${c.h4}em;font-weight:600;color:${u.heading};margin:12px 0 4px;`,strong:`font-weight:600;color:${u.strong};`,em:"font-style:italic;",a:`color:${u.link};text-decoration:underline;`,ul:"padding-left:1.5em;margin:0 0 10px;",ol:"padding-left:1.5em;margin:0 0 10px;",li:`margin:3px 0;line-height:1.7;color:${u.text};`,blockquote:`border-left:3px solid ${u.blockquoteBorder};padding:2px 0 2px 14px;margin:10px 0;color:${u.blockquoteText};`,hr:`border:none;border-top:1px solid ${u.hrColor};margin:20px 0;`,table:"border-collapse:collapse;width:100%;margin:10px 0;",thead:`background:${u.tableHeaderBg};`,th:`border:1px solid ${u.tableBorder};padding:8px 12px;text-align:left;font-weight:600;color:${u.tableHeaderText};`,td:`border:1px solid ${u.tableBorder};padding:8px 12px;color:${u.text};`,img:"max-width:100%;height:auto;"};function f(g){g.removeAttribute("class");const h=g.tagName.toLowerCase();if(h==="pre"){g.setAttribute("style",`background:${u.preBg};color:${u.preText};padding:14px;border-radius:6px;overflow-x:auto;margin:10px 0;font-size:0.88em;line-height:1.5;border:1px solid ${u.preBorder};`);const b=g.querySelector("code");b&&(b.removeAttribute("class"),b.setAttribute("style","background:transparent;padding:0;border-radius:0;color:inherit;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;font-size:inherit;"));return}h==="code"?g.setAttribute("style",`background:${u.codeBg};color:${u.codeText};padding:2px 6px;border-radius:4px;font-size:0.9em;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;`):m[h]&&g.setAttribute("style",m[h]),Array.from(g.children).forEach(f)}return a.removeAttribute("class"),Array.from(a.children).forEach(g=>f(g)),`<div style="background:${u.bg};color:${u.text};padding:20px 24px;font-family:${i};font-size:${l};line-height:1.7;max-width:800px;">${a.innerHTML}</div>`}async function tA(e){try{return await navigator.clipboard.writeText(e),!0}catch{try{const t=document.createElement("textarea");t.value=e,t.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0",document.body.appendChild(t),t.select();const n=document.execCommand("copy");return document.body.removeChild(t),n}catch{return!1}}}async function xpe(e,t,n,a){const i=Dde(e,t,a);try{return await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([i],{type:"text/html"}),"text/plain":new Blob([n],{type:"text/plain"})})]),{ok:!0,method:"html"}}catch{return{ok:await tA(n),method:"text"}}}function Vg({code:e,language:t,children:n}){const{t:a}=ut("common"),[i,l]=w.useState("rendered"),[c,u]=w.useState(!1),m=w.useCallback(async()=>{await tA(e)&&(u(!0),setTimeout(()=>u(!1),1800))},[e]);return o.jsxs("div",{className:"not-prose my-2 rounded-lg overflow-hidden border border-border-subtle",children:[o.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle bg-surface-secondary",children:[o.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:t}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:()=>l("rendered"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${i==="rendered"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsxs("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]}),a("markdown.viewRendered")]})}),o.jsx("button",{onClick:()=>l("source"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${i==="source"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}),a("markdown.viewSource")]})})]})]}),i==="rendered"?o.jsx("div",{children:n}):o.jsxs("div",{className:"relative group/source",children:[o.jsx("pre",{className:"p-3 overflow-x-auto text-xs font-mono text-fg-secondary bg-surface-secondary leading-relaxed whitespace-pre-wrap break-words",children:e}),o.jsx("button",{onClick:m,className:"absolute top-2 right-2 p-1.5 rounded-md bg-surface-elevated/80 hover:bg-surface-overlay text-fg-tertiary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all opacity-0 group-hover/source:opacity-100",title:a("markdown.copyContent"),children:c?o.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]})}const Ide=[ZC,eA];function Lde(e){for(const t of w.Children.toArray(e))if(w.isValidElement(t)&&typeof t.props?.className=="string"){const n=t.props.className;return hce(n)}return null}function kc(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(!e)return"";if(Array.isArray(e))return e.map(kc).join("");if(w.isValidElement(e)){const t=e.props;return kc(t.children)}return""}function Pde({children:e}){const{t}=ut("common"),n=Lde(e),a=w.useRef(null),[i,l]=w.useState(!1),[c,u]=w.useState("rendered"),m=w.useCallback(async()=>{let g;c==="source"?g=kc(e):g=a.current?.querySelector("code")?.textContent??"";try{await navigator.clipboard.writeText(g),l(!0),setTimeout(()=>l(!1),1800)}catch{}},[c,e]);if(w.Children.toArray(e).some(g=>w.isValidElement(g)&&Ide.includes(g.type))){const g=kc(e),h=n==="mermaid"||n==="plantuml"?n:"diagram";return o.jsx(Vg,{code:g,language:h,children:e})}return n==="mermaid"||n==="plantuml"?o.jsx(o.Fragment,{children:e}):o.jsxs("div",{className:"not-prose relative group/code my-2 rounded-lg overflow-hidden bg-surface-secondary border border-border-subtle",children:[n&&o.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle",children:[o.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:fce(n)}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:()=>u("rendered"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${c==="rendered"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("markdown.viewRendered")}),o.jsx("button",{onClick:()=>u("source"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${c==="source"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("markdown.viewSource")})]})]}),o.jsxs("div",{className:"relative",children:[c==="rendered"?o.jsx("pre",{ref:a,className:"p-3 overflow-x-auto text-xs [&>code]:p-0 [&>code]:rounded-none [&>code]:text-fg-secondary",children:w.Children.map(e,g=>w.isValidElement(g)?w.cloneElement(g,{style:{background:"transparent",padding:0}}):g)}):o.jsx("pre",{className:"p-3 overflow-x-auto text-xs font-mono text-fg-secondary whitespace-pre-wrap break-words",children:kc(e)}),o.jsx("button",{onClick:m,className:"absolute top-2 right-2 p-1.5 rounded-md bg-surface-elevated/80 hover:bg-surface-overlay text-fg-tertiary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all opacity-0 group-hover/code:opacity-100",title:t("markdown.copyContent"),children:i?o.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]})}const n4="#mention:",Gm="#entity:",Ode=/^\[([^\]]+)\]\(#entity:((tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)$/i,nA=/^(workflow|task|requirement|project|deliverable|agent|team):(.+)$/,Wg="text-brand-500 hover:text-brand-500 underline break-all cursor-pointer";function Yg(e){return e.type==="text"?e.value??"":(e.children??[]).map(Yg).join("")}function Hde(e){return e.type==="text"&&(e.value??"").trim()===""}function Bde(e){if(!e?.children)return null;const t=e.children.filter(a=>!Hde(a));if(t.length!==1)return null;const n=t[0];if(n.type==="element"&&n.tagName==="a"){const a=n.properties?.href;if(!a)return null;const i=Yg(n);if(a.startsWith(Gm))return{id:a.slice(Gm.length)};const l=a.match(nA);return l&&l[1]!=="workflow"?{id:l[2],type:KC(l[1]),label:i}:null}if(n.type==="element"&&n.tagName==="code"){const a=Yg(n).trim();if(Fm(a))return{id:a}}if(n.type==="text"){const a=(n.value??"").trim();if(Fm(a))return{id:a}}return null}const zde={p:({children:e})=>o.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:e}),h1:({children:e})=>o.jsx("h1",{className:"text-base font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h2:({children:e})=>o.jsx("h2",{className:"text-sm font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h3:({children:e})=>o.jsx("h3",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h4:({children:e})=>o.jsx("h4",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h5:({children:e})=>o.jsx("h5",{className:"text-xs font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h6:({children:e})=>o.jsx("h6",{className:"text-xs font-medium mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),ul:({children:e})=>o.jsx("ul",{className:"list-disc pl-4 mb-2 space-y-0.5",children:e}),ol:({children:e,start:t})=>o.jsx("ol",{start:t,className:"list-decimal pl-7 mb-2 space-y-0.5",children:e}),li:({children:e,value:t})=>o.jsx("li",{value:t,className:"leading-relaxed text-fg-secondary marker:text-fg-secondary",children:e}),code:({children:e,className:t})=>{const n=typeof e=="string"?e:String(e??""),a=n.trim();if(t?.includes("language-plantuml")||mce(a))return o.jsx(Vg,{code:a,language:"plantuml",children:o.jsx(eA,{code:a})});if(t?.includes("language-mermaid"))return o.jsx(Vg,{code:a,language:"mermaid",children:o.jsx(ZC,{code:a})});if(t?.includes("language-"))return o.jsx("code",{className:`${t} text-fg-secondary font-mono text-xs`,children:e});if(Fm(n))return o.jsx(wc,{id:n.trim()});const i=n.match(Ode);return i?o.jsx(wc,{id:i[2],label:i[1]}):tce(n)?o.jsx(vde,{path:n}):o.jsx("code",{className:"bg-surface-secondary px-1.5 py-0.5 rounded text-xs font-mono text-brand-500 break-all",children:e})},pre:({children:e})=>o.jsx(Pde,{children:e}),strong:({children:e})=>o.jsx("strong",{className:"font-bold text-fg-primary",children:e}),em:({children:e})=>o.jsx("em",{className:"italic text-fg-secondary",children:e}),del:({children:e})=>o.jsx("del",{className:"line-through text-fg-tertiary",children:e}),blockquote:({children:e})=>o.jsx("blockquote",{className:"border-l-2 border-brand-500 pl-3 my-2 text-fg-secondary italic",children:e}),a:({href:e,children:t})=>o.jsx("a",{href:e,className:Wg,children:t}),hr:()=>o.jsx("hr",{className:"border-border-default my-3"}),table:({children:e})=>o.jsx("div",{className:"overflow-x-auto my-2",children:o.jsx("table",{className:"min-w-full text-sm border-collapse border border-border-default",children:e})}),thead:({children:e})=>o.jsx("thead",{className:"bg-surface-secondary",children:e}),tbody:({children:e})=>o.jsx("tbody",{className:"divide-y divide-border-default",children:e}),tr:({children:e})=>o.jsx("tr",{className:"hover:bg-surface-elevated/50 transition-colors",children:e}),th:({children:e})=>o.jsx("th",{className:"px-3 py-2 text-left text-sm font-semibold text-fg-primary border border-border-default",children:e}),td:({children:e})=>o.jsx("td",{className:"px-3 py-2 text-sm text-fg-primary border border-border-default",children:e})},qde=/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i;function $de(e){const t=Ub(e);return Xle(e)&&qde.test(t.split("?")[0]??t)}function Fde(e,t){const n=Ub(e);if(n.startsWith("/")||n.startsWith("~/")||/^[A-Za-z]:\//.test(n)||n.startsWith("//"))return n;if((n.startsWith("./")||n.startsWith("../"))&&t){const i=((t.replace(/\\/g,"/").endsWith("/")?t.replace(/\\/g,"/"):`${t.replace(/\\/g,"/")}/`)+n).split("/"),l=[];for(const c of i)c===".."?l.pop():c!=="."&&c!==""&&l.push(c);return"/"+l.join("/")}return n}function Ude(e){return`/api/files/image?path=${encodeURIComponent(e)}`}function Gde(e,t){return $de(e)?Ude(Fde(e,t)):null}const Oo=new Map,oc=new Map,Kde=w.memo(function({src:t,alt:n,onPreview:a,basePath:i}){const{t:l}=ut("common"),c=w.useMemo(()=>Gde(t,i)??t,[t,i]),u=c.startsWith("/api/files/image?"),m=Oo.get(c),f=oc.get(c),[g,h]=w.useState(m??(u?null:c)),[b,y]=w.useState(!!m),[k,C]=w.useState(!!f),[T,A]=w.useState(f??null),[M,I]=w.useState(0),B=w.useRef(0),G=w.useCallback(O=>{oc.set(c,O),A(O),C(!0),y(!1)},[c]),j=w.useCallback(()=>{Oo.delete(c),oc.delete(c),C(!1),A(null),y(!1),h(u?null:`${c}${c.includes("?")?"&":"?"}retry=${Date.now()}`),I(O=>O+1)},[c,u]);return w.useEffect(()=>{if(!u)return;const O=Oo.get(c);if(O){h(O),y(!0),C(!1),A(null);return}const F=oc.get(c);if(F!==void 0){C(!0),A(F),y(!1);return}const Y=++B.current;C(!1),A(null),y(!1),h(null),(async()=>{try{const q=await fetch(c,{credentials:"same-origin"});if(Y!==B.current)return;if(!q.ok){let J=`HTTP ${q.status}`;try{const D=await q.json();D.error&&(J=D.error)}catch{}throw new Error(J)}const V=await q.blob();if(Y!==B.current)return;if(V.size===0)throw new Error("Empty image response");if(V.type&&!V.type.startsWith("image/")&&!V.type.includes("octet-stream"))throw new Error(`Unexpected content-type: ${V.type}`);const z=URL.createObjectURL(V);Oo.set(c,z),h(z),y(!0),C(!1),A(null)}catch(q){if(Y!==B.current)return;const V=q instanceof Error?q.message:String(q);console.warn("[MarkdownImage] failed to load local image",c,q),G(V)}})()},[u,c,M]),w.useEffect(()=>{if(u)return;const O=oc.get(c);if(O!==void 0){C(!0),A(O),y(!1);return}h(c),y(!!Oo.get(c)),C(!1),A(null)},[c,u,M]),k?o.jsxs("button",{type:"button",onClick:j,title:T??l("markdown.clickToRetry"),className:"inline-flex items-center gap-1.5 px-3 py-2 text-xs text-fg-tertiary bg-surface-elevated rounded-lg border border-border-default hover:bg-surface-overlay hover:text-fg-secondary cursor-pointer transition-colors max-w-full",children:[o.jsxs("svg",{className:"w-4 h-4 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:[o.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),o.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),o.jsx("polyline",{points:"21 15 16 10 5 21"})]}),o.jsxs("span",{className:"truncate",children:[l("markdown.imageLoadFailed"),T?` (${T})`:""]})]}):o.jsxs("span",{className:"inline-block align-middle max-w-full",children:[!b&&o.jsx("span",{className:"block w-full min-h-[80px] max-w-[400px] bg-surface-elevated rounded-lg animate-pulse"}),g?o.jsx("img",{src:g,alt:n??"",onLoad:()=>{u||Oo.set(c,c),y(!0)},onError:()=>{G("Image decode failed")},onClick:()=>a?.(g),className:`max-w-full h-auto rounded-lg cursor-pointer hover:opacity-90 transition-opacity my-1${b?"":" absolute opacity-0 pointer-events-none"}`,style:{maxHeight:"400px",objectFit:"contain"}}):null]})});async function a4(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch image (${t.status})`);return t.blob()}async function Vde(e){if(e.type==="image/png")return e;const t=await createImageBitmap(e),n=document.createElement("canvas");n.width=t.width,n.height=t.height;const a=n.getContext("2d");if(!a)throw new Error("Canvas unavailable");return a.drawImage(t,0,0),t.close(),new Promise((i,l)=>{n.toBlob(c=>c?i(c):l(new Error("PNG encode failed")),"image/png")})}function Wde(e,t){try{const i=(e.startsWith("data:")?"":new URL(e,window.location.href).pathname).split("/").pop()||"";if(i&&/\.(png|jpe?g|gif|webp|svg|bmp)$/i.test(i))return decodeURIComponent(i)}catch{}return`image.${(t.type.split("/")[1]||"png").replace("jpeg","jpg")}`}function wpe({src:e,onClose:t}){const{t:n}=ut("common"),[a,i]=w.useState(null),[l,c]=w.useState(null);$s(!0),w.useEffect(()=>{const h=b=>{b.key==="Escape"&&t()};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[t]);const u=w.useCallback(h=>{i(h),window.setTimeout(()=>i(null),1600)},[]),m=w.useCallback(async h=>{if(h.stopPropagation(),!l){c("copy");try{const b=await a4(e),y=await Vde(b);await navigator.clipboard.write([new ClipboardItem({"image/png":y})]),u(n("imageCopied"))}catch{u(n("imageCopyFailed"))}finally{c(null)}}},[l,u,e,n]),f=w.useCallback(async h=>{if(h.stopPropagation(),!l){c("download");try{const b=await a4(e),y=URL.createObjectURL(b),k=document.createElement("a");k.href=y,k.download=Wde(e,b),document.body.appendChild(k),k.click(),k.remove(),URL.revokeObjectURL(y),u(n("imageDownloaded"))}catch{u(n("imageDownloadFailed"))}finally{c(null)}}},[l,u,e,n]),g="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-white/10 hover:bg-white/20 text-white text-sm transition-colors disabled:opacity-50";return Jo.createPortal(o.jsxs("div",{className:"fixed inset-0 z-[9999] bg-black/80 flex items-center justify-center p-4",onClick:t,children:[o.jsxs("div",{className:"absolute top-4 right-4 z-10 flex items-center gap-2",onClick:h=>h.stopPropagation(),children:[o.jsxs("button",{type:"button",className:g,onClick:m,disabled:!!l,title:n("copyImage"),children:[o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),o.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),n("copy")]}),o.jsxs("button",{type:"button",className:g,onClick:f,disabled:!!l,title:n("downloadImage"),children:[o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"}),o.jsx("polyline",{points:"7 10 12 15 17 10"}),o.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),n("downloadImage")]}),o.jsx("button",{type:"button",onClick:t,className:"w-10 h-10 rounded-full bg-white/10 hover:bg-white/20 flex items-center justify-center transition-colors",title:n("close"),children:o.jsxs("svg",{className:"w-6 h-6 text-white",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),a&&o.jsx("div",{className:"absolute top-16 left-1/2 -translate-x-1/2 z-10 px-3 py-1.5 rounded-lg bg-black/70 text-white text-xs",children:a}),o.jsx("img",{src:e,alt:n("fileEditor.preview"),className:"max-w-full max-h-[90vh] object-contain rounded-lg",onClick:h=>h.stopPropagation()})]}),document.body)}function Yde(e={}){const{onMentionClick:t,basePath:n,onImagePreview:a,contentRef:i,hostAvailable:l,openRightPanel:c}=e,u=w.useCallback((m,f)=>{const g=qk(f,n);if(g.kind!=="passthrough"){if(m.preventDefault(),m.stopPropagation(),g.kind==="fragment"){nce(i?.current??null,g.id);return}if(g.kind==="file"){l&&c?c({kind:"file",path:g.path,title:g.path.split(/[/\\]/).pop()}):Se.files.reveal(g.path).catch(()=>{});return}if(g.kind==="external"){if(l&&c&&/^https?:\/\//i.test(g.url)){c({kind:"url",url:g.url,title:g.url});return}Or(g.url)}}},[n,i,l,c]);return w.useMemo(()=>({...zde,img:({src:m,alt:f})=>o.jsx(Kde,{src:m??"",alt:f,onPreview:a,basePath:n},m??""),p:({children:m,node:f})=>{const g=Bde(f);return g?o.jsx(Kce,{id:g.id,type:g.type,label:g.label}):o.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:m})},a:({href:m,children:f})=>{if(m?.startsWith(n4)){const h=decodeURIComponent(m.slice(n4.length));return o.jsx("span",{className:`text-brand-500 font-medium${t?" cursor-pointer hover:underline":""}`,onClick:t?b=>{b.preventDefault(),b.stopPropagation(),t(h,b)}:void 0,title:h,children:f})}if(m?.startsWith(Gm))return o.jsx(wc,{id:m.slice(Gm.length)});{const h=m?.match(nA);if(h){const[,b,y]=h;if(b==="workflow")return o.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1 py-0.5 rounded bg-brand-500/10 text-brand-500 text-xs font-medium cursor-pointer hover:bg-brand-500/20 transition-colors",onClick:C=>{C.preventDefault(),C.stopPropagation(),yt.navigate(ce.WORK,{boardType:"workflows"})},title:`workflow: ${y}`,children:[o.jsx("span",{className:"text-[10px]",children:"⚙️"}),o.jsx("span",{children:f})]});const k=KC(b);if(k)return o.jsx(wc,{id:y,type:k,label:f})}}if(m&&Fm(m))return o.jsx(wc,{id:m.trim(),label:f});const g=qk(m,n);return g.kind==="fragment"||g.kind==="file"||g.kind==="external"?o.jsx("a",{href:m,className:Wg,onClick:h=>u(h,m),title:g.kind==="fragment"?`#${g.id}`:g.kind==="file"?g.path:g.url,children:f}):o.jsx("a",{href:m,className:Wg,onClick:h=>{Ko()&&m&&!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(m)&&h.preventDefault()},children:f})}}),[t,n,a,u])}const r4={agent:{icon:"✦",label:"Agent",color:"text-brand-500",gradient:"from-brand-500 to-purple-600",bg:"bg-brand-500/10",ring:"ring-brand-500/30"},team:{icon:"◈",label:"Team",color:"text-blue-600",gradient:"from-blue-500 to-blue-600",bg:"bg-blue-500/10",ring:"ring-blue-500/30"},skill:{icon:"⬡",label:"Skill",color:"text-green-600",gradient:"from-green-500 to-green-600",bg:"bg-green-500/10",ring:"ring-green-500/30"}},Qde=["development","devops","management","productivity","browser","custom","general"],Jde=[{label:"Tech",emojis:["✦","◈","⬡","⚡","🤖","🧠","💡","🎯","🔧","📦","🚀","💻","🛠️","⭐","🔥","💎","⚙️","🧩","🔌","💾","🖥️","📡","🔬","🧪","🏗️","📱","🎮","🕹️","📟","💽","🖨️","⌨️"]},{label:"People",emojis:["👤","👥","🧑💻","👨💼","👩🔬","🧙","🦸","🤝","💪","🎓","👷","🕵️","🧑🎨","🧑🏫","👨🚀","🥷","🧑🏭","🧑⚕️","🧑🔧","🧑🍳","👨🎤","🦹","🧝","🧞","🧑✈️","💂","🤴","👸","🧛","🧟","🧜","🧚"]},{label:"Objects",emojis:["📝","📊","🗂️","📁","🔍","🔑","🌐","💬","🔒","🎨","📐","🗃️","📋","✏️","🖊️","📌","📎","🧲","🪝","🧰","🪜","🧬","🔭","💊","🩺","📕","📗","📘","📙","📓","🗒️","📰"]},{label:"Symbols",emojis:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","♠️","♥️","♦️","♣️","🎵","🎶","💯","✅","❌","⭕","🔴","🟠","🟡","🟢","🔵","🟣","⚫","⚪","🟤","🔶","🔷","▶️","⏸️","⏹️"]},{label:"Nature",emojis:["🌟","🌈","🌊","🌿","🍀","🔮","💫","✨","🌙","☀️","🦋","🐉","🦊","🐺","🦅","🐙","🦁","🐯","🦄","🐲","🌸","🌺","🍄","🌵","🎄","🌴","🍁","🌻","🐝","🦎","🐍","🦈"]},{label:"Activity",emojis:["🎯","🏆","🥇","🎖️","🏅","🎪","🎭","🎬","🎤","🎧","🎼","🎹","🥁","🎸","🎺","🎻","⚽","🏀","🎾","🏐","🎲","🧸","🪁","🎰","🎳","🏹","🥊","🤺","⛷️","🏄","🚴","🧗"]}],Xde={shell:{icon:">",color:"bg-amber-500/15 text-amber-400 border-amber-500/30"},file:{icon:"◫",color:"bg-blue-500/15 text-blue-400 border-blue-500/30"},network:{icon:"◎",color:"bg-purple-500/15 text-purple-400 border-purple-500/30"},browser:{icon:"◉",color:"bg-brand-500/15 text-brand-400 border-brand-500/30"}};function L0({value:e,onChange:t,renderAs:n="span",className:a,editClassName:i,placeholder:l,multiline:c,readOnly:u}){const[m,f]=w.useState(!1),[g,h]=w.useState(e),b=w.useRef(null);if(w.useEffect(()=>{h(e)},[e]),w.useEffect(()=>{m&&b.current?.focus()},[m]),u){const I=e||l,G=`${a??""} ${!e?"text-fg-muted italic":""}`;return n==="h1"?o.jsx("h1",{className:G,children:I}):n==="p"?o.jsx("p",{className:G,children:I}):o.jsx("span",{className:G,children:I})}const y=()=>{f(!1),g!==e&&t(g)},k=()=>{h(e),f(!1)},C=I=>{I.key==="Escape"&&k(),I.key==="Enter"&&!c&&y()};if(m){const I=`bg-transparent outline-none w-full ${i??a??""} ring-1 ring-brand-500/50 rounded px-1 -mx-1`;return c?o.jsx("textarea",{ref:b,value:g,onChange:B=>h(B.target.value),onBlur:y,onKeyDown:C,className:`${I} resize-y min-h-[60px]`,placeholder:l}):o.jsx("input",{ref:b,value:g,onChange:B=>h(B.target.value),onBlur:y,onKeyDown:C,className:I,placeholder:l})}const T=e||l,A=!e,M="cursor-text hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all";return n==="h1"?o.jsx("h1",{onClick:()=>f(!0),className:`${a??""} ${M} ${A?"text-fg-muted italic":""}`,children:T}):n==="p"?o.jsx("p",{onClick:()=>f(!0),className:`${a??""} ${M} ${A?"text-fg-muted italic":""}`,children:T}):n==="badge"?o.jsx("span",{onClick:()=>f(!0),className:`${a??""} ${M} ${A?"text-fg-muted italic":""}`,children:T}):o.jsx("span",{onClick:()=>f(!0),className:`${a??""} ${M} ${A?"text-fg-muted italic":""}`,children:T})}function Zde({value:e,options:t,onChange:n,className:a,readOnly:i}){const[l,c]=w.useState(!1),[u,m]=w.useState(e),f=w.useRef(null),g=w.useRef(null);if(w.useEffect(()=>{l&&(m(e),setTimeout(()=>f.current?.focus(),0))},[l,e]),i)return o.jsx("span",{className:a,children:e});const h=t.filter(y=>y.toLowerCase().includes(u.toLowerCase())),b=y=>{const k=y.trim();k&&k!==e&&n(k),c(!1)};return l?o.jsxs("div",{ref:g,className:"relative inline-block",children:[o.jsx("input",{ref:f,value:u,onChange:y=>m(y.target.value),onKeyDown:y=>{y.key==="Enter"?(y.preventDefault(),b(u)):y.key==="Escape"&&c(!1)},onBlur:y=>{g.current?.contains(y.relatedTarget)||b(u)},className:`${a??""} bg-transparent outline-none ring-1 ring-brand-500/50 rounded w-28`}),h.length>0&&o.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 min-w-[120px] max-h-40 overflow-y-auto",children:h.map(y=>o.jsx("button",{onMouseDown:k=>{k.preventDefault(),b(y)},className:`block w-full text-left px-3 py-1.5 text-xs hover:bg-surface-secondary/80 transition-colors ${y===e?"text-brand-400 font-medium":"text-fg-secondary"}`,children:y},y))})]}):o.jsx("span",{onClick:()=>c(!0),className:`${a??""} cursor-pointer hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all`,children:e})}function eue({tags:e,onChange:t,readOnly:n}){const{t:a}=ut(["builder"]),[i,l]=w.useState(!1),[c,u]=w.useState(""),m=w.useRef(null);if(w.useEffect(()=>{i&&m.current?.focus()},[i]),n)return o.jsx("div",{className:"flex flex-wrap items-center gap-1.5 min-h-[24px]",children:e.map(g=>o.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:g},g))});const f=g=>{if((g.key==="Enter"||g.key===",")&&c.trim()){g.preventDefault();const h=c.trim().toLowerCase();e.includes(h)||t([...e,h]),u("")}else g.key==="Backspace"&&!c&&e.length>0?t(e.slice(0,-1)):g.key==="Escape"&&(l(!1),u(""))};return i?o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 ring-1 ring-brand-500/50 rounded px-2 py-1 -mx-1 min-h-[32px]",children:[e.map(g=>o.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] bg-surface-elevated text-fg-secondary rounded-full px-2 py-0.5 border border-border-default",children:[g,o.jsx("button",{onClick:()=>t(e.filter(h=>h!==g)),className:"text-fg-muted hover:text-red-500",children:"×"})]},g)),o.jsx("input",{ref:m,value:c,onChange:g=>u(g.target.value),onKeyDown:f,onBlur:()=>{c||l(!1)},className:"flex-1 min-w-[80px] bg-transparent text-xs text-fg-primary placeholder:text-fg-muted focus:outline-none",placeholder:a("detail.typeTagAndEnter")})]}):o.jsx("div",{onClick:()=>l(!0),className:"flex flex-wrap items-center gap-1.5 cursor-text hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 py-0.5 transition-all min-h-[24px]",children:e.length>0?e.map(g=>o.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:g},g)):o.jsx("span",{className:"text-[10px] text-fg-muted italic",children:a("detail.typeTagAndEnter")})})}function Qg({content:e}){const t=[Ure,Ose,zse],n=[ace,[boe,{strict:"ignore"}],[Kle,{detect:!0,ignoreMissing:!0}]],a=Yde({}),i=w.useMemo(()=>{let l=$k(e,rce);return l=$k(l,uce),l},[e]);return o.jsx("div",{className:`prose prose-invert prose-sm max-w-none
|
|
854
|
+
`,t.prepend(c),()=>{t.innerHTML=""}}let Hc=null;const Kg=new Set;function XC(){for(const e of Kg)e()}function ode(e){Hc!==e&&(Hc=e,XC())}function lde(){Hc!==null&&(Hc=null,XC())}function Qk(){return Hc}function cde(e){return Kg.add(e),()=>{Kg.delete(e)}}w.lazy(()=>fa(()=>import("./MarkdownMessage-BX6YVVx8.js"),[]).then(e=>({default:e.MarkdownMessage})));const dde=w.lazy(()=>fa(()=>import("./ContentRenderer-CHzFmlGx.js"),[]).then(e=>({default:e.ContentRenderer})));let Po=[],Jk=60;function ude(e){const t=w.useRef(e);t.current=e;const[n]=w.useState(()=>++Jk);return w.useEffect(()=>{const a=()=>t.current();Po.push(a);const i=l=>{l.key==="Escape"&&Po[Po.length-1]===a&&(l.preventDefault(),a())};return window.addEventListener("keydown",i,!0),()=>{window.removeEventListener("keydown",i,!0),Po=Po.filter(l=>l!==a),Po.length===0&&(Jk=60)}},[]),n}const Xk=500,Zi=new Map,Um=new Set,sm=new Map;let om=null;function mde(){if(Zi.size<=Xk)return;const e=Zi.size-Xk,t=Zi.keys();for(let n=0;n<e;n++){const{value:a,done:i}=t.next();if(i)break;Zi.delete(a)}}function Zk(e,t){Zi.delete(e),Zi.set(e,t),mde()}function e4(e){const t=sm.get(e);if(t)for(const n of t)n()}function pde(){om=null;const e=[...Um];Um.clear(),e.length!==0&&Se.files.check(e).then(({results:t})=>{for(const[n,a]of Object.entries(t))Zk(n,a),e4(n)}).catch(()=>{for(const t of e)Zk(t,{exists:!1,isFile:!1,type:"unknown"}),e4(t)})}function fde(e){Zi.has(e)||Um.has(e)||(Um.add(e),om&&clearTimeout(om),om=setTimeout(pde,30))}function hde(e,t){let n=sm.get(e);return n||(n=new Set,sm.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&sm.delete(e)}}function gde(e){const t=w.useCallback(i=>hde(e,i),[e]),n=w.useCallback(()=>Zi.get(e),[e]),a=w.useSyncExternalStore(t,n,n);return w.useEffect(()=>{fde(e)},[e]),a}function bde(e){const t=e.includes("\\")?"\\":"/",n=e.lastIndexOf(t);return n<=0?t==="/"?"/":e.slice(0,2):e.slice(0,n)}function yde({filePath:e,onClose:t}){const{t:n}=ut("common"),a=ude(t),[i,l]=w.useState(e),[c,u]=w.useState(!0),[m,f]=w.useState(null),[g,h]=w.useState(""),[b,y]=w.useState(""),[k,C]=w.useState(""),[T,A]=w.useState(""),[M,I]=w.useState(""),[B,G]=w.useState(null),[j,O]=w.useState(!1);w.useEffect(()=>{u(!0),f(null),h(""),G(null),Se.files.preview(i).then(z=>{if(z.type==="directory"&&Array.isArray(z.entries)){y("directory"),C(z.name),G(z.entries);return}y(z.type),C(z.name),A(z.mimeType||""),h(typeof z.content=="string"?z.content:""),I(z.streamUrl||(z.path?Se.files.streamUrl(z.path):"")||(z.type==="audio"||z.type==="video"?Se.files.streamUrl(i):""))}).catch(z=>{f(String(z?.message||z))}).finally(()=>{u(!1)})},[i]);const F=k||i.split(/[/\\]/).pop()||i,Y=b==="directory"||i!==e,q=()=>l(z=>bde(z)),V=()=>{navigator.clipboard?.writeText(i).then(()=>{O(!0),setTimeout(()=>O(!1),1500)}).catch(()=>{})};return Jo.createPortal(o.jsx("div",{className:"fixed inset-0 bg-black/40 flex items-center justify-center",style:{zIndex:a},onClick:t,children:o.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl shadow-2xl w-[90vw] max-w-3xl max-h-[85vh] flex flex-col overflow-hidden",onClick:z=>z.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-default bg-surface-elevated/50 shrink-0",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[b==="directory"&&o.jsx("svg",{className:"w-4 h-4 shrink-0 text-blue-400",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{d:"M3.5 3A1.5 1.5 0 002 4.5v11A1.5 1.5 0 003.5 17h13a1.5 1.5 0 001.5-1.5v-8A1.5 1.5 0 0016.5 6h-6.53a.5.5 0 01-.354-.146L8.706 4.854A1.5 1.5 0 007.586 4H3.5z"})}),b!=="directory"&&o.jsx("svg",{className:"w-4 h-4 shrink-0 text-fg-secondary",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})}),o.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:F}),o.jsx("span",{className:"text-xs text-fg-tertiary truncate hidden sm:inline",children:i})]}),o.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[Y&&o.jsxs("button",{className:"text-xs text-fg-secondary hover:text-fg-primary px-2 py-1 rounded hover:bg-surface-elevated transition-colors",onClick:q,title:n("backToParentDir"),children:["← ",n("goUp")]}),o.jsx("button",{className:"text-xs text-fg-secondary hover:text-fg-primary px-2 py-1 rounded hover:bg-surface-elevated transition-colors",onClick:V,title:n("copyPath"),children:j?`✓ ${n("ambassador.copied")}`:n("copyPath")}),o.jsx("button",{className:"text-xs text-fg-secondary hover:text-fg-primary px-2 py-1 rounded hover:bg-surface-elevated transition-colors",onClick:()=>Se.files.reveal(i),title:n("revealInFileExplorer"),children:o.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{d:"M4.5 17a2.5 2.5 0 01-2.5-2.5v-9A2.5 2.5 0 014.5 3h3.672a1.5 1.5 0 011.06.44L10.56 4.77a.5.5 0 00.354.147H15.5A2.5 2.5 0 0118 7.417v7.083A2.5 2.5 0 0115.5 17h-11z"})})}),o.jsx("button",{className:"text-fg-secondary hover:text-fg-primary p-1 rounded hover:bg-surface-elevated transition-colors",onClick:t,children:o.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[c&&o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx("div",{className:"w-5 h-5 border-2 border-brand-500/30 border-t-brand-500 rounded-full animate-spin"})}),m&&o.jsxs("div",{className:"text-center py-12 text-fg-secondary text-sm",children:[o.jsx("p",{className:"text-red-400 mb-1",children:n("filePreview.loadFailed")}),o.jsx("p",{className:"text-xs text-fg-tertiary",children:m})]}),!c&&!m&&b==="directory"&&B&&o.jsx(Jce,{path:i,entries:B,onNavigate:z=>l(z),onOpenFile:z=>l(z),onReveal:z=>Se.files.reveal(z),onCopyPath:z=>{navigator.clipboard?.writeText(z).then(()=>{O(!0),setTimeout(()=>O(!1),1500)}).catch(()=>{})}}),!c&&!m&&b==="office"&&M&&o.jsx(Zce,{data:{format:(i.split(".").pop()||"pdf").toLowerCase(),streamUrl:M,name:F},reference:i,onFallback:()=>{Se.files.reveal(i)}}),!c&&!m&&b==="image"&&g&&o.jsx("div",{className:"flex justify-center",children:o.jsx("img",{src:`data:${T||"image/png"};base64,${g}`,alt:F,className:"max-w-full rounded"})}),!c&&!m&&b==="audio"&&M&&o.jsx("audio",{controls:!0,preload:"metadata",src:M,className:"w-full"}),!c&&!m&&b==="video"&&M&&o.jsx("video",{controls:!0,preload:"metadata",src:M,className:"w-full max-h-[60vh] rounded-lg bg-black"}),!c&&!m&&(b==="binary"||!g&&b!=="image"&&b!=="audio"&&b!=="video"&&b!=="directory")&&o.jsxs("div",{className:"text-center py-8 space-y-3",children:[o.jsx("p",{className:"text-sm text-fg-secondary",children:n("filePreview.unsupported")}),o.jsx("button",{className:"px-3 py-2 text-xs rounded-lg bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors",onClick:()=>{Se.files.reveal(i)},children:n("revealInFileExplorer")})]}),!c&&!m&&g&&b!=="image"&&b!=="audio"&&b!=="video"&&b!=="binary"&&b!=="directory"&&o.jsx(w.Suspense,{fallback:o.jsx("div",{className:"text-xs text-fg-tertiary",children:n("loading")}),children:o.jsx(dde,{content:g,format:b==="text"?"text":b,className:"text-sm"})})]})]})}),document.body)}function vde({path:e}){const{t}=ut("common"),n=gde(e),a=kp(),i=n?.exists??!1,l=n?.type==="markdown"||n?.type==="html"||n?.type==="json"||n?.type==="text"||n?.type==="image"||n?.type==="audio"||n?.type==="video"||n?.type==="office"||n?.type==="directory",c=w.useCallback(f=>{if(f.preventDefault(),f.stopPropagation(),!!i)if(l){if(a?.hostAvailable){a.openRightPanel({kind:"file",path:e});return}ode(e)}else Se.files.reveal(e)},[i,l,e,a]),u="inline w-3 h-3 align-[-0.125em]",m=l?o.jsx("svg",{className:u,viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4zm2 6a1 1 0 011-1h6a1 1 0 110 2H7a1 1 0 01-1-1zm1 3a1 1 0 100 2h6a1 1 0 100-2H7z",clipRule:"evenodd"})}):o.jsx("svg",{className:u,viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})});return n?i?o.jsxs("code",{"data-file-path-link":"ready",className:"bg-brand-500/10 px-1.5 py-0.5 rounded text-xs font-mono text-brand-500 cursor-pointer hover:bg-brand-500/20 transition-colors border border-brand-500/20 hover:border-brand-500/40 break-all",onClick:c,title:t(l?"clickToPreview":"clickToRevealInExplorer"),role:"button",tabIndex:0,children:[o.jsxs("span",{className:"whitespace-nowrap",children:[m,e.charAt(0)]}),e.slice(1)]}):o.jsx("code",{"data-file-path-link":"missing",className:"bg-surface-secondary/50 px-1.5 py-0.5 rounded text-xs font-mono text-fg-tertiary border border-border-default/30 line-through decoration-fg-tertiary/30 break-all",title:t("fileNotFound"),children:e}):o.jsx("code",{"data-file-path-link":"loading",className:"bg-surface-secondary px-1.5 py-0.5 rounded text-xs font-mono text-fg-secondary break-all",children:e})}function xde(){const e=w.useSyncExternalStore(cde,Qk,Qk);return e?o.jsx(yde,{filePath:e,onClose:lde},e):null}let D0=null;function wde(){return D0||(D0=fa(()=>import("./mermaid.core-B17l8z4S.js").then(e=>e.b9),__vite__mapDeps([0,1])).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:"loose",fontFamily:"inherit"}),e))),D0}function kde(){const e=document.documentElement;return e.classList.contains("light")?!1:e.classList.contains("dark")||e.classList.contains("cyberpunk")||e.classList.contains("mono")?!0:!window.matchMedia("(prefers-color-scheme: light)").matches}function Sde(e){const t=window.matchMedia("(prefers-color-scheme: dark)");t.addEventListener("change",e);const n=new MutationObserver(e);return n.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>{t.removeEventListener("change",e),n.disconnect()}}function Cde(){return kde()}function Ade(){return w.useSyncExternalStore(Sde,Cde)}function ZC({code:e}){const{t}=ut("common"),n=w.useRef(null),[a,i]=w.useState(null),[l,c]=w.useState(!0),u=w.useId(),m=w.useRef(0),f=w.useRef(null),g=Ade();return w.useEffect(()=>{if(!e.trim()||f.current&&f.current.code===e&&f.current.dark===g)return;let h=!1;return c(!0),i(null),m.current+=1,(async()=>{try{const b=await wde();if(h)return;b.default.initialize({startOnLoad:!1,theme:g?"dark":"default",securityLevel:"loose",fontFamily:"inherit"});const y=`mermaid-${u.replace(/:/g,"")}-${m.current}`,{svg:k}=await b.default.render(y,e.trim());if(h)return;n.current&&(n.current.innerHTML=k,f.current={code:e,dark:g})}catch(b){h||i(b instanceof Error?b.message:String(b))}finally{h||c(!1)}})(),()=>{h=!0}},[e,u,g]),a?o.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[o.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-red-500/10 border-b border-red-500/20",children:[o.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})}),o.jsx("span",{className:"text-[10px] font-medium text-red-400",children:t("markdown.mermaidRenderError")})]}),a&&o.jsx("div",{className:"px-3 py-2 bg-surface-secondary/60 text-[11px] font-mono text-red-300/90 whitespace-pre-wrap break-words border-b border-red-500/10 max-h-40 overflow-y-auto",children:a}),o.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):o.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[l&&o.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[o.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),t("markdown.renderingDiagram")]}),o.jsx("div",{ref:n,className:`flex justify-center [&>svg]:max-w-full${l?" hidden":""}`})]})}const Tde="/assets/viz-global-C_AyN6D9.js";let Bu=!1,I0=null;function Ede(){return Bu?Promise.resolve():new Promise((e,t)=>{const n=document.querySelector("script[data-plantuml-viz]");if(n){globalThis.Viz?(Bu=!0,e()):(n.addEventListener("load",()=>{Bu=!0,e()}),n.addEventListener("error",()=>t(new Error("Failed to load viz-global.js"))));return}const a=document.createElement("script");a.setAttribute("data-plantuml-viz",""),a.src=Tde,a.onload=()=>{Bu=!0,e()},a.onerror=()=>t(new Error("Failed to load viz-global.js")),document.head.appendChild(a)})}function Nde(){return I0||(I0=Ede().then(()=>fa(()=>import("./plantuml-DezRDxd4.js"),[]))),I0}let t4=Promise.resolve();function Mde(e,t){const n=t4.then(()=>new Promise((a,i)=>{Nde().then(({renderToString:l})=>{const c=e.split(/\r\n|\r|\n/);l(c,a,i,{dark:t})}).catch(i)}));return t4=n.then(()=>{},()=>{}),n}function jde(){const e=document.documentElement;return e.classList.contains("light")?!1:e.classList.contains("dark")||e.classList.contains("cyberpunk")||e.classList.contains("mono")?!0:!window.matchMedia("(prefers-color-scheme: light)").matches}function Rde(e){const t=window.matchMedia("(prefers-color-scheme: dark)");t.addEventListener("change",e);const n=new MutationObserver(e);return n.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>{t.removeEventListener("change",e),n.disconnect()}}function _de(){return w.useSyncExternalStore(Rde,()=>jde())}function eA({code:e}){const{t}=ut("common"),[n,a]=w.useState(null),[i,l]=w.useState(null),[c,u]=w.useState(!0),m=w.useRef(null),f=_de();return w.useEffect(()=>{if(!e.trim()||m.current&&m.current.code===e&&m.current.dark===f)return;let g=!1;return u(!0),l(null),Mde(e.trim(),f).then(h=>{g||(a(h),m.current={code:e,dark:f})}).catch(h=>{g||l(h instanceof Error?h.message:String(h))}).finally(()=>{g||u(!1)}),()=>{g=!0}},[e,f]),i?o.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[o.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-red-500/10 border-b border-red-500/20",children:[o.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})}),o.jsx("span",{className:"text-[10px] font-medium text-red-400",children:t("markdown.plantumlRenderError")})]}),i&&o.jsx("div",{className:"px-3 py-2 bg-surface-secondary/60 text-[11px] font-mono text-red-300/90 whitespace-pre-wrap break-words border-b border-red-500/10 max-h-40 overflow-y-auto",children:i}),o.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):o.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[c&&o.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[o.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),t("markdown.renderingDiagram")]}),n&&o.jsx("div",{className:`flex justify-center [&>svg]:max-w-full${c?" hidden":""}`,dangerouslySetInnerHTML:{__html:n}})]})}function Dde(e,t,n){const a=e.cloneNode(!0),i=n?.fontFamily??"-apple-system,BlinkMacSystemFont,'Segoe UI','Noto Sans',Helvetica,Arial,sans-serif",l=n?.fontSize??"15px",c=n?.headingScales??{h1:1.6,h2:1.35,h3:1.15,h4:1},u=t==="light"?{bg:"#ffffff",text:"#24292f",heading:"#1f2328",strong:"#1f2328",link:"#0969da",codeBg:"#eff1f3",codeText:"#24292f",preBg:"#f6f8fa",preText:"#24292f",preBorder:"#d0d7de",border:"#d0d7de",blockquoteBorder:"#d0d7de",blockquoteText:"#656d76",tableBorder:"#d0d7de",tableHeaderBg:"#f6f8fa",tableHeaderText:"#24292f",hrColor:"#d8dee4"}:{bg:"#0d1117",text:"#e6edf3",heading:"#f0f6fc",strong:"#f0f6fc",link:"#58a6ff",codeBg:"#161b22",codeText:"#e6edf3",preBg:"#161b22",preText:"#e6edf3",preBorder:"#30363d",border:"#30363d",blockquoteBorder:"#3b82f6",blockquoteText:"#8b949e",tableBorder:"#30363d",tableHeaderBg:"#161b22",tableHeaderText:"#e6edf3",hrColor:"#21262d"},m={p:`margin:0 0 10px;color:${u.text};line-height:1.7;`,h1:`font-size:${c.h1}em;font-weight:700;color:${u.heading};margin:20px 0 10px;line-height:1.3;border-bottom:1px solid ${u.border};padding-bottom:6px;`,h2:`font-size:${c.h2}em;font-weight:700;color:${u.heading};margin:18px 0 8px;line-height:1.3;`,h3:`font-size:${c.h3}em;font-weight:600;color:${u.heading};margin:14px 0 6px;line-height:1.3;`,h4:`font-size:${c.h4}em;font-weight:600;color:${u.heading};margin:12px 0 4px;`,strong:`font-weight:600;color:${u.strong};`,em:"font-style:italic;",a:`color:${u.link};text-decoration:underline;`,ul:"padding-left:1.5em;margin:0 0 10px;",ol:"padding-left:1.5em;margin:0 0 10px;",li:`margin:3px 0;line-height:1.7;color:${u.text};`,blockquote:`border-left:3px solid ${u.blockquoteBorder};padding:2px 0 2px 14px;margin:10px 0;color:${u.blockquoteText};`,hr:`border:none;border-top:1px solid ${u.hrColor};margin:20px 0;`,table:"border-collapse:collapse;width:100%;margin:10px 0;",thead:`background:${u.tableHeaderBg};`,th:`border:1px solid ${u.tableBorder};padding:8px 12px;text-align:left;font-weight:600;color:${u.tableHeaderText};`,td:`border:1px solid ${u.tableBorder};padding:8px 12px;color:${u.text};`,img:"max-width:100%;height:auto;"};function f(g){g.removeAttribute("class");const h=g.tagName.toLowerCase();if(h==="pre"){g.setAttribute("style",`background:${u.preBg};color:${u.preText};padding:14px;border-radius:6px;overflow-x:auto;margin:10px 0;font-size:0.88em;line-height:1.5;border:1px solid ${u.preBorder};`);const b=g.querySelector("code");b&&(b.removeAttribute("class"),b.setAttribute("style","background:transparent;padding:0;border-radius:0;color:inherit;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;font-size:inherit;"));return}h==="code"?g.setAttribute("style",`background:${u.codeBg};color:${u.codeText};padding:2px 6px;border-radius:4px;font-size:0.9em;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;`):m[h]&&g.setAttribute("style",m[h]),Array.from(g.children).forEach(f)}return a.removeAttribute("class"),Array.from(a.children).forEach(g=>f(g)),`<div style="background:${u.bg};color:${u.text};padding:20px 24px;font-family:${i};font-size:${l};line-height:1.7;max-width:800px;">${a.innerHTML}</div>`}async function tA(e){try{return await navigator.clipboard.writeText(e),!0}catch{try{const t=document.createElement("textarea");t.value=e,t.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0",document.body.appendChild(t),t.select();const n=document.execCommand("copy");return document.body.removeChild(t),n}catch{return!1}}}async function xpe(e,t,n,a){const i=Dde(e,t,a);try{return await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([i],{type:"text/html"}),"text/plain":new Blob([n],{type:"text/plain"})})]),{ok:!0,method:"html"}}catch{return{ok:await tA(n),method:"text"}}}function Vg({code:e,language:t,children:n}){const{t:a}=ut("common"),[i,l]=w.useState("rendered"),[c,u]=w.useState(!1),m=w.useCallback(async()=>{await tA(e)&&(u(!0),setTimeout(()=>u(!1),1800))},[e]);return o.jsxs("div",{className:"not-prose my-2 rounded-lg overflow-hidden border border-border-subtle",children:[o.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle bg-surface-secondary",children:[o.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:t}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:()=>l("rendered"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${i==="rendered"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsxs("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]}),a("markdown.viewRendered")]})}),o.jsx("button",{onClick:()=>l("source"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${i==="source"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}),a("markdown.viewSource")]})})]})]}),i==="rendered"?o.jsx("div",{children:n}):o.jsxs("div",{className:"relative group/source",children:[o.jsx("pre",{className:"p-3 overflow-x-auto text-xs font-mono text-fg-secondary bg-surface-secondary leading-relaxed whitespace-pre-wrap break-words",children:e}),o.jsx("button",{onClick:m,className:"absolute top-2 right-2 p-1.5 rounded-md bg-surface-elevated/80 hover:bg-surface-overlay text-fg-tertiary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all opacity-0 group-hover/source:opacity-100",title:a("markdown.copyContent"),children:c?o.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]})}const Ide=[ZC,eA];function Lde(e){for(const t of w.Children.toArray(e))if(w.isValidElement(t)&&typeof t.props?.className=="string"){const n=t.props.className;return hce(n)}return null}function kc(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(!e)return"";if(Array.isArray(e))return e.map(kc).join("");if(w.isValidElement(e)){const t=e.props;return kc(t.children)}return""}function Pde({children:e}){const{t}=ut("common"),n=Lde(e),a=w.useRef(null),[i,l]=w.useState(!1),[c,u]=w.useState("rendered"),m=w.useCallback(async()=>{let g;c==="source"?g=kc(e):g=a.current?.querySelector("code")?.textContent??"";try{await navigator.clipboard.writeText(g),l(!0),setTimeout(()=>l(!1),1800)}catch{}},[c,e]);if(w.Children.toArray(e).some(g=>w.isValidElement(g)&&Ide.includes(g.type))){const g=kc(e),h=n==="mermaid"||n==="plantuml"?n:"diagram";return o.jsx(Vg,{code:g,language:h,children:e})}return n==="mermaid"||n==="plantuml"?o.jsx(o.Fragment,{children:e}):o.jsxs("div",{className:"not-prose relative group/code my-2 rounded-lg overflow-hidden bg-surface-secondary border border-border-subtle",children:[n&&o.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle",children:[o.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:fce(n)}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:()=>u("rendered"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${c==="rendered"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("markdown.viewRendered")}),o.jsx("button",{onClick:()=>u("source"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${c==="source"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("markdown.viewSource")})]})]}),o.jsxs("div",{className:"relative",children:[c==="rendered"?o.jsx("pre",{ref:a,className:"p-3 overflow-x-auto text-xs [&>code]:p-0 [&>code]:rounded-none [&>code]:text-fg-secondary",children:w.Children.map(e,g=>w.isValidElement(g)?w.cloneElement(g,{style:{background:"transparent",padding:0}}):g)}):o.jsx("pre",{className:"p-3 overflow-x-auto text-xs font-mono text-fg-secondary whitespace-pre-wrap break-words",children:kc(e)}),o.jsx("button",{onClick:m,className:"absolute top-2 right-2 p-1.5 rounded-md bg-surface-elevated/80 hover:bg-surface-overlay text-fg-tertiary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all opacity-0 group-hover/code:opacity-100",title:t("markdown.copyContent"),children:i?o.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]})}const n4="#mention:",Gm="#entity:",Ode=/^\[([^\]]+)\]\(#entity:((tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)$/i,nA=/^(workflow|task|requirement|project|deliverable|agent|team):(.+)$/,Wg="text-brand-500 hover:text-brand-500 underline break-all cursor-pointer";function Yg(e){return e.type==="text"?e.value??"":(e.children??[]).map(Yg).join("")}function Hde(e){return e.type==="text"&&(e.value??"").trim()===""}function Bde(e){if(!e?.children)return null;const t=e.children.filter(a=>!Hde(a));if(t.length!==1)return null;const n=t[0];if(n.type==="element"&&n.tagName==="a"){const a=n.properties?.href;if(!a)return null;const i=Yg(n);if(a.startsWith(Gm))return{id:a.slice(Gm.length)};const l=a.match(nA);return l&&l[1]!=="workflow"?{id:l[2],type:KC(l[1]),label:i}:null}if(n.type==="element"&&n.tagName==="code"){const a=Yg(n).trim();if(Fm(a))return{id:a}}if(n.type==="text"){const a=(n.value??"").trim();if(Fm(a))return{id:a}}return null}const zde={p:({children:e})=>o.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:e}),h1:({children:e})=>o.jsx("h1",{className:"text-base font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h2:({children:e})=>o.jsx("h2",{className:"text-sm font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h3:({children:e})=>o.jsx("h3",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h4:({children:e})=>o.jsx("h4",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h5:({children:e})=>o.jsx("h5",{className:"text-xs font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h6:({children:e})=>o.jsx("h6",{className:"text-xs font-medium mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),ul:({children:e})=>o.jsx("ul",{className:"list-disc pl-4 mb-2 space-y-0.5",children:e}),ol:({children:e,start:t})=>o.jsx("ol",{start:t,className:"list-decimal pl-7 mb-2 space-y-0.5",children:e}),li:({children:e,value:t})=>o.jsx("li",{value:t,className:"leading-relaxed text-fg-secondary marker:text-fg-secondary",children:e}),code:({children:e,className:t})=>{const n=typeof e=="string"?e:String(e??""),a=n.trim();if(t?.includes("language-plantuml")||mce(a))return o.jsx(Vg,{code:a,language:"plantuml",children:o.jsx(eA,{code:a})});if(t?.includes("language-mermaid"))return o.jsx(Vg,{code:a,language:"mermaid",children:o.jsx(ZC,{code:a})});if(t?.includes("language-"))return o.jsx("code",{className:`${t} text-fg-secondary font-mono text-xs`,children:e});if(Fm(n))return o.jsx(wc,{id:n.trim()});const i=n.match(Ode);return i?o.jsx(wc,{id:i[2],label:i[1]}):tce(n)?o.jsx(vde,{path:n}):o.jsx("code",{className:"bg-surface-secondary px-1.5 py-0.5 rounded text-xs font-mono text-brand-500 break-all",children:e})},pre:({children:e})=>o.jsx(Pde,{children:e}),strong:({children:e})=>o.jsx("strong",{className:"font-bold text-fg-primary",children:e}),em:({children:e})=>o.jsx("em",{className:"italic text-fg-secondary",children:e}),del:({children:e})=>o.jsx("del",{className:"line-through text-fg-tertiary",children:e}),blockquote:({children:e})=>o.jsx("blockquote",{className:"border-l-2 border-brand-500 pl-3 my-2 text-fg-secondary italic",children:e}),a:({href:e,children:t})=>o.jsx("a",{href:e,className:Wg,children:t}),hr:()=>o.jsx("hr",{className:"border-border-default my-3"}),table:({children:e})=>o.jsx("div",{className:"overflow-x-auto my-2",children:o.jsx("table",{className:"min-w-full text-sm border-collapse border border-border-default",children:e})}),thead:({children:e})=>o.jsx("thead",{className:"bg-surface-secondary",children:e}),tbody:({children:e})=>o.jsx("tbody",{className:"divide-y divide-border-default",children:e}),tr:({children:e})=>o.jsx("tr",{className:"hover:bg-surface-elevated/50 transition-colors",children:e}),th:({children:e})=>o.jsx("th",{className:"px-3 py-2 text-left text-sm font-semibold text-fg-primary border border-border-default",children:e}),td:({children:e})=>o.jsx("td",{className:"px-3 py-2 text-sm text-fg-primary border border-border-default",children:e})},qde=/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i;function $de(e){const t=Ub(e);return Xle(e)&&qde.test(t.split("?")[0]??t)}function Fde(e,t){const n=Ub(e);if(n.startsWith("/")||n.startsWith("~/")||/^[A-Za-z]:\//.test(n)||n.startsWith("//"))return n;if((n.startsWith("./")||n.startsWith("../"))&&t){const i=((t.replace(/\\/g,"/").endsWith("/")?t.replace(/\\/g,"/"):`${t.replace(/\\/g,"/")}/`)+n).split("/"),l=[];for(const c of i)c===".."?l.pop():c!=="."&&c!==""&&l.push(c);return"/"+l.join("/")}return n}function Ude(e){return`/api/files/image?path=${encodeURIComponent(e)}`}function Gde(e,t){return $de(e)?Ude(Fde(e,t)):null}const Oo=new Map,oc=new Map,Kde=w.memo(function({src:t,alt:n,onPreview:a,basePath:i}){const{t:l}=ut("common"),c=w.useMemo(()=>Gde(t,i)??t,[t,i]),u=c.startsWith("/api/files/image?"),m=Oo.get(c),f=oc.get(c),[g,h]=w.useState(m??(u?null:c)),[b,y]=w.useState(!!m),[k,C]=w.useState(!!f),[T,A]=w.useState(f??null),[M,I]=w.useState(0),B=w.useRef(0),G=w.useCallback(O=>{oc.set(c,O),A(O),C(!0),y(!1)},[c]),j=w.useCallback(()=>{Oo.delete(c),oc.delete(c),C(!1),A(null),y(!1),h(u?null:`${c}${c.includes("?")?"&":"?"}retry=${Date.now()}`),I(O=>O+1)},[c,u]);return w.useEffect(()=>{if(!u)return;const O=Oo.get(c);if(O){h(O),y(!0),C(!1),A(null);return}const F=oc.get(c);if(F!==void 0){C(!0),A(F),y(!1);return}const Y=++B.current;C(!1),A(null),y(!1),h(null),(async()=>{try{const q=await fetch(c,{credentials:"same-origin"});if(Y!==B.current)return;if(!q.ok){let J=`HTTP ${q.status}`;try{const D=await q.json();D.error&&(J=D.error)}catch{}throw new Error(J)}const V=await q.blob();if(Y!==B.current)return;if(V.size===0)throw new Error("Empty image response");if(V.type&&!V.type.startsWith("image/")&&!V.type.includes("octet-stream"))throw new Error(`Unexpected content-type: ${V.type}`);const z=URL.createObjectURL(V);Oo.set(c,z),h(z),y(!0),C(!1),A(null)}catch(q){if(Y!==B.current)return;const V=q instanceof Error?q.message:String(q);console.warn("[MarkdownImage] failed to load local image",c,q),G(V)}})()},[u,c,M]),w.useEffect(()=>{if(u)return;const O=oc.get(c);if(O!==void 0){C(!0),A(O),y(!1);return}h(c),y(!!Oo.get(c)),C(!1),A(null)},[c,u,M]),k?o.jsxs("button",{type:"button",onClick:j,title:T??l("markdown.clickToRetry"),className:"inline-flex items-center gap-1.5 px-3 py-2 text-xs text-fg-tertiary bg-surface-elevated rounded-lg border border-border-default hover:bg-surface-overlay hover:text-fg-secondary cursor-pointer transition-colors max-w-full",children:[o.jsxs("svg",{className:"w-4 h-4 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:[o.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),o.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),o.jsx("polyline",{points:"21 15 16 10 5 21"})]}),o.jsxs("span",{className:"truncate",children:[l("markdown.imageLoadFailed"),T?` (${T})`:""]})]}):o.jsxs("span",{className:"inline-block align-middle max-w-full",children:[!b&&o.jsx("span",{className:"block w-full min-h-[80px] max-w-[400px] bg-surface-elevated rounded-lg animate-pulse"}),g?o.jsx("img",{src:g,alt:n??"",onLoad:()=>{u||Oo.set(c,c),y(!0)},onError:()=>{G("Image decode failed")},onClick:()=>a?.(g),className:`max-w-full h-auto rounded-lg cursor-pointer hover:opacity-90 transition-opacity my-1${b?"":" absolute opacity-0 pointer-events-none"}`,style:{maxHeight:"400px",objectFit:"contain"}}):null]})});async function a4(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch image (${t.status})`);return t.blob()}async function Vde(e){if(e.type==="image/png")return e;const t=await createImageBitmap(e),n=document.createElement("canvas");n.width=t.width,n.height=t.height;const a=n.getContext("2d");if(!a)throw new Error("Canvas unavailable");return a.drawImage(t,0,0),t.close(),new Promise((i,l)=>{n.toBlob(c=>c?i(c):l(new Error("PNG encode failed")),"image/png")})}function Wde(e,t){try{const i=(e.startsWith("data:")?"":new URL(e,window.location.href).pathname).split("/").pop()||"";if(i&&/\.(png|jpe?g|gif|webp|svg|bmp)$/i.test(i))return decodeURIComponent(i)}catch{}return`image.${(t.type.split("/")[1]||"png").replace("jpeg","jpg")}`}function wpe({src:e,onClose:t}){const{t:n}=ut("common"),[a,i]=w.useState(null),[l,c]=w.useState(null);$s(!0),w.useEffect(()=>{const h=b=>{b.key==="Escape"&&t()};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[t]);const u=w.useCallback(h=>{i(h),window.setTimeout(()=>i(null),1600)},[]),m=w.useCallback(async h=>{if(h.stopPropagation(),!l){c("copy");try{const b=await a4(e),y=await Vde(b);await navigator.clipboard.write([new ClipboardItem({"image/png":y})]),u(n("imageCopied"))}catch{u(n("imageCopyFailed"))}finally{c(null)}}},[l,u,e,n]),f=w.useCallback(async h=>{if(h.stopPropagation(),!l){c("download");try{const b=await a4(e),y=URL.createObjectURL(b),k=document.createElement("a");k.href=y,k.download=Wde(e,b),document.body.appendChild(k),k.click(),k.remove(),URL.revokeObjectURL(y),u(n("imageDownloaded"))}catch{u(n("imageDownloadFailed"))}finally{c(null)}}},[l,u,e,n]),g="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-white/10 hover:bg-white/20 text-white text-sm transition-colors disabled:opacity-50";return Jo.createPortal(o.jsxs("div",{className:"fixed inset-0 z-[9999] bg-black/80 flex items-center justify-center p-4",onClick:t,children:[o.jsxs("div",{className:"absolute top-4 right-4 z-10 flex items-center gap-2",onClick:h=>h.stopPropagation(),children:[o.jsxs("button",{type:"button",className:g,onClick:m,disabled:!!l,title:n("copyImage"),children:[o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),o.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),n("copy")]}),o.jsxs("button",{type:"button",className:g,onClick:f,disabled:!!l,title:n("downloadImage"),children:[o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"}),o.jsx("polyline",{points:"7 10 12 15 17 10"}),o.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),n("downloadImage")]}),o.jsx("button",{type:"button",onClick:t,className:"w-10 h-10 rounded-full bg-white/10 hover:bg-white/20 flex items-center justify-center transition-colors",title:n("close"),children:o.jsxs("svg",{className:"w-6 h-6 text-white",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),a&&o.jsx("div",{className:"absolute top-16 left-1/2 -translate-x-1/2 z-10 px-3 py-1.5 rounded-lg bg-black/70 text-white text-xs",children:a}),o.jsx("img",{src:e,alt:n("fileEditor.preview"),className:"max-w-full max-h-[90vh] object-contain rounded-lg",onClick:h=>h.stopPropagation()})]}),document.body)}function Yde(e={}){const{onMentionClick:t,basePath:n,onImagePreview:a,contentRef:i,hostAvailable:l,openRightPanel:c}=e,u=w.useCallback((m,f)=>{const g=qk(f,n);if(g.kind!=="passthrough"){if(m.preventDefault(),m.stopPropagation(),g.kind==="fragment"){nce(i?.current??null,g.id);return}if(g.kind==="file"){l&&c?c({kind:"file",path:g.path,title:g.path.split(/[/\\]/).pop()}):Se.files.reveal(g.path).catch(()=>{});return}if(g.kind==="external"){if(l&&c&&/^https?:\/\//i.test(g.url)){c({kind:"url",url:g.url,title:g.url});return}Or(g.url)}}},[n,i,l,c]);return w.useMemo(()=>({...zde,img:({src:m,alt:f})=>o.jsx(Kde,{src:m??"",alt:f,onPreview:a,basePath:n},m??""),p:({children:m,node:f})=>{const g=Bde(f);return g?o.jsx(Kce,{id:g.id,type:g.type,label:g.label}):o.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:m})},a:({href:m,children:f})=>{if(m?.startsWith(n4)){const h=decodeURIComponent(m.slice(n4.length));return o.jsx("span",{className:`text-brand-500 font-medium${t?" cursor-pointer hover:underline":""}`,onClick:t?b=>{b.preventDefault(),b.stopPropagation(),t(h,b)}:void 0,title:h,children:f})}if(m?.startsWith(Gm))return o.jsx(wc,{id:m.slice(Gm.length)});{const h=m?.match(nA);if(h){const[,b,y]=h;if(b==="workflow")return o.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1 py-0.5 rounded bg-brand-500/10 text-brand-500 text-xs font-medium cursor-pointer hover:bg-brand-500/20 transition-colors",onClick:C=>{C.preventDefault(),C.stopPropagation(),yt.navigate(ce.WORK,{boardType:"workflows"})},title:`workflow: ${y}`,children:[o.jsx("span",{className:"text-[10px]",children:"⚙️"}),o.jsx("span",{children:f})]});const k=KC(b);if(k)return o.jsx(wc,{id:y,type:k,label:f})}}if(m&&Fm(m))return o.jsx(wc,{id:m.trim(),label:f});const g=qk(m,n);return g.kind==="fragment"||g.kind==="file"||g.kind==="external"?o.jsx("a",{href:m,className:Wg,onClick:h=>u(h,m),title:g.kind==="fragment"?`#${g.id}`:g.kind==="file"?g.path:g.url,children:f}):o.jsx("a",{href:m,className:Wg,onClick:h=>{Ko()&&m&&!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(m)&&h.preventDefault()},children:f})}}),[t,n,a,u])}const r4={agent:{icon:"✦",label:"Agent",color:"text-brand-500",gradient:"from-brand-500 to-purple-600",bg:"bg-brand-500/10",ring:"ring-brand-500/30"},team:{icon:"◈",label:"Team",color:"text-blue-600",gradient:"from-blue-500 to-blue-600",bg:"bg-blue-500/10",ring:"ring-blue-500/30"},skill:{icon:"⬡",label:"Skill",color:"text-green-600",gradient:"from-green-500 to-green-600",bg:"bg-green-500/10",ring:"ring-green-500/30"}},Qde=["development","devops","management","productivity","browser","custom","general"],Jde=[{label:"Tech",emojis:["✦","◈","⬡","⚡","🤖","🧠","💡","🎯","🔧","📦","🚀","💻","🛠️","⭐","🔥","💎","⚙️","🧩","🔌","💾","🖥️","📡","🔬","🧪","🏗️","📱","🎮","🕹️","📟","💽","🖨️","⌨️"]},{label:"People",emojis:["👤","👥","🧑💻","👨💼","👩🔬","🧙","🦸","🤝","💪","🎓","👷","🕵️","🧑🎨","🧑🏫","👨🚀","🥷","🧑🏭","🧑⚕️","🧑🔧","🧑🍳","👨🎤","🦹","🧝","🧞","🧑✈️","💂","🤴","👸","🧛","🧟","🧜","🧚"]},{label:"Objects",emojis:["📝","📊","🗂️","📁","🔍","🔑","🌐","💬","🔒","🎨","📐","🗃️","📋","✏️","🖊️","📌","📎","🧲","🪝","🧰","🪜","🧬","🔭","💊","🩺","📕","📗","📘","📙","📓","🗒️","📰"]},{label:"Symbols",emojis:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","♠️","♥️","♦️","♣️","🎵","🎶","💯","✅","❌","⭕","🔴","🟠","🟡","🟢","🔵","🟣","⚫","⚪","🟤","🔶","🔷","▶️","⏸️","⏹️"]},{label:"Nature",emojis:["🌟","🌈","🌊","🌿","🍀","🔮","💫","✨","🌙","☀️","🦋","🐉","🦊","🐺","🦅","🐙","🦁","🐯","🦄","🐲","🌸","🌺","🍄","🌵","🎄","🌴","🍁","🌻","🐝","🦎","🐍","🦈"]},{label:"Activity",emojis:["🎯","🏆","🥇","🎖️","🏅","🎪","🎭","🎬","🎤","🎧","🎼","🎹","🥁","🎸","🎺","🎻","⚽","🏀","🎾","🏐","🎲","🧸","🪁","🎰","🎳","🏹","🥊","🤺","⛷️","🏄","🚴","🧗"]}],Xde={shell:{icon:">",color:"bg-amber-500/15 text-amber-400 border-amber-500/30"},file:{icon:"◫",color:"bg-blue-500/15 text-blue-400 border-blue-500/30"},network:{icon:"◎",color:"bg-purple-500/15 text-purple-400 border-purple-500/30"},browser:{icon:"◉",color:"bg-brand-500/15 text-brand-400 border-brand-500/30"}};function L0({value:e,onChange:t,renderAs:n="span",className:a,editClassName:i,placeholder:l,multiline:c,readOnly:u}){const[m,f]=w.useState(!1),[g,h]=w.useState(e),b=w.useRef(null);if(w.useEffect(()=>{h(e)},[e]),w.useEffect(()=>{m&&b.current?.focus()},[m]),u){const I=e||l,G=`${a??""} ${!e?"text-fg-muted italic":""}`;return n==="h1"?o.jsx("h1",{className:G,children:I}):n==="p"?o.jsx("p",{className:G,children:I}):o.jsx("span",{className:G,children:I})}const y=()=>{f(!1),g!==e&&t(g)},k=()=>{h(e),f(!1)},C=I=>{I.key==="Escape"&&k(),I.key==="Enter"&&!c&&y()};if(m){const I=`bg-transparent outline-none w-full ${i??a??""} ring-1 ring-brand-500/50 rounded px-1 -mx-1`;return c?o.jsx("textarea",{ref:b,value:g,onChange:B=>h(B.target.value),onBlur:y,onKeyDown:C,className:`${I} resize-y min-h-[60px]`,placeholder:l}):o.jsx("input",{ref:b,value:g,onChange:B=>h(B.target.value),onBlur:y,onKeyDown:C,className:I,placeholder:l})}const T=e||l,A=!e,M="cursor-text hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all";return n==="h1"?o.jsx("h1",{onClick:()=>f(!0),className:`${a??""} ${M} ${A?"text-fg-muted italic":""}`,children:T}):n==="p"?o.jsx("p",{onClick:()=>f(!0),className:`${a??""} ${M} ${A?"text-fg-muted italic":""}`,children:T}):n==="badge"?o.jsx("span",{onClick:()=>f(!0),className:`${a??""} ${M} ${A?"text-fg-muted italic":""}`,children:T}):o.jsx("span",{onClick:()=>f(!0),className:`${a??""} ${M} ${A?"text-fg-muted italic":""}`,children:T})}function Zde({value:e,options:t,onChange:n,className:a,readOnly:i}){const[l,c]=w.useState(!1),[u,m]=w.useState(e),f=w.useRef(null),g=w.useRef(null);if(w.useEffect(()=>{l&&(m(e),setTimeout(()=>f.current?.focus(),0))},[l,e]),i)return o.jsx("span",{className:a,children:e});const h=t.filter(y=>y.toLowerCase().includes(u.toLowerCase())),b=y=>{const k=y.trim();k&&k!==e&&n(k),c(!1)};return l?o.jsxs("div",{ref:g,className:"relative inline-block",children:[o.jsx("input",{ref:f,value:u,onChange:y=>m(y.target.value),onKeyDown:y=>{y.key==="Enter"?(y.preventDefault(),b(u)):y.key==="Escape"&&c(!1)},onBlur:y=>{g.current?.contains(y.relatedTarget)||b(u)},className:`${a??""} bg-transparent outline-none ring-1 ring-brand-500/50 rounded w-28`}),h.length>0&&o.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 min-w-[120px] max-h-40 overflow-y-auto",children:h.map(y=>o.jsx("button",{onMouseDown:k=>{k.preventDefault(),b(y)},className:`block w-full text-left px-3 py-1.5 text-xs hover:bg-surface-secondary/80 transition-colors ${y===e?"text-brand-400 font-medium":"text-fg-secondary"}`,children:y},y))})]}):o.jsx("span",{onClick:()=>c(!0),className:`${a??""} cursor-pointer hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all`,children:e})}function eue({tags:e,onChange:t,readOnly:n}){const{t:a}=ut(["builder"]),[i,l]=w.useState(!1),[c,u]=w.useState(""),m=w.useRef(null);if(w.useEffect(()=>{i&&m.current?.focus()},[i]),n)return o.jsx("div",{className:"flex flex-wrap items-center gap-1.5 min-h-[24px]",children:e.map(g=>o.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:g},g))});const f=g=>{if((g.key==="Enter"||g.key===",")&&c.trim()){g.preventDefault();const h=c.trim().toLowerCase();e.includes(h)||t([...e,h]),u("")}else g.key==="Backspace"&&!c&&e.length>0?t(e.slice(0,-1)):g.key==="Escape"&&(l(!1),u(""))};return i?o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 ring-1 ring-brand-500/50 rounded px-2 py-1 -mx-1 min-h-[32px]",children:[e.map(g=>o.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] bg-surface-elevated text-fg-secondary rounded-full px-2 py-0.5 border border-border-default",children:[g,o.jsx("button",{onClick:()=>t(e.filter(h=>h!==g)),className:"text-fg-muted hover:text-red-500",children:"×"})]},g)),o.jsx("input",{ref:m,value:c,onChange:g=>u(g.target.value),onKeyDown:f,onBlur:()=>{c||l(!1)},className:"flex-1 min-w-[80px] bg-transparent text-xs text-fg-primary placeholder:text-fg-muted focus:outline-none",placeholder:a("detail.typeTagAndEnter")})]}):o.jsx("div",{onClick:()=>l(!0),className:"flex flex-wrap items-center gap-1.5 cursor-text hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 py-0.5 transition-all min-h-[24px]",children:e.length>0?e.map(g=>o.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:g},g)):o.jsx("span",{className:"text-[10px] text-fg-muted italic",children:a("detail.typeTagAndEnter")})})}function Qg({content:e}){const t=[Ure,Ose,zse],n=[ace,[boe,{strict:"ignore"}],[Kle,{detect:!0,ignoreMissing:!0}]],a=Yde({}),i=w.useMemo(()=>{let l=$k(e,rce);return l=$k(l,uce),l},[e]);return o.jsx("div",{className:`prose prose-invert prose-sm max-w-none
|
|
855
855
|
prose-headings:text-fg-primary prose-headings:font-semibold
|
|
856
856
|
prose-p:text-fg-secondary prose-p:leading-relaxed
|
|
857
857
|
prose-a:text-brand-400 prose-a:no-underline hover:prose-a:underline
|
|
@@ -864,4 +864,4 @@ await import("${new URL("/assets/pdf.worker.min-CHFwMXne.mjs",import.meta.url).t
|
|
|
864
864
|
|
|
865
865
|
${m("share.rejectedEncourage")}`})},className:"text-xs px-2 py-1.5 rounded-lg border border-red-500/30 text-red-400 hover:bg-red-500/10 transition-colors inline-flex items-center gap-1 cursor-pointer",title:m("share.rejectedTip"),children:[o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),o.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),m("share.rejected")]}),o.jsxs("button",{onClick:()=>{xe({visibility:j.visibility})},disabled:F,className:"text-xs px-3 py-1.5 rounded-lg border border-brand-500/40 text-brand-400 hover:bg-brand-500/10 hover:border-brand-500/60 transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:[o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("polyline",{points:"23 4 23 10 17 10"}),o.jsx("polyline",{points:"1 20 1 14 7 14"}),o.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]}),m(F?"share.updating":"share.resubmit")]})]}),!j.moderationStatus&&j.pendingReview&&o.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 inline-flex items-center gap-1",title:m("share.updateUnderReviewTip"),children:[o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("polyline",{points:"12 6 12 12 16 14"})]}),m("share.updateUnderReview")]}),he&&o.jsxs("a",{href:he,target:"_blank",rel:"noopener noreferrer",onClick:Je=>{Ko()&&(Je.preventDefault(),Or(he))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1.5 ${j.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/50":j.visibility==="unlisted"?"border-gray-500/30 text-fg-tertiary hover:text-fg-secondary hover:border-gray-400/50":"border-green-600/30 text-green-600 hover:text-green-500 hover:border-green-500/50"}`,children:[j.visibility==="org"?o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M3 21h18"}),o.jsx("path",{d:"M9 8h1"}),o.jsx("path",{d:"M9 12h1"}),o.jsx("path",{d:"M9 16h1"}),o.jsx("path",{d:"M14 8h1"}),o.jsx("path",{d:"M14 12h1"}),o.jsx("path",{d:"M14 16h1"}),o.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}):j.visibility==="unlisted"?o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),o.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}):o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),o.jsx("polyline",{points:"15 3 21 3 21 9"}),o.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),j.visibility==="org"?m("visibility.sharedOrg"):j.visibility==="unlisted"?m("visibility.sharedUnlisted"):m("share.viewOnHub")]}),dt&&o.jsx("button",{onClick:()=>{xe({visibility:j.visibility})},disabled:F,className:"text-xs px-3 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 hover:bg-amber-500/10 hover:border-amber-500/50 transition-colors disabled:opacity-50",children:F?m("share.updating"):m("share.updateVersion",{version:Ve})})]})})(),!i&&!j.shared&&o.jsx("button",{onClick:()=>te(!0),disabled:F,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand transition-colors disabled:opacity-50",children:m(F?"share.sharing":"share.toHub")})]})]}),!i&&q&&!z&&o.jsxs("div",{className:"mb-4 px-4 py-2.5 rounded-lg bg-amber-50 dark:bg-amber-500/10 border border-amber-300 dark:border-amber-500/20 flex items-center justify-between",children:[o.jsx("span",{className:"text-xs text-amber-800 dark:text-amber-300",children:m("versionBump.contentModified")}),o.jsx("button",{onClick:()=>J(!0),className:"text-xs px-3 py-1 rounded bg-amber-200 dark:bg-amber-500/20 text-amber-800 dark:text-amber-300 hover:bg-amber-300 dark:hover:bg-amber-500/30 transition-colors",children:m("versionBump.bumpVersion")})]}),!i&&z&&o.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-amber-50 dark:bg-amber-500/10 border border-amber-300 dark:border-amber-500/20",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("span",{className:"text-xs text-amber-800 dark:text-amber-300",children:m("versionBump.newVersion")}),o.jsx("input",{type:"text",defaultValue:(()=>{const ue=(Ue||"1.0.0").split(".");return ue[2]=String(Number(ue[2]??0)+1),ue.join(".")})(),className:"text-xs px-2 py-1 rounded bg-surface-elevated border border-border-default text-fg-primary w-24 font-mono",onKeyDown:ue=>{ue.key==="Enter"&&tt("version",ue.target.value)}}),o.jsx("button",{onClick:ue=>{const he=ue.target.parentElement?.querySelector("input");he&&tt("version",he.value)},className:"text-xs px-3 py-1 rounded bg-amber-200 dark:bg-amber-500/20 text-amber-800 dark:text-amber-300 hover:bg-amber-300 dark:hover:bg-amber-500/30 transition-colors",children:m("common:confirm")}),o.jsx("button",{onClick:()=>J(!1),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:m("common:cancel")})]}),j.shared&&o.jsx("p",{className:"text-[10px] text-fg-tertiary mt-2",children:m("detail.shareAfterVersionBump")})]}),o.jsxs("div",{className:`flex gap-8 ${f?"flex-col":""}`,children:[o.jsxs("div",{className:`${f?"w-full":"flex-1 min-w-0"}`,children:[o.jsxs("div",{className:"flex items-start gap-4 mb-6",children:[o.jsxs("div",{className:"relative",children:[o.jsx("div",{onClick:()=>!i&&ke(!le),className:`w-16 h-16 rounded-xl ${ne.bg} flex items-center justify-center text-3xl shrink-0 ${i?"":"cursor-pointer hover:ring-2"} ${ne.ring} transition-all overflow-hidden`,children:rt&&rt.startsWith("images/")?o.jsx("img",{src:`/api/builder/artifacts/${e}s/${encodeURIComponent(b)}/images/${encodeURIComponent(rt.replace("images/",""))}?v=${oe}`,alt:"",className:"w-full h-full object-cover"}):rt&&(rt.startsWith("http")||rt.startsWith("/"))?o.jsx("img",{src:rt,alt:"",className:"w-full h-full object-cover"}):(()=>{const ue=rt||"";if(ue&&[...ue].length<=2&&new RegExp("\\p{Emoji}","u").test(ue))return ue;const Ve=Bs[il(e)].accent;return o.jsx("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:o.jsx("path",{d:TC(Ne||t||e),fill:Ve})})})()}),!i&&le&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>ke(!1)}),o.jsxs("div",{className:"absolute top-full left-0 mt-2 z-50 bg-surface-secondary border border-border-default rounded-xl p-3 shadow-xl w-80",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[o.jsx("input",{type:"text",placeholder:m("detail.pasteEmojiOrUrl"),className:"flex-1 text-sm px-2 py-1.5 rounded-lg bg-surface-elevated border border-border-default text-fg-primary placeholder:text-fg-muted",defaultValue:rt,onKeyDown:ue=>{ue.key==="Enter"&&(tt("icon",ue.target.value),ke(!1))}}),o.jsxs("label",{className:"text-[10px] text-brand-400 hover:text-brand-300 cursor-pointer px-1.5 py-1 border border-brand-500/30 rounded-lg",children:[m("detail.upload"),o.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:async ue=>{const he=ue.target.files?.[0];if(!he)return;const Ve=new FormData;Ve.append("image",he);try{const dt=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(b)}/images`,{method:"POST",body:Ve,credentials:"include"});if(dt.ok){const ot=(await dt.json()).path;if(jt(ot),ke(!1),T){const Ft={...T,icon:ot};A(Ft),await Se.builder.artifacts.save(e,Ft)}V(!0)}}catch{}}})]}),rt&&o.jsx("button",{onClick:()=>{tt("icon",""),ke(!1)},className:"text-[10px] text-fg-tertiary hover:text-red-400 px-1",children:"✕"})]}),o.jsx("div",{className:"max-h-64 overflow-y-auto",children:Jde.map(ue=>o.jsxs("div",{className:"mb-2.5",children:[o.jsx("div",{className:"text-[10px] text-fg-tertiary mb-1 sticky top-0 bg-surface-secondary py-0.5",children:ue.label}),o.jsx("div",{className:"flex flex-wrap gap-0.5",children:ue.emojis.map(he=>o.jsx("button",{onClick:()=>{tt("icon",he),ke(!1)},className:`w-7 h-7 rounded flex items-center justify-center text-base hover:bg-surface-elevated transition-colors ${rt===he?"ring-1.5 ring-brand-500 bg-brand-500/10":""}`,children:he},he))})]},ue.label))})]})]})]}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[o.jsx(L0,{value:Ne,onChange:ue=>tt("displayName",ue),renderAs:"h1",className:"text-xl font-bold text-fg-primary",placeholder:m("detail.untitled"),readOnly:i}),o.jsx("span",{className:`text-[10px] font-medium uppercase tracking-wider px-2 py-0.5 rounded-full ${ne.bg} ${ne.color}`,children:ne.label}),o.jsx(L0,{value:Ue,onChange:ue=>tt("version",ue),renderAs:"badge",className:"text-[10px] px-2 py-0.5 rounded-full bg-surface-elevated text-fg-tertiary border border-border-default font-mono",placeholder:"1.0.0",readOnly:i})]}),o.jsx(L0,{value:me,onChange:ue=>tt("description",ue),renderAs:"p",className:"text-sm text-fg-secondary mt-1.5 leading-relaxed",placeholder:m("detail.addDescription"),multiline:!0,readOnly:i}),o.jsxs("div",{className:"flex items-center gap-2 mt-2 flex-wrap",children:[o.jsx(Zde,{value:Ye,options:Qde,onChange:ue=>tt("category",ue),className:"text-xs px-2 py-0.5 rounded bg-surface-elevated text-fg-tertiary",readOnly:i}),o.jsx(eue,{tags:mt,onChange:ue=>tt("tags",ue),readOnly:i})]})]})]}),o.jsx("div",{className:"mb-8",children:o.jsx(nue,{images:U,artifactType:e,artifactName:t,onUpload:Me,onRemove:Ie,readOnly:i,cacheBust:oe})}),u&&o.jsx("div",{className:"mb-8",children:u}),e==="team"&&T.team&&o.jsx("div",{className:"mb-8",children:o.jsx(aue,{members:T.team.members,teamTopFiles:Pe,files:k,artifactName:b,onFileSave:it,readOnly:i})}),e==="agent"&&Ce.length>0&&o.jsxs("div",{className:"mb-8",children:[o.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-4 uppercase tracking-wider",children:m("artifact.aboutThisAgent")}),o.jsx(Km,{noHeader:!0,files:Ce,onSave:it,readOnly:i})]}),e==="skill"&&o.jsxs("div",{className:"mb-8",children:[T.skill?.requiredPermissions&&T.skill.requiredPermissions.length>0&&o.jsxs("div",{className:"mb-6",children:[o.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:m("sidebar.permissions")}),o.jsx("div",{className:"flex flex-wrap gap-2",children:T.skill.requiredPermissions.map(ue=>{const he=Xde[ue];return o.jsxs("span",{className:`inline-flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg border font-medium ${he?.color??"bg-surface-elevated text-fg-secondary border-border-default"}`,children:[o.jsx("span",{className:"font-mono text-[10px]",children:he?.icon??"?"})," ",ue]},ue)})})]}),T.skill?.mcpServers&&Object.keys(T.skill.mcpServers).length>0&&o.jsxs("div",{className:"mb-6",children:[o.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:m("artifact.integrations")}),o.jsx("div",{className:"grid gap-2",children:Object.entries(T.skill.mcpServers).map(([ue,he])=>o.jsxs("div",{className:"rounded-lg border border-border-default bg-surface-secondary/40 px-4 py-3 flex items-center gap-3",children:[o.jsx("span",{className:"w-8 h-8 rounded-lg bg-purple-500/15 flex items-center justify-center text-purple-400 text-sm shrink-0",children:"◎"}),o.jsxs("div",{children:[o.jsx("div",{className:"text-xs font-medium text-fg-primary",children:ue}),o.jsx("div",{className:"text-[10px] text-fg-muted font-mono truncate",children:typeof he=="object"?JSON.stringify(he).slice(0,80):String(he)})]})]},ue))})]}),re&&o.jsxs("div",{children:[o.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:m("artifact.instructions")}),o.jsx("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:o.jsx(Qg,{content:re})})]})]}),$e.length>0&&o.jsx(Km,{files:$e,onSave:it,readOnly:i})]}),o.jsx("div",{className:`${f?"w-full":"w-72 shrink-0"}`,children:o.jsxs("div",{className:`${f?"":"sticky top-6"} space-y-4`,children:[o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[o.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.info")}),o.jsxs("div",{className:"space-y-2 text-xs",children:[o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-fg-muted",children:m("sidebar.type")}),o.jsx("span",{className:`font-medium ${ne.color}`,children:ne.label})]}),o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-fg-muted",children:m("sidebar.category")}),o.jsx("span",{className:"text-fg-secondary",children:Ye})]}),o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-fg-muted",children:m("sidebar.version")}),o.jsx("span",{className:"text-fg-secondary font-mono",children:Ue})]}),T.author&&o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-fg-muted",children:m("sidebar.author")}),o.jsx("span",{className:"text-fg-secondary",children:typeof T.author=="string"?T.author:T.author?.name??""})]})]})]}),e==="agent"&&T.agent&&o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[o.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.agentSpecs")}),o.jsxs("div",{className:"space-y-2 text-xs",children:[T.agent.roleName&&o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-fg-muted",children:m("sidebar.role")}),o.jsx("span",{className:"text-fg-secondary",children:T.agent.roleName})]}),T.agent.llmProvider&&o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-fg-muted",children:m("sidebar.provider")}),o.jsx("span",{className:"text-fg-secondary",children:T.agent.llmProvider})]}),T.agent.llmModel&&o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-fg-muted",children:m("sidebar.model")}),o.jsx("span",{className:"text-fg-secondary font-mono",children:T.agent.llmModel})]}),T.agent.temperature!==void 0&&o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-fg-muted",children:m("sidebar.temperature")}),o.jsx("span",{className:"text-fg-secondary",children:T.agent.temperature})]})]})]}),e==="team"&&T.team&&o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[o.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.composition")}),o.jsxs("div",{className:"space-y-2 text-xs",children:[o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-fg-muted",children:m("sidebar.totalMembers")}),o.jsx("span",{className:"text-fg-secondary",children:T.team.members.reduce((ue,he)=>ue+he.count,0)})]}),o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-fg-muted",children:m("sidebar.managers")}),o.jsx("span",{className:"text-amber-400",children:T.team.members.filter(ue=>ue.role==="manager").reduce((ue,he)=>ue+he.count,0)})]}),o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-fg-muted",children:m("sidebar.workers")}),o.jsx("span",{className:"text-blue-400",children:T.team.members.filter(ue=>ue.role!=="manager").reduce((ue,he)=>ue+he.count,0)})]})]})]}),e==="skill"&&T.skill&&o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[o.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.skillInfo")}),o.jsxs("div",{className:"space-y-2 text-xs",children:[T.skill.alwaysOn!==void 0&&o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-fg-muted",children:m("sidebar.alwaysOn")}),o.jsx("span",{className:T.skill.alwaysOn?"text-green-400":"text-fg-secondary",children:T.skill.alwaysOn?m("sidebar.yes"):m("sidebar.no")})]}),o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-fg-muted",children:m("sidebar.skillFile")}),o.jsx("span",{className:"text-fg-secondary font-mono truncate ml-2",children:T.skill.skillFile})]}),T.skill.requiredPermissions&&T.skill.requiredPermissions.length>0&&o.jsxs("div",{children:[o.jsx("span",{className:"text-fg-muted",children:m("sidebar.permissions")}),o.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:T.skill.requiredPermissions.map(ue=>o.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-elevated text-fg-muted rounded border border-border-default",children:ue},ue))})]})]})]}),T.dependencies&&(T.dependencies.skills?.length||T.dependencies.env?.length)?o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[o.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.dependencies")}),T.dependencies.skills?.length?o.jsxs("div",{children:[o.jsx("div",{className:"text-[10px] text-fg-muted mb-1",children:m("sidebar.skills")}),o.jsx("div",{className:"flex flex-wrap gap-1",children:T.dependencies.skills.map(ue=>o.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-secondary rounded border border-border-default",children:ue},ue))})]}):null,T.dependencies.env?.length?o.jsxs("div",{children:[o.jsx("div",{className:"text-[10px] text-fg-muted mb-1",children:m("sidebar.environment")}),o.jsx("div",{className:"flex flex-wrap gap-1",children:T.dependencies.env.map(ue=>o.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-secondary rounded font-mono border border-border-default",children:ue},ue))})]}):null]}):null,!i&&M&&o.jsxs("button",{onClick:()=>Se.system.openPath(M).catch(()=>{}),className:"w-full text-left rounded-xl border border-border-default bg-surface-secondary/60 px-4 py-3 text-[10px] text-fg-muted hover:text-fg-secondary hover:border-gray-600 transition-colors truncate",title:M,children:[o.jsx("span",{className:"text-fg-tertiary block mb-0.5",children:m("sidebar.openInFinder")}),M.replace(/.*\.markus\//,"~/.markus/")]})]})})]})]}),!i&&D&&o.jsx(iue,{onClose:()=>ee(!1),onConfirm:(ue,he)=>{ee(!1),xe({donationsEnabled:!1,priceCents:ue==="paid"?he:void 0})},isUpdate:j.shared}),!i&&R&&o.jsx(rue,{onClose:()=>te(!1),onConfirm:(ue,he,Ve,dt)=>{te(!1),xe({visibility:ue,orgId:he,priceCents:Ve,donationsEnabled:dt})}}),$&&o.jsx(xr,{alertOnly:!0,variant:$.variant??"primary",title:$.title,message:$.message,onConfirm:()=>W(null),onCancel:()=>W(null)})]}):o.jsx("div",{className:"flex-1 overflow-y-auto",children:o.jsxs("div",{className:"px-6 py-8",children:[o.jsxs("button",{onClick:n,className:"text-xs text-brand-400 hover:text-brand-300 mb-4 inline-flex items-center gap-1",children:[o.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("polyline",{points:"15 18 9 12 15 6"})}),m("detail.backToBuilder")]}),o.jsx("div",{className:"text-fg-tertiary text-sm py-20 text-center",children:m("detail.notFound")})]})})}function rue({onClose:e,onConfirm:t}){const{t:n}=ut(["builder","common"]),[a,i]=w.useState("public"),[l,c]=w.useState([]),[u,m]=w.useState(""),[f,g]=w.useState(!1),[h,b]=w.useState(0),[y,k]=w.useState(!1);w.useEffect(()=>{a==="org"&&l.length===0&&(g(!0),at.myOrgs().then(A=>{c(A.memberships),A.memberships.length>0&&m(A.memberships[0].id)}).catch(()=>{}).finally(()=>g(!1)))},[a,l.length]);const C=a==="public"||a==="unlisted",T=[{value:"public",icon:o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),o.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),label:n("visibility.public"),desc:n("visibility.publicDesc")},{value:"org",icon:o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M3 21h18"}),o.jsx("path",{d:"M9 8h1"}),o.jsx("path",{d:"M9 12h1"}),o.jsx("path",{d:"M9 16h1"}),o.jsx("path",{d:"M14 8h1"}),o.jsx("path",{d:"M14 12h1"}),o.jsx("path",{d:"M14 16h1"}),o.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}),label:n("visibility.org"),desc:n("visibility.orgDesc")},{value:"unlisted",icon:o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),o.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}),label:n("visibility.unlisted"),desc:n("visibility.unlistedDesc")}];return o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:e,children:o.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:A=>A.stopPropagation(),children:[o.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-1",children:n("visibility.label")}),o.jsx("p",{className:"text-[11px] text-fg-tertiary mb-4 leading-relaxed",children:n("visibility.subtitle")}),o.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-fg-tertiary font-semibold mb-2",children:["1 · ",n("visibility.public")," / ",n("visibility.org")]}),o.jsx("div",{className:"space-y-2 mb-5",children:T.map(A=>o.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${a===A.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[o.jsx("input",{type:"radio",name:"visibility",checked:a===A.value,onChange:()=>i(A.value),className:"accent-brand-500"}),o.jsx("div",{className:"flex items-center gap-2 text-fg-secondary",children:A.icon}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium text-fg-primary",children:A.label}),o.jsx("div",{className:"text-[11px] text-fg-tertiary",children:A.desc})]})]},A.value))}),a==="org"&&o.jsxs("div",{className:"mb-5",children:[o.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("visibility.orgSelect")}),f?o.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:n("common:loading")}):l.length===0?o.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:n("visibility.orgNone")}):o.jsx("select",{value:u,onChange:A=>m(A.target.value),className:"w-full text-sm px-3 py-2 rounded-lg bg-surface-elevated border border-border-default text-fg-primary",children:l.map(A=>o.jsx("option",{value:A.id,children:A.name},A.id))})]}),C&&o.jsxs("div",{className:"mb-5",children:[o.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-fg-tertiary font-semibold mb-2",children:["2 · ",n("pricing.label")]}),o.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("pricing.label")}),o.jsx("div",{className:"grid grid-cols-4 gap-2 mb-3",children:aA.map(A=>o.jsx("button",{type:"button",onClick:()=>b(A.cents),className:`text-sm px-2 py-2 rounded-lg border transition-colors ${h===A.cents?"border-brand-500 bg-brand-500/10 text-fg-primary":"border-border-default text-fg-secondary hover:border-gray-600"}`,children:A.label},A.cents))}),o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:y,onChange:A=>k(A.target.checked),className:"accent-brand-500"}),o.jsx("span",{className:"text-xs text-fg-secondary",children:n("pricing.enableTips")})]})]}),C&&o.jsx("div",{className:"mb-4 text-[11px] text-fg-tertiary rounded-lg border border-border-default px-3 py-2",children:n("pricing.reviewNote")}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx("button",{onClick:e,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:n("common:cancel")}),o.jsx("button",{onClick:()=>t(a,a==="org"?u:void 0,C&&h>0?h:void 0,C?y:void 0),disabled:a==="org"&&!u,className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n("shareMode.share")})]})]})})}const aA=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function iue({onClose:e,onConfirm:t,isUpdate:n}){const{t:a}=ut(["builder","common"]),[i,l]=w.useState(0);return o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:e,children:o.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:c=>c.stopPropagation(),children:[o.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:a(n?"shareMode.titleUpdate":"share.toHub")}),o.jsx("div",{className:"space-y-2 mb-5",children:aA.map(c=>o.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${i===c.cents?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[o.jsx("input",{type:"radio",name:"sharePrice",checked:i===c.cents,onChange:()=>l(c.cents),className:"accent-brand-500"}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium text-fg-primary",children:c.label}),o.jsx("div",{className:"text-[11px] text-fg-tertiary",children:c.cents===0?a("shareMode.freeDesc"):a("shareMode.paidDesc")})]})]},c.cents))}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx("button",{onClick:e,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:a("common:cancel")}),o.jsx("button",{onClick:()=>t(i>0?"paid":"free",i),className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand transition-colors",children:a(n?"shareMode.update":"shareMode.share")})]})]})})}function Vm(e,t){return!e||!EC(e)?null:e.startsWith("http")||e.startsWith("data:")?e:e.startsWith("/")&&t?`${t}${e}`:e}function sue({type:e,seed:t,icon:n,hubBase:a,size:i=44,className:l="",rounded:c="rounded-xl"}){const u=il(e),m=Vm(n,a),f=w.useMemo(()=>Fb(u,t),[u,t]),g=w.useMemo(()=>TC(t),[t]),[h,b]=w.useState(!1);return m&&!h?o.jsx("img",{src:m,alt:"",onError:()=>b(!0),style:{width:i,height:i},className:`${c} object-cover shrink-0 ${l}`}):Yle(n)?o.jsx("div",{style:{width:i,height:i,background:f,fontSize:i*.5},className:`${c} shrink-0 flex items-center justify-center shadow-inner ${l}`,children:o.jsx("span",{className:"drop-shadow-sm",children:n})}):n&&tJ(n)?o.jsx("div",{style:{width:i,height:i,background:f},className:`${c} shrink-0 flex items-center justify-center text-white shadow-inner ${l}`,children:o.jsx(LS,{name:n,size:i*.52,className:"drop-shadow-sm"})}):o.jsx("div",{style:{width:i,height:i,background:f},className:`${c} shrink-0 flex items-center justify-center shadow-inner ${l}`,children:o.jsx("svg",{width:i*.55,height:i*.55,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:o.jsx("path",{d:g,fill:"rgba(255,255,255,0.92)"})})})}function Wm({name:e,username:t,avatarUrl:n,hubBase:a,size:i=24,className:l="",verified:c}){const u=t||e||"markus",m=Vm(n,a),[f,g]=w.useState(!1),h=m&&!f?m:Qle(u);return o.jsxs("span",{className:`relative inline-flex shrink-0 ${l}`,style:{width:i,height:i},children:[o.jsx("img",{src:h,alt:e||t||"",onError:()=>g(!0),className:"w-full h-full rounded-full object-cover ring-1 ring-white/10 bg-surface-elevated"}),c&&o.jsx("span",{className:"absolute -right-0.5 -bottom-0.5 flex items-center justify-center rounded-full bg-brand-500 text-on-brand ring-2 ring-surface-primary",style:{width:i*.42,height:i*.42},children:o.jsx("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%",fill:"currentColor","aria-hidden":!0,children:o.jsx("path",{d:"M9 16.2l-3.5-3.5 1.4-1.4L9 13.4l7.1-7.1 1.4 1.4z"})})})]})}function oue({type:e,className:t=""}){const n=il(e),a=Bs[n];return o.jsx("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-semibold tracking-wide text-white bg-gradient-to-r ${a.gradient} ${t}`,children:a.label})}function s4({rating:e=0}){const t=Math.round(e);return o.jsx("span",{className:"inline-flex items-center","aria-label":`${e} out of 5`,children:[0,1,2,3,4].map(n=>o.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",className:n<t?"text-amber-400":"text-fg-muted/40",fill:"currentColor","aria-hidden":!0,children:o.jsx("path",{d:"M12 2l2.4 6.9L21 9l-5.4 4 2 7-5.6-4.1L6.4 20l2-7L3 9l6.6-.1z"})},n))})}function mr(e){const{type:t,name:n,description:a,seed:i,icon:l,cover:c,hubBase:u,author:m,authorLabel:f,version:g,category:h,tags:b,rating:y=0,ratingCount:k=0,downloadCount:C=0,priceCents:T,currency:A="usd",installed:M,glowing:I,selected:B,showTypeBadge:G=!0,hideStats:j=!1,cornerLabel:O,actions:F,footerLeft:Y,headerAction:q,onClick:V,className:z=""}=e,J=il(t),D=Bs[J],ee=i||n,R=(T??0)>0,te=!!Vm(c||void 0,u),le=Fb(J,ee),ke=f??m?.displayName??m?.username??"",[$,W]=w.useState(null),oe=M?o.jsx("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-500/12 text-emerald-400 border border-emerald-500/25 px-2 py-0.5 text-[10px] font-semibold",children:o.jsx("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3.5",children:o.jsx("polyline",{points:"20 6 9 17 4 12"})})}):O?o.jsx("span",{className:"chip",children:O}):R?o.jsx("span",{className:"badge-paid",children:Bk(T,A)}):null;if(te){const L=Vm(c||void 0,u);return o.jsxs("div",{onClick:V,style:{aspectRatio:$??void 0},className:`group asset-card card-shine relative flex flex-col overflow-hidden min-h-[180px] ${V?"cursor-pointer":""} ${B?"ring-1 ring-brand-500/60":""} ${I?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${z}`,children:[o.jsx("img",{src:L,alt:"",onLoad:Ne=>{const qe=Ne.currentTarget;qe.naturalWidth&&qe.naturalHeight&&W(Math.min(1.9,Math.max(1,qe.naturalWidth/qe.naturalHeight)))},className:"absolute inset-0 w-full h-full object-cover transition-transform duration-[600ms] group-hover:scale-[1.05]"}),o.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/90 via-black/50 to-black/5"}),o.jsx("div",{className:"absolute inset-x-0 top-0 h-20 bg-gradient-to-b from-black/50 to-transparent"}),o.jsxs("div",{className:"relative flex items-start justify-between gap-2 p-3",children:[o.jsx("span",{children:G&&o.jsx(oue,{type:J})}),o.jsxs("span",{className:"flex items-center gap-1.5",onClick:Ne=>Ne.stopPropagation(),children:[M?o.jsx("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-500/25 text-emerald-50 border border-emerald-300/40 px-2 py-0.5 text-[10px] font-semibold backdrop-blur-md",children:o.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:o.jsx("polyline",{points:"20 6 9 17 4 12"})})}):O?o.jsx("span",{className:"inline-flex items-center rounded-full bg-white/15 text-white border border-white/25 px-2 py-0.5 text-[10px] font-medium backdrop-blur-md",children:O}):q?null:o.jsx("span",{className:R?"badge-paid":"badge-free",children:Bk(T,A)}),q]})]}),o.jsxs("div",{className:"relative mt-auto p-4 pt-10 flex flex-col gap-2 text-white",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h3",{className:"text-[15px] font-semibold truncate drop-shadow-md",children:n}),g&&o.jsxs("span",{className:"shrink-0 rounded-full bg-white/15 border border-white/25 px-1.5 py-0.5 text-[10px] font-medium backdrop-blur-md",children:["v",g]})]}),ke&&o.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-white/85",children:[m&&o.jsx(Wm,{name:m.displayName,username:m.username,avatarUrl:m.avatarUrl,hubBase:u,size:15}),o.jsx("span",{className:"truncate",children:ke})]}),a&&o.jsx("p",{className:"text-[12.5px] text-white/80 truncate leading-snug drop-shadow-sm",children:a}),(h||b&&b.length>0)&&o.jsxs("div",{className:"flex flex-nowrap gap-1.5 overflow-hidden",children:[h&&o.jsx("span",{className:"shrink-0 rounded-full bg-white/15 border border-white/20 text-white/95 px-2 py-0.5 text-[10px] font-semibold capitalize backdrop-blur-md",children:h}),b?.slice(0,3).map(Ne=>o.jsx("span",{className:"shrink-0 rounded-full bg-white/10 border border-white/15 text-white/85 px-2 py-0.5 text-[10px] backdrop-blur-md",children:Ne},Ne))]}),(!j||F)&&o.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1 shrink-0",children:[j?o.jsx("span",{}):o.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-white/80",children:[o.jsxs("span",{className:"inline-flex items-center gap-1",children:[o.jsx(s4,{rating:y}),k>0&&o.jsxs("span",{className:"text-white/60",children:["(",qo(k),")"]})]}),o.jsxs("span",{className:"inline-flex items-center gap-1",children:[o.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":!0,children:o.jsx("path",{d:"M12 3v12m0 0l-4-4m4 4l4-4M5 21h14"})}),qo(C)]})]}),F&&o.jsx("div",{className:"flex items-center gap-2",onClick:Ne=>Ne.stopPropagation(),children:F})]})]})]})}return o.jsxs("div",{onClick:V,className:`group asset-card card-shine relative flex flex-col ${V?"cursor-pointer":""} ${B?"ring-1 ring-brand-500/60":""} ${I?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${z}`,children:[o.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-[2px] opacity-0 group-hover:opacity-100 transition-opacity duration-300",style:{background:`linear-gradient(90deg, transparent, ${D.accent}, transparent)`}}),o.jsx("div",{className:"pointer-events-none absolute -top-10 -left-10 w-36 h-36 rounded-full blur-2xl opacity-[0.12] group-hover:opacity-20 transition-opacity duration-300",style:{background:le}}),q&&o.jsx("div",{className:"absolute top-2.5 right-2.5 z-10",onClick:L=>L.stopPropagation(),children:q}),o.jsxs("div",{className:"relative p-4 flex flex-col flex-1 gap-2.5",children:[o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx(sue,{type:J,seed:ee,icon:l,hubBase:u,size:46,rounded:"rounded-2xl",className:"ring-1 ring-white/10 shadow-sm shadow-black/20"}),o.jsxs("div",{className:`min-w-0 flex-1 ${q?"pr-7":""}`,children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-primary truncate group-hover:text-brand-300 transition-colors",children:n}),g&&o.jsxs("span",{className:"chip shrink-0",children:["v",g]}),oe&&o.jsx("span",{className:"ml-auto shrink-0",children:oe})]}),(ke||G)&&o.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-[11px] text-fg-tertiary min-w-0",children:[m&&o.jsx(Wm,{name:m.displayName,username:m.username,avatarUrl:m.avatarUrl,hubBase:u,size:15}),ke&&o.jsx("span",{className:"truncate",children:ke}),G&&o.jsxs(o.Fragment,{children:[ke&&o.jsx("span",{className:"text-fg-muted",children:"·"}),o.jsx("span",{className:"font-semibold shrink-0",style:{color:D.accent},children:D.label})]})]})]})]}),a&&o.jsx("p",{className:"text-[13px] text-fg-secondary truncate leading-snug",children:a}),(h||b&&b.length>0)&&o.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[h&&o.jsx("span",{className:"chip-accent capitalize",children:h}),b?.slice(0,3).map(L=>o.jsx("span",{className:"chip",children:L},L)),(b?.length??0)>3&&o.jsxs("span",{className:"text-[10px] text-fg-muted self-center",children:["+",(b?.length??0)-3]})]}),(()=>{const L=Y??(j?null:o.jsxs("span",{className:"flex items-center gap-3 text-[11px] text-fg-tertiary",children:[o.jsxs("span",{className:"inline-flex items-center gap-1",children:[o.jsx(s4,{rating:y}),o.jsx("span",{className:"text-fg-muted",children:k>0?`(${qo(k)})`:""})]}),o.jsxs("span",{className:"inline-flex items-center gap-1",children:[o.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":!0,children:o.jsx("path",{d:"M12 3v12m0 0l-4-4m4 4l4-4M5 21h14"})}),qo(C)]})]}));return!L&&!F?null:o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 pt-2 mt-auto border-t border-border-subtle/60",onClick:Ne=>Ne.stopPropagation(),children:[L&&o.jsx("div",{className:"min-w-0 flex items-center gap-2",children:L}),F&&o.jsx("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:F})]})})()]})]})}function Ha({children:e,maxCardWidth:t=400,gap:n="1rem",className:a=""}){const i=w.useRef(null),[l,c]=w.useState(0);w.useEffect(()=>{const g=i.current;if(!g)return;c(g.clientWidth);const h=new ResizeObserver(b=>{for(const y of b)c(y.contentRect.width)});return h.observe(g),()=>h.disconnect()},[]);const u=Math.max(1,Math.ceil((l||t)/t)),m=w.Children.toArray(e),f=Array.from({length:u},()=>[]);return m.forEach((g,h)=>{f[h%u].push(g)}),o.jsx("div",{ref:i,className:`flex items-start ${a}`,style:{gap:n},children:f.map((g,h)=>o.jsx("div",{className:"cv-stack flex flex-col flex-1 min-w-0",style:{gap:n,maxWidth:t},children:g},h))})}function lue(e){const t=e.indexOf(".markus/builder-artifacts/");return t>=0?"~/"+e.slice(t):e}const cue=[{id:"hireAgent",icon:"✦",color:"from-brand-500 to-purple-600",borderColor:"border-brand-500/30 hover:border-brand-400/50",bgColor:"bg-brand-500/10"},{id:"buildTeam",icon:"◈",color:"from-blue-500 to-blue-600",borderColor:"border-blue-500/30 hover:border-blue-400/50",bgColor:"bg-blue-500/10"},{id:"createSkill",icon:"⬡",color:"from-green-500 to-green-600",borderColor:"border-green-500/30 hover:border-green-400/50",bgColor:"bg-green-500/10"}];function due(){const[e,t]=w.useState(()=>{const a=window.location.hash.slice(1).split("/");return Tc(a[0])===ce.BUILDER&&a[1]&&a[2]?{type:a[1],name:decodeURIComponent(a[2])}:null});return w.useEffect(()=>{const n=()=>{const i=window.location.hash.slice(1).split("/");Tc(i[0])===ce.BUILDER&&i[1]&&i[2]?t({type:i[1],name:decodeURIComponent(i[2])}):t(null)};return window.addEventListener("hashchange",n),()=>window.removeEventListener("hashchange",n)},[]),e}const rA="markus_builder_shared_map";function uue(){try{const e=localStorage.getItem(rA);if(!e)return new Map;const t=JSON.parse(e);return new Map(Object.entries(t))}catch{return new Map}}function zu(e){try{localStorage.setItem(rA,JSON.stringify(Object.fromEntries(e)))}catch{}}function iA({authUser:e}={}){const{t}=ut(["builder","common"]),n=Xo(),a=due(),[i,l]=w.useState([]),[c,u]=w.useState([]),[m,f]=w.useState(!1),[g,h]=w.useState("all"),[b,y]=w.useState(null),[k,C]=w.useState(new Map),[T,A]=w.useState(null),[M,I]=w.useState(null),[B,G]=w.useState(null),[j,O]=w.useState(uue),[F,Y]=w.useState(null),[q,V]=w.useState(null),[z,J]=w.useState(null),[D,ee]=w.useState(null),[R,te]=w.useState(null),[le,ke]=w.useState("creations"),[$,W]=w.useState([]),[oe,L]=w.useState(""),[Ne,qe]=w.useState([]),[me,ze]=w.useState(!1),[Ue,je]=w.useState("all"),Ye=w.useCallback(()=>{f(!0),Promise.all([(Ls(La.builderArtifacts)??Se.builder.artifacts.list()).then(ie=>ie?.artifacts??[]).catch(()=>[]),(Ls(La.builderAgents)??Se.agents.list()).then(ie=>ie?.agents??[]).catch(()=>[]),(Ls(La.builderHubMyItems)??at.myItems()).then(ie=>ie?.items??[]).catch(()=>[]),(Ls(La.builderInstalled)??Se.builder.artifacts.installed()).then(ie=>ie?.installed??{}).catch(()=>({}))]).then(([ie,tt,it,xe])=>{if(u(ie),l(tt),it.length>0){const Ie=new Map;for(const ne of it){const U=ne.itemType==="agent"?"agent":ne.itemType==="team"?"team":"skill";for(const re of ie)re.type===U&&(ne.slug===re.name||ne.name===(re.meta.displayName||re.meta.name||re.name))&&Ie.set(`${re.type}/${re.name}`,{id:ne.id,name:ne.name,slug:ne.slug||re.name,version:ne.version||"1.0.0",visibility:ne.visibility??"public",moderationStatus:ne.moderationStatus,moderationNote:ne.moderationNote,pendingReview:ne.pendingReview})}Ie.size>0&&O(ne=>{const U=new Map(ne);for(const[re,Ce]of Ie)U.set(re,Ce);return zu(U),U})}const Me=new Map;for(const Ie of ie){const ne=`${Ie.type}/${Ie.name}`,U=xe[ne];U&&Me.set(ne,{agentId:U.agentId,agentIds:U.agentIds,teamId:U.teamId})}C(Me)}).finally(()=>f(!1))},[]);w.useEffect(()=>{Ye();const ie=tt=>{tt.detail?.page===ce.BUILDER&&Ye()};return window.addEventListener("markus:navigate",ie),()=>window.removeEventListener("markus:navigate",ie)},[Ye]);const xt=ie=>{const tt=i.find(it=>it.role==="Secretary"||it.name==="Secretary");tt?yt.navigate(ce.TEAM,{agentId:tt.id,prefillMessage:ie}):yt.navigate(ce.TEAM,{prefillMessage:ie})},mt=async ie=>{const tt=`${ie.type}/${ie.name}`;if(!k.has(tt)){y({key:tt,action:"install"});try{const it=await Se.builder.artifacts.install(ie.type,ie.name),xe={};it.agent&&typeof it.agent=="object"&&(xe.agentId=it.agent.id),it.team&&typeof it.team=="object"&&(xe.teamId=it.team.id),Array.isArray(it.agents)&&(xe.agentIds=it.agents.map(Me=>Me.id)),C(Me=>new Map(Me).set(tt,xe)),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(it){console.error("Install failed:",it),V({title:t("common:install"),message:t("installFailed",{error:String(it)}),variant:"danger"})}finally{y(null)}}},ft=async ie=>{const tt=`${ie.type}/${ie.name}`;if(k.has(tt)){y({key:tt,action:"uninstall"});try{await Se.builder.artifacts.uninstall(ie.type,ie.name),C(it=>{const xe=new Map(it);return xe.delete(tt),xe}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(it){console.error("Uninstall failed:",it),V({title:t("common:uninstall"),message:t("uninstallFailed",{error:String(it)}),variant:"danger"})}finally{y(null)}}},rt=async(ie,tt)=>{const it=`${ie.type}/${ie.name}`;y({key:it,action:"share"});try{const xe=await Se.builder.artifacts.ensureSlugSafe(ie.type,ie.name,ie.meta.displayName||ie.meta.name||ie.name),Me=xe.name,Ie=xe.slug||jc(Me);if(!Ie)throw new Error("Invalid package slug: use English kebab-case for the artifact name (e.g. qwen-multimodal). Chinese-only names cannot be shared — rename the package slug and put the Chinese title in displayName.");const ne=`${ie.type}/${Me}`;xe.converted&&(u(cn=>cn.map(Ot=>Ot.type===ie.type&&Ot.name===ie.name?{...Ot,name:Me,path:xe.path,meta:{...Ot.meta,name:Me,displayName:xe.displayName??Ot.meta.displayName??ie.name}}:Ot)),O(cn=>{const Ot=new Map(cn),Ee=Ot.get(it);return Ee&&(Ot.delete(it),Ot.set(ne,{...Ee,slug:Ie,name:xe.displayName??Ee.name})),zu(Ot),Ot}),C(cn=>{const Ot=new Map(cn),Ee=Ot.get(it);return Ee&&(Ot.delete(it),Ot.set(ne,Ee)),Ot}));const U=await Se.builder.artifacts.get(ie.type,Me);let re={...ie.meta,name:Me,displayName:xe.displayName??ie.meta.displayName??ie.name};try{const cn=U.files?.[`${ie.type}.json`]??U.files?.["agent.json"]??U.files?.["team.json"]??U.files?.["skill.json"];cn&&(re={...JSON.parse(cn),...re,name:Me,displayName:re.displayName})}catch{}const Ce=re.displayName||re.name||Me,Pe=re.description||"",$e=re.category||"general",ue=Array.isArray(re.tags)?re.tags:[];let he=re.icon||void 0;const Ve=re.version||"1.0.0";if(he&&!he.startsWith("http")&&/\.(png|jpe?g|gif|webp|svg)$/i.test(he)){const cn=he.split("/").pop()??he;try{const Ot=await fetch(`/api/builder/artifacts/${ie.type}s/${encodeURIComponent(Me)}/images/${encodeURIComponent(cn)}`);if(Ot.ok){const Ee=await Ot.blob(),_e=new File([Ee],cn,{type:Ee.type}),De=await at.uploadImage(_e);De?.url&&(he=De.url)}}catch{}}let dt;const Je=[],ot=Array.isArray(re.screenshots)?re.screenshots:[];for(let cn=0;cn<ot.length;cn++){const Ot=ot[cn],Ee=Ot.split("/").pop()??Ot;try{const _e=await fetch(`/api/builder/artifacts/${ie.type}s/${encodeURIComponent(Me)}/images/${encodeURIComponent(Ee)}`);if(_e.ok){const De=await _e.blob(),Q=new File([De],Ee,{type:De.type}),be=await at.uploadImage(Q);be?.url&&(Je.push({url:be.url,alt:Ee,order:cn}),(cn===0||re.thumbnail===Ot)&&(dt=be.url))}}catch{}}const Ft=await at.publishViaProxy({itemType:ie.type==="team"?"team":ie.type==="skill"?"skill":"agent",name:Ce,slug:Ie,description:Pe,category:$e,tags:ue,icon:he,version:Ve,config:{...re,name:Me,displayName:Ce},files:U.files&&Object.keys(U.files).length>0?U.files:void 0,thumbnailUrl:dt,images:Je.length>0?Je:void 0,priceCents:tt?.priceCents,donationsEnabled:tt?.donationsEnabled,visibility:tt?.visibility,orgId:tt?.orgId});Ft.id&&(O(Ot=>{const Ee=new Map(Ot);return Ee.set(ne,{id:Ft.id,name:Ce,slug:Ft.slug??Ie,version:Ve,visibility:Ft.visibility??tt?.visibility??"public",moderationStatus:Ft.moderationStatus,pendingReview:Ft.pendingReview}),zu(Ee),Ee}),(Ft.visibility??tt?.visibility??"public")!=="org"?V({title:t("common:share"),message:xe.converted?t("share.convertedAndSubmitted",{previous:ie.name,slug:Ie}):Ft.updated?t("share.updateSubmitted"):t("share.submittedForReview"),variant:"primary"}):xe.converted&&V({title:t("common:share"),message:t("share.convertedSlug",{previous:ie.name,slug:Ie}),variant:"primary"}))}catch(xe){console.error("Share failed:",xe),V({title:t("common:share"),message:t("shareFailed",{error:xe instanceof Error?xe.message:String(xe)}),variant:"danger"})}finally{y(null)}},jt=async()=>{if(!F)return;const{key:ie}=F,tt=j.get(ie);if(Y(null),!tt)return;const it=tt.id;y({key:ie,action:"hubDelete"});try{await at.deleteItem(it),O(xe=>{const Me=new Map(xe);return Me.delete(ie),zu(Me),Me})}catch(xe){console.error("Hub delete failed:",xe),V({title:t("unshare"),message:t("hubDeleteFailed",{error:String(xe)}),variant:"danger"})}finally{y(null)}},ht=async()=>{if(!T)return;const ie=T,tt=`${ie.type}/${ie.name}`;A(null),y({key:tt,action:"delete"});try{await Se.builder.artifacts.delete(ie.type,ie.name),u(it=>it.filter(xe=>!(xe.type===ie.type&&xe.name===ie.name))),C(it=>{const xe=new Map(it);return xe.delete(tt),xe}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(it){console.error("Delete failed:",it)}finally{y(null)}},He=g==="all"?c:c.filter(ie=>ie.type===g);w.useEffect(()=>{le!=="orgAssets"||$.length>0||at.myOrgs().then(ie=>{W(ie.memberships),ie.memberships.length>0&&!oe&&L(ie.memberships[0].id)}).catch(()=>{})},[le,$.length,oe]),w.useEffect(()=>{le!=="orgAssets"||!oe||(ze(!0),at.browseItems({orgId:oe,limit:100}).then(ie=>qe(ie.items??[])).catch(()=>qe([])).finally(()=>ze(!1)))},[le,oe]);const Et=Ue==="all"?Ne:Ne.filter(ie=>ie.itemType===Ue),Kt=ie=>{history.pushState(null,"",Hs(ce.BUILDER,`${ie.type}/${encodeURIComponent(ie.name)}`)),window.dispatchEvent(new HashChangeEvent("hashchange"))};return w.useEffect(()=>(c2(ce.BUILDER,a?1:0),()=>c2(ce.BUILDER,0)),[a]),a?o.jsx(qs,{type:a.type,name:a.name,authUser:e,onBack:()=>{history.pushState(null,"",Hs(ce.BUILDER)),window.dispatchEvent(new HashChangeEvent("hashchange"))}}):o.jsx("div",{className:"flex-1 overflow-y-auto",children:o.jsxs("div",{className:`max-w-5xl mx-auto w-full ${n?"px-4 py-5":"px-6 py-6"}`,children:[o.jsxs("div",{className:"mb-6",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-xl font-bold text-fg-primary",children:t("title")}),o.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:t("subtitle")})]}),o.jsx("button",{onClick:Ye,className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors px-3 py-1.5 rounded-lg border border-border-default hover:border-gray-600",children:t("common:refresh")})]}),o.jsx("div",{className:`grid ${n?"grid-cols-1 gap-2":"grid-cols-3 gap-3"}`,children:cue.map(ie=>{const tt=t(`prompts.${ie.id}Prompt`),it=t(`prompts.${ie.id}Examples`,{returnObjects:!0}),xe=Array.isArray(it)?it:[];return o.jsx("button",{onClick:()=>xt(tt),className:`group text-left w-full rounded-xl border ${ie.borderColor} bg-surface-secondary/60 p-4 transition-all hover:bg-surface-secondary/80 hover:shadow-lg`,children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:`w-10 h-10 text-xl rounded-lg ${ie.bgColor} flex items-center justify-center shrink-0`,children:ie.icon}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("h3",{className:`text-sm font-semibold bg-gradient-to-r ${ie.color} bg-clip-text text-transparent`,children:t(`prompts.${ie.id}`)}),o.jsx("p",{className:"text-[11px] text-fg-tertiary mt-1 leading-relaxed",children:t(`prompts.${ie.id}Desc`)}),xe.length>0&&o.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:xe.slice(0,2).map((Me,Ie)=>o.jsxs("span",{className:"text-[10px] text-fg-muted bg-surface-elevated/60 rounded-full px-2 py-0.5 border border-border-default",onClick:ne=>{ne.stopPropagation(),xt(tt+Me)},children:["“",Me,"”"]},Ie))})]})]})},ie.id)})})]}),o.jsx("div",{className:"mb-3",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("button",{onClick:()=>ke("creations"),className:`text-sm font-semibold transition-colors ${le==="creations"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("myCreations.title")}),o.jsx("button",{onClick:()=>ke("orgAssets"),className:`text-sm font-semibold transition-colors ${le==="orgAssets"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("orgAssets.title")})]}),le==="creations"&&o.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(ie=>o.jsx("button",{onClick:()=>h(ie),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${g===ie?"bg-brand-600 text-on-brand":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(ie==="all"?"myCreations.filterAll":ie==="agent"?"myCreations.filterAgents":ie==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},ie))}),le==="orgAssets"&&o.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(ie=>o.jsx("button",{onClick:()=>je(ie),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${Ue===ie?"bg-brand-600 text-on-brand":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(ie==="all"?"myCreations.filterAll":ie==="agent"?"myCreations.filterAgents":ie==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},ie))})]})}),le==="orgAssets"&&$.length>0&&o.jsx("div",{className:"flex gap-2 mb-3 overflow-x-auto pb-1",children:$.map(ie=>o.jsx("button",{onClick:()=>L(ie.id),className:`text-xs px-3 py-1.5 rounded-full whitespace-nowrap border transition-colors ${oe===ie.id?"bg-blue-500/15 border-blue-500/40 text-blue-400":"border-border-default text-fg-tertiary hover:text-fg-secondary hover:border-gray-600"}`,children:ie.name},ie.id))}),le==="orgAssets"&&($.length===0&&!me?o.jsx("div",{className:"text-center py-12",children:o.jsx("div",{className:"text-fg-tertiary text-sm",children:t("orgAssets.noOrgs")})}):me?o.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("orgAssets.loading")}):Et.length===0?o.jsx("div",{className:"text-center py-12",children:o.jsx("div",{className:"text-fg-tertiary text-sm",children:t("orgAssets.noItems")})}):o.jsx(Ha,{children:Et.map(ie=>{const tt=ie.author?.username&&ie.slug?`${at.getUrl()}/@${encodeURIComponent(ie.author.username)}/${encodeURIComponent(ie.slug)}`:null;return o.jsx(mr,{type:ie.itemType,name:ie.name,description:ie.description,seed:ie.slug||ie.id||ie.name,icon:ie.icon,cover:ie.thumbnailUrl,hubBase:at.getUrl(),author:ie.author,version:ie.version,rating:parseFloat(ie.avgRating)||0,ratingCount:ie.ratingCount,downloadCount:ie.downloadCount,actions:tt?o.jsxs("a",{href:tt,target:"_blank",rel:"noopener noreferrer",onClick:it=>{it.stopPropagation(),Ko()&&(it.preventDefault(),Or(tt))},className:"text-xs px-3 py-1.5 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors inline-flex items-center gap-1",children:[o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),o.jsx("polyline",{points:"15 3 21 3 21 9"}),o.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),"Hub"]}):void 0},ie.id)})})),le==="creations"&&(m&&c.length===0?o.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("myCreations.loadingArtifacts")}):He.length===0?o.jsxs("div",{className:"text-center py-12",children:[o.jsx("div",{className:"text-fg-tertiary text-sm",children:t("myCreations.noArtifacts")}),o.jsx("div",{className:"text-fg-muted text-xs mt-1",children:t("myCreations.noArtifactsHint")})]}):o.jsx(Ha,{children:He.map(ie=>{const tt=ie.meta.displayName||ie.meta.name||ie.name,it=ie.meta.description||"",xe=`${ie.type}/${ie.name}`,Me=b?.key===xe?b.action:null,Ie=j.get(xe),ne=ie.meta.version||"1.0.0",U=!!Ie,re=U&&Ie.version!==ne,Ce=()=>{const Je=at.getUser();return!Ie||!Je?null:`${at.getUrl()}/@${encodeURIComponent(Je.username)}/${encodeURIComponent(Ie.slug)}`},Pe=U&&Ie?.moderationStatus==="rejected",$e=o.jsxs("div",{className:"flex items-center gap-1.5 justify-end",onClick:Je=>Je.stopPropagation(),children:[k.has(xe)?o.jsxs("button",{onClick:()=>G(ie),disabled:!!Me,className:"text-xs px-3 py-1.5 rounded-lg border border-green-600/30 text-green-600 hover:bg-red-500/10 hover:text-red-500 hover:border-red-500/30 transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:[o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),o.jsx("polyline",{points:"17 8 12 3 7 8"}),o.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]}),t(Me==="uninstall"?"common:uninstalling":"common:uninstall")]}):o.jsxs("button",{onClick:()=>I(ie),disabled:!!Me,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:[o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),o.jsx("polyline",{points:"7 10 12 15 17 10"}),o.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),t(Me==="install"?"common:installing":"common:install")]}),U&&Pe?o.jsxs(o.Fragment,{children:[o.jsxs("button",{onClick:()=>{V({title:t("share.rejectedDetailTitle"),variant:"danger",message:`${t("share.rejectedReasonLabel")}${Ie?.moderationNote?Ie.moderationNote:t("share.rejectedNoReason")}
|
|
866
866
|
|
|
867
|
-
${t("share.rejectedEncourage")}`})},className:"text-xs px-2 py-1.5 rounded-lg border border-red-500/30 text-red-400 hover:bg-red-500/10 transition-colors inline-flex items-center gap-1 cursor-pointer",title:t("share.rejectedTip"),children:[o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),o.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),t("share.rejected")]}),o.jsxs("button",{onClick:()=>{rt(ie,{visibility:Ie?.visibility??"public"})},disabled:!!Me,className:"text-xs px-3 py-1.5 rounded-lg border border-brand-500/40 text-brand-400 hover:bg-brand-500/10 hover:border-brand-500/60 transition-colors disabled:opacity-50 inline-flex items-center gap-1",title:t("share.rejectedTip"),children:[o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("polyline",{points:"23 4 23 10 17 10"}),o.jsx("polyline",{points:"1 20 1 14 7 14"}),o.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]}),t(Me==="share"?"common:sharing":"share.resubmit")]})]}):U?o.jsxs(o.Fragment,{children:[re&&o.jsxs("button",{onClick:()=>{const Je=Ie?.visibility??"public";rt(ie,{visibility:Je})},disabled:!!Me,className:"text-xs px-3 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 hover:bg-amber-500/10 hover:border-amber-500/50 transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:[o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("polyline",{points:"23 4 23 10 17 10"}),o.jsx("polyline",{points:"1 20 1 14 7 14"}),o.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]}),Me==="share"?t("common:sharing"):t("share.updateVersion",{version:ne})]}),o.jsxs("a",{href:Ce()??"#",target:"_blank",rel:"noopener noreferrer",onClick:Je=>{const ot=Ce();Ko()&&ot&&(Je.preventDefault(),Or(ot))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1 ${Ie?.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/40":Ie?.visibility==="unlisted"?"border-gray-500/30 text-fg-tertiary hover:text-fg-secondary hover:border-gray-400/40":"border-green-600/30 text-green-600 hover:text-green-500 hover:border-green-500/40"}`,children:[Ie?.visibility==="org"?o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M3 21h18"}),o.jsx("path",{d:"M9 8h1"}),o.jsx("path",{d:"M9 12h1"}),o.jsx("path",{d:"M9 16h1"}),o.jsx("path",{d:"M14 8h1"}),o.jsx("path",{d:"M14 12h1"}),o.jsx("path",{d:"M14 16h1"}),o.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}):Ie?.visibility==="unlisted"?o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),o.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}):o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),o.jsx("polyline",{points:"15 3 21 3 21 9"}),o.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),Ie?.visibility==="org"?t("visibility.sharedOrg"):Ie?.visibility==="unlisted"?t("visibility.sharedUnlisted"):t("visibility.shared")]}),o.jsxs("button",{onClick:()=>Y({key:xe,name:tt}),disabled:!!Me,className:"text-xs px-2.5 py-1.5 rounded-lg border border-border-default text-fg-secondary hover:text-amber-500 hover:border-amber-500/40 hover:bg-amber-500/10 transition-colors disabled:opacity-50 inline-flex items-center gap-1",title:t("removeFromHubTooltip"),children:[o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),o.jsx("path",{d:"M5.17 11.75l-1.71 1.71a5 5 0 0 0 7.07 7.07l1.71-1.71"}),o.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"})]}),t("unshare")]})]}):o.jsxs("button",{onClick:async()=>{await at.ensureAuth(),Array.isArray(ie.meta.screenshots)&&ie.meta.screenshots.length>0?te(ie):J(ie)},disabled:!!Me,className:"text-xs px-3 py-1.5 rounded-lg border border-border-default text-fg-secondary hover:text-green-600 hover:border-green-500/30 transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:[o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("circle",{cx:"18",cy:"5",r:"3"}),o.jsx("circle",{cx:"6",cy:"12",r:"3"}),o.jsx("circle",{cx:"18",cy:"19",r:"3"}),o.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),o.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),t(Me==="share"?"common:sharing":"common:share")]})]}),ue=o.jsx("button",{onClick:()=>A(ie),disabled:!!Me,className:"w-7 h-7 rounded-lg text-fg-muted hover:text-red-500 hover:bg-red-500/10 transition-colors disabled:opacity-50 inline-flex items-center justify-center",title:t("deleteLocalTooltip"),children:o.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("polyline",{points:"3 6 5 6 21 6"}),o.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})}),he=ie.meta.icon,dt=!!he&&/\.(png|jpe?g|gif|webp|svg)$/i.test(he)?he.startsWith("http")||he.startsWith("/")?he:`/api/builder/artifacts/${ie.type}s/${encodeURIComponent(ie.name)}/images/${encodeURIComponent(he.split("/").pop()??"")}?v=${ie.updatedAt??""}`:he;return o.jsx(mr,{type:ie.type,name:tt,description:it,seed:xe,icon:dt,version:ne,footerLeft:o.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary min-w-0",children:[o.jsx("button",{onClick:Je=>{Je.stopPropagation(),Se.system.openPath(ie.path).catch(()=>{})},className:"hover:text-fg-secondary transition-colors truncate min-w-0",title:ie.path,children:lue(ie.path)}),o.jsx("span",{className:"shrink-0",children:"·"}),o.jsx("span",{className:"shrink-0",children:new Date(ie.updatedAt).toLocaleDateString()})]}),headerAction:ue,actions:$e,onClick:()=>Kt(ie)},xe)})})),M&&o.jsx(xr,{variant:"primary",title:t("confirmInstall"),message:t("confirmInstallMsg",{name:M.meta.displayName||M.meta.name||M.name}),confirmLabel:t("common:install"),onConfirm:()=>{const ie=M;I(null),mt(ie)},onCancel:()=>I(null)}),B&&o.jsx(xr,{variant:"primary",title:t("confirmUninstall"),message:t("confirmUninstallMsg",{name:B.meta.displayName||B.meta.name||B.name}),confirmLabel:t("common:uninstall"),onConfirm:()=>{const ie=B;G(null),ft(ie)},onCancel:()=>G(null)}),T&&o.jsx(xr,{title:t("confirmDeleteLocal"),message:t("deleteCannotUndo",{name:T.meta.displayName||T.meta.name||T.name}),confirmLabel:t("common:delete"),onConfirm:ht,onCancel:()=>A(null)}),F&&o.jsx(xr,{title:t("confirmUnshare"),message:t("removeFromHub",{name:F.name}),confirmLabel:t("unshare"),onConfirm:()=>{jt()},onCancel:()=>Y(null)}),q&&o.jsx(xr,{alertOnly:!0,variant:q.variant??"primary",title:q.title,message:q.message,onConfirm:()=>V(null),onCancel:()=>V(null)}),z&&o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>J(null),children:o.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ie=>ie.stopPropagation(),children:[o.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-2",children:t("common:share")}),o.jsx("p",{className:"text-sm text-fg-secondary mb-5",children:t("share.imagePrompt")}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx("button",{onClick:()=>{const ie=z;J(null),te(ie)},className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-fg-tertiary transition-colors",children:t("share.directly")}),o.jsx("button",{onClick:()=>{const ie=z;J(null),Kt(ie)},className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand transition-colors",children:t("share.addImagesFirst")})]})]})}),D&&o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>ee(null),children:o.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ie=>ie.stopPropagation(),children:o.jsx(pue,{isUpdate:j.has(`${D.type}/${D.name}`),onCancel:()=>ee(null),onConfirm:(ie,tt)=>{const it=D;ee(null),rt(it,{priceCents:tt>0?tt:void 0})}})})}),R&&o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>te(null),children:o.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ie=>ie.stopPropagation(),children:o.jsx(mue,{onCancel:()=>te(null),onConfirm:(ie,tt,it,xe)=>{const Me=R;te(null),rt(Me,{visibility:ie,orgId:tt,priceCents:it,donationsEnabled:xe})}})})})]})})}function mue({onCancel:e,onConfirm:t}){const{t:n}=ut(["builder","common"]),[a,i]=w.useState("public"),[l,c]=w.useState([]),[u,m]=w.useState(""),[f,g]=w.useState(!1),[h,b]=w.useState(0),[y,k]=w.useState(!1);w.useEffect(()=>{a==="org"&&l.length===0&&(g(!0),at.myOrgs().then(A=>{c(A.memberships),A.memberships.length>0&&m(A.memberships[0].id)}).catch(()=>{}).finally(()=>g(!1)))},[a,l.length]);const C=a==="public"||a==="unlisted",T=[{value:"public",icon:o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),o.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),label:n("visibility.public"),desc:n("visibility.publicDesc")},{value:"org",icon:o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M3 21h18"}),o.jsx("path",{d:"M9 8h1"}),o.jsx("path",{d:"M9 12h1"}),o.jsx("path",{d:"M9 16h1"}),o.jsx("path",{d:"M14 8h1"}),o.jsx("path",{d:"M14 12h1"}),o.jsx("path",{d:"M14 16h1"}),o.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}),label:n("visibility.org"),desc:n("visibility.orgDesc")},{value:"unlisted",icon:o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),o.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}),label:n("visibility.unlisted"),desc:n("visibility.unlistedDesc")}];return o.jsxs(o.Fragment,{children:[o.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:n("visibility.label")}),o.jsx("div",{className:"space-y-2 mb-5",children:T.map(A=>o.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${a===A.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[o.jsx("input",{type:"radio",name:"visibility",checked:a===A.value,onChange:()=>i(A.value),className:"accent-brand-500"}),o.jsx("div",{className:"flex items-center gap-2 text-fg-secondary",children:A.icon}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium text-fg-primary",children:A.label}),o.jsx("div",{className:"text-[11px] text-fg-tertiary",children:A.desc})]})]},A.value))}),a==="org"&&o.jsxs("div",{className:"mb-5",children:[o.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("visibility.orgSelect")}),f?o.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:n("common:loading")}):l.length===0?o.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:n("visibility.orgNone")}):o.jsx("select",{value:u,onChange:A=>m(A.target.value),className:"w-full text-sm px-3 py-2 rounded-lg bg-surface-elevated border border-border-default text-fg-primary",children:l.map(A=>o.jsx("option",{value:A.id,children:A.name},A.id))})]}),C&&o.jsxs("div",{className:"mb-5",children:[o.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("pricing.label")}),o.jsx("div",{className:"grid grid-cols-4 gap-2 mb-3",children:sA.map(A=>o.jsx("button",{type:"button",onClick:()=>b(A.cents),className:`text-sm px-2 py-2 rounded-lg border transition-colors ${h===A.cents?"border-brand-500 bg-brand-500/10 text-fg-primary":"border-border-default text-fg-secondary hover:border-gray-600"}`,children:A.label},A.cents))}),o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:y,onChange:A=>k(A.target.checked),className:"accent-brand-500"}),o.jsx("span",{className:"text-xs text-fg-secondary",children:n("pricing.enableTips")})]})]}),C&&o.jsx("div",{className:"mb-4 text-[11px] text-fg-tertiary rounded-lg border border-border-default px-3 py-2",children:n("pricing.reviewNote")}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx("button",{onClick:e,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:n("common:cancel")}),o.jsx("button",{onClick:()=>t(a,a==="org"?u:void 0,C&&h>0?h:void 0,C?y:void 0),disabled:a==="org"&&!u,className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n("shareMode.share")})]})]})}const sA=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function pue({isUpdate:e,onCancel:t,onConfirm:n}){const{t:a}=ut(["builder","common"]),[i,l]=w.useState(0);return o.jsxs(o.Fragment,{children:[o.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:a(e?"shareMode.titleUpdate":"shareMode.title")}),o.jsx("div",{className:"space-y-2 mb-5",children:sA.map(c=>o.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${i===c.cents?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[o.jsx("input",{type:"radio",name:"sharePrice",checked:i===c.cents,onChange:()=>l(c.cents),className:"accent-brand-500"}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium text-fg-primary",children:c.label}),o.jsx("div",{className:"text-[11px] text-fg-tertiary",children:c.cents===0?a("shareMode.freeDesc"):a("shareMode.paidDesc")})]})]},c.cents))}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx("button",{onClick:t,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:a("common:cancel")}),o.jsx("button",{onClick:()=>n(i>0?"paid":"free",i),className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand transition-colors",children:a(e?"shareMode.update":"shareMode.share")})]})]})}const fue=Object.freeze(Object.defineProperty({__proto__:null,AgentBuilder:iA},Symbol.toStringTag,{value:"Module"}));function oA(e){const t=e.filter(Boolean);if(t.length===0)return"";try{return new Intl.ListFormat(tn.language,{style:"short",type:"unit"}).format(t)}catch{return t.join(", ")}}function hue(e,t=tn.t("common:readFailed")){return e instanceof Error&&e.message?e.message:(typeof e=="string"?e:"")||t}function qu(){return{state:"loading",items:[],error:null}}function gue(e){return{state:"ok",items:e,error:null}}function bue(e,t=[]){return{state:"error",items:t,error:hue(e)}}async function o4(e,t={}){try{return gue(await e())}catch(n){return bue(n,t.keep??[])}}function kpe(e){const t=e.state==="loading",n=e.state==="error";return{loading:t,error:n,rows:e.items,empty:!t&&!n&&e.items.length===0}}function yue(e){const t=[];let n=!1,a=!1;for(const l of e)l.state==="loading"?n=!0:l.state==="error"?t.push(l.label):a=!0;return{state:n?"loading":t.length>0?"error":"ok",loading:n,failures:t,anyOk:a}}async function vue(e,t){if(!t)return{items:e,highlighted:null,missing:!1};const n=e.find(a=>a.id===t);if(n)return{items:[n,...e.filter(a=>a.id!==t)],highlighted:n,missing:!1};try{const{item:a}=await at.getItem(t);return a?{items:[a,...e],highlighted:a,missing:!1}:{items:e,highlighted:null,missing:!0}}catch{return{items:e,highlighted:null,missing:!0}}}function lA(e){const{catalogType:t,search:n,highlightItemId:a,onHighlightDone:i,loadTemplates:l,takeHubPrefetch:c}=e,[u,m]=w.useState(qu()),[f,g]=w.useState(qu()),[h,b]=w.useState(0),y=w.useRef({highlightItemId:a,onHighlightDone:i,loadTemplates:l,takeHubPrefetch:c});y.current={highlightItemId:a,onHighlightDone:i,loadTemplates:l,takeHubPrefetch:c},w.useEffect(()=>{let T=!1;return m(qu()),g(qu()),(async()=>{const A=(async()=>{const G=await o4(async()=>{const O=n?null:await y.current.takeHubPrefetch?.()??null;return O||((await at.search({type:t,q:n,limit:50})).items??[])});if(G.state!=="ok")return G;const j=await vue([...G.items],y.current.highlightItemId??null);return j.missing&&y.current.onHighlightDone?.(),{state:"ok",items:j.items,error:null}})(),M=o4(()=>y.current.loadTemplates(n)),[I,B]=await Promise.all([A,M]);T||(m(I),g(B))})(),()=>{T=!0}},[t,n,h]);const k=w.useCallback(()=>b(T=>T+1),[]),C=yue([{label:tn.t("store:catalog.hubAssets"),state:u.state},{label:tn.t("store:catalog.localTemplates"),state:f.state}]);return{hub:u,templates:f,sources:C,reload:k}}function cA({subject:e,error:t,notEquals:n,onRetry:a,retryLabel:i,hint:l,variant:c="bar"}){const{t:u}=ut("common"),m=o.jsx("span",{className:c==="inline"?"text-[11px] text-rose-500":"text-xs text-rose-500",children:u("readErrorNotice",{subject:e,error:t,notEquals:n})}),f=a?o.jsx("button",{type:"button",onClick:a,className:"text-xs text-brand-500 hover:text-brand-400 shrink-0 cursor-pointer",children:i??u("retry")}):l?o.jsx("span",{className:"text-xs text-fg-tertiary shrink-0",children:l}):null;return c==="inline"?o.jsxs("div",{className:"flex items-center gap-2 px-2 py-1",role:"alert",children:[m,f]}):o.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2 border-b border-rose-500/30 bg-rose-500/10 shrink-0",role:"alert",children:[m,f]})}function xue(e,t){const n=e.split(".").map(Number),a=t.split(".").map(Number);for(let i=0;i<Math.max(n.length,a.length);i++){const l=n[i]??0,c=a[i]??0;if(l>c)return!0;if(l<c)return!1}return!1}function Ym(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function l4(e,t){return e.i18n?.[t]?.description||e.description}const wue={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function kue({authUser:e,highlightItemId:t,onHighlightDone:n}={}){const{t:a,i18n:i}=ut(["store","common"]),l=i.language,[c,u]=w.useState(""),m=lA({catalogType:"agent",search:c,highlightItemId:t,onHighlightDone:n,loadTemplates:w.useCallback(async z=>{const J=new URLSearchParams;z&&J.set("q",z);const D=await fetch("/api/templates?"+J.toString(),{credentials:"include"});if(!D.ok)throw new Error(`HTTP ${D.status}`);const ee=await D.json();return Array.isArray(ee.templates)?ee.templates:[]},[]),takeHubPrefetch:async()=>(await Ls(La.hubAgents))?.items??null}),f=m.templates.items,g=m.hub.items,h=m.sources.loading,[b,y]=w.useState(null),[k,C]=w.useState({}),[T,A]=w.useState(!1),[M,I]=w.useState(new Map),[B,G]=w.useState(new Set),[j,O]=w.useState(null),[F,Y]=w.useState(null),q=w.useCallback(async()=>{try{const[z,J]=await Promise.all([Se.builder.artifacts.list().catch(()=>({artifacts:[]})),Se.builder.artifacts.installed().catch(()=>({installed:{}}))]),D=new Map;for(const ee of z.artifacts){if(ee.type!=="agent")continue;const R=!!J.installed[`agent/${ee.name}`];D.set(ee.name,{installed:R,localVersion:ee.meta.version||void 0,localUpdatedAt:ee.updatedAt})}I(D)}catch{}},[]);w.useEffect(()=>{q(),at.isAuthenticated()&&at.purchases.mine().then(z=>G(new Set(z.purchases.map(J=>J.itemId)))).catch(()=>{})},[q]),w.useEffect(()=>{if(!b){C({});return}fetch(`/api/templates/${encodeURIComponent(b.id)}/files`,{credentials:"include"}).then(z=>z.json()).then(z=>C(z.files??{})).catch(()=>C({}))},[b]);const V=async(z,J,D)=>{try{const ee=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:z,name:J,orgId:"default",teamId:D})});if(!ee.ok)throw new Error(`Failed: ${ee.status}`);A(!1),y(null)}catch(ee){Y({title:a("common:create",{defaultValue:"Create"}),message:`Failed to create agent: ${ee}`,variant:"danger"})}};if(j)return o.jsx(qs,{type:j.type,name:j.name,onBack:()=>O(null)});if(b){const z={type:"agent",name:b.id,displayName:Ym(b,l),version:b.version,description:l4(b,l),author:b.author,category:b.category,tags:b.tags,icon:b.icon,files:k,agent:{roleName:b.roleId,agentRole:b.agentRole==="manager"?"manager":"worker"},dependencies:{skills:b.skills}},J=o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[o.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:a("agentStore.roleConfig")}),o.jsxs("div",{className:"space-y-2.5 text-sm",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-fg-tertiary w-20",children:a("agentStore.role")}),o.jsx("span",{className:"text-fg-secondary font-mono text-xs bg-surface-elevated px-2 py-0.5 rounded",children:b.roleId})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-fg-tertiary w-20",children:a("agentStore.position")}),o.jsx("span",{className:`px-2 py-0.5 rounded text-xs capitalize ${wue[b.agentRole]??""}`,children:b.agentRole})]})]})]}),o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[o.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:a("agentStore.skills")}),o.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[b.skills.map(D=>o.jsx("span",{className:"px-2.5 py-1 text-xs bg-brand-500/10 text-brand-500 rounded-lg border border-brand-500/20",children:D},D)),b.skills.length===0&&o.jsx("span",{className:"text-xs text-fg-tertiary italic",children:a("agentStore.noSkills")})]})]})]}),b.starterTasks&&b.starterTasks.length>0&&o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[o.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:a("agentStore.starterTasks")}),o.jsx("div",{className:"space-y-2",children:b.starterTasks.map((D,ee)=>o.jsxs("div",{className:"flex items-start gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[o.jsx("span",{className:`inline-block w-2 h-2 rounded-full shrink-0 mt-1 ${D.priority==="high"?"bg-red-400":D.priority==="medium"?"bg-amber-400":"bg-green-400"}`}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm text-fg-primary",children:D.title}),D.description&&o.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:D.description})]})]},ee))})]})]});return o.jsxs(o.Fragment,{children:[o.jsx(qs,{type:"agent",name:b.id,onBack:()=>y(null),readOnly:!0,initialManifest:z,actionSlot:o.jsx("button",{onClick:()=>A(!0),className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg transition-colors font-medium",children:a("agentStore.hireAgent")}),contentSlot:J}),T&&o.jsx(c4,{template:b,lang:l,onClose:()=>A(!1),onHire:V}),F&&o.jsx(xr,{alertOnly:!0,variant:F.variant??"danger",title:F.title,message:F.message,onConfirm:()=>Y(null),onCancel:()=>Y(null)})]})}return o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[o.jsxs("div",{"data-electron-drag":!0,className:"px-6 h-14 flex items-center justify-between shrink-0 gap-3",children:[o.jsx("h2",{className:"text-lg font-semibold",children:a("agentStore.title")}),o.jsx("input",{type:"text",placeholder:a("agentStore.searchPlaceholder"),value:c,onChange:z=>u(z.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm max-w-xs w-full focus:border-brand-500 focus:outline-none"})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:[m.sources.failures.length>0&&o.jsx(cA,{subject:oA(m.sources.failures),error:m.hub.error??m.templates.error??a("common:readFailed"),notEquals:a("store:templates.nothingHere"),onRetry:m.reload}),h?o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((z,J)=>o.jsx("div",{className:"h-56 rounded-2xl skeleton"},J))}):m.sources.failures.length===0&&f.length===0&&g.length===0?o.jsxs("div",{className:"text-center py-20",children:[o.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),o.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:c?a("agentStore.noResults",{search:c}):a("agentStore.noAgents")}),o.jsx("div",{className:"text-fg-tertiary text-sm",children:a(c?"agentStore.noResultsHint":"agentStore.noAgentsHint")})]}):o.jsxs(o.Fragment,{children:[f.length>0&&o.jsxs("section",{children:[o.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[o.jsx("h3",{className:"section-title",children:a("agentStore.builtin")}),o.jsx("span",{className:"text-xs text-fg-tertiary",children:a("agentStore.available",{count:f.length})})]}),o.jsx(Ha,{columns:3,children:f.map(z=>o.jsx(mr,{type:"agent",name:Ym(z,l),description:l4(z,l),seed:z.id,icon:z.icon,version:z.version,category:z.category,tags:z.tags,authorLabel:z.author,hideStats:!0,showTypeBadge:!1,cornerLabel:a("agentStore.builtin"),onClick:()=>y(z)},z.id))})]}),g.length>0&&o.jsxs("section",{children:[o.jsx("h3",{className:"section-title mb-3",children:a("agentStore.markusHub")}),o.jsx(Ha,{columns:3,children:g.map(z=>o.jsx(Sue,{item:z,localInfo:M.get(Vc(z)),purchased:bm(z,B),onStatusChange:q,highlight:z.id===t,onHighlightDone:n,onViewDetail:J=>O({type:"agent",name:J})},z.id))})]})]})]}),T&&b&&o.jsx(c4,{template:b,lang:l,onClose:()=>A(!1),onHire:V}),F&&o.jsx(xr,{alertOnly:!0,variant:F.variant??"danger",title:F.title,message:F.message,onConfirm:()=>Y(null),onCancel:()=>Y(null)})]})}function Vc(e,t){if(e.slug&&e.slug.trim())return e.slug.trim();const n=t&&typeof t.name=="string"?t.name.trim():"";return xm(n||e.name,"hub-pkg")}function Ps(e){return(async()=>{const t=await at.download(e.id),n=t.name||e.name,a=t.config??{},i=Vc(e,a),l=t.itemType==="team"?"team":t.itemType==="skill"?"skill":"agent",c={type:"hub",hubItemId:e.id},u=(t.version||e.version||(typeof a.version=="string"?a.version:"")||"").trim()||void 0;if(t.files&&Object.keys(t.files).length>0)await Se.builder.artifacts.import(l,i,t.files,c,u);else{const m={...a,...u?{version:u}:{},name:i,displayName:a.displayName||n,description:e.description,source:c};await Se.builder.artifacts.save(l,m)}return await Se.builder.artifacts.install(l,i),window.dispatchEvent(new CustomEvent("markus:data-changed")),n})()}async function Xb(e,t){t("checking"),await at.ensureAuth();const n=await at.purchases.checkout(e.id);if(n.alreadyOwned)return t("installing"),await Ps(e),"installed";try{if((await at.creator.getBalance()).availableBalance>=(e.priceCents??0)){const c=await at.purchases.payWithEarnings(e.id);if(c.ok||c.alreadyOwned)return t("installing"),await Ps(e),"installed"}}catch{}if(!n.checkoutUrl)throw new Error("No checkout URL");t("checkout_opened");const a=Ko();let i=null;return a?Or(n.checkoutUrl):i=window.open(n.checkoutUrl,"_blank","noopener"),new Promise((l,c)=>{const u=Date.now(),m=300*1e3,f=setInterval(async()=>{if(Date.now()-u>m){clearInterval(f),l("cancelled");return}const h=!a&&i?i.closed:!1;try{if((await at.purchases.checkout(e.id)).alreadyOwned){clearInterval(f),t("installing");try{await Ps(e),l("installed")}catch(y){c(y)}return}}catch{}if(h){clearInterval(f);try{if((await at.purchases.checkout(e.id)).alreadyOwned){t("installing"),await Ps(e),l("installed");return}}catch{}l("cancelled")}},2e3)})}function Sue({item:e,localInfo:t,purchased:n,onStatusChange:a,highlight:i,onHighlightDone:l,onViewDetail:c}){const{t:u}=ut(["store"]),[m,f]=w.useState(!1),[g,h]=w.useState(""),b=w.useRef(null),[y,k]=w.useState(!1);w.useEffect(()=>{if(i&&b.current){b.current.scrollIntoView({behavior:"smooth",block:"center"}),k(!0);const F=setTimeout(()=>{k(!1)},4e3);return()=>clearTimeout(F)}},[i,l]);const C=t?.installed??!1,T=C&&e.version&&t?.localVersion&&xue(e.version,t.localVersion),A=(e.priceCents??0)>0,M=async F=>{if(F.stopPropagation(),!m){f(!0),h("");try{await Ps(e),h(T?u("card.upgraded"):u("card.installed")+"!"),a()}catch(Y){const q=Y instanceof Error?Y.message:"";q.includes("402")||q.includes("Purchase required")?h(u("card.purchaseRequired")):h(u("card.failed"))}finally{f(!1)}}},I=async F=>{if(F.stopPropagation(),!m){f(!0),h("");try{await Xb(e,q=>{q==="checkout_opened"?h(u("card.waitingPurchase","Waiting for purchase...")):q==="installing"&&h(u("card.installing"))})==="installed"?(h(u("card.installed")+"!"),a()):h("")}catch(Y){h(Y instanceof Error?Y.message:u("card.failed"))}finally{f(!1)}}},B=A?`$${((e.priceCents??0)/100).toFixed(2)}`:null,G=e.slug&&e.author?.username?`${at.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,j=()=>{C&&c?c(Vc(e)):G&&window.open(G,"_blank","noopener,noreferrer")},O=o.jsxs(o.Fragment,{children:[T?o.jsx("button",{onClick:F=>{M(F)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:m?u("card.upgrading"):u("card.upgrade",{version:e.version})}):C?o.jsxs("button",{onClick:F=>{M(F)},disabled:m,className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default rounded-lg transition-colors disabled:opacity-50",children:[u("card.installed"),t?.localVersion?` v${t.localVersion}`:""]}):A&&!n?o.jsx("button",{onClick:F=>{I(F)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:m?g||u("card.installing"):o.jsxs(o.Fragment,{children:[u("card.buy","Buy")," ",B]})}):o.jsx("button",{onClick:F=>{M(F)},disabled:m,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg transition-colors disabled:opacity-50",children:u(m?"card.installing":"card.install")}),g&&!(A&&!n)&&o.jsx("span",{className:`text-[10px] ${g===u("card.failed")||g===u("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:g})]});return o.jsx("div",{ref:b,className:y?"animate-pulse":"",children:o.jsx(mr,{type:"agent",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"bot",cover:e.thumbnailUrl,hubBase:at.getUrl(),author:e.author,version:e.version,category:e.category,tags:e.tags,rating:parseFloat(e.avgRating)||0,ratingCount:e.ratingCount,downloadCount:e.downloadCount,priceCents:e.priceCents,currency:e.currency,installed:C,glowing:y,onClick:j,actions:O})})}function c4({template:e,lang:t,onClose:n,onHire:a}){const{t:i}=ut(["store"]),[l,c]=w.useState(`${Ym(e,t)} Agent`),[u,m]=w.useState(""),[f,g]=w.useState([]),[h,b]=w.useState(!1);w.useEffect(()=>{fetch("/api/teams",{credentials:"include"}).then(k=>k.json()).then(k=>g(k.teams??[])).catch(()=>{})},[]);const y=async()=>{if(l.trim()){b(!0);try{await a(e.id,l.trim(),u||void 0)}finally{b(!1)}}};return o.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:n,children:o.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[440px] shadow-2xl",onClick:k=>k.stopPropagation(),children:[o.jsx("div",{className:"flex items-center gap-3 mb-5",children:o.jsxs("div",{children:[o.jsx("h3",{className:"text-base font-semibold",children:i("hireModal.title")}),o.jsx("p",{className:"text-xs text-fg-tertiary",children:i("hireModal.creating",{name:Ym(e,t)})})]})}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:i("hireModal.agentName")}),o.jsx("input",{type:"text",value:l,onChange:k=>c(k.target.value),className:"input-field",autoFocus:!0})]}),f.length>0&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:i("hireModal.assignTeam")}),o.jsxs("select",{value:u,onChange:k=>m(k.target.value),className:"input-field",children:[o.jsx("option",{value:"",children:i("hireModal.noTeam")}),f.map(k=>o.jsx("option",{value:k.id,children:k.name},k.id))]})]}),o.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg p-3",children:[o.jsx("div",{className:"text-xs text-fg-tertiary mb-2 font-medium",children:i("hireModal.agentConfig")}),o.jsxs("div",{className:"grid grid-cols-2 gap-y-1.5 gap-x-4 text-xs",children:[o.jsx("div",{className:"text-fg-tertiary",children:i("hireModal.role")}),o.jsx("div",{className:"text-fg-secondary font-mono",children:e.roleId}),o.jsx("div",{className:"text-fg-tertiary",children:i("hireModal.position")}),o.jsx("div",{className:"text-fg-secondary capitalize",children:e.agentRole}),o.jsx("div",{className:"text-fg-tertiary",children:i("hireModal.skills")}),o.jsx("div",{className:"text-fg-secondary",children:e.skills.join(", ")||i("hireModal.none")})]})]})]}),o.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[o.jsx("button",{onClick:n,className:"btn-secondary",children:i("hireModal.cancel")}),o.jsx("button",{onClick:y,disabled:!l.trim()||h,className:"btn-primary",children:i(h?"hireModal.creating_progress":"hireModal.create")})]})]})})}function O0(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function d4(e,t){return e.i18n?.[t]?.description||e.description}function u4(e,t,n){return e.i18n?.[n]?.members?.[t]||t}function Cue(e,t){const n=e.split(".").map(Number),a=t.split(".").map(Number);for(let i=0;i<Math.max(n.length,a.length);i++){const l=n[i]??0,c=a[i]??0;if(l>c)return!0;if(l<c)return!1}return!1}function Aue({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:a}=ut(["store","common"]),i=a.language,[l,c]=w.useState(""),u=lA({catalogType:"team",search:l,highlightItemId:e,onHighlightDone:t,loadTemplates:w.useCallback(V=>Se.teamTemplates.list(V||void 0).then(z=>z.templates??[]),[]),takeHubPrefetch:async()=>(await Ls(La.hubTeams))?.items??null}),m=u.templates.items,f=u.hub.items,g=u.sources.loading,[h,b]=w.useState(null),[y,k]=w.useState({}),[C,T]=w.useState(!1),[A,M]=w.useState(null),[I,B]=w.useState(new Map),[G,j]=w.useState(new Set),[O,F]=w.useState(null),Y=w.useCallback(async()=>{try{const[V,z]=await Promise.all([Se.builder.artifacts.list().catch(()=>({artifacts:[]})),Se.builder.artifacts.installed().catch(()=>({installed:{}}))]),J=new Map;for(const D of V.artifacts){if(D.type!=="team")continue;const ee=!!z.installed[`team/${D.name}`];J.set(D.name,{installed:ee,localVersion:D.meta.version||void 0,localUpdatedAt:D.updatedAt})}B(J)}catch{}},[]);w.useEffect(()=>{Y(),at.isAuthenticated()&&at.purchases.mine().then(V=>j(new Set(V.purchases.map(z=>z.itemId)))).catch(()=>{})},[Y]),w.useEffect(()=>{if(!h){k({});return}fetch(`/api/team-templates/${encodeURIComponent(h.id)}/files`,{credentials:"include"}).then(V=>V.json()).then(V=>k(V.files??{})).catch(()=>k({}))},[h]);const q=async V=>{T(!0),M(null);try{const J=(await Se.teams.create(V.name,V.description)).team.id;let D,ee=0;const R=[];for(const le of V.members){const ke=le.count??1;for(let $=0;$<ke;$++){const W=le.name??`${V.name} Agent ${$+1}`,oe=ke>1?`${W} ${$+1}`:W,L=le.roleName??le.templateId;try{const Ne=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:oe,...L?{roleName:L}:{},orgId:"default",teamId:J,agentRole:le.role??"worker",skills:le.skills??[]})});if(Ne.ok){ee++;const qe=await Ne.json();le.role==="manager"&&!D&&(D=qe.agent?.id)}else{const qe=await Ne.json().catch(()=>({error:`HTTP ${Ne.status}`}));R.push(`${oe}: ${qe.error??Ne.statusText}`)}}catch(Ne){R.push(`${oe}: ${String(Ne)}`)}}}D&&await Se.teams.update(J,{managerId:D,managerType:"agent"}).catch(()=>{});const te=R.length>0?` (${R.length} failed: ${R[0]})`:"";M({ok:ee>0,message:`Team "${O0(V,i)}" deployed with ${ee} agent(s)${te}`})}catch(z){M({ok:!1,message:`Failed: ${z}`})}finally{T(!1)}};if(O)return o.jsx(qs,{type:O.type,name:O.name,onBack:()=>F(null)});if(h){const V={...y};h.announcements&&(V["ANNOUNCEMENT.md"]=h.announcements),h.norms&&(V["NORMS.md"]=h.norms);const z={type:"team",name:h.id,displayName:O0(h,i),version:h.version,description:d4(h,i),author:h.author,category:h.category??"general",tags:h.tags??[],files:V,team:{members:h.members.map(D=>({name:u4(h,D.name??D.roleName??D.templateId??"Agent",i),role:D.role??"worker",roleName:D.roleName??D.templateId,count:D.count??1,skills:D.skills??[]}))}},J=o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[o.jsx("div",{className:"px-5 py-3 border-b border-border-default bg-surface-elevated/30",children:o.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider",children:n("teamStore.teamComposition")})}),o.jsx("div",{className:"p-5 space-y-2",children:h.members.map((D,ee)=>{const R=u4(h,D.name??D.roleName??D.templateId??"Agent",i);return o.jsxs("div",{className:"flex items-center gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[o.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center text-sm font-bold shrink-0 ${D.role==="manager"?"bg-amber-500/15 text-amber-400 ring-1 ring-amber-500/30":"bg-blue-500/15 text-blue-400 ring-1 ring-blue-500/30"}`,children:(R[0]??"?").toUpperCase()}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-sm text-fg-primary font-medium",children:R}),o.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] capitalize font-medium ${D.role==="manager"?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:D.role??"worker"}),(D.count??1)>1&&o.jsxs("span",{className:"text-[10px] text-fg-muted",children:["×",D.count]})]}),(D.roleName||D.templateId)&&o.jsx("div",{className:"text-[10px] text-fg-tertiary font-mono mt-0.5",children:D.roleName??D.templateId})]}),D.skills&&D.skills.length>0&&o.jsxs("div",{className:"flex flex-wrap gap-1 shrink-0",children:[D.skills.slice(0,3).map(te=>o.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-surface-elevated text-fg-muted rounded border border-border-default",children:te},te)),D.skills.length>3&&o.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",D.skills.length-3]})]})]},ee)})})]});return o.jsx(o.Fragment,{children:o.jsx(qs,{type:"team",name:h.id,onBack:()=>{b(null),M(null)},readOnly:!0,initialManifest:z,contentSlot:J,actionSlot:o.jsxs(o.Fragment,{children:[A&&o.jsx("span",{className:`text-xs ${A.ok?"text-green-500":"text-red-500"}`,children:A.message}),o.jsx("button",{onClick:()=>{q(h)},disabled:C,className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg transition-colors font-medium disabled:opacity-50",children:n(C?"teamStore.deploying":"teamStore.deployTeam")})]})})})}return o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[o.jsxs("div",{"data-electron-drag":!0,className:"px-6 h-14 flex items-center justify-between shrink-0 gap-3",children:[o.jsx("h2",{className:"text-lg font-semibold",children:n("teamStore.title")}),o.jsx("input",{type:"text",placeholder:n("teamStore.searchPlaceholder"),value:l,onChange:V=>c(V.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm max-w-xs w-full focus:border-brand-500 focus:outline-none"})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:[u.sources.failures.length>0&&o.jsx(cA,{subject:oA(u.sources.failures),error:u.hub.error??u.templates.error??n("common:readFailed"),notEquals:n("store:teamsStore.nothingHere"),onRetry:u.reload}),g?o.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:Array.from({length:4}).map((V,z)=>o.jsx("div",{className:"h-56 rounded-2xl skeleton"},z))}):u.sources.failures.length===0&&m.length===0&&f.length===0?o.jsxs("div",{className:"text-center py-20",children:[o.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"◉"}),o.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:l?n("teamStore.noResults",{search:l}):n("teamStore.noTeams")}),o.jsx("div",{className:"text-fg-tertiary text-sm",children:n(l?"teamStore.noResultsHint":"teamStore.noTeamsHint")})]}):o.jsxs(o.Fragment,{children:[m.length>0&&o.jsxs("section",{children:[o.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[o.jsx("h3",{className:"section-title",children:n("teamStore.builtin")}),o.jsx("span",{className:"text-xs text-fg-tertiary",children:n("teamStore.available",{count:m.length})})]}),o.jsx(Ha,{columns:2,children:m.map(V=>o.jsx(mr,{type:"team",name:O0(V,i),description:d4(V,i),seed:V.id,icon:V.icon||"users",version:V.version,category:V.category,tags:V.tags,authorLabel:V.author,hideStats:!0,showTypeBadge:!1,cornerLabel:n("teamStore.builtin"),onClick:()=>b(V)},V.id))})]}),f.length>0&&o.jsxs("section",{children:[o.jsx("h3",{className:"section-title mb-3",children:n("teamStore.markusHub")}),o.jsx(Ha,{columns:2,children:f.map(V=>o.jsx(Tue,{item:V,localInfo:I.get(Vc(V)),purchased:bm(V,G),onStatusChange:Y,highlight:V.id===e,onHighlightDone:t,onViewDetail:z=>F({type:"team",name:z})},V.id))})]})]})]})]})}function Tue({item:e,localInfo:t,purchased:n,onStatusChange:a,highlight:i,onHighlightDone:l,onViewDetail:c}){const{t:u}=ut(["store"]),[m,f]=w.useState(!1),[g,h]=w.useState(""),b=w.useRef(null),[y,k]=w.useState(!1);w.useEffect(()=>{if(i&&b.current){b.current.scrollIntoView({behavior:"smooth",block:"center"}),k(!0);const F=setTimeout(()=>{k(!1)},4e3);return()=>clearTimeout(F)}},[i,l]);const C=t?.installed??!1,T=C&&e.version&&t?.localVersion&&Cue(e.version,t.localVersion),A=(e.priceCents??0)>0,M=A?`$${((e.priceCents??0)/100).toFixed(2)}`:null,I=async F=>{if(F.stopPropagation(),!m){f(!0),h("");try{await Ps(e),h(T?u("card.upgraded"):u("card.installed")+"!"),a()}catch(Y){const q=Y instanceof Error?Y.message:"";q.includes("402")||q.includes("Purchase required")?h(u("card.purchaseRequired")):h(u("card.failed"))}finally{f(!1)}}},B=async F=>{if(F.stopPropagation(),!m){f(!0),h("");try{await Xb(e,q=>{q==="checkout_opened"?h(u("card.waitingPurchase","Waiting for purchase...")):q==="installing"&&h(u("card.installing"))})==="installed"?(h(u("card.installed")+"!"),a()):h("")}catch(Y){h(Y instanceof Error?Y.message:u("card.failed"))}finally{f(!1)}}},G=e.slug&&e.author?.username?`${at.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,j=()=>{C&&c?c(Vc(e)):G&&window.open(G,"_blank","noopener,noreferrer")},O=o.jsxs(o.Fragment,{children:[T?o.jsx("button",{onClick:F=>{I(F)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:m?u("card.upgrading"):u("card.upgrade",{version:e.version})}):C?o.jsxs("button",{onClick:F=>{I(F)},disabled:m,className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default rounded-lg transition-colors disabled:opacity-50",children:[u("card.installed"),t?.localVersion?` v${t.localVersion}`:""]}):A&&!n?o.jsx("button",{onClick:F=>{B(F)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:m?g||u("card.installing"):o.jsxs(o.Fragment,{children:[u("card.buy","Buy")," ",M]})}):o.jsx("button",{onClick:F=>{I(F)},disabled:m,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg transition-colors disabled:opacity-50",children:u(m?"card.installing":"card.install")}),g&&o.jsx("span",{className:`text-[10px] ${g===u("card.failed")||g===u("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:g})]});return o.jsx("div",{ref:b,className:y?"animate-pulse":"",children:o.jsx(mr,{type:"team",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"users",cover:e.thumbnailUrl,hubBase:at.getUrl(),author:e.author,version:e.version,category:e.category,tags:e.tags,rating:parseFloat(e.avgRating)||0,ratingCount:e.ratingCount,downloadCount:e.downloadCount,priceCents:e.priceCents,currency:e.currency,installed:C,glowing:y,onClick:j,actions:O})})}function H0(e,t){return e.i18n?.[t]?.displayName||e.name}function B0(e,t){return e.i18n?.[t]?.description||e.description||""}function Eue(e,t){try{return new Intl.NumberFormat(t,{notation:"compact",maximumFractionDigits:1}).format(e)}catch{return e.toLocaleString()}}function dA(e,t){const n=e.split(".").map(Number),a=t.split(".").map(Number);for(let i=0;i<Math.max(n.length,a.length);i++){const l=n[i]??0,c=a[i]??0;if(l>c)return!0;if(l<c)return!1}return!1}const Nue={development:"bg-blue-500/15 text-blue-600",devops:"bg-amber-500/15 text-amber-600",productivity:"bg-green-500/15 text-green-600",custom:"bg-gray-500/15 text-fg-secondary",browser:"bg-brand-500/15 text-brand-500",communication:"bg-green-500/15 text-green-600",data:"bg-brand-500/15 text-brand-500",platform:"bg-blue-500/15 text-blue-600","AI 智能":"bg-brand-500/15 text-brand-500",开发工具:"bg-blue-500/15 text-blue-600",效率提升:"bg-green-500/15 text-green-600",数据分析:"bg-brand-500/15 text-brand-500",内容创作:"bg-brand-500/15 text-brand-500",安全合规:"bg-red-500/15 text-red-500",通讯协作:"bg-green-500/15 text-green-600"};function Mue({item:e,installedSkills:t,purchased:n,onMsg:a,onRefresh:i}){const{t:l}=ut(["store"]),[c,u]=w.useState(!1),m=e.name.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed",f=t.find(A=>A.name===e.name||A.name===m||!!e.slug&&A.name===e.slug),g=!!f,h=g&&e.version&&f?.version&&dA(e.version,f.version),b=(e.priceCents??0)>0,[y,k]=w.useState(""),C=async()=>{if(!c){u(!0),k("");try{await Ps(e),a(h?`Upgraded ${e.name}`:`Installed ${e.name}`,"success"),i()}catch(A){const M=A instanceof Error?A.message:"";M.includes("402")||M.includes("Purchase required")?a(l("card.purchaseRequired"),"error"):a(l("card.failed"),"error")}finally{u(!1)}}},T=async()=>{if(!c){u(!0),k("");try{await Xb(e,M=>{M==="checkout_opened"?k(l("card.waitingPurchase","Waiting for purchase...")):M==="installing"&&k(l("card.installing"))})==="installed"&&(a(`Purchased & installed ${e.name}`,"success"),i()),k("")}catch(A){a(A instanceof Error?A.message:l("card.failed"),"error"),k("")}finally{u(!1)}}};if(h)return o.jsx("button",{onClick:()=>{C()},disabled:c,className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50",children:c?l("card.upgrading"):l("card.upgrade",{version:e.version})});if(g)return o.jsxs("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:[l("card.installed"),f?.version?` (v${f.version})`:""]});if(b&&!n){const A=`$${((e.priceCents??0)/100).toFixed(2)}`;return o.jsx("span",{className:"inline-flex items-center gap-1.5",children:o.jsx("button",{onClick:()=>{T()},disabled:c,className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50 inline-flex items-center gap-1",children:c?y||l("card.installing"):o.jsxs(o.Fragment,{children:[l("card.buy","Buy")," ",A]})})})}return o.jsx("button",{onClick:()=>{C()},disabled:c,className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg disabled:opacity-50",children:l(c?"card.installing":"card.install")})}function m4({item:e,installedSkills:t,purchased:n,onMsg:a,onRefresh:i,highlight:l,onHighlightDone:c,type:u="skill"}){const m=w.useRef(null),[f,g]=w.useState(!1);w.useEffect(()=>{if(l&&m.current){m.current.scrollIntoView({behavior:"smooth",block:"center"}),g(!0);const y=setTimeout(()=>{g(!1)},4e3);return()=>clearTimeout(y)}},[l,c]);const h=e.slug&&e.author?.username?`${at.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,b=()=>{h&&window.open(h,"_blank","noopener,noreferrer")};return o.jsx("div",{ref:m,className:f?"animate-pulse":"",children:o.jsx(mr,{type:u,showTypeBadge:u!=="skill",name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||Zu(e.slug||e.name,e.category),cover:e.thumbnailUrl,hubBase:at.getUrl(),author:e.author,version:e.version,category:e.category,tags:e.tags,rating:parseFloat(e.avgRating)||0,ratingCount:e.ratingCount,downloadCount:e.downloadCount,priceCents:e.priceCents,currency:e.currency,onClick:b,actions:o.jsx(Mue,{item:e,installedSkills:t,purchased:n,onMsg:a,onRefresh:i})})})}function jue({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:a}=ut(["store","common"]),i=a.language,l=Xo(),[c,u]=w.useState("skills"),[m,f]=w.useState(null),[g,h]=w.useState(new Set),[b,y]=w.useState([]),[k,C]=w.useState(null),[T,A]=w.useState([]),[M,I]=w.useState(0),[B,G]=w.useState(1),[j,O]=w.useState([]),[F,Y]=w.useState(""),[q,V]=w.useState("score"),[z,J]=w.useState(""),[D,ee]=w.useState(!1),[R,te]=w.useState([]),[le,ke]=w.useState(!1),[$,W]=w.useState([]),[oe,L]=w.useState(""),[Ne,qe]=w.useState(!1),[me,ze]=w.useState([]),[Ue,je]=w.useState([]),[Ye,xt]=w.useState(new Set),[mt,ft]=w.useState(!1),[rt,jt]=w.useState(""),ht=[{id:"skills",labelKey:"skillStore.tabs.all"},{id:"skillhub",labelKey:"skillStore.tabs.skillhub"},{id:"skillssh",labelKey:"skillStore.tabs.skillssh"}],He=(U,re="success")=>{f({text:U,type:re}),setTimeout(()=>f(null),re==="error"?1e4:4e3)},Et=w.useCallback(async()=>{try{const U=await Se.skills.list();y(U.skills)}catch{}},[]),Kt=w.useCallback(async()=>{ke(!0);try{const U=await Se.skills.builtin();te(U.skills)}catch{}ke(!1)},[]),ie=w.useCallback(async U=>{ee(!0);try{const re=await Se.skills.registrySkillhub({q:U?.q,category:U?.category,page:U?.page??1,limit:24,sort:U?.sort??q});A(re.skills),I(re.total),re.categories?.length&&O(re.categories)}catch{}ee(!1)},[q]),tt=w.useCallback(async U=>{qe(!0);try{const re=await Se.skills.registrySkillssh(U);W(re.skills)}catch{}qe(!1)},[]),it=w.useCallback(async U=>{ft(!0);try{const re=U?at.search({type:"skill",q:U,limit:50}):Ls(La.hubSkills)??at.search({type:"skill",limit:50}),Ce=at.search({subtype:"connector",q:U||void 0,limit:50}).catch(()=>({items:[]})),[Pe,$e]=await Promise.all([re,Ce,at.isAuthenticated()?at.purchases.mine().then(Ve=>xt(new Set(Ve.purchases.map(dt=>dt.itemId)))).catch(()=>{}):Promise.resolve()]);let ue=Pe?.items??[],he=$e?.items??[];if(e){const Ve=ue.some(Je=>Je.id===e),dt=he.some(Je=>Je.id===e);if(!Ve&&!dt)try{const{item:Je}=await at.getItem(e);Je?.subtype==="connector"?he=[Je,...he]:Je?ue=[Je,...ue]:t?.()}catch{t?.()}else Ve&&(ue=[ue.find(ot=>ot.id===e),...ue.filter(ot=>ot.id!==e)]),dt&&(he=[he.find(ot=>ot.id===e),...he.filter(ot=>ot.id!==e)])}ze(ue),je(he)}catch{}ft(!1)},[e,t]);w.useEffect(()=>{Et(),Kt(),ie(),tt()},[]),w.useEffect(()=>{c==="skills"&&it(rt)},[c,rt,it]);const xe=async U=>{h(re=>new Set(re).add(U.name));try{const re=await Se.skills.install({name:U.name,source:"skillhub",slug:U.slug,sourceUrl:U.homepage,description:U.description_zh??U.description,category:"custom",version:U.version});await Et(),He(`"${U.name}" installed (${re.method}) → ${re.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{He(`Download failed for "${U.name}". You can try manually from: ${U.homepage}`,"error")}h(re=>{const Ce=new Set(re);return Ce.delete(U.name),Ce})},Me=async U=>{h(re=>new Set(re).add(U.name));try{const re=await Se.skills.install({name:U.name,source:"skillssh",sourceUrl:U.url,githubRepo:`${U.author}/${U.repo}`,githubSkillPath:U.name});await Et(),He(`"${U.name}" installed (${re.method}) → ${re.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{He(`Download failed for "${U.name}". You can try manually from: ${U.url}`,"error")}h(re=>{const Ce=new Set(re);return Ce.delete(U.name),Ce})},Ie=async U=>{h(re=>new Set(re).add(U.name));try{const re=await Se.skills.install({name:U.name,source:"builtin"});await Et(),await Kt(),He(`"${U.name}" installed (${re.method}) → ${re.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(re){He(`Install failed for "${U.name}": ${re}`,"error")}h(re=>{const Ce=new Set(re);return Ce.delete(U.name),Ce})},ne=$.filter(U=>{if(!oe)return!0;const re=oe.toLowerCase();return U.name.toLowerCase().includes(re)||U.repo.toLowerCase().includes(re)});if(k){const U=k,re={};U.instructions&&(re["SKILL.md"]=U.instructions);const Ce={type:"skill",name:U.name,displayName:H0(U,i),version:U.version,description:B0(U,i),author:U.author??"",category:U.category??"general",tags:U.tags,files:re,skill:{skillFile:U.instructions?"SKILL.md":"",requiredPermissions:U.requiredPermissions,mcpServers:void 0,alwaysOn:!1}},Pe=U.installed&&U.installedVersion&&dA(U.version,U.installedVersion)?o.jsx("button",{onClick:()=>{Ie(U)},disabled:g.has(U.name),className:"px-4 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:g.has(U.name)?n("card.upgrading"):n("card.upgrade",{version:U.version})}):U.installed?o.jsxs("span",{className:"px-4 py-1.5 text-xs bg-green-500/10 text-green-500 rounded-lg border border-green-500/20 inline-flex items-center gap-1",children:[o.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:o.jsx("polyline",{points:"20 6 9 17 4 12"})}),n("card.installed"),U.installedVersion?` v${U.installedVersion}`:""]}):o.jsx("button",{onClick:()=>{Ie(U)},disabled:g.has(U.name),className:"px-4 py-1.5 text-xs bg-green-600 hover:bg-green-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:g.has(U.name)?n("card.installing"):n("card.install")}),$e=o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[o.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.details")}),o.jsxs("div",{className:"space-y-2.5 text-sm",children:[U.category&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.category")}),o.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium capitalize ${Nue[U.category]??"bg-gray-500/15 text-fg-secondary"}`,children:U.category})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.version")}),o.jsx("span",{className:"text-fg-secondary font-mono text-xs",children:U.version})]}),U.hasMcpServers&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.integration")}),o.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] bg-purple-500/15 text-purple-400",children:"MCP"})]}),U.hasInstructions&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.instructions")}),o.jsx("span",{className:"text-green-500 text-xs",children:"✓"})]})]})]}),(U.requiredPermissions.length>0||U.tags.length>0)&&o.jsxs("div",{className:"space-y-4",children:[U.requiredPermissions.length>0&&o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[o.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.permissions")}),o.jsx("div",{className:"flex flex-wrap gap-1.5",children:U.requiredPermissions.map(ue=>o.jsx("span",{className:"px-2.5 py-1 text-xs bg-amber-500/10 text-amber-500 rounded-lg border border-amber-500/20",children:ue},ue))})]}),U.tags.length>0&&o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[o.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.tags")}),o.jsx("div",{className:"flex flex-wrap gap-1.5",children:U.tags.map(ue=>o.jsx("span",{className:"px-2.5 py-1 text-xs bg-surface-elevated text-fg-secondary rounded-lg border border-border-default/50",children:ue},ue))})]})]})]});return o.jsxs(o.Fragment,{children:[o.jsx(qs,{type:"skill",name:U.name,onBack:()=>C(null),readOnly:!0,initialManifest:Ce,actionSlot:Pe,contentSlot:$e}),m&&o.jsx("div",{className:`mx-7 mb-2 px-3 py-1.5 text-xs rounded-lg shrink-0 ${m.type==="error"?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-600"}`,children:m.text})]})}return o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[o.jsxs("div",{className:`${l?"px-4":"px-6"} shrink-0`,children:[o.jsx("div",{"data-electron-drag":!0,className:"flex items-center h-14",children:o.jsx("h2",{className:"text-lg font-semibold",children:n("skillStore.title")})}),o.jsx("div",{className:`flex ${l?"flex-wrap":""} gap-1 pb-2 overflow-x-auto scrollbar-hide`,children:ht.map(U=>o.jsx("button",{onClick:()=>u(U.id),className:`px-3 py-1.5 text-xs rounded-lg transition-colors shrink-0 ${c===U.id?"bg-brand-600 text-on-brand":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:n(U.labelKey)},U.id))})]}),m&&o.jsx("div",{className:`mx-7 mt-2 px-3 py-1.5 text-xs rounded-lg shrink-0 ${m.type==="error"?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-600"}`,children:m.text}),c==="skills"&&(()=>{const U=rt.trim().toLowerCase(),re=U?R.filter($e=>H0($e,i).toLowerCase().includes(U)||B0($e,i).toLowerCase().includes(U)):R,Ce=le&&mt,Pe=re.length===0&&me.length===0&&Ue.length===0;return o.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"} space-y-8`,children:[o.jsx("div",{className:"flex items-center gap-2",children:o.jsx("input",{value:rt,onChange:$e=>jt($e.target.value),placeholder:n("skillStore.searchMarkusHub"),className:`px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none ${l?"flex-1 min-w-0":"w-72"}`})}),Ce&&Pe?o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map(($e,ue)=>o.jsx("div",{className:"h-56 rounded-2xl skeleton"},ue))}):Pe?o.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[o.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◇"}),o.jsx("div",{children:n("skillStore.noBuiltin")}),o.jsx("div",{className:"text-xs mt-1",children:n("skillStore.noBuiltinHint")})]}):o.jsxs(o.Fragment,{children:[re.length>0&&o.jsxs("section",{children:[o.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[o.jsx("h3",{className:"section-title",children:n("skillStore.tabs.builtin")}),o.jsx("span",{className:"text-xs text-fg-tertiary",children:n("skillStore.builtinCount",{count:re.length})})]}),o.jsx(Ha,{columns:3,children:re.map($e=>o.jsx(mr,{type:"skill",name:H0($e,i),description:B0($e,i),seed:$e.name,icon:Zu($e.name,$e.category),version:$e.version,category:$e.category,tags:$e.tags,authorLabel:$e.author||void 0,installed:$e.installed,hideStats:!0,showTypeBadge:!1,cornerLabel:$e.installed?void 0:n("skillStore.tabs.builtin"),onClick:()=>C($e)},$e.name))})]}),me.length>0&&o.jsxs("section",{children:[o.jsx("h3",{className:"section-title mb-3",children:n("skillStore.tabs.markusHub")}),o.jsx(Ha,{columns:3,children:me.map($e=>o.jsx(m4,{item:$e,installedSkills:b,purchased:bm($e,Ye),onMsg:He,onRefresh:()=>{Et(),it(rt)},highlight:$e.id===e,onHighlightDone:t},$e.id))})]}),Ue.length>0&&o.jsxs("section",{children:[o.jsxs("div",{className:"mb-3",children:[o.jsx("h3",{className:"section-title",children:n("tabs.connectors")}),o.jsx("p",{className:"text-xs text-fg-tertiary mt-0.5",children:n("connectorStore.emptyHint","连接器让智能体接入外部工具与服务 (MCP)")})]}),o.jsx(Ha,{columns:3,children:Ue.map($e=>o.jsx(m4,{item:$e,type:"connector",installedSkills:b,purchased:bm($e,Ye),onMsg:He,onRefresh:()=>{Et(),it(rt)},highlight:$e.id===e,onHighlightDone:t},$e.id))})]})]})]})})(),c==="skillhub"&&o.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`,children:[o.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[o.jsxs("select",{value:F,onChange:U=>{Y(U.target.value),G(1),ie({q:z||void 0,category:U.target.value||void 0,page:1})},className:"px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-secondary outline-none",children:[o.jsx("option",{value:"",children:n("skillStore.allCategories")}),j.map(U=>o.jsx("option",{value:U,children:U},U))]}),o.jsxs("select",{value:q,onChange:U=>{V(U.target.value),G(1),ie({q:z||void 0,category:F||void 0,page:1,sort:U.target.value})},className:"px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-secondary outline-none",children:[o.jsx("option",{value:"score",children:n("skillStore.sortScore")}),o.jsx("option",{value:"downloads",children:n("skillStore.sortDownloads")}),o.jsx("option",{value:"stars",children:n("skillStore.sortStars")}),o.jsx("option",{value:"installs",children:n("skillStore.sortInstalls")})]}),!l&&o.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:o.jsx("a",{href:"https://skillhub.tencent.com",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),o.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[o.jsx("input",{value:z,onChange:U=>J(U.target.value),onKeyDown:U=>{U.key==="Enter"&&(G(1),ie({q:z||void 0,category:F||void 0,page:1}))},placeholder:n("skillStore.searchSkillhub"),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none flex-1 min-w-0"}),o.jsx("button",{onClick:()=>{G(1),ie({q:z||void 0,category:F||void 0,page:1})},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-on-brand text-xs rounded-lg shrink-0",children:n("common:search")})]}),D?o.jsx("div",{className:"text-center text-fg-tertiary py-20",children:o.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillhub")})}):T.length===0?o.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[o.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◎"}),o.jsx("div",{children:n("skillStore.noSkillhub")})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"text-xs text-fg-tertiary mb-3",children:n("skillStore.skillhubTotal",{count:M.toLocaleString()})}),o.jsx(Ha,{columns:3,children:T.map(U=>{const re=b.some(Ce=>Ce.name===U.name||Ce.name===U.slug);return o.jsx(mr,{type:"skill",name:U.name,description:U.description_zh??U.description??"",seed:U.slug,icon:Zu(U.slug||U.name,U.tags?.[0]),version:U.version,authorLabel:"SkillHub",showTypeBadge:!1,tags:U.tags,installed:re,hideStats:!0,onClick:()=>window.open(U.homepage,"_blank","noopener,noreferrer"),footerLeft:o.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary",children:[U.stars>0&&o.jsxs("span",{className:"text-amber-600",children:["★ ",U.stars.toLocaleString()]}),U.downloads>0&&o.jsxs("span",{children:[U.downloads>=1e4?Eue(U.downloads,a.language):U.downloads.toLocaleString()," ",n("skillStore.downloads")]})]}),actions:re?void 0:o.jsx("button",{onClick:()=>{xe(U)},disabled:g.has(U.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg disabled:opacity-50",children:g.has(U.name)?"...":n("card.install")})},U.slug)})}),M>24&&o.jsxs("div",{className:"flex items-center justify-center gap-2 mt-6",children:[o.jsx("button",{disabled:B<=1,onClick:()=>{const U=B-1;G(U),ie({q:z||void 0,category:F||void 0,page:U})},className:"px-3 py-1.5 text-xs bg-surface-elevated text-fg-secondary rounded-lg hover:bg-surface-overlay disabled:opacity-30",children:n("skillStore.prevPage")}),o.jsx("span",{className:"text-xs text-fg-tertiary",children:n("skillStore.pageInfo",{current:B,total:Math.ceil(M/24)})}),o.jsx("button",{disabled:B>=Math.ceil(M/24),onClick:()=>{const U=B+1;G(U),ie({q:z||void 0,category:F||void 0,page:U})},className:"px-3 py-1.5 text-xs bg-surface-elevated text-fg-secondary rounded-lg hover:bg-surface-overlay disabled:opacity-30",children:n("skillStore.nextPage")})]})]})]}),c==="skillssh"&&o.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`,children:[o.jsxs("div",{className:`flex ${l?"flex-wrap":""} items-center gap-2 mb-5`,children:[o.jsx("input",{value:oe,onChange:U=>L(U.target.value),onKeyDown:U=>{U.key==="Enter"&&oe.trim()&&tt(oe)},placeholder:n("skillStore.searchSkillssh"),className:`px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none ${l?"flex-1 min-w-0":"w-72"}`}),o.jsx("button",{onClick:()=>{oe.trim()&&tt(oe)},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-on-brand text-xs rounded-lg shrink-0",children:n("common:search")}),!l&&o.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:o.jsx("a",{href:"https://skills.sh",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),Ne?o.jsx("div",{className:"text-center text-fg-tertiary py-20",children:o.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillssh")})}):ne.length===0?o.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[o.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"⬡"}),o.jsx("div",{children:n("skillStore.browseSkillssh")}),o.jsx("div",{className:"text-xs mt-1",children:n("skillStore.browseSkillsshHint")})]}):o.jsx(Ha,{columns:3,children:ne.map(U=>{const re=b.some(Ce=>Ce.name===U.name);return o.jsx(mr,{type:"skill",name:U.name,description:U.description||"",seed:`${U.author}-${U.name}`,icon:Zu(U.name),authorLabel:`${U.author}/${U.repo}`,showTypeBadge:!1,installed:re,hideStats:!0,cornerLabel:re?void 0:"skills.sh",onClick:()=>window.open(U.url,"_blank","noopener,noreferrer"),footerLeft:U.installs?o.jsx("span",{className:"text-[10px] text-fg-tertiary",children:n("skillStore.installsCount",{count:U.installs})}):void 0,actions:re?void 0:o.jsx("button",{onClick:()=>{Me(U)},disabled:g.has(U.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg disabled:opacity-50",children:g.has(U.name)?"...":n("card.install")})},`${U.author}-${U.name}`)})})]})]})}const Rue=["agent","team","skill","connector"];function z0({title:e,subtitle:t,onMore:n,moreLabel:a}){return o.jsxs("div",{className:"flex items-end justify-between mb-3",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"section-title",children:e}),t&&o.jsx("p",{className:"section-subtitle",children:t})]}),n&&o.jsxs("button",{className:"section-link",onClick:n,children:[a??"View all"," →"]})]})}function _ue({item:e,onOpen:t}){const{t:n}=ut(["store","common"]),a=il(e.subtype==="connector"?"connector":e.itemType),i=Fb(a,e.slug||e.name),l=Bs[a];return o.jsxs("button",{onClick:t,className:"group relative w-full overflow-hidden rounded-2xl text-left h-44 md:h-52",style:{background:i},children:[o.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-black/55 via-black/20 to-transparent"}),o.jsx("svg",{className:"absolute -right-8 -bottom-10 opacity-20",width:"220",height:"220",viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:o.jsx("path",{d:"M12 2l2.4 6.9L21 9l-5.4 4 2 7-5.6-4.1L6.4 20l2-7L3 9l6.6-.1z",fill:"white"})}),o.jsxs("div",{className:"relative h-full flex flex-col justify-end p-5 md:p-6",children:[o.jsx("span",{className:"inline-flex w-fit items-center gap-1 rounded-full bg-white/20 backdrop-blur px-2.5 py-0.5 text-[11px] font-semibold text-white mb-2",children:n("discover.featured",{type:l.label})}),o.jsx("h2",{className:"text-xl md:text-2xl font-bold text-white drop-shadow-sm",children:e.name}),o.jsx("p",{className:"text-sm text-white/85 truncate max-w-lg mt-1",children:e.description}),o.jsxs("div",{className:"flex items-center gap-3 mt-3 text-white/80 text-xs",children:[o.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[o.jsx(Wm,{name:e.author?.displayName,username:e.author?.username,avatarUrl:e.author?.avatarUrl,hubBase:at.getUrl(),size:18}),e.author?.displayName||e.author?.username]}),o.jsxs("span",{children:["↓ ",qo(e.downloadCount)]}),(e.priceCents??0)>0?o.jsxs("span",{className:"badge-paid",children:["$",((e.priceCents??0)/100).toFixed(0)]}):o.jsx("span",{className:"badge-free",children:n("discover.free")})]})]})]})}function p4({items:e,onOpen:t}){return o.jsx(Ha,{columns:3,children:e.map(n=>o.jsx(mr,{type:n.subtype==="connector"?"connector":n.itemType,name:n.name,description:n.description,seed:n.slug||n.name,icon:n.icon,cover:n.thumbnailUrl,hubBase:at.getUrl(),author:n.author,category:n.category,tags:n.tags,rating:parseFloat(n.avgRating)||0,ratingCount:n.ratingCount,downloadCount:n.downloadCount,priceCents:n.priceCents,currency:n.currency,onClick:()=>t(n)},n.id))})}function f4(){return o.jsx(Ha,{columns:3,children:Array.from({length:6}).map((e,t)=>o.jsx("div",{className:"h-64 rounded-2xl skeleton"},t))})}function Due({onOpenType:e}){const{t}=ut(["store","common"]),[n,a]=w.useState([]),[i,l]=w.useState(!0);w.useEffect(()=>{let h=!1;return(async()=>{l(!0);try{const b=await at.search({limit:60,sort:"popular"});h||a(b.items??[])}catch{h||a([])}finally{h||l(!1)}})(),()=>{h=!0}},[]);const c=w.useMemo(()=>{const h=n.filter(y=>y.featured);return(h.length>0?h:n).slice(0,3)},[n]),u=w.useMemo(()=>[...n].sort((h,b)=>(b.trendingScore??b.downloadCount)-(h.trendingScore??h.downloadCount)).slice(0,10),[n]),m=w.useMemo(()=>[...n].sort((h,b)=>(b.createdAt||"").localeCompare(h.createdAt||"")).slice(0,10),[n]),f=w.useMemo(()=>{const h=new Map;for(const b of n){const y=b.author?.username||b.author?.id;if(!y)continue;const k=h.get(y)??{author:b.author,downloads:0,count:0};k.downloads+=b.downloadCount||0,k.count+=1,h.set(y,k)}return[...h.values()].sort((b,y)=>y.downloads-b.downloads).slice(0,6)},[n]),g=h=>e(il(h.subtype==="connector"?"connector":h.itemType),h.id);return o.jsxs("div",{className:"flex-1 overflow-y-auto px-5 md:px-7 py-5 space-y-8",children:[o.jsxs("div",{className:"hero-glow rounded-2xl border border-border-subtle bg-surface-secondary p-5 md:p-6",children:[o.jsx("h1",{className:"text-2xl font-bold text-gradient tracking-tight",children:t("discover.title","Markus 广场")}),o.jsx("p",{className:"text-sm text-fg-tertiary mt-1 max-w-2xl",children:t("discover.subtitle","发现社区共享的智能体、AI 小队、技能与连接器 — 由创作者共建的开放生态。")}),o.jsx("div",{className:"flex flex-wrap gap-2 mt-4",children:Rue.map(h=>o.jsxs("button",{onClick:()=>e(h),className:`inline-flex items-center gap-1.5 rounded-full px-3 py-1.5 text-xs font-medium text-white bg-gradient-to-r ${Bs[h].gradient} hover:opacity-90 transition-opacity`,children:[Bs[h].labelZh,o.jsx("span",{className:"opacity-70",children:Bs[h].label})]},h))})]}),i?o.jsx("div",{className:"h-52 rounded-2xl skeleton"}):c.length>0?o.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:c.map(h=>o.jsx(_ue,{item:h,onOpen:()=>g(h)},h.id))}):null,o.jsxs("section",{children:[o.jsx(z0,{title:t("discover.trending","热门趋势"),subtitle:t("discover.trendingSub","社区中下载与评分增长最快的资产")}),i?o.jsx(f4,{}):u.length>0?o.jsx(p4,{items:u,onOpen:g}):o.jsx(Iue,{})]}),o.jsxs("section",{children:[o.jsx(z0,{title:t("discover.fresh","新鲜上架"),subtitle:t("discover.freshSub","来自创作者的最新作品")}),i?o.jsx(f4,{}):m.length>0?o.jsx(p4,{items:m,onOpen:g}):null]}),f.length>0&&o.jsxs("section",{children:[o.jsx(z0,{title:t("discover.topCreators","顶尖创作者"),subtitle:t("discover.topCreatorsSub","生态贡献榜")}),o.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:f.map((h,b)=>o.jsxs("div",{className:"asset-card p-4 flex flex-col items-center text-center",children:[o.jsxs("div",{className:"relative",children:[o.jsx(Wm,{name:h.author?.displayName,username:h.author?.username,avatarUrl:h.author?.avatarUrl,hubBase:at.getUrl(),size:48,verified:b<3}),b<3&&o.jsx("span",{className:"absolute -top-1 -left-1 w-5 h-5 rounded-full bg-amber-400 text-black text-[10px] font-bold flex items-center justify-center ring-2 ring-surface-secondary",children:b+1})]}),o.jsx("div",{className:"text-sm font-semibold text-fg-primary truncate w-full mt-2",children:h.author?.displayName||h.author?.username}),o.jsxs("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:[t("discover.worksCount",{count:h.count})," · ↓ ",qo(h.downloads)]})]},h.author?.username||b))})]})]})}function Iue(){const{t:e}=ut(["store"]);return o.jsxs("div",{className:"text-center py-12 rounded-2xl border border-dashed border-border-default",children:[o.jsx("div",{className:"text-3xl mb-2 opacity-40",children:"✦"}),o.jsx("div",{className:"text-fg-secondary font-medium",children:e("discover.empty","生态正在成长中")}),o.jsx("div",{className:"text-fg-tertiary text-sm mt-1",children:e("discover.emptyHint","成为首批创作者,分享你的第一个资产")})]})}function $u(e,t,n){return e.i18n?.[n]?.[t]}function Lue(){const{t:e,i18n:t}=ut(["store","common"]),n=Xo(),a=t.language,[i,l]=w.useState([]),[c,u]=w.useState({}),[m,f]=w.useState(new Set),[g,h]=w.useState(null),[b,y]=w.useState(!0),[k,C]=w.useState(""),[T,A]=w.useState("all"),[M,I]=w.useState(null),B=w.useCallback(async()=>{y(!0);try{const[O,F,Y,q]=await Promise.all([Se.builder.artifacts.list().catch(()=>({artifacts:[]})),Se.builder.artifacts.installed().catch(()=>({installed:{}})),Se.skills.updates().catch(()=>({updates:[],count:0})),Se.skills.builtin().catch(()=>({skills:[]}))]),V={};for(const D of Y.updates)V[D.name]={availableVersion:D.availableVersion,installedVersion:D.installedVersion,displayName:D.displayName,description:D.description};u(V);const z=O.artifacts.filter(D=>{const ee=`${D.type}/${D.name}`;return!!F.installed[ee]}),J=new Set(z.filter(D=>D.type==="skill").map(D=>D.name));for(const D of q.skills)!D.installed||J.has(D.name)||!(F.installed[`skill/${D.name}`]||V[D.name])&&!D.updateAvailable||!F.installed[`skill/${D.name}`]&&!V[D.name]||(z.push({type:"skill",name:D.name,meta:{displayName:D.i18n?.[a]?.displayName||D.name,description:D.i18n?.[a]?.description||D.description||"",version:D.installedVersion||D.version,author:D.author,category:D.category,tags:D.tags,i18n:D.i18n},path:"",updatedAt:""}),J.add(D.name));for(const[D,ee]of Object.entries(V))J.has(D)||(z.push({type:"skill",name:D,meta:{displayName:ee.displayName||D,description:ee.description||"",version:ee.installedVersion},path:"",updatedAt:""}),J.add(D));l(z)}catch{}y(!1)},[a]);w.useEffect(()=>{B()},[B]),w.useEffect(()=>{const O=()=>{B()};return window.addEventListener("markus:data-changed",O),()=>window.removeEventListener("markus:data-changed",O)},[B]),w.useEffect(()=>{if(!g)return;const O=setTimeout(()=>h(null),3e3);return()=>clearTimeout(O)},[g]);const G=async(O,F)=>{if(!m.has(O)){f(Y=>new Set(Y).add(O));try{await Se.skills.install({name:O,source:"builtin"});try{localStorage.removeItem("markus:template-updates-ack")}catch{}h({text:e("installedTab.updateSuccess",{name:O,version:F}),type:"success"}),window.dispatchEvent(new CustomEvent("markus:data-changed")),await B()}catch{h({text:e("installedTab.updateFailed",{name:O}),type:"error"})}f(Y=>{const q=new Set(Y);return q.delete(O),q})}},j=i.filter(O=>{if(T!=="all"&&O.type!==T)return!1;if(!k)return!0;const F=k.toLowerCase(),Y=($u(O.meta,"displayName",a)||O.meta.displayName||O.name).toLowerCase(),q=($u(O.meta,"description",a)||O.meta.description||"").toLowerCase();return Y.includes(F)||q.includes(F)}).sort((O,F)=>{const Y=O.type==="skill"&&c[O.name]?1:0;return(F.type==="skill"&&c[F.name]?1:0)-Y});return M?o.jsx(qs,{type:M.type,name:M.name,onBack:()=>I(null)}):o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[o.jsxs("div",{"data-electron-drag":!0,className:`${n?"px-4":"px-6"} h-14 flex items-center shrink-0 gap-3`,children:[o.jsx("h2",{className:"text-lg font-semibold",children:e("installedTab.title")}),Object.keys(c).length>0&&o.jsxs("span",{className:"px-2 py-0.5 text-[11px] font-medium rounded-md bg-amber-500/15 text-amber-600 border border-amber-500/25",children:[e("installedTab.updateAvailable")," · ",Object.keys(c).length]})]}),o.jsxs("div",{className:`flex flex-wrap items-center gap-2 ${n?"px-4":"px-6"} py-2 shrink-0`,children:[o.jsx("div",{className:"flex gap-1",children:["all","agent","team","skill"].map(O=>o.jsx("button",{onClick:()=>A(O),className:`px-3 py-1 text-xs rounded-md transition-colors ${T===O?"bg-brand-600 text-on-brand":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:e(`installedTab.filter${O==="all"?"All":O==="agent"?"Agents":O==="team"?"Teams":"Skills"}`)},O))}),o.jsx("div",{className:"flex-1 min-w-[120px]",children:o.jsx("input",{type:"text",placeholder:e("installedTab.searchPlaceholder"),value:k,onChange:O=>C(O.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm w-full focus:border-brand-500 focus:outline-none"})})]}),o.jsx("div",{className:`flex-1 overflow-y-auto ${n?"p-4":"p-7"}`,children:b?o.jsx("div",{className:"text-center text-fg-tertiary py-20 animate-pulse",children:e("installedTab.loading")}):j.length===0?o.jsxs("div",{className:"text-center py-20",children:[o.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),o.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:e("installedTab.noItems")}),o.jsx("div",{className:"text-fg-tertiary text-sm",children:e("installedTab.noItemsHint")})]}):o.jsx(Ha,{columns:3,children:j.map(O=>{const F=$u(O.meta,"displayName",a)||O.meta.displayName||O.name,Y=$u(O.meta,"description",a)||O.meta.description||"",q=O.meta.version||"",V=O.meta.author||"",z=O.meta.tags??[],J=O.meta.category||"",D=O.meta.icon,ee=D&&/\.(png|jpe?g|gif|webp|svg)$/i.test(D)&&!D.startsWith("http")&&!D.startsWith("data:")&&!D.startsWith("/")?`/api/builder/artifacts/${O.type}s/${encodeURIComponent(O.name)}/${D}`:D,R=O.type==="skill"?c[O.name]:void 0;return o.jsx(mr,{type:O.type,name:F,description:Y,seed:O.name,icon:ee,author:null,authorLabel:V||void 0,version:R?R.installedVersion:q,category:J,tags:z,installed:!R,hideStats:!0,cornerLabel:R?e("installedTab.updateAvailable"):void 0,onClick:()=>{O.path&&I({type:O.type,name:O.name})},actions:R?o.jsx("button",{type:"button",disabled:m.has(O.name),onClick:()=>{G(O.name,R.availableVersion)},className:"px-3 py-1.5 text-xs font-medium bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:m.has(O.name)?e("installedTab.updating"):e("installedTab.updateTo",{version:R.availableVersion})}):void 0},`${O.type}/${O.name}`)})})}),g&&o.jsx("div",{className:`fixed bottom-6 left-1/2 -translate-x-1/2 z-50 px-4 py-2 rounded-lg text-sm shadow-lg ${g.type==="success"?"bg-emerald-600 text-white":"bg-red-600 text-white"}`,children:g.text})]})}const Pue=50,Oue=30;function Hue(e,t,n,a){const i=w.useRef(0),l=w.useRef(0),c=w.useCallback(m=>{i.current=m.touches[0].clientX,l.current=m.touches[0].clientY},[]),u=w.useCallback(m=>{const f=m.changedTouches[0].clientX-i.current,g=m.changedTouches[0].clientY-l.current,h=Math.abs(f),b=Math.abs(g);if(h<Pue||Math.atan2(b,h)*(180/Math.PI)>Oue)return;if(a?.scrollContainerRef?.current){const C=a.scrollContainerRef.current,T=C.scrollLeft<=1,A=C.scrollLeft+C.clientWidth>=C.scrollWidth-1;if(f>0&&!T||f<0&&!A)return}const k=e.findIndex(C=>C.id===t);f<0&&k<e.length-1?n(e[k+1].id):f>0&&k>0?n(e[k-1].id):f>0&&k===0&&a?.onSwipeOutLeft?a.onSwipeOutLeft():f<0&&k===e.length-1&&a?.onSwipeOutRight&&a.onSwipeOutRight()},[e,t,n,a]);return{onTouchStart:c,onTouchEnd:u}}const Bue=["builder","discover","agents","teams","skills","installed"],zue={agent:"agents",team:"teams",skill:"skills",connector:"skills"};function Jg(e){return!!e&&Bue.includes(e)}function h4(){const e=localStorage.getItem("markus_nav_installItem"),t=localStorage.getItem("markus_nav_storeTab");return{tab:Jg(t)?t:"builder",installId:e}}function que({authUser:e}){const{t}=ut(["nav","store","common"]),n=w.useMemo(()=>[{id:"builder",label:t("nav:tabs.create")},{id:"discover",label:t("nav:tabs.discover")},{id:"agents",label:t("nav:tabs.agents")},{id:"teams",label:t("nav:tabs.teams")},{id:"skills",label:t("nav:tabs.skills")},{id:"installed",label:t("nav:tabs.installed")}],[t]),[a]=w.useState(h4),[i,l]=w.useState(a.tab),[c,u]=w.useState(a.installId),m=Hue(n,i,l);w.useEffect(()=>{const g=h4();g.installId&&(u(g.installId),Jg(g.tab)&&l(g.tab),localStorage.removeItem("markus_nav_installItem"),localStorage.removeItem("markus_nav_storeTab"))},[]),w.useEffect(()=>{const g=h=>{const b=h.detail,y=b.params?.storeTab??localStorage.getItem("markus_nav_storeTab");Jg(y)&&l(y);const k=b.params?.installItem??localStorage.getItem("markus_nav_installItem");k&&u(k),localStorage.removeItem("markus_nav_storeTab"),localStorage.removeItem("markus_nav_installItem")};return window.addEventListener("markus:navigate",g),()=>window.removeEventListener("markus:navigate",g)},[]);const f=(g,h)=>{h&&u(h),l(zue[g]??"agents")};return o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:m.onTouchStart,onTouchEnd:m.onTouchEnd,children:[o.jsxs("div",{className:"flex items-center shrink-0 overflow-x-auto scrollbar-hide",children:[o.jsx(ES,{className:"ml-2"}),n.map(g=>o.jsx("button",{onClick:()=>l(g.id),className:`flex-1 min-w-fit px-3 py-2.5 text-xs font-medium text-center whitespace-nowrap transition-colors border-b-2 ${i===g.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:g.label},g.id))]}),o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[i==="builder"&&o.jsx(iA,{authUser:e}),i==="discover"&&o.jsx(Due,{onOpenType:f}),i==="agents"&&o.jsx(kue,{authUser:e,highlightItemId:c,onHighlightDone:()=>u(null)}),i==="teams"&&o.jsx(Aue,{highlightItemId:c,onHighlightDone:()=>u(null)}),i==="skills"&&o.jsx(jue,{highlightItemId:c,onHighlightDone:()=>u(null)}),i==="installed"&&o.jsx(Lue,{})]})]})}const uA="markus_native_update_dismissed";function mA(e=window.markusDesktop){return!e||e.isMAS?!1:typeof e.onUpdateState=="function"&&typeof e.installUpdate=="function"}function $ue(){try{return localStorage.getItem(uA)}catch{return null}}function Fue(){const{t:e}=ut("common"),[t,n]=w.useState(null),[a,i]=w.useState($ue),[l,c]=w.useState(null);w.useEffect(()=>{const y=window.markusDesktop;if(!y||!mA(y))return;let k=!1;y.getUpdateState?.().then(T=>{!k&&T&&n(T)}).catch(()=>{});const C=y.onUpdateState?.(T=>n(T));return()=>{k=!0,C?.()}},[]);const u=w.useCallback(()=>{const y=t?.version??null;i(y);try{y&&localStorage.setItem(uA,y)}catch{}},[t]),m=w.useCallback(()=>{c(null),window.markusDesktop?.installUpdate?.().then(y=>{y?.ok||c(y?.error??"unknown")}).catch(()=>c("unknown"))},[]);if(!t||t.version===null||t.phase!=="downloading"&&t.phase!=="ready"||a===t.version)return null;const{version:f,percent:g,requiresMoveToApplications:h}=t,b=t.phase==="ready";return o.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-brand-500/10 border-b border-brand-500/30 text-brand-400 text-sm shrink-0",children:[o.jsxs("span",{className:"text-xs",children:[h?e("update.moveToApplications"):b?e("update.ready",{version:f}):e("update.downloading",{version:f,percent:g??0}),l&&o.jsx("span",{className:"ml-2 text-amber-500",children:e("update.restartFailed")})]}),o.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[b&&!h&&o.jsx("button",{type:"button",onClick:m,className:"px-3 py-1 bg-brand-600 hover:bg-brand-500 text-on-brand text-xs rounded-lg transition-colors",children:e("update.restart")}),o.jsx("button",{type:"button",onClick:u,className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]})}const g4="usageType",q0="profile";function Uue({onComplete:e,theme:t,onThemeChange:n,skipProfile:a,onProfileUpdated:i}){const{t:l}=ut(["onboarding","common"]),[c,u]=w.useState(0),[m,f]=w.useState("local"),[g,h]=w.useState(""),[b,y]=w.useState(""),[k,C]=w.useState(""),[T,A]=w.useState(""),[M,I]=w.useState(!1),[B,G]=w.useState(""),[j,O]=w.useState(!1),[F,Y]=w.useState(null);w.useEffect(()=>{Se.auth.me().then(({user:He})=>{He.name&&h(He.name),He.email&&y(He.email),He.avatarUrl&&Y(He.avatarUrl);const Et=He.name||He.email?.split("@")[0]||"";Et&&J(Kt=>Kt||l("usageType.defaultOrgName",{name:Et}))}).catch(()=>{}),Se.settings.getOrg().then(({org:He})=>{He?.name&&He.name!=="My Organization"&&J(He.name)}).catch(()=>{}),Tn()&&Se.hubOrgs.invitations().then(He=>{He.invitations?.length>0&&W(He.invitations)}).catch(()=>{})},[]);const[q,V]=w.useState(null),[z,J]=w.useState(""),[D,ee]=w.useState(!1),[R,te]=w.useState(!1),[le,ke]=w.useState(""),[$,W]=w.useState([]),[oe,L]=w.useState(null),[Ne,qe]=w.useState(null),me=async()=>{const He=z.trim();if(He){ee(!0),ke("");try{if(await Se.settings.updateOrg(He),Tn()){const Et=await Se.hubOrgs.mine(),Kt=Et.orgs?.find(ie=>ie.role==="owner")??Et.orgs?.[0];Kt?.id?await Se.hubOrgs.update(Kt.id,{name:He}):await Se.hubOrgs.create(He)}te(!0)}catch{ke(l("usageType.orgNameSaveFailed"))}finally{ee(!1)}}},[ze,Ue]=w.useState(!0),je=async()=>{if(G(""),!g.trim()){G(l("profile.errors.nameRequired"));return}if(!b.trim()){G(l("profile.errors.emailRequired"));return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(b.trim())){G(l("profile.errors.emailInvalid"));return}if(k&&k.length<6){G(l("profile.errors.passwordTooShort"));return}if(k&&k!==T){G(l("profile.errors.passwordMismatch"));return}I(!0);try{const{user:He}=await Se.auth.updateProfile(g.trim(),b.trim());k&&await Se.auth.changePassword("",k),i?.(He),O(!0)}catch{G(l("profile.errors.saveFailed"))}finally{I(!1)}},Ye=[{value:"system",label:l("theme.system"),icon:"💻",desc:l("theme.systemDesc")},{value:"light",label:l("theme.light"),icon:"☀️",desc:l("theme.lightDesc")},{value:"dark",label:l("theme.dark"),icon:"🌊",desc:l("theme.darkDesc")},{value:"cyberpunk",label:l("theme.cyberpunk"),icon:"🔮",desc:l("theme.cyberpunkDesc")},{value:"mono",label:l("theme.mono"),icon:"⬛",desc:l("theme.monoDesc")}],xt=[{id:"welcome",title:l("welcome.title"),subtitle:l("welcome.subtitle"),content:o.jsx("p",{className:"text-fg-secondary text-sm leading-relaxed",children:o.jsx(vE,{i18nKey:"welcome.description",ns:"onboarding",components:{strong:o.jsx("strong",{className:"text-fg-primary"})}})})},{id:g4,title:l("usageType.title",{defaultValue:"How will you use Markus?"}),subtitle:l("usageType.subtitle",{defaultValue:"This helps us tailor your experience."}),content:o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("button",{onClick:()=>{V("personal"),te(!0)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${q==="personal"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[o.jsx("span",{className:"text-2xl",children:"👤"}),o.jsxs("div",{children:[o.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:l("usageType.personal",{defaultValue:"Personal"})}),o.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:l("usageType.personalDesc",{defaultValue:"Individual use with your own AI agents."})})]})]}),o.jsxs("button",{onClick:()=>{V("organization"),te(!1)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${q==="organization"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[o.jsx("span",{className:"text-2xl",children:"🏢"}),o.jsxs("div",{children:[o.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:l("usageType.organization",{defaultValue:"Team & Enterprise"})}),o.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:l("usageType.organizationDesc",{defaultValue:"For teams sharing licenses and collaborating."})})]})]})]}),q==="organization"&&o.jsxs("div",{className:"space-y-4 mt-4",children:[$.length>0&&o.jsxs("div",{className:"space-y-2",children:[o.jsx("div",{className:"text-xs text-fg-tertiary font-medium",children:l("usageType.pendingInvitations")}),$.map(He=>o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 rounded-xl border border-amber-500/20 bg-amber-500/5",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium text-fg-primary",children:He.orgName}),o.jsx("div",{className:"text-[11px] text-fg-tertiary",children:l("usageType.invitedBy",{name:He.invitedBy})})]}),o.jsx("button",{onClick:async()=>{L(He.orgId);try{await Se.hubOrgs.acceptInvitation(He.orgId),qe(He.orgId),te(!0)}catch{}finally{L(null)}},disabled:oe===He.orgId||Ne===He.orgId,className:"px-3 py-1.5 text-xs rounded-lg bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-on-brand transition-colors",children:Ne===He.orgId?l("usageType.accepted"):oe===He.orgId?l("usageType.accepting"):l("usageType.acceptAndJoin")})]},He.orgId)),o.jsx("div",{className:"text-[11px] text-fg-tertiary text-center pt-1",children:l("usageType.orCreateNew")})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("usageType.orgNameLabel")}),o.jsx("input",{type:"text",value:z,onChange:He=>{J(He.target.value),te(!1),ke("")},placeholder:l("usageType.orgNamePlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),le&&o.jsx("p",{className:"text-xs text-red-500",children:le}),o.jsx("button",{onClick:()=>{me()},disabled:D||!z.trim()||R,className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-on-brand text-sm rounded-xl transition-colors",children:l(D?"common:saving":R?"usageType.orgNameSaved":"usageType.setOrgName")})]})]})},{id:q0,title:l("profile.title"),subtitle:l("profile.subtitle"),content:j?o.jsxs("div",{className:"flex items-center gap-3 bg-green-500/10 border border-green-500/30 rounded-xl p-4",children:[o.jsx("span",{className:"text-green-600 text-lg",children:"✓"}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium text-green-600",children:l("profile.saved")}),o.jsxs("div",{className:"text-xs text-fg-secondary mt-0.5",children:[g," · ",b]})]})]}):o.jsxs("div",{className:"space-y-4",children:[o.jsx("div",{className:"flex justify-center",children:o.jsx(AS,{currentUrl:F,name:g,size:64,targetType:"user"})}),o.jsxs("div",{className:"space-y-1",children:[o.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.nameLabel")," ",o.jsx("span",{className:"text-red-500",children:"*"})]}),o.jsx("input",{type:"text",value:g,onChange:He=>h(He.target.value),placeholder:l("profile.namePlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",autoFocus:!0})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.emailLabel")," ",o.jsx("span",{className:"text-red-500",children:"*"})]}),o.jsx("input",{type:"email",value:b,onChange:He=>y(He.target.value),placeholder:l("profile.emailPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("profile.newPasswordLabel")}),o.jsx("input",{type:"password",value:k,onChange:He=>C(He.target.value),placeholder:l("profile.newPasswordPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),k&&o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("profile.confirmPasswordLabel")}),o.jsx("input",{type:"password",value:T,onChange:He=>A(He.target.value),placeholder:l("profile.confirmPasswordPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),B&&o.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:B}),o.jsx("button",{onClick:()=>{je()},disabled:M||!g.trim()||!b.trim(),className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-on-brand text-sm rounded-xl transition-colors",children:l(M?"common:saving":"profile.saveProfile")})]})},{id:"accessScope",title:l("settings:accessScope.title"),subtitle:l("settings:accessScope.description"),content:o.jsxs("div",{className:"space-y-3",children:[[{id:"local",label:l("settings:accessScope.localOnly"),desc:l("settings:accessScope.localOnlyHint"),host:"127.0.0.1"},{id:"lan",label:l("settings:accessScope.lan"),desc:l("settings:accessScope.lanHint"),host:"0.0.0.0"}].map(He=>o.jsxs("button",{onClick:()=>{f(He.id),fetch("/api/settings/network",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({host:He.host})}).catch(()=>{})},className:`w-full text-left p-3 rounded-lg border transition-colors ${m===He.id?"border-brand-500 bg-brand-500/10":"border-border-default bg-surface-elevated/30"}`,children:[o.jsx("div",{className:"text-sm text-fg-primary",children:He.label}),o.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:He.desc})]},He.id)),o.jsx("p",{className:"text-[11px] text-fg-muted",children:l("settings:accessScope.remoteNote")})]})},{id:"theme",title:l("theme.title"),subtitle:l("theme.subtitle"),content:o.jsxs("div",{className:"space-y-4",children:[o.jsx("div",{className:"grid grid-cols-3 gap-3",children:Ye.map(He=>o.jsxs("button",{onClick:()=>n(He.value),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-5 transition-all ${t===He.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[o.jsx("span",{className:"text-2xl",children:He.icon}),o.jsx("span",{className:"text-sm font-medium text-fg-primary",children:He.label}),o.jsx("span",{className:"text-[11px] text-fg-tertiary leading-tight text-center",children:He.desc})]},He.value))}),o.jsxs("label",{className:"flex items-center gap-2.5 p-3 bg-surface-elevated/30 rounded-lg cursor-pointer group",children:[o.jsx("input",{type:"checkbox",checked:ze,onChange:He=>Ue(He.target.checked),className:"accent-brand-500 shrink-0"}),o.jsx("span",{className:"text-[11px] text-fg-tertiary",children:l("done.telemetry")})]})]})}],mt=a?xt.filter(He=>He.id!==q0):xt,ft=mt.findIndex(He=>He.id===g4),rt=mt.findIndex(He=>He.id===q0),jt=()=>{c===ft&&ft>=0&&!q||c===ft&&q==="organization"&&!R||c===rt&&rt>=0&&!j||(c<mt.length-1?u(c+1):(fetch("/api/settings/telemetry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:ze})}).catch(()=>{}),e()))},ht=mt[c];return o.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4",children:o.jsx("div",{className:"w-full max-w-lg",children:o.jsxs("div",{className:"bg-surface-elevated rounded-2xl p-8",children:[o.jsx("div",{className:"flex gap-1.5 mb-8",children:mt.map((He,Et)=>o.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${Et<=c?"bg-brand-500":"bg-surface-elevated"}`},Et))}),o.jsx("h2",{className:"text-2xl font-bold text-fg-primary",children:ht.title}),o.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:ht.subtitle}),ht.content,o.jsxs("div",{className:"flex justify-between mt-8",children:[c>0?o.jsx("button",{onClick:()=>u(c-1),className:"px-4 py-2 text-sm text-fg-secondary hover:text-fg-primary transition-colors",children:l("common:back")}):o.jsx("span",{}),o.jsx("button",{onClick:jt,disabled:rt>=0&&c===rt&&!j||ft>=0&&c===ft&&(!q||q==="organization"&&!R),className:`px-6 py-2.5 text-on-brand text-sm rounded-xl transition-colors ${rt>=0&&c===rt&&!j||ft>=0&&c===ft&&(!q||q==="organization"&&!R)?"bg-brand-600/40 cursor-not-allowed":"bg-brand-600 hover:bg-brand-500"}`,children:c===mt.length-1?l("getStarted"):l("common:next")})]})]})})})}const b4="markus:legal-consent",Gue="https://markus.global";function Kue({onLogin:e,hasOwner:t}){const{t:n,i18n:a}=ut("auth"),[i,l]=w.useState(null),[c,u]=w.useState(""),[m,f]=w.useState(!1),[g,h]=w.useState(""),[b,y]=w.useState(""),[k,C]=w.useState(!1),[T,A]=w.useState(!1),M=V=>{const z=(a.language||"").toLowerCase().startsWith("zh")?"?lang=zh":"";return`${Gue}${V}${z}`},I=()=>{try{localStorage.setItem(b4,JSON.stringify({acceptedAt:new Date().toISOString(),terms:!0,privacy:!0}))}catch{}},B=()=>T?(I(),!0):(C(!1),requestAnimationFrame(()=>C(!0)),!1),G=async()=>{const V=Tn(),z=Oa();if(!V||!z){u(n("login.hubUnavailable"));return}const J=await Se.auth.hubLogin(V,z);if(window.markusDesktop?.clearPendingDeepLinkAuth?.(),J.cloudAiReady===!1)try{sessionStorage.setItem("markus:cloud-ai-warning",J.cloudAiError?n("login.cloudAiNotReady",{error:J.cloudAiError}):n("login.cloudAiNotReadyGeneric"))}catch{}e(J.user,J.needsOnboarding??!1,{fromHub:!0})},j=async(V,z=!1)=>{if(!(!z&&!B())){u(""),l(V??"hub");try{if(z&&Tn()&&Oa()){await G();return}await Ia({method:V,force:!0}),await G()}catch(J){const D=J instanceof Error?J.message:"";if(!D.includes("cancelled")){if(!z&&Tn())return j(V,!0);u(D||n("login.hubUnavailable"))}}finally{l(null)}}},O=()=>{HY(),l(null),u("")};w.useEffect(()=>{const V=window.markusDesktop;if(!V?.peekPendingDeepLinkAuth&&!V?.consumePendingDeepLinkAuth)return;let z=!1;return(async()=>{const J=V.peekPendingDeepLinkAuth?await V.peekPendingDeepLinkAuth():null;if(z||!J)return;let D=!1;try{D=!!localStorage.getItem(b4)}catch{}if(!T&&!D){u(n("login.consentRequired"));return}D&&!T&&A(!0),I();const ee=V.consumePendingDeepLinkAuth?await V.consumePendingDeepLinkAuth():J;if(!(z||!ee)){u(""),l("hub");try{if(!await OY(ee)||!Tn()||!Oa()){u(n("login.hubUnavailable"));return}await G()}catch{u(n("login.hubUnavailable"))}finally{z||l(null)}}})().catch(()=>{}),()=>{z=!0}},[T]);const F=async V=>{if(V.preventDefault(),!(!g.trim()||!b)&&B()){u(""),l("local");try{const{user:z,needsOnboarding:J}=await Se.auth.login(g.trim(),b);e(z,J??!1)}catch{u(n("login.invalidCredentials"))}finally{l(null)}}},Y=n(t?"login.welcomeBack":"login.getStarted"),q="w-full flex items-center justify-center gap-3 h-11 px-4 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary font-medium transition-all hover:border-brand-400/60 hover:shadow-sm active:scale-[0.99] disabled:opacity-50 disabled:pointer-events-none";return o.jsxs("div",{className:"min-h-dvh bg-surface-primary flex flex-col items-center justify-center p-4 relative overflow-hidden",children:[o.jsxs("div",{className:"pointer-events-none absolute inset-0 overflow-hidden",children:[o.jsx("div",{className:"absolute -top-48 left-1/2 -translate-x-1/2 h-[42rem] w-[42rem] rounded-full bg-brand-500/20 blur-[120px]"}),o.jsx("div",{className:"absolute top-1/4 -left-40 h-[26rem] w-[26rem] rounded-full bg-brand-400/10 blur-[100px]"}),o.jsx("div",{className:"absolute -bottom-40 -right-32 h-[34rem] w-[34rem] rounded-full bg-brand-600/10 blur-[110px]"})]}),o.jsxs("div",{className:"w-full max-w-[26rem] relative z-10 flex-1 flex flex-col justify-center",children:[o.jsxs("div",{className:"text-center mb-8",children:[o.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-16 h-16 mx-auto mb-4 rounded-2xl shadow-xl shadow-brand-900/20 ring-1 ring-border-default/40"}),o.jsx("div",{className:"text-[1.75rem] leading-none font-extrabold tracking-tight text-fg-primary mb-2",children:"Markus"}),o.jsx("div",{className:"text-sm text-fg-tertiary",children:Y})]}),o.jsx("div",{className:"bg-surface-secondary/70 backdrop-blur-xl border border-border-default/80 rounded-3xl p-7 sm:p-8 shadow-2xl shadow-black/10",children:m?o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-base font-semibold text-fg-primary",children:n("login.localTitle")}),o.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:n("login.localAccountHint")})]}),o.jsxs("form",{onSubmit:F,className:"space-y-3",children:[o.jsx("input",{type:"email",value:g,onChange:V=>h(V.target.value),autoComplete:"email",autoFocus:!0,placeholder:n("login.email"),className:"w-full px-4 h-11 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 focus:ring-2 focus:ring-brand-500/20 outline-none transition-all placeholder:text-fg-tertiary",required:!0}),o.jsx("input",{type:"password",value:b,onChange:V=>y(V.target.value),autoComplete:"current-password",placeholder:n("login.password"),className:"w-full px-4 h-11 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 focus:ring-2 focus:ring-brand-500/20 outline-none transition-all placeholder:text-fg-tertiary",required:!0}),c&&o.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:c}),!t&&o.jsx("p",{className:"text-[11px] text-fg-tertiary",children:n("login.defaultCredentials")}),o.jsx("button",{type:"submit",disabled:i==="local"||!g||!b,className:"w-full h-11 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-on-brand text-sm font-semibold rounded-xl transition-all shadow-md shadow-brand-900/30 hover:shadow-lg active:scale-[0.99]",children:n(i==="local"?"login.signingIn":"login.signIn")})]}),o.jsx("div",{className:"text-center",children:o.jsx("button",{onClick:()=>{f(!1),u("")},className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors",children:n("login.backToHub")})})]}):o.jsxs("div",{className:"space-y-3",children:[o.jsxs("button",{onClick:()=>j("google"),disabled:!!i,className:q,children:[o.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[o.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 01-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z"}),o.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),o.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),o.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),n(i==="google"?"login.connectingHub":"login.withGoogle")]}),o.jsxs("button",{onClick:()=>j("github"),disabled:!!i,className:q,children:[o.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"})}),n(i==="github"?"login.connectingHub":"login.withGithub")]}),o.jsxs("button",{onClick:()=>j("email"),disabled:!!i,className:q,children:[o.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"})}),n(i==="email"?"login.connectingHub":"login.withEmail")]}),i&&(i==="google"||i==="github"||i==="email"||i==="hub")&&o.jsxs("div",{className:"px-3 py-2.5 bg-brand-500/10 border border-brand-500/30 rounded-lg text-xs text-fg-secondary space-y-2",children:[o.jsx("p",{children:n("login.browserOpened")}),o.jsx("button",{type:"button",onClick:O,className:"text-brand-500 hover:text-brand-400 underline font-medium",children:n("login.cancelWaiting")})]}),c&&o.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:c}),o.jsxs("div",{className:"flex items-center gap-3 py-1 text-[11px] text-fg-tertiary",children:[o.jsx("span",{className:"h-px flex-1 bg-border-default"}),n("login.or"),o.jsx("span",{className:"h-px flex-1 bg-border-default"})]}),o.jsx("button",{onClick:()=>{f(!0),u("")},disabled:!!i,className:"w-full h-11 px-4 rounded-xl text-sm text-fg-secondary font-medium transition-all hover:bg-surface-elevated/70 disabled:opacity-50",children:n("login.useLocalAccount")})]})}),o.jsxs("label",{onAnimationEnd:()=>C(!1),className:`mt-5 flex items-start justify-center gap-2 text-[11px] leading-relaxed cursor-pointer select-none px-2 transition-colors ${k?"animate-shake text-fg-primary font-medium":"text-fg-tertiary"}`,children:[o.jsx("input",{type:"checkbox",checked:T,onChange:V=>{A(V.target.checked),V.target.checked&&C(!1)},className:"mt-0.5 h-3.5 w-3.5 shrink-0 accent-brand-600 cursor-pointer"}),o.jsxs("span",{className:"text-center",children:[n("login.consentPrefix")," ",o.jsx("a",{href:M("/terms"),target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-400 underline",children:n("login.termsLink")})," ",n("login.consentAnd")," ",o.jsx("a",{href:M("/privacy"),target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-400 underline",children:n("login.privacyLink")})]})]})]}),o.jsxs("div",{className:"relative z-10 flex flex-wrap items-center justify-center gap-x-5 gap-y-1 py-6 text-[11px] text-fg-tertiary",children:[o.jsx("a",{href:"https://markus.global",target:"_blank",rel:"noopener noreferrer",className:"hover:text-fg-secondary transition-colors",children:"markus.global"}),o.jsx("a",{href:"mailto:business@markus.global",className:"hover:text-fg-secondary transition-colors",children:n("login.contactSales")})]})]})}function Vue({token:e,onComplete:t}){const{t:n}=ut(["auth","common"]),[a,i]=w.useState(null),[l,c]=w.useState(""),[u,m]=w.useState(""),[f,g]=w.useState(""),[h,b]=w.useState(!1),[y,k]=w.useState(!1),[C,T]=w.useState(!1);w.useEffect(()=>{Se.auth.inviteInfo(e).then(M=>i(M)).catch(()=>T(!0))},[e]);const A=async M=>{if(M.preventDefault(),g(""),l.length<6){g(n("invite.passwordMinLength"));return}if(l!==u){g(n("invite.passwordsDoNotMatch"));return}b(!0);try{await Se.auth.setup(e,l),k(!0),setTimeout(()=>{window.location.hash="",t()},2e3)}catch{g(n("invite.error"))}finally{b(!1)}};return o.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[o.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),o.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[o.jsxs("div",{className:"text-center mb-8",children:[o.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),o.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),o.jsx("div",{className:"text-sm text-fg-tertiary",children:n("invite.subtitle")})]}),o.jsx("div",{className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:C?o.jsxs("div",{className:"text-center space-y-3",children:[o.jsx("div",{className:"text-red-500 text-3xl",children:"⚠"}),o.jsx("p",{className:"text-sm text-fg-secondary",children:n("invite.invalidLink")}),o.jsx("button",{onClick:()=>{window.location.hash="",t()},className:"text-sm text-brand-500 hover:text-brand-400",children:n("login.signIn")})]}):y?o.jsxs("div",{className:"text-center space-y-3",children:[o.jsx("div",{className:"text-green-500 text-3xl",children:"✓"}),o.jsx("p",{className:"text-sm text-fg-secondary",children:n("invite.setupComplete")})]}):a?o.jsxs("form",{onSubmit:A,className:"space-y-5",children:[o.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n("invite.greeting",{name:a.name})}),o.jsx("p",{className:"text-xs text-fg-tertiary text-center",children:a.email}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("invite.setPassword")}),o.jsx("input",{type:"password",value:l,onChange:M=>c(M.target.value),autoComplete:"new-password",autoFocus:!0,className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("invite.confirmPassword")}),o.jsx("input",{type:"password",value:u,onChange:M=>m(M.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),f&&o.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:f}),o.jsx("button",{type:"submit",disabled:h||!l||!u,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-on-brand text-sm font-medium rounded-xl transition-all shadow-md shadow-brand-900/40 hover:shadow-lg hover:shadow-brand-900/50",children:n(h?"invite.settingUp":"invite.setupAccount")})]}):o.jsx("div",{className:"text-center text-fg-tertiary text-sm animate-pulse py-4",children:n("common:loading")})})]})]})}function Wue({onComplete:e,isFirstTime:t}){const{t:n}=ut("auth"),[a,i]=w.useState(""),[l,c]=w.useState(""),[u,m]=w.useState(""),[f,g]=w.useState(""),[h,b]=w.useState(!1),y=async k=>{if(k.preventDefault(),g(""),l.length<6){g(n("changePassword.passwordMinLength"));return}if(l!==u){g(n("changePassword.passwordsDoNotMatch"));return}b(!0);try{await Se.auth.changePassword(a,l),e()}catch{g(n("changePassword.failedToChange"))}finally{b(!1)}};return o.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[o.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),o.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[o.jsxs("div",{className:"text-center mb-8",children:[o.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),o.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),o.jsx("div",{className:"text-sm text-fg-tertiary",children:n("login.subtitle")})]}),o.jsxs("form",{onSubmit:y,className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n(t?"changePassword.setYourPassword":"changePassword.changePassword")}),t&&o.jsx("p",{className:"text-xs text-amber-600/80 text-center mt-2",children:n("changePassword.defaultPasswordWarning")})]}),!t&&o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.currentPassword")}),o.jsx("input",{type:"password",value:a,onChange:k=>i(k.target.value),autoComplete:"current-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.newPassword")}),o.jsx("input",{type:"password",value:l,onChange:k=>c(k.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0,minLength:6})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.confirmNewPassword")}),o.jsx("input",{type:"password",value:u,onChange:k=>m(k.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),f&&o.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:f}),o.jsx("button",{type:"submit",disabled:h||!l||!u,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-on-brand text-sm font-medium rounded-xl transition-colors",children:n(h?"changePassword.saving":t?"changePassword.setPasswordAndContinue":"changePassword.changePassword")})]})]})]})}const Yue=3e4;let dc=null,lc=null;function Spe(){dc=null}async function Que(e){if(!e?.force&&dc&&Date.now()-dc.at<Yue)return dc.data;if(lc)return lc;const t=(async()=>{const n=await fetch("/api/settings/llm",{credentials:"include"});if(!n.ok)throw new Error(`HTTP ${n.status}`);const a=await n.json();return dc={at:Date.now(),data:a},a})();lc=t;try{return await t}finally{lc===t&&(lc=null)}}function Jue({side:e,defaultWidth:t,minWidth:n,maxWidth:a,collapsedWidth:i=0,storageKey:l}){const[c,u]=w.useState(()=>{try{const C=localStorage.getItem(`${l}_w`);if(C)return Math.max(n,Math.min(a,parseInt(C,10)))}catch{}return t}),[m,f]=w.useState(()=>{try{return localStorage.getItem(`${l}_c`)==="1"}catch{return!1}}),g=w.useRef(!1),h=w.useRef(n),b=w.useRef(a);h.current=n,b.current=a,w.useEffect(()=>{try{localStorage.setItem(`${l}_w`,String(c))}catch{}},[c,l]),w.useEffect(()=>{try{localStorage.setItem(`${l}_c`,m?"1":"0")}catch{}},[m,l]),w.useEffect(()=>{u(C=>Math.max(n,Math.min(a,C)))},[n,a]);const y=w.useCallback(C=>{C.preventDefault(),g.current=!0;const T=C.clientX,A=c,M=B=>{if(!g.current)return;const G=B.clientX-T;u(Math.max(h.current,Math.min(b.current,A+G)))},I=()=>{g.current=!1,document.removeEventListener("mousemove",M),document.removeEventListener("mouseup",I),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",M),document.addEventListener("mouseup",I),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[c,e]),k=w.useCallback(()=>f(C=>!C),[]);return{width:m?i:c,rawWidth:c,collapsed:m,toggle:k,setCollapsed:f,setWidth:u,onResizeStart:y}}const Cpe=[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"cyberpunk",label:"Cyberpunk"},{value:"mono",label:"Mono"}],Xg="markus-theme";function y4(e){const t=document.documentElement;t.classList.remove("light","dark","cyberpunk","mono"),e==="light"?t.classList.add("light"):e==="dark"?t.classList.add("dark"):e==="cyberpunk"?t.classList.add("cyberpunk"):e==="mono"&&t.classList.add("mono")}function Xue(){try{const e=localStorage.getItem(Xg);if(e==="midnight")return localStorage.setItem(Xg,"dark"),"dark";if(e==="light"||e==="dark"||e==="system"||e==="cyberpunk"||e==="mono")return e}catch{}return"system"}function Zue(){const[e,t]=w.useState(Xue),n=w.useCallback(a=>{t(a);try{localStorage.setItem(Xg,a)}catch{}y4(a)},[]);return w.useEffect(()=>{y4(e)},[e]),{mode:e,setMode:n}}let Zg=!1;const eb=new Set;function Ape(e){if(Zg!==e){Zg=e;for(const t of eb)t()}}function eme(e){return eb.add(e),()=>{eb.delete(e)}}function tme(){return Zg}const lm={agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]},nme={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},ame=["agents","tasks","requirements","projects","deliverables","workflows"];let v4="",x4="all",w4=lm,k4=!1;function rme({onClose:e,currentPage:t}){const{t:n}=ut(["common","home","work"]);$s(!0);const[a,i]=w.useState(v4),[l,c]=w.useState(x4),[u,m]=w.useState(w4),[f,g]=w.useState(!1),[h,b]=w.useState(k4),[y,k]=w.useState(-1);w.useEffect(()=>{v4=a},[a]),w.useEffect(()=>{x4=l},[l]),w.useEffect(()=>{w4=u},[u]),w.useEffect(()=>{k4=h},[h]);const C=w.useRef(null),T=w.useRef(void 0),A=w.useRef(null),M=w.useRef(null);w.useEffect(()=>{setTimeout(()=>{C.current?.focus(),C.current?.select()},100)},[]);const I=w.useCallback(async J=>{if(!J.trim()){m(lm),b(!1),k(-1);return}g(!0),b(!0),k(-1);const D=J.toLowerCase();try{const[ee,R,te,le,ke,$]=await Promise.allSettled([Se.agents.list({lean:!0}),Se.tasks.list({search:J,pageSize:20}),Se.requirements.list(),Se.projects.list(),Se.deliverables.search({q:J,limit:20}),Se.teams.list()]),W=ee.status==="fulfilled"?ee.value.agents.filter(ze=>ze.name?.toLowerCase().includes(D)||ze.role?.toLowerCase().includes(D)):[],oe=R.status==="fulfilled"?R.value.tasks:[],L=te.status==="fulfilled"?te.value.requirements.filter(ze=>ze.title?.toLowerCase().includes(D)||ze.description?.toLowerCase().includes(D)):[],Ne=le.status==="fulfilled"?le.value.projects.filter(ze=>ze.name?.toLowerCase().includes(D)||ze.description?.toLowerCase().includes(D)):[],qe=ke.status==="fulfilled"?ke.value.results:[],me=[];if($.status==="fulfilled"){const ze=await Promise.allSettled($.value.teams.map(Ue=>Se.workflows.list(Ue.id)));for(const Ue of ze)if(Ue.status==="fulfilled")for(const je of Ue.value.workflows)(je.name.toLowerCase().includes(D)||(je.displayName||"").toLowerCase().includes(D)||je.description?.toLowerCase().includes(D))&&me.push(je)}m({agents:W,tasks:oe,requirements:L,projects:Ne,deliverables:qe,workflows:me})}catch{m(lm)}finally{g(!1)}},[]),B=J=>{i(J),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>I(J),400)},G=w.useCallback((J,D)=>{e(),yt.navigate(J,D)},[e]),j=[{id:"all",label:n("common:all",{defaultValue:"全部"})},{id:"agents",label:n("common:agents",{defaultValue:"智能体"})},{id:"tasks",label:n("common:tasks",{defaultValue:"任务"})},{id:"requirements",label:n("common:requirements",{defaultValue:"需求"})},{id:"projects",label:n("common:projects",{defaultValue:"项目"})},{id:"deliverables",label:n("common:deliverables",{defaultValue:"交付物"})},{id:"workflows",label:n("common:workflows",{defaultValue:"工作流"})}],O=w.useMemo(()=>nme[t||""]||ame,[t]),F=w.useMemo(()=>{const J=[],D=l==="all"?8:void 0,ee=R=>{if(l!=="all"&&l!==R)return;const te=u[R].length;if(R==="workflows"){const le=D?u.workflows.slice(0,D):u.workflows;for(const ke of le)J.push({id:ke.name,type:"workflow",page:ce.WORK,params:{boardType:"workflows"}})}else{const le=u[R],ke=D?le.slice(0,D):le;for(const $ of ke)switch(R){case"agents":J.push({id:$.id,type:"agent",page:ce.TEAM,params:{agentId:$.id}});break;case"tasks":J.push({id:$.id,type:"task",page:ce.WORK,params:{openTask:$.id}});break;case"requirements":J.push({id:$.id,type:"requirement",page:ce.WORK,params:{openRequirement:$.id}});break;case"projects":J.push({id:$.id,type:"project",page:ce.WORK,params:{projectId:$.id}});break;case"deliverables":J.push({id:$.id,type:"deliverable",page:ce.DELIVERABLES,params:{openDeliverable:$.id}});break}}D&&te>D&&J.push({id:`more_${R}`,type:"showMore",page:"",expandCategory:R,totalCount:te})};for(const R of O)ee(R);return J},[u,l,O]),Y=w.useCallback(J=>{if(J.type==="showMore"&&J.expandCategory){c(J.expandCategory),k(-1);return}G(J.page,J.params)},[G]);w.useEffect(()=>{const J=M.current;if(!J||y<0)return;const D=J.querySelector(`[data-idx="${y}"]`);D&&D.scrollIntoView({block:"nearest"})},[y]);const q=w.useCallback(J=>{if(J.key==="Escape"){e();return}if(J.key==="Tab"){J.preventDefault();const R=j.map(ke=>ke.id),te=R.indexOf(l),le=J.shiftKey?te<=0?R.length-1:te-1:te>=R.length-1?0:te+1;c(R[le]),k(-1);return}const D=J.ctrlKey&&J.key==="n"||J.key==="ArrowDown",ee=J.ctrlKey&&J.key==="p"||J.key==="ArrowUp";if(D||ee){J.preventDefault(),k(R=>{const te=F.length-1;return te<0?-1:D?R>=te?0:R+1:R<=0?te:R-1});return}J.key==="Enter"&&(J.preventDefault(),y>=0&&y<F.length&&Y(F[y]))},[e,F,y,Y,j,l]);w.useEffect(()=>(document.addEventListener("keydown",q),()=>document.removeEventListener("keydown",q)),[q]);const V=F.length>0;let z=0;return o.jsx("div",{ref:A,className:"fixed inset-0 bg-black/50 flex items-start justify-center z-50 pt-[8vh]",onClick:J=>{J.target===A.current&&e()},children:o.jsxs("div",{className:"bg-surface-primary border border-border-default rounded-2xl shadow-2xl w-full max-w-3xl max-h-[78vh] flex flex-col overflow-hidden animate-fadeIn",children:[o.jsxs("div",{className:"shrink-0 px-5 pt-4 pb-3 border-b border-border-default space-y-3",children:[o.jsxs("div",{className:"relative",children:[o.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-fg-tertiary",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("circle",{cx:"11",cy:"11",r:"8"}),o.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),o.jsx("input",{ref:C,value:a,onChange:J=>B(J.target.value),placeholder:n("common:search"),className:"w-full bg-surface-elevated border border-border-default rounded-xl pl-9 pr-9 py-2.5 text-sm text-fg-primary placeholder:text-fg-tertiary focus:border-brand-500 focus:outline-none transition-colors"}),a&&o.jsx("button",{onClick:()=>{i(""),m(lm),b(!1),k(-1),C.current?.focus()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-fg-tertiary hover:text-fg-secondary",children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:j.map(J=>o.jsx("button",{onClick:()=>{c(J.id),k(-1)},className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${l===J.id?"bg-brand-600 text-on-brand":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:J.label},J.id))})]}),o.jsxs("div",{ref:M,className:"flex-1 overflow-y-auto px-5 py-3",children:[f&&o.jsx("div",{className:"flex items-center justify-center py-8",children:o.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:n("common:loading")})}),!f&&h&&!V&&o.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[o.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-2",children:[o.jsx("circle",{cx:"11",cy:"11",r:"8"}),o.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),o.jsx("p",{className:"text-sm text-fg-tertiary",children:n("common:noResults",{defaultValue:"没有找到相关结果"})})]}),!f&&V&&o.jsx("div",{className:"space-y-4",children:O.map(J=>{if(l!=="all"&&l!==J)return null;const D=l==="all"?8:void 0,ee=R=>{const te=z++,le=R==="agents"?u.agents.length:R==="tasks"?u.tasks.length:R==="requirements"?u.requirements.length:R==="projects"?u.projects.length:R==="workflows"?u.workflows.length:u.deliverables.length;return o.jsxs("button",{"data-idx":te,onClick:()=>{c(R),k(-1)},className:`mt-1 w-full text-xs py-1.5 rounded-lg transition-colors ${te===y?"bg-brand-600/15 ring-1 ring-brand-500/40 text-brand-500":"text-brand-500 hover:text-brand-400 hover:bg-surface-overlay"}`,children:[n("common:showAll",{defaultValue:"查看全部"})," (",le,")"]})};return J==="agents"&&u.agents.length>0?o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:agents",{defaultValue:"智能体"})}),o.jsx("div",{className:"space-y-0.5",children:(D?u.agents.slice(0,D):u.agents).map(R=>{const te=z++;return o.jsxs("button",{"data-idx":te,onClick:()=>G(ce.TEAM,{agentId:R.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${te===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[o.jsx(Go,{name:R.name||"Agent",avatarUrl:R.avatarUrl,size:28}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:R.name}),o.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:R.role||R.status})]}),o.jsx(ime,{status:R.status})]},R.id)})}),D&&u.agents.length>D&&ee("agents")]},"agents"):J==="tasks"&&u.tasks.length>0?o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:tasks",{defaultValue:"任务"})}),o.jsx("div",{className:"space-y-0.5",children:(D?u.tasks.slice(0,D):u.tasks).map(R=>{const te=z++;return o.jsxs("button",{"data-idx":te,onClick:()=>G(ce.WORK,{openTask:R.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${te===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[o.jsx(sme,{status:R.status}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm text-fg-primary truncate",children:R.title}),o.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[R.status," · ",R.priority||""]})]})]},R.id)})}),D&&u.tasks.length>D&&ee("tasks")]},"tasks"):J==="requirements"&&u.requirements.length>0?o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:requirements",{defaultValue:"需求"})}),o.jsx("div",{className:"space-y-0.5",children:(D?u.requirements.slice(0,D):u.requirements).map(R=>{const te=z++;return o.jsxs("button",{"data-idx":te,onClick:()=>G(ce.WORK,{openRequirement:R.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${te===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[o.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${R.status==="approved"?"text-green-500 bg-green-500/15":R.status==="pending"?"text-amber-500 bg-amber-500/15":R.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),o.jsx("polyline",{points:"14 2 14 8 20 8"}),o.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),o.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm text-fg-primary truncate",children:R.title}),o.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[R.status," · ",R.priority||""]})]})]},R.id)})}),D&&u.requirements.length>D&&ee("requirements")]},"requirements"):J==="projects"&&u.projects.length>0?o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:projects",{defaultValue:"项目"})}),o.jsx("div",{className:"space-y-0.5",children:(D?u.projects.slice(0,D):u.projects).map(R=>{const te=z++;return o.jsxs("button",{"data-idx":te,onClick:()=>G(ce.WORK,{projectId:R.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${te===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[o.jsx("div",{className:"w-7 h-7 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:o.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:o.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm text-fg-primary truncate",children:R.name}),R.description&&o.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:R.description})]})]},R.id)})}),D&&u.projects.length>D&&ee("projects")]},"projects"):J==="deliverables"&&u.deliverables.length>0?o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:deliverables",{defaultValue:"交付物"})}),o.jsx("div",{className:"space-y-0.5",children:(D?u.deliverables.slice(0,D):u.deliverables).map(R=>{const te=z++;return o.jsxs("button",{"data-idx":te,onClick:()=>G(ce.DELIVERABLES,{openDeliverable:R.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${te===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[o.jsx("div",{className:"w-7 h-7 rounded-lg bg-purple-500/15 flex items-center justify-center shrink-0",children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-purple-500",children:[o.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),o.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm text-fg-primary truncate",children:R.title}),o.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[R.type," · ",R.status]})]})]},R.id)})}),D&&u.deliverables.length>D&&ee("deliverables")]},"deliverables"):J==="workflows"&&u.workflows.length>0?o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:workflows",{defaultValue:"工作流"})}),o.jsx("div",{className:"space-y-0.5",children:(D?u.workflows.slice(0,D):u.workflows).map(R=>{const te=z++;return o.jsxs("button",{"data-idx":te,onClick:()=>G(ce.WORK,{boardType:"workflows"}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${te===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[o.jsx("div",{className:"w-7 h-7 rounded-lg bg-teal-500/15 flex items-center justify-center shrink-0",children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-teal-500",children:[o.jsx("circle",{cx:"12",cy:"12",r:"3"}),o.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm text-fg-primary truncate",children:R.displayName||R.name}),o.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:n("searchResults.workflowMeta",{n:R.stepCount,version:R.version})})]})]},R.name)})}),D&&u.workflows.length>D&&ee("workflows")]},"workflows"):null})}),!f&&!h&&o.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[o.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-2",children:[o.jsx("circle",{cx:"11",cy:"11",r:"8"}),o.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),o.jsx("p",{className:"text-sm text-fg-tertiary",children:n("common:searchHint",{defaultValue:"输入关键词搜索"})})]})]}),o.jsxs("div",{className:"shrink-0 px-5 py-2 border-t border-border-default flex items-center gap-4 text-xs text-fg-tertiary flex-wrap",children:[o.jsxs("span",{children:[o.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:navigator.platform.toUpperCase().includes("MAC")?"Cmd+P":"Ctrl+P"})," ",n("common:toggle",{defaultValue:"唤起/关闭"})]}),o.jsxs("span",{children:[o.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Tab"})," ",n("common:switchTab",{defaultValue:"切换分类"})]}),o.jsxs("span",{children:[o.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"↑↓"})," ",n("common:navigate",{defaultValue:"导航"})]}),o.jsxs("span",{children:[o.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Enter"})," ",n("common:open",{defaultValue:"打开"})]}),o.jsxs("span",{children:[o.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Esc"})," ",n("common:close",{defaultValue:"关闭"})]})]})]})})}function ime({status:e}){const t=e==="active"||e==="idle"?"bg-green-500":e==="working"||e==="busy"?"bg-blue-500":"bg-gray-400";return o.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${t}`})}function sme({status:e}){const t=An[zc(e)].chip;return o.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${t}`,children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("path",{d:"M9 11l3 3L22 4"}),o.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})})}const ome=["layout","navigation","tasks","team","search","rightPanel","terminal","help"];function lme(e){return e===ce.TEAM?"team":e===ce.WORK?"work":e===ce.DELIVERABLES?"deliverables":e===ce.STORE?"store":"any"}function cme({open:e,onClose:t,page:n}){const{t:a}=ut("common"),i=typeof navigator<"u"&&navigator.platform.toUpperCase().includes("MAC"),l=lme(n);return w.useEffect(()=>{if(!e)return;const c=u=>{u.key==="Escape"&&(u.preventDefault(),u.stopPropagation(),t())};return window.addEventListener("keydown",c,!0),()=>window.removeEventListener("keydown",c,!0)},[e,t]),e?o.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/45 backdrop-blur-[1px] p-4",onMouseDown:c=>{c.target===c.currentTarget&&t()},role:"dialog","aria-modal":"true","aria-label":a("shortcuts.title"),children:o.jsxs("div",{className:"w-full max-w-lg max-h-[80vh] overflow-auto rounded-xl border border-border-default bg-surface-primary shadow-2xl",children:[o.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between gap-3 px-4 py-3 border-b border-border-default bg-surface-primary",children:[o.jsx("h2",{className:"text-sm font-semibold text-fg-primary",children:a("shortcuts.title")}),o.jsx("button",{type:"button",onClick:t,className:"w-7 h-7 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated","aria-label":a("shortcuts.close"),children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsx("div",{className:"px-4 py-3 space-y-4",children:ome.map(c=>{const u=$Q.filter(m=>{if(m.group!==c)return!1;const f=m.page??"any";return f==="any"?!0:f===l});return u.length===0?null:o.jsxs("section",{children:[o.jsx("h3",{className:"text-[11px] font-semibold uppercase tracking-wide text-fg-tertiary mb-2",children:a(`shortcuts.groups.${c}`)}),o.jsx("ul",{className:"space-y-1.5",children:u.map(m=>o.jsxs("li",{className:"flex items-center justify-between gap-3 text-sm",children:[o.jsx("span",{className:"text-fg-secondary min-w-0",children:a(m.labelKey??m.label,{defaultValue:m.label})}),o.jsx("kbd",{className:"shrink-0 px-2 py-1 rounded bg-surface-elevated border border-border-default text-[13px] font-medium leading-none text-fg-primary font-mono",children:jS(m.keys,i,m.bare)})]},m.id))})]},c)})})]})}):null}function dme({authUser:e,onClose:t,onSaved:n,onUserUpdated:a}){const{t:i}=ut("common");$s(!0);const[l,c]=w.useState(e.name||""),[u,m]=w.useState(e.email||""),[f,g]=w.useState(!1),[h,b]=w.useState(""),[y,k]=w.useState(()=>SS(e.avatarUrl,Oa()?.avatarUrl)),C=async T=>{if(T.preventDefault(),!l.trim()){b(i("profile.nameRequired"));return}if(u&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(u.trim())){b(i("profile.invalidEmail"));return}g(!0),b("");try{const{user:A}=await Se.auth.updateProfile(l.trim(),u.trim());n({...A,avatarUrl:y??A.avatarUrl})}catch{b(i("profile.failedToSave"))}finally{g(!1)}};return o.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10000]",onClick:t,children:o.jsxs("form",{onSubmit:C,className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[400px] max-w-[calc(100vw-2rem)] shadow-2xl",onClick:T=>T.stopPropagation(),children:[o.jsx("h3",{className:"text-base font-semibold mb-5",children:i("profile.editProfile")}),o.jsx("div",{className:"flex justify-center mb-5",children:o.jsx(AS,{currentUrl:y,name:l,size:72,targetType:"user",targetId:e.id,onUploaded:T=>{k(T),a?.({...e,avatarUrl:T})}})}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:i("profile.name")}),o.jsx("input",{value:l,onChange:T=>c(T.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:i("profile.email")}),o.jsx("input",{value:u,onChange:T=>m(T.target.value),type:"email",className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none"})]}),h&&o.jsx("div",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:h})]}),o.jsxs("div",{className:"flex justify-end gap-3 mt-5",children:[o.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:i("cancel")}),o.jsx("button",{type:"submit",disabled:f,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-on-brand rounded-lg",children:i(f?"saving":"save")})]})]})})}const pA="markus_lan_notice_acked";let S4=null;function fA(){try{const t=globalThis.localStorage;if(t&&typeof t.getItem=="function"&&typeof t.setItem=="function"&&typeof t.removeItem=="function")return t}catch{}S4??=new Map;const e=S4;return{getItem:t=>e.get(t)??null,setItem:(t,n)=>{e.set(t,n)},removeItem:t=>{e.delete(t)}}}function ume(e){return fA().getItem(pA)===e}function mme(e){fA().setItem(pA,e)}function pme(e,t){return e&&!ume(t)}const C4=w.lazy(()=>fa(()=>import("./Team-Dfz_Jkoy.js"),__vite__mapDeps([2,3,4,5,6,7,8,9,10])).then(e=>({default:e.TeamPage}))),A4=w.lazy(()=>fa(()=>import("./Settings-B05tnigv.js"),__vite__mapDeps([11,6,7])).then(e=>({default:e.Settings}))),fme=w.lazy(()=>fa(()=>import("./Store-B4hpcTFJ.js"),[]).then(e=>({default:e.StorePage}))),hme=w.lazy(()=>fa(()=>Promise.resolve().then(()=>fue),void 0).then(e=>({default:e.AgentBuilder}))),T4=w.lazy(()=>fa(()=>import("./Work-DqxE8g_Q.js"),__vite__mapDeps([12,4,3,5,13,6,8,1,14,15])).then(e=>({default:e.WorkPage}))),E4=w.lazy(()=>fa(()=>import("./Deliverables-oCzunom7.js"),__vite__mapDeps([16,3,8,9,13,5])).then(e=>({default:e.DeliverablesPage}))),gme=w.lazy(()=>fa(()=>import("./Search-Badheo3V.js"),__vite__mapDeps([17,6])).then(e=>({default:e.SearchPage}))),N4=w.lazy(()=>fa(()=>Promise.resolve().then(()=>XJ),void 0).then(e=>({default:e.default}))),bme={display:"none"};function yme(e){try{const t=navigator.language,n=Intl.DateTimeFormat().resolvedOptions().timeZone,a=e.preferences??{};if(a.locale===t&&a.timezone===n)return;Se.auth.updatePreferences({locale:t,timezone:n}).catch(()=>{})}catch{}}function vme({docScroll:e}={}){const{t}=ut("common");return o.jsx("div",{className:`flex-1 flex items-center justify-center text-fg-tertiary text-sm animate-pulse ${e?"min-h-[50dvh]":""}`,children:t("loading")})}function xme({error:e,onRetry:t,docScroll:n}){const{t:a}=ut("common");return o.jsx("div",{className:`flex-1 flex items-center justify-center p-8 ${n?"min-h-[50dvh]":""}`,children:o.jsxs("div",{className:"max-w-md w-full text-center space-y-3",children:[o.jsx("h3",{className:"text-sm font-medium text-fg-primary",children:a("pageErrorTitle")}),o.jsx("p",{className:"text-xs text-fg-tertiary leading-relaxed",children:a("pageErrorHint")}),o.jsx("pre",{className:"text-[11px] text-left whitespace-pre-wrap break-words bg-surface-elevated rounded-lg p-3 text-fg-secondary max-h-40 overflow-auto",children:e.message}),o.jsx("button",{type:"button",onClick:t,className:"px-3 py-1.5 text-[11px] bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg font-medium",children:a("pageErrorRetry")})]})})}const wme=w.memo(function({id:t,activePage:n,docScroll:a,children:i}){const l=t===n,c=w.useRef(null),u=w.useRef(l);return w.useEffect(()=>{l&&!u.current&&c.current&&c.current.dispatchEvent(new CustomEvent("markus:page-shown",{bubbles:!0})),u.current=l},[l]),o.jsx("div",{ref:c,"data-page-slot":!0,"data-page-active":l?"true":"false",className:a?"block overflow-hidden":"flex-1 overflow-hidden flex flex-col",style:l?void 0:bme,children:o.jsx(w.Suspense,{fallback:o.jsx(vme,{docScroll:a}),children:o.jsx(ZJ,{resetKeys:[t,l],fallback:(m,f)=>o.jsx(xme,{error:m,onRetry:f,docScroll:a}),children:i})})})},(e,t)=>{if(e.docScroll!==t.docScroll)return!1;const n=e.id===e.activePage,a=t.id===t.activePage;return n!==a?!1:a?e.children===t.children:!0}),Fu={};function hA(e){return typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches?W4[e]??e:e}function M4(){return hA(Ec())}function kme(){const{t:e}=ut("common"),[t,n]=w.useState(M4),[a,i]=w.useState(!1),[l,c]=w.useState(!0),u=Xo(),m=w.useSyncExternalStore(eme,tme,()=>!1),f=u&&!(t===ce.TEAM&&m),g=w.useSyncExternalStore(QW,Z4,JW),h=u&&t!==ce.SETTINGS&&t!==ce.SEARCH&&X4(g,t);w.useEffect(()=>{const Ee=document.documentElement;return Ee.classList.toggle("mobile-doc-scroll",f),()=>{Ee.classList.remove("mobile-doc-scroll")}},[f]),w.useLayoutEffect(()=>{f&&window.scrollTo(0,0)},[t,f]);const b=Zue(),y=Jue({side:"left",defaultWidth:160,minWidth:140,maxWidth:400,collapsedWidth:64,storageKey:"markus_sidebar"}),[k,C]=w.useState(()=>new Set([M4()])),[T,A]=w.useState("loading"),[M,I]=w.useState(!1),[B,G]=w.useState(null),[j,O]=w.useState({hasOwner:!1,hasMultipleUsers:!1}),[F,Y]=w.useState(!1),[q,V]=w.useState(!1),[z,J]=w.useState(null),[D,ee]=w.useState(!1),[R,te]=w.useState(null),[le,ke]=w.useState(!1),[$,W]=w.useState(null),[oe,L]=w.useState(()=>{const Ee=localStorage.getItem("markus_update_dismissed");return Ee||null}),[Ne,qe]=w.useState(!1),[me,ze]=w.useState(!1),Ue=kp(),je=Ue?.leftCollapsed??!1,Ye=Ue?.toggleLeftCollapsed,xt=Ue?.setLeftCollapsed,mt=Ue?.keyboardPane??"l0",ft=Ue?.setKeyboardPane,rt=Ue?.l0FocusPageId??null,jt=Ue?.setL0FocusPageId,ht=w.useRef(t);ht.current=t;const He=w.useRef(ce.HOME),Et=Ue?.toggleRightPanel,Kt=Ue?.toggleTerminalPanel,ie=Ue?.cycleRightPanelTab,tt=Ue?.activateRightPanelTabAt,it=Ue?.openNewRightPanelTab,xe=Ue?.rightPanelOpen??!1,Me=Ue?.activeRightPanelTabId??null,Ie=Ue?.openRightPanel,ne=Ue?.closeRightPanelTab,U=Ue?.updateRightPanelBrowserTab,re=Ue?.updateRightPanelTerminalTab,Ce=w.useRef(Ue?.rightPanelTabs);Ce.current=Ue?.rightPanelTabs,w.useEffect(()=>{const Ee=window.markusDesktop?.browser?.onPageEvent;if(!(!Ee||!Ie))return Ee(_e=>{if(_e.type==="closed"){const De=Ce.current?.find(Q=>Q.payload.kind==="url"&&Q.payload.browserId===_e.browserId);De&&ne&&ne(De.id);return}if(_e.type==="navigated"){if(_e.url&&Nc(_e.url))return;_e.browserId&&U&&U(_e.browserId,{url:_e.url,title:_e.title||_e.url});return}if(_e.type==="opened"||_e.type==="selected"){if(!_e.url&&!_e.browserId||_e.browserId.startsWith("eb_")||jce(_e.browserId)||_e.url&&Nc(_e.url))return;Ie({kind:"url",url:_e.url||"about:blank",title:_e.title||_e.url||"Browser",browserId:_e.browserId,pageId:_e.pageId})}})},[Ie,ne,U]),w.useEffect(()=>{const Ee=window.markusDesktop?.terminal?.onEvent;if(!(!Ee||!Ie))return Ee(_e=>{if(_e.type==="closed"){const De=Ce.current?.find(Q=>Q.payload.kind==="terminal"&&Q.payload.terminalId===_e.id);De&&ne&&ne(De.id);return}if(_e.type==="cwd"){_e.cwd&&re?.(_e.id,{cwd:_e.cwd});return}if(_e.type==="selected"){(_e.title||_e.cwd)&&re?.(_e.id,{title:_e.title,cwd:_e.cwd});return}if(_e.type==="opened"){if(Gb.has(_e.id)){(_e.title||_e.cwd)&&re?.(_e.id,{title:_e.title,cwd:_e.cwd});return}_s(_e.id),Ie({kind:"terminal",terminalId:_e.id,title:_e.title||"Terminal",cwd:_e.cwd})}})},[Ie,ne,re]);const Pe=Ue?.handleTerminalExit;w.useEffect(()=>{const Ee=window.markusDesktop?.terminal?.onExit;if(!(!Ee||!Pe))return Ee(_e=>{Pe(_e.id)})},[Pe]),w.useLayoutEffect(()=>{const Ee=t===ce.TEAM&&xe&&Ue?.rightPanelMode==="browser";Oh(Ee)},[t,xe,Ue?.rightPanelMode]),w.useEffect(()=>{window.markusDesktop?.browser?.hideAll?.()},[]);const $e=w.useRef(!1);w.useEffect(()=>{if(!$e.current){$e.current=!0;return}y.setCollapsed(je)},[je,y.setCollapsed]),w.useEffect(()=>{if(u)return;const Ee=navigator.platform.toUpperCase().includes("MAC"),_e=Q=>{Ee&&Q.metaKey&&!Q.ctrlKey&&Q.key==="p"?(Q.preventDefault(),qe(be=>!be)):!Ee&&Q.ctrlKey&&!Q.metaKey&&Q.key==="p"&&(Q.preventDefault(),qe(be=>!be))},De=()=>qe(!0);return document.addEventListener("keydown",_e),window.addEventListener("markus:open-search",De),()=>{document.removeEventListener("keydown",_e),window.removeEventListener("markus:open-search",De)}},[u]);const ue=w.useCallback(()=>!xe||!Me||!ne?!1:(ne(Me),!0),[xe,Me,ne]);w.useEffect(()=>{const Ee=window.markusDesktop?.onAppShortcut?.(_e=>{if(_e.type==="close-tab"){ue();return}_e.type==="new-tab"&&it?.()});return()=>{Ee?.()}},[ue,it]),w.useEffect(()=>{if(u||!Ye||!Et)return;const Ee=navigator.platform.toUpperCase().includes("MAC"),_e=De=>{if(!(Ee?De.metaKey&&!De.ctrlKey:De.ctrlKey&&!De.metaKey)||De.altKey)return;if(!De.shiftKey&&(De.key==="/"||De.code==="Slash")){De.preventDefault(),ze(Te=>!Te);return}if(De.shiftKey&&(De.key==="?"||De.key==="/")){De.preventDefault(),ze(Te=>!Te);return}if(De.shiftKey&&xe&&ie){if(De.key==="]"||De.code==="BracketRight"){De.preventDefault(),ie(1);return}if(De.key==="["||De.code==="BracketLeft"){De.preventDefault(),ie(-1);return}}if(!De.shiftKey&&xe&&tt){const Te=De.key>="1"&&De.key<="9"?Number(De.key):0;if(Te>=1){De.preventDefault(),tt(Te-1);return}}if(De.shiftKey)return;const be=De.key.toLowerCase();if(be==="w"){De.preventDefault(),De.stopPropagation(),ue();return}if(be==="t"){De.preventDefault(),it?.();return}if(be==="b"){if(t===ce.DELIVERABLES)return;De.preventDefault(),Ye()}else if(t===ce.TEAM&&be==="l"){if(!Ee&&T2(De.target)||Ee&&T2(De.target)&&De.ctrlKey)return;De.preventDefault(),Et()}else t===ce.TEAM&&be==="j"&&Kt&&(De.preventDefault(),Kt())};return document.addEventListener("keydown",_e,!0),()=>document.removeEventListener("keydown",_e,!0)},[u,t,Ye,Et,Kt,ie,tt,xe,ue,it]);const he=w.useCallback((Ee,_e)=>{let De=Tc(Ee);u&&(De=W4[De]??De),De!==ce.TEAM&&Oh(!1);const Q=Ec(),be=window.location.hash.slice(1);be!==V0(Q)?Fu[Q]=be:delete Fu[Q];const Te=ht.current;if(De===ce.SETTINGS&&Te!==ce.SETTINGS&&(He.current=Te,yt.setSettingsReturnPage(Te),ft?.("l1"),jt?.(ce.SETTINGS)),Te===ce.SETTINGS&&De!==ce.SETTINGS&&(ft?.("l0"),jt?.(De)),De===ce.SETTINGS&&_e?.tab){const wt=`settings/${_e.tab}`;Fu[De]=wt,history.pushState(null,"","#"+wt),window.dispatchEvent(new HashChangeEvent("hashchange")),n(De),C(Ht=>Ht.has(De)?Ht:new Set([...Ht,De]));return}const Xe=De!==ce.WORK?Fu[De]:void 0;Xe&&Xe!==V0(De)?(history.pushState(null,"",Hs(De)),history.pushState(null,"","#"+Xe)):history.pushState(null,"",Hs(De)),window.dispatchEvent(new HashChangeEvent("hashchange")),n(De),C(wt=>wt.has(De)?wt:new Set([...wt,De]))},[u,ft,jt]);w.useEffect(()=>{yt.setHandler((Ee,_e)=>he(Ee,_e))},[he]);const Ve=w.useCallback(Ee=>{const _e=ht.current,De=nY(_e,eY(_e),Ee);De&&(De.sub&&sY(De.page,De.sub),he(De.page))},[he]);mY({enabled:u,activePage:()=>ht.current,onStep:Ve}),w.useEffect(()=>{mt==="l0"&&t!==ce.SETTINGS&&jt?.(t)},[mt,t,jt]),w.useEffect(()=>{if(u||!ft||!jt)return;const Ee=_e=>{if(_e.metaKey||_e.ctrlKey||_e.altKey||A2(_e.target))return;const De=_e.key.length===1?_e.key.toLowerCase():_e.key;if(t===ce.SETTINGS&&(De==="h"||De==="ArrowLeft")){_e.preventDefault(),_e.stopImmediatePropagation(),yt.leaveSettings();return}if(mt!=="l0"||t===ce.SETTINGS)return;const Q=rt&&Mo.includes(rt)?rt:t,be=Math.max(0,Mo.indexOf(Q));if(De==="j"||De==="ArrowDown"){_e.preventDefault(),_e.stopImmediatePropagation();const Te=Mo[Math.min(Mo.length-1,be+1)];jt(Te),Te!==t&&he(Te),requestAnimationFrame(()=>{document.querySelector(`[data-l0-page-id="${Te}"]`)?.scrollIntoView({block:"nearest"})});return}if(De==="k"||De==="ArrowUp"){_e.preventDefault(),_e.stopImmediatePropagation();const Te=Mo[Math.max(0,be-1)];jt(Te),Te!==t&&he(Te),requestAnimationFrame(()=>{document.querySelector(`[data-l0-page-id="${Te}"]`)?.scrollIntoView({block:"nearest"})});return}if(De==="l"||De==="ArrowRight"||De==="Enter"){const Te=rt&&Mo.includes(rt)?rt:t;if(!GW.has(Te)){_e.preventDefault(),_e.stopImmediatePropagation();return}_e.preventDefault(),_e.stopImmediatePropagation(),Te!==t&&he(Te),xt?.(!1),ft("l1");return}(De==="h"||De==="ArrowLeft")&&(_e.preventDefault(),_e.stopImmediatePropagation())};return document.addEventListener("keydown",Ee,!0),()=>document.removeEventListener("keydown",Ee,!0)},[u,mt,rt,t,he,ft,jt,xt]),w.useEffect(()=>{const Ee=()=>I(!0);return window.addEventListener("markus:open-edit-profile",Ee),()=>window.removeEventListener("markus:open-edit-profile",Ee)},[]),w.useEffect(()=>{if(!window.markusDesktop)return;!u&&t!==ce.SETTINGS&&!y.collapsed?window.markusDesktop.setTrafficLightPosition(16,16):window.markusDesktop.setTrafficLightPosition(6,16)},[y.collapsed,t,u]),w.useEffect(()=>{window.markusDesktop&&window.markusDesktop.onNotificationClick(Ee=>{if(Ee.page){const _e=Tc(Ee.page);Ee.params&&Object.entries(Ee.params).forEach(([De,Q])=>localStorage.setItem(`markus_nav_${De}`,Q)),he(_e),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:_e,params:Ee.params}}));return}Ee.openNotifications&&(pY(),he(ce.HOME))})},[he]);const dt=w.useCallback(()=>{Que().then(Ee=>{if(Ee?.providers){const _e=Object.values(Ee.providers).some(De=>De.configured);J(_e)}}).catch(()=>{})},[]),Je=w.useCallback((Ee,_e)=>{if(!Ee)return;const Q=_e&&{agent:"agents",team:"teams",skill:"skills"}[_e]||"agents";localStorage.setItem("markus_nav_installItem",Ee),localStorage.setItem("markus_nav_storeTab",Q);const be=new URLSearchParams(window.location.search);be.get("install")||(be.set("install",Ee),_e&&be.set("type",_e));const Te=be.toString();window.history.replaceState(null,"",`${window.location.pathname}?${Te}${Hs(ce.STORE)}`);const Xe=()=>yt.navigate(ce.STORE,{storeTab:Q,installItem:Ee});Xe(),setTimeout(Xe,500),setTimeout(Xe,1500)},[]);w.useEffect(()=>{const Ee=()=>A(null);return window.addEventListener(X0,Ee),()=>window.removeEventListener(X0,Ee)},[]),w.useEffect(()=>{const Ee=new URLSearchParams(window.location.search),_e=Ee.get("install");_e&&Je(_e,Ee.get("type"));const De=window.markusDesktop;De?.onDeepLinkInstall?.(({id:Te,type:Xe})=>Je(Te,Xe)),De?.consumePendingDeepLinkInstall?.().then(Te=>{Te?.id&&Je(Te.id,Te.type)}),Se.auth.me().then(({user:Te})=>{p2(),A(Te),G(!0),i(!1),Te.preferences?.guideHidden===!0&&!lg(Te.id)&&cg(Te.id),yme(Te),di.connect(Te.id),dt(),Se.health().then(wt=>{wt.updateAvailable&&wt.latestVersion&&W({latestVersion:wt.latestVersion,currentVersion:wt.version});const Ht=wt.bindHost??"0.0.0.0";pme(wt.lanExposed===!0,Ht)&&te({host:Ht})}).catch(()=>{});const Xe=()=>{As(La.builderArtifacts,()=>Se.builder.artifacts.list()),As(La.builderAgents,()=>Se.agents.list()),As(La.builderHubMyItems,()=>at.myItems()),As(La.builderInstalled,()=>Se.builder.artifacts.installed()),As(La.hubAgents,()=>at.search({type:"agent",limit:50})),As(La.hubTeams,()=>at.search({type:"team",limit:50})),As(La.hubSkills,()=>at.search({type:"skill",limit:50}))};typeof requestIdleCallback=="function"?requestIdleCallback(Xe,{timeout:5e3}):setTimeout(Xe,3e3)}).catch(()=>{A(null),Se.auth.status().then(({initialized:Te,hasOwner:Xe,hasMultipleUsers:wt})=>{G(Te),O({hasOwner:Xe,hasMultipleUsers:wt})}).catch(()=>G(!0))}),di.connect();const Q=di.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),be=()=>{const Te=hA(Ec());Te!==ce.TEAM&&Oh(!1),n(Te),C(Xe=>Xe.has(Te)?Xe:new Set([...Xe,Te]))};return window.addEventListener("hashchange",be),window.addEventListener("popstate",be),()=>{Q(),di.disconnect(),window.removeEventListener("hashchange",be),window.removeEventListener("popstate",be)}},[]),w.useEffect(()=>{const Ee=T!=="loading"&&T!==null?T.id:void 0;if(!Ee)return;const _e=navigator.platform.toUpperCase().includes("MAC"),De=Q=>{if(A2(Q.target))return;const be={key:Q.key,code:Q.code,metaKey:Q.metaKey,ctrlKey:Q.ctrlKey,altKey:Q.altKey,shiftKey:Q.shiftKey};zQ(be,Ee,_e)&&window.dispatchEvent(new CustomEvent("markus:shortcut-lesson-complete"))};return window.addEventListener("keydown",De,!0),()=>window.removeEventListener("keydown",De,!0)},[T]);const ot=T!=="loading"&&T!==null?T:void 0;mQ(ot?.id),NQ(!!ot);const Ft=w.useMemo(()=>u?{[ce.HOME]:o.jsx(U2,{authUser:ot}),[ce.TEAM]:o.jsx(C4,{authUser:ot}),[ce.BUILDER]:o.jsx(que,{authUser:ot}),[ce.SETTINGS]:o.jsx(A4,{theme:b.mode,onThemeChange:b.setMode,authUser:ot,onLogout:()=>{Se.auth.logout().catch(()=>{}),Is(),A(null)},onUserUpdated:Ee=>A(Ee)}),[ce.WORK]:o.jsx(T4,{authUser:ot}),[ce.DELIVERABLES]:o.jsx(E4,{authUser:ot}),[ce.SEARCH]:o.jsx(gme,{}),...Am(ot?.role)?{[ce.AUDIT]:o.jsx(N4,{role:ot?.role,authUser:ot})}:{}}:{[ce.HOME]:o.jsx(U2,{authUser:ot}),[ce.TEAM]:o.jsx(C4,{authUser:ot}),[ce.SETTINGS]:o.jsx(A4,{theme:b.mode,onThemeChange:b.setMode,authUser:ot,onLogout:()=>{Se.auth.logout().catch(()=>{}),Is(),A(null)},onUserUpdated:Ee=>A(Ee)}),[ce.STORE]:o.jsx(fme,{authUser:ot}),[ce.BUILDER]:o.jsx(hme,{authUser:ot}),[ce.WORK]:o.jsx(T4,{authUser:ot}),[ce.DELIVERABLES]:o.jsx(E4,{authUser:ot}),...Am(ot?.role)?{[ce.AUDIT]:o.jsx(N4,{role:ot?.role,authUser:ot})}:{}},[ot?.id,ot?.role,b.mode,u]);if(T==="loading"||T===null&&B===null)return o.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center",children:o.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:e("loading")})});const Ot=(typeof window<"u"?window.location.hash:"").match(/^#invite\?token=([a-f0-9]+)/);return Ot?o.jsx(Vue,{token:Ot[1],onComplete:()=>{window.location.hash="",localStorage.removeItem("markus_onboarded"),i(!0),Y(!0),A("loading"),Se.auth.me().then(Ee=>{B2(Ee.user.id),A(Ee.user)}).catch(()=>A(null))}}):T===null?o.jsx(Kue,{hasOwner:j.hasOwner,hasMultipleUsers:j.hasMultipleUsers,onLogin:(Ee,_e,De)=>{p2(),A(Ee),di.connect(Ee.id),_e?(B2(Ee.id),i(!0),De?.fromHub&&Y(!0)):(i(!1),lg(Ee.id)?(cg(Ee.id),Se.auth.updatePreferences({guideHidden:!0}).catch(()=>{}),A({...Ee,preferences:{...Ee.preferences,guideHidden:!0}})):A(Ee))}}):q?o.jsx(Wue,{onComplete:()=>V(!1),isFirstTime:!0}):a?o.jsx(Uue,{theme:b.mode,onThemeChange:b.setMode,skipProfile:F,onProfileUpdated:Ee=>{const _e={id:Ee.id,name:Ee.name,email:Ee.email,role:Ee.role,orgId:Ee.orgId??"default",avatarUrl:Ee.avatarUrl};A(_e)},onComplete:()=>{localStorage.removeItem("markus_onboarded"),i(!1),Y(!1),Se.auth.me().then(Ee=>A(Ee.user)).catch(()=>{}),dt(),he(ce.HOME)}}):o.jsxs("div",{className:`flex ${f?"min-h-dvh":"h-dvh overflow-x-hidden"} bg-surface-primary text-fg-primary ${u?"flex-col":""}`,children:[!u&&t!==ce.SETTINGS&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"relative z-40 shrink-0",style:{width:y.width},children:o.jsx(dX,{currentPage:t,onNavigate:Ee=>{he(Ee),c(!1),ft?.("l0"),jt?.(Ee)},authUser:T,collapsed:y.collapsed,onToggleCollapse:y.toggle,onLogout:()=>{Se.auth.logout().catch(()=>{}),Is(),A(null)},keyboardFocusPageId:rt,keyboardPaneActive:mt==="l0"})}),o.jsx("div",{className:`${y.collapsed?"w-0":"w-1.5 cursor-col-resize"} shrink-0 group relative z-10 flex items-center justify-center`,onMouseDown:y.collapsed?void 0:y.onResizeStart,children:!y.collapsed&&o.jsx("div",{className:"w-px h-2/3 border-l border-dashed border-transparent group-hover:border-border-default group-active:border-fg-tertiary transition-colors"})})]}),o.jsxs("div",{className:`flex-1 ${f?"":"overflow-hidden"} flex flex-col min-w-0 ${h?"pb-14":""}`,children:[z===!1&&!D&&t!==ce.SETTINGS&&o.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-amber-500/10 border-b border-amber-500/30 text-amber-600 text-sm shrink-0",children:[o.jsx("span",{className:u?"text-xs":"",children:e("llmBanner.message")}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("button",{onClick:()=>{window.location.hash="#settings/providers"},className:"px-3 py-1 bg-amber-700/50 hover:bg-amber-700/70 text-white text-xs rounded-lg transition-colors",children:e("llmBanner.goToSettings")}),o.jsx("button",{onClick:()=>ee(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:e("dismiss")})]})]}),!mA()&&$&&oe!==$.latestVersion&&o.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-brand-500/10 border-b border-brand-500/30 text-brand-400 text-sm shrink-0",children:[o.jsx("span",{className:u?"text-xs":"",children:e("update.available",{latest:$.latestVersion,current:$.currentVersion})}),o.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[o.jsx("a",{href:"https://markus.global/#download",target:"_blank",rel:"noopener noreferrer",className:"text-xs font-medium text-brand-400 hover:text-brand-300 transition-colors",children:e("update.download")}),o.jsx("button",{onClick:()=>{L($.latestVersion),localStorage.setItem("markus_update_dismissed",$.latestVersion)},className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]}),o.jsx(Fue,{}),R&&!le&&t!==ce.SETTINGS&&o.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-emerald-500/10 border-b border-emerald-500/25 text-emerald-600 dark:text-emerald-400 text-sm shrink-0",children:[o.jsx("span",{className:u?"text-xs":"",children:e("lanNotice.message",{host:R.host})}),o.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[o.jsx("button",{onClick:()=>{window.location.hash="#settings/network"},className:"text-xs font-medium text-emerald-600 dark:text-emerald-400 hover:text-emerald-500 transition-colors",children:e("lanNotice.goToSettings")}),o.jsx("button",{onClick:()=>{mme(R.host),ke(!0)},className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]}),o.jsx("main",{className:`flex-1 ${f?"":"overflow-hidden"} flex flex-col relative`,children:Object.keys(Ft).map(Ee=>k.has(Ee)?o.jsx(wme,{id:Ee,activePage:t,docScroll:f,children:Ft[Ee]},Ee):null)})]}),h&&o.jsx(AX,{currentPage:t,onNavigate:he}),u&&o.jsx(OQ,{authUser:ot,onNavigate:he,onLogout:()=>{Se.auth.logout().catch(()=>{}),Is(),A(null)}}),!u&&Ne&&o.jsx(rme,{onClose:()=>qe(!1),currentPage:t}),!u&&o.jsx(cme,{open:me,onClose:()=>ze(!1),page:t}),o.jsx(xde,{}),M&&ot&&o.jsx(dme,{authUser:ot,onClose:()=>I(!1),onUserUpdated:Ee=>A(Ee),onSaved:Ee=>{I(!1),A(Ee)}})]})}const j4="data-anim-paused",Sme="data-anim-tick",R4=8,Cme=250,gA=["animate-spin","animate-bounce","activity-text-shimmer","exec-card-active"];gA.map(e=>`.${e}`).join(", ");function Ame(){return document.visibilityState!=="visible"||document.hidden}let Sc=null,uc=0;function Tme(){Sc===null&&(uc=uc%R4,_4(),Sc=window.setInterval(()=>{uc=(uc+1)%R4,_4()},Cme))}function _4(){const e=String(uc);for(const t of gA){const n=document.getElementsByClassName(t);for(let a=0;a<n.length;a++)n[a].setAttribute(Sme,e)}}function Eme(){Sc!==null&&(window.clearInterval(Sc),Sc=null)}function $0(){const e=document.documentElement;Ame()?(e.setAttribute(j4,"true"),Eme()):(e.removeAttribute(j4),Tme())}let D4=!1;function Nme(){D4||typeof document>"u"||(D4=!0,$0(),document.addEventListener("visibilitychange",$0,{passive:!0}),window.addEventListener("pageshow",$0,{passive:!0}))}Nme();E6.createRoot(document.getElementById("root")).render(o.jsx(w.StrictMode,{children:o.jsx(Pce,{children:o.jsx(kme,{})})}));export{tn as $,Go as A,Xle as B,One as C,rce as D,ZJ as E,lpe as F,ope as G,dpe as H,Lue as I,upe as J,cpe as K,uce as L,Dne as M,tA as N,xpe as O,ce as P,Jue as Q,c2 as R,Due as S,kue as T,di as U,Tn as V,Tc as W,ES as X,Jce as Y,Zce as Z,fa as _,Xo as a,xm as a$,Ia as a0,Jo as a1,Mme as a2,Bc as a3,mpe as a4,Or as a5,LS as a6,xr as a7,sX as a8,Gme as a9,cA as aA,JJ as aB,hue as aC,$s as aD,Lr as aE,vE as aF,Yme as aG,Ace as aH,zg as aI,VW as aJ,ppe as aK,bpe as aL,fpe as aM,ype as aN,vpe as aO,gpe as aP,hpe as aQ,_me as aR,Dme as aS,_s as aT,Lu as aU,Qb as aV,Cce as aW,FC as aX,qu as aY,o4 as aZ,kpe as a_,Oa as aa,Fme as ab,qme as ac,tS as ad,Ome as ae,Ume as af,EY as ag,$me as ah,m2 as ai,Hme as aj,CY as ak,zme as al,Bme as am,Rc as an,Xme as ao,wQ as ap,gQ as aq,Zme as ar,bQ as as,Jme as at,gue as au,bue as av,Ko as aw,Que as ax,Cpe as ay,Rme as az,jQ as b,ape as b0,sg as b1,wce as b2,Uk as b3,npe as b4,Kme as b5,Vme as b6,Pme as b7,Spe as b8,Ape as b9,xX as ba,rpe as bb,RY as bc,Wme as bd,AS as be,jS as bf,eJ as bg,epe as bh,VC as bi,T2 as bj,Qme as bk,Qm as bl,wE as bm,jme as bn,Ime as bo,Lme as bp,Hs as bq,$Y as br,mJ as bs,tpe as bt,nS as bu,sJ as bv,spe as bw,kp as c,Hue as d,Aue as e,jue as f,Ps as g,at as h,A2 as i,o as j,Se as k,An as l,$k as m,yt as n,Yde as o,ace as p,boe as q,w as r,Kle as s,zc as t,ut as u,Ure as v,Ose as w,zse as x,wpe as y,_C as z};
|
|
867
|
+
${t("share.rejectedEncourage")}`})},className:"text-xs px-2 py-1.5 rounded-lg border border-red-500/30 text-red-400 hover:bg-red-500/10 transition-colors inline-flex items-center gap-1 cursor-pointer",title:t("share.rejectedTip"),children:[o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),o.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),t("share.rejected")]}),o.jsxs("button",{onClick:()=>{rt(ie,{visibility:Ie?.visibility??"public"})},disabled:!!Me,className:"text-xs px-3 py-1.5 rounded-lg border border-brand-500/40 text-brand-400 hover:bg-brand-500/10 hover:border-brand-500/60 transition-colors disabled:opacity-50 inline-flex items-center gap-1",title:t("share.rejectedTip"),children:[o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("polyline",{points:"23 4 23 10 17 10"}),o.jsx("polyline",{points:"1 20 1 14 7 14"}),o.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]}),t(Me==="share"?"common:sharing":"share.resubmit")]})]}):U?o.jsxs(o.Fragment,{children:[re&&o.jsxs("button",{onClick:()=>{const Je=Ie?.visibility??"public";rt(ie,{visibility:Je})},disabled:!!Me,className:"text-xs px-3 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 hover:bg-amber-500/10 hover:border-amber-500/50 transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:[o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("polyline",{points:"23 4 23 10 17 10"}),o.jsx("polyline",{points:"1 20 1 14 7 14"}),o.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]}),Me==="share"?t("common:sharing"):t("share.updateVersion",{version:ne})]}),o.jsxs("a",{href:Ce()??"#",target:"_blank",rel:"noopener noreferrer",onClick:Je=>{const ot=Ce();Ko()&&ot&&(Je.preventDefault(),Or(ot))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1 ${Ie?.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/40":Ie?.visibility==="unlisted"?"border-gray-500/30 text-fg-tertiary hover:text-fg-secondary hover:border-gray-400/40":"border-green-600/30 text-green-600 hover:text-green-500 hover:border-green-500/40"}`,children:[Ie?.visibility==="org"?o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M3 21h18"}),o.jsx("path",{d:"M9 8h1"}),o.jsx("path",{d:"M9 12h1"}),o.jsx("path",{d:"M9 16h1"}),o.jsx("path",{d:"M14 8h1"}),o.jsx("path",{d:"M14 12h1"}),o.jsx("path",{d:"M14 16h1"}),o.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}):Ie?.visibility==="unlisted"?o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),o.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}):o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),o.jsx("polyline",{points:"15 3 21 3 21 9"}),o.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),Ie?.visibility==="org"?t("visibility.sharedOrg"):Ie?.visibility==="unlisted"?t("visibility.sharedUnlisted"):t("visibility.shared")]}),o.jsxs("button",{onClick:()=>Y({key:xe,name:tt}),disabled:!!Me,className:"text-xs px-2.5 py-1.5 rounded-lg border border-border-default text-fg-secondary hover:text-amber-500 hover:border-amber-500/40 hover:bg-amber-500/10 transition-colors disabled:opacity-50 inline-flex items-center gap-1",title:t("removeFromHubTooltip"),children:[o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),o.jsx("path",{d:"M5.17 11.75l-1.71 1.71a5 5 0 0 0 7.07 7.07l1.71-1.71"}),o.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"})]}),t("unshare")]})]}):o.jsxs("button",{onClick:async()=>{await at.ensureAuth(),Array.isArray(ie.meta.screenshots)&&ie.meta.screenshots.length>0?te(ie):J(ie)},disabled:!!Me,className:"text-xs px-3 py-1.5 rounded-lg border border-border-default text-fg-secondary hover:text-green-600 hover:border-green-500/30 transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:[o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("circle",{cx:"18",cy:"5",r:"3"}),o.jsx("circle",{cx:"6",cy:"12",r:"3"}),o.jsx("circle",{cx:"18",cy:"19",r:"3"}),o.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),o.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),t(Me==="share"?"common:sharing":"common:share")]})]}),ue=o.jsx("button",{onClick:()=>A(ie),disabled:!!Me,className:"w-7 h-7 rounded-lg text-fg-muted hover:text-red-500 hover:bg-red-500/10 transition-colors disabled:opacity-50 inline-flex items-center justify-center",title:t("deleteLocalTooltip"),children:o.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("polyline",{points:"3 6 5 6 21 6"}),o.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})}),he=ie.meta.icon,dt=!!he&&/\.(png|jpe?g|gif|webp|svg)$/i.test(he)?he.startsWith("http")||he.startsWith("/")?he:`/api/builder/artifacts/${ie.type}s/${encodeURIComponent(ie.name)}/images/${encodeURIComponent(he.split("/").pop()??"")}?v=${ie.updatedAt??""}`:he;return o.jsx(mr,{type:ie.type,name:tt,description:it,seed:xe,icon:dt,version:ne,footerLeft:o.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary min-w-0",children:[o.jsx("button",{onClick:Je=>{Je.stopPropagation(),Se.system.openPath(ie.path).catch(()=>{})},className:"hover:text-fg-secondary transition-colors truncate min-w-0",title:ie.path,children:lue(ie.path)}),o.jsx("span",{className:"shrink-0",children:"·"}),o.jsx("span",{className:"shrink-0",children:new Date(ie.updatedAt).toLocaleDateString()})]}),headerAction:ue,actions:$e,onClick:()=>Kt(ie)},xe)})})),M&&o.jsx(xr,{variant:"primary",title:t("confirmInstall"),message:t("confirmInstallMsg",{name:M.meta.displayName||M.meta.name||M.name}),confirmLabel:t("common:install"),onConfirm:()=>{const ie=M;I(null),mt(ie)},onCancel:()=>I(null)}),B&&o.jsx(xr,{variant:"primary",title:t("confirmUninstall"),message:t("confirmUninstallMsg",{name:B.meta.displayName||B.meta.name||B.name}),confirmLabel:t("common:uninstall"),onConfirm:()=>{const ie=B;G(null),ft(ie)},onCancel:()=>G(null)}),T&&o.jsx(xr,{title:t("confirmDeleteLocal"),message:t("deleteCannotUndo",{name:T.meta.displayName||T.meta.name||T.name}),confirmLabel:t("common:delete"),onConfirm:ht,onCancel:()=>A(null)}),F&&o.jsx(xr,{title:t("confirmUnshare"),message:t("removeFromHub",{name:F.name}),confirmLabel:t("unshare"),onConfirm:()=>{jt()},onCancel:()=>Y(null)}),q&&o.jsx(xr,{alertOnly:!0,variant:q.variant??"primary",title:q.title,message:q.message,onConfirm:()=>V(null),onCancel:()=>V(null)}),z&&o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>J(null),children:o.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ie=>ie.stopPropagation(),children:[o.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-2",children:t("common:share")}),o.jsx("p",{className:"text-sm text-fg-secondary mb-5",children:t("share.imagePrompt")}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx("button",{onClick:()=>{const ie=z;J(null),te(ie)},className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-fg-tertiary transition-colors",children:t("share.directly")}),o.jsx("button",{onClick:()=>{const ie=z;J(null),Kt(ie)},className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand transition-colors",children:t("share.addImagesFirst")})]})]})}),D&&o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>ee(null),children:o.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ie=>ie.stopPropagation(),children:o.jsx(pue,{isUpdate:j.has(`${D.type}/${D.name}`),onCancel:()=>ee(null),onConfirm:(ie,tt)=>{const it=D;ee(null),rt(it,{priceCents:tt>0?tt:void 0})}})})}),R&&o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>te(null),children:o.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ie=>ie.stopPropagation(),children:o.jsx(mue,{onCancel:()=>te(null),onConfirm:(ie,tt,it,xe)=>{const Me=R;te(null),rt(Me,{visibility:ie,orgId:tt,priceCents:it,donationsEnabled:xe})}})})})]})})}function mue({onCancel:e,onConfirm:t}){const{t:n}=ut(["builder","common"]),[a,i]=w.useState("public"),[l,c]=w.useState([]),[u,m]=w.useState(""),[f,g]=w.useState(!1),[h,b]=w.useState(0),[y,k]=w.useState(!1);w.useEffect(()=>{a==="org"&&l.length===0&&(g(!0),at.myOrgs().then(A=>{c(A.memberships),A.memberships.length>0&&m(A.memberships[0].id)}).catch(()=>{}).finally(()=>g(!1)))},[a,l.length]);const C=a==="public"||a==="unlisted",T=[{value:"public",icon:o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),o.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),label:n("visibility.public"),desc:n("visibility.publicDesc")},{value:"org",icon:o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M3 21h18"}),o.jsx("path",{d:"M9 8h1"}),o.jsx("path",{d:"M9 12h1"}),o.jsx("path",{d:"M9 16h1"}),o.jsx("path",{d:"M14 8h1"}),o.jsx("path",{d:"M14 12h1"}),o.jsx("path",{d:"M14 16h1"}),o.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}),label:n("visibility.org"),desc:n("visibility.orgDesc")},{value:"unlisted",icon:o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),o.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}),label:n("visibility.unlisted"),desc:n("visibility.unlistedDesc")}];return o.jsxs(o.Fragment,{children:[o.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:n("visibility.label")}),o.jsx("div",{className:"space-y-2 mb-5",children:T.map(A=>o.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${a===A.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[o.jsx("input",{type:"radio",name:"visibility",checked:a===A.value,onChange:()=>i(A.value),className:"accent-brand-500"}),o.jsx("div",{className:"flex items-center gap-2 text-fg-secondary",children:A.icon}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium text-fg-primary",children:A.label}),o.jsx("div",{className:"text-[11px] text-fg-tertiary",children:A.desc})]})]},A.value))}),a==="org"&&o.jsxs("div",{className:"mb-5",children:[o.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("visibility.orgSelect")}),f?o.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:n("common:loading")}):l.length===0?o.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:n("visibility.orgNone")}):o.jsx("select",{value:u,onChange:A=>m(A.target.value),className:"w-full text-sm px-3 py-2 rounded-lg bg-surface-elevated border border-border-default text-fg-primary",children:l.map(A=>o.jsx("option",{value:A.id,children:A.name},A.id))})]}),C&&o.jsxs("div",{className:"mb-5",children:[o.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("pricing.label")}),o.jsx("div",{className:"grid grid-cols-4 gap-2 mb-3",children:sA.map(A=>o.jsx("button",{type:"button",onClick:()=>b(A.cents),className:`text-sm px-2 py-2 rounded-lg border transition-colors ${h===A.cents?"border-brand-500 bg-brand-500/10 text-fg-primary":"border-border-default text-fg-secondary hover:border-gray-600"}`,children:A.label},A.cents))}),o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:y,onChange:A=>k(A.target.checked),className:"accent-brand-500"}),o.jsx("span",{className:"text-xs text-fg-secondary",children:n("pricing.enableTips")})]})]}),C&&o.jsx("div",{className:"mb-4 text-[11px] text-fg-tertiary rounded-lg border border-border-default px-3 py-2",children:n("pricing.reviewNote")}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx("button",{onClick:e,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:n("common:cancel")}),o.jsx("button",{onClick:()=>t(a,a==="org"?u:void 0,C&&h>0?h:void 0,C?y:void 0),disabled:a==="org"&&!u,className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n("shareMode.share")})]})]})}const sA=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function pue({isUpdate:e,onCancel:t,onConfirm:n}){const{t:a}=ut(["builder","common"]),[i,l]=w.useState(0);return o.jsxs(o.Fragment,{children:[o.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:a(e?"shareMode.titleUpdate":"shareMode.title")}),o.jsx("div",{className:"space-y-2 mb-5",children:sA.map(c=>o.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${i===c.cents?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[o.jsx("input",{type:"radio",name:"sharePrice",checked:i===c.cents,onChange:()=>l(c.cents),className:"accent-brand-500"}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium text-fg-primary",children:c.label}),o.jsx("div",{className:"text-[11px] text-fg-tertiary",children:c.cents===0?a("shareMode.freeDesc"):a("shareMode.paidDesc")})]})]},c.cents))}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx("button",{onClick:t,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:a("common:cancel")}),o.jsx("button",{onClick:()=>n(i>0?"paid":"free",i),className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand transition-colors",children:a(e?"shareMode.update":"shareMode.share")})]})]})}const fue=Object.freeze(Object.defineProperty({__proto__:null,AgentBuilder:iA},Symbol.toStringTag,{value:"Module"}));function oA(e){const t=e.filter(Boolean);if(t.length===0)return"";try{return new Intl.ListFormat(tn.language,{style:"short",type:"unit"}).format(t)}catch{return t.join(", ")}}function hue(e,t=tn.t("common:readFailed")){return e instanceof Error&&e.message?e.message:(typeof e=="string"?e:"")||t}function qu(){return{state:"loading",items:[],error:null}}function gue(e){return{state:"ok",items:e,error:null}}function bue(e,t=[]){return{state:"error",items:t,error:hue(e)}}async function o4(e,t={}){try{return gue(await e())}catch(n){return bue(n,t.keep??[])}}function kpe(e){const t=e.state==="loading",n=e.state==="error";return{loading:t,error:n,rows:e.items,empty:!t&&!n&&e.items.length===0}}function yue(e){const t=[];let n=!1,a=!1;for(const l of e)l.state==="loading"?n=!0:l.state==="error"?t.push(l.label):a=!0;return{state:n?"loading":t.length>0?"error":"ok",loading:n,failures:t,anyOk:a}}async function vue(e,t){if(!t)return{items:e,highlighted:null,missing:!1};const n=e.find(a=>a.id===t);if(n)return{items:[n,...e.filter(a=>a.id!==t)],highlighted:n,missing:!1};try{const{item:a}=await at.getItem(t);return a?{items:[a,...e],highlighted:a,missing:!1}:{items:e,highlighted:null,missing:!0}}catch{return{items:e,highlighted:null,missing:!0}}}function lA(e){const{catalogType:t,search:n,highlightItemId:a,onHighlightDone:i,loadTemplates:l,takeHubPrefetch:c}=e,[u,m]=w.useState(qu()),[f,g]=w.useState(qu()),[h,b]=w.useState(0),y=w.useRef({highlightItemId:a,onHighlightDone:i,loadTemplates:l,takeHubPrefetch:c});y.current={highlightItemId:a,onHighlightDone:i,loadTemplates:l,takeHubPrefetch:c},w.useEffect(()=>{let T=!1;return m(qu()),g(qu()),(async()=>{const A=(async()=>{const G=await o4(async()=>{const O=n?null:await y.current.takeHubPrefetch?.()??null;return O||((await at.search({type:t,q:n,limit:50})).items??[])});if(G.state!=="ok")return G;const j=await vue([...G.items],y.current.highlightItemId??null);return j.missing&&y.current.onHighlightDone?.(),{state:"ok",items:j.items,error:null}})(),M=o4(()=>y.current.loadTemplates(n)),[I,B]=await Promise.all([A,M]);T||(m(I),g(B))})(),()=>{T=!0}},[t,n,h]);const k=w.useCallback(()=>b(T=>T+1),[]),C=yue([{label:tn.t("store:catalog.hubAssets"),state:u.state},{label:tn.t("store:catalog.localTemplates"),state:f.state}]);return{hub:u,templates:f,sources:C,reload:k}}function cA({subject:e,error:t,notEquals:n,onRetry:a,retryLabel:i,hint:l,variant:c="bar"}){const{t:u}=ut("common"),m=o.jsx("span",{className:c==="inline"?"text-[11px] text-rose-500":"text-xs text-rose-500",children:u("readErrorNotice",{subject:e,error:t,notEquals:n})}),f=a?o.jsx("button",{type:"button",onClick:a,className:"text-xs text-brand-500 hover:text-brand-400 shrink-0 cursor-pointer",children:i??u("retry")}):l?o.jsx("span",{className:"text-xs text-fg-tertiary shrink-0",children:l}):null;return c==="inline"?o.jsxs("div",{className:"flex items-center gap-2 px-2 py-1",role:"alert",children:[m,f]}):o.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2 border-b border-rose-500/30 bg-rose-500/10 shrink-0",role:"alert",children:[m,f]})}function xue(e,t){const n=e.split(".").map(Number),a=t.split(".").map(Number);for(let i=0;i<Math.max(n.length,a.length);i++){const l=n[i]??0,c=a[i]??0;if(l>c)return!0;if(l<c)return!1}return!1}function Ym(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function l4(e,t){return e.i18n?.[t]?.description||e.description}const wue={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function kue({authUser:e,highlightItemId:t,onHighlightDone:n}={}){const{t:a,i18n:i}=ut(["store","common"]),l=i.language,[c,u]=w.useState(""),m=lA({catalogType:"agent",search:c,highlightItemId:t,onHighlightDone:n,loadTemplates:w.useCallback(async z=>{const J=new URLSearchParams;z&&J.set("q",z);const D=await fetch("/api/templates?"+J.toString(),{credentials:"include"});if(!D.ok)throw new Error(`HTTP ${D.status}`);const ee=await D.json();return Array.isArray(ee.templates)?ee.templates:[]},[]),takeHubPrefetch:async()=>(await Ls(La.hubAgents))?.items??null}),f=m.templates.items,g=m.hub.items,h=m.sources.loading,[b,y]=w.useState(null),[k,C]=w.useState({}),[T,A]=w.useState(!1),[M,I]=w.useState(new Map),[B,G]=w.useState(new Set),[j,O]=w.useState(null),[F,Y]=w.useState(null),q=w.useCallback(async()=>{try{const[z,J]=await Promise.all([Se.builder.artifacts.list().catch(()=>({artifacts:[]})),Se.builder.artifacts.installed().catch(()=>({installed:{}}))]),D=new Map;for(const ee of z.artifacts){if(ee.type!=="agent")continue;const R=!!J.installed[`agent/${ee.name}`];D.set(ee.name,{installed:R,localVersion:ee.meta.version||void 0,localUpdatedAt:ee.updatedAt})}I(D)}catch{}},[]);w.useEffect(()=>{q(),at.isAuthenticated()&&at.purchases.mine().then(z=>G(new Set(z.purchases.map(J=>J.itemId)))).catch(()=>{})},[q]),w.useEffect(()=>{if(!b){C({});return}fetch(`/api/templates/${encodeURIComponent(b.id)}/files`,{credentials:"include"}).then(z=>z.json()).then(z=>C(z.files??{})).catch(()=>C({}))},[b]);const V=async(z,J,D)=>{try{const ee=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:z,name:J,orgId:"default",teamId:D})});if(!ee.ok)throw new Error(`Failed: ${ee.status}`);A(!1),y(null)}catch(ee){Y({title:a("common:create",{defaultValue:"Create"}),message:`Failed to create agent: ${ee}`,variant:"danger"})}};if(j)return o.jsx(qs,{type:j.type,name:j.name,onBack:()=>O(null)});if(b){const z={type:"agent",name:b.id,displayName:Ym(b,l),version:b.version,description:l4(b,l),author:b.author,category:b.category,tags:b.tags,icon:b.icon,files:k,agent:{roleName:b.roleId,agentRole:b.agentRole==="manager"?"manager":"worker"},dependencies:{skills:b.skills}},J=o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[o.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:a("agentStore.roleConfig")}),o.jsxs("div",{className:"space-y-2.5 text-sm",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-fg-tertiary w-20",children:a("agentStore.role")}),o.jsx("span",{className:"text-fg-secondary font-mono text-xs bg-surface-elevated px-2 py-0.5 rounded",children:b.roleId})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-fg-tertiary w-20",children:a("agentStore.position")}),o.jsx("span",{className:`px-2 py-0.5 rounded text-xs capitalize ${wue[b.agentRole]??""}`,children:b.agentRole})]})]})]}),o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[o.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:a("agentStore.skills")}),o.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[b.skills.map(D=>o.jsx("span",{className:"px-2.5 py-1 text-xs bg-brand-500/10 text-brand-500 rounded-lg border border-brand-500/20",children:D},D)),b.skills.length===0&&o.jsx("span",{className:"text-xs text-fg-tertiary italic",children:a("agentStore.noSkills")})]})]})]}),b.starterTasks&&b.starterTasks.length>0&&o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[o.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:a("agentStore.starterTasks")}),o.jsx("div",{className:"space-y-2",children:b.starterTasks.map((D,ee)=>o.jsxs("div",{className:"flex items-start gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[o.jsx("span",{className:`inline-block w-2 h-2 rounded-full shrink-0 mt-1 ${D.priority==="high"?"bg-red-400":D.priority==="medium"?"bg-amber-400":"bg-green-400"}`}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm text-fg-primary",children:D.title}),D.description&&o.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:D.description})]})]},ee))})]})]});return o.jsxs(o.Fragment,{children:[o.jsx(qs,{type:"agent",name:b.id,onBack:()=>y(null),readOnly:!0,initialManifest:z,actionSlot:o.jsx("button",{onClick:()=>A(!0),className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg transition-colors font-medium",children:a("agentStore.hireAgent")}),contentSlot:J}),T&&o.jsx(c4,{template:b,lang:l,onClose:()=>A(!1),onHire:V}),F&&o.jsx(xr,{alertOnly:!0,variant:F.variant??"danger",title:F.title,message:F.message,onConfirm:()=>Y(null),onCancel:()=>Y(null)})]})}return o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[o.jsxs("div",{"data-electron-drag":!0,className:"px-6 h-14 flex items-center justify-between shrink-0 gap-3",children:[o.jsx("h2",{className:"text-lg font-semibold",children:a("agentStore.title")}),o.jsx("input",{type:"text",placeholder:a("agentStore.searchPlaceholder"),value:c,onChange:z=>u(z.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm max-w-xs w-full focus:border-brand-500 focus:outline-none"})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:[m.sources.failures.length>0&&o.jsx(cA,{subject:oA(m.sources.failures),error:m.hub.error??m.templates.error??a("common:readFailed"),notEquals:a("store:templates.nothingHere"),onRetry:m.reload}),h?o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((z,J)=>o.jsx("div",{className:"h-56 rounded-2xl skeleton"},J))}):m.sources.failures.length===0&&f.length===0&&g.length===0?o.jsxs("div",{className:"text-center py-20",children:[o.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),o.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:c?a("agentStore.noResults",{search:c}):a("agentStore.noAgents")}),o.jsx("div",{className:"text-fg-tertiary text-sm",children:a(c?"agentStore.noResultsHint":"agentStore.noAgentsHint")})]}):o.jsxs(o.Fragment,{children:[f.length>0&&o.jsxs("section",{children:[o.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[o.jsx("h3",{className:"section-title",children:a("agentStore.builtin")}),o.jsx("span",{className:"text-xs text-fg-tertiary",children:a("agentStore.available",{count:f.length})})]}),o.jsx(Ha,{columns:3,children:f.map(z=>o.jsx(mr,{type:"agent",name:Ym(z,l),description:l4(z,l),seed:z.id,icon:z.icon,version:z.version,category:z.category,tags:z.tags,authorLabel:z.author,hideStats:!0,showTypeBadge:!1,cornerLabel:a("agentStore.builtin"),onClick:()=>y(z)},z.id))})]}),g.length>0&&o.jsxs("section",{children:[o.jsx("h3",{className:"section-title mb-3",children:a("agentStore.markusHub")}),o.jsx(Ha,{columns:3,children:g.map(z=>o.jsx(Sue,{item:z,localInfo:M.get(Vc(z)),purchased:bm(z,B),onStatusChange:q,highlight:z.id===t,onHighlightDone:n,onViewDetail:J=>O({type:"agent",name:J})},z.id))})]})]})]}),T&&b&&o.jsx(c4,{template:b,lang:l,onClose:()=>A(!1),onHire:V}),F&&o.jsx(xr,{alertOnly:!0,variant:F.variant??"danger",title:F.title,message:F.message,onConfirm:()=>Y(null),onCancel:()=>Y(null)})]})}function Vc(e,t){if(e.slug&&e.slug.trim())return e.slug.trim();const n=t&&typeof t.name=="string"?t.name.trim():"";return xm(n||e.name,"hub-pkg")}function Ps(e){return(async()=>{const t=await at.download(e.id),n=t.name||e.name,a=t.config??{},i=Vc(e,a),l=t.itemType==="team"?"team":t.itemType==="skill"?"skill":"agent",c={type:"hub",hubItemId:e.id},u=(t.version||e.version||(typeof a.version=="string"?a.version:"")||"").trim()||void 0;if(t.files&&Object.keys(t.files).length>0)await Se.builder.artifacts.import(l,i,t.files,c,u);else{const m={...a,...u?{version:u}:{},name:i,displayName:a.displayName||n,description:e.description,source:c};await Se.builder.artifacts.save(l,m)}return await Se.builder.artifacts.install(l,i),window.dispatchEvent(new CustomEvent("markus:data-changed")),n})()}async function Xb(e,t){t("checking"),await at.ensureAuth();const n=await at.purchases.checkout(e.id);if(n.alreadyOwned)return t("installing"),await Ps(e),"installed";try{if((await at.creator.getBalance()).availableBalance>=(e.priceCents??0)){const c=await at.purchases.payWithEarnings(e.id);if(c.ok||c.alreadyOwned)return t("installing"),await Ps(e),"installed"}}catch{}if(!n.checkoutUrl)throw new Error("No checkout URL");t("checkout_opened");const a=Ko();let i=null;return a?Or(n.checkoutUrl):i=window.open(n.checkoutUrl,"_blank","noopener"),new Promise((l,c)=>{const u=Date.now(),m=300*1e3,f=setInterval(async()=>{if(Date.now()-u>m){clearInterval(f),l("cancelled");return}const h=!a&&i?i.closed:!1;try{if((await at.purchases.checkout(e.id)).alreadyOwned){clearInterval(f),t("installing");try{await Ps(e),l("installed")}catch(y){c(y)}return}}catch{}if(h){clearInterval(f);try{if((await at.purchases.checkout(e.id)).alreadyOwned){t("installing"),await Ps(e),l("installed");return}}catch{}l("cancelled")}},2e3)})}function Sue({item:e,localInfo:t,purchased:n,onStatusChange:a,highlight:i,onHighlightDone:l,onViewDetail:c}){const{t:u}=ut(["store"]),[m,f]=w.useState(!1),[g,h]=w.useState(""),b=w.useRef(null),[y,k]=w.useState(!1);w.useEffect(()=>{if(i&&b.current){b.current.scrollIntoView({behavior:"smooth",block:"center"}),k(!0);const F=setTimeout(()=>{k(!1)},4e3);return()=>clearTimeout(F)}},[i,l]);const C=t?.installed??!1,T=C&&e.version&&t?.localVersion&&xue(e.version,t.localVersion),A=(e.priceCents??0)>0,M=async F=>{if(F.stopPropagation(),!m){f(!0),h("");try{await Ps(e),h(T?u("card.upgraded"):u("card.installed")+"!"),a()}catch(Y){const q=Y instanceof Error?Y.message:"";q.includes("402")||q.includes("Purchase required")?h(u("card.purchaseRequired")):h(u("card.failed"))}finally{f(!1)}}},I=async F=>{if(F.stopPropagation(),!m){f(!0),h("");try{await Xb(e,q=>{q==="checkout_opened"?h(u("card.waitingPurchase","Waiting for purchase...")):q==="installing"&&h(u("card.installing"))})==="installed"?(h(u("card.installed")+"!"),a()):h("")}catch(Y){h(Y instanceof Error?Y.message:u("card.failed"))}finally{f(!1)}}},B=A?`$${((e.priceCents??0)/100).toFixed(2)}`:null,G=e.slug&&e.author?.username?`${at.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,j=()=>{C&&c?c(Vc(e)):G&&window.open(G,"_blank","noopener,noreferrer")},O=o.jsxs(o.Fragment,{children:[T?o.jsx("button",{onClick:F=>{M(F)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:m?u("card.upgrading"):u("card.upgrade",{version:e.version})}):C?o.jsxs("button",{onClick:F=>{M(F)},disabled:m,className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default rounded-lg transition-colors disabled:opacity-50",children:[u("card.installed"),t?.localVersion?` v${t.localVersion}`:""]}):A&&!n?o.jsx("button",{onClick:F=>{I(F)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:m?g||u("card.installing"):o.jsxs(o.Fragment,{children:[u("card.buy","Buy")," ",B]})}):o.jsx("button",{onClick:F=>{M(F)},disabled:m,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg transition-colors disabled:opacity-50",children:u(m?"card.installing":"card.install")}),g&&!(A&&!n)&&o.jsx("span",{className:`text-[10px] ${g===u("card.failed")||g===u("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:g})]});return o.jsx("div",{ref:b,className:y?"animate-pulse":"",children:o.jsx(mr,{type:"agent",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"bot",cover:e.thumbnailUrl,hubBase:at.getUrl(),author:e.author,version:e.version,category:e.category,tags:e.tags,rating:parseFloat(e.avgRating)||0,ratingCount:e.ratingCount,downloadCount:e.downloadCount,priceCents:e.priceCents,currency:e.currency,installed:C,glowing:y,onClick:j,actions:O})})}function c4({template:e,lang:t,onClose:n,onHire:a}){const{t:i}=ut(["store"]),[l,c]=w.useState(`${Ym(e,t)} Agent`),[u,m]=w.useState(""),[f,g]=w.useState([]),[h,b]=w.useState(!1);w.useEffect(()=>{fetch("/api/teams",{credentials:"include"}).then(k=>k.json()).then(k=>g(k.teams??[])).catch(()=>{})},[]);const y=async()=>{if(l.trim()){b(!0);try{await a(e.id,l.trim(),u||void 0)}finally{b(!1)}}};return o.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:n,children:o.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[440px] shadow-2xl",onClick:k=>k.stopPropagation(),children:[o.jsx("div",{className:"flex items-center gap-3 mb-5",children:o.jsxs("div",{children:[o.jsx("h3",{className:"text-base font-semibold",children:i("hireModal.title")}),o.jsx("p",{className:"text-xs text-fg-tertiary",children:i("hireModal.creating",{name:Ym(e,t)})})]})}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:i("hireModal.agentName")}),o.jsx("input",{type:"text",value:l,onChange:k=>c(k.target.value),className:"input-field",autoFocus:!0})]}),f.length>0&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:i("hireModal.assignTeam")}),o.jsxs("select",{value:u,onChange:k=>m(k.target.value),className:"input-field",children:[o.jsx("option",{value:"",children:i("hireModal.noTeam")}),f.map(k=>o.jsx("option",{value:k.id,children:k.name},k.id))]})]}),o.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg p-3",children:[o.jsx("div",{className:"text-xs text-fg-tertiary mb-2 font-medium",children:i("hireModal.agentConfig")}),o.jsxs("div",{className:"grid grid-cols-2 gap-y-1.5 gap-x-4 text-xs",children:[o.jsx("div",{className:"text-fg-tertiary",children:i("hireModal.role")}),o.jsx("div",{className:"text-fg-secondary font-mono",children:e.roleId}),o.jsx("div",{className:"text-fg-tertiary",children:i("hireModal.position")}),o.jsx("div",{className:"text-fg-secondary capitalize",children:e.agentRole}),o.jsx("div",{className:"text-fg-tertiary",children:i("hireModal.skills")}),o.jsx("div",{className:"text-fg-secondary",children:e.skills.join(", ")||i("hireModal.none")})]})]})]}),o.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[o.jsx("button",{onClick:n,className:"btn-secondary",children:i("hireModal.cancel")}),o.jsx("button",{onClick:y,disabled:!l.trim()||h,className:"btn-primary",children:i(h?"hireModal.creating_progress":"hireModal.create")})]})]})})}function O0(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function d4(e,t){return e.i18n?.[t]?.description||e.description}function u4(e,t,n){return e.i18n?.[n]?.members?.[t]||t}function Cue(e,t){const n=e.split(".").map(Number),a=t.split(".").map(Number);for(let i=0;i<Math.max(n.length,a.length);i++){const l=n[i]??0,c=a[i]??0;if(l>c)return!0;if(l<c)return!1}return!1}function Aue({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:a}=ut(["store","common"]),i=a.language,[l,c]=w.useState(""),u=lA({catalogType:"team",search:l,highlightItemId:e,onHighlightDone:t,loadTemplates:w.useCallback(V=>Se.teamTemplates.list(V||void 0).then(z=>z.templates??[]),[]),takeHubPrefetch:async()=>(await Ls(La.hubTeams))?.items??null}),m=u.templates.items,f=u.hub.items,g=u.sources.loading,[h,b]=w.useState(null),[y,k]=w.useState({}),[C,T]=w.useState(!1),[A,M]=w.useState(null),[I,B]=w.useState(new Map),[G,j]=w.useState(new Set),[O,F]=w.useState(null),Y=w.useCallback(async()=>{try{const[V,z]=await Promise.all([Se.builder.artifacts.list().catch(()=>({artifacts:[]})),Se.builder.artifacts.installed().catch(()=>({installed:{}}))]),J=new Map;for(const D of V.artifacts){if(D.type!=="team")continue;const ee=!!z.installed[`team/${D.name}`];J.set(D.name,{installed:ee,localVersion:D.meta.version||void 0,localUpdatedAt:D.updatedAt})}B(J)}catch{}},[]);w.useEffect(()=>{Y(),at.isAuthenticated()&&at.purchases.mine().then(V=>j(new Set(V.purchases.map(z=>z.itemId)))).catch(()=>{})},[Y]),w.useEffect(()=>{if(!h){k({});return}fetch(`/api/team-templates/${encodeURIComponent(h.id)}/files`,{credentials:"include"}).then(V=>V.json()).then(V=>k(V.files??{})).catch(()=>k({}))},[h]);const q=async V=>{T(!0),M(null);try{const J=(await Se.teams.create(V.name,V.description)).team.id;let D,ee=0;const R=[];for(const le of V.members){const ke=le.count??1;for(let $=0;$<ke;$++){const W=le.name??`${V.name} Agent ${$+1}`,oe=ke>1?`${W} ${$+1}`:W,L=le.roleName??le.templateId;try{const Ne=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:oe,...L?{roleName:L}:{},orgId:"default",teamId:J,agentRole:le.role??"worker",skills:le.skills??[]})});if(Ne.ok){ee++;const qe=await Ne.json();le.role==="manager"&&!D&&(D=qe.agent?.id)}else{const qe=await Ne.json().catch(()=>({error:`HTTP ${Ne.status}`}));R.push(`${oe}: ${qe.error??Ne.statusText}`)}}catch(Ne){R.push(`${oe}: ${String(Ne)}`)}}}D&&await Se.teams.update(J,{managerId:D,managerType:"agent"}).catch(()=>{});const te=R.length>0?` (${R.length} failed: ${R[0]})`:"";M({ok:ee>0,message:`Team "${O0(V,i)}" deployed with ${ee} agent(s)${te}`})}catch(z){M({ok:!1,message:`Failed: ${z}`})}finally{T(!1)}};if(O)return o.jsx(qs,{type:O.type,name:O.name,onBack:()=>F(null)});if(h){const V={...y};h.announcements&&(V["ANNOUNCEMENT.md"]=h.announcements),h.norms&&(V["NORMS.md"]=h.norms);const z={type:"team",name:h.id,displayName:O0(h,i),version:h.version,description:d4(h,i),author:h.author,category:h.category??"general",tags:h.tags??[],files:V,team:{members:h.members.map(D=>({name:u4(h,D.name??D.roleName??D.templateId??"Agent",i),role:D.role??"worker",roleName:D.roleName??D.templateId,count:D.count??1,skills:D.skills??[]}))}},J=o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[o.jsx("div",{className:"px-5 py-3 border-b border-border-default bg-surface-elevated/30",children:o.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider",children:n("teamStore.teamComposition")})}),o.jsx("div",{className:"p-5 space-y-2",children:h.members.map((D,ee)=>{const R=u4(h,D.name??D.roleName??D.templateId??"Agent",i);return o.jsxs("div",{className:"flex items-center gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[o.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center text-sm font-bold shrink-0 ${D.role==="manager"?"bg-amber-500/15 text-amber-400 ring-1 ring-amber-500/30":"bg-blue-500/15 text-blue-400 ring-1 ring-blue-500/30"}`,children:(R[0]??"?").toUpperCase()}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-sm text-fg-primary font-medium",children:R}),o.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] capitalize font-medium ${D.role==="manager"?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:D.role??"worker"}),(D.count??1)>1&&o.jsxs("span",{className:"text-[10px] text-fg-muted",children:["×",D.count]})]}),(D.roleName||D.templateId)&&o.jsx("div",{className:"text-[10px] text-fg-tertiary font-mono mt-0.5",children:D.roleName??D.templateId})]}),D.skills&&D.skills.length>0&&o.jsxs("div",{className:"flex flex-wrap gap-1 shrink-0",children:[D.skills.slice(0,3).map(te=>o.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-surface-elevated text-fg-muted rounded border border-border-default",children:te},te)),D.skills.length>3&&o.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",D.skills.length-3]})]})]},ee)})})]});return o.jsx(o.Fragment,{children:o.jsx(qs,{type:"team",name:h.id,onBack:()=>{b(null),M(null)},readOnly:!0,initialManifest:z,contentSlot:J,actionSlot:o.jsxs(o.Fragment,{children:[A&&o.jsx("span",{className:`text-xs ${A.ok?"text-green-500":"text-red-500"}`,children:A.message}),o.jsx("button",{onClick:()=>{q(h)},disabled:C,className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg transition-colors font-medium disabled:opacity-50",children:n(C?"teamStore.deploying":"teamStore.deployTeam")})]})})})}return o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[o.jsxs("div",{"data-electron-drag":!0,className:"px-6 h-14 flex items-center justify-between shrink-0 gap-3",children:[o.jsx("h2",{className:"text-lg font-semibold",children:n("teamStore.title")}),o.jsx("input",{type:"text",placeholder:n("teamStore.searchPlaceholder"),value:l,onChange:V=>c(V.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm max-w-xs w-full focus:border-brand-500 focus:outline-none"})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:[u.sources.failures.length>0&&o.jsx(cA,{subject:oA(u.sources.failures),error:u.hub.error??u.templates.error??n("common:readFailed"),notEquals:n("store:teamsStore.nothingHere"),onRetry:u.reload}),g?o.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:Array.from({length:4}).map((V,z)=>o.jsx("div",{className:"h-56 rounded-2xl skeleton"},z))}):u.sources.failures.length===0&&m.length===0&&f.length===0?o.jsxs("div",{className:"text-center py-20",children:[o.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"◉"}),o.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:l?n("teamStore.noResults",{search:l}):n("teamStore.noTeams")}),o.jsx("div",{className:"text-fg-tertiary text-sm",children:n(l?"teamStore.noResultsHint":"teamStore.noTeamsHint")})]}):o.jsxs(o.Fragment,{children:[m.length>0&&o.jsxs("section",{children:[o.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[o.jsx("h3",{className:"section-title",children:n("teamStore.builtin")}),o.jsx("span",{className:"text-xs text-fg-tertiary",children:n("teamStore.available",{count:m.length})})]}),o.jsx(Ha,{columns:2,children:m.map(V=>o.jsx(mr,{type:"team",name:O0(V,i),description:d4(V,i),seed:V.id,icon:V.icon||"users",version:V.version,category:V.category,tags:V.tags,authorLabel:V.author,hideStats:!0,showTypeBadge:!1,cornerLabel:n("teamStore.builtin"),onClick:()=>b(V)},V.id))})]}),f.length>0&&o.jsxs("section",{children:[o.jsx("h3",{className:"section-title mb-3",children:n("teamStore.markusHub")}),o.jsx(Ha,{columns:2,children:f.map(V=>o.jsx(Tue,{item:V,localInfo:I.get(Vc(V)),purchased:bm(V,G),onStatusChange:Y,highlight:V.id===e,onHighlightDone:t,onViewDetail:z=>F({type:"team",name:z})},V.id))})]})]})]})]})}function Tue({item:e,localInfo:t,purchased:n,onStatusChange:a,highlight:i,onHighlightDone:l,onViewDetail:c}){const{t:u}=ut(["store"]),[m,f]=w.useState(!1),[g,h]=w.useState(""),b=w.useRef(null),[y,k]=w.useState(!1);w.useEffect(()=>{if(i&&b.current){b.current.scrollIntoView({behavior:"smooth",block:"center"}),k(!0);const F=setTimeout(()=>{k(!1)},4e3);return()=>clearTimeout(F)}},[i,l]);const C=t?.installed??!1,T=C&&e.version&&t?.localVersion&&Cue(e.version,t.localVersion),A=(e.priceCents??0)>0,M=A?`$${((e.priceCents??0)/100).toFixed(2)}`:null,I=async F=>{if(F.stopPropagation(),!m){f(!0),h("");try{await Ps(e),h(T?u("card.upgraded"):u("card.installed")+"!"),a()}catch(Y){const q=Y instanceof Error?Y.message:"";q.includes("402")||q.includes("Purchase required")?h(u("card.purchaseRequired")):h(u("card.failed"))}finally{f(!1)}}},B=async F=>{if(F.stopPropagation(),!m){f(!0),h("");try{await Xb(e,q=>{q==="checkout_opened"?h(u("card.waitingPurchase","Waiting for purchase...")):q==="installing"&&h(u("card.installing"))})==="installed"?(h(u("card.installed")+"!"),a()):h("")}catch(Y){h(Y instanceof Error?Y.message:u("card.failed"))}finally{f(!1)}}},G=e.slug&&e.author?.username?`${at.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,j=()=>{C&&c?c(Vc(e)):G&&window.open(G,"_blank","noopener,noreferrer")},O=o.jsxs(o.Fragment,{children:[T?o.jsx("button",{onClick:F=>{I(F)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:m?u("card.upgrading"):u("card.upgrade",{version:e.version})}):C?o.jsxs("button",{onClick:F=>{I(F)},disabled:m,className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default rounded-lg transition-colors disabled:opacity-50",children:[u("card.installed"),t?.localVersion?` v${t.localVersion}`:""]}):A&&!n?o.jsx("button",{onClick:F=>{B(F)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:m?g||u("card.installing"):o.jsxs(o.Fragment,{children:[u("card.buy","Buy")," ",M]})}):o.jsx("button",{onClick:F=>{I(F)},disabled:m,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg transition-colors disabled:opacity-50",children:u(m?"card.installing":"card.install")}),g&&o.jsx("span",{className:`text-[10px] ${g===u("card.failed")||g===u("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:g})]});return o.jsx("div",{ref:b,className:y?"animate-pulse":"",children:o.jsx(mr,{type:"team",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"users",cover:e.thumbnailUrl,hubBase:at.getUrl(),author:e.author,version:e.version,category:e.category,tags:e.tags,rating:parseFloat(e.avgRating)||0,ratingCount:e.ratingCount,downloadCount:e.downloadCount,priceCents:e.priceCents,currency:e.currency,installed:C,glowing:y,onClick:j,actions:O})})}function H0(e,t){return e.i18n?.[t]?.displayName||e.name}function B0(e,t){return e.i18n?.[t]?.description||e.description||""}function Eue(e,t){try{return new Intl.NumberFormat(t,{notation:"compact",maximumFractionDigits:1}).format(e)}catch{return e.toLocaleString()}}function dA(e,t){const n=e.split(".").map(Number),a=t.split(".").map(Number);for(let i=0;i<Math.max(n.length,a.length);i++){const l=n[i]??0,c=a[i]??0;if(l>c)return!0;if(l<c)return!1}return!1}const Nue={development:"bg-blue-500/15 text-blue-600",devops:"bg-amber-500/15 text-amber-600",productivity:"bg-green-500/15 text-green-600",custom:"bg-gray-500/15 text-fg-secondary",browser:"bg-brand-500/15 text-brand-500",communication:"bg-green-500/15 text-green-600",data:"bg-brand-500/15 text-brand-500",platform:"bg-blue-500/15 text-blue-600","AI 智能":"bg-brand-500/15 text-brand-500",开发工具:"bg-blue-500/15 text-blue-600",效率提升:"bg-green-500/15 text-green-600",数据分析:"bg-brand-500/15 text-brand-500",内容创作:"bg-brand-500/15 text-brand-500",安全合规:"bg-red-500/15 text-red-500",通讯协作:"bg-green-500/15 text-green-600"};function Mue({item:e,installedSkills:t,purchased:n,onMsg:a,onRefresh:i}){const{t:l}=ut(["store"]),[c,u]=w.useState(!1),m=e.name.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed",f=t.find(A=>A.name===e.name||A.name===m||!!e.slug&&A.name===e.slug),g=!!f,h=g&&e.version&&f?.version&&dA(e.version,f.version),b=(e.priceCents??0)>0,[y,k]=w.useState(""),C=async()=>{if(!c){u(!0),k("");try{await Ps(e),a(h?`Upgraded ${e.name}`:`Installed ${e.name}`,"success"),i()}catch(A){const M=A instanceof Error?A.message:"";M.includes("402")||M.includes("Purchase required")?a(l("card.purchaseRequired"),"error"):a(l("card.failed"),"error")}finally{u(!1)}}},T=async()=>{if(!c){u(!0),k("");try{await Xb(e,M=>{M==="checkout_opened"?k(l("card.waitingPurchase","Waiting for purchase...")):M==="installing"&&k(l("card.installing"))})==="installed"&&(a(`Purchased & installed ${e.name}`,"success"),i()),k("")}catch(A){a(A instanceof Error?A.message:l("card.failed"),"error"),k("")}finally{u(!1)}}};if(h)return o.jsx("button",{onClick:()=>{C()},disabled:c,className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50",children:c?l("card.upgrading"):l("card.upgrade",{version:e.version})});if(g)return o.jsxs("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:[l("card.installed"),f?.version?` (v${f.version})`:""]});if(b&&!n){const A=`$${((e.priceCents??0)/100).toFixed(2)}`;return o.jsx("span",{className:"inline-flex items-center gap-1.5",children:o.jsx("button",{onClick:()=>{T()},disabled:c,className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50 inline-flex items-center gap-1",children:c?y||l("card.installing"):o.jsxs(o.Fragment,{children:[l("card.buy","Buy")," ",A]})})})}return o.jsx("button",{onClick:()=>{C()},disabled:c,className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg disabled:opacity-50",children:l(c?"card.installing":"card.install")})}function m4({item:e,installedSkills:t,purchased:n,onMsg:a,onRefresh:i,highlight:l,onHighlightDone:c,type:u="skill"}){const m=w.useRef(null),[f,g]=w.useState(!1);w.useEffect(()=>{if(l&&m.current){m.current.scrollIntoView({behavior:"smooth",block:"center"}),g(!0);const y=setTimeout(()=>{g(!1)},4e3);return()=>clearTimeout(y)}},[l,c]);const h=e.slug&&e.author?.username?`${at.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,b=()=>{h&&window.open(h,"_blank","noopener,noreferrer")};return o.jsx("div",{ref:m,className:f?"animate-pulse":"",children:o.jsx(mr,{type:u,showTypeBadge:u!=="skill",name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||Zu(e.slug||e.name,e.category),cover:e.thumbnailUrl,hubBase:at.getUrl(),author:e.author,version:e.version,category:e.category,tags:e.tags,rating:parseFloat(e.avgRating)||0,ratingCount:e.ratingCount,downloadCount:e.downloadCount,priceCents:e.priceCents,currency:e.currency,onClick:b,actions:o.jsx(Mue,{item:e,installedSkills:t,purchased:n,onMsg:a,onRefresh:i})})})}function jue({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:a}=ut(["store","common"]),i=a.language,l=Xo(),[c,u]=w.useState("skills"),[m,f]=w.useState(null),[g,h]=w.useState(new Set),[b,y]=w.useState([]),[k,C]=w.useState(null),[T,A]=w.useState([]),[M,I]=w.useState(0),[B,G]=w.useState(1),[j,O]=w.useState([]),[F,Y]=w.useState(""),[q,V]=w.useState("score"),[z,J]=w.useState(""),[D,ee]=w.useState(!1),[R,te]=w.useState([]),[le,ke]=w.useState(!1),[$,W]=w.useState([]),[oe,L]=w.useState(""),[Ne,qe]=w.useState(!1),[me,ze]=w.useState([]),[Ue,je]=w.useState([]),[Ye,xt]=w.useState(new Set),[mt,ft]=w.useState(!1),[rt,jt]=w.useState(""),ht=[{id:"skills",labelKey:"skillStore.tabs.all"},{id:"skillhub",labelKey:"skillStore.tabs.skillhub"},{id:"skillssh",labelKey:"skillStore.tabs.skillssh"}],He=(U,re="success")=>{f({text:U,type:re}),setTimeout(()=>f(null),re==="error"?1e4:4e3)},Et=w.useCallback(async()=>{try{const U=await Se.skills.list();y(U.skills)}catch{}},[]),Kt=w.useCallback(async()=>{ke(!0);try{const U=await Se.skills.builtin();te(U.skills)}catch{}ke(!1)},[]),ie=w.useCallback(async U=>{ee(!0);try{const re=await Se.skills.registrySkillhub({q:U?.q,category:U?.category,page:U?.page??1,limit:24,sort:U?.sort??q});A(re.skills),I(re.total),re.categories?.length&&O(re.categories)}catch{}ee(!1)},[q]),tt=w.useCallback(async U=>{qe(!0);try{const re=await Se.skills.registrySkillssh(U);W(re.skills)}catch{}qe(!1)},[]),it=w.useCallback(async U=>{ft(!0);try{const re=U?at.search({type:"skill",q:U,limit:50}):Ls(La.hubSkills)??at.search({type:"skill",limit:50}),Ce=at.search({subtype:"connector",q:U||void 0,limit:50}).catch(()=>({items:[]})),[Pe,$e]=await Promise.all([re,Ce,at.isAuthenticated()?at.purchases.mine().then(Ve=>xt(new Set(Ve.purchases.map(dt=>dt.itemId)))).catch(()=>{}):Promise.resolve()]);let ue=Pe?.items??[],he=$e?.items??[];if(e){const Ve=ue.some(Je=>Je.id===e),dt=he.some(Je=>Je.id===e);if(!Ve&&!dt)try{const{item:Je}=await at.getItem(e);Je?.subtype==="connector"?he=[Je,...he]:Je?ue=[Je,...ue]:t?.()}catch{t?.()}else Ve&&(ue=[ue.find(ot=>ot.id===e),...ue.filter(ot=>ot.id!==e)]),dt&&(he=[he.find(ot=>ot.id===e),...he.filter(ot=>ot.id!==e)])}ze(ue),je(he)}catch{}ft(!1)},[e,t]);w.useEffect(()=>{Et(),Kt(),ie(),tt()},[]),w.useEffect(()=>{c==="skills"&&it(rt)},[c,rt,it]);const xe=async U=>{h(re=>new Set(re).add(U.name));try{const re=await Se.skills.install({name:U.name,source:"skillhub",slug:U.slug,sourceUrl:U.homepage,description:U.description_zh??U.description,category:"custom",version:U.version});await Et(),He(`"${U.name}" installed (${re.method}) → ${re.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{He(`Download failed for "${U.name}". You can try manually from: ${U.homepage}`,"error")}h(re=>{const Ce=new Set(re);return Ce.delete(U.name),Ce})},Me=async U=>{h(re=>new Set(re).add(U.name));try{const re=await Se.skills.install({name:U.name,source:"skillssh",sourceUrl:U.url,githubRepo:`${U.author}/${U.repo}`,githubSkillPath:U.name});await Et(),He(`"${U.name}" installed (${re.method}) → ${re.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{He(`Download failed for "${U.name}". You can try manually from: ${U.url}`,"error")}h(re=>{const Ce=new Set(re);return Ce.delete(U.name),Ce})},Ie=async U=>{h(re=>new Set(re).add(U.name));try{const re=await Se.skills.install({name:U.name,source:"builtin"});await Et(),await Kt(),He(`"${U.name}" installed (${re.method}) → ${re.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(re){He(`Install failed for "${U.name}": ${re}`,"error")}h(re=>{const Ce=new Set(re);return Ce.delete(U.name),Ce})},ne=$.filter(U=>{if(!oe)return!0;const re=oe.toLowerCase();return U.name.toLowerCase().includes(re)||U.repo.toLowerCase().includes(re)});if(k){const U=k,re={};U.instructions&&(re["SKILL.md"]=U.instructions);const Ce={type:"skill",name:U.name,displayName:H0(U,i),version:U.version,description:B0(U,i),author:U.author??"",category:U.category??"general",tags:U.tags,files:re,skill:{skillFile:U.instructions?"SKILL.md":"",requiredPermissions:U.requiredPermissions,mcpServers:void 0,alwaysOn:!1}},Pe=U.installed&&U.installedVersion&&dA(U.version,U.installedVersion)?o.jsx("button",{onClick:()=>{Ie(U)},disabled:g.has(U.name),className:"px-4 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:g.has(U.name)?n("card.upgrading"):n("card.upgrade",{version:U.version})}):U.installed?o.jsxs("span",{className:"px-4 py-1.5 text-xs bg-green-500/10 text-green-500 rounded-lg border border-green-500/20 inline-flex items-center gap-1",children:[o.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:o.jsx("polyline",{points:"20 6 9 17 4 12"})}),n("card.installed"),U.installedVersion?` v${U.installedVersion}`:""]}):o.jsx("button",{onClick:()=>{Ie(U)},disabled:g.has(U.name),className:"px-4 py-1.5 text-xs bg-green-600 hover:bg-green-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:g.has(U.name)?n("card.installing"):n("card.install")}),$e=o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[o.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.details")}),o.jsxs("div",{className:"space-y-2.5 text-sm",children:[U.category&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.category")}),o.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium capitalize ${Nue[U.category]??"bg-gray-500/15 text-fg-secondary"}`,children:U.category})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.version")}),o.jsx("span",{className:"text-fg-secondary font-mono text-xs",children:U.version})]}),U.hasMcpServers&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.integration")}),o.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] bg-purple-500/15 text-purple-400",children:"MCP"})]}),U.hasInstructions&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.instructions")}),o.jsx("span",{className:"text-green-500 text-xs",children:"✓"})]})]})]}),(U.requiredPermissions.length>0||U.tags.length>0)&&o.jsxs("div",{className:"space-y-4",children:[U.requiredPermissions.length>0&&o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[o.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.permissions")}),o.jsx("div",{className:"flex flex-wrap gap-1.5",children:U.requiredPermissions.map(ue=>o.jsx("span",{className:"px-2.5 py-1 text-xs bg-amber-500/10 text-amber-500 rounded-lg border border-amber-500/20",children:ue},ue))})]}),U.tags.length>0&&o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[o.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.tags")}),o.jsx("div",{className:"flex flex-wrap gap-1.5",children:U.tags.map(ue=>o.jsx("span",{className:"px-2.5 py-1 text-xs bg-surface-elevated text-fg-secondary rounded-lg border border-border-default/50",children:ue},ue))})]})]})]});return o.jsxs(o.Fragment,{children:[o.jsx(qs,{type:"skill",name:U.name,onBack:()=>C(null),readOnly:!0,initialManifest:Ce,actionSlot:Pe,contentSlot:$e}),m&&o.jsx("div",{className:`mx-7 mb-2 px-3 py-1.5 text-xs rounded-lg shrink-0 ${m.type==="error"?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-600"}`,children:m.text})]})}return o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[o.jsxs("div",{className:`${l?"px-4":"px-6"} shrink-0`,children:[o.jsx("div",{"data-electron-drag":!0,className:"flex items-center h-14",children:o.jsx("h2",{className:"text-lg font-semibold",children:n("skillStore.title")})}),o.jsx("div",{className:`flex ${l?"flex-wrap":""} gap-1 pb-2 overflow-x-auto scrollbar-hide`,children:ht.map(U=>o.jsx("button",{onClick:()=>u(U.id),className:`px-3 py-1.5 text-xs rounded-lg transition-colors shrink-0 ${c===U.id?"bg-brand-600 text-on-brand":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:n(U.labelKey)},U.id))})]}),m&&o.jsx("div",{className:`mx-7 mt-2 px-3 py-1.5 text-xs rounded-lg shrink-0 ${m.type==="error"?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-600"}`,children:m.text}),c==="skills"&&(()=>{const U=rt.trim().toLowerCase(),re=U?R.filter($e=>H0($e,i).toLowerCase().includes(U)||B0($e,i).toLowerCase().includes(U)):R,Ce=le&&mt,Pe=re.length===0&&me.length===0&&Ue.length===0;return o.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"} space-y-8`,children:[o.jsx("div",{className:"flex items-center gap-2",children:o.jsx("input",{value:rt,onChange:$e=>jt($e.target.value),placeholder:n("skillStore.searchMarkusHub"),className:`px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none ${l?"flex-1 min-w-0":"w-72"}`})}),Ce&&Pe?o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map(($e,ue)=>o.jsx("div",{className:"h-56 rounded-2xl skeleton"},ue))}):Pe?o.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[o.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◇"}),o.jsx("div",{children:n("skillStore.noBuiltin")}),o.jsx("div",{className:"text-xs mt-1",children:n("skillStore.noBuiltinHint")})]}):o.jsxs(o.Fragment,{children:[re.length>0&&o.jsxs("section",{children:[o.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[o.jsx("h3",{className:"section-title",children:n("skillStore.tabs.builtin")}),o.jsx("span",{className:"text-xs text-fg-tertiary",children:n("skillStore.builtinCount",{count:re.length})})]}),o.jsx(Ha,{columns:3,children:re.map($e=>o.jsx(mr,{type:"skill",name:H0($e,i),description:B0($e,i),seed:$e.name,icon:Zu($e.name,$e.category),version:$e.version,category:$e.category,tags:$e.tags,authorLabel:$e.author||void 0,installed:$e.installed,hideStats:!0,showTypeBadge:!1,cornerLabel:$e.installed?void 0:n("skillStore.tabs.builtin"),onClick:()=>C($e)},$e.name))})]}),me.length>0&&o.jsxs("section",{children:[o.jsx("h3",{className:"section-title mb-3",children:n("skillStore.tabs.markusHub")}),o.jsx(Ha,{columns:3,children:me.map($e=>o.jsx(m4,{item:$e,installedSkills:b,purchased:bm($e,Ye),onMsg:He,onRefresh:()=>{Et(),it(rt)},highlight:$e.id===e,onHighlightDone:t},$e.id))})]}),Ue.length>0&&o.jsxs("section",{children:[o.jsxs("div",{className:"mb-3",children:[o.jsx("h3",{className:"section-title",children:n("tabs.connectors")}),o.jsx("p",{className:"text-xs text-fg-tertiary mt-0.5",children:n("connectorStore.emptyHint","连接器让智能体接入外部工具与服务 (MCP)")})]}),o.jsx(Ha,{columns:3,children:Ue.map($e=>o.jsx(m4,{item:$e,type:"connector",installedSkills:b,purchased:bm($e,Ye),onMsg:He,onRefresh:()=>{Et(),it(rt)},highlight:$e.id===e,onHighlightDone:t},$e.id))})]})]})]})})(),c==="skillhub"&&o.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`,children:[o.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[o.jsxs("select",{value:F,onChange:U=>{Y(U.target.value),G(1),ie({q:z||void 0,category:U.target.value||void 0,page:1})},className:"px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-secondary outline-none",children:[o.jsx("option",{value:"",children:n("skillStore.allCategories")}),j.map(U=>o.jsx("option",{value:U,children:U},U))]}),o.jsxs("select",{value:q,onChange:U=>{V(U.target.value),G(1),ie({q:z||void 0,category:F||void 0,page:1,sort:U.target.value})},className:"px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-secondary outline-none",children:[o.jsx("option",{value:"score",children:n("skillStore.sortScore")}),o.jsx("option",{value:"downloads",children:n("skillStore.sortDownloads")}),o.jsx("option",{value:"stars",children:n("skillStore.sortStars")}),o.jsx("option",{value:"installs",children:n("skillStore.sortInstalls")})]}),!l&&o.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:o.jsx("a",{href:"https://skillhub.tencent.com",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),o.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[o.jsx("input",{value:z,onChange:U=>J(U.target.value),onKeyDown:U=>{U.key==="Enter"&&(G(1),ie({q:z||void 0,category:F||void 0,page:1}))},placeholder:n("skillStore.searchSkillhub"),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none flex-1 min-w-0"}),o.jsx("button",{onClick:()=>{G(1),ie({q:z||void 0,category:F||void 0,page:1})},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-on-brand text-xs rounded-lg shrink-0",children:n("common:search")})]}),D?o.jsx("div",{className:"text-center text-fg-tertiary py-20",children:o.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillhub")})}):T.length===0?o.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[o.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◎"}),o.jsx("div",{children:n("skillStore.noSkillhub")})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"text-xs text-fg-tertiary mb-3",children:n("skillStore.skillhubTotal",{count:M.toLocaleString()})}),o.jsx(Ha,{columns:3,children:T.map(U=>{const re=b.some(Ce=>Ce.name===U.name||Ce.name===U.slug);return o.jsx(mr,{type:"skill",name:U.name,description:U.description_zh??U.description??"",seed:U.slug,icon:Zu(U.slug||U.name,U.tags?.[0]),version:U.version,authorLabel:"SkillHub",showTypeBadge:!1,tags:U.tags,installed:re,hideStats:!0,onClick:()=>window.open(U.homepage,"_blank","noopener,noreferrer"),footerLeft:o.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary",children:[U.stars>0&&o.jsxs("span",{className:"text-amber-600",children:["★ ",U.stars.toLocaleString()]}),U.downloads>0&&o.jsxs("span",{children:[U.downloads>=1e4?Eue(U.downloads,a.language):U.downloads.toLocaleString()," ",n("skillStore.downloads")]})]}),actions:re?void 0:o.jsx("button",{onClick:()=>{xe(U)},disabled:g.has(U.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg disabled:opacity-50",children:g.has(U.name)?"...":n("card.install")})},U.slug)})}),M>24&&o.jsxs("div",{className:"flex items-center justify-center gap-2 mt-6",children:[o.jsx("button",{disabled:B<=1,onClick:()=>{const U=B-1;G(U),ie({q:z||void 0,category:F||void 0,page:U})},className:"px-3 py-1.5 text-xs bg-surface-elevated text-fg-secondary rounded-lg hover:bg-surface-overlay disabled:opacity-30",children:n("skillStore.prevPage")}),o.jsx("span",{className:"text-xs text-fg-tertiary",children:n("skillStore.pageInfo",{current:B,total:Math.ceil(M/24)})}),o.jsx("button",{disabled:B>=Math.ceil(M/24),onClick:()=>{const U=B+1;G(U),ie({q:z||void 0,category:F||void 0,page:U})},className:"px-3 py-1.5 text-xs bg-surface-elevated text-fg-secondary rounded-lg hover:bg-surface-overlay disabled:opacity-30",children:n("skillStore.nextPage")})]})]})]}),c==="skillssh"&&o.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`,children:[o.jsxs("div",{className:`flex ${l?"flex-wrap":""} items-center gap-2 mb-5`,children:[o.jsx("input",{value:oe,onChange:U=>L(U.target.value),onKeyDown:U=>{U.key==="Enter"&&oe.trim()&&tt(oe)},placeholder:n("skillStore.searchSkillssh"),className:`px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none ${l?"flex-1 min-w-0":"w-72"}`}),o.jsx("button",{onClick:()=>{oe.trim()&&tt(oe)},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-on-brand text-xs rounded-lg shrink-0",children:n("common:search")}),!l&&o.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:o.jsx("a",{href:"https://skills.sh",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),Ne?o.jsx("div",{className:"text-center text-fg-tertiary py-20",children:o.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillssh")})}):ne.length===0?o.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[o.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"⬡"}),o.jsx("div",{children:n("skillStore.browseSkillssh")}),o.jsx("div",{className:"text-xs mt-1",children:n("skillStore.browseSkillsshHint")})]}):o.jsx(Ha,{columns:3,children:ne.map(U=>{const re=b.some(Ce=>Ce.name===U.name);return o.jsx(mr,{type:"skill",name:U.name,description:U.description||"",seed:`${U.author}-${U.name}`,icon:Zu(U.name),authorLabel:`${U.author}/${U.repo}`,showTypeBadge:!1,installed:re,hideStats:!0,cornerLabel:re?void 0:"skills.sh",onClick:()=>window.open(U.url,"_blank","noopener,noreferrer"),footerLeft:U.installs?o.jsx("span",{className:"text-[10px] text-fg-tertiary",children:n("skillStore.installsCount",{count:U.installs})}):void 0,actions:re?void 0:o.jsx("button",{onClick:()=>{Me(U)},disabled:g.has(U.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg disabled:opacity-50",children:g.has(U.name)?"...":n("card.install")})},`${U.author}-${U.name}`)})})]})]})}const Rue=["agent","team","skill","connector"];function z0({title:e,subtitle:t,onMore:n,moreLabel:a}){return o.jsxs("div",{className:"flex items-end justify-between mb-3",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"section-title",children:e}),t&&o.jsx("p",{className:"section-subtitle",children:t})]}),n&&o.jsxs("button",{className:"section-link",onClick:n,children:[a??"View all"," →"]})]})}function _ue({item:e,onOpen:t}){const{t:n}=ut(["store","common"]),a=il(e.subtype==="connector"?"connector":e.itemType),i=Fb(a,e.slug||e.name),l=Bs[a];return o.jsxs("button",{onClick:t,className:"group relative w-full overflow-hidden rounded-2xl text-left h-44 md:h-52",style:{background:i},children:[o.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-black/55 via-black/20 to-transparent"}),o.jsx("svg",{className:"absolute -right-8 -bottom-10 opacity-20",width:"220",height:"220",viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:o.jsx("path",{d:"M12 2l2.4 6.9L21 9l-5.4 4 2 7-5.6-4.1L6.4 20l2-7L3 9l6.6-.1z",fill:"white"})}),o.jsxs("div",{className:"relative h-full flex flex-col justify-end p-5 md:p-6",children:[o.jsx("span",{className:"inline-flex w-fit items-center gap-1 rounded-full bg-white/20 backdrop-blur px-2.5 py-0.5 text-[11px] font-semibold text-white mb-2",children:n("discover.featured",{type:l.label})}),o.jsx("h2",{className:"text-xl md:text-2xl font-bold text-white drop-shadow-sm",children:e.name}),o.jsx("p",{className:"text-sm text-white/85 truncate max-w-lg mt-1",children:e.description}),o.jsxs("div",{className:"flex items-center gap-3 mt-3 text-white/80 text-xs",children:[o.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[o.jsx(Wm,{name:e.author?.displayName,username:e.author?.username,avatarUrl:e.author?.avatarUrl,hubBase:at.getUrl(),size:18}),e.author?.displayName||e.author?.username]}),o.jsxs("span",{children:["↓ ",qo(e.downloadCount)]}),(e.priceCents??0)>0?o.jsxs("span",{className:"badge-paid",children:["$",((e.priceCents??0)/100).toFixed(0)]}):o.jsx("span",{className:"badge-free",children:n("discover.free")})]})]})]})}function p4({items:e,onOpen:t}){return o.jsx(Ha,{columns:3,children:e.map(n=>o.jsx(mr,{type:n.subtype==="connector"?"connector":n.itemType,name:n.name,description:n.description,seed:n.slug||n.name,icon:n.icon,cover:n.thumbnailUrl,hubBase:at.getUrl(),author:n.author,category:n.category,tags:n.tags,rating:parseFloat(n.avgRating)||0,ratingCount:n.ratingCount,downloadCount:n.downloadCount,priceCents:n.priceCents,currency:n.currency,onClick:()=>t(n)},n.id))})}function f4(){return o.jsx(Ha,{columns:3,children:Array.from({length:6}).map((e,t)=>o.jsx("div",{className:"h-64 rounded-2xl skeleton"},t))})}function Due({onOpenType:e}){const{t}=ut(["store","common"]),[n,a]=w.useState([]),[i,l]=w.useState(!0);w.useEffect(()=>{let h=!1;return(async()=>{l(!0);try{const b=await at.search({limit:60,sort:"popular"});h||a(b.items??[])}catch{h||a([])}finally{h||l(!1)}})(),()=>{h=!0}},[]);const c=w.useMemo(()=>{const h=n.filter(y=>y.featured);return(h.length>0?h:n).slice(0,3)},[n]),u=w.useMemo(()=>[...n].sort((h,b)=>(b.trendingScore??b.downloadCount)-(h.trendingScore??h.downloadCount)).slice(0,10),[n]),m=w.useMemo(()=>[...n].sort((h,b)=>(b.createdAt||"").localeCompare(h.createdAt||"")).slice(0,10),[n]),f=w.useMemo(()=>{const h=new Map;for(const b of n){const y=b.author?.username||b.author?.id;if(!y)continue;const k=h.get(y)??{author:b.author,downloads:0,count:0};k.downloads+=b.downloadCount||0,k.count+=1,h.set(y,k)}return[...h.values()].sort((b,y)=>y.downloads-b.downloads).slice(0,6)},[n]),g=h=>e(il(h.subtype==="connector"?"connector":h.itemType),h.id);return o.jsxs("div",{className:"flex-1 overflow-y-auto px-5 md:px-7 py-5 space-y-8",children:[o.jsxs("div",{className:"hero-glow rounded-2xl border border-border-subtle bg-surface-secondary p-5 md:p-6",children:[o.jsx("h1",{className:"text-2xl font-bold text-gradient tracking-tight",children:t("discover.title","Markus 广场")}),o.jsx("p",{className:"text-sm text-fg-tertiary mt-1 max-w-2xl",children:t("discover.subtitle","发现社区共享的智能体、AI 小队、技能与连接器 — 由创作者共建的开放生态。")}),o.jsx("div",{className:"flex flex-wrap gap-2 mt-4",children:Rue.map(h=>o.jsxs("button",{onClick:()=>e(h),className:`inline-flex items-center gap-1.5 rounded-full px-3 py-1.5 text-xs font-medium text-white bg-gradient-to-r ${Bs[h].gradient} hover:opacity-90 transition-opacity`,children:[Bs[h].labelZh,o.jsx("span",{className:"opacity-70",children:Bs[h].label})]},h))})]}),i?o.jsx("div",{className:"h-52 rounded-2xl skeleton"}):c.length>0?o.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:c.map(h=>o.jsx(_ue,{item:h,onOpen:()=>g(h)},h.id))}):null,o.jsxs("section",{children:[o.jsx(z0,{title:t("discover.trending","热门趋势"),subtitle:t("discover.trendingSub","社区中下载与评分增长最快的资产")}),i?o.jsx(f4,{}):u.length>0?o.jsx(p4,{items:u,onOpen:g}):o.jsx(Iue,{})]}),o.jsxs("section",{children:[o.jsx(z0,{title:t("discover.fresh","新鲜上架"),subtitle:t("discover.freshSub","来自创作者的最新作品")}),i?o.jsx(f4,{}):m.length>0?o.jsx(p4,{items:m,onOpen:g}):null]}),f.length>0&&o.jsxs("section",{children:[o.jsx(z0,{title:t("discover.topCreators","顶尖创作者"),subtitle:t("discover.topCreatorsSub","生态贡献榜")}),o.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:f.map((h,b)=>o.jsxs("div",{className:"asset-card p-4 flex flex-col items-center text-center",children:[o.jsxs("div",{className:"relative",children:[o.jsx(Wm,{name:h.author?.displayName,username:h.author?.username,avatarUrl:h.author?.avatarUrl,hubBase:at.getUrl(),size:48,verified:b<3}),b<3&&o.jsx("span",{className:"absolute -top-1 -left-1 w-5 h-5 rounded-full bg-amber-400 text-black text-[10px] font-bold flex items-center justify-center ring-2 ring-surface-secondary",children:b+1})]}),o.jsx("div",{className:"text-sm font-semibold text-fg-primary truncate w-full mt-2",children:h.author?.displayName||h.author?.username}),o.jsxs("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:[t("discover.worksCount",{count:h.count})," · ↓ ",qo(h.downloads)]})]},h.author?.username||b))})]})]})}function Iue(){const{t:e}=ut(["store"]);return o.jsxs("div",{className:"text-center py-12 rounded-2xl border border-dashed border-border-default",children:[o.jsx("div",{className:"text-3xl mb-2 opacity-40",children:"✦"}),o.jsx("div",{className:"text-fg-secondary font-medium",children:e("discover.empty","生态正在成长中")}),o.jsx("div",{className:"text-fg-tertiary text-sm mt-1",children:e("discover.emptyHint","成为首批创作者,分享你的第一个资产")})]})}function $u(e,t,n){return e.i18n?.[n]?.[t]}function Lue(){const{t:e,i18n:t}=ut(["store","common"]),n=Xo(),a=t.language,[i,l]=w.useState([]),[c,u]=w.useState({}),[m,f]=w.useState(new Set),[g,h]=w.useState(null),[b,y]=w.useState(!0),[k,C]=w.useState(""),[T,A]=w.useState("all"),[M,I]=w.useState(null),B=w.useCallback(async()=>{y(!0);try{const[O,F,Y,q]=await Promise.all([Se.builder.artifacts.list().catch(()=>({artifacts:[]})),Se.builder.artifacts.installed().catch(()=>({installed:{}})),Se.skills.updates().catch(()=>({updates:[],count:0})),Se.skills.builtin().catch(()=>({skills:[]}))]),V={};for(const D of Y.updates)V[D.name]={availableVersion:D.availableVersion,installedVersion:D.installedVersion,displayName:D.displayName,description:D.description};u(V);const z=O.artifacts.filter(D=>{const ee=`${D.type}/${D.name}`;return!!F.installed[ee]}),J=new Set(z.filter(D=>D.type==="skill").map(D=>D.name));for(const D of q.skills)!D.installed||J.has(D.name)||!(F.installed[`skill/${D.name}`]||V[D.name])&&!D.updateAvailable||!F.installed[`skill/${D.name}`]&&!V[D.name]||(z.push({type:"skill",name:D.name,meta:{displayName:D.i18n?.[a]?.displayName||D.name,description:D.i18n?.[a]?.description||D.description||"",version:D.installedVersion||D.version,author:D.author,category:D.category,tags:D.tags,i18n:D.i18n},path:"",updatedAt:""}),J.add(D.name));for(const[D,ee]of Object.entries(V))J.has(D)||(z.push({type:"skill",name:D,meta:{displayName:ee.displayName||D,description:ee.description||"",version:ee.installedVersion},path:"",updatedAt:""}),J.add(D));l(z)}catch{}y(!1)},[a]);w.useEffect(()=>{B()},[B]),w.useEffect(()=>{const O=()=>{B()};return window.addEventListener("markus:data-changed",O),()=>window.removeEventListener("markus:data-changed",O)},[B]),w.useEffect(()=>{if(!g)return;const O=setTimeout(()=>h(null),3e3);return()=>clearTimeout(O)},[g]);const G=async(O,F)=>{if(!m.has(O)){f(Y=>new Set(Y).add(O));try{await Se.skills.install({name:O,source:"builtin"});try{localStorage.removeItem("markus:template-updates-ack")}catch{}h({text:e("installedTab.updateSuccess",{name:O,version:F}),type:"success"}),window.dispatchEvent(new CustomEvent("markus:data-changed")),await B()}catch{h({text:e("installedTab.updateFailed",{name:O}),type:"error"})}f(Y=>{const q=new Set(Y);return q.delete(O),q})}},j=i.filter(O=>{if(T!=="all"&&O.type!==T)return!1;if(!k)return!0;const F=k.toLowerCase(),Y=($u(O.meta,"displayName",a)||O.meta.displayName||O.name).toLowerCase(),q=($u(O.meta,"description",a)||O.meta.description||"").toLowerCase();return Y.includes(F)||q.includes(F)}).sort((O,F)=>{const Y=O.type==="skill"&&c[O.name]?1:0;return(F.type==="skill"&&c[F.name]?1:0)-Y});return M?o.jsx(qs,{type:M.type,name:M.name,onBack:()=>I(null)}):o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[o.jsxs("div",{"data-electron-drag":!0,className:`${n?"px-4":"px-6"} h-14 flex items-center shrink-0 gap-3`,children:[o.jsx("h2",{className:"text-lg font-semibold",children:e("installedTab.title")}),Object.keys(c).length>0&&o.jsxs("span",{className:"px-2 py-0.5 text-[11px] font-medium rounded-md bg-amber-500/15 text-amber-600 border border-amber-500/25",children:[e("installedTab.updateAvailable")," · ",Object.keys(c).length]})]}),o.jsxs("div",{className:`flex flex-wrap items-center gap-2 ${n?"px-4":"px-6"} py-2 shrink-0`,children:[o.jsx("div",{className:"flex gap-1",children:["all","agent","team","skill"].map(O=>o.jsx("button",{onClick:()=>A(O),className:`px-3 py-1 text-xs rounded-md transition-colors ${T===O?"bg-brand-600 text-on-brand":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:e(`installedTab.filter${O==="all"?"All":O==="agent"?"Agents":O==="team"?"Teams":"Skills"}`)},O))}),o.jsx("div",{className:"flex-1 min-w-[120px]",children:o.jsx("input",{type:"text",placeholder:e("installedTab.searchPlaceholder"),value:k,onChange:O=>C(O.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm w-full focus:border-brand-500 focus:outline-none"})})]}),o.jsx("div",{className:`flex-1 overflow-y-auto ${n?"p-4":"p-7"}`,children:b?o.jsx("div",{className:"text-center text-fg-tertiary py-20 animate-pulse",children:e("installedTab.loading")}):j.length===0?o.jsxs("div",{className:"text-center py-20",children:[o.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),o.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:e("installedTab.noItems")}),o.jsx("div",{className:"text-fg-tertiary text-sm",children:e("installedTab.noItemsHint")})]}):o.jsx(Ha,{columns:3,children:j.map(O=>{const F=$u(O.meta,"displayName",a)||O.meta.displayName||O.name,Y=$u(O.meta,"description",a)||O.meta.description||"",q=O.meta.version||"",V=O.meta.author||"",z=O.meta.tags??[],J=O.meta.category||"",D=O.meta.icon,ee=D&&/\.(png|jpe?g|gif|webp|svg)$/i.test(D)&&!D.startsWith("http")&&!D.startsWith("data:")&&!D.startsWith("/")?`/api/builder/artifacts/${O.type}s/${encodeURIComponent(O.name)}/${D}`:D,R=O.type==="skill"?c[O.name]:void 0;return o.jsx(mr,{type:O.type,name:F,description:Y,seed:O.name,icon:ee,author:null,authorLabel:V||void 0,version:R?R.installedVersion:q,category:J,tags:z,installed:!R,hideStats:!0,cornerLabel:R?e("installedTab.updateAvailable"):void 0,onClick:()=>{O.path&&I({type:O.type,name:O.name})},actions:R?o.jsx("button",{type:"button",disabled:m.has(O.name),onClick:()=>{G(O.name,R.availableVersion)},className:"px-3 py-1.5 text-xs font-medium bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:m.has(O.name)?e("installedTab.updating"):e("installedTab.updateTo",{version:R.availableVersion})}):void 0},`${O.type}/${O.name}`)})})}),g&&o.jsx("div",{className:`fixed bottom-6 left-1/2 -translate-x-1/2 z-50 px-4 py-2 rounded-lg text-sm shadow-lg ${g.type==="success"?"bg-emerald-600 text-white":"bg-red-600 text-white"}`,children:g.text})]})}const Pue=50,Oue=30;function Hue(e,t,n,a){const i=w.useRef(0),l=w.useRef(0),c=w.useCallback(m=>{i.current=m.touches[0].clientX,l.current=m.touches[0].clientY},[]),u=w.useCallback(m=>{const f=m.changedTouches[0].clientX-i.current,g=m.changedTouches[0].clientY-l.current,h=Math.abs(f),b=Math.abs(g);if(h<Pue||Math.atan2(b,h)*(180/Math.PI)>Oue)return;if(a?.scrollContainerRef?.current){const C=a.scrollContainerRef.current,T=C.scrollLeft<=1,A=C.scrollLeft+C.clientWidth>=C.scrollWidth-1;if(f>0&&!T||f<0&&!A)return}const k=e.findIndex(C=>C.id===t);f<0&&k<e.length-1?n(e[k+1].id):f>0&&k>0?n(e[k-1].id):f>0&&k===0&&a?.onSwipeOutLeft?a.onSwipeOutLeft():f<0&&k===e.length-1&&a?.onSwipeOutRight&&a.onSwipeOutRight()},[e,t,n,a]);return{onTouchStart:c,onTouchEnd:u}}const Bue=["builder","discover","agents","teams","skills","installed"],zue={agent:"agents",team:"teams",skill:"skills",connector:"skills"};function Jg(e){return!!e&&Bue.includes(e)}function h4(){const e=localStorage.getItem("markus_nav_installItem"),t=localStorage.getItem("markus_nav_storeTab");return{tab:Jg(t)?t:"builder",installId:e}}function que({authUser:e}){const{t}=ut(["nav","store","common"]),n=w.useMemo(()=>[{id:"builder",label:t("nav:tabs.create")},{id:"discover",label:t("nav:tabs.discover")},{id:"agents",label:t("nav:tabs.agents")},{id:"teams",label:t("nav:tabs.teams")},{id:"skills",label:t("nav:tabs.skills")},{id:"installed",label:t("nav:tabs.installed")}],[t]),[a]=w.useState(h4),[i,l]=w.useState(a.tab),[c,u]=w.useState(a.installId),m=Hue(n,i,l);w.useEffect(()=>{const g=h4();g.installId&&(u(g.installId),Jg(g.tab)&&l(g.tab),localStorage.removeItem("markus_nav_installItem"),localStorage.removeItem("markus_nav_storeTab"))},[]),w.useEffect(()=>{const g=h=>{const b=h.detail,y=b.params?.storeTab??localStorage.getItem("markus_nav_storeTab");Jg(y)&&l(y);const k=b.params?.installItem??localStorage.getItem("markus_nav_installItem");k&&u(k),localStorage.removeItem("markus_nav_storeTab"),localStorage.removeItem("markus_nav_installItem")};return window.addEventListener("markus:navigate",g),()=>window.removeEventListener("markus:navigate",g)},[]);const f=(g,h)=>{h&&u(h),l(zue[g]??"agents")};return o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:m.onTouchStart,onTouchEnd:m.onTouchEnd,children:[o.jsxs("div",{className:"flex items-center shrink-0 overflow-x-auto scrollbar-hide",children:[o.jsx(ES,{className:"ml-2"}),n.map(g=>o.jsx("button",{onClick:()=>l(g.id),className:`flex-1 min-w-fit px-3 py-2.5 text-xs font-medium text-center whitespace-nowrap transition-colors border-b-2 ${i===g.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:g.label},g.id))]}),o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[i==="builder"&&o.jsx(iA,{authUser:e}),i==="discover"&&o.jsx(Due,{onOpenType:f}),i==="agents"&&o.jsx(kue,{authUser:e,highlightItemId:c,onHighlightDone:()=>u(null)}),i==="teams"&&o.jsx(Aue,{highlightItemId:c,onHighlightDone:()=>u(null)}),i==="skills"&&o.jsx(jue,{highlightItemId:c,onHighlightDone:()=>u(null)}),i==="installed"&&o.jsx(Lue,{})]})]})}const uA="markus_native_update_dismissed";function mA(e=window.markusDesktop){return!e||e.isMAS?!1:typeof e.onUpdateState=="function"&&typeof e.installUpdate=="function"}function $ue(){try{return localStorage.getItem(uA)}catch{return null}}function Fue(){const{t:e}=ut("common"),[t,n]=w.useState(null),[a,i]=w.useState($ue),[l,c]=w.useState(null);w.useEffect(()=>{const y=window.markusDesktop;if(!y||!mA(y))return;let k=!1;y.getUpdateState?.().then(T=>{!k&&T&&n(T)}).catch(()=>{});const C=y.onUpdateState?.(T=>n(T));return()=>{k=!0,C?.()}},[]);const u=w.useCallback(()=>{const y=t?.version??null;i(y);try{y&&localStorage.setItem(uA,y)}catch{}},[t]),m=w.useCallback(()=>{c(null),window.markusDesktop?.installUpdate?.().then(y=>{y?.ok||c(y?.error??"unknown")}).catch(()=>c("unknown"))},[]);if(!t||t.version===null||t.phase!=="downloading"&&t.phase!=="ready"||a===t.version)return null;const{version:f,percent:g,requiresMoveToApplications:h}=t,b=t.phase==="ready";return o.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-brand-500/10 border-b border-brand-500/30 text-brand-400 text-sm shrink-0",children:[o.jsxs("span",{className:"text-xs",children:[h?e("update.moveToApplications"):b?e("update.ready",{version:f}):e("update.downloading",{version:f,percent:g??0}),l&&o.jsx("span",{className:"ml-2 text-amber-500",children:e("update.restartFailed")})]}),o.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[b&&!h&&o.jsx("button",{type:"button",onClick:m,className:"px-3 py-1 bg-brand-600 hover:bg-brand-500 text-on-brand text-xs rounded-lg transition-colors",children:e("update.restart")}),o.jsx("button",{type:"button",onClick:u,className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]})}const g4="usageType",q0="profile";function Uue({onComplete:e,theme:t,onThemeChange:n,skipProfile:a,onProfileUpdated:i}){const{t:l}=ut(["onboarding","common"]),[c,u]=w.useState(0),[m,f]=w.useState("local"),[g,h]=w.useState(""),[b,y]=w.useState(""),[k,C]=w.useState(""),[T,A]=w.useState(""),[M,I]=w.useState(!1),[B,G]=w.useState(""),[j,O]=w.useState(!1),[F,Y]=w.useState(null);w.useEffect(()=>{Se.auth.me().then(({user:He})=>{He.name&&h(He.name),He.email&&y(He.email),He.avatarUrl&&Y(He.avatarUrl);const Et=He.name||He.email?.split("@")[0]||"";Et&&J(Kt=>Kt||l("usageType.defaultOrgName",{name:Et}))}).catch(()=>{}),Se.settings.getOrg().then(({org:He})=>{He?.name&&He.name!=="My Organization"&&J(He.name)}).catch(()=>{}),Tn()&&Se.hubOrgs.invitations().then(He=>{He.invitations?.length>0&&W(He.invitations)}).catch(()=>{})},[]);const[q,V]=w.useState(null),[z,J]=w.useState(""),[D,ee]=w.useState(!1),[R,te]=w.useState(!1),[le,ke]=w.useState(""),[$,W]=w.useState([]),[oe,L]=w.useState(null),[Ne,qe]=w.useState(null),me=async()=>{const He=z.trim();if(He){ee(!0),ke("");try{if(await Se.settings.updateOrg(He),Tn()){const Et=await Se.hubOrgs.mine(),Kt=Et.orgs?.find(ie=>ie.role==="owner")??Et.orgs?.[0];Kt?.id?await Se.hubOrgs.update(Kt.id,{name:He}):await Se.hubOrgs.create(He)}te(!0)}catch{ke(l("usageType.orgNameSaveFailed"))}finally{ee(!1)}}},[ze,Ue]=w.useState(!0),je=async()=>{if(G(""),!g.trim()){G(l("profile.errors.nameRequired"));return}if(!b.trim()){G(l("profile.errors.emailRequired"));return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(b.trim())){G(l("profile.errors.emailInvalid"));return}if(k&&k.length<6){G(l("profile.errors.passwordTooShort"));return}if(k&&k!==T){G(l("profile.errors.passwordMismatch"));return}I(!0);try{const{user:He}=await Se.auth.updateProfile(g.trim(),b.trim());k&&await Se.auth.changePassword("",k),i?.(He),O(!0)}catch{G(l("profile.errors.saveFailed"))}finally{I(!1)}},Ye=[{value:"system",label:l("theme.system"),icon:"💻",desc:l("theme.systemDesc")},{value:"light",label:l("theme.light"),icon:"☀️",desc:l("theme.lightDesc")},{value:"dark",label:l("theme.dark"),icon:"🌊",desc:l("theme.darkDesc")},{value:"cyberpunk",label:l("theme.cyberpunk"),icon:"🔮",desc:l("theme.cyberpunkDesc")},{value:"mono",label:l("theme.mono"),icon:"⬛",desc:l("theme.monoDesc")}],xt=[{id:"welcome",title:l("welcome.title"),subtitle:l("welcome.subtitle"),content:o.jsx("p",{className:"text-fg-secondary text-sm leading-relaxed",children:o.jsx(vE,{i18nKey:"welcome.description",ns:"onboarding",components:{strong:o.jsx("strong",{className:"text-fg-primary"})}})})},{id:g4,title:l("usageType.title",{defaultValue:"How will you use Markus?"}),subtitle:l("usageType.subtitle",{defaultValue:"This helps us tailor your experience."}),content:o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("button",{onClick:()=>{V("personal"),te(!0)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${q==="personal"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[o.jsx("span",{className:"text-2xl",children:"👤"}),o.jsxs("div",{children:[o.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:l("usageType.personal",{defaultValue:"Personal"})}),o.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:l("usageType.personalDesc",{defaultValue:"Individual use with your own AI agents."})})]})]}),o.jsxs("button",{onClick:()=>{V("organization"),te(!1)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${q==="organization"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[o.jsx("span",{className:"text-2xl",children:"🏢"}),o.jsxs("div",{children:[o.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:l("usageType.organization",{defaultValue:"Team & Enterprise"})}),o.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:l("usageType.organizationDesc",{defaultValue:"For teams sharing licenses and collaborating."})})]})]})]}),q==="organization"&&o.jsxs("div",{className:"space-y-4 mt-4",children:[$.length>0&&o.jsxs("div",{className:"space-y-2",children:[o.jsx("div",{className:"text-xs text-fg-tertiary font-medium",children:l("usageType.pendingInvitations")}),$.map(He=>o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 rounded-xl border border-amber-500/20 bg-amber-500/5",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium text-fg-primary",children:He.orgName}),o.jsx("div",{className:"text-[11px] text-fg-tertiary",children:l("usageType.invitedBy",{name:He.invitedBy})})]}),o.jsx("button",{onClick:async()=>{L(He.orgId);try{await Se.hubOrgs.acceptInvitation(He.orgId),qe(He.orgId),te(!0)}catch{}finally{L(null)}},disabled:oe===He.orgId||Ne===He.orgId,className:"px-3 py-1.5 text-xs rounded-lg bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-on-brand transition-colors",children:Ne===He.orgId?l("usageType.accepted"):oe===He.orgId?l("usageType.accepting"):l("usageType.acceptAndJoin")})]},He.orgId)),o.jsx("div",{className:"text-[11px] text-fg-tertiary text-center pt-1",children:l("usageType.orCreateNew")})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("usageType.orgNameLabel")}),o.jsx("input",{type:"text",value:z,onChange:He=>{J(He.target.value),te(!1),ke("")},placeholder:l("usageType.orgNamePlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),le&&o.jsx("p",{className:"text-xs text-red-500",children:le}),o.jsx("button",{onClick:()=>{me()},disabled:D||!z.trim()||R,className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-on-brand text-sm rounded-xl transition-colors",children:l(D?"common:saving":R?"usageType.orgNameSaved":"usageType.setOrgName")})]})]})},{id:q0,title:l("profile.title"),subtitle:l("profile.subtitle"),content:j?o.jsxs("div",{className:"flex items-center gap-3 bg-green-500/10 border border-green-500/30 rounded-xl p-4",children:[o.jsx("span",{className:"text-green-600 text-lg",children:"✓"}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium text-green-600",children:l("profile.saved")}),o.jsxs("div",{className:"text-xs text-fg-secondary mt-0.5",children:[g," · ",b]})]})]}):o.jsxs("div",{className:"space-y-4",children:[o.jsx("div",{className:"flex justify-center",children:o.jsx(AS,{currentUrl:F,name:g,size:64,targetType:"user"})}),o.jsxs("div",{className:"space-y-1",children:[o.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.nameLabel")," ",o.jsx("span",{className:"text-red-500",children:"*"})]}),o.jsx("input",{type:"text",value:g,onChange:He=>h(He.target.value),placeholder:l("profile.namePlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",autoFocus:!0})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.emailLabel")," ",o.jsx("span",{className:"text-red-500",children:"*"})]}),o.jsx("input",{type:"email",value:b,onChange:He=>y(He.target.value),placeholder:l("profile.emailPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("profile.newPasswordLabel")}),o.jsx("input",{type:"password",value:k,onChange:He=>C(He.target.value),placeholder:l("profile.newPasswordPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),k&&o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("profile.confirmPasswordLabel")}),o.jsx("input",{type:"password",value:T,onChange:He=>A(He.target.value),placeholder:l("profile.confirmPasswordPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),B&&o.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:B}),o.jsx("button",{onClick:()=>{je()},disabled:M||!g.trim()||!b.trim(),className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-on-brand text-sm rounded-xl transition-colors",children:l(M?"common:saving":"profile.saveProfile")})]})},{id:"accessScope",title:l("settings:accessScope.title"),subtitle:l("settings:accessScope.description"),content:o.jsxs("div",{className:"space-y-3",children:[[{id:"local",label:l("settings:accessScope.localOnly"),desc:l("settings:accessScope.localOnlyHint"),host:"127.0.0.1"},{id:"lan",label:l("settings:accessScope.lan"),desc:l("settings:accessScope.lanHint"),host:"0.0.0.0"}].map(He=>o.jsxs("button",{onClick:()=>{f(He.id),fetch("/api/settings/network",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({host:He.host})}).catch(()=>{})},className:`w-full text-left p-3 rounded-lg border transition-colors ${m===He.id?"border-brand-500 bg-brand-500/10":"border-border-default bg-surface-elevated/30"}`,children:[o.jsx("div",{className:"text-sm text-fg-primary",children:He.label}),o.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:He.desc})]},He.id)),o.jsx("p",{className:"text-[11px] text-fg-muted",children:l("settings:accessScope.remoteNote")})]})},{id:"theme",title:l("theme.title"),subtitle:l("theme.subtitle"),content:o.jsxs("div",{className:"space-y-4",children:[o.jsx("div",{className:"grid grid-cols-3 gap-3",children:Ye.map(He=>o.jsxs("button",{onClick:()=>n(He.value),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-5 transition-all ${t===He.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[o.jsx("span",{className:"text-2xl",children:He.icon}),o.jsx("span",{className:"text-sm font-medium text-fg-primary",children:He.label}),o.jsx("span",{className:"text-[11px] text-fg-tertiary leading-tight text-center",children:He.desc})]},He.value))}),o.jsxs("label",{className:"flex items-center gap-2.5 p-3 bg-surface-elevated/30 rounded-lg cursor-pointer group",children:[o.jsx("input",{type:"checkbox",checked:ze,onChange:He=>Ue(He.target.checked),className:"accent-brand-500 shrink-0"}),o.jsx("span",{className:"text-[11px] text-fg-tertiary",children:l("done.telemetry")})]})]})}],mt=a?xt.filter(He=>He.id!==q0):xt,ft=mt.findIndex(He=>He.id===g4),rt=mt.findIndex(He=>He.id===q0),jt=()=>{c===ft&&ft>=0&&!q||c===ft&&q==="organization"&&!R||c===rt&&rt>=0&&!j||(c<mt.length-1?u(c+1):(fetch("/api/settings/telemetry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:ze})}).catch(()=>{}),e()))},ht=mt[c];return o.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4",children:o.jsx("div",{className:"w-full max-w-lg",children:o.jsxs("div",{className:"bg-surface-elevated rounded-2xl p-8",children:[o.jsx("div",{className:"flex gap-1.5 mb-8",children:mt.map((He,Et)=>o.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${Et<=c?"bg-brand-500":"bg-surface-elevated"}`},Et))}),o.jsx("h2",{className:"text-2xl font-bold text-fg-primary",children:ht.title}),o.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:ht.subtitle}),ht.content,o.jsxs("div",{className:"flex justify-between mt-8",children:[c>0?o.jsx("button",{onClick:()=>u(c-1),className:"px-4 py-2 text-sm text-fg-secondary hover:text-fg-primary transition-colors",children:l("common:back")}):o.jsx("span",{}),o.jsx("button",{onClick:jt,disabled:rt>=0&&c===rt&&!j||ft>=0&&c===ft&&(!q||q==="organization"&&!R),className:`px-6 py-2.5 text-on-brand text-sm rounded-xl transition-colors ${rt>=0&&c===rt&&!j||ft>=0&&c===ft&&(!q||q==="organization"&&!R)?"bg-brand-600/40 cursor-not-allowed":"bg-brand-600 hover:bg-brand-500"}`,children:c===mt.length-1?l("getStarted"):l("common:next")})]})]})})})}const b4="markus:legal-consent",Gue="https://markus.global";function Kue({onLogin:e,hasOwner:t}){const{t:n,i18n:a}=ut("auth"),[i,l]=w.useState(null),[c,u]=w.useState(""),[m,f]=w.useState(!1),[g,h]=w.useState(""),[b,y]=w.useState(""),[k,C]=w.useState(!1),[T,A]=w.useState(!1),M=V=>{const z=(a.language||"").toLowerCase().startsWith("zh")?"?lang=zh":"";return`${Gue}${V}${z}`},I=()=>{try{localStorage.setItem(b4,JSON.stringify({acceptedAt:new Date().toISOString(),terms:!0,privacy:!0}))}catch{}},B=()=>T?(I(),!0):(C(!1),requestAnimationFrame(()=>C(!0)),!1),G=async()=>{const V=Tn(),z=Oa();if(!V||!z){u(n("login.hubUnavailable"));return}const J=await Se.auth.hubLogin(V,z);if(window.markusDesktop?.clearPendingDeepLinkAuth?.(),J.cloudAiReady===!1)try{sessionStorage.setItem("markus:cloud-ai-warning",J.cloudAiError?n("login.cloudAiNotReady",{error:J.cloudAiError}):n("login.cloudAiNotReadyGeneric"))}catch{}e(J.user,J.needsOnboarding??!1,{fromHub:!0})},j=async(V,z=!1)=>{if(!(!z&&!B())){u(""),l(V??"hub");try{if(z&&Tn()&&Oa()){await G();return}await Ia({method:V,force:!0}),await G()}catch(J){const D=J instanceof Error?J.message:"";if(!D.includes("cancelled")){if(!z&&Tn())return j(V,!0);u(D||n("login.hubUnavailable"))}}finally{l(null)}}},O=()=>{HY(),l(null),u("")};w.useEffect(()=>{const V=window.markusDesktop;if(!V?.peekPendingDeepLinkAuth&&!V?.consumePendingDeepLinkAuth)return;let z=!1;return(async()=>{const J=V.peekPendingDeepLinkAuth?await V.peekPendingDeepLinkAuth():null;if(z||!J)return;let D=!1;try{D=!!localStorage.getItem(b4)}catch{}if(!T&&!D){u(n("login.consentRequired"));return}D&&!T&&A(!0),I();const ee=V.consumePendingDeepLinkAuth?await V.consumePendingDeepLinkAuth():J;if(!(z||!ee)){u(""),l("hub");try{if(!await OY(ee)||!Tn()||!Oa()){u(n("login.hubUnavailable"));return}await G()}catch{u(n("login.hubUnavailable"))}finally{z||l(null)}}})().catch(()=>{}),()=>{z=!0}},[T]);const F=async V=>{if(V.preventDefault(),!(!g.trim()||!b)&&B()){u(""),l("local");try{const{user:z,needsOnboarding:J}=await Se.auth.login(g.trim(),b);e(z,J??!1)}catch{u(n("login.invalidCredentials"))}finally{l(null)}}},Y=n(t?"login.welcomeBack":"login.getStarted"),q="w-full flex items-center justify-center gap-3 h-11 px-4 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary font-medium transition-all hover:border-brand-400/60 hover:shadow-sm active:scale-[0.99] disabled:opacity-50 disabled:pointer-events-none";return o.jsxs("div",{className:"min-h-dvh bg-surface-primary flex flex-col items-center justify-center p-4 relative overflow-hidden",children:[o.jsxs("div",{className:"pointer-events-none absolute inset-0 overflow-hidden",children:[o.jsx("div",{className:"absolute -top-48 left-1/2 -translate-x-1/2 h-[42rem] w-[42rem] rounded-full bg-brand-500/20 blur-[120px]"}),o.jsx("div",{className:"absolute top-1/4 -left-40 h-[26rem] w-[26rem] rounded-full bg-brand-400/10 blur-[100px]"}),o.jsx("div",{className:"absolute -bottom-40 -right-32 h-[34rem] w-[34rem] rounded-full bg-brand-600/10 blur-[110px]"})]}),o.jsxs("div",{className:"w-full max-w-[26rem] relative z-10 flex-1 flex flex-col justify-center",children:[o.jsxs("div",{className:"text-center mb-8",children:[o.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-16 h-16 mx-auto mb-4 rounded-2xl shadow-xl shadow-brand-900/20 ring-1 ring-border-default/40"}),o.jsx("div",{className:"text-[1.75rem] leading-none font-extrabold tracking-tight text-fg-primary mb-2",children:"Markus"}),o.jsx("div",{className:"text-sm text-fg-tertiary",children:Y})]}),o.jsx("div",{className:"bg-surface-secondary/70 backdrop-blur-xl border border-border-default/80 rounded-3xl p-7 sm:p-8 shadow-2xl shadow-black/10",children:m?o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-base font-semibold text-fg-primary",children:n("login.localTitle")}),o.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:n("login.localAccountHint")})]}),o.jsxs("form",{onSubmit:F,className:"space-y-3",children:[o.jsx("input",{type:"email",value:g,onChange:V=>h(V.target.value),autoComplete:"email",autoFocus:!0,placeholder:n("login.email"),className:"w-full px-4 h-11 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 focus:ring-2 focus:ring-brand-500/20 outline-none transition-all placeholder:text-fg-tertiary",required:!0}),o.jsx("input",{type:"password",value:b,onChange:V=>y(V.target.value),autoComplete:"current-password",placeholder:n("login.password"),className:"w-full px-4 h-11 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 focus:ring-2 focus:ring-brand-500/20 outline-none transition-all placeholder:text-fg-tertiary",required:!0}),c&&o.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:c}),!t&&o.jsx("p",{className:"text-[11px] text-fg-tertiary",children:n("login.defaultCredentials")}),o.jsx("button",{type:"submit",disabled:i==="local"||!g||!b,className:"w-full h-11 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-on-brand text-sm font-semibold rounded-xl transition-all shadow-md shadow-brand-900/30 hover:shadow-lg active:scale-[0.99]",children:n(i==="local"?"login.signingIn":"login.signIn")})]}),o.jsx("div",{className:"text-center",children:o.jsx("button",{onClick:()=>{f(!1),u("")},className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors",children:n("login.backToHub")})})]}):o.jsxs("div",{className:"space-y-3",children:[o.jsxs("button",{onClick:()=>j("google"),disabled:!!i,className:q,children:[o.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[o.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 01-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z"}),o.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),o.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),o.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),n(i==="google"?"login.connectingHub":"login.withGoogle")]}),o.jsxs("button",{onClick:()=>j("github"),disabled:!!i,className:q,children:[o.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"})}),n(i==="github"?"login.connectingHub":"login.withGithub")]}),o.jsxs("button",{onClick:()=>j("email"),disabled:!!i,className:q,children:[o.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"})}),n(i==="email"?"login.connectingHub":"login.withEmail")]}),i&&(i==="google"||i==="github"||i==="email"||i==="hub")&&o.jsxs("div",{className:"px-3 py-2.5 bg-brand-500/10 border border-brand-500/30 rounded-lg text-xs text-fg-secondary space-y-2",children:[o.jsx("p",{children:n("login.browserOpened")}),o.jsx("button",{type:"button",onClick:O,className:"text-brand-500 hover:text-brand-400 underline font-medium",children:n("login.cancelWaiting")})]}),c&&o.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:c}),o.jsxs("div",{className:"flex items-center gap-3 py-1 text-[11px] text-fg-tertiary",children:[o.jsx("span",{className:"h-px flex-1 bg-border-default"}),n("login.or"),o.jsx("span",{className:"h-px flex-1 bg-border-default"})]}),o.jsx("button",{onClick:()=>{f(!0),u("")},disabled:!!i,className:"w-full h-11 px-4 rounded-xl text-sm text-fg-secondary font-medium transition-all hover:bg-surface-elevated/70 disabled:opacity-50",children:n("login.useLocalAccount")})]})}),o.jsxs("label",{onAnimationEnd:()=>C(!1),className:`mt-5 flex items-start justify-center gap-2 text-[11px] leading-relaxed cursor-pointer select-none px-2 transition-colors ${k?"animate-shake text-fg-primary font-medium":"text-fg-tertiary"}`,children:[o.jsx("input",{type:"checkbox",checked:T,onChange:V=>{A(V.target.checked),V.target.checked&&C(!1)},className:"mt-0.5 h-3.5 w-3.5 shrink-0 accent-brand-600 cursor-pointer"}),o.jsxs("span",{className:"text-center",children:[n("login.consentPrefix")," ",o.jsx("a",{href:M("/terms"),target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-400 underline",children:n("login.termsLink")})," ",n("login.consentAnd")," ",o.jsx("a",{href:M("/privacy"),target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-400 underline",children:n("login.privacyLink")})]})]})]}),o.jsxs("div",{className:"relative z-10 flex flex-wrap items-center justify-center gap-x-5 gap-y-1 py-6 text-[11px] text-fg-tertiary",children:[o.jsx("a",{href:"https://markus.global",target:"_blank",rel:"noopener noreferrer",className:"hover:text-fg-secondary transition-colors",children:"markus.global"}),o.jsx("a",{href:"mailto:business@markus.global",className:"hover:text-fg-secondary transition-colors",children:n("login.contactSales")})]})]})}function Vue({token:e,onComplete:t}){const{t:n}=ut(["auth","common"]),[a,i]=w.useState(null),[l,c]=w.useState(""),[u,m]=w.useState(""),[f,g]=w.useState(""),[h,b]=w.useState(!1),[y,k]=w.useState(!1),[C,T]=w.useState(!1);w.useEffect(()=>{Se.auth.inviteInfo(e).then(M=>i(M)).catch(()=>T(!0))},[e]);const A=async M=>{if(M.preventDefault(),g(""),l.length<6){g(n("invite.passwordMinLength"));return}if(l!==u){g(n("invite.passwordsDoNotMatch"));return}b(!0);try{await Se.auth.setup(e,l),k(!0),setTimeout(()=>{window.location.hash="",t()},2e3)}catch{g(n("invite.error"))}finally{b(!1)}};return o.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[o.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),o.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[o.jsxs("div",{className:"text-center mb-8",children:[o.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),o.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),o.jsx("div",{className:"text-sm text-fg-tertiary",children:n("invite.subtitle")})]}),o.jsx("div",{className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:C?o.jsxs("div",{className:"text-center space-y-3",children:[o.jsx("div",{className:"text-red-500 text-3xl",children:"⚠"}),o.jsx("p",{className:"text-sm text-fg-secondary",children:n("invite.invalidLink")}),o.jsx("button",{onClick:()=>{window.location.hash="",t()},className:"text-sm text-brand-500 hover:text-brand-400",children:n("login.signIn")})]}):y?o.jsxs("div",{className:"text-center space-y-3",children:[o.jsx("div",{className:"text-green-500 text-3xl",children:"✓"}),o.jsx("p",{className:"text-sm text-fg-secondary",children:n("invite.setupComplete")})]}):a?o.jsxs("form",{onSubmit:A,className:"space-y-5",children:[o.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n("invite.greeting",{name:a.name})}),o.jsx("p",{className:"text-xs text-fg-tertiary text-center",children:a.email}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("invite.setPassword")}),o.jsx("input",{type:"password",value:l,onChange:M=>c(M.target.value),autoComplete:"new-password",autoFocus:!0,className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("invite.confirmPassword")}),o.jsx("input",{type:"password",value:u,onChange:M=>m(M.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),f&&o.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:f}),o.jsx("button",{type:"submit",disabled:h||!l||!u,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-on-brand text-sm font-medium rounded-xl transition-all shadow-md shadow-brand-900/40 hover:shadow-lg hover:shadow-brand-900/50",children:n(h?"invite.settingUp":"invite.setupAccount")})]}):o.jsx("div",{className:"text-center text-fg-tertiary text-sm animate-pulse py-4",children:n("common:loading")})})]})]})}function Wue({onComplete:e,isFirstTime:t}){const{t:n}=ut("auth"),[a,i]=w.useState(""),[l,c]=w.useState(""),[u,m]=w.useState(""),[f,g]=w.useState(""),[h,b]=w.useState(!1),y=async k=>{if(k.preventDefault(),g(""),l.length<6){g(n("changePassword.passwordMinLength"));return}if(l!==u){g(n("changePassword.passwordsDoNotMatch"));return}b(!0);try{await Se.auth.changePassword(a,l),e()}catch{g(n("changePassword.failedToChange"))}finally{b(!1)}};return o.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[o.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),o.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[o.jsxs("div",{className:"text-center mb-8",children:[o.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),o.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),o.jsx("div",{className:"text-sm text-fg-tertiary",children:n("login.subtitle")})]}),o.jsxs("form",{onSubmit:y,className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n(t?"changePassword.setYourPassword":"changePassword.changePassword")}),t&&o.jsx("p",{className:"text-xs text-amber-600/80 text-center mt-2",children:n("changePassword.defaultPasswordWarning")})]}),!t&&o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.currentPassword")}),o.jsx("input",{type:"password",value:a,onChange:k=>i(k.target.value),autoComplete:"current-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.newPassword")}),o.jsx("input",{type:"password",value:l,onChange:k=>c(k.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0,minLength:6})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.confirmNewPassword")}),o.jsx("input",{type:"password",value:u,onChange:k=>m(k.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),f&&o.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:f}),o.jsx("button",{type:"submit",disabled:h||!l||!u,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-on-brand text-sm font-medium rounded-xl transition-colors",children:n(h?"changePassword.saving":t?"changePassword.setPasswordAndContinue":"changePassword.changePassword")})]})]})]})}const Yue=3e4;let dc=null,lc=null;function Spe(){dc=null}async function Que(e){if(!e?.force&&dc&&Date.now()-dc.at<Yue)return dc.data;if(lc)return lc;const t=(async()=>{const n=await fetch("/api/settings/llm",{credentials:"include"});if(!n.ok)throw new Error(`HTTP ${n.status}`);const a=await n.json();return dc={at:Date.now(),data:a},a})();lc=t;try{return await t}finally{lc===t&&(lc=null)}}function Jue({side:e,defaultWidth:t,minWidth:n,maxWidth:a,collapsedWidth:i=0,storageKey:l}){const[c,u]=w.useState(()=>{try{const C=localStorage.getItem(`${l}_w`);if(C)return Math.max(n,Math.min(a,parseInt(C,10)))}catch{}return t}),[m,f]=w.useState(()=>{try{return localStorage.getItem(`${l}_c`)==="1"}catch{return!1}}),g=w.useRef(!1),h=w.useRef(n),b=w.useRef(a);h.current=n,b.current=a,w.useEffect(()=>{try{localStorage.setItem(`${l}_w`,String(c))}catch{}},[c,l]),w.useEffect(()=>{try{localStorage.setItem(`${l}_c`,m?"1":"0")}catch{}},[m,l]),w.useEffect(()=>{u(C=>Math.max(n,Math.min(a,C)))},[n,a]);const y=w.useCallback(C=>{C.preventDefault(),g.current=!0;const T=C.clientX,A=c,M=B=>{if(!g.current)return;const G=B.clientX-T;u(Math.max(h.current,Math.min(b.current,A+G)))},I=()=>{g.current=!1,document.removeEventListener("mousemove",M),document.removeEventListener("mouseup",I),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",M),document.addEventListener("mouseup",I),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[c,e]),k=w.useCallback(()=>f(C=>!C),[]);return{width:m?i:c,rawWidth:c,collapsed:m,toggle:k,setCollapsed:f,setWidth:u,onResizeStart:y}}const Cpe=[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"cyberpunk",label:"Cyberpunk"},{value:"mono",label:"Mono"}],Xg="markus-theme";function y4(e){const t=document.documentElement;t.classList.remove("light","dark","cyberpunk","mono"),e==="light"?t.classList.add("light"):e==="dark"?t.classList.add("dark"):e==="cyberpunk"?t.classList.add("cyberpunk"):e==="mono"&&t.classList.add("mono")}function Xue(){try{const e=localStorage.getItem(Xg);if(e==="midnight")return localStorage.setItem(Xg,"dark"),"dark";if(e==="light"||e==="dark"||e==="system"||e==="cyberpunk"||e==="mono")return e}catch{}return"system"}function Zue(){const[e,t]=w.useState(Xue),n=w.useCallback(a=>{t(a);try{localStorage.setItem(Xg,a)}catch{}y4(a)},[]);return w.useEffect(()=>{y4(e)},[e]),{mode:e,setMode:n}}let Zg=!1;const eb=new Set;function Ape(e){if(Zg!==e){Zg=e;for(const t of eb)t()}}function eme(e){return eb.add(e),()=>{eb.delete(e)}}function tme(){return Zg}const lm={agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]},nme={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},ame=["agents","tasks","requirements","projects","deliverables","workflows"];let v4="",x4="all",w4=lm,k4=!1;function rme({onClose:e,currentPage:t}){const{t:n}=ut(["common","home","work"]);$s(!0);const[a,i]=w.useState(v4),[l,c]=w.useState(x4),[u,m]=w.useState(w4),[f,g]=w.useState(!1),[h,b]=w.useState(k4),[y,k]=w.useState(-1);w.useEffect(()=>{v4=a},[a]),w.useEffect(()=>{x4=l},[l]),w.useEffect(()=>{w4=u},[u]),w.useEffect(()=>{k4=h},[h]);const C=w.useRef(null),T=w.useRef(void 0),A=w.useRef(null),M=w.useRef(null);w.useEffect(()=>{setTimeout(()=>{C.current?.focus(),C.current?.select()},100)},[]);const I=w.useCallback(async J=>{if(!J.trim()){m(lm),b(!1),k(-1);return}g(!0),b(!0),k(-1);const D=J.toLowerCase();try{const[ee,R,te,le,ke,$]=await Promise.allSettled([Se.agents.list({lean:!0}),Se.tasks.list({search:J,pageSize:20}),Se.requirements.list(),Se.projects.list(),Se.deliverables.search({q:J,limit:20}),Se.teams.list()]),W=ee.status==="fulfilled"?ee.value.agents.filter(ze=>ze.name?.toLowerCase().includes(D)||ze.role?.toLowerCase().includes(D)):[],oe=R.status==="fulfilled"?R.value.tasks:[],L=te.status==="fulfilled"?te.value.requirements.filter(ze=>ze.title?.toLowerCase().includes(D)||ze.description?.toLowerCase().includes(D)):[],Ne=le.status==="fulfilled"?le.value.projects.filter(ze=>ze.name?.toLowerCase().includes(D)||ze.description?.toLowerCase().includes(D)):[],qe=ke.status==="fulfilled"?ke.value.results:[],me=[];if($.status==="fulfilled"){const ze=await Promise.allSettled($.value.teams.map(Ue=>Se.workflows.list(Ue.id)));for(const Ue of ze)if(Ue.status==="fulfilled")for(const je of Ue.value.workflows)(je.name.toLowerCase().includes(D)||(je.displayName||"").toLowerCase().includes(D)||je.description?.toLowerCase().includes(D))&&me.push(je)}m({agents:W,tasks:oe,requirements:L,projects:Ne,deliverables:qe,workflows:me})}catch{m(lm)}finally{g(!1)}},[]),B=J=>{i(J),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>I(J),400)},G=w.useCallback((J,D)=>{e(),yt.navigate(J,D)},[e]),j=[{id:"all",label:n("common:all",{defaultValue:"全部"})},{id:"agents",label:n("common:agents",{defaultValue:"智能体"})},{id:"tasks",label:n("common:tasks",{defaultValue:"任务"})},{id:"requirements",label:n("common:requirements",{defaultValue:"需求"})},{id:"projects",label:n("common:projects",{defaultValue:"项目"})},{id:"deliverables",label:n("common:deliverables",{defaultValue:"交付物"})},{id:"workflows",label:n("common:workflows",{defaultValue:"工作流"})}],O=w.useMemo(()=>nme[t||""]||ame,[t]),F=w.useMemo(()=>{const J=[],D=l==="all"?8:void 0,ee=R=>{if(l!=="all"&&l!==R)return;const te=u[R].length;if(R==="workflows"){const le=D?u.workflows.slice(0,D):u.workflows;for(const ke of le)J.push({id:ke.name,type:"workflow",page:ce.WORK,params:{boardType:"workflows"}})}else{const le=u[R],ke=D?le.slice(0,D):le;for(const $ of ke)switch(R){case"agents":J.push({id:$.id,type:"agent",page:ce.TEAM,params:{agentId:$.id}});break;case"tasks":J.push({id:$.id,type:"task",page:ce.WORK,params:{openTask:$.id}});break;case"requirements":J.push({id:$.id,type:"requirement",page:ce.WORK,params:{openRequirement:$.id}});break;case"projects":J.push({id:$.id,type:"project",page:ce.WORK,params:{projectId:$.id}});break;case"deliverables":J.push({id:$.id,type:"deliverable",page:ce.DELIVERABLES,params:{openDeliverable:$.id}});break}}D&&te>D&&J.push({id:`more_${R}`,type:"showMore",page:"",expandCategory:R,totalCount:te})};for(const R of O)ee(R);return J},[u,l,O]),Y=w.useCallback(J=>{if(J.type==="showMore"&&J.expandCategory){c(J.expandCategory),k(-1);return}G(J.page,J.params)},[G]);w.useEffect(()=>{const J=M.current;if(!J||y<0)return;const D=J.querySelector(`[data-idx="${y}"]`);D&&D.scrollIntoView({block:"nearest"})},[y]);const q=w.useCallback(J=>{if(J.key==="Escape"){e();return}if(J.key==="Tab"){J.preventDefault();const R=j.map(ke=>ke.id),te=R.indexOf(l),le=J.shiftKey?te<=0?R.length-1:te-1:te>=R.length-1?0:te+1;c(R[le]),k(-1);return}const D=J.ctrlKey&&J.key==="n"||J.key==="ArrowDown",ee=J.ctrlKey&&J.key==="p"||J.key==="ArrowUp";if(D||ee){J.preventDefault(),k(R=>{const te=F.length-1;return te<0?-1:D?R>=te?0:R+1:R<=0?te:R-1});return}J.key==="Enter"&&(J.preventDefault(),y>=0&&y<F.length&&Y(F[y]))},[e,F,y,Y,j,l]);w.useEffect(()=>(document.addEventListener("keydown",q),()=>document.removeEventListener("keydown",q)),[q]);const V=F.length>0;let z=0;return o.jsx("div",{ref:A,className:"fixed inset-0 bg-black/50 flex items-start justify-center z-50 pt-[8vh]",onClick:J=>{J.target===A.current&&e()},children:o.jsxs("div",{className:"bg-surface-primary border border-border-default rounded-2xl shadow-2xl w-full max-w-3xl max-h-[78vh] flex flex-col overflow-hidden animate-fadeIn",children:[o.jsxs("div",{className:"shrink-0 px-5 pt-4 pb-3 border-b border-border-default space-y-3",children:[o.jsxs("div",{className:"relative",children:[o.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-fg-tertiary",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("circle",{cx:"11",cy:"11",r:"8"}),o.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),o.jsx("input",{ref:C,value:a,onChange:J=>B(J.target.value),placeholder:n("common:search"),className:"w-full bg-surface-elevated border border-border-default rounded-xl pl-9 pr-9 py-2.5 text-sm text-fg-primary placeholder:text-fg-tertiary focus:border-brand-500 focus:outline-none transition-colors"}),a&&o.jsx("button",{onClick:()=>{i(""),m(lm),b(!1),k(-1),C.current?.focus()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-fg-tertiary hover:text-fg-secondary",children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:j.map(J=>o.jsx("button",{onClick:()=>{c(J.id),k(-1)},className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${l===J.id?"bg-brand-600 text-on-brand":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:J.label},J.id))})]}),o.jsxs("div",{ref:M,className:"flex-1 overflow-y-auto px-5 py-3",children:[f&&o.jsx("div",{className:"flex items-center justify-center py-8",children:o.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:n("common:loading")})}),!f&&h&&!V&&o.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[o.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-2",children:[o.jsx("circle",{cx:"11",cy:"11",r:"8"}),o.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),o.jsx("p",{className:"text-sm text-fg-tertiary",children:n("common:noResults",{defaultValue:"没有找到相关结果"})})]}),!f&&V&&o.jsx("div",{className:"space-y-4",children:O.map(J=>{if(l!=="all"&&l!==J)return null;const D=l==="all"?8:void 0,ee=R=>{const te=z++,le=R==="agents"?u.agents.length:R==="tasks"?u.tasks.length:R==="requirements"?u.requirements.length:R==="projects"?u.projects.length:R==="workflows"?u.workflows.length:u.deliverables.length;return o.jsxs("button",{"data-idx":te,onClick:()=>{c(R),k(-1)},className:`mt-1 w-full text-xs py-1.5 rounded-lg transition-colors ${te===y?"bg-brand-600/15 ring-1 ring-brand-500/40 text-brand-500":"text-brand-500 hover:text-brand-400 hover:bg-surface-overlay"}`,children:[n("common:showAll",{defaultValue:"查看全部"})," (",le,")"]})};return J==="agents"&&u.agents.length>0?o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:agents",{defaultValue:"智能体"})}),o.jsx("div",{className:"space-y-0.5",children:(D?u.agents.slice(0,D):u.agents).map(R=>{const te=z++;return o.jsxs("button",{"data-idx":te,onClick:()=>G(ce.TEAM,{agentId:R.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${te===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[o.jsx(Go,{name:R.name||"Agent",avatarUrl:R.avatarUrl,size:28}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:R.name}),o.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:R.role||R.status})]}),o.jsx(ime,{status:R.status})]},R.id)})}),D&&u.agents.length>D&&ee("agents")]},"agents"):J==="tasks"&&u.tasks.length>0?o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:tasks",{defaultValue:"任务"})}),o.jsx("div",{className:"space-y-0.5",children:(D?u.tasks.slice(0,D):u.tasks).map(R=>{const te=z++;return o.jsxs("button",{"data-idx":te,onClick:()=>G(ce.WORK,{openTask:R.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${te===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[o.jsx(sme,{status:R.status}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm text-fg-primary truncate",children:R.title}),o.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[R.status," · ",R.priority||""]})]})]},R.id)})}),D&&u.tasks.length>D&&ee("tasks")]},"tasks"):J==="requirements"&&u.requirements.length>0?o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:requirements",{defaultValue:"需求"})}),o.jsx("div",{className:"space-y-0.5",children:(D?u.requirements.slice(0,D):u.requirements).map(R=>{const te=z++;return o.jsxs("button",{"data-idx":te,onClick:()=>G(ce.WORK,{openRequirement:R.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${te===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[o.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${R.status==="approved"?"text-green-500 bg-green-500/15":R.status==="pending"?"text-amber-500 bg-amber-500/15":R.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),o.jsx("polyline",{points:"14 2 14 8 20 8"}),o.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),o.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm text-fg-primary truncate",children:R.title}),o.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[R.status," · ",R.priority||""]})]})]},R.id)})}),D&&u.requirements.length>D&&ee("requirements")]},"requirements"):J==="projects"&&u.projects.length>0?o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:projects",{defaultValue:"项目"})}),o.jsx("div",{className:"space-y-0.5",children:(D?u.projects.slice(0,D):u.projects).map(R=>{const te=z++;return o.jsxs("button",{"data-idx":te,onClick:()=>G(ce.WORK,{projectId:R.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${te===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[o.jsx("div",{className:"w-7 h-7 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:o.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:o.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm text-fg-primary truncate",children:R.name}),R.description&&o.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:R.description})]})]},R.id)})}),D&&u.projects.length>D&&ee("projects")]},"projects"):J==="deliverables"&&u.deliverables.length>0?o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:deliverables",{defaultValue:"交付物"})}),o.jsx("div",{className:"space-y-0.5",children:(D?u.deliverables.slice(0,D):u.deliverables).map(R=>{const te=z++;return o.jsxs("button",{"data-idx":te,onClick:()=>G(ce.DELIVERABLES,{openDeliverable:R.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${te===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[o.jsx("div",{className:"w-7 h-7 rounded-lg bg-purple-500/15 flex items-center justify-center shrink-0",children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-purple-500",children:[o.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),o.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm text-fg-primary truncate",children:R.title}),o.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[R.type," · ",R.status]})]})]},R.id)})}),D&&u.deliverables.length>D&&ee("deliverables")]},"deliverables"):J==="workflows"&&u.workflows.length>0?o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:workflows",{defaultValue:"工作流"})}),o.jsx("div",{className:"space-y-0.5",children:(D?u.workflows.slice(0,D):u.workflows).map(R=>{const te=z++;return o.jsxs("button",{"data-idx":te,onClick:()=>G(ce.WORK,{boardType:"workflows"}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${te===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[o.jsx("div",{className:"w-7 h-7 rounded-lg bg-teal-500/15 flex items-center justify-center shrink-0",children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-teal-500",children:[o.jsx("circle",{cx:"12",cy:"12",r:"3"}),o.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm text-fg-primary truncate",children:R.displayName||R.name}),o.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:n("searchResults.workflowMeta",{n:R.stepCount,version:R.version})})]})]},R.name)})}),D&&u.workflows.length>D&&ee("workflows")]},"workflows"):null})}),!f&&!h&&o.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[o.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-2",children:[o.jsx("circle",{cx:"11",cy:"11",r:"8"}),o.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),o.jsx("p",{className:"text-sm text-fg-tertiary",children:n("common:searchHint",{defaultValue:"输入关键词搜索"})})]})]}),o.jsxs("div",{className:"shrink-0 px-5 py-2 border-t border-border-default flex items-center gap-4 text-xs text-fg-tertiary flex-wrap",children:[o.jsxs("span",{children:[o.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:navigator.platform.toUpperCase().includes("MAC")?"Cmd+P":"Ctrl+P"})," ",n("common:toggle",{defaultValue:"唤起/关闭"})]}),o.jsxs("span",{children:[o.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Tab"})," ",n("common:switchTab",{defaultValue:"切换分类"})]}),o.jsxs("span",{children:[o.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"↑↓"})," ",n("common:navigate",{defaultValue:"导航"})]}),o.jsxs("span",{children:[o.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Enter"})," ",n("common:open",{defaultValue:"打开"})]}),o.jsxs("span",{children:[o.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Esc"})," ",n("common:close",{defaultValue:"关闭"})]})]})]})})}function ime({status:e}){const t=e==="active"||e==="idle"?"bg-green-500":e==="working"||e==="busy"?"bg-blue-500":"bg-gray-400";return o.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${t}`})}function sme({status:e}){const t=An[zc(e)].chip;return o.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${t}`,children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("path",{d:"M9 11l3 3L22 4"}),o.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})})}const ome=["layout","navigation","tasks","team","search","rightPanel","terminal","help"];function lme(e){return e===ce.TEAM?"team":e===ce.WORK?"work":e===ce.DELIVERABLES?"deliverables":e===ce.STORE?"store":"any"}function cme({open:e,onClose:t,page:n}){const{t:a}=ut("common"),i=typeof navigator<"u"&&navigator.platform.toUpperCase().includes("MAC"),l=lme(n);return w.useEffect(()=>{if(!e)return;const c=u=>{u.key==="Escape"&&(u.preventDefault(),u.stopPropagation(),t())};return window.addEventListener("keydown",c,!0),()=>window.removeEventListener("keydown",c,!0)},[e,t]),e?o.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/45 backdrop-blur-[1px] p-4",onMouseDown:c=>{c.target===c.currentTarget&&t()},role:"dialog","aria-modal":"true","aria-label":a("shortcuts.title"),children:o.jsxs("div",{className:"w-full max-w-lg max-h-[80vh] overflow-auto rounded-xl border border-border-default bg-surface-primary shadow-2xl",children:[o.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between gap-3 px-4 py-3 border-b border-border-default bg-surface-primary",children:[o.jsx("h2",{className:"text-sm font-semibold text-fg-primary",children:a("shortcuts.title")}),o.jsx("button",{type:"button",onClick:t,className:"w-7 h-7 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated","aria-label":a("shortcuts.close"),children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsx("div",{className:"px-4 py-3 space-y-4",children:ome.map(c=>{const u=$Q.filter(m=>{if(m.group!==c)return!1;const f=m.page??"any";return f==="any"?!0:f===l});return u.length===0?null:o.jsxs("section",{children:[o.jsx("h3",{className:"text-[11px] font-semibold uppercase tracking-wide text-fg-tertiary mb-2",children:a(`shortcuts.groups.${c}`)}),o.jsx("ul",{className:"space-y-1.5",children:u.map(m=>o.jsxs("li",{className:"flex items-center justify-between gap-3 text-sm",children:[o.jsx("span",{className:"text-fg-secondary min-w-0",children:a(m.labelKey??m.label,{defaultValue:m.label})}),o.jsx("kbd",{className:"shrink-0 px-2 py-1 rounded bg-surface-elevated border border-border-default text-[13px] font-medium leading-none text-fg-primary font-mono",children:jS(m.keys,i,m.bare)})]},m.id))})]},c)})})]})}):null}function dme({authUser:e,onClose:t,onSaved:n,onUserUpdated:a}){const{t:i}=ut("common");$s(!0);const[l,c]=w.useState(e.name||""),[u,m]=w.useState(e.email||""),[f,g]=w.useState(!1),[h,b]=w.useState(""),[y,k]=w.useState(()=>SS(e.avatarUrl,Oa()?.avatarUrl)),C=async T=>{if(T.preventDefault(),!l.trim()){b(i("profile.nameRequired"));return}if(u&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(u.trim())){b(i("profile.invalidEmail"));return}g(!0),b("");try{const{user:A}=await Se.auth.updateProfile(l.trim(),u.trim());n({...A,avatarUrl:y??A.avatarUrl})}catch{b(i("profile.failedToSave"))}finally{g(!1)}};return o.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10000]",onClick:t,children:o.jsxs("form",{onSubmit:C,className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[400px] max-w-[calc(100vw-2rem)] shadow-2xl",onClick:T=>T.stopPropagation(),children:[o.jsx("h3",{className:"text-base font-semibold mb-5",children:i("profile.editProfile")}),o.jsx("div",{className:"flex justify-center mb-5",children:o.jsx(AS,{currentUrl:y,name:l,size:72,targetType:"user",targetId:e.id,onUploaded:T=>{k(T),a?.({...e,avatarUrl:T})}})}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:i("profile.name")}),o.jsx("input",{value:l,onChange:T=>c(T.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:i("profile.email")}),o.jsx("input",{value:u,onChange:T=>m(T.target.value),type:"email",className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none"})]}),h&&o.jsx("div",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:h})]}),o.jsxs("div",{className:"flex justify-end gap-3 mt-5",children:[o.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:i("cancel")}),o.jsx("button",{type:"submit",disabled:f,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-on-brand rounded-lg",children:i(f?"saving":"save")})]})]})})}const pA="markus_lan_notice_acked";let S4=null;function fA(){try{const t=globalThis.localStorage;if(t&&typeof t.getItem=="function"&&typeof t.setItem=="function"&&typeof t.removeItem=="function")return t}catch{}S4??=new Map;const e=S4;return{getItem:t=>e.get(t)??null,setItem:(t,n)=>{e.set(t,n)},removeItem:t=>{e.delete(t)}}}function ume(e){return fA().getItem(pA)===e}function mme(e){fA().setItem(pA,e)}function pme(e,t){return e&&!ume(t)}const C4=w.lazy(()=>fa(()=>import("./Team-DfNOc2Oj.js"),__vite__mapDeps([2,3,4,5,6,7,8,9,10])).then(e=>({default:e.TeamPage}))),A4=w.lazy(()=>fa(()=>import("./Settings-DJyCWAY9.js"),__vite__mapDeps([11,6,7])).then(e=>({default:e.Settings}))),fme=w.lazy(()=>fa(()=>import("./Store-Cl-05eXo.js"),[]).then(e=>({default:e.StorePage}))),hme=w.lazy(()=>fa(()=>Promise.resolve().then(()=>fue),void 0).then(e=>({default:e.AgentBuilder}))),T4=w.lazy(()=>fa(()=>import("./Work-Cwkb9n7H.js"),__vite__mapDeps([12,4,3,5,13,6,8,1,14,15])).then(e=>({default:e.WorkPage}))),E4=w.lazy(()=>fa(()=>import("./Deliverables-Cn_DRg-F.js"),__vite__mapDeps([16,3,8,9,13,5])).then(e=>({default:e.DeliverablesPage}))),gme=w.lazy(()=>fa(()=>import("./Search-BGSuNeNO.js"),__vite__mapDeps([17,6])).then(e=>({default:e.SearchPage}))),N4=w.lazy(()=>fa(()=>Promise.resolve().then(()=>XJ),void 0).then(e=>({default:e.default}))),bme={display:"none"};function yme(e){try{const t=navigator.language,n=Intl.DateTimeFormat().resolvedOptions().timeZone,a=e.preferences??{};if(a.locale===t&&a.timezone===n)return;Se.auth.updatePreferences({locale:t,timezone:n}).catch(()=>{})}catch{}}function vme({docScroll:e}={}){const{t}=ut("common");return o.jsx("div",{className:`flex-1 flex items-center justify-center text-fg-tertiary text-sm animate-pulse ${e?"min-h-[50dvh]":""}`,children:t("loading")})}function xme({error:e,onRetry:t,docScroll:n}){const{t:a}=ut("common");return o.jsx("div",{className:`flex-1 flex items-center justify-center p-8 ${n?"min-h-[50dvh]":""}`,children:o.jsxs("div",{className:"max-w-md w-full text-center space-y-3",children:[o.jsx("h3",{className:"text-sm font-medium text-fg-primary",children:a("pageErrorTitle")}),o.jsx("p",{className:"text-xs text-fg-tertiary leading-relaxed",children:a("pageErrorHint")}),o.jsx("pre",{className:"text-[11px] text-left whitespace-pre-wrap break-words bg-surface-elevated rounded-lg p-3 text-fg-secondary max-h-40 overflow-auto",children:e.message}),o.jsx("button",{type:"button",onClick:t,className:"px-3 py-1.5 text-[11px] bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg font-medium",children:a("pageErrorRetry")})]})})}const wme=w.memo(function({id:t,activePage:n,docScroll:a,children:i}){const l=t===n,c=w.useRef(null),u=w.useRef(l);return w.useEffect(()=>{l&&!u.current&&c.current&&c.current.dispatchEvent(new CustomEvent("markus:page-shown",{bubbles:!0})),u.current=l},[l]),o.jsx("div",{ref:c,"data-page-slot":!0,"data-page-active":l?"true":"false",className:a?"block overflow-hidden":"flex-1 overflow-hidden flex flex-col",style:l?void 0:bme,children:o.jsx(w.Suspense,{fallback:o.jsx(vme,{docScroll:a}),children:o.jsx(ZJ,{resetKeys:[t,l],fallback:(m,f)=>o.jsx(xme,{error:m,onRetry:f,docScroll:a}),children:i})})})},(e,t)=>{if(e.docScroll!==t.docScroll)return!1;const n=e.id===e.activePage,a=t.id===t.activePage;return n!==a?!1:a?e.children===t.children:!0}),Fu={};function hA(e){return typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches?W4[e]??e:e}function M4(){return hA(Ec())}function kme(){const{t:e}=ut("common"),[t,n]=w.useState(M4),[a,i]=w.useState(!1),[l,c]=w.useState(!0),u=Xo(),m=w.useSyncExternalStore(eme,tme,()=>!1),f=u&&!(t===ce.TEAM&&m),g=w.useSyncExternalStore(QW,Z4,JW),h=u&&t!==ce.SETTINGS&&t!==ce.SEARCH&&X4(g,t);w.useEffect(()=>{const Ee=document.documentElement;return Ee.classList.toggle("mobile-doc-scroll",f),()=>{Ee.classList.remove("mobile-doc-scroll")}},[f]),w.useLayoutEffect(()=>{f&&window.scrollTo(0,0)},[t,f]);const b=Zue(),y=Jue({side:"left",defaultWidth:160,minWidth:140,maxWidth:400,collapsedWidth:64,storageKey:"markus_sidebar"}),[k,C]=w.useState(()=>new Set([M4()])),[T,A]=w.useState("loading"),[M,I]=w.useState(!1),[B,G]=w.useState(null),[j,O]=w.useState({hasOwner:!1,hasMultipleUsers:!1}),[F,Y]=w.useState(!1),[q,V]=w.useState(!1),[z,J]=w.useState(null),[D,ee]=w.useState(!1),[R,te]=w.useState(null),[le,ke]=w.useState(!1),[$,W]=w.useState(null),[oe,L]=w.useState(()=>{const Ee=localStorage.getItem("markus_update_dismissed");return Ee||null}),[Ne,qe]=w.useState(!1),[me,ze]=w.useState(!1),Ue=kp(),je=Ue?.leftCollapsed??!1,Ye=Ue?.toggleLeftCollapsed,xt=Ue?.setLeftCollapsed,mt=Ue?.keyboardPane??"l0",ft=Ue?.setKeyboardPane,rt=Ue?.l0FocusPageId??null,jt=Ue?.setL0FocusPageId,ht=w.useRef(t);ht.current=t;const He=w.useRef(ce.HOME),Et=Ue?.toggleRightPanel,Kt=Ue?.toggleTerminalPanel,ie=Ue?.cycleRightPanelTab,tt=Ue?.activateRightPanelTabAt,it=Ue?.openNewRightPanelTab,xe=Ue?.rightPanelOpen??!1,Me=Ue?.activeRightPanelTabId??null,Ie=Ue?.openRightPanel,ne=Ue?.closeRightPanelTab,U=Ue?.updateRightPanelBrowserTab,re=Ue?.updateRightPanelTerminalTab,Ce=w.useRef(Ue?.rightPanelTabs);Ce.current=Ue?.rightPanelTabs,w.useEffect(()=>{const Ee=window.markusDesktop?.browser?.onPageEvent;if(!(!Ee||!Ie))return Ee(_e=>{if(_e.type==="closed"){const De=Ce.current?.find(Q=>Q.payload.kind==="url"&&Q.payload.browserId===_e.browserId);De&&ne&&ne(De.id);return}if(_e.type==="navigated"){if(_e.url&&Nc(_e.url))return;_e.browserId&&U&&U(_e.browserId,{url:_e.url,title:_e.title||_e.url});return}if(_e.type==="opened"||_e.type==="selected"){if(!_e.url&&!_e.browserId||_e.browserId.startsWith("eb_")||jce(_e.browserId)||_e.url&&Nc(_e.url))return;Ie({kind:"url",url:_e.url||"about:blank",title:_e.title||_e.url||"Browser",browserId:_e.browserId,pageId:_e.pageId})}})},[Ie,ne,U]),w.useEffect(()=>{const Ee=window.markusDesktop?.terminal?.onEvent;if(!(!Ee||!Ie))return Ee(_e=>{if(_e.type==="closed"){const De=Ce.current?.find(Q=>Q.payload.kind==="terminal"&&Q.payload.terminalId===_e.id);De&&ne&&ne(De.id);return}if(_e.type==="cwd"){_e.cwd&&re?.(_e.id,{cwd:_e.cwd});return}if(_e.type==="selected"){(_e.title||_e.cwd)&&re?.(_e.id,{title:_e.title,cwd:_e.cwd});return}if(_e.type==="opened"){if(Gb.has(_e.id)){(_e.title||_e.cwd)&&re?.(_e.id,{title:_e.title,cwd:_e.cwd});return}_s(_e.id),Ie({kind:"terminal",terminalId:_e.id,title:_e.title||"Terminal",cwd:_e.cwd})}})},[Ie,ne,re]);const Pe=Ue?.handleTerminalExit;w.useEffect(()=>{const Ee=window.markusDesktop?.terminal?.onExit;if(!(!Ee||!Pe))return Ee(_e=>{Pe(_e.id)})},[Pe]),w.useLayoutEffect(()=>{const Ee=t===ce.TEAM&&xe&&Ue?.rightPanelMode==="browser";Oh(Ee)},[t,xe,Ue?.rightPanelMode]),w.useEffect(()=>{window.markusDesktop?.browser?.hideAll?.()},[]);const $e=w.useRef(!1);w.useEffect(()=>{if(!$e.current){$e.current=!0;return}y.setCollapsed(je)},[je,y.setCollapsed]),w.useEffect(()=>{if(u)return;const Ee=navigator.platform.toUpperCase().includes("MAC"),_e=Q=>{Ee&&Q.metaKey&&!Q.ctrlKey&&Q.key==="p"?(Q.preventDefault(),qe(be=>!be)):!Ee&&Q.ctrlKey&&!Q.metaKey&&Q.key==="p"&&(Q.preventDefault(),qe(be=>!be))},De=()=>qe(!0);return document.addEventListener("keydown",_e),window.addEventListener("markus:open-search",De),()=>{document.removeEventListener("keydown",_e),window.removeEventListener("markus:open-search",De)}},[u]);const ue=w.useCallback(()=>!xe||!Me||!ne?!1:(ne(Me),!0),[xe,Me,ne]);w.useEffect(()=>{const Ee=window.markusDesktop?.onAppShortcut?.(_e=>{if(_e.type==="close-tab"){ue();return}_e.type==="new-tab"&&it?.()});return()=>{Ee?.()}},[ue,it]),w.useEffect(()=>{if(u||!Ye||!Et)return;const Ee=navigator.platform.toUpperCase().includes("MAC"),_e=De=>{if(!(Ee?De.metaKey&&!De.ctrlKey:De.ctrlKey&&!De.metaKey)||De.altKey)return;if(!De.shiftKey&&(De.key==="/"||De.code==="Slash")){De.preventDefault(),ze(Te=>!Te);return}if(De.shiftKey&&(De.key==="?"||De.key==="/")){De.preventDefault(),ze(Te=>!Te);return}if(De.shiftKey&&xe&&ie){if(De.key==="]"||De.code==="BracketRight"){De.preventDefault(),ie(1);return}if(De.key==="["||De.code==="BracketLeft"){De.preventDefault(),ie(-1);return}}if(!De.shiftKey&&xe&&tt){const Te=De.key>="1"&&De.key<="9"?Number(De.key):0;if(Te>=1){De.preventDefault(),tt(Te-1);return}}if(De.shiftKey)return;const be=De.key.toLowerCase();if(be==="w"){De.preventDefault(),De.stopPropagation(),ue();return}if(be==="t"){De.preventDefault(),it?.();return}if(be==="b"){if(t===ce.DELIVERABLES)return;De.preventDefault(),Ye()}else if(t===ce.TEAM&&be==="l"){if(!Ee&&T2(De.target)||Ee&&T2(De.target)&&De.ctrlKey)return;De.preventDefault(),Et()}else t===ce.TEAM&&be==="j"&&Kt&&(De.preventDefault(),Kt())};return document.addEventListener("keydown",_e,!0),()=>document.removeEventListener("keydown",_e,!0)},[u,t,Ye,Et,Kt,ie,tt,xe,ue,it]);const he=w.useCallback((Ee,_e)=>{let De=Tc(Ee);u&&(De=W4[De]??De),De!==ce.TEAM&&Oh(!1);const Q=Ec(),be=window.location.hash.slice(1);be!==V0(Q)?Fu[Q]=be:delete Fu[Q];const Te=ht.current;if(De===ce.SETTINGS&&Te!==ce.SETTINGS&&(He.current=Te,yt.setSettingsReturnPage(Te),ft?.("l1"),jt?.(ce.SETTINGS)),Te===ce.SETTINGS&&De!==ce.SETTINGS&&(ft?.("l0"),jt?.(De)),De===ce.SETTINGS&&_e?.tab){const wt=`settings/${_e.tab}`;Fu[De]=wt,history.pushState(null,"","#"+wt),window.dispatchEvent(new HashChangeEvent("hashchange")),n(De),C(Ht=>Ht.has(De)?Ht:new Set([...Ht,De]));return}const Xe=De!==ce.WORK?Fu[De]:void 0;Xe&&Xe!==V0(De)?(history.pushState(null,"",Hs(De)),history.pushState(null,"","#"+Xe)):history.pushState(null,"",Hs(De)),window.dispatchEvent(new HashChangeEvent("hashchange")),n(De),C(wt=>wt.has(De)?wt:new Set([...wt,De]))},[u,ft,jt]);w.useEffect(()=>{yt.setHandler((Ee,_e)=>he(Ee,_e))},[he]);const Ve=w.useCallback(Ee=>{const _e=ht.current,De=nY(_e,eY(_e),Ee);De&&(De.sub&&sY(De.page,De.sub),he(De.page))},[he]);mY({enabled:u,activePage:()=>ht.current,onStep:Ve}),w.useEffect(()=>{mt==="l0"&&t!==ce.SETTINGS&&jt?.(t)},[mt,t,jt]),w.useEffect(()=>{if(u||!ft||!jt)return;const Ee=_e=>{if(_e.metaKey||_e.ctrlKey||_e.altKey||A2(_e.target))return;const De=_e.key.length===1?_e.key.toLowerCase():_e.key;if(t===ce.SETTINGS&&(De==="h"||De==="ArrowLeft")){_e.preventDefault(),_e.stopImmediatePropagation(),yt.leaveSettings();return}if(mt!=="l0"||t===ce.SETTINGS)return;const Q=rt&&Mo.includes(rt)?rt:t,be=Math.max(0,Mo.indexOf(Q));if(De==="j"||De==="ArrowDown"){_e.preventDefault(),_e.stopImmediatePropagation();const Te=Mo[Math.min(Mo.length-1,be+1)];jt(Te),Te!==t&&he(Te),requestAnimationFrame(()=>{document.querySelector(`[data-l0-page-id="${Te}"]`)?.scrollIntoView({block:"nearest"})});return}if(De==="k"||De==="ArrowUp"){_e.preventDefault(),_e.stopImmediatePropagation();const Te=Mo[Math.max(0,be-1)];jt(Te),Te!==t&&he(Te),requestAnimationFrame(()=>{document.querySelector(`[data-l0-page-id="${Te}"]`)?.scrollIntoView({block:"nearest"})});return}if(De==="l"||De==="ArrowRight"||De==="Enter"){const Te=rt&&Mo.includes(rt)?rt:t;if(!GW.has(Te)){_e.preventDefault(),_e.stopImmediatePropagation();return}_e.preventDefault(),_e.stopImmediatePropagation(),Te!==t&&he(Te),xt?.(!1),ft("l1");return}(De==="h"||De==="ArrowLeft")&&(_e.preventDefault(),_e.stopImmediatePropagation())};return document.addEventListener("keydown",Ee,!0),()=>document.removeEventListener("keydown",Ee,!0)},[u,mt,rt,t,he,ft,jt,xt]),w.useEffect(()=>{const Ee=()=>I(!0);return window.addEventListener("markus:open-edit-profile",Ee),()=>window.removeEventListener("markus:open-edit-profile",Ee)},[]),w.useEffect(()=>{if(!window.markusDesktop)return;!u&&t!==ce.SETTINGS&&!y.collapsed?window.markusDesktop.setTrafficLightPosition(16,16):window.markusDesktop.setTrafficLightPosition(6,16)},[y.collapsed,t,u]),w.useEffect(()=>{window.markusDesktop&&window.markusDesktop.onNotificationClick(Ee=>{if(Ee.page){const _e=Tc(Ee.page);Ee.params&&Object.entries(Ee.params).forEach(([De,Q])=>localStorage.setItem(`markus_nav_${De}`,Q)),he(_e),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:_e,params:Ee.params}}));return}Ee.openNotifications&&(pY(),he(ce.HOME))})},[he]);const dt=w.useCallback(()=>{Que().then(Ee=>{if(Ee?.providers){const _e=Object.values(Ee.providers).some(De=>De.configured);J(_e)}}).catch(()=>{})},[]),Je=w.useCallback((Ee,_e)=>{if(!Ee)return;const Q=_e&&{agent:"agents",team:"teams",skill:"skills"}[_e]||"agents";localStorage.setItem("markus_nav_installItem",Ee),localStorage.setItem("markus_nav_storeTab",Q);const be=new URLSearchParams(window.location.search);be.get("install")||(be.set("install",Ee),_e&&be.set("type",_e));const Te=be.toString();window.history.replaceState(null,"",`${window.location.pathname}?${Te}${Hs(ce.STORE)}`);const Xe=()=>yt.navigate(ce.STORE,{storeTab:Q,installItem:Ee});Xe(),setTimeout(Xe,500),setTimeout(Xe,1500)},[]);w.useEffect(()=>{const Ee=()=>A(null);return window.addEventListener(X0,Ee),()=>window.removeEventListener(X0,Ee)},[]),w.useEffect(()=>{const Ee=new URLSearchParams(window.location.search),_e=Ee.get("install");_e&&Je(_e,Ee.get("type"));const De=window.markusDesktop;De?.onDeepLinkInstall?.(({id:Te,type:Xe})=>Je(Te,Xe)),De?.consumePendingDeepLinkInstall?.().then(Te=>{Te?.id&&Je(Te.id,Te.type)}),Se.auth.me().then(({user:Te})=>{p2(),A(Te),G(!0),i(!1),Te.preferences?.guideHidden===!0&&!lg(Te.id)&&cg(Te.id),yme(Te),di.connect(Te.id),dt(),Se.health().then(wt=>{wt.updateAvailable&&wt.latestVersion&&W({latestVersion:wt.latestVersion,currentVersion:wt.version});const Ht=wt.bindHost??"0.0.0.0";pme(wt.lanExposed===!0,Ht)&&te({host:Ht})}).catch(()=>{});const Xe=()=>{As(La.builderArtifacts,()=>Se.builder.artifacts.list()),As(La.builderAgents,()=>Se.agents.list()),As(La.builderHubMyItems,()=>at.myItems()),As(La.builderInstalled,()=>Se.builder.artifacts.installed()),As(La.hubAgents,()=>at.search({type:"agent",limit:50})),As(La.hubTeams,()=>at.search({type:"team",limit:50})),As(La.hubSkills,()=>at.search({type:"skill",limit:50}))};typeof requestIdleCallback=="function"?requestIdleCallback(Xe,{timeout:5e3}):setTimeout(Xe,3e3)}).catch(()=>{A(null),Se.auth.status().then(({initialized:Te,hasOwner:Xe,hasMultipleUsers:wt})=>{G(Te),O({hasOwner:Xe,hasMultipleUsers:wt})}).catch(()=>G(!0))}),di.connect();const Q=di.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),be=()=>{const Te=hA(Ec());Te!==ce.TEAM&&Oh(!1),n(Te),C(Xe=>Xe.has(Te)?Xe:new Set([...Xe,Te]))};return window.addEventListener("hashchange",be),window.addEventListener("popstate",be),()=>{Q(),di.disconnect(),window.removeEventListener("hashchange",be),window.removeEventListener("popstate",be)}},[]),w.useEffect(()=>{const Ee=T!=="loading"&&T!==null?T.id:void 0;if(!Ee)return;const _e=navigator.platform.toUpperCase().includes("MAC"),De=Q=>{if(A2(Q.target))return;const be={key:Q.key,code:Q.code,metaKey:Q.metaKey,ctrlKey:Q.ctrlKey,altKey:Q.altKey,shiftKey:Q.shiftKey};zQ(be,Ee,_e)&&window.dispatchEvent(new CustomEvent("markus:shortcut-lesson-complete"))};return window.addEventListener("keydown",De,!0),()=>window.removeEventListener("keydown",De,!0)},[T]);const ot=T!=="loading"&&T!==null?T:void 0;mQ(ot?.id),NQ(!!ot);const Ft=w.useMemo(()=>u?{[ce.HOME]:o.jsx(U2,{authUser:ot}),[ce.TEAM]:o.jsx(C4,{authUser:ot}),[ce.BUILDER]:o.jsx(que,{authUser:ot}),[ce.SETTINGS]:o.jsx(A4,{theme:b.mode,onThemeChange:b.setMode,authUser:ot,onLogout:()=>{Se.auth.logout().catch(()=>{}),Is(),A(null)},onUserUpdated:Ee=>A(Ee)}),[ce.WORK]:o.jsx(T4,{authUser:ot}),[ce.DELIVERABLES]:o.jsx(E4,{authUser:ot}),[ce.SEARCH]:o.jsx(gme,{}),...Am(ot?.role)?{[ce.AUDIT]:o.jsx(N4,{role:ot?.role,authUser:ot})}:{}}:{[ce.HOME]:o.jsx(U2,{authUser:ot}),[ce.TEAM]:o.jsx(C4,{authUser:ot}),[ce.SETTINGS]:o.jsx(A4,{theme:b.mode,onThemeChange:b.setMode,authUser:ot,onLogout:()=>{Se.auth.logout().catch(()=>{}),Is(),A(null)},onUserUpdated:Ee=>A(Ee)}),[ce.STORE]:o.jsx(fme,{authUser:ot}),[ce.BUILDER]:o.jsx(hme,{authUser:ot}),[ce.WORK]:o.jsx(T4,{authUser:ot}),[ce.DELIVERABLES]:o.jsx(E4,{authUser:ot}),...Am(ot?.role)?{[ce.AUDIT]:o.jsx(N4,{role:ot?.role,authUser:ot})}:{}},[ot?.id,ot?.role,b.mode,u]);if(T==="loading"||T===null&&B===null)return o.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center",children:o.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:e("loading")})});const Ot=(typeof window<"u"?window.location.hash:"").match(/^#invite\?token=([a-f0-9]+)/);return Ot?o.jsx(Vue,{token:Ot[1],onComplete:()=>{window.location.hash="",localStorage.removeItem("markus_onboarded"),i(!0),Y(!0),A("loading"),Se.auth.me().then(Ee=>{B2(Ee.user.id),A(Ee.user)}).catch(()=>A(null))}}):T===null?o.jsx(Kue,{hasOwner:j.hasOwner,hasMultipleUsers:j.hasMultipleUsers,onLogin:(Ee,_e,De)=>{p2(),A(Ee),di.connect(Ee.id),_e?(B2(Ee.id),i(!0),De?.fromHub&&Y(!0)):(i(!1),lg(Ee.id)?(cg(Ee.id),Se.auth.updatePreferences({guideHidden:!0}).catch(()=>{}),A({...Ee,preferences:{...Ee.preferences,guideHidden:!0}})):A(Ee))}}):q?o.jsx(Wue,{onComplete:()=>V(!1),isFirstTime:!0}):a?o.jsx(Uue,{theme:b.mode,onThemeChange:b.setMode,skipProfile:F,onProfileUpdated:Ee=>{const _e={id:Ee.id,name:Ee.name,email:Ee.email,role:Ee.role,orgId:Ee.orgId??"default",avatarUrl:Ee.avatarUrl};A(_e)},onComplete:()=>{localStorage.removeItem("markus_onboarded"),i(!1),Y(!1),Se.auth.me().then(Ee=>A(Ee.user)).catch(()=>{}),dt(),he(ce.HOME)}}):o.jsxs("div",{className:`flex ${f?"min-h-dvh":"h-dvh overflow-x-hidden"} bg-surface-primary text-fg-primary ${u?"flex-col":""}`,children:[!u&&t!==ce.SETTINGS&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"relative z-40 shrink-0",style:{width:y.width},children:o.jsx(dX,{currentPage:t,onNavigate:Ee=>{he(Ee),c(!1),ft?.("l0"),jt?.(Ee)},authUser:T,collapsed:y.collapsed,onToggleCollapse:y.toggle,onLogout:()=>{Se.auth.logout().catch(()=>{}),Is(),A(null)},keyboardFocusPageId:rt,keyboardPaneActive:mt==="l0"})}),o.jsx("div",{className:`${y.collapsed?"w-0":"w-1.5 cursor-col-resize"} shrink-0 group relative z-10 flex items-center justify-center`,onMouseDown:y.collapsed?void 0:y.onResizeStart,children:!y.collapsed&&o.jsx("div",{className:"w-px h-2/3 border-l border-dashed border-transparent group-hover:border-border-default group-active:border-fg-tertiary transition-colors"})})]}),o.jsxs("div",{className:`flex-1 ${f?"":"overflow-hidden"} flex flex-col min-w-0 ${h?"pb-14":""}`,children:[z===!1&&!D&&t!==ce.SETTINGS&&o.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-amber-500/10 border-b border-amber-500/30 text-amber-600 text-sm shrink-0",children:[o.jsx("span",{className:u?"text-xs":"",children:e("llmBanner.message")}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("button",{onClick:()=>{window.location.hash="#settings/providers"},className:"px-3 py-1 bg-amber-700/50 hover:bg-amber-700/70 text-white text-xs rounded-lg transition-colors",children:e("llmBanner.goToSettings")}),o.jsx("button",{onClick:()=>ee(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:e("dismiss")})]})]}),!mA()&&$&&oe!==$.latestVersion&&o.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-brand-500/10 border-b border-brand-500/30 text-brand-400 text-sm shrink-0",children:[o.jsx("span",{className:u?"text-xs":"",children:e("update.available",{latest:$.latestVersion,current:$.currentVersion})}),o.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[o.jsx("a",{href:"https://markus.global/#download",target:"_blank",rel:"noopener noreferrer",className:"text-xs font-medium text-brand-400 hover:text-brand-300 transition-colors",children:e("update.download")}),o.jsx("button",{onClick:()=>{L($.latestVersion),localStorage.setItem("markus_update_dismissed",$.latestVersion)},className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]}),t!==ce.SETTINGS&&o.jsx(Fue,{}),R&&!le&&t!==ce.SETTINGS&&o.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-emerald-500/10 border-b border-emerald-500/25 text-emerald-600 dark:text-emerald-400 text-sm shrink-0",children:[o.jsx("span",{className:u?"text-xs":"",children:e("lanNotice.message",{host:R.host})}),o.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[o.jsx("button",{onClick:()=>{window.location.hash="#settings/network"},className:"text-xs font-medium text-emerald-600 dark:text-emerald-400 hover:text-emerald-500 transition-colors",children:e("lanNotice.goToSettings")}),o.jsx("button",{onClick:()=>{mme(R.host),ke(!0)},className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]}),o.jsx("main",{className:`flex-1 ${f?"":"overflow-hidden"} flex flex-col relative`,children:Object.keys(Ft).map(Ee=>k.has(Ee)?o.jsx(wme,{id:Ee,activePage:t,docScroll:f,children:Ft[Ee]},Ee):null)})]}),h&&o.jsx(AX,{currentPage:t,onNavigate:he}),u&&o.jsx(OQ,{authUser:ot,onNavigate:he,onLogout:()=>{Se.auth.logout().catch(()=>{}),Is(),A(null)}}),!u&&Ne&&o.jsx(rme,{onClose:()=>qe(!1),currentPage:t}),!u&&o.jsx(cme,{open:me,onClose:()=>ze(!1),page:t}),o.jsx(xde,{}),M&&ot&&o.jsx(dme,{authUser:ot,onClose:()=>I(!1),onUserUpdated:Ee=>A(Ee),onSaved:Ee=>{I(!1),A(Ee)}})]})}const j4="data-anim-paused",Sme="data-anim-tick",R4=8,Cme=250,gA=["animate-spin","animate-bounce","activity-text-shimmer","exec-card-active"];gA.map(e=>`.${e}`).join(", ");function Ame(){return document.visibilityState!=="visible"||document.hidden}let Sc=null,uc=0;function Tme(){Sc===null&&(uc=uc%R4,_4(),Sc=window.setInterval(()=>{uc=(uc+1)%R4,_4()},Cme))}function _4(){const e=String(uc);for(const t of gA){const n=document.getElementsByClassName(t);for(let a=0;a<n.length;a++)n[a].setAttribute(Sme,e)}}function Eme(){Sc!==null&&(window.clearInterval(Sc),Sc=null)}function $0(){const e=document.documentElement;Ame()?(e.setAttribute(j4,"true"),Eme()):(e.removeAttribute(j4),Tme())}let D4=!1;function Nme(){D4||typeof document>"u"||(D4=!0,$0(),document.addEventListener("visibilitychange",$0,{passive:!0}),window.addEventListener("pageshow",$0,{passive:!0}))}Nme();E6.createRoot(document.getElementById("root")).render(o.jsx(w.StrictMode,{children:o.jsx(Pce,{children:o.jsx(kme,{})})}));export{tn as $,Go as A,Xle as B,One as C,rce as D,ZJ as E,lpe as F,ope as G,dpe as H,Lue as I,upe as J,cpe as K,uce as L,Dne as M,tA as N,xpe as O,ce as P,Jue as Q,c2 as R,Due as S,kue as T,di as U,Tn as V,Tc as W,ES as X,Jce as Y,Zce as Z,fa as _,Xo as a,xm as a$,Ia as a0,Jo as a1,Mme as a2,Bc as a3,mpe as a4,Or as a5,LS as a6,xr as a7,sX as a8,Gme as a9,cA as aA,JJ as aB,hue as aC,$s as aD,Lr as aE,vE as aF,Yme as aG,Ace as aH,zg as aI,VW as aJ,ppe as aK,bpe as aL,fpe as aM,ype as aN,vpe as aO,gpe as aP,hpe as aQ,_me as aR,Dme as aS,_s as aT,Lu as aU,Qb as aV,Cce as aW,FC as aX,qu as aY,o4 as aZ,kpe as a_,Oa as aa,Fme as ab,qme as ac,tS as ad,Ome as ae,Ume as af,EY as ag,$me as ah,m2 as ai,Hme as aj,CY as ak,zme as al,Bme as am,Rc as an,Xme as ao,wQ as ap,gQ as aq,Zme as ar,bQ as as,Jme as at,gue as au,bue as av,Ko as aw,Que as ax,Cpe as ay,Rme as az,jQ as b,ape as b0,sg as b1,wce as b2,Uk as b3,npe as b4,Kme as b5,Vme as b6,Pme as b7,Spe as b8,Ape as b9,xX as ba,rpe as bb,RY as bc,Wme as bd,AS as be,jS as bf,eJ as bg,epe as bh,VC as bi,T2 as bj,Qme as bk,Qm as bl,wE as bm,jme as bn,Ime as bo,Lme as bp,Hs as bq,$Y as br,mJ as bs,tpe as bt,nS as bu,sJ as bv,spe as bw,kp as c,Hue as d,Aue as e,jue as f,Ps as g,at as h,A2 as i,o as j,Se as k,An as l,$k as m,yt as n,Yde as o,ace as p,boe as q,w as r,Kle as s,zc as t,ut as u,Ure as v,Ose as w,zse as x,wpe as y,_C as z};
|