@markus-global/cli 0.9.1 → 0.9.2
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/markus.mjs +88 -10
- package/dist/web-ui/assets/{CommentInput-ZW-2JyIg.js → CommentInput-D3jx82c7.js} +1 -1
- package/dist/web-ui/assets/{ContentRenderer-Ccoj5KhH.js → ContentRenderer-CQ9uMng0.js} +2 -2
- package/dist/web-ui/assets/{Deliverables-Cfdx-Yeu.js → Deliverables-DKy2_HPY.js} +1 -1
- package/dist/web-ui/assets/{Notifications-CKTZO9fn.js → Notifications-1YKMlJ91.js} +1 -1
- package/dist/web-ui/assets/{Search-_yYhKio7.js → Search-D5P2V5tM.js} +1 -1
- package/dist/web-ui/assets/{Settings-BzI3q_dx.js → Settings-C86a_mG8.js} +6 -6
- package/dist/web-ui/assets/{Store-DweBtEGf.js → Store-Ca8mvyTT.js} +1 -1
- package/dist/web-ui/assets/Team-DHmWU23x.js +40 -0
- package/dist/web-ui/assets/{Work-CMguHPuO.js → Work-zJLJ6A3I.js} +1 -1
- package/dist/web-ui/assets/{arc-BCQf-2jC.js → arc-s5quZ9MF.js} +1 -1
- package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-CPfkQ9P6.js → architectureDiagram-3BPJPVTR-iZhZ9wDV.js} +1 -1
- package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-w0CZJHe6.js → blockDiagram-GPEHLZMM-lYMBEpQb.js} +1 -1
- package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-BTiNccgB.js → c4Diagram-AAUBKEIU-C8vbScKq.js} +1 -1
- package/dist/web-ui/assets/channel-D2RoSw08.js +1 -0
- package/dist/web-ui/assets/{chunk-2J33WTMH-BGdXq7Ci.js → chunk-2J33WTMH-DhvC5Teh.js} +1 -1
- package/dist/web-ui/assets/{chunk-4BX2VUAB-CDNqL2YA.js → chunk-4BX2VUAB-Do4f1QNX.js} +1 -1
- package/dist/web-ui/assets/{chunk-55IACEB6-B0gL5ae4.js → chunk-55IACEB6-BCDgVda5.js} +1 -1
- package/dist/web-ui/assets/{chunk-727SXJPM-C377nPB7.js → chunk-727SXJPM-n9W-gHJL.js} +1 -1
- package/dist/web-ui/assets/{chunk-AQP2D5EJ-DmrWdQ_x.js → chunk-AQP2D5EJ-joCNa2WM.js} +1 -1
- package/dist/web-ui/assets/{chunk-FMBD7UC4-CasLcPiP.js → chunk-FMBD7UC4-Cp9QtfEA.js} +1 -1
- package/dist/web-ui/assets/{chunk-ND2GUHAM-Bl_5b1IO.js → chunk-ND2GUHAM-Dt_ZkR0s.js} +1 -1
- package/dist/web-ui/assets/{chunk-QZHKN3VN-CAFFoh9g.js → chunk-QZHKN3VN-CVGCkc4k.js} +1 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-DGebyJZN.js +1 -0
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-DGebyJZN.js +1 -0
- package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-CNLxRUfr.js → cose-bilkent-S5V4N54A-B4Q2AELl.js} +1 -1
- package/dist/web-ui/assets/{dagre-BM42HDAG-CkqVIRox.js → dagre-BM42HDAG-DoazhTnM.js} +1 -1
- package/dist/web-ui/assets/{diagram-2AECGRRQ-CBxL1Jqg.js → diagram-2AECGRRQ-C7KY67Fn.js} +1 -1
- package/dist/web-ui/assets/{diagram-5GNKFQAL-CpSDzWYR.js → diagram-5GNKFQAL-dPjx6DBc.js} +1 -1
- package/dist/web-ui/assets/{diagram-KO2AKTUF-DG-3NyJR.js → diagram-KO2AKTUF-D4BEU7N2.js} +1 -1
- package/dist/web-ui/assets/{diagram-LMA3HP47-DOq08i33.js → diagram-LMA3HP47-D9PLmyge.js} +1 -1
- package/dist/web-ui/assets/{diagram-OG6HWLK6-B6_uG9hH.js → diagram-OG6HWLK6-Dg6SRSYN.js} +1 -1
- package/dist/web-ui/assets/{erDiagram-TEJ5UH35-DOyEVlMM.js → erDiagram-TEJ5UH35-D97ueERw.js} +1 -1
- package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-BiWeEgX3.js → flowDiagram-I6XJVG4X-Cm-sRIL_.js} +1 -1
- package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-D-j-5cEg.js → ganttDiagram-6RSMTGT7-CXq6jqCz.js} +1 -1
- package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-C6lcURfO.js → gitGraphDiagram-PVQCEYII-CJ50_J0p.js} +1 -1
- package/dist/web-ui/assets/{index-lNtr_En-.js → index-CHkb08MZ.js} +5 -5
- package/dist/web-ui/assets/{infoDiagram-5YYISTIA-DU_r7Q4O.js → infoDiagram-5YYISTIA-CbTpYpwF.js} +1 -1
- package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-C7M7fHbe.js → ishikawaDiagram-YF4QCWOH-CUt9Btxt.js} +1 -1
- package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-DQJbMKSV.js → journeyDiagram-JHISSGLW-F9zmJizG.js} +1 -1
- package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-D8nO46ug.js → kanban-definition-UN3LZRKU-jNs9ezLz.js} +1 -1
- package/dist/web-ui/assets/{mermaid.core-D9X_B1hr.js → mermaid.core-Cxm0p7KD.js} +5 -5
- package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-BoWfA0x3.js → mindmap-definition-RKZ34NQL-BuW2AA71.js} +1 -1
- package/dist/web-ui/assets/{pieDiagram-4H26LBE5-GeMxJnY4.js → pieDiagram-4H26LBE5-BKrViKGj.js} +1 -1
- package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-B5xQl44f.js → quadrantDiagram-W4KKPZXB-Hh0Kzhcb.js} +1 -1
- package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-DAecntg7.js → requirementDiagram-4Y6WPE33-B1ga-7j9.js} +1 -1
- package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-DOLj0rKK.js → sankeyDiagram-5OEKKPKP-2uQ075vI.js} +1 -1
- package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-BvS7cOXA.js → sequenceDiagram-3UESZ5HK-97k-cDlv.js} +1 -1
- package/dist/web-ui/assets/{stateDiagram-AJRCARHV-CqHRpjfn.js → stateDiagram-AJRCARHV-PTiMHe-8.js} +1 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-CNP7uL0K.js +1 -0
- package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-Bsk6HQIz.js → timeline-definition-PNZ67QCA-Gji5tIlk.js} +1 -1
- package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-CekJLx4L.js → vennDiagram-CIIHVFJN-B91fyhQC.js} +1 -1
- package/dist/web-ui/assets/{wardley-L42UT6IY-CBUmu8Xa.js → wardley-L42UT6IY-C9MIuW9C.js} +1 -1
- package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-BgoDq86Z.js → wardleyDiagram-YWT4CUSO-CtXjrE4d.js} +1 -1
- package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-zDxkTG1v.js → xychartDiagram-2RQKCTM6-BgVdUlxT.js} +1 -1
- package/dist/web-ui/index.html +1 -1
- package/package.json +1 -1
- package/dist/web-ui/assets/Team-CpIDXpOi.js +0 -40
- package/dist/web-ui/assets/channel-DIphKEQ6.js +0 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-CIRviJO4.js +0 -1
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-CIRviJO4.js +0 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-Df743oiT.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-Cxm0p7KD.js","assets/transform-CpIVI4vC.js","assets/Team-DHmWU23x.js","assets/CommentInput-D3jx82c7.js","assets/ContentRenderer-CQ9uMng0.js","assets/Work-zJLJ6A3I.js","assets/value-DIujSiJ7.js","assets/Work-BZV40eAE.css","assets/Deliverables-DKy2_HPY.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 o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const l of o)if(l.type==="childList")for(const c of l.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&r(c)}).observe(document,{childList:!0,subtree:!0});function n(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerPolicy&&(l.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?l.credentials="include":o.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(o){if(o.ep)return;o.ep=!0;const l=n(o);fetch(o.href,l)}})();function wc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Gf={exports:{}},$l={};var by;function QS(){if(by)return $l;by=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,o,l){var c=null;if(l!==void 0&&(c=""+l),o.key!==void 0&&(c=""+o.key),"key"in o){l={};for(var d in o)d!=="key"&&(l[d]=o[d])}else l=o;return o=l.ref,{$$typeof:e,type:r,key:c,ref:o!==void 0?o:null,props:l}}return $l.Fragment=t,$l.jsx=n,$l.jsxs=n,$l}var xy;function ZS(){return xy||(xy=1,Gf.exports=QS()),Gf.exports}var s=ZS(),Vf={exports:{}},Ot={};var yy;function JS(){if(yy)return Ot;yy=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),x=Symbol.iterator;function y(q){return q===null||typeof q!="object"?null:(q=x&&q[x]||q["@@iterator"],typeof q=="function"?q:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,T={};function S(q,le,I){this.props=q,this.context=le,this.refs=T,this.updater=I||w}S.prototype.isReactComponent={},S.prototype.setState=function(q,le){if(typeof q!="object"&&typeof q!="function"&&q!=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,q,le,"setState")},S.prototype.forceUpdate=function(q){this.updater.enqueueForceUpdate(this,q,"forceUpdate")};function _(){}_.prototype=S.prototype;function j(q,le,I){this.props=q,this.context=le,this.refs=T,this.updater=I||w}var O=j.prototype=new _;O.constructor=j,C(O,S.prototype),O.isPureReactComponent=!0;var P=Array.isArray;function D(){}var $={H:null,A:null,T:null,S:null},X=Object.prototype.hasOwnProperty;function ee(q,le,I){var Ae=I.ref;return{$$typeof:e,type:q,key:le,ref:Ae!==void 0?Ae:null,props:I}}function H(q,le){return ee(q.type,le,q.props)}function K(q){return typeof q=="object"&&q!==null&&q.$$typeof===e}function ae(q){var le={"=":"=0",":":"=2"};return"$"+q.replace(/[=:]/g,function(I){return le[I]})}var W=/\/+/g;function F(q,le){return typeof q=="object"&&q!==null&&q.key!=null?ae(""+q.key):le.toString(36)}function Z(q){switch(q.status){case"fulfilled":return q.value;case"rejected":throw q.reason;default:switch(typeof q.status=="string"?q.then(D,D):(q.status="pending",q.then(function(le){q.status==="pending"&&(q.status="fulfilled",q.value=le)},function(le){q.status==="pending"&&(q.status="rejected",q.reason=le)})),q.status){case"fulfilled":return q.value;case"rejected":throw q.reason}}throw q}function U(q,le,I,Ae,$e){var Oe=typeof q;(Oe==="undefined"||Oe==="boolean")&&(q=null);var We=!1;if(q===null)We=!0;else switch(Oe){case"bigint":case"string":case"number":We=!0;break;case"object":switch(q.$$typeof){case e:case t:We=!0;break;case h:return We=q._init,U(We(q._payload),le,I,Ae,$e)}}if(We)return $e=$e(q),We=Ae===""?"."+F(q,0):Ae,P($e)?(I="",We!=null&&(I=We.replace(W,"$&/")+"/"),U($e,le,I,"",function(At){return At})):$e!=null&&(K($e)&&($e=H($e,I+($e.key==null||q&&q.key===$e.key?"":(""+$e.key).replace(W,"$&/")+"/")+We)),le.push($e)),1;We=0;var st=Ae===""?".":Ae+":";if(P(q))for(var mt=0;mt<q.length;mt++)Ae=q[mt],Oe=st+F(Ae,mt),We+=U(Ae,le,I,Oe,$e);else if(mt=y(q),typeof mt=="function")for(q=mt.call(q),mt=0;!(Ae=q.next()).done;)Ae=Ae.value,Oe=st+F(Ae,mt++),We+=U(Ae,le,I,Oe,$e);else if(Oe==="object"){if(typeof q.then=="function")return U(Z(q),le,I,Ae,$e);throw le=String(q),Error("Objects are not valid as a React child (found: "+(le==="[object Object]"?"object with keys {"+Object.keys(q).join(", ")+"}":le)+"). If you meant to render a collection of children, use an array instead.")}return We}function Q(q,le,I){if(q==null)return q;var Ae=[],$e=0;return U(q,Ae,"","",function(Oe){return le.call(I,Oe,$e++)}),Ae}function ne(q){if(q._status===-1){var le=q._result;le=le(),le.then(function(I){(q._status===0||q._status===-1)&&(q._status=1,q._result=I)},function(I){(q._status===0||q._status===-1)&&(q._status=2,q._result=I)}),q._status===-1&&(q._status=0,q._result=le)}if(q._status===1)return q._result.default;throw q._result}var ke=typeof reportError=="function"?reportError:function(q){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var le=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof q=="object"&&q!==null&&typeof q.message=="string"?String(q.message):String(q),error:q});if(!window.dispatchEvent(le))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",q);return}console.error(q)},B={map:Q,forEach:function(q,le,I){Q(q,function(){le.apply(this,arguments)},I)},count:function(q){var le=0;return Q(q,function(){le++}),le},toArray:function(q){return Q(q,function(le){return le})||[]},only:function(q){if(!K(q))throw Error("React.Children.only expected to receive a single React element child.");return q}};return Ot.Activity=g,Ot.Children=B,Ot.Component=S,Ot.Fragment=n,Ot.Profiler=o,Ot.PureComponent=j,Ot.StrictMode=r,Ot.Suspense=m,Ot.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=$,Ot.__COMPILER_RUNTIME={__proto__:null,c:function(q){return $.H.useMemoCache(q)}},Ot.cache=function(q){return function(){return q.apply(null,arguments)}},Ot.cacheSignal=function(){return null},Ot.cloneElement=function(q,le,I){if(q==null)throw Error("The argument must be a React element, but you passed "+q+".");var Ae=C({},q.props),$e=q.key;if(le!=null)for(Oe in le.key!==void 0&&($e=""+le.key),le)!X.call(le,Oe)||Oe==="key"||Oe==="__self"||Oe==="__source"||Oe==="ref"&&le.ref===void 0||(Ae[Oe]=le[Oe]);var Oe=arguments.length-2;if(Oe===1)Ae.children=I;else if(1<Oe){for(var We=Array(Oe),st=0;st<Oe;st++)We[st]=arguments[st+2];Ae.children=We}return ee(q.type,$e,Ae)},Ot.createContext=function(q){return q={$$typeof:c,_currentValue:q,_currentValue2:q,_threadCount:0,Provider:null,Consumer:null},q.Provider=q,q.Consumer={$$typeof:l,_context:q},q},Ot.createElement=function(q,le,I){var Ae,$e={},Oe=null;if(le!=null)for(Ae in le.key!==void 0&&(Oe=""+le.key),le)X.call(le,Ae)&&Ae!=="key"&&Ae!=="__self"&&Ae!=="__source"&&($e[Ae]=le[Ae]);var We=arguments.length-2;if(We===1)$e.children=I;else if(1<We){for(var st=Array(We),mt=0;mt<We;mt++)st[mt]=arguments[mt+2];$e.children=st}if(q&&q.defaultProps)for(Ae in We=q.defaultProps,We)$e[Ae]===void 0&&($e[Ae]=We[Ae]);return ee(q,Oe,$e)},Ot.createRef=function(){return{current:null}},Ot.forwardRef=function(q){return{$$typeof:d,render:q}},Ot.isValidElement=K,Ot.lazy=function(q){return{$$typeof:h,_payload:{_status:-1,_result:q},_init:ne}},Ot.memo=function(q,le){return{$$typeof:p,type:q,compare:le===void 0?null:le}},Ot.startTransition=function(q){var le=$.T,I={};$.T=I;try{var Ae=q(),$e=$.S;$e!==null&&$e(I,Ae),typeof Ae=="object"&&Ae!==null&&typeof Ae.then=="function"&&Ae.then(D,ke)}catch(Oe){ke(Oe)}finally{le!==null&&I.types!==null&&(le.types=I.types),$.T=le}},Ot.unstable_useCacheRefresh=function(){return $.H.useCacheRefresh()},Ot.use=function(q){return $.H.use(q)},Ot.useActionState=function(q,le,I){return $.H.useActionState(q,le,I)},Ot.useCallback=function(q,le){return $.H.useCallback(q,le)},Ot.useContext=function(q){return $.H.useContext(q)},Ot.useDebugValue=function(){},Ot.useDeferredValue=function(q,le){return $.H.useDeferredValue(q,le)},Ot.useEffect=function(q,le){return $.H.useEffect(q,le)},Ot.useEffectEvent=function(q){return $.H.useEffectEvent(q)},Ot.useId=function(){return $.H.useId()},Ot.useImperativeHandle=function(q,le,I){return $.H.useImperativeHandle(q,le,I)},Ot.useInsertionEffect=function(q,le){return $.H.useInsertionEffect(q,le)},Ot.useLayoutEffect=function(q,le){return $.H.useLayoutEffect(q,le)},Ot.useMemo=function(q,le){return $.H.useMemo(q,le)},Ot.useOptimistic=function(q,le){return $.H.useOptimistic(q,le)},Ot.useReducer=function(q,le,I){return $.H.useReducer(q,le,I)},Ot.useRef=function(q){return $.H.useRef(q)},Ot.useState=function(q){return $.H.useState(q)},Ot.useSyncExternalStore=function(q,le,I){return $.H.useSyncExternalStore(q,le,I)},Ot.useTransition=function(){return $.H.useTransition()},Ot.version="19.2.4",Ot}var vy;function v0(){return vy||(vy=1,Vf.exports=JS()),Vf.exports}var k=v0();const JW=wc(k);var Kf={exports:{}},Hl={},Wf={exports:{}},Yf={};var wy;function e7(){return wy||(wy=1,(function(e){function t(U,Q){var ne=U.length;U.push(Q);e:for(;0<ne;){var ke=ne-1>>>1,B=U[ke];if(0<o(B,Q))U[ke]=Q,U[ne]=B,ne=ke;else break e}}function n(U){return U.length===0?null:U[0]}function r(U){if(U.length===0)return null;var Q=U[0],ne=U.pop();if(ne!==Q){U[0]=ne;e:for(var ke=0,B=U.length,q=B>>>1;ke<q;){var le=2*(ke+1)-1,I=U[le],Ae=le+1,$e=U[Ae];if(0>o(I,ne))Ae<B&&0>o($e,I)?(U[ke]=$e,U[Ae]=ne,ke=Ae):(U[ke]=I,U[le]=ne,ke=le);else if(Ae<B&&0>o($e,ne))U[ke]=$e,U[Ae]=ne,ke=Ae;else break e}}return Q}function o(U,Q){var ne=U.sortIndex-Q.sortIndex;return ne!==0?ne:U.id-Q.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,d=c.now();e.unstable_now=function(){return c.now()-d}}var m=[],p=[],h=1,g=null,x=3,y=!1,w=!1,C=!1,T=!1,S=typeof setTimeout=="function"?setTimeout:null,_=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function O(U){for(var Q=n(p);Q!==null;){if(Q.callback===null)r(p);else if(Q.startTime<=U)r(p),Q.sortIndex=Q.expirationTime,t(m,Q);else break;Q=n(p)}}function P(U){if(C=!1,O(U),!w)if(n(m)!==null)w=!0,D||(D=!0,ae());else{var Q=n(p);Q!==null&&Z(P,Q.startTime-U)}}var D=!1,$=-1,X=5,ee=-1;function H(){return T?!0:!(e.unstable_now()-ee<X)}function K(){if(T=!1,D){var U=e.unstable_now();ee=U;var Q=!0;try{e:{w=!1,C&&(C=!1,_($),$=-1),y=!0;var ne=x;try{t:{for(O(U),g=n(m);g!==null&&!(g.expirationTime>U&&H());){var ke=g.callback;if(typeof ke=="function"){g.callback=null,x=g.priorityLevel;var B=ke(g.expirationTime<=U);if(U=e.unstable_now(),typeof B=="function"){g.callback=B,O(U),Q=!0;break t}g===n(m)&&r(m),O(U)}else r(m);g=n(m)}if(g!==null)Q=!0;else{var q=n(p);q!==null&&Z(P,q.startTime-U),Q=!1}}break e}finally{g=null,x=ne,y=!1}Q=void 0}}finally{Q?ae():D=!1}}}var ae;if(typeof j=="function")ae=function(){j(K)};else if(typeof MessageChannel<"u"){var W=new MessageChannel,F=W.port2;W.port1.onmessage=K,ae=function(){F.postMessage(null)}}else ae=function(){S(K,0)};function Z(U,Q){$=S(function(){U(e.unstable_now())},Q)}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(U){U.callback=null},e.unstable_forceFrameRate=function(U){0>U||125<U?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):X=0<U?Math.floor(1e3/U):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_next=function(U){switch(x){case 1:case 2:case 3:var Q=3;break;default:Q=x}var ne=x;x=Q;try{return U()}finally{x=ne}},e.unstable_requestPaint=function(){T=!0},e.unstable_runWithPriority=function(U,Q){switch(U){case 1:case 2:case 3:case 4:case 5:break;default:U=3}var ne=x;x=U;try{return Q()}finally{x=ne}},e.unstable_scheduleCallback=function(U,Q,ne){var ke=e.unstable_now();switch(typeof ne=="object"&&ne!==null?(ne=ne.delay,ne=typeof ne=="number"&&0<ne?ke+ne:ke):ne=ke,U){case 1:var B=-1;break;case 2:B=250;break;case 5:B=1073741823;break;case 4:B=1e4;break;default:B=5e3}return B=ne+B,U={id:h++,callback:Q,priorityLevel:U,startTime:ne,expirationTime:B,sortIndex:-1},ne>ke?(U.sortIndex=ne,t(p,U),n(m)===null&&U===n(p)&&(C?(_($),$=-1):C=!0,Z(P,ne-ke))):(U.sortIndex=B,t(m,U),w||y||(w=!0,D||(D=!0,ae()))),U},e.unstable_shouldYield=H,e.unstable_wrapCallback=function(U){var Q=x;return function(){var ne=x;x=Q;try{return U.apply(this,arguments)}finally{x=ne}}}})(Yf)),Yf}var ky;function t7(){return ky||(ky=1,Wf.exports=e7()),Wf.exports}var Xf={exports:{}},nr={};var Sy;function n7(){if(Sy)return nr;Sy=1;var e=v0();function t(m){var p="https://react.dev/errors/"+m;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var h=2;h<arguments.length;h++)p+="&args[]="+encodeURIComponent(arguments[h])}return"Minified React error #"+m+"; visit "+p+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={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},o=Symbol.for("react.portal");function l(m,p,h){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:g==null?null:""+g,children:m,containerInfo:p,implementation:h}}var c=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(m,p){if(m==="font")return"";if(typeof p=="string")return p==="use-credentials"?p:""}return nr.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,nr.createPortal=function(m,p){var h=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11)throw Error(t(299));return l(m,p,null,h)},nr.flushSync=function(m){var p=c.T,h=r.p;try{if(c.T=null,r.p=2,m)return m()}finally{c.T=p,r.p=h,r.d.f()}},nr.preconnect=function(m,p){typeof m=="string"&&(p?(p=p.crossOrigin,p=typeof p=="string"?p==="use-credentials"?p:"":void 0):p=null,r.d.C(m,p))},nr.prefetchDNS=function(m){typeof m=="string"&&r.d.D(m)},nr.preinit=function(m,p){if(typeof m=="string"&&p&&typeof p.as=="string"){var h=p.as,g=d(h,p.crossOrigin),x=typeof p.integrity=="string"?p.integrity:void 0,y=typeof p.fetchPriority=="string"?p.fetchPriority:void 0;h==="style"?r.d.S(m,typeof p.precedence=="string"?p.precedence:void 0,{crossOrigin:g,integrity:x,fetchPriority:y}):h==="script"&&r.d.X(m,{crossOrigin:g,integrity:x,fetchPriority:y,nonce:typeof p.nonce=="string"?p.nonce:void 0})}},nr.preinitModule=function(m,p){if(typeof m=="string")if(typeof p=="object"&&p!==null){if(p.as==null||p.as==="script"){var h=d(p.as,p.crossOrigin);r.d.M(m,{crossOrigin:h,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0})}}else p==null&&r.d.M(m)},nr.preload=function(m,p){if(typeof m=="string"&&typeof p=="object"&&p!==null&&typeof p.as=="string"){var h=p.as,g=d(h,p.crossOrigin);r.d.L(m,h,{crossOrigin:g,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0,type:typeof p.type=="string"?p.type:void 0,fetchPriority:typeof p.fetchPriority=="string"?p.fetchPriority:void 0,referrerPolicy:typeof p.referrerPolicy=="string"?p.referrerPolicy:void 0,imageSrcSet:typeof p.imageSrcSet=="string"?p.imageSrcSet:void 0,imageSizes:typeof p.imageSizes=="string"?p.imageSizes:void 0,media:typeof p.media=="string"?p.media:void 0})}},nr.preloadModule=function(m,p){if(typeof m=="string")if(p){var h=d(p.as,p.crossOrigin);r.d.m(m,{as:typeof p.as=="string"&&p.as!=="script"?p.as:void 0,crossOrigin:h,integrity:typeof p.integrity=="string"?p.integrity:void 0})}else r.d.m(m)},nr.requestFormReset=function(m){r.d.r(m)},nr.unstable_batchedUpdates=function(m,p){return m(p)},nr.useFormState=function(m,p,h){return c.H.useFormState(m,p,h)},nr.useFormStatus=function(){return c.H.useHostTransitionStatus()},nr.version="19.2.4",nr}var Ny;function K4(){if(Ny)return Xf.exports;Ny=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(),Xf.exports=n7(),Xf.exports}var Cy;function r7(){if(Cy)return Hl;Cy=1;var e=t7(),t=v0(),n=K4();function r(a){var i="https://react.dev/errors/"+a;if(1<arguments.length){i+="?args[]="+encodeURIComponent(arguments[1]);for(var u=2;u<arguments.length;u++)i+="&args[]="+encodeURIComponent(arguments[u])}return"Minified React error #"+a+"; visit "+i+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function l(a){var i=a,u=a;if(a.alternate)for(;i.return;)i=i.return;else{a=i;do i=a,(i.flags&4098)!==0&&(u=i.return),a=i.return;while(a)}return i.tag===3?u:null}function c(a){if(a.tag===13){var i=a.memoizedState;if(i===null&&(a=a.alternate,a!==null&&(i=a.memoizedState)),i!==null)return i.dehydrated}return null}function d(a){if(a.tag===31){var i=a.memoizedState;if(i===null&&(a=a.alternate,a!==null&&(i=a.memoizedState)),i!==null)return i.dehydrated}return null}function m(a){if(l(a)!==a)throw Error(r(188))}function p(a){var i=a.alternate;if(!i){if(i=l(a),i===null)throw Error(r(188));return i!==a?null:a}for(var u=a,f=i;;){var b=u.return;if(b===null)break;var v=b.alternate;if(v===null){if(f=b.return,f!==null){u=f;continue}break}if(b.child===v.child){for(v=b.child;v;){if(v===u)return m(b),a;if(v===f)return m(b),i;v=v.sibling}throw Error(r(188))}if(u.return!==f.return)u=b,f=v;else{for(var E=!1,L=b.child;L;){if(L===u){E=!0,u=b,f=v;break}if(L===f){E=!0,f=b,u=v;break}L=L.sibling}if(!E){for(L=v.child;L;){if(L===u){E=!0,u=v,f=b;break}if(L===f){E=!0,f=v,u=b;break}L=L.sibling}if(!E)throw Error(r(189))}}if(u.alternate!==f)throw Error(r(190))}if(u.tag!==3)throw Error(r(188));return u.stateNode.current===u?a:i}function h(a){var i=a.tag;if(i===5||i===26||i===27||i===6)return a;for(a=a.child;a!==null;){if(i=h(a),i!==null)return i;a=a.sibling}return null}var g=Object.assign,x=Symbol.for("react.element"),y=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),S=Symbol.for("react.profiler"),_=Symbol.for("react.consumer"),j=Symbol.for("react.context"),O=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),D=Symbol.for("react.suspense_list"),$=Symbol.for("react.memo"),X=Symbol.for("react.lazy"),ee=Symbol.for("react.activity"),H=Symbol.for("react.memo_cache_sentinel"),K=Symbol.iterator;function ae(a){return a===null||typeof a!="object"?null:(a=K&&a[K]||a["@@iterator"],typeof a=="function"?a:null)}var W=Symbol.for("react.client.reference");function F(a){if(a==null)return null;if(typeof a=="function")return a.$$typeof===W?null:a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case C:return"Fragment";case S:return"Profiler";case T:return"StrictMode";case P:return"Suspense";case D:return"SuspenseList";case ee:return"Activity"}if(typeof a=="object")switch(a.$$typeof){case w:return"Portal";case j:return a.displayName||"Context";case _:return(a._context.displayName||"Context")+".Consumer";case O:var i=a.render;return a=a.displayName,a||(a=i.displayName||i.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case $:return i=a.displayName||null,i!==null?i:F(a.type)||"Memo";case X:i=a._payload,a=a._init;try{return F(a(i))}catch{}}return null}var Z=Array.isArray,U=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ne={pending:!1,data:null,method:null,action:null},ke=[],B=-1;function q(a){return{current:a}}function le(a){0>B||(a.current=ke[B],ke[B]=null,B--)}function I(a,i){B++,ke[B]=a.current,a.current=i}var Ae=q(null),$e=q(null),Oe=q(null),We=q(null);function st(a,i){switch(I(Oe,i),I($e,a),I(Ae,null),i.nodeType){case 9:case 11:a=(a=i.documentElement)&&(a=a.namespaceURI)?Ux(a):0;break;default:if(a=i.tagName,i=i.namespaceURI)i=Ux(i),a=$x(i,a);else switch(a){case"svg":a=1;break;case"math":a=2;break;default:a=0}}le(Ae),I(Ae,a)}function mt(){le(Ae),le($e),le(Oe)}function At(a){a.memoizedState!==null&&I(We,a);var i=Ae.current,u=$x(i,a.type);i!==u&&(I($e,a),I(Ae,u))}function gt(a){$e.current===a&&(le(Ae),le($e)),We.current===a&&(le(We),Pl._currentValue=ne)}var jt,Jt;function Rt(a){if(jt===void 0)try{throw Error()}catch(u){var i=u.stack.trim().match(/\n( *(at )?)/);jt=i&&i[1]||"",Jt=-1<u.stack.indexOf(`
|
|
3
3
|
at`)?" (<anonymous>)":-1<u.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
4
|
`+jt+a+Jt}var be=!1;function Me(a,i){if(!a||be)return"";be=!0;var u=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var f={DetermineComponentFrameRoot:function(){try{if(i){var je=function(){throw Error()};if(Object.defineProperty(je.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(je,[])}catch(Se){var we=Se}Reflect.construct(a,[],je)}else{try{je.call()}catch(Se){we=Se}a.call(je.prototype)}}else{try{throw Error()}catch(Se){we=Se}(je=a())&&typeof je.catch=="function"&&je.catch(function(){})}}catch(Se){if(Se&&we&&typeof Se.stack=="string")return[Se.stack,we.stack]}return[null,null]}};f.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var b=Object.getOwnPropertyDescriptor(f.DetermineComponentFrameRoot,"name");b&&b.configurable&&Object.defineProperty(f.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var v=f.DetermineComponentFrameRoot(),E=v[0],L=v[1];if(E&&L){var re=E.split(`
|
|
@@ -351,7 +351,7 @@ Web应用:2次SVG上传XSS(已修复)
|
|
|
351
351
|
**部署:** 灰度发布 → 5%流量 → 48小时监控 → 全量上线`,seoMatrix:"关键词研究矩阵,涵盖8个产品垂直领域的1,200+关键词。包含搜索量趋势、竞争分数、内容差距分析、SERP功能机会,以及6个月编辑日历和预计流量影响(+340%自然流量)。",financeReport:"2025年5月月度财务结算。营收:$2.4M(环比+18%)。关键亮点:SaaS ARR 突破 $24M 里程碑,CAC 回收期降至11个月,毛利率提升至78%。包含部门损益分析和现金流预测。",apiDocsV2:"API v2 开发者门户文档。涵盖认证(OAuth 2.0 + API Key)、86个端点(含5种语言代码示例)、Webhook集成指南、速率限制策略、版本控制策略及交互式API测试环境配置。",interviewNotes:"24个用户访谈的综合分析,覆盖4类用户画像(高级用户、管理员、新用户、流失用户)。关键发现:引导流程第3步存在阻力、仪表盘自定义是首要功能需求、移动端使用量超预期3倍。含亲和图和视频片段。",wireframes:"移动应用 v2.0 高保真线框图。涵盖5个用户流程共32个界面:引导、仪表盘、通知、设置和离线模式。包含手势标注、转场规格及 iOS/Android 平台适配。",patentAnalysis:"AI驱动工作流自动化领域847项专利的格局分析。识别12个自由实施风险、3个潜在许可机会和5个专有知识产权申请空白领域。包含权利要求映射和现有技术文献。",testFramework:"端到端测试自动化框架,支持API、UI和性能测试。跨8个模块共312个测试用例。包含并行执行(4倍加速)、Playwright视觉回归测试、负载测试场景(1万并发用户)及Slack集成报告。",socialAssets:"产品发布营销活动的60+社交媒体素材库。包含轮播模板、视频故事板、A/B标题变体、平台尺寸适配(LinkedIn、Twitter/X、Instagram)、品牌规范配色和发布排期。"},oD={general:"#综合频道",announcements:"#公告",watercooler:"#茶水间"},lD={general:{secretaryMorning:"早上好,团队。当前18个员工在线,12个任务进行中。今日重点:支付API审查、仪表盘组件开发、Q2调研截止日期。",alexReport:"进展不错。@研究主管——周五董事会需要竞争分析报告,周四前能完成吗?",researchLeadReply:"没问题,Alex。报告已完成90%。周四上午前会提交带有摘要的最终版本。",engLeadApi:"支付对账API已提交审查。@测试主管 请优先安排——涉及财务核心链路。",qaLeadReply:"收到,今天出测试报告。回归测试发现了回调处理器的2个边界情况——修复已提交。",pmStandup:"快速更新——引导流程重设计稿已由James审批通过。进入迭代规划。@前端开发 能评估一下仪表盘组件的工作量吗?",frontendEstimate:"仪表盘卡片:2天。图表组件:3天。今天下班前会把组件拆分方案放到交付物中。",chiefOfStaffSync:"跨团队同步:工程团队被产品团队的设计规范阻塞。@UI设计师 请今天将设计规范导出到共享仓库。",uiDesignerTokens:"完成!设计规范已导出到共享包。42个颜色变量、8个间距尺度、6个字体预设。PR链接已放入交付物。",sarahReview:"今天效率很高。3个PR已合并,2个交付物已验证。继续保持这个节奏冲刺Q2。",dataAnalystInsight:"仪表盘数据分析:89%的用户在3分钟内完成引导流程。移动端转化率仍偏低62%——优先进行移动端优化。",devopsDeployment:"预发布环境部署完成。所有健康检查通过。性能指标:API p99延迟180ms,较上周340ms大幅下降。",strategyMarket:"竞争情报更新:本周两家竞品发布了类似功能。我们的核心优势仍在于自主Agent协调——没有竞品具备多Agent任务委派能力。"},engineering:{sarahArchitecture:"团队,我审阅了支付架构文档。幂等方案看起来很扎实。一个顾虑:高负载下分布式锁过期的情况考虑了吗?",srBackendReply:"好问题。我加了滑动窗口续期机制——当操作还在进行且TTL达到80%时自动延期。PR已更新。",devopsCi:"CI流水线全绿。缓存优化后构建时间降至4分32秒,正在部署到预发布环境。",sarahBuildTime:"构建时间优化得不错。下个迭代目标3分钟。@运维工程师 能看看测试套件并行化吗?",frontendLib:"组件库完成80%。图表、表格、表单、弹窗均已完成,下一步是数据网格。",backendMigration:"Payment v2数据库迁移脚本已就绪。向后兼容的Schema设计——确认零停机部署。",engLeadCodeReview:"PR #127–#134 代码审查完毕,全部通过。@高级后端工程师 准备好后合并支付对账分支。",securityDep:"@高级后端工程师 注意——支付模块发现2个有CVE的传递依赖。jsonwebtoken需要升级到9.x。修补PR马上提交。",qaE2e:"端到端测试套件扩展至312个用例,通过率98.4%。5个不稳定测试是时序问题——已通过重试逻辑修复。全量回归测试已就绪。",sarahShipIt:"大家进展都很出色。目标周三冻结staging环境。发布吧!🚀",engLeadWrapUp:"收到。我已更新Sprint看板——23个任务已完成,4个在审查中,2个被支付模块阻塞。已将阻塞任务指派给高级后端开发优先处理。确认周三冻结staging环境,明天上午我来协调最后一轮代码审查。"},product:{jamesFunnel:"根据@数据分析师的漏斗分析,我们优先推进引导流程重设计。这是Q2的头号项目。",pmMockups:"@UI设计师 周四前能出设计稿吗?我今天准备PRD。",uiDesignerReply:"已经开始了!Figma链接会放到交付物中。新的设计规范也已就绪。",emilyA11y:"方向很好。确保达到无障碍标准——至少WCAG AA。我周四下午审查。",dataAnalystConversion:"新结账流程在A/B测试中转化率提升23%。完整报告已放入交付物。"},alpha:{engLeadSprint:"Alpha冲刺第3天。后端API完成,前端集成已启动。@移动端开发——支付接口已在预发布环境上线。",mobileIntegration:"立即开始集成。支付流程预计2天完成。",jamesTimeline:"时间紧但进度正常。@测试主管 周五前准备好端到端测试计划。这次发布董事会在关注。",qaLeadTestPlan:"测试计划将覆盖支付流程、异常恢复和压力测试。我会和@安全审计员协调上线前的安全扫描。"}},cD={humans:QO,agents:ZO,teams:JO,projects:eD,tasks:tD,taskDesc:nD,requirements:rD,reqDesc:aD,deliverables:sD,delSummary:iD,channels:oD,messages:lD},eY=[{code:"en",label:"English"},{code:"zh-CN",label:"中文"}],uD="common",dD=["common","nav","auth","home","team","work","settings","onboarding","builder","store","agent","deliverables","reports","showcase"];pr.use(s5).use(Y7).init({resources:{en:{common:pC,nav:AC,auth:RC,home:eT,team:mT,work:CT,settings:nA,onboarding:dA,builder:FA,store:aE,agent:bE,deliverables:qE,reports:r9,showcase:g9},"zh-CN":{common:mj,nav:Cj,auth:jj,home:Zj,team:uM,work:SM,settings:eR,onboarding:cR,builder:$R,store:nO,agent:hO,deliverables:PO,reports:XO,showcase:cD}},fallbackLng:"en",defaultNS:uD,ns:[...dD],interpolation:{escapeValue:!1},detection:{order:["localStorage","navigator"],lookupLocalStorage:"markus-language",caches:["localStorage"]}});const mD="modulepreload",fD=function(e){return"/"+e},Yy={},qr=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let m=function(p){return Promise.all(p.map(h=>Promise.resolve(h).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=c?.nonce||c?.getAttribute("nonce");o=m(n.map(p=>{if(p=fD(p),p in Yy)return;Yy[p]=!0;const h=p.endsWith(".css"),g=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${g}`))return;const x=document.createElement("link");if(x.rel=h?"stylesheet":mD,h||(x.as="script"),x.crossOrigin="",x.href=p,d&&x.setAttribute("nonce",d),document.head.appendChild(x),h)return new Promise((y,w)=>{x.addEventListener("load",y),x.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${p}`)))})}))}function l(c){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=c,window.dispatchEvent(d),!d.defaultPrevented)throw c}return o.then(c=>{for(const d of c||[])d.status==="rejected"&&l(d.reason);return t().catch(l)})},me={HOME:"home",TEAM:"team",WORK:"work",STORE:"store",BUILDER:"builder",DELIVERABLES:"deliverables",SETTINGS:"settings",NOTIFICATIONS:"notifications",SEARCH:"search"},pD=new Set(Object.values(me)),hD={dashboard:me.HOME,chat:me.TEAM,projects:me.WORK,usage:me.HOME,reports:me.HOME,prompts:me.BUILDER,templates:me.STORE,agents:me.STORE,skills:me.STORE,teams:me.STORE,knowledge:me.DELIVERABLES,governance:me.SETTINGS},i5={[me.HOME]:"overview",[me.TEAM]:"team",[me.WORK]:"tasks",[me.STORE]:"explore",[me.BUILDER]:"assets",[me.DELIVERABLES]:"output",[me.SETTINGS]:"settings",[me.NOTIFICATIONS]:"notifications",[me.SEARCH]:"search"},Xy=Object.fromEntries(Object.entries(i5).map(([e,t])=>[t,e]));function lh(e){return i5[e]??e}function cc(e){return Xy[e]?Xy[e]:pD.has(e)?e:hD[e]??me.HOME}function uc(){const e=window.location.hash.slice(1).split("/")[0];return cc(e)}function Ni(e,t){const n=lh(e);return t?`#${n}/${t}`:`#${n}`}const o5={[me.STORE]:me.BUILDER},dc={[me.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",[me.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",[me.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",[me.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",[me.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",[me.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",[me.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",[me.NOTIFICATIONS]:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9 M13.73 21a2 2 0 0 1-3.46 0"},gD=[{key:"quick",label:"QUICK"},{key:"workspace",label:"WORKSPACE"},{key:"build",label:"BUILD"},{key:"system",label:"SYSTEM"}],bD=[{id:me.NOTIFICATIONS,label:"Notifications",section:"quick"},{id:me.HOME,label:"Overview",section:"workspace"},{id:me.TEAM,label:"Team",section:"workspace"},{id:me.WORK,label:"Tasks",section:"workspace"},{id:me.DELIVERABLES,label:"Output",section:"workspace"},{id:me.BUILDER,label:"Builder",section:"build"},{id:me.STORE,label:"Store",section:"build"},{id:me.SETTINGS,label:"Settings",section:"system"}],xD=[{id:me.HOME,label:"Overview",group:[me.HOME]},{id:me.TEAM,label:"Team",group:[me.TEAM]},{id:me.NOTIFICATIONS,label:"Notifications",group:[me.NOTIFICATIONS]},{id:me.WORK,label:"Tasks",group:[me.WORK]},{id:me.DELIVERABLES,label:"Output",group:[me.DELIVERABLES]}];let xi=0,Gd=!0;function l5(){return typeof window<"u"?window.markusDesktop?.browser:void 0}function tY(){return xi>0}function nY(){return Gd}function rp(e){Gd!==e&&(Gd=e,e||l5()?.hideAll?.(),window.dispatchEvent(new CustomEvent("markus:native-browser-page",{detail:{allowed:e}})),e&&xi===0&&window.dispatchEvent(new CustomEvent("markus:embedded-browser-resync")))}function yD(){xi+=1,xi===1&&(l5()?.hideAll?.(),window.dispatchEvent(new CustomEvent("markus:native-browser-overlay",{detail:{active:!0}})));let e=!1;return()=>{e||(e=!0,xi=Math.max(0,xi-1),xi===0&&(window.dispatchEvent(new CustomEvent("markus:native-browser-overlay",{detail:{active:!1}})),Gd&&window.dispatchEvent(new CustomEvent("markus:embedded-browser-resync"))))}}const yi="/api";class vD extends Error{code;constructor(t,n){super(t),this.code=n}}const Is=new Map,wD=3e3;function Ya(e){if(!e){Is.clear();return}for(const t of Is.keys())t.startsWith(e)&&Is.delete(t)}async function Y(e,t){const r=(t?.method?.toUpperCase()??"GET")==="GET"&&!t?.body;if(r){const l=Is.get(e);if(l&&Date.now()-l.ts<wD)return l.promise}else{const l=e.replace(/\/[^/]+$/,"");for(const c of Is.keys())(c===e||c.startsWith(l))&&Is.delete(c)}const o=(async()=>{const l=await fetch(`${yi}${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="",d;try{const m=await l.json();c=m.error??m.message??"",d=m.code}catch{}throw new vD(c||`API error: ${l.status}`,d)}return l.json()})();return r&&(Is.set(e,{promise:o,ts:Date.now()}),o.catch(()=>Is.delete(e))),o}const Ce={agents:{list:()=>Y("/agents").then(e=>({...e,agents:e.agents.filter(t=>t.name)})),get:e=>Y(`/agents/${e}`),create:(e,t,n,r)=>Y("/agents",{method:"POST",body:JSON.stringify({name:e,...t?{roleName:t}:{},agentRole:n,teamId:r})}),start:e=>Y(`/agents/${e}/start`,{method:"POST"}),stop:e=>Y(`/agents/${e}/stop`,{method:"POST"}),pause:(e,t)=>Y(`/agents/${e}/stop`,{method:"POST"}),resume:e=>Y(`/agents/${e}/start`,{method:"POST"}),cancelProcessing:e=>Y(`/agents/${e}/cancel-processing`,{method:"POST"}),evolveFromMessage:(e,t)=>Y(`/agents/${e}/evolve-from-message`,{method:"POST",body:JSON.stringify(t)}),remove:(e,t)=>Y(`/agents/${e}${t?.purgeFiles?"?purgeFiles=true":""}`,{method:"DELETE"}),updateConfig:(e,t)=>Y(`/agents/${e}/config`,{method:"PATCH",body:JSON.stringify(t)}),getMemory:e=>Y(`/agents/${e}/memory`),getMemorySession:(e,t)=>Y(`/agents/${e}/memory/sessions/${encodeURIComponent(t)}`),updateDailyMemory:(e,t)=>Y(`/agents/${e}/memory/daily`,{method:"PUT",body:JSON.stringify({content:t})}),updateLongTermMemory:(e,t,n)=>Y(`/agents/${e}/memory/longterm`,{method:"PUT",body:JSON.stringify({key:t,content:n})}),getFiles:e=>Y(`/agents/${e}/files`),getFilesMap:e=>Y(`/agents/${e}/files`),updateFile:(e,t,n)=>Y(`/agents/${e}/files/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({content:n})}),updateSystemPrompt:(e,t)=>Y(`/agents/${e}/system-prompt`,{method:"PUT",body:JSON.stringify({systemPrompt:t})}),roleStatus:e=>Y(`/agents/${e}/role-status`),roleDiff:(e,t="ROLE.md")=>Y(`/agents/${e}/role-diff?file=${encodeURIComponent(t)}`),roleSync:(e,t)=>Y(`/agents/${e}/role-sync`,{method:"POST",body:JSON.stringify(t?{files:t}:{})}),roleSmartSync:(e,t)=>Y(`/agents/${e}/role-smart-sync`,{method:"POST",body:JSON.stringify({file:t})}),roleUpdates:()=>Y("/agents/role-updates"),addSkill:(e,t)=>Y(`/agents/${e}/skills`,{method:"POST",body:JSON.stringify({skillName:t})}),removeSkill:(e,t)=>Y(`/agents/${e}/skills/${encodeURIComponent(t)}`,{method:"DELETE"}),getHeartbeat:e=>Y(`/agents/${e}/heartbeat`),triggerHeartbeat:e=>Y(`/agents/${e}/heartbeat/trigger`,{method:"POST"}),cancelWakeup:(e,t)=>Y(`/agents/${e}/wakeups/${t}`,{method:"DELETE"}),getRecentActivities:e=>Y(`/agents/${e}/recent-activities`),getActivityLogs:(e,t)=>Y(`/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 r=n.toString();return Y(`/agents/${e}/activities${r?"?"+r:""}`)},getMindState:e=>Y(`/agents/${e}/mind`),sendCommand:(e,t,n)=>Y(`/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);const r=n.toString();return Y(`/agents/${e}/mailbox${r?"?"+r:""}`)},getDecisions:(e,t=50)=>Y(`/agents/${e}/decisions?limit=${t}`),messageStream:(e,t,n,r,o,l,c,d,m,p,h,g,x)=>new Promise(async(y,w)=>{let C="",T,S;try{const _=await fetch(`${yi}/agents/${e}/message`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({text:t,stream:!0,images:l,fileNames:h,sessionId:c??void 0,isRetry:d||void 0,isResume:m||void 0,replyTo:g||void 0,...x?.provider&&x?.model?{provider:x.provider,model:x.model}:{}}),signal:o});if(!_.ok){w(new Error(`API error: ${_.status}`));return}const j=_.body?.getReader();if(!j){w(new Error("No reader"));return}const O=new TextDecoder;let P="";for(;;){const{done:D,value:$}=await j.read();if(D)break;P+=O.decode($,{stream:!0});const X=P.split(`
|
|
352
352
|
`);P=X.pop()??"";for(const ee of X){const H=ee.trim();if(H.startsWith("data: "))try{const K=JSON.parse(H.slice(6));if(K.type==="session_start"&&K.sessionId){T=K.sessionId;const ae=K.userMessageId;p?.({type:"session_start",content:"",createdAt:new Date().toISOString(),sessionId:K.sessionId,userMessageId:ae})}else if(K.type==="text_delta"&&K.text)C+=K.text,n(K.text);else if(K.type==="thinking_delta"&&K.thinking)n?.(`<think>${K.thinking}</think>`);else if(K.type==="done"){C=K.content||C,K.sessionId&&(T=K.sessionId);const ae=K.segments;ae&&(S=ae);const W=!!K.merged,F=!!K.cancelled,Z=!!K.emptyReply;y({content:C,sessionId:T,segments:S,merged:W,cancelled:F,emptyReply:Z}),j.cancel().catch(()=>{});return}else if(K.type==="error"){const ae=K;ae.sessionId&&(T=ae.sessionId);const W=new Error(ae.message??ae.error??"Unknown stream error");W.sessionId=ae.sessionId,w(W),j.cancel().catch(()=>{});return}else K.type==="thinking_commit"&&K.thinking?p?.({type:"thinking_commit",content:K.thinking,createdAt:K.createdAt??new Date().toISOString()}):K.type==="text_commit"&&K.text?p?.({type:"text_commit",content:K.text,createdAt:K.createdAt??new Date().toISOString()}):K.type==="tool_call_start"&&K.toolCall?.name?r?.({tool:K.toolCall.name,phase:"start"}):K.type==="agent_tool"&&K.tool&&K.phase?K.phase==="start"?r?.({tool:K.tool,phase:"start",arguments:K.arguments}):K.phase==="end"&&r?.({tool:K.tool,phase:"end",success:K.success,arguments:K.arguments,result:K.result,error:K.error,durationMs:K.durationMs}):K.type==="tool_output"&&K.tool?r?.({tool:K.tool,phase:"output",output:K.text}):K.type==="subagent_progress"&&K.tool?r?.({tool:K.tool,phase:"subagent_progress",subagentEvent:K.subagentEvent}):K.type==="heartbeat"&&r?.({tool:"",phase:"heartbeat"})}catch{}}}y({content:C,sessionId:T,segments:S})}catch(_){_ instanceof Error&&_.name==="AbortError"?y({content:C,sessionId:T,segments:S}):w(_)}})},roles:{list:()=>Y("/roles")},teams:{list:e=>Y(`/teams?orgId=${e??"default"}`),create:(e,t)=>Y("/teams",{method:"POST",body:JSON.stringify({name:e,description:t})}),update:(e,t)=>Y(`/teams/${e}`,{method:"PATCH",body:JSON.stringify(t)}),delete:(e,t,n)=>Y(`/teams/${e}?deleteMembers=${t?"true":"false"}${n?.purgeFiles?"&purgeFiles=true":""}`,{method:"DELETE"}),addMember:(e,t,n)=>Y(`/teams/${e}/members`,{method:"POST",body:JSON.stringify({memberId:t,memberType:n})}),removeMember:(e,t)=>Y(`/teams/${e}/members/${t}`,{method:"DELETE"}),startAll:e=>Y(`/teams/${e}/start`,{method:"POST"}),stopAll:e=>Y(`/teams/${e}/stop`,{method:"POST"}),pauseAll:(e,t)=>Y(`/teams/${e}/stop`,{method:"POST"}),resumeAll:e=>Y(`/teams/${e}/start`,{method:"POST"}),status:e=>Y(`/teams/${e}/status`),getFiles:e=>Y(`/teams/${e}/files`),getFile:(e,t)=>Y(`/teams/${e}/files/${encodeURIComponent(t)}`),updateFile:(e,t,n)=>Y(`/teams/${e}/files/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({content:n})}),exportTeam:e=>Y(`/teams/${e}/export`,{method:"POST"}),getFilesMap:e=>Y(`/teams/${e}/export`)},externalAgents:{list:e=>Y(`/external-agents?orgId=${e??"default"}`)},tasks:{list:e=>{const t=new URLSearchParams;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 Y(`/tasks${n?`?${n}`:""}`)},get:e=>Y(`/tasks/${e}`),create:(e,t,n,r,o,l,c,d,m,p,h)=>Y("/tasks",{method:"POST",body:JSON.stringify({title:e,description:t,assignedAgentId:n,reviewerId:r,priority:o,projectId:l,blockedBy:c,requirementId:d,taskType:m,scheduleConfig:p,reviewerType:h})}),update:(e,t)=>Y(`/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)}),updateStatus:(e,t)=>Y(`/tasks/${e}`,{method:"PUT",body:JSON.stringify({status:t})}),assign:(e,t)=>Y(`/tasks/${e}`,{method:"PUT",body:JSON.stringify({assignedAgentId:t})}),approve:(e,t)=>Y(`/tasks/${e}/approve`,{method:"POST",body:JSON.stringify({runNow:t??void 0})}),reject:e=>Y(`/tasks/${e}/reject`,{method:"POST"}),cancel:(e,t=!1)=>Y(`/tasks/${e}/cancel`,{method:"POST",body:JSON.stringify({cascade:t})}),getDependentCount:e=>Y(`/tasks/${e}/dependents`),board:e=>{const t=new URLSearchParams;e?.projectId&&t.set("projectId",e.projectId);const n=t.toString();return Y(`/taskboard${n?`?${n}`:""}`)},listSubtasks:e=>Y(`/tasks/${e}/subtasks`),createSubtask:(e,t)=>Y(`/tasks/${e}/subtasks`,{method:"POST",body:JSON.stringify({title:t})}),completeSubtask:(e,t)=>Y(`/tasks/${e}/subtasks/${t}/complete`,{method:"POST"}),cancelSubtask:(e,t)=>Y(`/tasks/${e}/subtasks/${t}/cancel`,{method:"POST"}),deleteSubtask:(e,t)=>Y(`/tasks/${e}/subtasks/${t}`,{method:"DELETE"}),run:e=>Y(`/tasks/${e}/run`,{method:"POST"}),getLogs:(e,t)=>Y(`/tasks/${e}/logs${t!=null?`?round=${t}`:""}`),getLogsSummary:e=>Y(`/tasks/${e}/logs/summary`),accept:(e,t)=>Y(`/tasks/${e}/accept`,{method:"POST",body:JSON.stringify({reviewerId:t??"human"})}),revision:(e,t,n)=>Y(`/tasks/${e}/revision`,{method:"POST",body:JSON.stringify({reason:t,reviewerId:n??"human"})}),archive:e=>Y(`/tasks/${e}/archive`,{method:"POST"}),pause:e=>Y(`/tasks/${e}/pause`,{method:"POST"}),resume:e=>Y(`/tasks/${e}/resume`,{method:"POST"}),retry:e=>Y(`/tasks/${e}/retry`,{method:"POST"}),getComments:e=>Y(`/tasks/${e}/comments`),getHistory:e=>Y(`/tasks/${e}/history`),addComment:(e,t,n,r,o,l,c)=>Y(`/tasks/${e}/comments`,{method:"POST",body:JSON.stringify({content:t,authorId:o??"human",authorName:n??"User",authorType:"human",attachments:r,mentions:l,replyTo:c})}),pauseSchedule:e=>Y(`/tasks/${e}/schedule/pause`,{method:"POST"}),resumeSchedule:e=>Y(`/tasks/${e}/schedule/resume`,{method:"POST"}),runNow:e=>Y(`/tasks/${e}/schedule/run-now`,{method:"POST"}),updateSchedule:(e,t)=>Y(`/tasks/${e}/schedule`,{method:"PUT",body:JSON.stringify(t)}),deliverables:e=>{const t=e?`?projectId=${encodeURIComponent(e)}`:"";return Y(`/tasks/deliverables${t}`)}},files:{preview:e=>Y(`/files/preview?path=${encodeURIComponent(e)}`),streamUrl:e=>`${yi}/files/stream?path=${encodeURIComponent(e)}`,reveal:e=>Y("/files/reveal",{method:"POST",body:JSON.stringify({path:e})}),check:e=>Y("/files/check",{method:"POST",body:JSON.stringify({paths:e})}),write:(e,t)=>Y("/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);const n=t.toString();return Y(`/requirements${n?`?${n}`:""}`)},get:e=>Y(`/requirements/${e}`),create:e=>Y("/requirements",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>Y(`/requirements/${e}`,{method:"PUT",body:JSON.stringify(t)}),updateStatus:(e,t)=>Y(`/requirements/${e}/status`,{method:"POST",body:JSON.stringify({status:t})}),approve:e=>Y(`/requirements/${e}/approve`,{method:"POST"}),reject:(e,t)=>Y(`/requirements/${e}/reject`,{method:"POST",body:JSON.stringify({reason:t})}),cancel:e=>Y(`/requirements/${e}/cancel`,{method:"POST"}),delete:e=>Y(`/requirements/${e}`,{method:"DELETE"}),getComments:e=>Y(`/requirements/${e}/comments`),getHistory:e=>Y(`/requirements/${e}/history`),addComment:(e,t,n,r,o,l,c)=>Y(`/requirements/${e}/comments`,{method:"POST",body:JSON.stringify({content:t,authorId:o??"human",authorName:n??"User",authorType:"human",attachments:r,mentions:l,replyTo:c})})},users:{list:e=>Y(`/users?orgId=${e??"default"}`),create:(e,t,n,r,o,l)=>Y("/users",{method:"POST",body:JSON.stringify({name:e,role:t,orgId:n,email:r,password:o,teamId:l})}),update:(e,t)=>Y(`/users/${e}`,{method:"PATCH",body:JSON.stringify(t)}),resetPassword:(e,t)=>Y(`/users/${e}/reset-password`,{method:"POST",body:JSON.stringify({password:t})}),reinvite:e=>Y(`/users/${e}/reinvite`,{method:"POST"}),remove:e=>Y(`/users/${e}`,{method:"DELETE"})},teamTemplates:{list:e=>{const t=e?`?q=${encodeURIComponent(e)}`:"";return Y(`/team-templates${t}`)},get:e=>Y(`/team-templates/${e}`)},ops:{dashboard:(e="24h")=>Y(`/ops/dashboard?period=${e}`)},agentMetrics:(e,t="24h")=>Y(`/agents/${e}/metrics?period=${t}`),usage:{summary:(e="default",t)=>{const n=new URLSearchParams({orgId:e});return t&&n.set("period",t),Y(`/usage?${n}`)},agents:(e="default")=>Y(`/usage/agents?orgId=${e}`)},cu:{status:()=>Y("/cu/status")},health:()=>Y("/health"),system:{openPath:e=>Y("/system/open-path",{method:"POST",body:JSON.stringify({path:e})}),storage:()=>Y("/system/storage"),orphans:()=>Y("/system/storage/orphans"),purgeOrphans:e=>Y("/system/storage/orphans",{method:"DELETE",body:e?JSON.stringify({ids:e}):void 0})},browser:{tabOwnership:()=>Y("/browser/tab-ownership")},settings:{getLlm:()=>Y("/settings/llm"),getOrg:()=>Y("/settings/org"),updateOrg:e=>Y("/settings/org",{method:"PUT",body:JSON.stringify({name:e})}),syncOpenRouter:()=>Y("/settings/llm/sync-openrouter",{method:"POST",body:JSON.stringify({})}),getRouting:()=>Y("/settings/llm/routing"),updateRouting:e=>Y("/settings/llm",{method:"POST",body:JSON.stringify(e)}),getAgent:()=>Y("/settings/agent"),updateAgent:e=>Y("/settings/agent",{method:"POST",body:JSON.stringify(e)}),getBrowser:()=>Y("/settings/browser"),updateBrowser:e=>Y("/settings/browser",{method:"POST",body:JSON.stringify(e)}),testAutoClick:()=>Y("/settings/browser/test-auto-click",{method:"POST"}),downloadExtensionZip:()=>{const e=`${yi}/settings/browser/extension.zip`,t={},n=localStorage.getItem("markus_token");return n&&(t.Authorization=`Bearer ${n}`),fetch(e,{headers:t}).then(r=>{if(!r.ok)throw new Error(`HTTP ${r.status}`);return r.blob()}).then(r=>{const o=document.createElement("a");o.href=URL.createObjectURL(r),o.download="markus-browser-extension.zip",o.click(),URL.revokeObjectURL(o.href)})},openExtensionsPage:()=>Y("/settings/browser/open-extensions-page",{method:"POST"}),testConcurrentBrowserQuick:()=>Y("/settings/browser/test-concurrent",{method:"POST",body:JSON.stringify({mode:"quick"})}),testConcurrentBrowserChaos:async(e,t)=>{const n={"Content-Type":"application/json"},r=localStorage.getItem("markus_token");r&&(n.Authorization=`Bearer ${r}`);const o=await fetch(`${yi}/settings/browser/test-concurrent`,{method:"POST",headers:n,body:JSON.stringify({mode:"chaos",durationSec:e.durationSec??120,agents:e.agents??3})});if(!o.ok)throw new Error(`HTTP ${o.status}`);const l=o.body.getReader(),c=new TextDecoder;let d="";for(;;){const{done:m,value:p}=await l.read();if(m)break;d+=c.decode(p,{stream:!0});const h=d.split(`
|
|
353
353
|
`);d=h.pop()??"";let g="";for(const x of h)if(x.startsWith("event: "))g=x.slice(7).trim();else if(x.startsWith("data: ")){try{t({type:g||"unknown",...JSON.parse(x.slice(6))})}catch{}g=""}}},stopConcurrentBrowserTest:()=>Y("/settings/browser/test-concurrent",{method:"DELETE"}),getSearch:()=>Y("/settings/search"),updateSearch:e=>Y("/settings/search",{method:"POST",body:JSON.stringify(e)}),testSearch:(e,t)=>Y("/settings/search/test",{method:"POST",body:JSON.stringify({provider:e,...t})}),getRemote:()=>Y("/settings/remote"),enableRemote:()=>Y("/settings/remote/enable",{method:"POST"}),disableRemote:()=>Y("/settings/remote/disable",{method:"POST"}),getFeishuIntegration:()=>Y("/settings/integrations/feishu"),saveFeishuIntegration:e=>Y("/settings/integrations/feishu",{method:"POST",body:JSON.stringify(e)}),testFeishuConnection:e=>Y("/settings/integrations/feishu/test",{method:"POST",body:JSON.stringify(e)}),sendFeishuTestMessage:e=>Y("/settings/integrations/feishu/test-message",{method:"POST",body:JSON.stringify(e)}),deleteFeishuIntegration:()=>Y("/settings/integrations/feishu",{method:"DELETE"}),listFeishuChats:()=>Y("/settings/integrations/feishu/chats"),registerFeishuApp:()=>Y("/settings/integrations/feishu/register",{method:"POST"}),getFeishuRegisterStatus:()=>Y("/settings/integrations/feishu/register/status"),getCodingTools:()=>Y("/settings/coding-tools"),updateCodingTools:e=>Y("/settings/coding-tools",{method:"POST",body:JSON.stringify(e)}),detectCodingTools:()=>Y("/settings/coding-tools/detect"),detectCodingTool:e=>Y(`/settings/coding-tools/detect/${e}`),authCodingTool:(e,t,n)=>Y(`/settings/coding-tools/${e}/auth`,{method:"POST",body:JSON.stringify({method:t,apiKey:n})}),listCodingToolModels:e=>Y(`/settings/coding-tools/${e}/models`),testCodingTool:e=>Y(`/settings/coding-tools/${e}/test`,{method:"POST"})},modelCatalog:{getByProvider:e=>Y(`/models/catalog/${e}`),getLive:e=>Y(`/models/live/${e}`),getAll:e=>{const t=e?`?provider=${e}`:"";return Y(`/models/catalog${t}`)},getStatus:()=>Y("/models/catalog/status"),refresh:()=>Y("/models/catalog/refresh",{method:"POST"}),validateKey:(e,t,n)=>Y("/models/validate-key",{method:"POST",body:JSON.stringify({provider:e,apiKey:t,baseUrl:n})})},skills:{list:()=>Y("/skills"),builtin:()=>Y("/skills/builtin"),updates:()=>Y("/skills/updates"),registry:e=>Y(`/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 Y(`/skills/registry/skillhub${n?`?${n}`:""}`)},registrySkillssh:e=>Y(`/skills/registry/skillssh${e?`?q=${encodeURIComponent(e)}`:""}`),import:(e,t,n,r)=>Y("/skills/import",{method:"POST",body:JSON.stringify({name:e,sourceUrl:t,description:n,category:r})}),install:e=>Y("/skills/install",{method:"POST",body:JSON.stringify(e)}),uninstall:e=>Y(`/skills/installed/${encodeURIComponent(e)}`,{method:"DELETE"}),getFilesMap:e=>Y(`/skills/${encodeURIComponent(e)}/files`)},builder:{artifacts:{list:()=>Y("/builder/artifacts"),get:(e,t)=>Y(`/builder/artifacts/${e}s/${encodeURIComponent(t)}`),save:(e,t)=>Y("/builder/artifacts/save",{method:"POST",body:JSON.stringify({mode:e,artifact:t})}),import:(e,t,n,r,o)=>Y("/builder/artifacts/import",{method:"POST",body:JSON.stringify({type:e,name:t,files:n,source:r,version:o})}),install:(e,t)=>Y(`/builder/artifacts/${e}s/${encodeURIComponent(t)}/install`,{method:"POST"}),uninstall:(e,t)=>Y(`/builder/artifacts/${e}s/${encodeURIComponent(t)}/uninstall`,{method:"POST"}),delete:(e,t)=>Y(`/builder/artifacts/${e}s/${encodeURIComponent(t)}`,{method:"DELETE"}),ensureSlug:(e,t)=>Y(`/builder/artifacts/${e}s/${encodeURIComponent(t)}/ensure-slug`,{method:"POST"}),ensureSlugSafe:async(e,t,n)=>{const r=fc(t);if(r&&r===t)return{converted:!1,type:e,name:t,slug:r,displayName:n,path:""};try{return await Ce.builder.artifacts.ensureSlug(e,t)}catch(o){if(r)return{converted:!1,type:e,name:r,slug:r,displayName:n,path:""};throw o}},installed:()=>Y("/builder/artifacts/installed")}},auth:{status:()=>Y("/auth/status"),init:(e,t,n)=>Y("/auth/init",{method:"POST",body:JSON.stringify({name:e,email:t,password:n})}),login:(e,t)=>Y("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:t})}),hubLogin:(e,t)=>Y("/auth/hub-login",{method:"POST",body:JSON.stringify({hubToken:e,hubUser:t})}),logout:()=>Y("/auth/logout",{method:"POST"}),me:()=>Y("/auth/me"),changePassword:(e,t)=>Y("/auth/change-password",{method:"POST",body:JSON.stringify({currentPassword:e,newPassword:t})}),updateProfile:(e,t)=>Y("/auth/profile",{method:"PUT",body:JSON.stringify({name:e,email:t})}),updatePreferences:e=>Y("/auth/me/preferences",{method:"PUT",body:JSON.stringify(e)}),setup:(e,t)=>Y("/auth/setup",{method:"POST",body:JSON.stringify({token:e,password:t})}),inviteInfo:e=>Y(`/auth/invite-info?token=${encodeURIComponent(e)}`),uploadAvatar:(e,t="user",n)=>Y("/avatars/upload",{method:"POST",body:JSON.stringify({image:e,type:t,id:n})})},license:{get:()=>Y("/license"),refresh:()=>Y("/license/refresh",{method:"POST"}),activate:e=>Y("/license/activate",{method:"POST",body:JSON.stringify({licenseKey:e})}),trial:()=>Y("/license/trial",{method:"POST"})},sessions:{hasAny:()=>Y("/sessions/has-any"),listByAgent:(e,t=20)=>Y(`/agents/${e}/sessions?limit=${t}`),getMessages:(e,t=50,n)=>Y(`/sessions/${e}/messages?limit=${t}${n?`&before=${n}`:""}`),delete:e=>Y(`/sessions/${e}`,{method:"DELETE"}),setModelOverride:(e,t)=>Y(`/sessions/${e}/model-override`,{method:"PUT",body:JSON.stringify(t??{provider:"",model:""})}),streamStatus:(e,t)=>Y(`/agents/${e}/sessions/${t}/stream/status`),reattachStream:(e,t,n,r,o=0)=>new Promise(async(l,c)=>{let d="",m=t,p;try{const h=await fetch(`${yi}/agents/${e}/sessions/${t}/stream?afterSeq=${o}`,{method:"GET",credentials:"include",signal:r});if(h.status===204){l({content:"",sessionId:t,attached:!1});return}if(!h.ok){c(new Error(`API error: ${h.status}`));return}const g=h.body?.getReader();if(!g){c(new Error("No reader"));return}const x=new TextDecoder;let y="";for(;;){const{done:w,value:C}=await g.read();if(w)break;y+=x.decode(C,{stream:!0});const T=y.split(`
|
|
354
|
-
`);y=T.pop()??"";for(const S of T){const _=S.trim();if(_.startsWith("data: "))try{const j=JSON.parse(_.slice(6)),O=j.type;if(O==="snapshot"){const P=j.segments??[],D=typeof j.content=="string"?j.content:"";d=D,P.length&&(p=P),n.onSnapshot?.({content:D,segments:P})}else if(O==="text_delta"&&typeof j.text=="string")d+=j.text,n.onChunk?.(j.text);else if(O==="thinking_delta"&&typeof j.thinking=="string")n.onChunk?.(`<think>${j.thinking}</think>`);else if(O==="done"){d=j.content||d,typeof j.sessionId=="string"&&(m=j.sessionId);const P=j.segments;P&&(p=P),l({content:d,sessionId:m,segments:p,attached:!0}),g.cancel().catch(()=>{});return}else if(O==="error"){c(new Error(j.message??j.error??"Stream error")),g.cancel().catch(()=>{});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{}}}l({content:d,sessionId:m,segments:p,attached:!0})}catch(h){c(h)}})},channels:{getMessages:(e,t=50,n)=>Y(`/channels/${encodeURIComponent(e)}/messages?limit=${t}${n?`&before=${n}`:""}`),sendMessage:(e,t)=>Y(`/channels/${encodeURIComponent(e)}/messages`,{method:"POST",body:JSON.stringify(t)})},governance:{getSystemStatus:()=>Y("/system/status"),pauseAll:e=>Y("/system/pause-all",{method:"POST",body:JSON.stringify({reason:e})}),resumeAll:()=>Y("/system/resume-all",{method:"POST"}),emergencyStop:e=>Y("/system/emergency-stop",{method:"POST",body:JSON.stringify({reason:e})}),getAnnouncements:()=>Y("/system/announcements"),createAnnouncement:e=>Y("/system/announcements",{method:"POST",body:JSON.stringify(e)}),getPolicy:()=>Y("/governance/policy"),setPolicy:e=>Y("/governance/policy",{method:"PUT",body:JSON.stringify(e)})},approvals:{list:e=>{const t=e?`?status=${e}`:"";return Y(`/approvals${t}`)},respond:(e,t,n,r,o,l)=>Y(`/approvals/${e}`,{method:"POST",body:JSON.stringify({approved:t,respondedBy:n,comment:r,selectedOption:o,answers:l})})},notifications:{list:(e,t,n)=>{const r=new URLSearchParams;return e&&r.set("userId",e),t&&r.set("unread","true"),n?.type&&r.set("type",n.type),n?.limit&&r.set("limit",String(n.limit)),n?.offset&&r.set("offset",String(n.offset)),Y(`/notifications?${r}`)},create:e=>Y("/notifications",{method:"POST",body:JSON.stringify(e)}),markRead:e=>Y(`/notifications/${e}`,{method:"POST"}),markAllRead:e=>Y("/notifications/mark-all-read",{method:"POST",body:JSON.stringify({userId:e})})},unread:{getCounts:()=>Y("/unread"),markRead:(e,t,n)=>Y("/unread/mark-read",{method:"POST",body:JSON.stringify({conversationKey:e,lastReadAt:t,lastReadId:n})}),markAllRead:()=>Y("/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)),Y(`/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 Y(`/activity${n?`?${n}`:""}`)}},projects:{list:e=>{const t=e?`?orgId=${e}`:"";return Y(`/projects${t}`)},get:e=>Y(`/projects/${e}`),create:e=>Y("/projects",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>Y(`/projects/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>Y(`/projects/${e}`,{method:"DELETE"})},knowledge:{search:(e,t,n)=>{const r=new URLSearchParams;return e&&r.set("query",e),t&&r.set("scope",t),n&&r.set("category",n),Y(`/knowledge/search?${r}`)},contribute:e=>Y("/knowledge",{method:"POST",body:JSON.stringify(e)}),flagOutdated:(e,t)=>Y(`/knowledge/${e}/flag-outdated`,{method:"POST",body:JSON.stringify({reason:t})}),verify:e=>Y(`/knowledge/${e}/verify`,{method:"POST",body:JSON.stringify({verifiedBy:"human"})}),remove:e=>Y(`/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?.offset&&t.set("offset",String(e.offset)),e?.limit&&t.set("limit",String(e.limit)),Y(`/deliverables?${t}`)},get:e=>Y(`/deliverables/${e}`),create:e=>Y("/deliverables",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>Y(`/deliverables/${e}`,{method:"PUT",body:JSON.stringify(t)}),remove:e=>Y(`/deliverables/${e}`,{method:"DELETE"}),verify:e=>Y(`/deliverables/${e}`,{method:"PUT",body:JSON.stringify({status:"verified"})}),checkHealth:e=>{const t=new URLSearchParams;return e&&t.set("agentId",e),Y(`/deliverables/health?${t}`)}},codeReviews:{list:(e,t=20)=>{const n=new URLSearchParams;return e&&n.set("taskId",e),n.set("limit",String(t)),Y(`/reviews?${n}`)},get:e=>Y(`/reviews/${e}`),run:e=>Y("/reviews",{method:"POST",body:JSON.stringify(e)})},reports:{list:()=>Y("/reports"),get:e=>Y(`/reports/${e}`),generate:e=>Y("/reports/generate",{method:"POST",body:JSON.stringify(e)}),approvePlan:(e,t)=>Y(`/reports/${e}/plan/approve`,{method:"POST",body:JSON.stringify(t)}),rejectPlan:(e,t)=>Y(`/reports/${e}/plan/reject`,{method:"POST",body:JSON.stringify(t)}),addFeedback:(e,t)=>Y(`/reports/${e}/feedback`,{method:"POST",body:JSON.stringify(t)}),getFeedback:e=>Y(`/reports/${e}/feedback`)},executionLogs:{get:(e,t)=>Y(`/execution-logs?sourceType=${encodeURIComponent(e)}&sourceId=${encodeURIComponent(t)}`)},groupChats:{list:()=>Y("/group-chats"),create:e=>Y("/group-chats",{method:"POST",body:JSON.stringify(e)}),getById:e=>Y(`/group-chats/${e}`),update:(e,t)=>Y(`/group-chats/${e}`,{method:"PATCH",body:JSON.stringify(t)}),delete:e=>Y(`/group-chats/${e}`,{method:"DELETE"}),addMember:(e,t,n,r)=>Y(`/group-chats/${e}/members`,{method:"POST",body:JSON.stringify({memberId:t,memberType:n,memberName:r})}),removeMember:(e,t)=>Y(`/group-chats/${e}/members/${t}`,{method:"DELETE"})},uploads:{upload:(e,t)=>Y("/uploads",{method:"POST",body:JSON.stringify({files:e,prefix:t})})},hubOrgs:{mine:()=>$t("/orgs/mine"),get:e=>$t(`/orgs/${e}`),update:(e,t)=>$t(`/orgs/${e}`,{method:"PUT",body:JSON.stringify(t)}),create:e=>$t("/orgs",{method:"POST",body:JSON.stringify({name:e})}),members:e=>$t(`/orgs/${e}/members`),invite:(e,t)=>$t(`/orgs/${e}/members`,{method:"POST",body:JSON.stringify(t)}),removeMember:(e,t)=>$t(`/orgs/${e}/members/${t}`,{method:"DELETE"}),updateMemberRole:(e,t,n)=>$t(`/orgs/${e}/members/${t}`,{method:"PATCH",body:JSON.stringify({role:n})}),invitations:()=>$t("/orgs/invitations"),acceptInvitation:e=>$t(`/orgs/${e}/members/accept`,{method:"POST"}),leave:e=>$t(`/orgs/${e}/leave`,{method:"POST"})},workflows:{list:e=>Y(`/teams/${e}/workflows`),get:(e,t)=>Y(`/teams/${e}/workflows/${encodeURIComponent(t)}`),create:(e,t,n)=>Y(`/teams/${e}/workflows`,{method:"POST",body:JSON.stringify({name:t,yaml:n})}),update:(e,t,n)=>Y(`/teams/${e}/workflows/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({yaml:n})}),remove:(e,t)=>Y(`/teams/${e}/workflows/${encodeURIComponent(t)}`,{method:"DELETE"}),roles:(e,t)=>Y(`/teams/${e}/workflows/${encodeURIComponent(t)}/roles`),listRuns:(e,t,n)=>Y(`/teams/${e}/workflows/${encodeURIComponent(t)}/runs${n?`?limit=${n}`:""}`),startRun:(e,t,n,r,o)=>Y(`/teams/${e}/workflows/${encodeURIComponent(t)}/runs`,{method:"POST",body:JSON.stringify({projectId:n,params:r,roleMapping:o})}),getRun:e=>Y(`/workflow-runs/${e}`),cancelRun:e=>Y(`/workflow-runs/${e}`,{method:"DELETE"}),pauseRun:e=>Y(`/workflow-runs/${e}/pause`,{method:"POST"}),resumeRun:e=>Y(`/workflow-runs/${e}/resume`,{method:"POST"})}};function rY(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 aY(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 Jl{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:",r=new URLSearchParams;this.currentUserId&&r.set("userId",this.currentUserId),this.lastEventTimestamp&&r.set("since",this.lastEventTimestamp);const o=r.toString(),l=`${n}//${window.location.host}/ws${o?`?${o}`:""}`,c=new WebSocket(l);this.ws=c,c.onopen=()=>{this.reconnectAttempts=0,this.startHeartbeat(c)},c.onmessage=d=>{if(this.ws===c)try{const m=JSON.parse(d.data);if(m.timestamp&&(this.lastEventTimestamp=m.timestamp),m.type==="pong")return;const p=this.handlers.get(m.type);if(p)for(const g of p)g(m);const h=this.handlers.get("*");if(h)for(const g of h)g(m)}catch{}},c.onclose=()=>{if(this.stopHeartbeat(),this.intentionalClose)return;const d=Math.min(Jl.BACKOFF_BASE*Math.pow(2,this.reconnectAttempts),Jl.BACKOFF_MAX);this.reconnectAttempts++,this.reconnectTimer=setTimeout(()=>this.connect(this.currentUserId),d)},c.onerror=()=>{c.close()}}startHeartbeat(t){this.stopHeartbeat(),this.heartbeatTimer=setInterval(()=>{t.readyState===WebSocket.OPEN&&t.send(JSON.stringify({type:"ping"}))},Jl.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 va=new Jl;let k0=window.__MARKUS_HUB_URL__??"https://markus.global",Rd=null;async function ch(){if(!yn())return null;try{const e=await $t("/auth/me");if(e?.user?.id){const t=yn();return Wd(t,e.user),e.user}}catch{}return sa()}async function c5(){if(!window.__MARKUS_PREVIEW__)try{const e=await Y("/settings/hub");e.hubUrl&&(k0=e.hubUrl)}catch{}}function kD(){return Rd||(Rd=c5().finally(()=>{})),Rd}window.__MARKUS_PREVIEW__||(Rd=c5().then(async()=>{const e=localStorage.getItem("markus_hub_token");if(e)Y("/settings/hub-token",{method:"POST",body:JSON.stringify({token:e})}).catch(()=>{}),ch();else try{const t=await Y("/settings/hub-token");t.token&&(localStorage.setItem("markus_hub_token",t.token),await ch())}catch{}}).catch(()=>{}));const mc="markus_hub_token",Vd="markus_hub_user";function yn(){return localStorage.getItem(mc)}async function SD(){const e=yn();if(e)return e;try{const t=await Y("/settings/hub-token");if(t.token)return localStorage.setItem(mc,t.token),ch(),t.token}catch{}return null}function sa(){try{const e=localStorage.getItem(Vd);return e?JSON.parse(e):null}catch{return null}}function Kd(e,t){if(e.purchasedByCurrentUser||t?.has(e.id))return!0;const n=sa();if(!n?.id)return!1;const r=e.author?.id??e.authorId;return!!r&&r===n.id}function _o(){localStorage.removeItem(mc),localStorage.removeItem(Vd),u5(null),window.dispatchEvent(new CustomEvent("markus:hub-auth"))}function Wd(e,t){const n=localStorage.getItem(mc),r=localStorage.getItem(Vd),o=JSON.stringify(t);n===e&&r===o||(localStorage.setItem(mc,e),localStorage.setItem(Vd,o),u5(e),window.dispatchEvent(new CustomEvent("markus:hub-auth")))}function u5(e){Y("/settings/hub-token",{method:"POST",body:JSON.stringify({token:e})}).catch(()=>{})}async function ND(e){e.openrouter?.key&&await Y("/settings/subscription-key",{method:"POST",body:JSON.stringify({openrouter:e.openrouter})}).catch(()=>{})}async function Jh(e){try{return await Y(`/hub/auth/connect-status?session=${encodeURIComponent(e)}&_t=${Date.now()}`)}catch{return null}}async function eg(e){!e.token||!e.user||(Wd(e.token,e.user),e.openrouter?.key&&await ND({openrouter:e.openrouter}),CD())}async function CD(){if(yn())try{const{org:e}=await Y("/settings/org"),t=e?.name?.trim();if(!t||t==="My Organization")return;const r=((await $t("/orgs/mine")).orgs??[]).find(o=>o.role==="owner");if(!r||r.name===t)return;await $t(`/orgs/${r.id}`,{method:"PUT",body:JSON.stringify({name:t})})}catch{}}function d5(){return window.markusDesktop}async function TD(e,t=12e4){const n=Date.now()+t;for(;Date.now()<n;){const r=await Jh(e);if(r?.ready&&r.token&&r.user)return await eg(r),!0;await new Promise(o=>setTimeout(o,1200))}return!1}let Od=null;d5()?.onDeepLinkAuth?.(e=>{Od?.(e?.session??"")});let Yd=null;function AD(){Yd?.(),gi=null}function ED(e,t,n){return new Promise((r,o)=>{let l=!1,c=!1;const d=(C,T)=>{l||(l=!0,Yd=null,clearInterval(y),clearTimeout(w),window.removeEventListener("focus",h),document.removeEventListener("visibilitychange",g),Od===p&&(Od=null),C?(n.focusWindow?.(),r()):o(T))};Yd=()=>d(!1,new Error("Hub login cancelled"));const m=async()=>{if(!(l||c)){c=!0;try{const C=await Jh(e);C?.ready&&C.token&&C.user&&(await eg(C),d(!0))}finally{c=!1}}},p=C=>{(!C||C===e)&&m()};Od=p;const h=()=>{m()},g=()=>{document.visibilityState==="visible"&&m()};window.addEventListener("focus",h),document.addEventListener("visibilitychange",g);let x=`${k0}/auth/connect?session=${encodeURIComponent(e)}&redirect=${encodeURIComponent("markus://auth")}`;t&&(x+=`&method=${encodeURIComponent(t)}`),Promise.resolve(n.openExternal(x)).then(()=>{m()}).catch(C=>{d(!1,C instanceof Error?C:new Error("Failed to open browser"))});const y=setInterval(()=>{m()},1500),w=setTimeout(()=>d(!1,new Error("Hub login timed out")),5*6e4)})}function _D(e,t){return new Promise((n,r)=>{let o=`${k0}/auth/connect?session=${encodeURIComponent(e)}`;t&&(o+=`&method=${encodeURIComponent(t)}`);const l=460,c=580,d=Math.round(window.screenX+(window.outerWidth-l)/2),m=Math.round(window.screenY+(window.outerHeight-c)/2),p=window.open(o,"markus_hub_auth",`popup=yes,width=${l},height=${c},left=${d},top=${m}`);if(!p){r(new Error("Popup blocked by browser. Please allow popups for this site."));return}let h=!1,g=null;const x=()=>{clearInterval(w),clearInterval(T),g&&clearInterval(g),document.removeEventListener("visibilitychange",C)},y=async()=>{if(h)return;const S=await Jh(e);S?.ready&&S.token&&S.user&&(h=!0,await eg(S),x(),p?.close(),n())},w=setInterval(()=>{y()},1500),C=()=>{!h&&document.visibilityState==="visible"&&y()};document.addEventListener("visibilitychange",C);const T=setInterval(()=>{if(!h&&p?.closed){clearInterval(T);let S=0;g=setInterval(async()=>{if(h){clearInterval(g);return}S++,await y(),S>=5&&!h&&(h=!0,x(),yn()?n():r(new Error("Hub login cancelled")))},1e3)}},500)})}let gi=null;function na(e){const t=typeof e=="string"?{method:e}:e??{};if(t.force)Yd?.(),gi=null,(yn()||sa())&&_o();else if(yn())return Promise.resolve();if(gi)return gi;const n=`cs_${Date.now()}_${Math.random().toString(36).slice(2,10)}`,r=d5(),o=(async()=>{await kD(),r?await ED(n,t.method,r):await _D(n,t.method)})();return gi=o,o.catch(()=>{}).finally(()=>{gi===o&&(gi=null)}),o}async function $t(e,t){const n=yn(),r={"Content-Type":"application/json",...t?.headers};n&&(r.Authorization=`Bearer ${n}`);const o=await fetch(`${yi}/hub${e}`,{...t,headers:r,credentials:"include"}),l=await o.json();if(o.status===401&&n&&_o(),!o.ok){const c=new Error(l.error??`Hub HTTP ${o.status}`);throw c.code=typeof l.code=="string"?l.code:void 0,c.retryAfterSeconds=typeof l.retryAfterSeconds=="number"?l.retryAfterSeconds:void 0,c.status=o.status,c}return l}async function m5(){if(!yn())return!1;try{return await $t("/user/plan"),!0}catch{return!1}}const it={getUrl:()=>k0,isAuthenticated:()=>!!yn(),getUser:sa,logout:()=>{_o()},ensureAuth:na,validateSession:m5,login:async(e,t)=>{const n=await $t("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:t})});return Wd(n.token,n.user),n},register:async(e,t,n)=>{const r=await $t("/auth/register",{method:"POST",body:JSON.stringify({username:e,email:t,password:n})});return Wd(r.token,r.user),r},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 $t(`/items${n?`?${n}`:""}`)},getItem:e=>$t(`/items/${e}`),download:async e=>{await na();try{return await $t(`/items/${e}/download`,{method:"POST"})}catch(t){if(!yn())return await na(),$t(`/items/${e}/download`,{method:"POST"});throw t}},publish:async e=>{await na();try{return await $t("/items",{method:"POST",body:JSON.stringify(e)})}catch(t){if(!yn())return await na(),$t("/items",{method:"POST",body:JSON.stringify(e)});throw t}},uploadImage:async e=>{await na();try{const t=new FormData;t.append("file",e);const n=await fetch("/api/hub/upload",{method:"POST",credentials:"include",headers:{Authorization:`Bearer ${yn()}`},body:t});return n.ok?await n.json():null}catch{return null}},publishViaProxy:async e=>{await na();try{return await $t("/items",{method:"POST",body:JSON.stringify(e)})}catch(t){if(!yn())return await na(),$t("/items",{method:"POST",body:JSON.stringify(e)});throw t}},updateItem:async(e,t)=>(await na(),$t(`/items/${e}`,{method:"PUT",body:JSON.stringify(t)})),myItems:async()=>yn()?$t("/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 $t(`/items${n?`?${n}`:""}`)},myOrgs:async()=>yn()?$t("/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 na(),$t(`/items/${e}`,{method:"DELETE"})),purchases:{checkout:e=>$t("/purchases/checkout",{method:"POST",body:JSON.stringify({itemId:e})}),payWithEarnings:e=>$t("/purchases/pay-with-earnings",{method:"POST",body:JSON.stringify({itemId:e})}),mine:()=>$t("/purchases/mine")},creator:{getBalance:()=>$t("/creator/balance")},user:{plan:()=>$t("/user/plan"),cuStats:(e=30,t="day")=>$t(`/user/cu/stats?days=${e}&granularity=${t}`),claimFreeCreditsStatus:()=>$t("/user/claim-free-credits"),claimFreeCredits:()=>$t("/user/claim-free-credits",{method:"POST"})}},jD=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;function f5(e){return typeof e=="string"&&e.length>=2&&e.length<=64&&jD.test(e)}function fc(e){const t=e.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-+|-+$/g,"");return f5(t)?t:null}function Xd(e,t){const n=fc(e);if(n)return n;if(t){const o=fc(t);if(o)return o;if(f5(t))return t}let r=0;for(let o=0;o<e.length;o++)r=(r<<5)-r+e.charCodeAt(o)|0;return`pkg-${Math.abs(r).toString(36)}`}let Qy=null;const at={setHandler(e){Qy=e},navigate(e,t){t&&Object.entries(t).forEach(([n,r])=>localStorage.setItem(`markus_nav_${n}`,r)),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:e,params:t}})),Qy?.(e,t)}};let p5=uc();const uh=new Set;function Zy(){p5=uc(),uh.forEach(e=>e())}typeof window<"u"&&(window.addEventListener("hashchange",Zy),window.addEventListener("popstate",Zy));function MD(e){return uh.add(e),()=>uh.delete(e)}function RD(e){return k.useSyncExternalStore(MD,()=>p5===e,()=>!1)}var Sa=K4();function zo(e){k.useEffect(()=>yD(),[e])}function dr({title:e,message:t,confirmLabel:n,cancelLabel:r,variant:o="danger",alertOnly:l=!1,checkboxes:c,onConfirm:d,onCancel:m,onCancelClick:p}){const{t:h}=dt("common");zo(!0);const[g,x]=k.useState(()=>{const C={};for(const T of c??[])C[T.id]=T.defaultChecked??!1;return C}),y=o==="primary",w=y?"px-4 py-1.5 text-sm bg-brand-600 hover:bg-brand-500 text-white 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 Sa.createPortal(s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10050] p-4",onClick:m,children:s.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:[s.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[s.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?s.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:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"M12 16v-4"}),s.jsx("path",{d:"M12 8h.01"})]}):s.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:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),s.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}),s.jsxs("div",{className:"min-w-0 pt-0.5",children:[s.jsx("h3",{className:"font-semibold text-base text-fg-primary",children:e}),s.jsx("p",{className:"text-sm text-fg-secondary mt-1 leading-relaxed",children:t})]})]}),c&&c.length>0&&s.jsx("div",{className:"mb-4 space-y-2",children:c.map(C=>s.jsxs("label",{className:"flex items-center gap-2 text-sm text-fg-secondary cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:g[C.id]??!1,onChange:T=>x(S=>({...S,[C.id]:T.target.checked})),className:"rounded bg-surface-elevated border-border-default"}),C.label]},C.id))}),s.jsxs("div",{className:"flex justify-end gap-2",children:[!l&&s.jsx("button",{type:"button",onClick:()=>{p?p(c?g: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:r??h("cancel")}),s.jsx("button",{type:"button",onClick:()=>d(c?g:void 0),className:w,children:n??h(l?"ok":"confirm")})]})]})}),document.body)}function h5(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 r=it.getUrl()?.replace(/\/$/,"")||"";return r?`${r}${n}`:n}return n}function g5({size:e,className:t=""}){const n=Math.max(12,Math.round(e*.55));return s.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:s.jsxs("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),s.jsx("circle",{cx:"12",cy:"7",r:"4"})]})})}function Us({name:e,avatarUrl:t,size:n=28,className:r="",bgClass:o="bg-brand-600",fallback:l="initials"}){const[c,d]=k.useState(!1);if(k.useEffect(()=>{d(!1)},[t]),!!t&&!c)return s.jsx("img",{src:t,alt:e??"",className:`rounded-full object-cover shrink-0 ${r}`,style:{width:n,height:n},onError:()=>d(!0)});if(l==="icon")return s.jsx(g5,{size:n,className:r});const p=e?.[0]?.toUpperCase()??"?",h=n<=20?"text-[8px]":n<=28?"text-xs":n<=40?"text-sm":"text-lg",g=/\btext-(?!white\b)/.test(o);return s.jsx("div",{className:`rounded-full ${o} flex items-center justify-center ${g?"":"text-white"} ${h} font-bold shrink-0 ${r}`,style:{width:n,height:n},children:p})}function b5({currentUrl:e,name:t,size:n=64,targetType:r="user",targetId:o,onUploaded:l}){const{t:c}=dt("common"),[d,m]=k.useState(null),[p,h]=k.useState(!1),[g,x]=k.useState(!1),[y,w]=k.useState(null),C=k.useRef(null),T=d??e;k.useEffect(()=>{x(!1)},[T]);const S=!!T&&!g,_=k.useCallback(async j=>{if(!j.type.startsWith("image/"))return;if(j.size>2*1024*1024){w(c("imageTooLarge"));return}const O=new FileReader;O.onload=async()=>{const P=O.result;m(P),x(!1),h(!0);try{const{avatarUrl:D}=await Ce.auth.uploadAvatar(P,r,o);l?.(D)}catch{m(null)}finally{h(!1)}},O.readAsDataURL(j)},[r,o,l,c]);return s.jsxs("div",{className:"relative inline-block group",children:[s.jsx("input",{ref:C,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",className:"hidden",onChange:j=>{const O=j.target.files?.[0];O&&_(O)}}),s.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:"Click to set avatar",children:[S?s.jsx("img",{src:T,alt:t??"",className:"w-full h-full object-cover",onError:()=>x(!0)}):s.jsx(g5,{size:n}),s.jsx("div",{className:"absolute inset-0 bg-black/40 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:p?s.jsx("div",{className:"w-5 h-5 border-2 border-white/60 border-t-white rounded-full animate-spin"}):s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.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"}),s.jsx("circle",{cx:"12",cy:"13",r:"4"})]})})]}),y&&s.jsx(dr,{alertOnly:!0,variant:"danger",title:c("error",{defaultValue:"Error"}),message:y,onConfirm:()=>w(null),onCancel:()=>w(null)})]})}function OD({authUser:e,onNavigate:t}){const{t:n}=dt(["settings","common","nav"]),[r,o]=k.useState(!1);k.useEffect(()=>{const c=()=>o(!0);return window.addEventListener("markus:open-drawer",c),()=>window.removeEventListener("markus:open-drawer",c)},[]),k.useEffect(()=>(r?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[r]);const l=c=>{if(o(!1),c==="__edit_profile"){window.dispatchEvent(new CustomEvent("markus:open-edit-profile"));return}t(c)};return r?s.jsxs("div",{className:"fixed inset-0 z-[100]",children:[s.jsx("div",{className:"absolute inset-0 bg-black/40 animate-fadeIn",onClick:()=>o(!1)}),s.jsxs("aside",{className:"absolute inset-y-0 left-0 w-72 bg-surface-secondary shadow-2xl flex flex-col animate-slideInLeft",children:[s.jsx("div",{className:"px-5 pt-6 pb-4 border-b border-border-default",children:e?s.jsxs("button",{onClick:()=>l("__edit_profile"),className:"flex items-center gap-3 w-full text-left",children:[s.jsx(Us,{name:e.name||"User",avatarUrl:e.avatarUrl,size:40}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:e.name||n("common:userPlaceholder")}),s.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:e.email||e.role})]}),s.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:s.jsx("polyline",{points:"9 18 15 12 9 6"})})]}):s.jsx("div",{className:"text-sm text-fg-tertiary",children:n("common:loading")})}),s.jsxs("nav",{className:"flex-1 overflow-y-auto py-3 px-3 space-y-1",children:[s.jsx(ap,{icon:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),s.jsx("polyline",{points:"9 22 9 12 15 12 15 22"})]}),label:n("common:home",{defaultValue:"Home"}),onClick:()=>l(me.HOME)}),s.jsx(ap,{icon:s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:dc[me.BUILDER]})}),label:n("nav:builder"),onClick:()=>l(me.BUILDER)}),s.jsx(ap,{icon:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.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:n("settings:title"),onClick:()=>l(me.SETTINGS)})]})]})]}):null}function ap({icon:e,label:t,onClick:n}){return s.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,s.jsx("span",{children:t})]})}function DD(){window.dispatchEvent(new CustomEvent("markus:open-drawer"))}function x5({className:e=""}){return s.jsx("button",{onClick:DD,className:`p-1.5 -ml-1 rounded-lg hover:bg-surface-overlay transition-colors shrink-0 ${e}`,"aria-label":"Menu",children:s.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),s.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),s.jsx("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]})})}function pc(){return!!window.markusDesktop}function Ai(e){window.markusDesktop?window.markusDesktop.openExternal(e):window.open(e,"_blank","noopener,noreferrer")}function LD({onClose:e,onClaimed:t}){const{t:n}=dt(["home","common"]);zo(!0);const[r,o]=k.useState("loading"),[l,c]=k.useState(1e3),[d,m]=k.useState(""),p=k.useRef(t);p.current=t;const h=k.useRef(!1),g=()=>`${it.getUrl().replace(/\/$/,"")}/settings?tab=overview&claim=1`,x=k.useCallback(async()=>{o("loading"),m("");try{yn()||await na();const w=await it.user.claimFreeCreditsStatus();if(typeof w.amountCu=="number"&&w.amountCu>0&&c(w.amountCu),w.claimed){o("already"),p.current();return}o("open_hub")}catch(w){m(w instanceof Error?w.message:n("claim.loadFailed")),o("error")}},[n]);k.useEffect(()=>{h.current||(h.current=!0,x())},[x]);const y=()=>{const w=g();pc()?Ai(w):window.open(w,"_blank","noopener,noreferrer")};return s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60] p-4",onClick:e,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-2xl p-6 w-full max-w-md shadow-2xl",onClick:w=>w.stopPropagation(),children:[s.jsxs("div",{className:"flex items-start justify-between gap-3 mb-4",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"font-semibold text-lg text-fg-primary",children:n("claim.title")}),s.jsx("p",{className:"text-sm text-fg-secondary mt-1 leading-relaxed",children:n("claim.subtitle")})]}),s.jsx("button",{type:"button",onClick:e,className:"text-fg-tertiary hover:text-fg-primary text-lg leading-none",children:"×"})]}),r==="loading"&&s.jsx("p",{className:"text-sm text-fg-tertiary mb-5",children:n("claim.loading")}),r==="already"&&s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-emerald-400",children:n("claim.success",{amount:l.toLocaleString()})}),s.jsx("p",{className:"text-sm text-fg-secondary",children:n("claim.startUsing")}),s.jsx("button",{type:"button",onClick:e,className:"w-full py-2.5 text-sm font-medium rounded-xl bg-brand-500 text-white hover:bg-brand-600",children:n("common:close")})]}),r==="open_hub"&&s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-fg-secondary leading-relaxed",children:n("claim.openHubHint",{amount:l.toLocaleString()})}),s.jsx("button",{type:"button",onClick:y,className:"w-full py-2.5 text-sm font-medium rounded-xl bg-brand-500 text-white hover:bg-brand-600",children:n("claim.openHub")})]}),r==="error"&&s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:"text-sm text-red-400",children:d}),s.jsx("button",{type:"button",onClick:()=>{x()},className:"w-full py-2 text-sm rounded-xl border border-border-default",children:n("claim.retry")})]})]})})}function y5(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 Qd(e){return e.toLocaleString(void 0,{maximumFractionDigits:0})}function ID(e,t,n){const[r,o]=k.useState([]),[l,c]=k.useState(null),[d,m]=k.useState(null),[p,h]=k.useState(it.isAuthenticated()),g=k.useCallback(async()=>{try{const w=await Ce.usage.agents();o(w.agents)}catch{}},[]),x=k.useCallback(async()=>{if(!it.isAuthenticated()){h(!1),m(null);return}h(!0);try{const[w,C]=await Promise.all([it.user.plan(),Ce.hubOrgs.mine().catch(()=>null)]);c(w);const T=C?.orgs?.find(S=>S.id===w.orgId)??C?.orgs?.[0];m(T?{role:T.role,memberCount:T.memberCount??1}:null)}catch{}},[]);return k.useEffect(()=>{if(!e)return;g(),x();const w=setInterval(g,3e4),C=()=>{g(),x()};return window.addEventListener("markus:data-changed",C),()=>{clearInterval(w),window.removeEventListener("markus:data-changed",C)}},[e,g,x]),{contributors:k.useMemo(()=>{const w=[],C=new Map;for(const S of n)for(const _ of S.members)C.set(_.id,S.name);const T=new Map((t?.agentEfficiency??[]).map(S=>[S.agentId,S]));for(const S of r){const _=T.get(S.agentId),j=S.cuUsed??0,O=S.totalTokens,P=_?.taskMetrics.completed??0,D=O>0?P/O*1e3:P>0?1/0:0;w.push({id:S.agentId,name:S.agentName,type:"agent",role:S.role,teamName:C.get(S.agentId),status:S.status,tasksCompleted:P,tasksFailed:_?.taskMetrics.failed??0,cuUsed:j,cuUsedToday:S.cuUsedToday??0,totalTokens:O,tokensToday:S.tokensUsedToday,requestCount:S.requestCount,toolCalls:S.toolCalls,healthScore:_?.healthScore??0,efficiency:D,provider:S.provider})}return w.sort((S,_)=>_.cuUsed+_.tasksCompleted*100-(S.cuUsed+S.tasksCompleted*100)===0?_.totalTokens-S.totalTokens:_.cuUsed+_.tasksCompleted*100-(S.cuUsed+S.tasksCompleted*100)),w},[r,t,n]),hubPlan:l,hubOrgMeta:d,hubConnected:p}}function dh({title:e,badge:t,children:n}){const{t:r}=dt("home"),[o,l]=k.useState(!1);return s.jsxs("section",{className:`bg-surface-elevated shadow-sm rounded-2xl ${o?"overflow-visible":"overflow-hidden"}`,children:[s.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":o,children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg-primary truncate",children:e}),t]}),s.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-fg-tertiary shrink-0",children:[s.jsx("span",{className:"hidden sm:inline",children:r(o?"usage.trends.collapse":"usage.trends.expand")}),s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`transition-transform ${o?"rotate-180":""}`,children:s.jsx("polyline",{points:"6 9 12 15 18 9"})})]})]}),o&&s.jsx("div",{className:"rounded-b-2xl overflow-visible",children:n})]})}function PD({hubConnected:e,hubPlan:t,hubOrgMeta:n}){const{t:r}=dt("home"),o=sa();if(!e)return s.jsxs("div",{className:"px-4 sm:px-5 pb-4 flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-500 shrink-0"}),s.jsx("span",{className:"text-sm text-fg-tertiary",children:r("usage.quota.notConnected")})]}),s.jsx("button",{onClick:()=>it.ensureAuth().catch(()=>{}),className:"px-3 py-1.5 text-xs font-medium bg-brand-600 text-white rounded-lg hover:bg-brand-500 transition-colors shrink-0",children:r("usage.quota.connect")})]});if(!t)return s.jsx("div",{className:"px-4 sm:px-5 pb-4 text-sm text-fg-tertiary",children:r("usage.trends.noData")});const l=t.memberCuLimit!=null&&t.memberCuLimit>0,c=!n||n.role==="owner"||n.role==="admin"||n.memberCount<=1,d=l&&!c,m=l?t.memberCuLimit:(t.monthlyQuotaCu??0)+(t.bonusCu??0)+(t.purchasedCu??0),p=l?t.memberCuUsed??0:t.totalConsumedThisPeriod??(t.monthlyQuotaCu??0)+(t.bonusCu??0)+(t.purchasedCu??0)-Math.max(0,(t.monthlyQuotaCu??0)-(t.cuUsed??0))-(t.bonusCu??0)-(t.purchasedCu??0),h=m>0?Math.min(100,Math.round(p/m*100)):0,g=h>90?"bg-red-500":h>70?"bg-amber-500":"bg-brand-500",x=()=>{Ai(`${it.getUrl().replace(/\/$/,"")}/settings?tab=billing`)};return s.jsxs("div",{className:"px-4 sm:px-5 pb-4",children:[d&&s.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:r("usage.quota.personalLimit")}),s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"text-xs font-semibold text-fg-secondary",children:r(l&&!c?"usage.quota.personalLimitLabel":"usage.quota.title")}),s.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}),o?.username&&s.jsx("span",{className:"text-[10px] text-fg-tertiary truncate",children:r("usage.quota.connectedAs",{username:o.username})})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3 text-[10px] text-fg-tertiary",children:[s.jsx("span",{children:t.cuResetAt?r("usage.quota.resetsAt",{date:new Date(t.cuResetAt).toLocaleDateString()}):""}),s.jsx("button",{type:"button",className:"px-2 py-1 bg-brand-600 text-white rounded hover:bg-brand-500 transition-colors font-medium",onClick:y=>{y.stopPropagation(),x()},children:r("usage.quota.topUp")})]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"flex-1 h-2 bg-surface-overlay rounded-full overflow-hidden",children:s.jsx("div",{className:`h-full rounded-full transition-all ${g}`,style:{width:`${h}%`}})}),s.jsxs("span",{className:"text-xs text-fg-secondary tabular-nums shrink-0",children:[Qd(p)," / ",Qd(m)]})]})]})}function zD({contributors:e}){const{t}=dt("home"),[n,r]=k.useState("totalTokens"),[o,l]=k.useState(!0),[c,d]=k.useState(!1),m=10,p=S=>{n===S?l(!o):(r(S),l(!0))},h=k.useMemo(()=>[...e].sort((S,_)=>{const j=S[n]===1/0?999999:S[n],O=_[n]===1/0?999999:_[n];return o?O-j:j-O}),[e,n,o]),g=c?h:h.slice(0,m),x=Math.max(1,...e.map(S=>S.totalTokens)),y=e.some(S=>S.cuUsed>0),w=new Set(e.filter(S=>S.provider).map(S=>S.provider)),T=w.size>1||w.size===1&&!w.has("markus")?s.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?s.jsx(dh,{title:t("usage.agents.title"),children:s.jsx("div",{className:"px-4 sm:px-5 pb-6 text-center",children:s.jsx("p",{className:"text-sm text-fg-tertiary",children:t("usage.agents.noData")})})}):s.jsxs(dh,{title:t("usage.agents.title"),badge:T,children:[s.jsx("div",{className:"overflow-x-auto scrollbar-thin border-t border-border-default",children:s.jsxs("table",{className:"w-full min-w-[520px]",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border-default text-xs text-fg-tertiary uppercase tracking-wider",children:[s.jsx("th",{className:"px-3 sm:px-4 py-3 text-left font-medium w-8",children:"#"}),s.jsx("th",{className:"px-3 sm:px-4 py-3 text-left font-medium",children:t("usage.agents.name")}),s.jsx("th",{className:"px-3 sm:px-4 py-3 text-left font-medium hidden sm:table-cell",children:t("usage.agents.team")}),s.jsx(Vu,{label:t("usage.agents.tasks"),col:"tasksCompleted",current:n,desc:o,onSort:p}),s.jsx(Vu,{label:t("usage.agents.tokens"),col:"totalTokens",current:n,desc:o,onSort:p}),y&&s.jsx(Vu,{label:t("usage.agents.cuUsed"),col:"cuUsed",current:n,desc:o,onSort:p}),s.jsx(Vu,{label:t("usage.agents.efficiency"),col:"efficiency",current:n,desc:o,onSort:p,align:"right"})]})}),s.jsx("tbody",{children:g.map((S,_)=>s.jsx(BD,{contributor:S,rank:_+1,maxTokens:x,showCu:y},S.id))}),s.jsx("tfoot",{children:s.jsxs("tr",{className:"border-t border-border-default bg-surface-elevated/30",children:[s.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})}),s.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})}),s.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:e.reduce((S,_)=>S+_.tasksCompleted,0)}),s.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:y5(e.reduce((S,_)=>S+_.totalTokens,0))}),y&&s.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:Qd(e.reduce((S,_)=>S+_.cuUsed,0))}),s.jsx("td",{})]})})]})}),h.length>m&&s.jsx("button",{type:"button",onClick:()=>d(S=>!S),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:h.length})})]})}function BD({contributor:e,rank:t,maxTokens:n,showCu:r}){const o=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)}`:"∞",d=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 s.jsxs("tr",{className:"border-b border-border-default/50 hover:bg-surface-elevated/30 transition-colors cursor-pointer",onClick:()=>at.navigate(me.TEAM,{selectAgent:e.id}),children:[s.jsx("td",{className:`px-3 sm:px-4 py-3 text-sm tabular-nums ${d}`,children:t}),s.jsx("td",{className:"px-3 sm:px-4 py-3",children:s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsx("div",{className:`w-2 h-2 rounded-full ${l} shrink-0`}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:e.name}),m&&s.jsx("span",{className:"px-1 py-0.5 rounded text-[8px] font-medium bg-surface-overlay text-fg-tertiary shrink-0",children:m})]}),s.jsxs("div",{className:"text-[10px] text-fg-tertiary truncate",children:[e.role,s.jsx("span",{className:"sm:hidden",children:e.teamName?` · ${e.teamName}`:""})]})]})]})}),s.jsx("td",{className:"px-3 sm:px-4 py-3 text-xs text-fg-tertiary hidden sm:table-cell",children:e.teamName||"—"}),s.jsx("td",{className:"px-3 sm:px-4 py-3",children:s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-sm text-fg-secondary tabular-nums",children:e.tasksCompleted}),e.tasksFailed>0&&s.jsxs("span",{className:"text-[10px] text-red-500 tabular-nums",children:["(",e.tasksFailed,")"]})]})}),s.jsx("td",{className:"px-3 sm:px-4 py-3",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"flex-1 h-1.5 bg-surface-overlay rounded-full overflow-hidden max-w-[80px] hidden md:block",children:s.jsx("div",{className:"h-full bg-indigo-500 rounded-full transition-all",style:{width:`${o}%`}})}),s.jsx("span",{className:"text-sm text-fg-secondary tabular-nums",children:y5(e.totalTokens)})]})}),r&&s.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm text-fg-secondary tabular-nums",children:e.cuUsed>0?Qd(e.cuUsed):s.jsx("span",{className:"text-fg-tertiary",children:"—"})}),s.jsx("td",{className:"px-3 sm:px-4 py-3 text-right",children:s.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 Vu({label:e,col:t,current:n,desc:r,onSort:o,align:l}){const c=n===t?r?"↓":"↑":"↕",d=n===t?"text-brand-500":"text-fg-muted";return s.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:()=>o(t),children:[e,s.jsx("span",{className:`ml-1 ${d}`,children:c})]})}function UD({contributors:e,hubPlan:t,hubOrgMeta:n,hubConnected:r,showMarkusUsage:o}){const{t:l}=dt("home");return s.jsxs("div",{className:"space-y-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg-tertiary px-0.5",children:l("usage.sectionTitle")}),o&&s.jsx(dh,{title:l("usage.creditsTitle"),children:s.jsx(PD,{hubConnected:r,hubPlan:t,hubOrgMeta:n})}),s.jsx(zD,{contributors:e})]})}const $D="(max-width: 767px)";let sp=null;function v5(){return sp||(sp=window.matchMedia($D)),sp}function HD(e){const t=v5();return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function FD(){return v5().matches}function qD(){return!1}const GD=k.createContext(!1);function Bo(){const e=k.useContext(GD),t=k.useSyncExternalStore(HD,FD,qD);return e?!1:t}const VD={completed:"#22c55e",in_progress:"#8b5cf6",review:"#3b82f6",pending:"#f59e0b",failed:"#ef4444",blocked:"#f59e0b",rejected:"#fb7185",cancelled:"#6b7280"},KD={completed:"bg-green-500",in_progress:"bg-brand-500",review:"bg-blue-500",pending:"bg-amber-500",failed:"bg-red-500",blocked:"bg-amber-500",rejected:"bg-rose-400",cancelled:"bg-gray-500"},WD={pending:"common:status.pending",in_progress:"common:status.inProgress",blocked:"common:status.blocked",review:"common:status.review",completed:"common:status.completed",failed:"common:status.failed",rejected:"common:status.rejected",cancelled:"common:status.cancelled"},w5=["completed","in_progress","review","pending","failed","blocked","rejected","cancelled"],YD={completed:"bg-green-500/15",in_progress:"bg-brand-500/15",pending:"bg-amber-500/15",review:"bg-blue-500/15",failed:"bg-red-500/15",blocked:"bg-amber-500/15",rejected:"bg-red-500/15",cancelled:"bg-gray-500/15"},Jy={"Heartbeat check-in":"agentFocus.heartbeatCheckIn","Heartbeat check-in (idle skip)":"agentFocus.heartbeatSkip"};function ev({authUser:e,previewMode:t,previewData:n}={}){const{t:r}=dt(["home","common","team"]),o=Bo(),l=RD(me.HOME),[c,d]=k.useState(n?.agents??[]),[m,p]=k.useState(n?.teams??[]),[h,g]=k.useState(n?.board??{}),[x,y]=k.useState(n?.ops??null),w="7d",[C,T]=k.useState(n?.requirements??[]),[S,_]=k.useState(n?.projects??[]),[j,O]=k.useState(n?.deliverableTotal??0),[P,D]=k.useState([]),[$,X]=k.useState(n?.storageInfo??null),[ee,H]=k.useState(n?.usageInfo??null),[K,ae]=k.useState(null),[W,F]=k.useState(!1),[Z,U]=k.useState(!1),[Q,ne]=k.useState(!1),[ke,B]=k.useState(null),[q,le]=k.useState(!1),[I,Ae]=k.useState(!1),[$e,Oe]=k.useState(null),[We,st]=k.useState(!1),mt=k.useRef(!1);mt.current=We;const[At,gt]=k.useState(()=>localStorage.getItem("markus_checklist_dismissed")==="true"),[jt,Jt]=k.useState(!1),[Rt,be]=k.useState(!1),Me=k.useRef(null),qe=k.useCallback(()=>{Ae(!0),Ce.cu.status().then(ae).catch(()=>{}),Ce.settings.getLlm().then(R=>{B(Object.values(R.providers).some(oe=>oe.configured)),le(!!R.providers.markus?.configured)}).catch(()=>{}),window.dispatchEvent(new CustomEvent("markus:data-changed")),window.setTimeout(()=>{window.dispatchEvent(new CustomEvent("markus:data-changed"))},800)},[]);k.useEffect(()=>{if(!W)return;const R=oe=>{Me.current&&!Me.current.contains(oe.target)&&F(!1)};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[W]),k.useEffect(()=>{!t||!n||(n.agents&&d(n.agents),n.teams&&p(n.teams),n.board&&g(n.board),y(n.ops??null),T(n.requirements??[]),_(n.projects??[]),O(n.deliverableTotal??0),n.storageInfo&&X(n.storageInfo),n.usageInfo&&H(n.usageInfo))},[t,n]);const ot=k.useCallback(()=>{const R=Ce.agents.list().then(ie=>{d(ie.agents);const Ne=ie.agents.find(Le=>Le.role==="secretary")??ie.agents.find(Le=>Le.name?.toLowerCase().includes("secretary"));Ne&&Ce.sessions.listByAgent(Ne.id,1).then(async Le=>{if(Le.sessions.length===0)return;const Je=await Ce.sessions.getMessages(Le.sessions[0].id,1);Jt(Je.messages.length>0)}).catch(()=>{})}).catch(()=>{}),oe=Ce.teams.list().then(ie=>p(ie.teams)).catch(()=>{});Ce.tasks.board().then(ie=>g(ie.board)).catch(()=>{}),Ce.ops.dashboard(w).then(y).catch(()=>{});const _e=Ce.requirements.list().then(ie=>T(ie.requirements)).catch(()=>{}),de=Ce.projects.list().then(ie=>_(ie.projects)).catch(()=>{});Ce.deliverables.search({limit:18}).then(ie=>{O(ie.total);const Ne=new Map;for(const Le of ie.results){const Je=Le.reference,vt=Ne.get(Je);(!vt||Le.updatedAt>vt.updatedAt)&&Ne.set(Je,Le)}D([...Ne.values()].sort((Le,Je)=>Je.updatedAt.localeCompare(Le.updatedAt)).slice(0,6))}).catch(()=>{}),Ce.system.storage().then(X).catch(()=>{}),Ce.usage.summary().then(ie=>H(ie.usage)).catch(()=>{}),Ce.cu.status().then(ae).catch(()=>{});const Pe=Ce.settings.getLlm().then(ie=>{B(Object.values(ie.providers).some(Ne=>Ne.configured)),le(!!ie.providers.markus?.configured)}).catch(()=>{}),Ve=Ce.settings.getBrowser().then(ie=>{Oe(ie.extensionConnected)}).catch(()=>{}),G=SD().then(ie=>{if(!ie&&!yn()){Ae(!1);return}return it.user.claimFreeCreditsStatus().then(Ne=>Ae(!!Ne.claimed)).catch(()=>{})}).catch(()=>{});Promise.allSettled([R,oe,_e,de,Pe,Ve,G]).then(()=>{be(!0)})},[w]);k.useEffect(()=>{if(t||!l)return;ot();const R=setInterval(ot,6e4),oe=()=>ot(),_e=()=>{if(mt.current){it.user.claimFreeCreditsStatus().then(de=>Ae(!!de.claimed)).catch(()=>{});return}ot()};return window.addEventListener("markus:data-changed",oe),window.addEventListener("markus:hub-auth",_e),()=>{clearInterval(R),window.removeEventListener("markus:data-changed",oe),window.removeEventListener("markus:hub-auth",_e)}},[t,w,l,ot]);const ft={};for(const[R,oe]of Object.entries(h))R!=="archived"&&oe.length>0&&(ft[R]=oe.length);const se=ft.completed??0,Be=Object.values(ft).reduce((R,oe)=>R+oe,0),Xe=c.filter(R=>R.status==="working").length,Ge=S.filter(R=>R.status==="active").length,et=Be>0?Math.round(se/Be*100):0,yt=w5.filter(R=>(ft[R]??0)>0).map(R=>({status:R,count:ft[R]})),he=k.useMemo(()=>{const R={};return C.forEach(oe=>{R[oe.status]=(R[oe.status]??0)+1}),R},[C]),V=k.useMemo(()=>{const R=new Map(c.map(oe=>[oe.id,oe]));return m.map(oe=>{const _e=oe.members.filter(de=>de.type==="agent").map(de=>R.get(de.id)).filter(de=>!!de);return{team:oe,agents:_e,working:_e.filter(de=>de.status==="working").length,total:_e.length}})},[m,c]),ye=c.filter(R=>R.status==="working"),Qe=!(ke===!0&&!q),pe=ID(!t&&l,x,m),ve=k.useMemo(()=>{const R=new Map;for(const oe of Object.values(h))for(const _e of oe)R.set(_e.id,_e);return R},[h]),Ye=k.useCallback(R=>!R.blockedBy||R.blockedBy.length===0?!0:R.blockedBy.every(oe=>{const _e=ve.get(oe);return _e&&_e.status==="completed"}),[ve]),nt=k.useMemo(()=>{const R=[],oe=(h.review??[]).filter(Ne=>Ne.reviewerType==="human");if(oe.length>0){const Ne=oe.filter(Le=>Le.priority==="urgent"||Le.priority==="high").length;R.push({type:"review",count:oe.length,tasks:oe,urgent:Ne})}const _e=C.filter(Ne=>Ne.status==="pending");_e.length>0&&R.push({type:"approval",count:_e.length});const de=[...h.blocked??[]],Pe=[...h.failed??[]],Ve=de.filter(Ne=>Ye(Ne)),G=de.filter(Ne=>!Ye(Ne)),ie=[...Ve,...Pe];if(ie.length>0){const Ne=ie.filter(Le=>Le.priority==="urgent"||Le.priority==="high").length;R.push({type:"blocked_abnormal",count:ie.length,tasks:ie,urgent:Ne})}return G.length>0&&R.push({type:"blocked",count:G.length,tasks:G}),R},[h,C,Ye]),xt=k.useMemo(()=>{const R=new Map;for(const oe of Object.values(h))for(const _e of oe)_e.priority&&R.set(_e.id,_e.priority);return R},[h]),Dt=k.useMemo(()=>{const R=new Map;for(const oe of c)R.set(oe.id,oe.name);return R},[c]),{activityLimit:ct,teamsLimit:Xt}=k.useMemo(()=>{const R=(S.length>0?1:0)+(C.length>0?1:0)+(j>0?1:0),oe=Be>0?6+R:0,_e=oe>0?2:0,Pe=oe+_e+2,Ve=V.length>0?2+V.length:0,G=Math.max(Ve,4),ie=ye.length,Ne=ie>0?8:12,Le=Math.max(0,G-Pe);let Je=ie>0?Math.max(ie,Le):Le;Je=Math.max(3,Math.min(Ne,Je));const vt=Pe+Math.max(ie,Je);let Ie=V.length;if(G>vt+2){const tt=G-vt;Ie=Math.max(2,V.length-tt)}else if(vt>G+2){const tt=vt-G;Je=Math.max(3,Je-tt)}return{activityLimit:Je,teamsLimit:Ie}},[V,Be,S,C,j,ye]);return s.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-thin",children:[s.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:[s.jsxs("div",{className:"flex items-center gap-2",children:[o&&s.jsx(x5,{}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-base sm:text-lg font-bold",children:r("title")}),s.jsx("p",{className:"text-xs text-fg-tertiary hidden sm:block",children:r("subtitle")})]})]}),s.jsxs("div",{"data-no-drag":!0,className:"flex items-center gap-1.5",children:[s.jsx("button",{onClick:()=>t?void 0:o?at.navigate(me.SEARCH):window.dispatchEvent(new CustomEvent("markus:open-search")),className:"p-2 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary","aria-label":"Search",children:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}),s.jsx(aL,{ref:Me,show:W,onToggle:()=>F(!W),onClose:()=>F(!1),t:r,isMobile:o})]})]}),s.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:[s.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[s.jsx(Ku,{label:r("metricCards.working"),value:String(Xe),sub:`/${c.length}`,icon:s.jsx(Wu,{type:"working"}),pulse:Xe>0,onClick:()=>U(!0)}),s.jsx(Ku,{label:r("metricCards.tasksDone"),value:`${se}`,sub:`/${Be}`,icon:s.jsx(Wu,{type:"tasks"}),onClick:()=>at.navigate(me.WORK)}),s.jsx(Ku,{label:r("metricCards.projects"),value:String(Ge),icon:s.jsx(Wu,{type:"projects"}),onClick:()=>at.navigate(me.WORK)}),s.jsx(Ku,{label:r("metricCards.health"),value:`${ke===!1?100:x?.systemHealth.overallScore??"—"}`,sub:ke===!1||x?"%":void 0,icon:s.jsx(Wu,{type:"health"}),color:ke===!1?"green":x?x.systemHealth.overallScore>=80?"green":x.systemHealth.overallScore>=50?"amber":"red":void 0,onClick:()=>ne(!0)})]}),!t&&nt.length>0&&s.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:[s.jsx("div",{className:"flex items-center justify-between px-5 pt-4 pb-2",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-500 animate-pulse"}),s.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:r("attention.title")})]})}),s.jsx("div",{className:"px-3 pb-3 space-y-1",children:nt.map(R=>{const oe=R.type==="blocked_abnormal",_e=R.type==="blocked"||oe,de=R.type==="review"?"bg-blue-500/15":R.type==="approval"?"bg-amber-500/15":oe?"bg-red-500/15":"bg-amber-500/15",Pe=R.type==="review"?"bg-blue-500/10 text-blue-500 hover:bg-blue-500/20":R.type==="approval"?"bg-amber-500/10 text-amber-600 hover:bg-amber-500/20":oe?"bg-red-500/10 text-red-500 hover:bg-red-500/20":"bg-amber-500/10 text-amber-600 hover:bg-amber-500/20",Ve=R.type==="review"?r("attention.tasksReview"):R.type==="approval"?r("attention.requirements"):r(oe?"attention.blockedAbnormal":"attention.blockedNormal"),G=R.type==="review"?r("attention.goReview"):R.type==="approval"?r("attention.goApprove"):r("attention.viewDetails");return s.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay/40 cursor-pointer transition-colors",onClick:()=>{R.type==="review"?at.navigate(me.WORK,{statusFilter:"review"}):R.type==="approval"?at.navigate(me.WORK):_e&&R.tasks&&R.tasks.length>0?at.navigate(me.WORK,{openTask:R.tasks[0].id}):at.navigate(me.WORK)},children:[s.jsx("span",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${de}`,children:s.jsx(JD,{type:_e?"blocked":R.type})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("span",{className:"text-xs font-medium text-fg-primary",children:[R.count," ",Ve]}),(R.urgent??0)>0&&s.jsxs("span",{className:"ml-2 inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-semibold bg-red-500/15 text-red-500",children:[R.urgent," urgent"]})]}),s.jsx("button",{className:`text-[11px] font-medium px-3 py-1 rounded-lg transition-colors shrink-0 ${Pe}`,children:G})]},R.type)})})]}),P.length>0&&s.jsxs("div",{className:"bg-surface-elevated shadow-sm rounded-2xl overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:r("recentDeliverables.title")}),s.jsx("button",{onClick:()=>at.navigate(me.DELIVERABLES),className:"text-[11px] text-brand-400 hover:text-brand-300 font-medium",children:r("common:viewAll")})]}),s.jsx("div",{className:"px-3 pb-3",children:s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-1",children:P.map(R=>s.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:()=>at.navigate(me.DELIVERABLES,{openDeliverable:R.id}),children:[s.jsx("span",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 mt-0.5 ${R.artifactType?"bg-brand-500/10":R.type==="directory"?"bg-blue-500/10":"bg-green-500/10"}`,children:s.jsx(tL,{type:R.type,artifactType:R.artifactType})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-xs font-medium text-fg-primary truncate",children:R.title}),s.jsx("div",{className:"text-[11px] text-fg-tertiary truncate mt-0.5",children:R.summary}),s.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[R.agentId&&Dt.get(R.agentId)&&s.jsx("span",{className:"text-[10px] text-fg-muted",children:Dt.get(R.agentId)}),s.jsx("span",{className:"text-[10px] text-fg-muted",children:nv(R.updatedAt,r)}),R.status==="verified"&&s.jsx("span",{className:"text-[10px] text-blue-500 font-medium",children:"Verified"})]})]}),R.diffStats&&s.jsxs("div",{className:"text-[10px] text-fg-muted shrink-0 mt-1 tabular-nums",children:[s.jsxs("span",{className:"text-green-500",children:["+",R.diffStats.additions]})," ",s.jsxs("span",{className:"text-red-500",children:["-",R.diffStats.deletions]})]})]},R.id))})})]}),Rt&&(()=>{const R=Ie=>{const tt=c.find(St=>St.role==="secretary")??c.find(St=>St.name?.toLowerCase().includes("secretary"));at.navigate(me.TEAM,{...tt?{agentId:tt.id}:{},prefillMessage:Ie})},_e=!!yn()||q,de=ke===!0||q,Pe=[..._e?[{id:"claim",done:I,isSetup:!0,label:r("checklist.setup.claim"),desc:r("checklist.setup.claimDesc"),action:r("checklist.setup.claimAction"),onClick:()=>{st(!0)}}]:[],{id:"llm",done:de,isSetup:!0,label:r("checklist.setup.llm"),desc:r(_e?"checklist.setup.llmDescHub":"checklist.setup.llmDesc"),action:r("checklist.setup.llmAction"),onClick:()=>{window.location.hash="#settings/providers"}},{id:"browser",done:$e===!0,isSetup:!0,optional:!0,label:r("checklist.setup.browser"),desc:r("checklist.setup.browserDesc"),action:r("checklist.setup.browserAction"),onClick:()=>{window.location.hash="#settings/browser"}}],Ve=[{id:"greet",done:jt,label:r("checklist.explore.greet"),desc:r("checklist.explore.greetDesc"),action:r("checklist.explore.greetAction"),onClick:()=>R("你好!我是新用户,请简单介绍一下你能帮我做什么?")},{id:"project",done:S.length>0,label:r("checklist.explore.project"),desc:r("checklist.explore.projectDesc"),action:r("checklist.explore.projectAction"),onClick:()=>R("帮我创建一个名为「Markus探索」的项目,用于了解和体验Markus的各项能力")},{id:"requirements",done:C.length>0,label:r("checklist.explore.requirements"),desc:r("checklist.explore.requirementsDesc"),action:r("checklist.explore.requirementsAction"),onClick:()=>R("在「Markus探索」项目中创建两个需求:1. 了解Markus开源项目的架构和设计理念 2. 探索Markus智能体的能力和使用方式")},{id:"team",done:m.length>0,label:r("checklist.explore.team"),desc:r("checklist.explore.teamDesc"),action:r("checklist.explore.teamAction"),onClick:()=>R("帮我组建一个名为「科技前沿智库」的团队,成员包括4位科技领袖角色的智能体:埃隆·马斯克(关注太空、电动车、AI安全)、史蒂夫·乔布斯(关注产品设计与用户体验)、山姆·奥特曼(关注AGI与AI创业生态)、黄仁勋(关注GPU、AI算力与数据中心)。团队目标是从不同视角分析科技前沿趋势。")}],G=[...Pe,...Ve],ie=G.filter(Ie=>Ie.done).length,Ne=G.length,Le=Pe.filter(Ie=>!Ie.optional).every(Ie=>Ie.done)&&Ve.every(Ie=>Ie.done),Je=Pe.some(Ie=>!Ie.optional&&!Ie.done);if(Le||At&&!Je)return null;const vt=Ie=>s.jsxs("div",{className:"flex items-start gap-3 py-2.5 px-3 rounded-lg hover:bg-surface-elevated/50 transition-colors group",children:[s.jsx("div",{className:`mt-0.5 shrink-0 w-5 h-5 rounded-full flex items-center justify-center ${Ie.done?"bg-green-500":"border-2 border-border-default"}`,children:Ie.done&&s.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`text-xs font-medium ${Ie.done?"text-fg-tertiary line-through":"text-fg-primary"}`,children:Ie.label}),"optional"in Ie&&Ie.optional&&s.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-surface-elevated text-fg-muted font-medium",children:r("checklist.setup.optional")})]}),s.jsx("p",{className:`text-[11px] mt-0.5 ${Ie.done?"text-fg-muted":"text-fg-tertiary"}`,children:Ie.desc})]}),Ie.done&&Ie.isSetup?s.jsx("button",{onClick:Ie.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:r("checklist.setup.update")}):Ie.done?null:s.jsx("button",{onClick:Ie.onClick,className:"shrink-0 text-[11px] px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white font-medium transition-colors opacity-80 group-hover:opacity-100",children:Ie.action})]},Ie.id);return s.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:[s.jsxs("div",{className:"flex items-start justify-between mb-4",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-semibold text-fg-primary mb-1",children:r("checklist.title")}),s.jsx("p",{className:"text-xs text-fg-secondary",children:r("checklist.subtitle")})]}),s.jsx("button",{onClick:()=>{gt(!0),localStorage.setItem("markus_checklist_dismissed","true")},className:"text-fg-muted hover:text-fg-secondary transition-colors p-1 -mr-1 -mt-1",title:"Dismiss",children:s.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),s.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[s.jsx("div",{className:"flex-1 h-1.5 bg-surface-elevated rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-brand-500 rounded-full transition-all duration-500",style:{width:`${ie/Ne*100}%`}})}),s.jsx("span",{className:"text-[11px] text-fg-secondary font-medium shrink-0",children:r("checklist.progress",{done:ie,total:Ne})})]}),s.jsxs("div",{className:"mb-4",children:[s.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1 px-3",children:r("checklist.setup.title")}),s.jsx("div",{className:"space-y-0.5",children:Pe.map(vt)})]}),s.jsx("div",{className:"border-t border-border-default/50 my-3"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1 px-3",children:r("checklist.explore.title")}),s.jsx("div",{className:"space-y-0.5",children:Ve.map(vt)})]})]})})(),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[s.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[Be>0&&s.jsxs("div",{className:"bg-surface-elevated shadow-sm rounded-2xl overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:r("globalOverview.title")}),s.jsx("button",{onClick:()=>at.navigate(me.WORK),className:"text-[11px] text-brand-400 hover:text-brand-300 font-medium",children:r("common:viewAll")})]}),s.jsxs("div",{className:"px-5 py-4 flex flex-col sm:flex-row items-center gap-6 border-t border-border-subtle/50",children:[s.jsx(QD,{statusCounts:ft,total:Be,completionRate:et,completed:se}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("div",{className:"grid grid-cols-2 gap-x-5 gap-y-2.5",children:yt.map(({status:R,count:oe})=>s.jsxs("button",{onClick:()=>at.navigate(me.WORK,{statusFilter:R}),className:"flex items-center gap-2 group cursor-pointer text-left",children:[s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${KD[R]??"bg-gray-500"}`}),s.jsx("span",{className:"text-xs text-fg-tertiary group-hover:text-fg-secondary transition-colors",children:r(WD[R]??R)}),s.jsx("span",{className:"text-sm font-semibold text-fg-primary ml-auto tabular-nums",children:oe})]},R))})})]}),s.jsxs("div",{className:"divide-y divide-border-subtle/50",children:[S.length>0&&s.jsx(ip,{icon:"folder",label:r("globalOverview.projects"),value:S.length,onClick:()=>at.navigate(me.WORK),children:s.jsxs(tv,{children:[Ge," ",r("globalOverview.active")]})}),C.length>0&&s.jsx(ip,{icon:"edit",label:r("globalOverview.requirements"),value:C.length,onClick:()=>at.navigate(me.WORK),children:["in_progress","pending","completed"].map(R=>(he[R]??0)>0&&s.jsxs(tv,{children:[he[R]," ",r(`common:status.${R==="in_progress"?"inProgress":R}`)]},R))}),j>0&&s.jsx(ip,{icon:"book",label:r("globalOverview.deliverables"),value:j,onClick:()=>at.navigate(me.DELIVERABLES)})]})]}),(ye.length>0||x&&x.taskKPI.recentActivity.length>0)&&s.jsx("div",{className:"bg-surface-elevated shadow-sm rounded-2xl overflow-hidden",children:s.jsxs("div",{className:`grid grid-cols-1 ${ye.length>0&&x&&x.taskKPI.recentActivity.length>0?"sm:grid-cols-2 divide-y sm:divide-y-0 sm:divide-x divide-border-subtle/50":""}`,children:[ye.length>0&&s.jsxs("div",{className:"p-5",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 animate-pulse"}),s.jsx("h4",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:r("liveActivity.whosWorking")})]}),s.jsx("div",{className:"space-y-1",children:ye.map(R=>s.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:()=>at.navigate(me.TEAM,{agentId:R.id}),children:[s.jsx(Us,{name:R.name,avatarUrl:R.avatarUrl,size:24,bgClass:"bg-brand-600/30 text-brand-300"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-xs font-medium text-fg-primary truncate",children:R.name}),s.jsx("div",{className:"text-[10px] text-fg-tertiary truncate",children:sL(R.currentActivity?.label,r)??r("agentFocus.working")})]})]},R.id))})]}),x&&x.taskKPI.recentActivity.length>0&&s.jsxs("div",{className:"p-5",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h4",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:r("liveActivity.recentChanges")}),s.jsx("button",{onClick:()=>at.navigate(me.WORK),className:"text-[11px] text-brand-400 hover:text-brand-300 font-medium",children:r("common:viewAll")})]}),s.jsx("div",{className:`${ye.length>0?"":"grid grid-cols-1 sm:grid-cols-2 gap-x-4"}`,children:x.taskKPI.recentActivity.slice(0,ct).map(R=>{const oe=xt.get(R.taskId);return s.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:()=>at.navigate(me.WORK,{openTask:R.taskId}),children:[s.jsx("span",{className:`w-5 h-5 rounded-full flex items-center justify-center shrink-0 ${YD[R.status]??"bg-gray-500/15"}`,children:s.jsx(ZD,{status:R.status})}),s.jsx("span",{className:"text-[11px] text-fg-secondary truncate flex-1",children:R.title}),(oe==="urgent"||oe==="high")&&s.jsx(eL,{priority:oe}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:nv(R.updatedAt,r)})]},R.taskId)})})]})]})})]}),s.jsx("div",{className:"space-y-6",children:V.length>0&&s.jsx("div",{className:"bg-surface-elevated shadow-sm rounded-2xl overflow-hidden",children:s.jsxs("div",{className:"p-5",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:r("teamOverview.title")}),s.jsx("button",{onClick:()=>at.navigate(me.TEAM),className:"text-[11px] text-brand-400 hover:text-brand-300 font-medium",children:r("common:viewAll")})]}),s.jsxs("div",{className:"space-y-0.5",children:[V.slice(0,Xt).map(R=>s.jsxs("div",{className:"flex items-center gap-3 px-2 py-2 rounded-lg hover:bg-surface-overlay/40 cursor-pointer transition-colors",onClick:()=>at.navigate(me.TEAM,{selectTeam:R.team.id}),children:[s.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:R.team.name.charAt(0)}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("div",{className:"text-xs font-medium text-fg-primary truncate",children:R.team.name})}),s.jsx("div",{className:"flex items-center -space-x-1 shrink-0",children:R.agents.slice(0,3).map(oe=>s.jsx(Us,{name:oe.name,avatarUrl:oe.avatarUrl,size:18,bgClass:"bg-surface-overlay text-fg-secondary ring-1 ring-surface-elevated"},oe.id))}),R.working>0&&s.jsxs("span",{className:"text-[10px] text-green-500 font-medium shrink-0",children:[R.working,"/",R.total]})]},R.team.id)),Xt<V.length&&s.jsxs("button",{onClick:()=>at.navigate(me.TEAM),className:"w-full text-center text-[11px] text-brand-400 hover:text-brand-300 font-medium py-1.5",children:["+",V.length-Xt," more"]})]})]})})})]}),!t&&ke!==null&&s.jsx(UD,{contributors:pe.contributors,hubPlan:pe.hubPlan,hubOrgMeta:pe.hubOrgMeta,hubConnected:pe.hubConnected,showMarkusUsage:Qe})]}),Z&&s.jsx(nL,{workingAgents:ye,onClose:()=>U(!1),t:r}),Q&&s.jsx(rL,{ops:x,completed:se,totalRootTasks:Be,workingAgents:Xe,totalAgents:c.length,usageInfo:ee,storageInfo:$,cuQuota:K,onClose:()=>ne(!1),t:r}),We&&s.jsx(LD,{onClose:()=>st(!1),onClaimed:qe})]})}function Ku({label:e,value:t,sub:n,icon:r,pulse:o,color:l,badge:c,onClick:d}){const m=l==="green"?"text-green-500":l==="amber"?"text-amber-500":l==="red"?"text-red-500":"text-fg-primary";return s.jsxs("div",{onClick:d,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:[s.jsxs("div",{children:[s.jsx("div",{className:"text-[11px] text-fg-tertiary mb-2",children:e}),s.jsxs("div",{className:"flex items-baseline gap-0.5",children:[s.jsx("span",{className:`text-2xl sm:text-3xl font-bold ${m} leading-none`,children:t}),n&&s.jsx("span",{className:"text-sm text-fg-muted font-medium",children:n})]}),c&&s.jsx("div",{className:"text-[10px] text-amber-500 font-medium mt-1.5",children:c})]}),s.jsxs("div",{className:"relative",children:[s.jsx("div",{className:"w-10 h-10 rounded-xl bg-surface-overlay/60 flex items-center justify-center text-fg-tertiary",children:r}),o&&s.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-2.5 h-2.5 rounded-full bg-green-500 animate-pulse"})]})]})}function Wu({type:e}){const t={working:s.jsx(s.Fragment,{children:s.jsx("path",{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z"})}),tasks:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),s.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),projects:s.jsx(s.Fragment,{children:s.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:s.jsx(s.Fragment,{children:s.jsx("path",{d:"M22 12h-4l-3 9L9 3l-3 9H2"})})};return s.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 ip({icon:e,label:t,value:n,onClick:r,children:o}){return s.jsxs("div",{className:"flex items-center gap-3 px-5 py-3 hover:bg-surface-overlay/30 cursor-pointer transition-colors",onClick:r,children:[s.jsx("span",{className:"text-fg-muted",children:s.jsx(XD,{type:e})}),s.jsx("span",{className:"text-xs text-fg-secondary",children:t}),s.jsx("span",{className:"text-sm font-semibold text-fg-primary",children:n}),s.jsx("div",{className:"flex items-center gap-2 ml-auto text-[11px] text-fg-tertiary",children:o})]})}function tv({children:e}){return s.jsx("span",{className:"px-2 py-0.5 rounded-full bg-surface-overlay/60 text-[11px] text-fg-secondary",children:e})}function XD({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 s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:t[e]})})}function QD({statusCounts:e,total:t,completionRate:n,completed:r}){const d=2*Math.PI*42,m=w5.filter(g=>(e[g]??0)>0).map(g=>({status:g,value:e[g],color:VD[g]??"#6b7280"}));let p=0;const h=m.map(g=>{const x=g.value/t*d,y={len:Math.max(x-.8,.5),offset:p,color:g.color,status:g.status};return p+=x,y});return s.jsxs("div",{className:"relative shrink-0",style:{width:120,height:120},children:[s.jsx("svg",{width:120,height:120,viewBox:"0 0 120 120",children:h.map((g,x)=>s.jsx("circle",{cx:"60",cy:"60",r:42,fill:"none",stroke:g.color,strokeWidth:12,strokeDasharray:`${g.len} ${d-g.len}`,strokeDashoffset:-g.offset,transform:"rotate(-90 60 60)",className:"transition-all duration-500 cursor-pointer",onClick:()=>at.navigate(me.WORK,{statusFilter:g.status})},x))}),s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[s.jsxs("span",{className:"text-2xl font-bold text-fg-primary leading-none",children:[n,"%"]}),s.jsxs("span",{className:"text-[10px] text-fg-tertiary mt-0.5",children:[r,"/",t]})]})]})}function ZD({status:e}){const n={completed:"#22c55e",in_progress:"#8b5cf6",pending:"#f59e0b",review:"#3b82f6",failed:"#ef4444",blocked:"#f59e0b",rejected:"#ef4444",cancelled:"#6b7280"}[e]??"#6b7280";return s.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"&&s.jsx("polyline",{points:"20 6 9 17 4 12"}),e==="in_progress"&&s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),e==="pending"&&s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),s.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),e==="review"&&s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),(e==="failed"||e==="rejected")&&s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),s.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),e==="blocked"&&s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"4.93",y1:"4.93",x2:"19.07",y2:"19.07"})]}),e==="cancelled"&&s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})]})}function JD({type:e}){const t=e==="review"?"#3b82f6":e==="approval"?"#f59e0b":"#ef4444";return s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:t,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e==="review"&&s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),e==="approval"&&s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),s.jsx("polyline",{points:"14 2 14 8 20 8"}),s.jsx("line",{x1:"12",y1:"18",x2:"12",y2:"12"}),s.jsx("line",{x1:"9",y1:"15",x2:"15",y2:"15"})]}),e==="blocked"&&s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),s.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),s.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})]})}function eL({priority:e}){return e==="urgent"?s.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"?s.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 tL({type:e,artifactType:t}){if(t){const r=t==="agent"?"#8b5cf6":t==="team"?"#3b82f6":"#f59e0b";return s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),s.jsx("path",{d:"M2 17l10 5 10-5"}),s.jsx("path",{d:"M2 12l10 5 10-5"})]})}const n=e==="directory"?"#3b82f6":"#22c55e";return s.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"?s.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"}):s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),s.jsx("polyline",{points:"14 2 14 8 20 8"})]})})}function nL({workingAgents:e,onClose:t,t:n}){return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:s.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:r=>r.stopPropagation(),children:[s.jsxs("div",{className:"px-5 py-4 border-b border-border-default flex items-center justify-between shrink-0",children:[s.jsx("h3",{className:"text-sm font-semibold",children:n("ranking.workingNow")}),s.jsx("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary hover:text-fg-primary",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 scrollbar-thin px-5 py-4",children:e.length>0?s.jsx("div",{className:"space-y-0.5",children:e.map(r=>s.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(),at.navigate(me.TEAM,{agentId:r.id})},children:[s.jsx(Us,{name:r.name,avatarUrl:r.avatarUrl,size:26,bgClass:"bg-brand-600/30 text-brand-300"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-xs font-medium text-fg-primary truncate",children:r.name}),s.jsx("div",{className:"text-[10px] text-fg-tertiary truncate",children:r.currentActivity?.label??"—"})]}),s.jsx("span",{className:"text-[10px] text-green-500 font-medium shrink-0",children:"Working"})]},r.id))}):s.jsx("div",{className:"py-8 text-center text-xs text-fg-tertiary",children:n("ranking.noData")})})]})})}function rL({ops:e,completed:t,totalRootTasks:n,workingAgents:r,totalAgents:o,usageInfo:l,storageInfo:c,cuQuota:d,onClose:m,t:p}){return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:m,children:s.jsxs("div",{className:"bg-surface-elevated rounded-xl border border-border-default shadow-2xl w-[400px] max-w-[90vw] overflow-hidden",onClick:h=>h.stopPropagation(),children:[s.jsxs("div",{className:"px-5 py-4 border-b border-border-default flex items-center justify-between",children:[s.jsx("h3",{className:"text-sm font-semibold",children:p("systemHealth.title")}),s.jsx("button",{onClick:m,className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary hover:text-fg-primary",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),s.jsxs("div",{className:"p-5 space-y-4",children:[e&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-xs text-fg-secondary",children:p("systemHealth.successRate")}),s.jsxs("span",{className:"text-sm font-bold text-fg-primary",children:[Math.round(e.taskKPI.successRate),"%"]})]}),s.jsx("div",{className:"h-2 rounded-full bg-surface-overlay/60 overflow-hidden",children:s.jsx("div",{className:"h-full rounded-full bg-green-500 transition-all duration-500",style:{width:`${Math.round(e.taskKPI.successRate)}%`}})})]}),e&&s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-xs text-fg-secondary",children:p("metricCards.health")}),s.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,"%"]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-xs text-fg-secondary",children:p("systemHealth.tasksTotal")}),s.jsxs("span",{className:"text-xs font-semibold text-fg-primary",children:[t,"/",n]})]}),l&&s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-xs text-fg-secondary",children:p("systemHealth.tokenUsage")}),s.jsx("span",{className:"text-xs font-semibold text-fg-primary",children:Xu(l.llmTokens)})]}),d?.available&&d.cuLimit>0&&(()=>{const h=d.cuLimit-d.cuRemaining,g=Math.min(100,Math.round(h/d.cuLimit*100)),x=g>=95?"text-red-500":g>=80?"text-amber-500":"text-green-500",y=g>=95?"bg-red-500":g>=80?"bg-amber-500":"bg-green-500";return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[s.jsx("span",{className:"text-xs text-fg-secondary",children:"CU Quota"}),s.jsxs("span",{className:`text-xs font-semibold ${x}`,children:[Xu(h)," / ",Xu(d.cuLimit)," (",g,"%)"]})]}),s.jsx("div",{className:"h-2 rounded-full bg-surface-overlay/60 overflow-hidden",children:s.jsx("div",{className:`h-full rounded-full ${y} transition-all duration-500`,style:{width:`${g}%`}})}),d.cuUsedToday!=null&&d.cuUsedToday>0&&s.jsxs("div",{className:"flex items-center justify-between mt-1.5",children:[s.jsx("span",{className:"text-xs text-fg-tertiary",children:"Today's CU Used"}),s.jsx("span",{className:"text-xs font-semibold text-fg-secondary",children:Xu(d.cuUsedToday)})]})]})})(),r>0&&s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-xs text-fg-secondary",children:p("systemHealth.currentWorking")}),s.jsxs("span",{className:"text-xs font-semibold text-green-500",children:[r,"/",o]})]}),c&&s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-xs text-fg-secondary",children:p("systemHealth.storage")}),s.jsx("span",{className:"text-xs font-semibold text-fg-primary",children:iL(c.totalSize)})]})]})]})})}const aL=k.forwardRef(({show:e,onToggle:t,onClose:n,t:r,isMobile:o},l)=>s.jsxs("div",{ref:l,className:"relative",children:[s.jsx("button",{onClick:t,className:"p-2 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary","aria-label":"Create",children:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),s.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}),e&&s.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:s.jsxs("div",{className:"py-1",children:[s.jsx(Yu,{onClick:()=>{n(),at.navigate(me.BUILDER,o?{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:r("home:createMenu.agent")}),s.jsx(Yu,{onClick:()=>{n(),at.navigate(me.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:r("home:createMenu.team")}),s.jsx(Yu,{onClick:()=>{n(),at.navigate(me.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:r("home:createMenu.skill")}),s.jsx("div",{className:"border-t border-border-default my-1"}),s.jsx(Yu,{onClick:()=>{n(),at.navigate(me.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:r("home:createMenu.discover")})]})})]}));function Yu({onClick:e,icon:t,children:n}){return s.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:[s.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:t})}),n]})}function nv(e,t){const n=Date.now()-new Date(e).getTime(),r=Math.floor(n/6e4);if(r<1)return t("common:time.now");if(r<60)return t("common:time.minutesAgo",{count:r});const o=Math.floor(r/60);return o<24?t("common:time.hoursAgo",{count:o}):t("common:time.daysAgo",{count:Math.floor(o/24)})}function sL(e,t){return e?Jy[e]?t(Jy[e]):e:null}function Xu(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 iL(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]}`}function rv(e){const t=[],n=String(e||"");let r=n.indexOf(","),o=0,l=!1;for(;!l;){r===-1&&(r=n.length,l=!0);const c=n.slice(o,r).trim();(c||!l)&&t.push(c),o=r+1,r=n.indexOf(",",o)}return t}function oL(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const lL=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,cL=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,uL={};function av(e,t){return(uL.jsx?cL:lL).test(e)}const dL=/[ \t\n\f\r]/g;function mL(e){return typeof e=="object"?e.type==="text"?sv(e.value):!1:sv(e)}function sv(e){return e.replace(dL,"")===""}class kc{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}kc.prototype.normal={};kc.prototype.property={};kc.prototype.space=void 0;function k5(e,t){const n={},r={};for(const o of e)Object.assign(n,o.property),Object.assign(r,o.normal);return new kc(n,r,t)}function hc(e){return e.toLowerCase()}class jr{constructor(t,n){this.attribute=n,this.property=t}}jr.prototype.attribute="";jr.prototype.booleanish=!1;jr.prototype.boolean=!1;jr.prototype.commaOrSpaceSeparated=!1;jr.prototype.commaSeparated=!1;jr.prototype.defined=!1;jr.prototype.mustUseProperty=!1;jr.prototype.number=!1;jr.prototype.overloadedBoolean=!1;jr.prototype.property="";jr.prototype.spaceSeparated=!1;jr.prototype.space=void 0;let fL=0;const zt=ji(),$n=ji(),mh=ji(),Fe=ji(),gn=ji(),jo=ji(),Ur=ji();function ji(){return 2**++fL}const fh=Object.freeze(Object.defineProperty({__proto__:null,boolean:zt,booleanish:$n,commaOrSpaceSeparated:Ur,commaSeparated:jo,number:Fe,overloadedBoolean:mh,spaceSeparated:gn},Symbol.toStringTag,{value:"Module"})),op=Object.keys(fh);class tg extends jr{constructor(t,n,r,o){let l=-1;if(super(t,n),iv(this,"space",o),typeof r=="number")for(;++l<op.length;){const c=op[l];iv(this,op[l],(r&fh[c])===fh[c])}}}tg.prototype.defined=!0;function iv(e,t,n){n&&(e[t]=n)}function Uo(e){const t={},n={};for(const[r,o]of Object.entries(e.properties)){const l=new tg(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(l.mustUseProperty=!0),t[r]=l,n[hc(r)]=r,n[hc(l.attribute)]=r}return new kc(t,n,e.space)}const S5=Uo({properties:{ariaActiveDescendant:null,ariaAtomic:$n,ariaAutoComplete:null,ariaBusy:$n,ariaChecked:$n,ariaColCount:Fe,ariaColIndex:Fe,ariaColSpan:Fe,ariaControls:gn,ariaCurrent:null,ariaDescribedBy:gn,ariaDetails:null,ariaDisabled:$n,ariaDropEffect:gn,ariaErrorMessage:null,ariaExpanded:$n,ariaFlowTo:gn,ariaGrabbed:$n,ariaHasPopup:null,ariaHidden:$n,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:gn,ariaLevel:Fe,ariaLive:null,ariaModal:$n,ariaMultiLine:$n,ariaMultiSelectable:$n,ariaOrientation:null,ariaOwns:gn,ariaPlaceholder:null,ariaPosInSet:Fe,ariaPressed:$n,ariaReadOnly:$n,ariaRelevant:null,ariaRequired:$n,ariaRoleDescription:gn,ariaRowCount:Fe,ariaRowIndex:Fe,ariaRowSpan:Fe,ariaSelected:$n,ariaSetSize:Fe,ariaSort:null,ariaValueMax:Fe,ariaValueMin:Fe,ariaValueNow:Fe,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function N5(e,t){return t in e?e[t]:t}function C5(e,t){return N5(e,t.toLowerCase())}const pL=Uo({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:jo,acceptCharset:gn,accessKey:gn,action:null,allow:null,allowFullScreen:zt,allowPaymentRequest:zt,allowUserMedia:zt,alt:null,as:null,async:zt,autoCapitalize:null,autoComplete:gn,autoFocus:zt,autoPlay:zt,blocking:gn,capture:null,charSet:null,checked:zt,cite:null,className:gn,cols:Fe,colSpan:null,content:null,contentEditable:$n,controls:zt,controlsList:gn,coords:Fe|jo,crossOrigin:null,data:null,dateTime:null,decoding:null,default:zt,defer:zt,dir:null,dirName:null,disabled:zt,download:mh,draggable:$n,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:zt,formTarget:null,headers:gn,height:Fe,hidden:mh,high:Fe,href:null,hrefLang:null,htmlFor:gn,httpEquiv:gn,id:null,imageSizes:null,imageSrcSet:null,inert:zt,inputMode:null,integrity:null,is:null,isMap:zt,itemId:null,itemProp:gn,itemRef:gn,itemScope:zt,itemType:gn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:zt,low:Fe,manifest:null,max:null,maxLength:Fe,media:null,method:null,min:null,minLength:Fe,multiple:zt,muted:zt,name:null,nonce:null,noModule:zt,noValidate:zt,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:zt,optimum:Fe,pattern:null,ping:gn,placeholder:null,playsInline:zt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:zt,referrerPolicy:null,rel:gn,required:zt,reversed:zt,rows:Fe,rowSpan:Fe,sandbox:gn,scope:null,scoped:zt,seamless:zt,selected:zt,shadowRootClonable:zt,shadowRootDelegatesFocus:zt,shadowRootMode:null,shape:null,size:Fe,sizes:null,slot:null,span:Fe,spellCheck:$n,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Fe,step:null,style:null,tabIndex:Fe,target:null,title:null,translate:null,type:null,typeMustMatch:zt,useMap:null,value:$n,width:Fe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:gn,axis:null,background:null,bgColor:null,border:Fe,borderColor:null,bottomMargin:Fe,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:zt,declare:zt,event:null,face:null,frame:null,frameBorder:null,hSpace:Fe,leftMargin:Fe,link:null,longDesc:null,lowSrc:null,marginHeight:Fe,marginWidth:Fe,noResize:zt,noHref:zt,noShade:zt,noWrap:zt,object:null,profile:null,prompt:null,rev:null,rightMargin:Fe,rules:null,scheme:null,scrolling:$n,standby:null,summary:null,text:null,topMargin:Fe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Fe,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:zt,disableRemotePlayback:zt,prefix:null,property:null,results:Fe,security:null,unselectable:null},space:"html",transform:C5}),hL=Uo({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:Ur,accentHeight:Fe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Fe,amplitude:Fe,arabicForm:null,ascent:Fe,attributeName:null,attributeType:null,azimuth:Fe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Fe,by:null,calcMode:null,capHeight:Fe,className:gn,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:Fe,diffuseConstant:Fe,direction:null,display:null,dur:null,divisor:Fe,dominantBaseline:null,download:zt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Fe,enableBackground:null,end:null,event:null,exponent:Fe,externalResourcesRequired:null,fill:null,fillOpacity:Fe,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:jo,g2:jo,glyphName:jo,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Fe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Fe,horizOriginX:Fe,horizOriginY:Fe,id:null,ideographic:Fe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Fe,k:Fe,k1:Fe,k2:Fe,k3:Fe,k4:Fe,kernelMatrix:Ur,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Fe,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:Fe,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:Fe,overlineThickness:Fe,paintOrder:null,panose1:null,path:null,pathLength:Fe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:gn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Fe,pointsAtY:Fe,pointsAtZ:Fe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ur,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ur,rev:Ur,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ur,requiredFeatures:Ur,requiredFonts:Ur,requiredFormats:Ur,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:Fe,specularExponent:Fe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Fe,strikethroughThickness:Fe,string:null,stroke:null,strokeDashArray:Ur,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Fe,strokeOpacity:Fe,strokeWidth:null,style:null,surfaceScale:Fe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ur,tabIndex:Fe,tableValues:null,target:null,targetX:Fe,targetY:Fe,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ur,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Fe,underlineThickness:Fe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Fe,values:null,vAlphabetic:Fe,vMathematical:Fe,vectorEffect:null,vHanging:Fe,vIdeographic:Fe,version:null,vertAdvY:Fe,vertOriginX:Fe,vertOriginY:Fe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Fe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:N5}),T5=Uo({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()}}),A5=Uo({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:C5}),E5=Uo({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),gL={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"},bL=/[A-Z]/g,ov=/-[a-z]/g,xL=/^data[-\w.:]+$/i;function _5(e,t){const n=hc(t);let r=t,o=jr;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&xL.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(ov,vL);r="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!ov.test(l)){let c=l.replace(bL,yL);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}o=tg}return new o(r,t)}function yL(e){return"-"+e.toLowerCase()}function vL(e){return e.charAt(1).toUpperCase()}const j5=k5([S5,pL,T5,A5,E5],"html"),S0=k5([S5,hL,T5,A5,E5],"svg");function lv(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function wL(e){return e.join(" ").trim()}var xo={},lp,cv;function kL(){if(cv)return lp;cv=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,d=/^\s+|\s+$/g,m=`
|
|
354
|
+
`);y=T.pop()??"";for(const S of T){const _=S.trim();if(_.startsWith("data: "))try{const j=JSON.parse(_.slice(6)),O=j.type;if(O==="snapshot"){const P=j.segments??[],D=typeof j.content=="string"?j.content:"";d=D,P.length&&(p=P),n.onSnapshot?.({content:D,segments:P})}else if(O==="text_delta"&&typeof j.text=="string")d+=j.text,n.onChunk?.(j.text);else if(O==="thinking_delta"&&typeof j.thinking=="string")n.onChunk?.(`<think>${j.thinking}</think>`);else if(O==="done"){d=j.content||d,typeof j.sessionId=="string"&&(m=j.sessionId);const P=j.segments;P&&(p=P),l({content:d,sessionId:m,segments:p,attached:!0}),g.cancel().catch(()=>{});return}else if(O==="error"){c(new Error(j.message??j.error??"Stream error")),g.cancel().catch(()=>{});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{}}}l({content:d,sessionId:m,segments:p,attached:!0})}catch(h){c(h)}})},channels:{getMessages:(e,t=50,n)=>Y(`/channels/${encodeURIComponent(e)}/messages?limit=${t}${n?`&before=${n}`:""}`),sendMessage:(e,t)=>Y(`/channels/${encodeURIComponent(e)}/messages`,{method:"POST",body:JSON.stringify(t)})},governance:{getSystemStatus:()=>Y("/system/status"),pauseAll:e=>Y("/system/pause-all",{method:"POST",body:JSON.stringify({reason:e})}),resumeAll:()=>Y("/system/resume-all",{method:"POST"}),emergencyStop:e=>Y("/system/emergency-stop",{method:"POST",body:JSON.stringify({reason:e})}),getAnnouncements:()=>Y("/system/announcements"),createAnnouncement:e=>Y("/system/announcements",{method:"POST",body:JSON.stringify(e)}),getPolicy:()=>Y("/governance/policy"),setPolicy:e=>Y("/governance/policy",{method:"PUT",body:JSON.stringify(e)})},approvals:{list:e=>{const t=e?`?status=${e}`:"";return Y(`/approvals${t}`)},respond:(e,t,n,r,o,l)=>Y(`/approvals/${e}`,{method:"POST",body:JSON.stringify({approved:t,respondedBy:n,comment:r,selectedOption:o,answers:l})})},notifications:{list:(e,t,n)=>{const r=new URLSearchParams;return e&&r.set("userId",e),t&&r.set("unread","true"),n?.type&&r.set("type",n.type),n?.limit&&r.set("limit",String(n.limit)),n?.offset&&r.set("offset",String(n.offset)),Y(`/notifications?${r}`)},create:e=>Y("/notifications",{method:"POST",body:JSON.stringify(e)}),markRead:e=>Y(`/notifications/${e}`,{method:"POST"}),markAllRead:e=>Y("/notifications/mark-all-read",{method:"POST",body:JSON.stringify({userId:e})})},unread:{getCounts:()=>Y("/unread"),markRead:(e,t,n)=>Y("/unread/mark-read",{method:"POST",body:JSON.stringify({conversationKey:e,lastReadAt:t,lastReadId:n})}),markAllRead:()=>Y("/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)),Y(`/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 Y(`/activity${n?`?${n}`:""}`)}},projects:{list:e=>{const t=e?`?orgId=${e}`:"";return Y(`/projects${t}`)},get:e=>Y(`/projects/${e}`),create:e=>Y("/projects",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>Y(`/projects/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>Y(`/projects/${e}`,{method:"DELETE"})},knowledge:{search:(e,t,n)=>{const r=new URLSearchParams;return e&&r.set("query",e),t&&r.set("scope",t),n&&r.set("category",n),Y(`/knowledge/search?${r}`)},contribute:e=>Y("/knowledge",{method:"POST",body:JSON.stringify(e)}),flagOutdated:(e,t)=>Y(`/knowledge/${e}/flag-outdated`,{method:"POST",body:JSON.stringify({reason:t})}),verify:e=>Y(`/knowledge/${e}/verify`,{method:"POST",body:JSON.stringify({verifiedBy:"human"})}),remove:e=>Y(`/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?.offset&&t.set("offset",String(e.offset)),e?.limit&&t.set("limit",String(e.limit)),Y(`/deliverables?${t}`)},get:e=>Y(`/deliverables/${e}`),create:e=>Y("/deliverables",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>Y(`/deliverables/${e}`,{method:"PUT",body:JSON.stringify(t)}),remove:e=>Y(`/deliverables/${e}`,{method:"DELETE"}),verify:e=>Y(`/deliverables/${e}`,{method:"PUT",body:JSON.stringify({status:"verified"})}),checkHealth:e=>{const t=new URLSearchParams;return e&&t.set("agentId",e),Y(`/deliverables/health?${t}`)}},codeReviews:{list:(e,t=20)=>{const n=new URLSearchParams;return e&&n.set("taskId",e),n.set("limit",String(t)),Y(`/reviews?${n}`)},get:e=>Y(`/reviews/${e}`),run:e=>Y("/reviews",{method:"POST",body:JSON.stringify(e)})},reports:{list:()=>Y("/reports"),get:e=>Y(`/reports/${e}`),generate:e=>Y("/reports/generate",{method:"POST",body:JSON.stringify(e)}),approvePlan:(e,t)=>Y(`/reports/${e}/plan/approve`,{method:"POST",body:JSON.stringify(t)}),rejectPlan:(e,t)=>Y(`/reports/${e}/plan/reject`,{method:"POST",body:JSON.stringify(t)}),addFeedback:(e,t)=>Y(`/reports/${e}/feedback`,{method:"POST",body:JSON.stringify(t)}),getFeedback:e=>Y(`/reports/${e}/feedback`)},executionLogs:{get:(e,t)=>Y(`/execution-logs?sourceType=${encodeURIComponent(e)}&sourceId=${encodeURIComponent(t)}`)},groupChats:{list:()=>Y("/group-chats"),create:e=>Y("/group-chats",{method:"POST",body:JSON.stringify(e)}),getById:e=>Y(`/group-chats/${e}`),update:(e,t)=>Y(`/group-chats/${e}`,{method:"PATCH",body:JSON.stringify(t)}),delete:e=>Y(`/group-chats/${e}`,{method:"DELETE"}),addMember:(e,t,n,r)=>Y(`/group-chats/${e}/members`,{method:"POST",body:JSON.stringify({memberId:t,memberType:n,memberName:r})}),removeMember:(e,t)=>Y(`/group-chats/${e}/members/${t}`,{method:"DELETE"})},uploads:{upload:(e,t)=>Y("/uploads",{method:"POST",body:JSON.stringify({files:e,prefix:t})})},hubOrgs:{mine:()=>$t("/orgs/mine"),get:e=>$t(`/orgs/${e}`),update:(e,t)=>$t(`/orgs/${e}`,{method:"PUT",body:JSON.stringify(t)}),create:e=>$t("/orgs",{method:"POST",body:JSON.stringify({name:e})}),members:e=>$t(`/orgs/${e}/members`),invite:(e,t)=>$t(`/orgs/${e}/members`,{method:"POST",body:JSON.stringify(t)}),removeMember:(e,t)=>$t(`/orgs/${e}/members/${t}`,{method:"DELETE"}),updateMemberRole:(e,t,n)=>$t(`/orgs/${e}/members/${t}`,{method:"PATCH",body:JSON.stringify({role:n})}),invitations:()=>$t("/orgs/invitations"),acceptInvitation:e=>$t(`/orgs/${e}/members/accept`,{method:"POST"}),leave:e=>$t(`/orgs/${e}/leave`,{method:"POST"})},workflows:{list:e=>Y(`/teams/${e}/workflows`),get:(e,t)=>Y(`/teams/${e}/workflows/${encodeURIComponent(t)}`),create:(e,t,n)=>Y(`/teams/${e}/workflows`,{method:"POST",body:JSON.stringify({name:t,yaml:n})}),update:(e,t,n)=>Y(`/teams/${e}/workflows/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({yaml:n})}),remove:(e,t)=>Y(`/teams/${e}/workflows/${encodeURIComponent(t)}`,{method:"DELETE"}),roles:(e,t)=>Y(`/teams/${e}/workflows/${encodeURIComponent(t)}/roles`),listRuns:(e,t,n)=>Y(`/teams/${e}/workflows/${encodeURIComponent(t)}/runs${n?`?limit=${n}`:""}`),startRun:(e,t,n,r,o)=>Y(`/teams/${e}/workflows/${encodeURIComponent(t)}/runs`,{method:"POST",body:JSON.stringify({projectId:n,params:r,roleMapping:o})}),getRun:e=>Y(`/workflow-runs/${e}`),cancelRun:e=>Y(`/workflow-runs/${e}`,{method:"DELETE"}),pauseRun:e=>Y(`/workflow-runs/${e}/pause`,{method:"POST"}),resumeRun:e=>Y(`/workflow-runs/${e}/resume`,{method:"POST"})}};function rY(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 aY(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 Jl{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:",r=new URLSearchParams;this.currentUserId&&r.set("userId",this.currentUserId),this.lastEventTimestamp&&r.set("since",this.lastEventTimestamp);const o=r.toString(),l=`${n}//${window.location.host}/ws${o?`?${o}`:""}`,c=new WebSocket(l);this.ws=c,c.onopen=()=>{this.reconnectAttempts=0,this.startHeartbeat(c)},c.onmessage=d=>{if(this.ws===c)try{const m=JSON.parse(d.data);if(m.timestamp&&(this.lastEventTimestamp=m.timestamp),m.type==="pong")return;const p=this.handlers.get(m.type);if(p)for(const g of p)g(m);const h=this.handlers.get("*");if(h)for(const g of h)g(m)}catch{}},c.onclose=()=>{if(this.stopHeartbeat(),this.intentionalClose)return;const d=Math.min(Jl.BACKOFF_BASE*Math.pow(2,this.reconnectAttempts),Jl.BACKOFF_MAX);this.reconnectAttempts++,this.reconnectTimer=setTimeout(()=>this.connect(this.currentUserId),d)},c.onerror=()=>{c.close()}}startHeartbeat(t){this.stopHeartbeat(),this.heartbeatTimer=setInterval(()=>{t.readyState===WebSocket.OPEN&&t.send(JSON.stringify({type:"ping"}))},Jl.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 va=new Jl;let k0=window.__MARKUS_HUB_URL__??"https://markus.global",Rd=null;async function ch(){if(!yn())return null;try{const e=await $t("/auth/me");if(e?.user?.id){const t=yn();return Wd(t,e.user),e.user}}catch{}return sa()}async function c5(){if(!window.__MARKUS_PREVIEW__)try{const e=await Y("/settings/hub");e.hubUrl&&(k0=e.hubUrl)}catch{}}function kD(){return Rd||(Rd=c5().finally(()=>{})),Rd}window.__MARKUS_PREVIEW__||(Rd=c5().then(async()=>{const e=localStorage.getItem("markus_hub_token");if(e)Y("/settings/hub-token",{method:"POST",body:JSON.stringify({token:e})}).catch(()=>{}),ch();else try{const t=await Y("/settings/hub-token");t.token&&(localStorage.setItem("markus_hub_token",t.token),await ch())}catch{}}).catch(()=>{}));const mc="markus_hub_token",Vd="markus_hub_user";function yn(){return localStorage.getItem(mc)}async function SD(){const e=yn();if(e)return e;try{const t=await Y("/settings/hub-token");if(t.token)return localStorage.setItem(mc,t.token),ch(),t.token}catch{}return null}function sa(){try{const e=localStorage.getItem(Vd);return e?JSON.parse(e):null}catch{return null}}function Kd(e,t){if(e.purchasedByCurrentUser||t?.has(e.id))return!0;const n=sa();if(!n?.id)return!1;const r=e.author?.id??e.authorId;return!!r&&r===n.id}function _o(){localStorage.removeItem(mc),localStorage.removeItem(Vd),u5(null),window.dispatchEvent(new CustomEvent("markus:hub-auth"))}function Wd(e,t){const n=localStorage.getItem(mc),r=localStorage.getItem(Vd),o=JSON.stringify(t);n===e&&r===o||(localStorage.setItem(mc,e),localStorage.setItem(Vd,o),u5(e),window.dispatchEvent(new CustomEvent("markus:hub-auth")))}function u5(e){Y("/settings/hub-token",{method:"POST",body:JSON.stringify({token:e})}).catch(()=>{})}async function ND(e){e.openrouter?.key&&await Y("/settings/subscription-key",{method:"POST",body:JSON.stringify({openrouter:e.openrouter})}).catch(()=>{})}async function Jh(e){try{return await Y(`/hub/auth/connect-status?session=${encodeURIComponent(e)}&_t=${Date.now()}`)}catch{return null}}async function eg(e){!e.token||!e.user||(Wd(e.token,e.user),e.openrouter?.key&&await ND({openrouter:e.openrouter}),CD())}async function CD(){if(yn())try{const{org:e}=await Y("/settings/org"),t=e?.name?.trim();if(!t||t==="My Organization")return;const r=((await $t("/orgs/mine")).orgs??[]).find(o=>o.role==="owner");if(!r||r.name===t)return;await $t(`/orgs/${r.id}`,{method:"PUT",body:JSON.stringify({name:t})})}catch{}}function d5(){return window.markusDesktop}async function TD(e,t=12e4){const n=Date.now()+t;for(;Date.now()<n;){const r=await Jh(e);if(r?.ready&&r.token&&r.user)return await eg(r),!0;await new Promise(o=>setTimeout(o,1200))}return!1}let Od=null;d5()?.onDeepLinkAuth?.(e=>{Od?.(e?.session??"")});let Yd=null;function AD(){Yd?.(),gi=null}function ED(e,t,n){return new Promise((r,o)=>{let l=!1,c=!1;const d=(C,T)=>{l||(l=!0,Yd=null,clearInterval(y),clearTimeout(w),window.removeEventListener("focus",h),document.removeEventListener("visibilitychange",g),Od===p&&(Od=null),C?(n.focusWindow?.(),r()):o(T))};Yd=()=>d(!1,new Error("Hub login cancelled"));const m=async()=>{if(!(l||c)){c=!0;try{const C=await Jh(e);C?.ready&&C.token&&C.user&&(await eg(C),d(!0))}finally{c=!1}}},p=C=>{(!C||C===e)&&m()};Od=p;const h=()=>{m()},g=()=>{document.visibilityState==="visible"&&m()};window.addEventListener("focus",h),document.addEventListener("visibilitychange",g);let x=`${k0}/auth/connect?session=${encodeURIComponent(e)}&redirect=${encodeURIComponent("markus://auth")}`;t&&(x+=`&method=${encodeURIComponent(t)}`),Promise.resolve(n.openExternal(x)).then(()=>{m()}).catch(C=>{d(!1,C instanceof Error?C:new Error("Failed to open browser"))});const y=setInterval(()=>{m()},1500),w=setTimeout(()=>d(!1,new Error("Hub login timed out")),5*6e4)})}function _D(e,t){return new Promise((n,r)=>{let o=`${k0}/auth/connect?session=${encodeURIComponent(e)}`;t&&(o+=`&method=${encodeURIComponent(t)}`);const l=460,c=580,d=Math.round(window.screenX+(window.outerWidth-l)/2),m=Math.round(window.screenY+(window.outerHeight-c)/2),p=window.open(o,"markus_hub_auth",`popup=yes,width=${l},height=${c},left=${d},top=${m}`);if(!p){r(new Error("Popup blocked by browser. Please allow popups for this site."));return}let h=!1,g=null;const x=()=>{clearInterval(w),clearInterval(T),g&&clearInterval(g),document.removeEventListener("visibilitychange",C)},y=async()=>{if(h)return;const S=await Jh(e);S?.ready&&S.token&&S.user&&(h=!0,await eg(S),x(),p?.close(),n())},w=setInterval(()=>{y()},1500),C=()=>{!h&&document.visibilityState==="visible"&&y()};document.addEventListener("visibilitychange",C);const T=setInterval(()=>{if(!h&&p?.closed){clearInterval(T);let S=0;g=setInterval(async()=>{if(h){clearInterval(g);return}S++,await y(),S>=5&&!h&&(h=!0,x(),yn()?n():r(new Error("Hub login cancelled")))},1e3)}},500)})}let gi=null;function na(e){const t=typeof e=="string"?{method:e}:e??{};if(t.force)Yd?.(),gi=null,(yn()||sa())&&_o();else if(yn())return Promise.resolve();if(gi)return gi;const n=`cs_${Date.now()}_${Math.random().toString(36).slice(2,10)}`,r=d5(),o=(async()=>{await kD(),r?await ED(n,t.method,r):await _D(n,t.method)})();return gi=o,o.catch(()=>{}).finally(()=>{gi===o&&(gi=null)}),o}async function $t(e,t){const n=yn(),r={"Content-Type":"application/json",...t?.headers};n&&(r.Authorization=`Bearer ${n}`);const o=await fetch(`${yi}/hub${e}`,{...t,headers:r,credentials:"include"}),l=await o.json();if(o.status===401&&n&&_o(),!o.ok){const c=new Error(l.error??`Hub HTTP ${o.status}`);throw c.code=typeof l.code=="string"?l.code:void 0,c.retryAfterSeconds=typeof l.retryAfterSeconds=="number"?l.retryAfterSeconds:void 0,c.status=o.status,c}return l}async function m5(){if(!yn())return!1;try{return await $t("/user/plan"),!0}catch{return!1}}const it={getUrl:()=>k0,isAuthenticated:()=>!!yn(),getUser:sa,logout:()=>{_o()},ensureAuth:na,validateSession:m5,login:async(e,t)=>{const n=await $t("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:t})});return Wd(n.token,n.user),n},register:async(e,t,n)=>{const r=await $t("/auth/register",{method:"POST",body:JSON.stringify({username:e,email:t,password:n})});return Wd(r.token,r.user),r},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 $t(`/items${n?`?${n}`:""}`)},getItem:e=>$t(`/items/${e}`),download:async e=>{await na();try{return await $t(`/items/${e}/download`,{method:"POST"})}catch(t){if(!yn())return await na(),$t(`/items/${e}/download`,{method:"POST"});throw t}},publish:async e=>{await na();try{return await $t("/items",{method:"POST",body:JSON.stringify(e)})}catch(t){if(!yn())return await na(),$t("/items",{method:"POST",body:JSON.stringify(e)});throw t}},uploadImage:async e=>{await na();try{const t=new FormData;t.append("file",e);const n=await fetch("/api/hub/upload",{method:"POST",credentials:"include",headers:{Authorization:`Bearer ${yn()}`},body:t});return n.ok?await n.json():null}catch{return null}},publishViaProxy:async e=>{await na();try{return await $t("/items",{method:"POST",body:JSON.stringify(e)})}catch(t){if(!yn())return await na(),$t("/items",{method:"POST",body:JSON.stringify(e)});throw t}},updateItem:async(e,t)=>(await na(),$t(`/items/${e}`,{method:"PUT",body:JSON.stringify(t)})),myItems:async()=>yn()?$t("/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 $t(`/items${n?`?${n}`:""}`)},myOrgs:async()=>yn()?$t("/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 na(),$t(`/items/${e}`,{method:"DELETE"})),purchases:{checkout:e=>$t("/purchases/checkout",{method:"POST",body:JSON.stringify({itemId:e})}),payWithEarnings:e=>$t("/purchases/pay-with-earnings",{method:"POST",body:JSON.stringify({itemId:e})}),mine:()=>$t("/purchases/mine")},creator:{getBalance:()=>$t("/creator/balance")},user:{plan:()=>$t("/user/plan"),cuStats:(e=30,t="day")=>$t(`/user/cu/stats?days=${e}&granularity=${t}`),claimFreeCreditsStatus:()=>$t("/user/claim-free-credits"),claimFreeCredits:()=>$t("/user/claim-free-credits",{method:"POST"})}},jD=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;function f5(e){return typeof e=="string"&&e.length>=2&&e.length<=64&&jD.test(e)}function fc(e){const t=e.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-+|-+$/g,"");return f5(t)?t:null}function Xd(e,t){const n=fc(e);if(n)return n;if(t){const o=fc(t);if(o)return o;if(f5(t))return t}let r=0;for(let o=0;o<e.length;o++)r=(r<<5)-r+e.charCodeAt(o)|0;return`pkg-${Math.abs(r).toString(36)}`}let Qy=null;const at={setHandler(e){Qy=e},navigate(e,t){t&&Object.entries(t).forEach(([n,r])=>localStorage.setItem(`markus_nav_${n}`,r)),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:e,params:t}})),Qy?.(e,t)}};let p5=uc();const uh=new Set;function Zy(){p5=uc(),uh.forEach(e=>e())}typeof window<"u"&&(window.addEventListener("hashchange",Zy),window.addEventListener("popstate",Zy));function MD(e){return uh.add(e),()=>uh.delete(e)}function RD(e){return k.useSyncExternalStore(MD,()=>p5===e,()=>!1)}var Sa=K4();function zo(e){k.useEffect(()=>yD(),[e])}function dr({title:e,message:t,confirmLabel:n,cancelLabel:r,variant:o="danger",alertOnly:l=!1,checkboxes:c,onConfirm:d,onCancel:m,onCancelClick:p}){const{t:h}=dt("common");zo(!0);const[g,x]=k.useState(()=>{const C={};for(const T of c??[])C[T.id]=T.defaultChecked??!1;return C}),y=o==="primary",w=y?"px-4 py-1.5 text-sm bg-brand-600 hover:bg-brand-500 text-white 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 Sa.createPortal(s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10050] p-4",onClick:m,children:s.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:[s.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[s.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?s.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:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"M12 16v-4"}),s.jsx("path",{d:"M12 8h.01"})]}):s.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:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),s.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}),s.jsxs("div",{className:"min-w-0 pt-0.5",children:[s.jsx("h3",{className:"font-semibold text-base text-fg-primary",children:e}),s.jsx("p",{className:"text-sm text-fg-secondary mt-1 leading-relaxed",children:t})]})]}),c&&c.length>0&&s.jsx("div",{className:"mb-4 space-y-2",children:c.map(C=>s.jsxs("label",{className:"flex items-center gap-2 text-sm text-fg-secondary cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:g[C.id]??!1,onChange:T=>x(S=>({...S,[C.id]:T.target.checked})),className:"rounded bg-surface-elevated border-border-default"}),C.label]},C.id))}),s.jsxs("div",{className:"flex justify-end gap-2",children:[!l&&s.jsx("button",{type:"button",onClick:()=>{p?p(c?g: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:r??h("cancel")}),s.jsx("button",{type:"button",onClick:()=>d(c?g:void 0),className:w,children:n??h(l?"ok":"confirm")})]})]})}),document.body)}function h5(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 r=it.getUrl()?.replace(/\/$/,"")||"";return r?`${r}${n}`:n}return n}function g5({size:e,className:t=""}){const n=Math.max(12,Math.round(e*.55));return s.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:s.jsxs("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),s.jsx("circle",{cx:"12",cy:"7",r:"4"})]})})}function Us({name:e,avatarUrl:t,size:n=28,className:r="",bgClass:o="bg-brand-600",fallback:l="initials"}){const[c,d]=k.useState(!1);if(k.useEffect(()=>{d(!1)},[t]),!!t&&!c)return s.jsx("img",{src:t,alt:e??"",className:`rounded-full object-cover shrink-0 ${r}`,style:{width:n,height:n},onError:()=>d(!0)});if(l==="icon")return s.jsx(g5,{size:n,className:r});const p=e?.[0]?.toUpperCase()??"?",h=n<=20?"text-[8px]":n<=28?"text-xs":n<=40?"text-sm":"text-lg",g=/\btext-(?!white\b)/.test(o);return s.jsx("div",{className:`rounded-full ${o} flex items-center justify-center ${g?"":"text-white"} ${h} font-bold shrink-0 ${r}`,style:{width:n,height:n},children:p})}function b5({currentUrl:e,name:t,size:n=64,targetType:r="user",targetId:o,onUploaded:l}){const{t:c}=dt("common"),[d,m]=k.useState(null),[p,h]=k.useState(!1),[g,x]=k.useState(!1),[y,w]=k.useState(null),C=k.useRef(null),T=d??e;k.useEffect(()=>{x(!1)},[T]);const S=!!T&&!g,_=k.useCallback(async j=>{if(!j.type.startsWith("image/"))return;if(j.size>2*1024*1024){w(c("imageTooLarge"));return}const O=new FileReader;O.onload=async()=>{const P=O.result;m(P),x(!1),h(!0);try{const{avatarUrl:D}=await Ce.auth.uploadAvatar(P,r,o);l?.(D)}catch{m(null)}finally{h(!1)}},O.readAsDataURL(j)},[r,o,l,c]);return s.jsxs("div",{className:"relative inline-block group",children:[s.jsx("input",{ref:C,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",className:"hidden",onChange:j=>{const O=j.target.files?.[0];O&&_(O)}}),s.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:"Click to set avatar",children:[S?s.jsx("img",{src:T,alt:t??"",className:"w-full h-full object-cover",onError:()=>x(!0)}):s.jsx(g5,{size:n}),s.jsx("div",{className:"absolute inset-0 bg-black/40 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:p?s.jsx("div",{className:"w-5 h-5 border-2 border-white/60 border-t-white rounded-full animate-spin"}):s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.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"}),s.jsx("circle",{cx:"12",cy:"13",r:"4"})]})})]}),y&&s.jsx(dr,{alertOnly:!0,variant:"danger",title:c("error",{defaultValue:"Error"}),message:y,onConfirm:()=>w(null),onCancel:()=>w(null)})]})}function OD({authUser:e,onNavigate:t}){const{t:n}=dt(["settings","common","nav"]),[r,o]=k.useState(!1);k.useEffect(()=>{const c=()=>o(!0);return window.addEventListener("markus:open-drawer",c),()=>window.removeEventListener("markus:open-drawer",c)},[]),k.useEffect(()=>(r?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[r]);const l=c=>{if(o(!1),c==="__edit_profile"){window.dispatchEvent(new CustomEvent("markus:open-edit-profile"));return}t(c)};return r?s.jsxs("div",{className:"fixed inset-0 z-[100]",children:[s.jsx("div",{className:"absolute inset-0 bg-black/40 animate-fadeIn",onClick:()=>o(!1)}),s.jsxs("aside",{className:"absolute inset-y-0 left-0 w-72 bg-surface-secondary shadow-2xl flex flex-col animate-slideInLeft",children:[s.jsx("div",{className:"px-5 pt-6 pb-4 border-b border-border-default",children:e?s.jsxs("button",{onClick:()=>l("__edit_profile"),className:"flex items-center gap-3 w-full text-left",children:[s.jsx(Us,{name:e.name||"User",avatarUrl:e.avatarUrl,size:40}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:e.name||n("common:userPlaceholder")}),s.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:e.email||e.role})]}),s.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:s.jsx("polyline",{points:"9 18 15 12 9 6"})})]}):s.jsx("div",{className:"text-sm text-fg-tertiary",children:n("common:loading")})}),s.jsxs("nav",{className:"flex-1 overflow-y-auto py-3 px-3 space-y-1",children:[s.jsx(ap,{icon:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),s.jsx("polyline",{points:"9 22 9 12 15 12 15 22"})]}),label:n("common:home",{defaultValue:"Home"}),onClick:()=>l(me.HOME)}),s.jsx(ap,{icon:s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:dc[me.BUILDER]})}),label:n("nav:builder"),onClick:()=>l(me.BUILDER)}),s.jsx(ap,{icon:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.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:n("settings:title"),onClick:()=>l(me.SETTINGS)})]})]})]}):null}function ap({icon:e,label:t,onClick:n}){return s.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,s.jsx("span",{children:t})]})}function DD(){window.dispatchEvent(new CustomEvent("markus:open-drawer"))}function x5({className:e=""}){return s.jsx("button",{onClick:DD,className:`p-1.5 -ml-1 rounded-lg hover:bg-surface-overlay transition-colors shrink-0 ${e}`,"aria-label":"Menu",children:s.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),s.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),s.jsx("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]})})}function pc(){return!!window.markusDesktop}function Ai(e){window.markusDesktop?window.markusDesktop.openExternal(e):window.open(e,"_blank","noopener,noreferrer")}function LD({onClose:e,onClaimed:t}){const{t:n}=dt(["home","common"]);zo(!0);const[r,o]=k.useState("loading"),[l,c]=k.useState(1e3),[d,m]=k.useState(""),p=k.useRef(t);p.current=t;const h=k.useRef(!1),g=()=>`${it.getUrl().replace(/\/$/,"")}/settings?tab=overview&claim=1`,x=k.useCallback(async()=>{o("loading"),m("");try{yn()||await na();const w=await it.user.claimFreeCreditsStatus();if(typeof w.amountCu=="number"&&w.amountCu>0&&c(w.amountCu),w.claimed){o("already"),p.current();return}o("open_hub")}catch(w){m(w instanceof Error?w.message:n("claim.loadFailed")),o("error")}},[n]);k.useEffect(()=>{h.current||(h.current=!0,x())},[x]);const y=()=>{const w=g();pc()?Ai(w):window.open(w,"_blank","noopener,noreferrer")};return s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60] p-4",onClick:e,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-2xl p-6 w-full max-w-md shadow-2xl",onClick:w=>w.stopPropagation(),children:[s.jsxs("div",{className:"flex items-start justify-between gap-3 mb-4",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"font-semibold text-lg text-fg-primary",children:n("claim.title")}),s.jsx("p",{className:"text-sm text-fg-secondary mt-1 leading-relaxed",children:n("claim.subtitle")})]}),s.jsx("button",{type:"button",onClick:e,className:"text-fg-tertiary hover:text-fg-primary text-lg leading-none",children:"×"})]}),r==="loading"&&s.jsx("p",{className:"text-sm text-fg-tertiary mb-5",children:n("claim.loading")}),r==="already"&&s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-emerald-400",children:n("claim.success",{amount:l.toLocaleString()})}),s.jsx("p",{className:"text-sm text-fg-secondary",children:n("claim.startUsing")}),s.jsx("button",{type:"button",onClick:e,className:"w-full py-2.5 text-sm font-medium rounded-xl bg-brand-500 text-white hover:bg-brand-600",children:n("common:close")})]}),r==="open_hub"&&s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-fg-secondary leading-relaxed",children:n("claim.openHubHint",{amount:l.toLocaleString()})}),s.jsx("button",{type:"button",onClick:y,className:"w-full py-2.5 text-sm font-medium rounded-xl bg-brand-500 text-white hover:bg-brand-600",children:n("claim.openHub")})]}),r==="error"&&s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:"text-sm text-red-400",children:d}),s.jsx("button",{type:"button",onClick:()=>{x()},className:"w-full py-2 text-sm rounded-xl border border-border-default",children:n("claim.retry")})]})]})})}function y5(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 Qd(e){return e.toLocaleString(void 0,{maximumFractionDigits:0})}function ID(e,t,n){const[r,o]=k.useState([]),[l,c]=k.useState(null),[d,m]=k.useState(null),[p,h]=k.useState(it.isAuthenticated()),g=k.useCallback(async()=>{try{const w=await Ce.usage.agents();o(w.agents)}catch{}},[]),x=k.useCallback(async()=>{if(!it.isAuthenticated()){h(!1),m(null);return}h(!0);try{const[w,C]=await Promise.all([it.user.plan(),Ce.hubOrgs.mine().catch(()=>null)]);c(w);const T=C?.orgs?.find(S=>S.id===w.orgId)??C?.orgs?.[0];m(T?{role:T.role,memberCount:T.memberCount??1}:null)}catch{}},[]);return k.useEffect(()=>{if(!e)return;g(),x();const w=setInterval(g,3e4),C=()=>{g(),x()};return window.addEventListener("markus:data-changed",C),()=>{clearInterval(w),window.removeEventListener("markus:data-changed",C)}},[e,g,x]),{contributors:k.useMemo(()=>{const w=[],C=new Map;for(const S of n)for(const _ of S.members)C.set(_.id,S.name);const T=new Map((t?.agentEfficiency??[]).map(S=>[S.agentId,S]));for(const S of r){const _=T.get(S.agentId),j=S.cuUsed??0,O=S.totalTokens,P=_?.taskMetrics.completed??0,D=O>0?P/O*1e3:P>0?1/0:0;w.push({id:S.agentId,name:S.agentName,type:"agent",role:S.role,teamName:C.get(S.agentId),status:S.status,tasksCompleted:P,tasksFailed:_?.taskMetrics.failed??0,cuUsed:j,cuUsedToday:S.cuUsedToday??0,totalTokens:O,tokensToday:S.tokensUsedToday,requestCount:S.requestCount,toolCalls:S.toolCalls,healthScore:_?.healthScore??0,efficiency:D,provider:S.provider})}return w.sort((S,_)=>_.cuUsed+_.tasksCompleted*100-(S.cuUsed+S.tasksCompleted*100)===0?_.totalTokens-S.totalTokens:_.cuUsed+_.tasksCompleted*100-(S.cuUsed+S.tasksCompleted*100)),w},[r,t,n]),hubPlan:l,hubOrgMeta:d,hubConnected:p}}function dh({title:e,badge:t,children:n}){const{t:r}=dt("home"),[o,l]=k.useState(!1);return s.jsxs("section",{className:`bg-surface-elevated shadow-sm rounded-2xl ${o?"overflow-visible":"overflow-hidden"}`,children:[s.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":o,children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg-primary truncate",children:e}),t]}),s.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-fg-tertiary shrink-0",children:[s.jsx("span",{className:"hidden sm:inline",children:r(o?"usage.trends.collapse":"usage.trends.expand")}),s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`transition-transform ${o?"rotate-180":""}`,children:s.jsx("polyline",{points:"6 9 12 15 18 9"})})]})]}),o&&s.jsx("div",{className:"rounded-b-2xl overflow-visible",children:n})]})}function PD({hubConnected:e,hubPlan:t,hubOrgMeta:n}){const{t:r}=dt("home"),o=sa();if(!e)return s.jsxs("div",{className:"px-4 sm:px-5 pb-4 flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-500 shrink-0"}),s.jsx("span",{className:"text-sm text-fg-tertiary",children:r("usage.quota.notConnected")})]}),s.jsx("button",{onClick:()=>it.ensureAuth().catch(()=>{}),className:"px-3 py-1.5 text-xs font-medium bg-brand-600 text-white rounded-lg hover:bg-brand-500 transition-colors shrink-0",children:r("usage.quota.connect")})]});if(!t)return s.jsx("div",{className:"px-4 sm:px-5 pb-4 text-sm text-fg-tertiary",children:r("usage.trends.noData")});const l=t.memberCuLimit!=null&&t.memberCuLimit>0,c=!n||n.role==="owner"||n.role==="admin"||n.memberCount<=1,d=l&&!c,m=(t.monthlyQuotaCu??0)+(t.bonusCu??0)+(t.purchasedCu??0),p=d?t.memberCuLimit:t.creditsBudgetCu??(l?t.memberCuLimit:m),h=d?t.memberCuUsed??0:t.totalConsumedThisPeriod??t.memberCuUsed??0,g=p>0?Math.min(100,Math.round(h/p*100)):0,x=g>90?"bg-red-500":g>70?"bg-amber-500":"bg-brand-500",y=()=>{Ai(`${it.getUrl().replace(/\/$/,"")}/settings?tab=billing`)};return s.jsxs("div",{className:"px-4 sm:px-5 pb-4",children:[d&&s.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:r("usage.quota.personalLimit")}),s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"text-xs font-semibold text-fg-secondary",children:r(l&&!c?"usage.quota.personalLimitLabel":"usage.quota.title")}),s.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}),o?.username&&s.jsx("span",{className:"text-[10px] text-fg-tertiary truncate",children:r("usage.quota.connectedAs",{username:o.username})})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3 text-[10px] text-fg-tertiary",children:[s.jsx("span",{children:t.cuResetAt?r("usage.quota.resetsAt",{date:new Date(t.cuResetAt).toLocaleDateString()}):""}),s.jsx("button",{type:"button",className:"px-2 py-1 bg-brand-600 text-white rounded hover:bg-brand-500 transition-colors font-medium",onClick:w=>{w.stopPropagation(),y()},children:r("usage.quota.topUp")})]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"flex-1 h-2 bg-surface-overlay rounded-full overflow-hidden",children:s.jsx("div",{className:`h-full rounded-full transition-all ${x}`,style:{width:`${g}%`}})}),s.jsxs("span",{className:"text-xs text-fg-secondary tabular-nums shrink-0",children:[Qd(h)," / ",Qd(p)]})]})]})}function zD({contributors:e}){const{t}=dt("home"),[n,r]=k.useState("totalTokens"),[o,l]=k.useState(!0),[c,d]=k.useState(!1),m=10,p=S=>{n===S?l(!o):(r(S),l(!0))},h=k.useMemo(()=>[...e].sort((S,_)=>{const j=S[n]===1/0?999999:S[n],O=_[n]===1/0?999999:_[n];return o?O-j:j-O}),[e,n,o]),g=c?h:h.slice(0,m),x=Math.max(1,...e.map(S=>S.totalTokens)),y=e.some(S=>S.cuUsed>0),w=new Set(e.filter(S=>S.provider).map(S=>S.provider)),T=w.size>1||w.size===1&&!w.has("markus")?s.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?s.jsx(dh,{title:t("usage.agents.title"),children:s.jsx("div",{className:"px-4 sm:px-5 pb-6 text-center",children:s.jsx("p",{className:"text-sm text-fg-tertiary",children:t("usage.agents.noData")})})}):s.jsxs(dh,{title:t("usage.agents.title"),badge:T,children:[s.jsx("div",{className:"overflow-x-auto scrollbar-thin border-t border-border-default",children:s.jsxs("table",{className:"w-full min-w-[520px]",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border-default text-xs text-fg-tertiary uppercase tracking-wider",children:[s.jsx("th",{className:"px-3 sm:px-4 py-3 text-left font-medium w-8",children:"#"}),s.jsx("th",{className:"px-3 sm:px-4 py-3 text-left font-medium",children:t("usage.agents.name")}),s.jsx("th",{className:"px-3 sm:px-4 py-3 text-left font-medium hidden sm:table-cell",children:t("usage.agents.team")}),s.jsx(Vu,{label:t("usage.agents.tasks"),col:"tasksCompleted",current:n,desc:o,onSort:p}),s.jsx(Vu,{label:t("usage.agents.tokens"),col:"totalTokens",current:n,desc:o,onSort:p}),y&&s.jsx(Vu,{label:t("usage.agents.cuUsed"),col:"cuUsed",current:n,desc:o,onSort:p}),s.jsx(Vu,{label:t("usage.agents.efficiency"),col:"efficiency",current:n,desc:o,onSort:p,align:"right"})]})}),s.jsx("tbody",{children:g.map((S,_)=>s.jsx(BD,{contributor:S,rank:_+1,maxTokens:x,showCu:y},S.id))}),s.jsx("tfoot",{children:s.jsxs("tr",{className:"border-t border-border-default bg-surface-elevated/30",children:[s.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})}),s.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})}),s.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:e.reduce((S,_)=>S+_.tasksCompleted,0)}),s.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:y5(e.reduce((S,_)=>S+_.totalTokens,0))}),y&&s.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:Qd(e.reduce((S,_)=>S+_.cuUsed,0))}),s.jsx("td",{})]})})]})}),h.length>m&&s.jsx("button",{type:"button",onClick:()=>d(S=>!S),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:h.length})})]})}function BD({contributor:e,rank:t,maxTokens:n,showCu:r}){const o=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)}`:"∞",d=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 s.jsxs("tr",{className:"border-b border-border-default/50 hover:bg-surface-elevated/30 transition-colors cursor-pointer",onClick:()=>at.navigate(me.TEAM,{selectAgent:e.id}),children:[s.jsx("td",{className:`px-3 sm:px-4 py-3 text-sm tabular-nums ${d}`,children:t}),s.jsx("td",{className:"px-3 sm:px-4 py-3",children:s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsx("div",{className:`w-2 h-2 rounded-full ${l} shrink-0`}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:e.name}),m&&s.jsx("span",{className:"px-1 py-0.5 rounded text-[8px] font-medium bg-surface-overlay text-fg-tertiary shrink-0",children:m})]}),s.jsxs("div",{className:"text-[10px] text-fg-tertiary truncate",children:[e.role,s.jsx("span",{className:"sm:hidden",children:e.teamName?` · ${e.teamName}`:""})]})]})]})}),s.jsx("td",{className:"px-3 sm:px-4 py-3 text-xs text-fg-tertiary hidden sm:table-cell",children:e.teamName||"—"}),s.jsx("td",{className:"px-3 sm:px-4 py-3",children:s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-sm text-fg-secondary tabular-nums",children:e.tasksCompleted}),e.tasksFailed>0&&s.jsxs("span",{className:"text-[10px] text-red-500 tabular-nums",children:["(",e.tasksFailed,")"]})]})}),s.jsx("td",{className:"px-3 sm:px-4 py-3",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"flex-1 h-1.5 bg-surface-overlay rounded-full overflow-hidden max-w-[80px] hidden md:block",children:s.jsx("div",{className:"h-full bg-indigo-500 rounded-full transition-all",style:{width:`${o}%`}})}),s.jsx("span",{className:"text-sm text-fg-secondary tabular-nums",children:y5(e.totalTokens)})]})}),r&&s.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm text-fg-secondary tabular-nums",children:e.cuUsed>0?Qd(e.cuUsed):s.jsx("span",{className:"text-fg-tertiary",children:"—"})}),s.jsx("td",{className:"px-3 sm:px-4 py-3 text-right",children:s.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 Vu({label:e,col:t,current:n,desc:r,onSort:o,align:l}){const c=n===t?r?"↓":"↑":"↕",d=n===t?"text-brand-500":"text-fg-muted";return s.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:()=>o(t),children:[e,s.jsx("span",{className:`ml-1 ${d}`,children:c})]})}function UD({contributors:e,hubPlan:t,hubOrgMeta:n,hubConnected:r,showMarkusUsage:o}){const{t:l}=dt("home");return s.jsxs("div",{className:"space-y-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg-tertiary px-0.5",children:l("usage.sectionTitle")}),o&&s.jsx(dh,{title:l("usage.creditsTitle"),children:s.jsx(PD,{hubConnected:r,hubPlan:t,hubOrgMeta:n})}),s.jsx(zD,{contributors:e})]})}const $D="(max-width: 767px)";let sp=null;function v5(){return sp||(sp=window.matchMedia($D)),sp}function HD(e){const t=v5();return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function FD(){return v5().matches}function qD(){return!1}const GD=k.createContext(!1);function Bo(){const e=k.useContext(GD),t=k.useSyncExternalStore(HD,FD,qD);return e?!1:t}const VD={completed:"#22c55e",in_progress:"#8b5cf6",review:"#3b82f6",pending:"#f59e0b",failed:"#ef4444",blocked:"#f59e0b",rejected:"#fb7185",cancelled:"#6b7280"},KD={completed:"bg-green-500",in_progress:"bg-brand-500",review:"bg-blue-500",pending:"bg-amber-500",failed:"bg-red-500",blocked:"bg-amber-500",rejected:"bg-rose-400",cancelled:"bg-gray-500"},WD={pending:"common:status.pending",in_progress:"common:status.inProgress",blocked:"common:status.blocked",review:"common:status.review",completed:"common:status.completed",failed:"common:status.failed",rejected:"common:status.rejected",cancelled:"common:status.cancelled"},w5=["completed","in_progress","review","pending","failed","blocked","rejected","cancelled"],YD={completed:"bg-green-500/15",in_progress:"bg-brand-500/15",pending:"bg-amber-500/15",review:"bg-blue-500/15",failed:"bg-red-500/15",blocked:"bg-amber-500/15",rejected:"bg-red-500/15",cancelled:"bg-gray-500/15"},Jy={"Heartbeat check-in":"agentFocus.heartbeatCheckIn","Heartbeat check-in (idle skip)":"agentFocus.heartbeatSkip"};function ev({authUser:e,previewMode:t,previewData:n}={}){const{t:r}=dt(["home","common","team"]),o=Bo(),l=RD(me.HOME),[c,d]=k.useState(n?.agents??[]),[m,p]=k.useState(n?.teams??[]),[h,g]=k.useState(n?.board??{}),[x,y]=k.useState(n?.ops??null),w="7d",[C,T]=k.useState(n?.requirements??[]),[S,_]=k.useState(n?.projects??[]),[j,O]=k.useState(n?.deliverableTotal??0),[P,D]=k.useState([]),[$,X]=k.useState(n?.storageInfo??null),[ee,H]=k.useState(n?.usageInfo??null),[K,ae]=k.useState(null),[W,F]=k.useState(!1),[Z,U]=k.useState(!1),[Q,ne]=k.useState(!1),[ke,B]=k.useState(null),[q,le]=k.useState(!1),[I,Ae]=k.useState(!1),[$e,Oe]=k.useState(null),[We,st]=k.useState(!1),mt=k.useRef(!1);mt.current=We;const[At,gt]=k.useState(()=>localStorage.getItem("markus_checklist_dismissed")==="true"),[jt,Jt]=k.useState(!1),[Rt,be]=k.useState(!1),Me=k.useRef(null),qe=k.useCallback(()=>{Ae(!0),Ce.cu.status().then(ae).catch(()=>{}),Ce.settings.getLlm().then(R=>{B(Object.values(R.providers).some(oe=>oe.configured)),le(!!R.providers.markus?.configured)}).catch(()=>{}),window.dispatchEvent(new CustomEvent("markus:data-changed")),window.setTimeout(()=>{window.dispatchEvent(new CustomEvent("markus:data-changed"))},800)},[]);k.useEffect(()=>{if(!W)return;const R=oe=>{Me.current&&!Me.current.contains(oe.target)&&F(!1)};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[W]),k.useEffect(()=>{!t||!n||(n.agents&&d(n.agents),n.teams&&p(n.teams),n.board&&g(n.board),y(n.ops??null),T(n.requirements??[]),_(n.projects??[]),O(n.deliverableTotal??0),n.storageInfo&&X(n.storageInfo),n.usageInfo&&H(n.usageInfo))},[t,n]);const ot=k.useCallback(()=>{const R=Ce.agents.list().then(ie=>{d(ie.agents);const Ne=ie.agents.find(Le=>Le.role==="secretary")??ie.agents.find(Le=>Le.name?.toLowerCase().includes("secretary"));Ne&&Ce.sessions.listByAgent(Ne.id,1).then(async Le=>{if(Le.sessions.length===0)return;const Je=await Ce.sessions.getMessages(Le.sessions[0].id,1);Jt(Je.messages.length>0)}).catch(()=>{})}).catch(()=>{}),oe=Ce.teams.list().then(ie=>p(ie.teams)).catch(()=>{});Ce.tasks.board().then(ie=>g(ie.board)).catch(()=>{}),Ce.ops.dashboard(w).then(y).catch(()=>{});const _e=Ce.requirements.list().then(ie=>T(ie.requirements)).catch(()=>{}),de=Ce.projects.list().then(ie=>_(ie.projects)).catch(()=>{});Ce.deliverables.search({limit:18}).then(ie=>{O(ie.total);const Ne=new Map;for(const Le of ie.results){const Je=Le.reference,vt=Ne.get(Je);(!vt||Le.updatedAt>vt.updatedAt)&&Ne.set(Je,Le)}D([...Ne.values()].sort((Le,Je)=>Je.updatedAt.localeCompare(Le.updatedAt)).slice(0,6))}).catch(()=>{}),Ce.system.storage().then(X).catch(()=>{}),Ce.usage.summary().then(ie=>H(ie.usage)).catch(()=>{}),Ce.cu.status().then(ae).catch(()=>{});const Pe=Ce.settings.getLlm().then(ie=>{B(Object.values(ie.providers).some(Ne=>Ne.configured)),le(!!ie.providers.markus?.configured)}).catch(()=>{}),Ve=Ce.settings.getBrowser().then(ie=>{Oe(ie.extensionConnected)}).catch(()=>{}),G=SD().then(ie=>{if(!ie&&!yn()){Ae(!1);return}return it.user.claimFreeCreditsStatus().then(Ne=>Ae(!!Ne.claimed)).catch(()=>{})}).catch(()=>{});Promise.allSettled([R,oe,_e,de,Pe,Ve,G]).then(()=>{be(!0)})},[w]);k.useEffect(()=>{if(t||!l)return;ot();const R=setInterval(ot,6e4),oe=()=>ot(),_e=()=>{if(mt.current){it.user.claimFreeCreditsStatus().then(de=>Ae(!!de.claimed)).catch(()=>{});return}ot()};return window.addEventListener("markus:data-changed",oe),window.addEventListener("markus:hub-auth",_e),()=>{clearInterval(R),window.removeEventListener("markus:data-changed",oe),window.removeEventListener("markus:hub-auth",_e)}},[t,w,l,ot]);const ft={};for(const[R,oe]of Object.entries(h))R!=="archived"&&oe.length>0&&(ft[R]=oe.length);const se=ft.completed??0,Be=Object.values(ft).reduce((R,oe)=>R+oe,0),Xe=c.filter(R=>R.status==="working").length,Ge=S.filter(R=>R.status==="active").length,et=Be>0?Math.round(se/Be*100):0,yt=w5.filter(R=>(ft[R]??0)>0).map(R=>({status:R,count:ft[R]})),he=k.useMemo(()=>{const R={};return C.forEach(oe=>{R[oe.status]=(R[oe.status]??0)+1}),R},[C]),V=k.useMemo(()=>{const R=new Map(c.map(oe=>[oe.id,oe]));return m.map(oe=>{const _e=oe.members.filter(de=>de.type==="agent").map(de=>R.get(de.id)).filter(de=>!!de);return{team:oe,agents:_e,working:_e.filter(de=>de.status==="working").length,total:_e.length}})},[m,c]),ye=c.filter(R=>R.status==="working"),Qe=!(ke===!0&&!q),pe=ID(!t&&l,x,m),ve=k.useMemo(()=>{const R=new Map;for(const oe of Object.values(h))for(const _e of oe)R.set(_e.id,_e);return R},[h]),Ye=k.useCallback(R=>!R.blockedBy||R.blockedBy.length===0?!0:R.blockedBy.every(oe=>{const _e=ve.get(oe);return _e&&_e.status==="completed"}),[ve]),nt=k.useMemo(()=>{const R=[],oe=(h.review??[]).filter(Ne=>Ne.reviewerType==="human");if(oe.length>0){const Ne=oe.filter(Le=>Le.priority==="urgent"||Le.priority==="high").length;R.push({type:"review",count:oe.length,tasks:oe,urgent:Ne})}const _e=C.filter(Ne=>Ne.status==="pending");_e.length>0&&R.push({type:"approval",count:_e.length});const de=[...h.blocked??[]],Pe=[...h.failed??[]],Ve=de.filter(Ne=>Ye(Ne)),G=de.filter(Ne=>!Ye(Ne)),ie=[...Ve,...Pe];if(ie.length>0){const Ne=ie.filter(Le=>Le.priority==="urgent"||Le.priority==="high").length;R.push({type:"blocked_abnormal",count:ie.length,tasks:ie,urgent:Ne})}return G.length>0&&R.push({type:"blocked",count:G.length,tasks:G}),R},[h,C,Ye]),xt=k.useMemo(()=>{const R=new Map;for(const oe of Object.values(h))for(const _e of oe)_e.priority&&R.set(_e.id,_e.priority);return R},[h]),Dt=k.useMemo(()=>{const R=new Map;for(const oe of c)R.set(oe.id,oe.name);return R},[c]),{activityLimit:ct,teamsLimit:Xt}=k.useMemo(()=>{const R=(S.length>0?1:0)+(C.length>0?1:0)+(j>0?1:0),oe=Be>0?6+R:0,_e=oe>0?2:0,Pe=oe+_e+2,Ve=V.length>0?2+V.length:0,G=Math.max(Ve,4),ie=ye.length,Ne=ie>0?8:12,Le=Math.max(0,G-Pe);let Je=ie>0?Math.max(ie,Le):Le;Je=Math.max(3,Math.min(Ne,Je));const vt=Pe+Math.max(ie,Je);let Ie=V.length;if(G>vt+2){const tt=G-vt;Ie=Math.max(2,V.length-tt)}else if(vt>G+2){const tt=vt-G;Je=Math.max(3,Je-tt)}return{activityLimit:Je,teamsLimit:Ie}},[V,Be,S,C,j,ye]);return s.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-thin",children:[s.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:[s.jsxs("div",{className:"flex items-center gap-2",children:[o&&s.jsx(x5,{}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-base sm:text-lg font-bold",children:r("title")}),s.jsx("p",{className:"text-xs text-fg-tertiary hidden sm:block",children:r("subtitle")})]})]}),s.jsxs("div",{"data-no-drag":!0,className:"flex items-center gap-1.5",children:[s.jsx("button",{onClick:()=>t?void 0:o?at.navigate(me.SEARCH):window.dispatchEvent(new CustomEvent("markus:open-search")),className:"p-2 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary","aria-label":"Search",children:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}),s.jsx(aL,{ref:Me,show:W,onToggle:()=>F(!W),onClose:()=>F(!1),t:r,isMobile:o})]})]}),s.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:[s.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[s.jsx(Ku,{label:r("metricCards.working"),value:String(Xe),sub:`/${c.length}`,icon:s.jsx(Wu,{type:"working"}),pulse:Xe>0,onClick:()=>U(!0)}),s.jsx(Ku,{label:r("metricCards.tasksDone"),value:`${se}`,sub:`/${Be}`,icon:s.jsx(Wu,{type:"tasks"}),onClick:()=>at.navigate(me.WORK)}),s.jsx(Ku,{label:r("metricCards.projects"),value:String(Ge),icon:s.jsx(Wu,{type:"projects"}),onClick:()=>at.navigate(me.WORK)}),s.jsx(Ku,{label:r("metricCards.health"),value:`${ke===!1?100:x?.systemHealth.overallScore??"—"}`,sub:ke===!1||x?"%":void 0,icon:s.jsx(Wu,{type:"health"}),color:ke===!1?"green":x?x.systemHealth.overallScore>=80?"green":x.systemHealth.overallScore>=50?"amber":"red":void 0,onClick:()=>ne(!0)})]}),!t&&nt.length>0&&s.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:[s.jsx("div",{className:"flex items-center justify-between px-5 pt-4 pb-2",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-500 animate-pulse"}),s.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:r("attention.title")})]})}),s.jsx("div",{className:"px-3 pb-3 space-y-1",children:nt.map(R=>{const oe=R.type==="blocked_abnormal",_e=R.type==="blocked"||oe,de=R.type==="review"?"bg-blue-500/15":R.type==="approval"?"bg-amber-500/15":oe?"bg-red-500/15":"bg-amber-500/15",Pe=R.type==="review"?"bg-blue-500/10 text-blue-500 hover:bg-blue-500/20":R.type==="approval"?"bg-amber-500/10 text-amber-600 hover:bg-amber-500/20":oe?"bg-red-500/10 text-red-500 hover:bg-red-500/20":"bg-amber-500/10 text-amber-600 hover:bg-amber-500/20",Ve=R.type==="review"?r("attention.tasksReview"):R.type==="approval"?r("attention.requirements"):r(oe?"attention.blockedAbnormal":"attention.blockedNormal"),G=R.type==="review"?r("attention.goReview"):R.type==="approval"?r("attention.goApprove"):r("attention.viewDetails");return s.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay/40 cursor-pointer transition-colors",onClick:()=>{R.type==="review"?at.navigate(me.WORK,{statusFilter:"review"}):R.type==="approval"?at.navigate(me.WORK):_e&&R.tasks&&R.tasks.length>0?at.navigate(me.WORK,{openTask:R.tasks[0].id}):at.navigate(me.WORK)},children:[s.jsx("span",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${de}`,children:s.jsx(JD,{type:_e?"blocked":R.type})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("span",{className:"text-xs font-medium text-fg-primary",children:[R.count," ",Ve]}),(R.urgent??0)>0&&s.jsxs("span",{className:"ml-2 inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-semibold bg-red-500/15 text-red-500",children:[R.urgent," urgent"]})]}),s.jsx("button",{className:`text-[11px] font-medium px-3 py-1 rounded-lg transition-colors shrink-0 ${Pe}`,children:G})]},R.type)})})]}),P.length>0&&s.jsxs("div",{className:"bg-surface-elevated shadow-sm rounded-2xl overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:r("recentDeliverables.title")}),s.jsx("button",{onClick:()=>at.navigate(me.DELIVERABLES),className:"text-[11px] text-brand-400 hover:text-brand-300 font-medium",children:r("common:viewAll")})]}),s.jsx("div",{className:"px-3 pb-3",children:s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-1",children:P.map(R=>s.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:()=>at.navigate(me.DELIVERABLES,{openDeliverable:R.id}),children:[s.jsx("span",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 mt-0.5 ${R.artifactType?"bg-brand-500/10":R.type==="directory"?"bg-blue-500/10":"bg-green-500/10"}`,children:s.jsx(tL,{type:R.type,artifactType:R.artifactType})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-xs font-medium text-fg-primary truncate",children:R.title}),s.jsx("div",{className:"text-[11px] text-fg-tertiary truncate mt-0.5",children:R.summary}),s.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[R.agentId&&Dt.get(R.agentId)&&s.jsx("span",{className:"text-[10px] text-fg-muted",children:Dt.get(R.agentId)}),s.jsx("span",{className:"text-[10px] text-fg-muted",children:nv(R.updatedAt,r)}),R.status==="verified"&&s.jsx("span",{className:"text-[10px] text-blue-500 font-medium",children:"Verified"})]})]}),R.diffStats&&s.jsxs("div",{className:"text-[10px] text-fg-muted shrink-0 mt-1 tabular-nums",children:[s.jsxs("span",{className:"text-green-500",children:["+",R.diffStats.additions]})," ",s.jsxs("span",{className:"text-red-500",children:["-",R.diffStats.deletions]})]})]},R.id))})})]}),Rt&&(()=>{const R=Ie=>{const tt=c.find(St=>St.role==="secretary")??c.find(St=>St.name?.toLowerCase().includes("secretary"));at.navigate(me.TEAM,{...tt?{agentId:tt.id}:{},prefillMessage:Ie})},_e=!!yn()||q,de=ke===!0||q,Pe=[..._e?[{id:"claim",done:I,isSetup:!0,label:r("checklist.setup.claim"),desc:r("checklist.setup.claimDesc"),action:r("checklist.setup.claimAction"),onClick:()=>{st(!0)}}]:[],{id:"llm",done:de,isSetup:!0,label:r("checklist.setup.llm"),desc:r(_e?"checklist.setup.llmDescHub":"checklist.setup.llmDesc"),action:r("checklist.setup.llmAction"),onClick:()=>{window.location.hash="#settings/providers"}},{id:"browser",done:$e===!0,isSetup:!0,optional:!0,label:r("checklist.setup.browser"),desc:r("checklist.setup.browserDesc"),action:r("checklist.setup.browserAction"),onClick:()=>{window.location.hash="#settings/browser"}}],Ve=[{id:"greet",done:jt,label:r("checklist.explore.greet"),desc:r("checklist.explore.greetDesc"),action:r("checklist.explore.greetAction"),onClick:()=>R("你好!我是新用户,请简单介绍一下你能帮我做什么?")},{id:"project",done:S.length>0,label:r("checklist.explore.project"),desc:r("checklist.explore.projectDesc"),action:r("checklist.explore.projectAction"),onClick:()=>R("帮我创建一个名为「Markus探索」的项目,用于了解和体验Markus的各项能力")},{id:"requirements",done:C.length>0,label:r("checklist.explore.requirements"),desc:r("checklist.explore.requirementsDesc"),action:r("checklist.explore.requirementsAction"),onClick:()=>R("在「Markus探索」项目中创建两个需求:1. 了解Markus开源项目的架构和设计理念 2. 探索Markus智能体的能力和使用方式")},{id:"team",done:m.length>0,label:r("checklist.explore.team"),desc:r("checklist.explore.teamDesc"),action:r("checklist.explore.teamAction"),onClick:()=>R("帮我组建一个名为「科技前沿智库」的团队,成员包括4位科技领袖角色的智能体:埃隆·马斯克(关注太空、电动车、AI安全)、史蒂夫·乔布斯(关注产品设计与用户体验)、山姆·奥特曼(关注AGI与AI创业生态)、黄仁勋(关注GPU、AI算力与数据中心)。团队目标是从不同视角分析科技前沿趋势。")}],G=[...Pe,...Ve],ie=G.filter(Ie=>Ie.done).length,Ne=G.length,Le=Pe.filter(Ie=>!Ie.optional).every(Ie=>Ie.done)&&Ve.every(Ie=>Ie.done),Je=Pe.some(Ie=>!Ie.optional&&!Ie.done);if(Le||At&&!Je)return null;const vt=Ie=>s.jsxs("div",{className:"flex items-start gap-3 py-2.5 px-3 rounded-lg hover:bg-surface-elevated/50 transition-colors group",children:[s.jsx("div",{className:`mt-0.5 shrink-0 w-5 h-5 rounded-full flex items-center justify-center ${Ie.done?"bg-green-500":"border-2 border-border-default"}`,children:Ie.done&&s.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`text-xs font-medium ${Ie.done?"text-fg-tertiary line-through":"text-fg-primary"}`,children:Ie.label}),"optional"in Ie&&Ie.optional&&s.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-surface-elevated text-fg-muted font-medium",children:r("checklist.setup.optional")})]}),s.jsx("p",{className:`text-[11px] mt-0.5 ${Ie.done?"text-fg-muted":"text-fg-tertiary"}`,children:Ie.desc})]}),Ie.done&&Ie.isSetup?s.jsx("button",{onClick:Ie.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:r("checklist.setup.update")}):Ie.done?null:s.jsx("button",{onClick:Ie.onClick,className:"shrink-0 text-[11px] px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white font-medium transition-colors opacity-80 group-hover:opacity-100",children:Ie.action})]},Ie.id);return s.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:[s.jsxs("div",{className:"flex items-start justify-between mb-4",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-semibold text-fg-primary mb-1",children:r("checklist.title")}),s.jsx("p",{className:"text-xs text-fg-secondary",children:r("checklist.subtitle")})]}),s.jsx("button",{onClick:()=>{gt(!0),localStorage.setItem("markus_checklist_dismissed","true")},className:"text-fg-muted hover:text-fg-secondary transition-colors p-1 -mr-1 -mt-1",title:"Dismiss",children:s.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),s.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[s.jsx("div",{className:"flex-1 h-1.5 bg-surface-elevated rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-brand-500 rounded-full transition-all duration-500",style:{width:`${ie/Ne*100}%`}})}),s.jsx("span",{className:"text-[11px] text-fg-secondary font-medium shrink-0",children:r("checklist.progress",{done:ie,total:Ne})})]}),s.jsxs("div",{className:"mb-4",children:[s.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1 px-3",children:r("checklist.setup.title")}),s.jsx("div",{className:"space-y-0.5",children:Pe.map(vt)})]}),s.jsx("div",{className:"border-t border-border-default/50 my-3"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1 px-3",children:r("checklist.explore.title")}),s.jsx("div",{className:"space-y-0.5",children:Ve.map(vt)})]})]})})(),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[s.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[Be>0&&s.jsxs("div",{className:"bg-surface-elevated shadow-sm rounded-2xl overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:r("globalOverview.title")}),s.jsx("button",{onClick:()=>at.navigate(me.WORK),className:"text-[11px] text-brand-400 hover:text-brand-300 font-medium",children:r("common:viewAll")})]}),s.jsxs("div",{className:"px-5 py-4 flex flex-col sm:flex-row items-center gap-6 border-t border-border-subtle/50",children:[s.jsx(QD,{statusCounts:ft,total:Be,completionRate:et,completed:se}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("div",{className:"grid grid-cols-2 gap-x-5 gap-y-2.5",children:yt.map(({status:R,count:oe})=>s.jsxs("button",{onClick:()=>at.navigate(me.WORK,{statusFilter:R}),className:"flex items-center gap-2 group cursor-pointer text-left",children:[s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${KD[R]??"bg-gray-500"}`}),s.jsx("span",{className:"text-xs text-fg-tertiary group-hover:text-fg-secondary transition-colors",children:r(WD[R]??R)}),s.jsx("span",{className:"text-sm font-semibold text-fg-primary ml-auto tabular-nums",children:oe})]},R))})})]}),s.jsxs("div",{className:"divide-y divide-border-subtle/50",children:[S.length>0&&s.jsx(ip,{icon:"folder",label:r("globalOverview.projects"),value:S.length,onClick:()=>at.navigate(me.WORK),children:s.jsxs(tv,{children:[Ge," ",r("globalOverview.active")]})}),C.length>0&&s.jsx(ip,{icon:"edit",label:r("globalOverview.requirements"),value:C.length,onClick:()=>at.navigate(me.WORK),children:["in_progress","pending","completed"].map(R=>(he[R]??0)>0&&s.jsxs(tv,{children:[he[R]," ",r(`common:status.${R==="in_progress"?"inProgress":R}`)]},R))}),j>0&&s.jsx(ip,{icon:"book",label:r("globalOverview.deliverables"),value:j,onClick:()=>at.navigate(me.DELIVERABLES)})]})]}),(ye.length>0||x&&x.taskKPI.recentActivity.length>0)&&s.jsx("div",{className:"bg-surface-elevated shadow-sm rounded-2xl overflow-hidden",children:s.jsxs("div",{className:`grid grid-cols-1 ${ye.length>0&&x&&x.taskKPI.recentActivity.length>0?"sm:grid-cols-2 divide-y sm:divide-y-0 sm:divide-x divide-border-subtle/50":""}`,children:[ye.length>0&&s.jsxs("div",{className:"p-5",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 animate-pulse"}),s.jsx("h4",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:r("liveActivity.whosWorking")})]}),s.jsx("div",{className:"space-y-1",children:ye.map(R=>s.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:()=>at.navigate(me.TEAM,{agentId:R.id}),children:[s.jsx(Us,{name:R.name,avatarUrl:R.avatarUrl,size:24,bgClass:"bg-brand-600/30 text-brand-300"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-xs font-medium text-fg-primary truncate",children:R.name}),s.jsx("div",{className:"text-[10px] text-fg-tertiary truncate",children:sL(R.currentActivity?.label,r)??r("agentFocus.working")})]})]},R.id))})]}),x&&x.taskKPI.recentActivity.length>0&&s.jsxs("div",{className:"p-5",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h4",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:r("liveActivity.recentChanges")}),s.jsx("button",{onClick:()=>at.navigate(me.WORK),className:"text-[11px] text-brand-400 hover:text-brand-300 font-medium",children:r("common:viewAll")})]}),s.jsx("div",{className:`${ye.length>0?"":"grid grid-cols-1 sm:grid-cols-2 gap-x-4"}`,children:x.taskKPI.recentActivity.slice(0,ct).map(R=>{const oe=xt.get(R.taskId);return s.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:()=>at.navigate(me.WORK,{openTask:R.taskId}),children:[s.jsx("span",{className:`w-5 h-5 rounded-full flex items-center justify-center shrink-0 ${YD[R.status]??"bg-gray-500/15"}`,children:s.jsx(ZD,{status:R.status})}),s.jsx("span",{className:"text-[11px] text-fg-secondary truncate flex-1",children:R.title}),(oe==="urgent"||oe==="high")&&s.jsx(eL,{priority:oe}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:nv(R.updatedAt,r)})]},R.taskId)})})]})]})})]}),s.jsx("div",{className:"space-y-6",children:V.length>0&&s.jsx("div",{className:"bg-surface-elevated shadow-sm rounded-2xl overflow-hidden",children:s.jsxs("div",{className:"p-5",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:r("teamOverview.title")}),s.jsx("button",{onClick:()=>at.navigate(me.TEAM),className:"text-[11px] text-brand-400 hover:text-brand-300 font-medium",children:r("common:viewAll")})]}),s.jsxs("div",{className:"space-y-0.5",children:[V.slice(0,Xt).map(R=>s.jsxs("div",{className:"flex items-center gap-3 px-2 py-2 rounded-lg hover:bg-surface-overlay/40 cursor-pointer transition-colors",onClick:()=>at.navigate(me.TEAM,{selectTeam:R.team.id}),children:[s.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:R.team.name.charAt(0)}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("div",{className:"text-xs font-medium text-fg-primary truncate",children:R.team.name})}),s.jsx("div",{className:"flex items-center -space-x-1 shrink-0",children:R.agents.slice(0,3).map(oe=>s.jsx(Us,{name:oe.name,avatarUrl:oe.avatarUrl,size:18,bgClass:"bg-surface-overlay text-fg-secondary ring-1 ring-surface-elevated"},oe.id))}),R.working>0&&s.jsxs("span",{className:"text-[10px] text-green-500 font-medium shrink-0",children:[R.working,"/",R.total]})]},R.team.id)),Xt<V.length&&s.jsxs("button",{onClick:()=>at.navigate(me.TEAM),className:"w-full text-center text-[11px] text-brand-400 hover:text-brand-300 font-medium py-1.5",children:["+",V.length-Xt," more"]})]})]})})})]}),!t&&ke!==null&&s.jsx(UD,{contributors:pe.contributors,hubPlan:pe.hubPlan,hubOrgMeta:pe.hubOrgMeta,hubConnected:pe.hubConnected,showMarkusUsage:Qe})]}),Z&&s.jsx(nL,{workingAgents:ye,onClose:()=>U(!1),t:r}),Q&&s.jsx(rL,{ops:x,completed:se,totalRootTasks:Be,workingAgents:Xe,totalAgents:c.length,usageInfo:ee,storageInfo:$,cuQuota:K,onClose:()=>ne(!1),t:r}),We&&s.jsx(LD,{onClose:()=>st(!1),onClaimed:qe})]})}function Ku({label:e,value:t,sub:n,icon:r,pulse:o,color:l,badge:c,onClick:d}){const m=l==="green"?"text-green-500":l==="amber"?"text-amber-500":l==="red"?"text-red-500":"text-fg-primary";return s.jsxs("div",{onClick:d,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:[s.jsxs("div",{children:[s.jsx("div",{className:"text-[11px] text-fg-tertiary mb-2",children:e}),s.jsxs("div",{className:"flex items-baseline gap-0.5",children:[s.jsx("span",{className:`text-2xl sm:text-3xl font-bold ${m} leading-none`,children:t}),n&&s.jsx("span",{className:"text-sm text-fg-muted font-medium",children:n})]}),c&&s.jsx("div",{className:"text-[10px] text-amber-500 font-medium mt-1.5",children:c})]}),s.jsxs("div",{className:"relative",children:[s.jsx("div",{className:"w-10 h-10 rounded-xl bg-surface-overlay/60 flex items-center justify-center text-fg-tertiary",children:r}),o&&s.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-2.5 h-2.5 rounded-full bg-green-500 animate-pulse"})]})]})}function Wu({type:e}){const t={working:s.jsx(s.Fragment,{children:s.jsx("path",{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z"})}),tasks:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),s.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),projects:s.jsx(s.Fragment,{children:s.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:s.jsx(s.Fragment,{children:s.jsx("path",{d:"M22 12h-4l-3 9L9 3l-3 9H2"})})};return s.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 ip({icon:e,label:t,value:n,onClick:r,children:o}){return s.jsxs("div",{className:"flex items-center gap-3 px-5 py-3 hover:bg-surface-overlay/30 cursor-pointer transition-colors",onClick:r,children:[s.jsx("span",{className:"text-fg-muted",children:s.jsx(XD,{type:e})}),s.jsx("span",{className:"text-xs text-fg-secondary",children:t}),s.jsx("span",{className:"text-sm font-semibold text-fg-primary",children:n}),s.jsx("div",{className:"flex items-center gap-2 ml-auto text-[11px] text-fg-tertiary",children:o})]})}function tv({children:e}){return s.jsx("span",{className:"px-2 py-0.5 rounded-full bg-surface-overlay/60 text-[11px] text-fg-secondary",children:e})}function XD({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 s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:t[e]})})}function QD({statusCounts:e,total:t,completionRate:n,completed:r}){const d=2*Math.PI*42,m=w5.filter(g=>(e[g]??0)>0).map(g=>({status:g,value:e[g],color:VD[g]??"#6b7280"}));let p=0;const h=m.map(g=>{const x=g.value/t*d,y={len:Math.max(x-.8,.5),offset:p,color:g.color,status:g.status};return p+=x,y});return s.jsxs("div",{className:"relative shrink-0",style:{width:120,height:120},children:[s.jsx("svg",{width:120,height:120,viewBox:"0 0 120 120",children:h.map((g,x)=>s.jsx("circle",{cx:"60",cy:"60",r:42,fill:"none",stroke:g.color,strokeWidth:12,strokeDasharray:`${g.len} ${d-g.len}`,strokeDashoffset:-g.offset,transform:"rotate(-90 60 60)",className:"transition-all duration-500 cursor-pointer",onClick:()=>at.navigate(me.WORK,{statusFilter:g.status})},x))}),s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[s.jsxs("span",{className:"text-2xl font-bold text-fg-primary leading-none",children:[n,"%"]}),s.jsxs("span",{className:"text-[10px] text-fg-tertiary mt-0.5",children:[r,"/",t]})]})]})}function ZD({status:e}){const n={completed:"#22c55e",in_progress:"#8b5cf6",pending:"#f59e0b",review:"#3b82f6",failed:"#ef4444",blocked:"#f59e0b",rejected:"#ef4444",cancelled:"#6b7280"}[e]??"#6b7280";return s.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"&&s.jsx("polyline",{points:"20 6 9 17 4 12"}),e==="in_progress"&&s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),e==="pending"&&s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),s.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),e==="review"&&s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),(e==="failed"||e==="rejected")&&s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),s.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),e==="blocked"&&s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"4.93",y1:"4.93",x2:"19.07",y2:"19.07"})]}),e==="cancelled"&&s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})]})}function JD({type:e}){const t=e==="review"?"#3b82f6":e==="approval"?"#f59e0b":"#ef4444";return s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:t,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e==="review"&&s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),e==="approval"&&s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),s.jsx("polyline",{points:"14 2 14 8 20 8"}),s.jsx("line",{x1:"12",y1:"18",x2:"12",y2:"12"}),s.jsx("line",{x1:"9",y1:"15",x2:"15",y2:"15"})]}),e==="blocked"&&s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),s.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),s.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})]})}function eL({priority:e}){return e==="urgent"?s.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"?s.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 tL({type:e,artifactType:t}){if(t){const r=t==="agent"?"#8b5cf6":t==="team"?"#3b82f6":"#f59e0b";return s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),s.jsx("path",{d:"M2 17l10 5 10-5"}),s.jsx("path",{d:"M2 12l10 5 10-5"})]})}const n=e==="directory"?"#3b82f6":"#22c55e";return s.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"?s.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"}):s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),s.jsx("polyline",{points:"14 2 14 8 20 8"})]})})}function nL({workingAgents:e,onClose:t,t:n}){return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:s.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:r=>r.stopPropagation(),children:[s.jsxs("div",{className:"px-5 py-4 border-b border-border-default flex items-center justify-between shrink-0",children:[s.jsx("h3",{className:"text-sm font-semibold",children:n("ranking.workingNow")}),s.jsx("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary hover:text-fg-primary",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 scrollbar-thin px-5 py-4",children:e.length>0?s.jsx("div",{className:"space-y-0.5",children:e.map(r=>s.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(),at.navigate(me.TEAM,{agentId:r.id})},children:[s.jsx(Us,{name:r.name,avatarUrl:r.avatarUrl,size:26,bgClass:"bg-brand-600/30 text-brand-300"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-xs font-medium text-fg-primary truncate",children:r.name}),s.jsx("div",{className:"text-[10px] text-fg-tertiary truncate",children:r.currentActivity?.label??"—"})]}),s.jsx("span",{className:"text-[10px] text-green-500 font-medium shrink-0",children:"Working"})]},r.id))}):s.jsx("div",{className:"py-8 text-center text-xs text-fg-tertiary",children:n("ranking.noData")})})]})})}function rL({ops:e,completed:t,totalRootTasks:n,workingAgents:r,totalAgents:o,usageInfo:l,storageInfo:c,cuQuota:d,onClose:m,t:p}){return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:m,children:s.jsxs("div",{className:"bg-surface-elevated rounded-xl border border-border-default shadow-2xl w-[400px] max-w-[90vw] overflow-hidden",onClick:h=>h.stopPropagation(),children:[s.jsxs("div",{className:"px-5 py-4 border-b border-border-default flex items-center justify-between",children:[s.jsx("h3",{className:"text-sm font-semibold",children:p("systemHealth.title")}),s.jsx("button",{onClick:m,className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary hover:text-fg-primary",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),s.jsxs("div",{className:"p-5 space-y-4",children:[e&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-xs text-fg-secondary",children:p("systemHealth.successRate")}),s.jsxs("span",{className:"text-sm font-bold text-fg-primary",children:[Math.round(e.taskKPI.successRate),"%"]})]}),s.jsx("div",{className:"h-2 rounded-full bg-surface-overlay/60 overflow-hidden",children:s.jsx("div",{className:"h-full rounded-full bg-green-500 transition-all duration-500",style:{width:`${Math.round(e.taskKPI.successRate)}%`}})})]}),e&&s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-xs text-fg-secondary",children:p("metricCards.health")}),s.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,"%"]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-xs text-fg-secondary",children:p("systemHealth.tasksTotal")}),s.jsxs("span",{className:"text-xs font-semibold text-fg-primary",children:[t,"/",n]})]}),l&&s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-xs text-fg-secondary",children:p("systemHealth.tokenUsage")}),s.jsx("span",{className:"text-xs font-semibold text-fg-primary",children:Xu(l.llmTokens)})]}),d?.available&&d.cuLimit>0&&(()=>{const h=d.cuLimit-d.cuRemaining,g=Math.min(100,Math.round(h/d.cuLimit*100)),x=g>=95?"text-red-500":g>=80?"text-amber-500":"text-green-500",y=g>=95?"bg-red-500":g>=80?"bg-amber-500":"bg-green-500";return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[s.jsx("span",{className:"text-xs text-fg-secondary",children:"CU Quota"}),s.jsxs("span",{className:`text-xs font-semibold ${x}`,children:[Xu(h)," / ",Xu(d.cuLimit)," (",g,"%)"]})]}),s.jsx("div",{className:"h-2 rounded-full bg-surface-overlay/60 overflow-hidden",children:s.jsx("div",{className:`h-full rounded-full ${y} transition-all duration-500`,style:{width:`${g}%`}})}),d.cuUsedToday!=null&&d.cuUsedToday>0&&s.jsxs("div",{className:"flex items-center justify-between mt-1.5",children:[s.jsx("span",{className:"text-xs text-fg-tertiary",children:"Today's CU Used"}),s.jsx("span",{className:"text-xs font-semibold text-fg-secondary",children:Xu(d.cuUsedToday)})]})]})})(),r>0&&s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-xs text-fg-secondary",children:p("systemHealth.currentWorking")}),s.jsxs("span",{className:"text-xs font-semibold text-green-500",children:[r,"/",o]})]}),c&&s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-xs text-fg-secondary",children:p("systemHealth.storage")}),s.jsx("span",{className:"text-xs font-semibold text-fg-primary",children:iL(c.totalSize)})]})]})]})})}const aL=k.forwardRef(({show:e,onToggle:t,onClose:n,t:r,isMobile:o},l)=>s.jsxs("div",{ref:l,className:"relative",children:[s.jsx("button",{onClick:t,className:"p-2 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary","aria-label":"Create",children:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),s.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}),e&&s.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:s.jsxs("div",{className:"py-1",children:[s.jsx(Yu,{onClick:()=>{n(),at.navigate(me.BUILDER,o?{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:r("home:createMenu.agent")}),s.jsx(Yu,{onClick:()=>{n(),at.navigate(me.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:r("home:createMenu.team")}),s.jsx(Yu,{onClick:()=>{n(),at.navigate(me.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:r("home:createMenu.skill")}),s.jsx("div",{className:"border-t border-border-default my-1"}),s.jsx(Yu,{onClick:()=>{n(),at.navigate(me.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:r("home:createMenu.discover")})]})})]}));function Yu({onClick:e,icon:t,children:n}){return s.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:[s.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:t})}),n]})}function nv(e,t){const n=Date.now()-new Date(e).getTime(),r=Math.floor(n/6e4);if(r<1)return t("common:time.now");if(r<60)return t("common:time.minutesAgo",{count:r});const o=Math.floor(r/60);return o<24?t("common:time.hoursAgo",{count:o}):t("common:time.daysAgo",{count:Math.floor(o/24)})}function sL(e,t){return e?Jy[e]?t(Jy[e]):e:null}function Xu(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 iL(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]}`}function rv(e){const t=[],n=String(e||"");let r=n.indexOf(","),o=0,l=!1;for(;!l;){r===-1&&(r=n.length,l=!0);const c=n.slice(o,r).trim();(c||!l)&&t.push(c),o=r+1,r=n.indexOf(",",o)}return t}function oL(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const lL=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,cL=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,uL={};function av(e,t){return(uL.jsx?cL:lL).test(e)}const dL=/[ \t\n\f\r]/g;function mL(e){return typeof e=="object"?e.type==="text"?sv(e.value):!1:sv(e)}function sv(e){return e.replace(dL,"")===""}class kc{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}kc.prototype.normal={};kc.prototype.property={};kc.prototype.space=void 0;function k5(e,t){const n={},r={};for(const o of e)Object.assign(n,o.property),Object.assign(r,o.normal);return new kc(n,r,t)}function hc(e){return e.toLowerCase()}class jr{constructor(t,n){this.attribute=n,this.property=t}}jr.prototype.attribute="";jr.prototype.booleanish=!1;jr.prototype.boolean=!1;jr.prototype.commaOrSpaceSeparated=!1;jr.prototype.commaSeparated=!1;jr.prototype.defined=!1;jr.prototype.mustUseProperty=!1;jr.prototype.number=!1;jr.prototype.overloadedBoolean=!1;jr.prototype.property="";jr.prototype.spaceSeparated=!1;jr.prototype.space=void 0;let fL=0;const zt=ji(),$n=ji(),mh=ji(),Fe=ji(),gn=ji(),jo=ji(),Ur=ji();function ji(){return 2**++fL}const fh=Object.freeze(Object.defineProperty({__proto__:null,boolean:zt,booleanish:$n,commaOrSpaceSeparated:Ur,commaSeparated:jo,number:Fe,overloadedBoolean:mh,spaceSeparated:gn},Symbol.toStringTag,{value:"Module"})),op=Object.keys(fh);class tg extends jr{constructor(t,n,r,o){let l=-1;if(super(t,n),iv(this,"space",o),typeof r=="number")for(;++l<op.length;){const c=op[l];iv(this,op[l],(r&fh[c])===fh[c])}}}tg.prototype.defined=!0;function iv(e,t,n){n&&(e[t]=n)}function Uo(e){const t={},n={};for(const[r,o]of Object.entries(e.properties)){const l=new tg(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(l.mustUseProperty=!0),t[r]=l,n[hc(r)]=r,n[hc(l.attribute)]=r}return new kc(t,n,e.space)}const S5=Uo({properties:{ariaActiveDescendant:null,ariaAtomic:$n,ariaAutoComplete:null,ariaBusy:$n,ariaChecked:$n,ariaColCount:Fe,ariaColIndex:Fe,ariaColSpan:Fe,ariaControls:gn,ariaCurrent:null,ariaDescribedBy:gn,ariaDetails:null,ariaDisabled:$n,ariaDropEffect:gn,ariaErrorMessage:null,ariaExpanded:$n,ariaFlowTo:gn,ariaGrabbed:$n,ariaHasPopup:null,ariaHidden:$n,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:gn,ariaLevel:Fe,ariaLive:null,ariaModal:$n,ariaMultiLine:$n,ariaMultiSelectable:$n,ariaOrientation:null,ariaOwns:gn,ariaPlaceholder:null,ariaPosInSet:Fe,ariaPressed:$n,ariaReadOnly:$n,ariaRelevant:null,ariaRequired:$n,ariaRoleDescription:gn,ariaRowCount:Fe,ariaRowIndex:Fe,ariaRowSpan:Fe,ariaSelected:$n,ariaSetSize:Fe,ariaSort:null,ariaValueMax:Fe,ariaValueMin:Fe,ariaValueNow:Fe,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function N5(e,t){return t in e?e[t]:t}function C5(e,t){return N5(e,t.toLowerCase())}const pL=Uo({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:jo,acceptCharset:gn,accessKey:gn,action:null,allow:null,allowFullScreen:zt,allowPaymentRequest:zt,allowUserMedia:zt,alt:null,as:null,async:zt,autoCapitalize:null,autoComplete:gn,autoFocus:zt,autoPlay:zt,blocking:gn,capture:null,charSet:null,checked:zt,cite:null,className:gn,cols:Fe,colSpan:null,content:null,contentEditable:$n,controls:zt,controlsList:gn,coords:Fe|jo,crossOrigin:null,data:null,dateTime:null,decoding:null,default:zt,defer:zt,dir:null,dirName:null,disabled:zt,download:mh,draggable:$n,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:zt,formTarget:null,headers:gn,height:Fe,hidden:mh,high:Fe,href:null,hrefLang:null,htmlFor:gn,httpEquiv:gn,id:null,imageSizes:null,imageSrcSet:null,inert:zt,inputMode:null,integrity:null,is:null,isMap:zt,itemId:null,itemProp:gn,itemRef:gn,itemScope:zt,itemType:gn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:zt,low:Fe,manifest:null,max:null,maxLength:Fe,media:null,method:null,min:null,minLength:Fe,multiple:zt,muted:zt,name:null,nonce:null,noModule:zt,noValidate:zt,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:zt,optimum:Fe,pattern:null,ping:gn,placeholder:null,playsInline:zt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:zt,referrerPolicy:null,rel:gn,required:zt,reversed:zt,rows:Fe,rowSpan:Fe,sandbox:gn,scope:null,scoped:zt,seamless:zt,selected:zt,shadowRootClonable:zt,shadowRootDelegatesFocus:zt,shadowRootMode:null,shape:null,size:Fe,sizes:null,slot:null,span:Fe,spellCheck:$n,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Fe,step:null,style:null,tabIndex:Fe,target:null,title:null,translate:null,type:null,typeMustMatch:zt,useMap:null,value:$n,width:Fe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:gn,axis:null,background:null,bgColor:null,border:Fe,borderColor:null,bottomMargin:Fe,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:zt,declare:zt,event:null,face:null,frame:null,frameBorder:null,hSpace:Fe,leftMargin:Fe,link:null,longDesc:null,lowSrc:null,marginHeight:Fe,marginWidth:Fe,noResize:zt,noHref:zt,noShade:zt,noWrap:zt,object:null,profile:null,prompt:null,rev:null,rightMargin:Fe,rules:null,scheme:null,scrolling:$n,standby:null,summary:null,text:null,topMargin:Fe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Fe,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:zt,disableRemotePlayback:zt,prefix:null,property:null,results:Fe,security:null,unselectable:null},space:"html",transform:C5}),hL=Uo({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:Ur,accentHeight:Fe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Fe,amplitude:Fe,arabicForm:null,ascent:Fe,attributeName:null,attributeType:null,azimuth:Fe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Fe,by:null,calcMode:null,capHeight:Fe,className:gn,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:Fe,diffuseConstant:Fe,direction:null,display:null,dur:null,divisor:Fe,dominantBaseline:null,download:zt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Fe,enableBackground:null,end:null,event:null,exponent:Fe,externalResourcesRequired:null,fill:null,fillOpacity:Fe,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:jo,g2:jo,glyphName:jo,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Fe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Fe,horizOriginX:Fe,horizOriginY:Fe,id:null,ideographic:Fe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Fe,k:Fe,k1:Fe,k2:Fe,k3:Fe,k4:Fe,kernelMatrix:Ur,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Fe,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:Fe,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:Fe,overlineThickness:Fe,paintOrder:null,panose1:null,path:null,pathLength:Fe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:gn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Fe,pointsAtY:Fe,pointsAtZ:Fe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ur,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ur,rev:Ur,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ur,requiredFeatures:Ur,requiredFonts:Ur,requiredFormats:Ur,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:Fe,specularExponent:Fe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Fe,strikethroughThickness:Fe,string:null,stroke:null,strokeDashArray:Ur,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Fe,strokeOpacity:Fe,strokeWidth:null,style:null,surfaceScale:Fe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ur,tabIndex:Fe,tableValues:null,target:null,targetX:Fe,targetY:Fe,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ur,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Fe,underlineThickness:Fe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Fe,values:null,vAlphabetic:Fe,vMathematical:Fe,vectorEffect:null,vHanging:Fe,vIdeographic:Fe,version:null,vertAdvY:Fe,vertOriginX:Fe,vertOriginY:Fe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Fe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:N5}),T5=Uo({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()}}),A5=Uo({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:C5}),E5=Uo({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),gL={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"},bL=/[A-Z]/g,ov=/-[a-z]/g,xL=/^data[-\w.:]+$/i;function _5(e,t){const n=hc(t);let r=t,o=jr;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&xL.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(ov,vL);r="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!ov.test(l)){let c=l.replace(bL,yL);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}o=tg}return new o(r,t)}function yL(e){return"-"+e.toLowerCase()}function vL(e){return e.charAt(1).toUpperCase()}const j5=k5([S5,pL,T5,A5,E5],"html"),S0=k5([S5,hL,T5,A5,E5],"svg");function lv(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function wL(e){return e.join(" ").trim()}var xo={},lp,cv;function kL(){if(cv)return lp;cv=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,d=/^\s+|\s+$/g,m=`
|
|
355
355
|
`,p="/",h="*",g="",x="comment",y="declaration";function w(T,S){if(typeof T!="string")throw new TypeError("First argument must be a string");if(!T)return[];S=S||{};var _=1,j=1;function O(F){var Z=F.match(t);Z&&(_+=Z.length);var U=F.lastIndexOf(m);j=~U?F.length-U:j+F.length}function P(){var F={line:_,column:j};return function(Z){return Z.position=new D(F),ee(),Z}}function D(F){this.start=F,this.end={line:_,column:j},this.source=S.source}D.prototype.content=T;function $(F){var Z=new Error(S.source+":"+_+":"+j+": "+F);if(Z.reason=F,Z.filename=S.source,Z.line=_,Z.column=j,Z.source=T,!S.silent)throw Z}function X(F){var Z=F.exec(T);if(Z){var U=Z[0];return O(U),T=T.slice(U.length),Z}}function ee(){X(n)}function H(F){var Z;for(F=F||[];Z=K();)Z!==!1&&F.push(Z);return F}function K(){var F=P();if(!(p!=T.charAt(0)||h!=T.charAt(1))){for(var Z=2;g!=T.charAt(Z)&&(h!=T.charAt(Z)||p!=T.charAt(Z+1));)++Z;if(Z+=2,g===T.charAt(Z-1))return $("End of comment missing");var U=T.slice(2,Z-2);return j+=2,O(U),T=T.slice(Z),j+=2,F({type:x,comment:U})}}function ae(){var F=P(),Z=X(r);if(Z){if(K(),!X(o))return $("property missing ':'");var U=X(l),Q=F({type:y,property:C(Z[0].replace(e,g)),value:U?C(U[0].replace(e,g)):g});return X(c),Q}}function W(){var F=[];H(F);for(var Z;Z=ae();)Z!==!1&&(F.push(Z),H(F));return F}return ee(),W()}function C(T){return T?T.replace(d,g):g}return lp=w,lp}var uv;function SL(){if(uv)return xo;uv=1;var e=xo&&xo.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(xo,"__esModule",{value:!0}),xo.default=n;const t=e(kL());function n(r,o){let l=null;if(!r||typeof r!="string")return l;const c=(0,t.default)(r),d=typeof o=="function";return c.forEach(m=>{if(m.type!=="declaration")return;const{property:p,value:h}=m;d?o(p,h,m):h&&(l=l||{},l[p]=h)}),l}return xo}var ql={},dv;function NL(){if(dv)return ql;dv=1,Object.defineProperty(ql,"__esModule",{value:!0}),ql.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,l=function(p){return!p||n.test(p)||e.test(p)},c=function(p,h){return h.toUpperCase()},d=function(p,h){return"".concat(h,"-")},m=function(p,h){return h===void 0&&(h={}),l(p)?p:(p=p.toLowerCase(),h.reactCompat?p=p.replace(o,d):p=p.replace(r,d),p.replace(t,c))};return ql.camelCase=m,ql}var Gl,mv;function CL(){if(mv)return Gl;mv=1;var e=Gl&&Gl.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},t=e(SL()),n=NL();function r(o,l){var c={};return!o||typeof o!="string"||(0,t.default)(o,function(d,m){d&&m&&(c[(0,n.camelCase)(d,l)]=m)}),c}return r.default=r,Gl=r,Gl}var TL=CL();const AL=wc(TL),M5=R5("end"),ng=R5("start");function R5(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function EL(e){const t=ng(e),n=M5(e);if(t&&n)return{start:t,end:n}}function ec(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?fv(e.position):"start"in e||"end"in e?fv(e):"line"in e||"column"in e?ph(e):""}function ph(e){return pv(e&&e.line)+":"+pv(e&&e.column)}function fv(e){return ph(e&&e.start)+"-"+ph(e&&e.end)}function pv(e){return e&&typeof e=="number"?e:1}class sr extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let o="",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"?o=t:!l.cause&&t&&(c=!0,o=t.message,l.cause=t),!l.ruleId&&!l.source&&typeof r=="string"){const m=r.indexOf(":");m===-1?l.ruleId=r:(l.source=r.slice(0,m),l.ruleId=r.slice(m+1))}if(!l.place&&l.ancestors&&l.ancestors){const m=l.ancestors[l.ancestors.length-1];m&&(l.place=m.position)}const d=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=d?d.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=d?d.line:void 0,this.name=ec(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}}sr.prototype.file="";sr.prototype.name="";sr.prototype.reason="";sr.prototype.message="";sr.prototype.stack="";sr.prototype.column=void 0;sr.prototype.line=void 0;sr.prototype.ancestors=void 0;sr.prototype.cause=void 0;sr.prototype.fatal=void 0;sr.prototype.place=void 0;sr.prototype.ruleId=void 0;sr.prototype.source=void 0;const rg={}.hasOwnProperty,_L=new Map,jL=/[A-Z]/g,ML=new Set(["table","tbody","thead","tfoot","tr"]),RL=new Set(["td","th"]),O5="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function OL(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=$L(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");r=UL(n,t.jsx,t.jsxs)}const o={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,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"?S0:j5,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},l=D5(o,e,void 0);return l&&typeof l!="string"?l:o.create(e,o.Fragment,{children:l||void 0},void 0)}function D5(e,t,n){if(t.type==="element")return DL(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return LL(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return PL(e,t,n);if(t.type==="mdxjsEsm")return IL(e,t);if(t.type==="root")return zL(e,t,n);if(t.type==="text")return BL(e,t)}function DL(e,t,n){const r=e.schema;let o=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(o=S0,e.schema=o),e.ancestors.push(t);const l=I5(e,t.tagName,!1),c=HL(e,t);let d=sg(e,t);return ML.has(t.tagName)&&(d=d.filter(function(m){return typeof m=="string"?!mL(m):!0})),L5(e,c,l,t),ag(c,d),e.ancestors.pop(),e.schema=r,e.create(t,l,c,n)}function LL(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}gc(e,t.position)}function IL(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);gc(e,t.position)}function PL(e,t,n){const r=e.schema;let o=r;t.name==="svg"&&r.space==="html"&&(o=S0,e.schema=o),e.ancestors.push(t);const l=t.name===null?e.Fragment:I5(e,t.name,!0),c=FL(e,t),d=sg(e,t);return L5(e,c,l,t),ag(c,d),e.ancestors.pop(),e.schema=r,e.create(t,l,c,n)}function zL(e,t,n){const r={};return ag(r,sg(e,t)),e.create(t,e.Fragment,r,n)}function BL(e,t){return t.value}function L5(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function ag(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function UL(e,t,n){return r;function r(o,l,c,d){const p=Array.isArray(c.children)?n:t;return d?p(l,c,d):p(l,c)}}function $L(e,t){return n;function n(r,o,l,c){const d=Array.isArray(l.children),m=ng(r);return t(o,l,c,d,{columnNumber:m?m.column-1:void 0,fileName:e,lineNumber:m?m.line:void 0},void 0)}}function HL(e,t){const n={};let r,o;for(o in t.properties)if(o!=="children"&&rg.call(t.properties,o)){const l=qL(e,o,t.properties[o]);if(l){const[c,d]=l;e.tableCellAlignToStyle&&c==="align"&&typeof d=="string"&&RL.has(t.tagName)?r=d:n[c]=d}}if(r){const l=n.style||(n.style={});l[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function FL(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const l=r.data.estree.body[0];l.type;const c=l.expression;c.type;const d=c.properties[0];d.type,Object.assign(n,e.evaluater.evaluateExpression(d.argument))}else gc(e,t.position);else{const o=r.name;let l;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const d=r.value.data.estree.body[0];d.type,l=e.evaluater.evaluateExpression(d.expression)}else gc(e,t.position);else l=r.value===null?!0:r.value;n[o]=l}return n}function sg(e,t){const n=[];let r=-1;const o=e.passKeys?new Map:_L;for(;++r<t.children.length;){const l=t.children[r];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 p=o.get(m)||0;c=m+"-"+p,o.set(m,p+1)}}const d=D5(e,l,c);d!==void 0&&n.push(d)}return n}function qL(e,t,n){const r=_5(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?oL(n):wL(n)),r.property==="style"){let o=typeof n=="object"?n:GL(e,String(n));return e.stylePropertyNameCase==="css"&&(o=VL(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&r.space?gL[r.property]||r.property:r.attribute,n]}}function GL(e,t){try{return AL(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,o=new sr("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw o.file=e.filePath||void 0,o.url=O5+"#cannot-parse-style-attribute",o}}function I5(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const o=t.split(".");let l=-1,c;for(;++l<o.length;){const d=av(o[l])?{type:"Identifier",name:o[l]}:{type:"Literal",value:o[l]};c=c?{type:"MemberExpression",object:c,property:d,computed:!!(l&&d.type==="Literal"),optional:!1}:d}r=c}else r=av(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const o=r.value;return rg.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(r);gc(e)}function gc(e,t){const n=new sr("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=O5+"#cannot-handle-mdx-estrees-without-createevaluater",n}function VL(e){const t={};let n;for(n in e)rg.call(e,n)&&(t[KL(n)]=e[n]);return t}function KL(e){let t=e.replace(jL,WL);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function WL(e){return"-"+e.toLowerCase()}const cp={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"]},YL={};function ig(e,t){const n=YL,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,o=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return P5(e,r,o)}function P5(e,t,n){if(XL(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 hv(e.children,t,n)}return Array.isArray(e)?hv(e,t,n):""}function hv(e,t,n){const r=[];let o=-1;for(;++o<e.length;)r[o]=P5(e[o],t,n);return r.join("")}function XL(e){return!!(e&&typeof e=="object")}const gv=document.createElement("i");function og(e){const t="&"+e+";";gv.innerHTML=t;const n=gv.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function $r(e,t,n,r){const o=e.length;let l=0,c;if(t<0?t=-t>o?0:o+t:t=t>o?o:t,n=n>0?n:0,r.length<1e4)c=Array.from(r),c.unshift(t,n),e.splice(...c);else for(n&&e.splice(t,n);l<r.length;)c=r.slice(l,l+1e4),c.unshift(t,0),e.splice(...c),l+=1e4,t+=1e4}function ra(e,t){return e.length>0?($r(e,e.length,0,t),e):t}const bv={}.hasOwnProperty;function z5(e){const t={};let n=-1;for(;++n<e.length;)QL(t,e[n]);return t}function QL(e,t){let n;for(n in t){const o=(bv.call(e,n)?e[n]:void 0)||(e[n]={}),l=t[n];let c;if(l)for(c in l){bv.call(o,c)||(o[c]=[]);const d=l[c];ZL(o[c],Array.isArray(d)?d:d?[d]:[])}}}function ZL(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);$r(e,0,0,r)}function B5(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 da(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const mr=Gs(/[A-Za-z]/),rr=Gs(/[\dA-Za-z]/),JL=Gs(/[#-'*+\--9=?A-Z^-~]/);function Zd(e){return e!==null&&(e<32||e===127)}const hh=Gs(/\d/),eI=Gs(/[\dA-Fa-f]/),tI=Gs(/[!-/:-@[-`{-~]/);function bt(e){return e!==null&&e<-2}function fn(e){return e!==null&&(e<0||e===32)}function Gt(e){return e===-2||e===-1||e===32}const N0=Gs(new RegExp("\\p{P}|\\p{S}","u")),Ei=Gs(/\s/);function Gs(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function $o(e){const t=[];let n=-1,r=0,o=0;for(;++n<e.length;){const l=e.charCodeAt(n);let c="";if(l===37&&rr(e.charCodeAt(n+1))&&rr(e.charCodeAt(n+2)))o=2;else if(l<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(l))||(c=String.fromCharCode(l));else if(l>55295&&l<57344){const d=e.charCodeAt(n+1);l<56320&&d>56319&&d<57344?(c=String.fromCharCode(l,d),o=1):c="�"}else c=String.fromCharCode(l);c&&(t.push(e.slice(r,n),encodeURIComponent(c)),r=n+o+1,c=""),o&&(n+=o,o=0)}return t.join("")+e.slice(r)}function Ht(e,t,n,r){const o=r?r-1:Number.POSITIVE_INFINITY;let l=0;return c;function c(m){return Gt(m)?(e.enter(n),d(m)):t(m)}function d(m){return Gt(m)&&l++<o?(e.consume(m),d):(e.exit(n),t(m))}}const nI={tokenize:rI};function rI(e){const t=e.attempt(this.parser.constructs.contentInitial,r,o);let n;return t;function r(d){if(d===null){e.consume(d);return}return e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),Ht(e,t,"linePrefix")}function o(d){return e.enter("paragraph"),l(d)}function l(d){const m=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=m),n=m,c(d)}function c(d){if(d===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(d);return}return bt(d)?(e.consume(d),e.exit("chunkText"),l):(e.consume(d),c)}}const aI={tokenize:sI},xv={tokenize:iI};function sI(e){const t=this,n=[];let r=0,o,l,c;return d;function d(j){if(r<n.length){const O=n[r];return t.containerState=O[1],e.attempt(O[0].continuation,m,p)(j)}return p(j)}function m(j){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,o&&_();const O=t.events.length;let P=O,D;for(;P--;)if(t.events[P][0]==="exit"&&t.events[P][1].type==="chunkFlow"){D=t.events[P][1].end;break}S(r);let $=O;for(;$<t.events.length;)t.events[$][1].end={...D},$++;return $r(t.events,P+1,0,t.events.slice(O)),t.events.length=$,p(j)}return d(j)}function p(j){if(r===n.length){if(!o)return x(j);if(o.currentConstruct&&o.currentConstruct.concrete)return w(j);t.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(xv,h,g)(j)}function h(j){return o&&_(),S(r),x(j)}function g(j){return t.parser.lazy[t.now().line]=r!==n.length,c=t.now().offset,w(j)}function x(j){return t.containerState={},e.attempt(xv,y,w)(j)}function y(j){return r++,n.push([t.currentConstruct,t.containerState]),x(j)}function w(j){if(j===null){o&&_(),S(0),e.consume(j);return}return o=o||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:l}),C(j)}function C(j){if(j===null){T(e.exit("chunkFlow"),!0),S(0),e.consume(j);return}return bt(j)?(e.consume(j),T(e.exit("chunkFlow")),r=0,t.interrupt=void 0,d):(e.consume(j),C)}function T(j,O){const P=t.sliceStream(j);if(O&&P.push(null),j.previous=l,l&&(l.next=j),l=j,o.defineSkip(j.start),o.write(P),t.parser.lazy[j.start.line]){let D=o.events.length;for(;D--;)if(o.events[D][1].start.offset<c&&(!o.events[D][1].end||o.events[D][1].end.offset>c))return;const $=t.events.length;let X=$,ee,H;for(;X--;)if(t.events[X][0]==="exit"&&t.events[X][1].type==="chunkFlow"){if(ee){H=t.events[X][1].end;break}ee=!0}for(S(r),D=$;D<t.events.length;)t.events[D][1].end={...H},D++;$r(t.events,X+1,0,t.events.slice($)),t.events.length=D}}function S(j){let O=n.length;for(;O-- >j;){const P=n[O];t.containerState=P[1],P[0].exit.call(t,e)}n.length=j}function _(){o.write([null]),l=void 0,o=void 0,t.containerState._closeFlow=void 0}}function iI(e,t,n){return Ht(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Oo(e){if(e===null||fn(e)||Ei(e))return 1;if(N0(e))return 2}function C0(e,t,n){const r=[];let o=-1;for(;++o<e.length;){const l=e[o].resolveAll;l&&!r.includes(l)&&(t=l(t,n),r.push(l))}return t}const gh={name:"attention",resolveAll:oI,tokenize:lI};function oI(e,t){let n=-1,r,o,l,c,d,m,p,h;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;m=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const g={...e[r][1].end},x={...e[n][1].start};yv(g,-m),yv(x,m),c={type:m>1?"strongSequence":"emphasisSequence",start:g,end:{...e[r][1].end}},d={type:m>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:x},l={type:m>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},o={type:m>1?"strong":"emphasis",start:{...c.start},end:{...d.end}},e[r][1].end={...c.start},e[n][1].start={...d.end},p=[],e[r][1].end.offset-e[r][1].start.offset&&(p=ra(p,[["enter",e[r][1],t],["exit",e[r][1],t]])),p=ra(p,[["enter",o,t],["enter",c,t],["exit",c,t],["enter",l,t]]),p=ra(p,C0(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),p=ra(p,[["exit",l,t],["enter",d,t],["exit",d,t],["exit",o,t]]),e[n][1].end.offset-e[n][1].start.offset?(h=2,p=ra(p,[["enter",e[n][1],t],["exit",e[n][1],t]])):h=0,$r(e,r-1,n-r+3,p),n=r+p.length-h-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function lI(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,o=Oo(r);let l;return c;function c(m){return l=m,e.enter("attentionSequence"),d(m)}function d(m){if(m===l)return e.consume(m),d;const p=e.exit("attentionSequence"),h=Oo(m),g=!h||h===2&&o||n.includes(m),x=!o||o===2&&h||n.includes(r);return p._open=!!(l===42?g:g&&(o||!x)),p._close=!!(l===42?x:x&&(h||!g)),t(m)}}function yv(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const cI={name:"autolink",tokenize:uI};function uI(e,t,n){let r=0;return o;function o(y){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),l}function l(y){return mr(y)?(e.consume(y),c):y===64?n(y):p(y)}function c(y){return y===43||y===45||y===46||rr(y)?(r=1,d(y)):p(y)}function d(y){return y===58?(e.consume(y),r=0,m):(y===43||y===45||y===46||rr(y))&&r++<32?(e.consume(y),d):(r=0,p(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||Zd(y)?n(y):(e.consume(y),m)}function p(y){return y===64?(e.consume(y),h):JL(y)?(e.consume(y),p):n(y)}function h(y){return rr(y)?g(y):n(y)}function g(y){return y===46?(e.consume(y),r=0,h):y===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),t):x(y)}function x(y){if((y===45||rr(y))&&r++<63){const w=y===45?x:g;return e.consume(y),w}return n(y)}}const Sc={partial:!0,tokenize:dI};function dI(e,t,n){return r;function r(l){return Gt(l)?Ht(e,o,"linePrefix")(l):o(l)}function o(l){return l===null||bt(l)?t(l):n(l)}}const U5={continuation:{tokenize:fI},exit:pI,name:"blockQuote",tokenize:mI};function mI(e,t,n){const r=this;return o;function o(c){if(c===62){const d=r.containerState;return d.open||(e.enter("blockQuote",{_container:!0}),d.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(c),e.exit("blockQuoteMarker"),l}return n(c)}function l(c){return Gt(c)?(e.enter("blockQuotePrefixWhitespace"),e.consume(c),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(c))}}function fI(e,t,n){const r=this;return o;function o(c){return Gt(c)?Ht(e,l,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):l(c)}function l(c){return e.attempt(U5,t,n)(c)}}function pI(e){e.exit("blockQuote")}const $5={name:"characterEscape",tokenize:hI};function hI(e,t,n){return r;function r(l){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(l),e.exit("escapeMarker"),o}function o(l){return tI(l)?(e.enter("characterEscapeValue"),e.consume(l),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(l)}}const H5={name:"characterReference",tokenize:gI};function gI(e,t,n){const r=this;let o=0,l,c;return d;function d(g){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),m}function m(g){return g===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(g),e.exit("characterReferenceMarkerNumeric"),p):(e.enter("characterReferenceValue"),l=31,c=rr,h(g))}function p(g){return g===88||g===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(g),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),l=6,c=eI,h):(e.enter("characterReferenceValue"),l=7,c=hh,h(g))}function h(g){if(g===59&&o){const x=e.exit("characterReferenceValue");return c===rr&&!og(r.sliceSerialize(x))?n(g):(e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return c(g)&&o++<l?(e.consume(g),h):n(g)}}const vv={partial:!0,tokenize:xI},wv={concrete:!0,name:"codeFenced",tokenize:bI};function bI(e,t,n){const r=this,o={partial:!0,tokenize:P};let l=0,c=0,d;return m;function m(D){return p(D)}function p(D){const $=r.events[r.events.length-1];return l=$&&$[1].type==="linePrefix"?$[2].sliceSerialize($[1],!0).length:0,d=D,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),h(D)}function h(D){return D===d?(c++,e.consume(D),h):c<3?n(D):(e.exit("codeFencedFenceSequence"),Gt(D)?Ht(e,g,"whitespace")(D):g(D))}function g(D){return D===null||bt(D)?(e.exit("codeFencedFence"),r.interrupt?t(D):e.check(vv,C,O)(D)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),x(D))}function x(D){return D===null||bt(D)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),g(D)):Gt(D)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ht(e,y,"whitespace")(D)):D===96&&D===d?n(D):(e.consume(D),x)}function y(D){return D===null||bt(D)?g(D):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),w(D))}function w(D){return D===null||bt(D)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),g(D)):D===96&&D===d?n(D):(e.consume(D),w)}function C(D){return e.attempt(o,O,T)(D)}function T(D){return e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),S}function S(D){return l>0&&Gt(D)?Ht(e,_,"linePrefix",l+1)(D):_(D)}function _(D){return D===null||bt(D)?e.check(vv,C,O)(D):(e.enter("codeFlowValue"),j(D))}function j(D){return D===null||bt(D)?(e.exit("codeFlowValue"),_(D)):(e.consume(D),j)}function O(D){return e.exit("codeFenced"),t(D)}function P(D,$,X){let ee=0;return H;function H(Z){return D.enter("lineEnding"),D.consume(Z),D.exit("lineEnding"),K}function K(Z){return D.enter("codeFencedFence"),Gt(Z)?Ht(D,ae,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(Z):ae(Z)}function ae(Z){return Z===d?(D.enter("codeFencedFenceSequence"),W(Z)):X(Z)}function W(Z){return Z===d?(ee++,D.consume(Z),W):ee>=c?(D.exit("codeFencedFenceSequence"),Gt(Z)?Ht(D,F,"whitespace")(Z):F(Z)):X(Z)}function F(Z){return Z===null||bt(Z)?(D.exit("codeFencedFence"),$(Z)):X(Z)}}}function xI(e,t,n){const r=this;return o;function o(c){return c===null?n(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),l)}function l(c){return r.parser.lazy[r.now().line]?n(c):t(c)}}const up={name:"codeIndented",tokenize:vI},yI={partial:!0,tokenize:wI};function vI(e,t,n){const r=this;return o;function o(p){return e.enter("codeIndented"),Ht(e,l,"linePrefix",5)(p)}function l(p){const h=r.events[r.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?c(p):n(p)}function c(p){return p===null?m(p):bt(p)?e.attempt(yI,c,m)(p):(e.enter("codeFlowValue"),d(p))}function d(p){return p===null||bt(p)?(e.exit("codeFlowValue"),c(p)):(e.consume(p),d)}function m(p){return e.exit("codeIndented"),t(p)}}function wI(e,t,n){const r=this;return o;function o(c){return r.parser.lazy[r.now().line]?n(c):bt(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o):Ht(e,l,"linePrefix",5)(c)}function l(c){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?t(c):bt(c)?o(c):n(c)}}const kI={name:"codeText",previous:NI,resolve:SI,tokenize:CI};function SI(e){let t=e.length-4,n=3,r,o;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)o===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(o=r):(r===t||e[r][1].type==="lineEnding")&&(e[o][1].type="codeTextData",r!==o+2&&(e[o][1].end=e[r-1][1].end,e.splice(o+2,r-o-2),t-=r-o-2,r=o+2),o=void 0);return e}function NI(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function CI(e,t,n){let r=0,o,l;return c;function c(g){return e.enter("codeText"),e.enter("codeTextSequence"),d(g)}function d(g){return g===96?(e.consume(g),r++,d):(e.exit("codeTextSequence"),m(g))}function m(g){return g===null?n(g):g===32?(e.enter("space"),e.consume(g),e.exit("space"),m):g===96?(l=e.enter("codeTextSequence"),o=0,h(g)):bt(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),m):(e.enter("codeTextData"),p(g))}function p(g){return g===null||g===32||g===96||bt(g)?(e.exit("codeTextData"),m(g)):(e.consume(g),p)}function h(g){return g===96?(e.consume(g),o++,h):o===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(g)):(l.type="codeTextData",p(g))}}class TI{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 r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const o=n||0;this.setCursor(Math.trunc(t));const l=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return r&&Vl(this.left,r),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),Vl(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Vl(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);Vl(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Vl(this.left,n.reverse())}}}function Vl(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 F5(e){const t={};let n=-1,r,o,l,c,d,m,p;const h=new TI(e);for(;++n<h.length;){for(;n in t;)n=t[n];if(r=h.get(n),n&&r[1].type==="chunkFlow"&&h.get(n-1)[1].type==="listItemPrefix"&&(m=r[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(r[0]==="enter")r[1].contentType&&(Object.assign(t,AI(h,n)),n=t[n],p=!0);else if(r[1]._container){for(l=n,o=void 0;l--;)if(c=h.get(l),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(o&&(h.get(o)[1].type="lineEndingBlank"),c[1].type="lineEnding",o=l);else if(!(c[1].type==="linePrefix"||c[1].type==="listItemIndent"))break;o&&(r[1].end={...h.get(o)[1].start},d=h.slice(o,n),d.unshift(r),h.splice(o,n-o+1,d))}}return $r(e,0,Number.POSITIVE_INFINITY,h.slice(0)),!p}function AI(e,t){const n=e.get(t)[1],r=e.get(t)[2];let o=t-1;const l=[];let c=n._tokenizer;c||(c=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));const d=c.events,m=[],p={};let h,g,x=-1,y=n,w=0,C=0;const T=[C];for(;y;){for(;e.get(++o)[1]!==y;);l.push(o),y._tokenizer||(h=r.sliceStream(y),y.next||h.push(null),g&&c.defineSkip(y.start),y._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(h),y._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),g=y,y=y.next}for(y=n;++x<d.length;)d[x][0]==="exit"&&d[x-1][0]==="enter"&&d[x][1].type===d[x-1][1].type&&d[x][1].start.line!==d[x][1].end.line&&(C=x+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(),x=T.length;x--;){const S=d.slice(T[x],T[x+1]),_=l.pop();m.push([_,_+S.length-1]),e.splice(_,2,S)}for(m.reverse(),x=-1;++x<m.length;)p[w+m[x][0]]=w+m[x][1],w+=m[x][1]-m[x][0]-1;return p}const EI={resolve:jI,tokenize:MI},_I={partial:!0,tokenize:RI};function jI(e){return F5(e),e}function MI(e,t){let n;return r;function r(d){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),o(d)}function o(d){return d===null?l(d):bt(d)?e.check(_I,c,l)(d):(e.consume(d),o)}function l(d){return e.exit("chunkContent"),e.exit("content"),t(d)}function c(d){return e.consume(d),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,o}}function RI(e,t,n){const r=this;return o;function o(c){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),Ht(e,l,"linePrefix")}function l(c){if(c===null||bt(c))return n(c);const d=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?t(c):e.interrupt(r.parser.constructs.flow,n,t)(c)}}function q5(e,t,n,r,o,l,c,d,m){const p=m||Number.POSITIVE_INFINITY;let h=0;return g;function g(S){return S===60?(e.enter(r),e.enter(o),e.enter(l),e.consume(S),e.exit(l),x):S===null||S===32||S===41||Zd(S)?n(S):(e.enter(r),e.enter(c),e.enter(d),e.enter("chunkString",{contentType:"string"}),C(S))}function x(S){return S===62?(e.enter(l),e.consume(S),e.exit(l),e.exit(o),e.exit(r),t):(e.enter(d),e.enter("chunkString",{contentType:"string"}),y(S))}function y(S){return S===62?(e.exit("chunkString"),e.exit(d),x(S)):S===null||S===60||bt(S)?n(S):(e.consume(S),S===92?w:y)}function w(S){return S===60||S===62||S===92?(e.consume(S),y):y(S)}function C(S){return!h&&(S===null||S===41||fn(S))?(e.exit("chunkString"),e.exit(d),e.exit(c),e.exit(r),t(S)):h<p&&S===40?(e.consume(S),h++,C):S===41?(e.consume(S),h--,C):S===null||S===32||S===40||Zd(S)?n(S):(e.consume(S),S===92?T:C)}function T(S){return S===40||S===41||S===92?(e.consume(S),C):C(S)}}function G5(e,t,n,r,o,l){const c=this;let d=0,m;return p;function p(y){return e.enter(r),e.enter(o),e.consume(y),e.exit(o),e.enter(l),h}function h(y){return d>999||y===null||y===91||y===93&&!m||y===94&&!d&&"_hiddenFootnoteSupport"in c.parser.constructs?n(y):y===93?(e.exit(l),e.enter(o),e.consume(y),e.exit(o),e.exit(r),t):bt(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),h):(e.enter("chunkString",{contentType:"string"}),g(y))}function g(y){return y===null||y===91||y===93||bt(y)||d++>999?(e.exit("chunkString"),h(y)):(e.consume(y),m||(m=!Gt(y)),y===92?x:g)}function x(y){return y===91||y===92||y===93?(e.consume(y),d++,g):g(y)}}function V5(e,t,n,r,o,l){let c;return d;function d(x){return x===34||x===39||x===40?(e.enter(r),e.enter(o),e.consume(x),e.exit(o),c=x===40?41:x,m):n(x)}function m(x){return x===c?(e.enter(o),e.consume(x),e.exit(o),e.exit(r),t):(e.enter(l),p(x))}function p(x){return x===c?(e.exit(l),m(c)):x===null?n(x):bt(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),Ht(e,p,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),h(x))}function h(x){return x===c||x===null||bt(x)?(e.exit("chunkString"),p(x)):(e.consume(x),x===92?g:h)}function g(x){return x===c||x===92?(e.consume(x),h):h(x)}}function tc(e,t){let n;return r;function r(o){return bt(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n=!0,r):Gt(o)?Ht(e,r,n?"linePrefix":"lineSuffix")(o):t(o)}}const OI={name:"definition",tokenize:LI},DI={partial:!0,tokenize:II};function LI(e,t,n){const r=this;let o;return l;function l(y){return e.enter("definition"),c(y)}function c(y){return G5.call(r,e,d,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function d(y){return o=da(r.sliceSerialize(r.events[r.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 fn(y)?tc(e,p)(y):p(y)}function p(y){return q5(e,h,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function h(y){return e.attempt(DI,g,g)(y)}function g(y){return Gt(y)?Ht(e,x,"whitespace")(y):x(y)}function x(y){return y===null||bt(y)?(e.exit("definition"),r.parser.defined.push(o),t(y)):n(y)}}function II(e,t,n){return r;function r(d){return fn(d)?tc(e,o)(d):n(d)}function o(d){return V5(e,l,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(d)}function l(d){return Gt(d)?Ht(e,c,"whitespace")(d):c(d)}function c(d){return d===null||bt(d)?t(d):n(d)}}const PI={name:"hardBreakEscape",tokenize:zI};function zI(e,t,n){return r;function r(l){return e.enter("hardBreakEscape"),e.consume(l),o}function o(l){return bt(l)?(e.exit("hardBreakEscape"),t(l)):n(l)}}const BI={name:"headingAtx",resolve:UI,tokenize:$I};function UI(e,t){let n=e.length-2,r=3,o,l;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(o={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},l={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},$r(e,r,n-r+1,[["enter",o,t],["enter",l,t],["exit",l,t],["exit",o,t]])),e}function $I(e,t,n){let r=0;return o;function o(h){return e.enter("atxHeading"),l(h)}function l(h){return e.enter("atxHeadingSequence"),c(h)}function c(h){return h===35&&r++<6?(e.consume(h),c):h===null||fn(h)?(e.exit("atxHeadingSequence"),d(h)):n(h)}function d(h){return h===35?(e.enter("atxHeadingSequence"),m(h)):h===null||bt(h)?(e.exit("atxHeading"),t(h)):Gt(h)?Ht(e,d,"whitespace")(h):(e.enter("atxHeadingText"),p(h))}function m(h){return h===35?(e.consume(h),m):(e.exit("atxHeadingSequence"),d(h))}function p(h){return h===null||h===35||fn(h)?(e.exit("atxHeadingText"),d(h)):(e.consume(h),p)}}const HI=["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"],kv=["pre","script","style","textarea"],FI={concrete:!0,name:"htmlFlow",resolveTo:VI,tokenize:KI},qI={partial:!0,tokenize:YI},GI={partial:!0,tokenize:WI};function VI(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 KI(e,t,n){const r=this;let o,l,c,d,m;return p;function p(I){return h(I)}function h(I){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(I),g}function g(I){return I===33?(e.consume(I),x):I===47?(e.consume(I),l=!0,C):I===63?(e.consume(I),o=3,r.interrupt?t:B):mr(I)?(e.consume(I),c=String.fromCharCode(I),T):n(I)}function x(I){return I===45?(e.consume(I),o=2,y):I===91?(e.consume(I),o=5,d=0,w):mr(I)?(e.consume(I),o=4,r.interrupt?t:B):n(I)}function y(I){return I===45?(e.consume(I),r.interrupt?t:B):n(I)}function w(I){const Ae="CDATA[";return I===Ae.charCodeAt(d++)?(e.consume(I),d===Ae.length?r.interrupt?t:ae:w):n(I)}function C(I){return mr(I)?(e.consume(I),c=String.fromCharCode(I),T):n(I)}function T(I){if(I===null||I===47||I===62||fn(I)){const Ae=I===47,$e=c.toLowerCase();return!Ae&&!l&&kv.includes($e)?(o=1,r.interrupt?t(I):ae(I)):HI.includes(c.toLowerCase())?(o=6,Ae?(e.consume(I),S):r.interrupt?t(I):ae(I)):(o=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(I):l?_(I):j(I))}return I===45||rr(I)?(e.consume(I),c+=String.fromCharCode(I),T):n(I)}function S(I){return I===62?(e.consume(I),r.interrupt?t:ae):n(I)}function _(I){return Gt(I)?(e.consume(I),_):H(I)}function j(I){return I===47?(e.consume(I),H):I===58||I===95||mr(I)?(e.consume(I),O):Gt(I)?(e.consume(I),j):H(I)}function O(I){return I===45||I===46||I===58||I===95||rr(I)?(e.consume(I),O):P(I)}function P(I){return I===61?(e.consume(I),D):Gt(I)?(e.consume(I),P):j(I)}function D(I){return I===null||I===60||I===61||I===62||I===96?n(I):I===34||I===39?(e.consume(I),m=I,$):Gt(I)?(e.consume(I),D):X(I)}function $(I){return I===m?(e.consume(I),m=null,ee):I===null||bt(I)?n(I):(e.consume(I),$)}function X(I){return I===null||I===34||I===39||I===47||I===60||I===61||I===62||I===96||fn(I)?P(I):(e.consume(I),X)}function ee(I){return I===47||I===62||Gt(I)?j(I):n(I)}function H(I){return I===62?(e.consume(I),K):n(I)}function K(I){return I===null||bt(I)?ae(I):Gt(I)?(e.consume(I),K):n(I)}function ae(I){return I===45&&o===2?(e.consume(I),U):I===60&&o===1?(e.consume(I),Q):I===62&&o===4?(e.consume(I),q):I===63&&o===3?(e.consume(I),B):I===93&&o===5?(e.consume(I),ke):bt(I)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(qI,le,W)(I)):I===null||bt(I)?(e.exit("htmlFlowData"),W(I)):(e.consume(I),ae)}function W(I){return e.check(GI,F,le)(I)}function F(I){return e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),Z}function Z(I){return I===null||bt(I)?W(I):(e.enter("htmlFlowData"),ae(I))}function U(I){return I===45?(e.consume(I),B):ae(I)}function Q(I){return I===47?(e.consume(I),c="",ne):ae(I)}function ne(I){if(I===62){const Ae=c.toLowerCase();return kv.includes(Ae)?(e.consume(I),q):ae(I)}return mr(I)&&c.length<8?(e.consume(I),c+=String.fromCharCode(I),ne):ae(I)}function ke(I){return I===93?(e.consume(I),B):ae(I)}function B(I){return I===62?(e.consume(I),q):I===45&&o===2?(e.consume(I),B):ae(I)}function q(I){return I===null||bt(I)?(e.exit("htmlFlowData"),le(I)):(e.consume(I),q)}function le(I){return e.exit("htmlFlow"),t(I)}}function WI(e,t,n){const r=this;return o;function o(c){return bt(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),l):n(c)}function l(c){return r.parser.lazy[r.now().line]?n(c):t(c)}}function YI(e,t,n){return r;function r(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(Sc,t,n)}}const XI={name:"htmlText",tokenize:QI};function QI(e,t,n){const r=this;let o,l,c;return d;function d(B){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(B),m}function m(B){return B===33?(e.consume(B),p):B===47?(e.consume(B),P):B===63?(e.consume(B),j):mr(B)?(e.consume(B),X):n(B)}function p(B){return B===45?(e.consume(B),h):B===91?(e.consume(B),l=0,w):mr(B)?(e.consume(B),_):n(B)}function h(B){return B===45?(e.consume(B),y):n(B)}function g(B){return B===null?n(B):B===45?(e.consume(B),x):bt(B)?(c=g,Q(B)):(e.consume(B),g)}function x(B){return B===45?(e.consume(B),y):g(B)}function y(B){return B===62?U(B):B===45?x(B):g(B)}function w(B){const q="CDATA[";return B===q.charCodeAt(l++)?(e.consume(B),l===q.length?C:w):n(B)}function C(B){return B===null?n(B):B===93?(e.consume(B),T):bt(B)?(c=C,Q(B)):(e.consume(B),C)}function T(B){return B===93?(e.consume(B),S):C(B)}function S(B){return B===62?U(B):B===93?(e.consume(B),S):C(B)}function _(B){return B===null||B===62?U(B):bt(B)?(c=_,Q(B)):(e.consume(B),_)}function j(B){return B===null?n(B):B===63?(e.consume(B),O):bt(B)?(c=j,Q(B)):(e.consume(B),j)}function O(B){return B===62?U(B):j(B)}function P(B){return mr(B)?(e.consume(B),D):n(B)}function D(B){return B===45||rr(B)?(e.consume(B),D):$(B)}function $(B){return bt(B)?(c=$,Q(B)):Gt(B)?(e.consume(B),$):U(B)}function X(B){return B===45||rr(B)?(e.consume(B),X):B===47||B===62||fn(B)?ee(B):n(B)}function ee(B){return B===47?(e.consume(B),U):B===58||B===95||mr(B)?(e.consume(B),H):bt(B)?(c=ee,Q(B)):Gt(B)?(e.consume(B),ee):U(B)}function H(B){return B===45||B===46||B===58||B===95||rr(B)?(e.consume(B),H):K(B)}function K(B){return B===61?(e.consume(B),ae):bt(B)?(c=K,Q(B)):Gt(B)?(e.consume(B),K):ee(B)}function ae(B){return B===null||B===60||B===61||B===62||B===96?n(B):B===34||B===39?(e.consume(B),o=B,W):bt(B)?(c=ae,Q(B)):Gt(B)?(e.consume(B),ae):(e.consume(B),F)}function W(B){return B===o?(e.consume(B),o=void 0,Z):B===null?n(B):bt(B)?(c=W,Q(B)):(e.consume(B),W)}function F(B){return B===null||B===34||B===39||B===60||B===61||B===96?n(B):B===47||B===62||fn(B)?ee(B):(e.consume(B),F)}function Z(B){return B===47||B===62||fn(B)?ee(B):n(B)}function U(B){return B===62?(e.consume(B),e.exit("htmlTextData"),e.exit("htmlText"),t):n(B)}function Q(B){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),ne}function ne(B){return Gt(B)?Ht(e,ke,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(B):ke(B)}function ke(B){return e.enter("htmlTextData"),c(B)}}const lg={name:"labelEnd",resolveAll:tP,resolveTo:nP,tokenize:rP},ZI={tokenize:aP},JI={tokenize:sP},eP={tokenize:iP};function tP(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const o=r.type==="labelImage"?4:2;r.type="data",t+=o}}return e.length!==n.length&&$r(e,0,e.length,n),e}function nP(e,t){let n=e.length,r=0,o,l,c,d;for(;n--;)if(o=e[n][1],l){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;e[n][0]==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(c){if(e[n][0]==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(l=n,o.type!=="labelLink")){r=2;break}}else o.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}},p={type:"label",start:{...e[l][1].start},end:{...e[c][1].end}},h={type:"labelText",start:{...e[l+r+2][1].end},end:{...e[c-2][1].start}};return d=[["enter",m,t],["enter",p,t]],d=ra(d,e.slice(l+1,l+r+3)),d=ra(d,[["enter",h,t]]),d=ra(d,C0(t.parser.constructs.insideSpan.null,e.slice(l+r+4,c-3),t)),d=ra(d,[["exit",h,t],e[c-2],e[c-1],["exit",p,t]]),d=ra(d,e.slice(c+1)),d=ra(d,[["exit",m,t]]),$r(e,l,e.length,d),e}function rP(e,t,n){const r=this;let o=r.events.length,l,c;for(;o--;)if((r.events[o][1].type==="labelImage"||r.events[o][1].type==="labelLink")&&!r.events[o][1]._balanced){l=r.events[o][1];break}return d;function d(x){return l?l._inactive?g(x):(c=r.parser.defined.includes(da(r.sliceSerialize({start:l.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(x),e.exit("labelMarker"),e.exit("labelEnd"),m):n(x)}function m(x){return x===40?e.attempt(ZI,h,c?h:g)(x):x===91?e.attempt(JI,h,c?p:g)(x):c?h(x):g(x)}function p(x){return e.attempt(eP,h,g)(x)}function h(x){return t(x)}function g(x){return l._balanced=!0,n(x)}}function aP(e,t,n){return r;function r(g){return e.enter("resource"),e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),o}function o(g){return fn(g)?tc(e,l)(g):l(g)}function l(g){return g===41?h(g):q5(e,c,d,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(g)}function c(g){return fn(g)?tc(e,m)(g):h(g)}function d(g){return n(g)}function m(g){return g===34||g===39||g===40?V5(e,p,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(g):h(g)}function p(g){return fn(g)?tc(e,h)(g):h(g)}function h(g){return g===41?(e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),e.exit("resource"),t):n(g)}}function sP(e,t,n){const r=this;return o;function o(d){return G5.call(r,e,l,c,"reference","referenceMarker","referenceString")(d)}function l(d){return r.parser.defined.includes(da(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(d):n(d)}function c(d){return n(d)}}function iP(e,t,n){return r;function r(l){return e.enter("reference"),e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),o}function o(l){return l===93?(e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),e.exit("reference"),t):n(l)}}const oP={name:"labelStartImage",resolveAll:lg.resolveAll,tokenize:lP};function lP(e,t,n){const r=this;return o;function o(d){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(d),e.exit("labelImageMarker"),l}function l(d){return d===91?(e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelImage"),c):n(d)}function c(d){return d===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(d):t(d)}}const cP={name:"labelStartLink",resolveAll:lg.resolveAll,tokenize:uP};function uP(e,t,n){const r=this;return o;function o(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 r.parser.constructs?n(c):t(c)}}const dp={name:"lineEnding",tokenize:dP};function dP(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ht(e,t,"linePrefix")}}const Dd={name:"thematicBreak",tokenize:mP};function mP(e,t,n){let r=0,o;return l;function l(p){return e.enter("thematicBreak"),c(p)}function c(p){return o=p,d(p)}function d(p){return p===o?(e.enter("thematicBreakSequence"),m(p)):r>=3&&(p===null||bt(p))?(e.exit("thematicBreak"),t(p)):n(p)}function m(p){return p===o?(e.consume(p),r++,m):(e.exit("thematicBreakSequence"),Gt(p)?Ht(e,d,"whitespace")(p):d(p))}}const Nr={continuation:{tokenize:gP},exit:xP,name:"list",tokenize:hP},fP={partial:!0,tokenize:yP},pP={partial:!0,tokenize:bP};function hP(e,t,n){const r=this,o=r.events[r.events.length-1];let l=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,c=0;return d;function d(y){const w=r.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!r.containerState.marker||y===r.containerState.marker:hh(y)){if(r.containerState.type||(r.containerState.type=w,e.enter(w,{_container:!0})),w==="listUnordered")return e.enter("listItemPrefix"),y===42||y===45?e.check(Dd,n,p)(y):p(y);if(!r.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),m(y)}return n(y)}function m(y){return hh(y)&&++c<10?(e.consume(y),m):(!r.interrupt||c<2)&&(r.containerState.marker?y===r.containerState.marker:y===41||y===46)?(e.exit("listItemValue"),p(y)):n(y)}function p(y){return e.enter("listItemMarker"),e.consume(y),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||y,e.check(Sc,r.interrupt?n:h,e.attempt(fP,x,g))}function h(y){return r.containerState.initialBlankLine=!0,l++,x(y)}function g(y){return Gt(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),x):n(y)}function x(y){return r.containerState.size=l+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(y)}}function gP(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Sc,o,l);function o(d){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ht(e,t,"listItemIndent",r.containerState.size+1)(d)}function l(d){return r.containerState.furtherBlankLines||!Gt(d)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,c(d)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(pP,t,c)(d))}function c(d){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ht(e,e.attempt(Nr,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d)}}function bP(e,t,n){const r=this;return Ht(e,o,"listItemIndent",r.containerState.size+1);function o(l){const c=r.events[r.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===r.containerState.size?t(l):n(l)}}function xP(e){e.exit(this.containerState.type)}function yP(e,t,n){const r=this;return Ht(e,o,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(l){const c=r.events[r.events.length-1];return!Gt(l)&&c&&c[1].type==="listItemPrefixWhitespace"?t(l):n(l)}}const Sv={name:"setextUnderline",resolveTo:vP,tokenize:wP};function vP(e,t){let n=e.length,r,o,l;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(o=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[r][1].start},end:{...e[e.length-1][1].end}};return e[o][1].type="setextHeadingText",l?(e.splice(o,0,["enter",c,t]),e.splice(l+1,0,["exit",e[r][1],t]),e[r][1].end={...e[l][1].end}):e[r][1]=c,e.push(["exit",c,t]),e}function wP(e,t,n){const r=this;let o;return l;function l(p){let h=r.events.length,g;for(;h--;)if(r.events[h][1].type!=="lineEnding"&&r.events[h][1].type!=="linePrefix"&&r.events[h][1].type!=="content"){g=r.events[h][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||g)?(e.enter("setextHeadingLine"),o=p,c(p)):n(p)}function c(p){return e.enter("setextHeadingLineSequence"),d(p)}function d(p){return p===o?(e.consume(p),d):(e.exit("setextHeadingLineSequence"),Gt(p)?Ht(e,m,"lineSuffix")(p):m(p))}function m(p){return p===null||bt(p)?(e.exit("setextHeadingLine"),t(p)):n(p)}}const kP={tokenize:SP};function SP(e){const t=this,n=e.attempt(Sc,r,e.attempt(this.parser.constructs.flowInitial,o,Ht(e,e.attempt(this.parser.constructs.flow,o,e.attempt(EI,o)),"linePrefix")));return n;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEndingBlank"),e.consume(l),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function o(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const NP={resolveAll:W5()},CP=K5("string"),TP=K5("text");function K5(e){return{resolveAll:W5(e==="text"?AP:void 0),tokenize:t};function t(n){const r=this,o=this.parser.constructs[e],l=n.attempt(o,c,d);return c;function c(h){return p(h)?l(h):d(h)}function d(h){if(h===null){n.consume(h);return}return n.enter("data"),n.consume(h),m}function m(h){return p(h)?(n.exit("data"),l(h)):(n.consume(h),m)}function p(h){if(h===null)return!0;const g=o[h];let x=-1;if(g)for(;++x<g.length;){const y=g[x];if(!y.previous||y.previous.call(r,r.previous))return!0}return!1}}}function W5(e){return t;function t(n,r){let o=-1,l;for(;++o<=n.length;)l===void 0?n[o]&&n[o][1].type==="data"&&(l=o,o++):(!n[o]||n[o][1].type!=="data")&&(o!==l+2&&(n[l][1].end=n[o-1][1].end,n.splice(l+2,o-l-2),o=l+2),l=void 0);return e?e(n,r):n}}function AP(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 r=e[n-1][1],o=t.sliceStream(r);let l=o.length,c=-1,d=0,m;for(;l--;){const p=o[l];if(typeof p=="string"){for(c=p.length;p.charCodeAt(c-1)===32;)d++,c--;if(c)break;c=-1}else if(p===-2)m=!0,d++;else if(p!==-1){l++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(d=0),d){const p={type:n===e.length||m||d<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:l?c:r.start._bufferIndex+c,_index:r.start._index+l,line:r.end.line,column:r.end.column-d,offset:r.end.offset-d},end:{...r.end}};r.end={...p.start},r.start.offset===r.end.offset?Object.assign(r,p):(e.splice(n,0,["enter",p,t],["exit",p,t]),n+=2)}n++}return e}const EP={42:Nr,43:Nr,45:Nr,48:Nr,49:Nr,50:Nr,51:Nr,52:Nr,53:Nr,54:Nr,55:Nr,56:Nr,57:Nr,62:U5},_P={91:OI},jP={[-2]:up,[-1]:up,32:up},MP={35:BI,42:Dd,45:[Sv,Dd],60:FI,61:Sv,95:Dd,96:wv,126:wv},RP={38:H5,92:$5},OP={[-5]:dp,[-4]:dp,[-3]:dp,33:oP,38:H5,42:gh,60:[cI,XI],91:cP,92:[PI,$5],93:lg,95:gh,96:kI},DP={null:[gh,NP]},LP={null:[42,95]},IP={null:[]},PP=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:LP,contentInitial:_P,disable:IP,document:EP,flow:MP,flowInitial:jP,insideSpan:DP,string:RP,text:OP},Symbol.toStringTag,{value:"Module"}));function zP(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const o={},l=[];let c=[],d=[];const m={attempt:$(P),check:$(D),consume:_,enter:j,exit:O,interrupt:$(D,{interrupt:!0})},p={code:null,containerState:{},defineSkip:C,events:[],now:w,parser:e,previous:null,sliceSerialize:x,sliceStream:y,write:g};let h=t.tokenize.call(p,m);return t.resolveAll&&l.push(t),p;function g(K){return c=ra(c,K),T(),c[c.length-1]!==null?[]:(X(t,0),p.events=C0(l,p.events,p),p.events)}function x(K,ae){return UP(y(K),ae)}function y(K){return BP(c,K)}function w(){const{_bufferIndex:K,_index:ae,line:W,column:F,offset:Z}=r;return{_bufferIndex:K,_index:ae,line:W,column:F,offset:Z}}function C(K){o[K.line]=K.column,H()}function T(){let K;for(;r._index<c.length;){const ae=c[r._index];if(typeof ae=="string")for(K=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===K&&r._bufferIndex<ae.length;)S(ae.charCodeAt(r._bufferIndex));else S(ae)}}function S(K){h=h(K)}function _(K){bt(K)?(r.line++,r.column=1,r.offset+=K===-3?2:1,H()):K!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===c[r._index].length&&(r._bufferIndex=-1,r._index++)),p.previous=K}function j(K,ae){const W=ae||{};return W.type=K,W.start=w(),p.events.push(["enter",W,p]),d.push(W),W}function O(K){const ae=d.pop();return ae.end=w(),p.events.push(["exit",ae,p]),ae}function P(K,ae){X(K,ae.from)}function D(K,ae){ae.restore()}function $(K,ae){return W;function W(F,Z,U){let Q,ne,ke,B;return Array.isArray(F)?le(F):"tokenize"in F?le([F]):q(F);function q(Oe){return We;function We(st){const mt=st!==null&&Oe[st],At=st!==null&&Oe.null,gt=[...Array.isArray(mt)?mt:mt?[mt]:[],...Array.isArray(At)?At:At?[At]:[]];return le(gt)(st)}}function le(Oe){return Q=Oe,ne=0,Oe.length===0?U:I(Oe[ne])}function I(Oe){return We;function We(st){return B=ee(),ke=Oe,Oe.partial||(p.currentConstruct=Oe),Oe.name&&p.parser.constructs.disable.null.includes(Oe.name)?$e():Oe.tokenize.call(ae?Object.assign(Object.create(p),ae):p,m,Ae,$e)(st)}}function Ae(Oe){return K(ke,B),Z}function $e(Oe){return B.restore(),++ne<Q.length?I(Q[ne]):U}}}function X(K,ae){K.resolveAll&&!l.includes(K)&&l.push(K),K.resolve&&$r(p.events,ae,p.events.length-ae,K.resolve(p.events.slice(ae),p)),K.resolveTo&&(p.events=K.resolveTo(p.events,p))}function ee(){const K=w(),ae=p.previous,W=p.currentConstruct,F=p.events.length,Z=Array.from(d);return{from:F,restore:U};function U(){r=K,p.previous=ae,p.currentConstruct=W,p.events.length=F,d=Z,H()}}function H(){r.line in o&&r.column<2&&(r.column=o[r.line],r.offset+=o[r.line]-1)}}function BP(e,t){const n=t.start._index,r=t.start._bufferIndex,o=t.end._index,l=t.end._bufferIndex;let c;if(n===o)c=[e[n].slice(r,l)];else{if(c=e.slice(n,o),r>-1){const d=c[0];typeof d=="string"?c[0]=d.slice(r):c.shift()}l>0&&c.push(e[o].slice(0,l))}return c}function UP(e,t){let n=-1;const r=[];let o;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=`
|
|
356
356
|
`;break}case-3:{c=`\r
|
|
357
357
|
`;break}case-2:{c=t?" ":" ";break}case-1:{if(!t&&o)continue;c=" ";break}default:c=String.fromCharCode(l)}o=l===-2,r.push(c)}return r.join("")}function $P(e){const r={constructs:z5([PP,...(e||{}).extensions||[]]),content:o(nI),defined:[],document:o(aI),flow:o(kP),lazy:{},string:o(CP),text:o(TP)};return r;function o(l){return c;function c(d){return zP(r,l,d)}}}function HP(e){for(;!F5(e););return e}const Nv=/[\0\t\n\r]/g;function FP(){let e=1,t="",n=!0,r;return o;function o(l,c,d){const m=[];let p,h,g,x,y;for(l=t+(typeof l=="string"?l.toString():new TextDecoder(c||void 0).decode(l)),g=0,t="",n&&(l.charCodeAt(0)===65279&&g++,n=void 0);g<l.length;){if(Nv.lastIndex=g,p=Nv.exec(l),x=p&&p.index!==void 0?p.index:l.length,y=l.charCodeAt(x),!p){t=l.slice(g);break}if(y===10&&g===x&&r)m.push(-3),r=void 0;else switch(r&&(m.push(-5),r=void 0),g<x&&(m.push(l.slice(g,x)),e+=x-g),y){case 0:{m.push(65533),e++;break}case 9:{for(h=Math.ceil(e/4)*4,m.push(-2);e++<h;)m.push(-1);break}case 10:{m.push(-4),e=1;break}default:r=!0,e=1}g=x+1}return d&&(r&&m.push(-5),t&&m.push(t),m.push(null)),m}}const qP=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function GP(e){return e.replace(qP,VP)}function VP(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const o=n.charCodeAt(1),l=o===120||o===88;return B5(n.slice(l?2:1),l?16:10)}return og(n)||e}const Y5={}.hasOwnProperty;function KP(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),WP(n)(HP($P(n).document().write(FP()(e,t,!0))))}function WP(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:l(ft),autolinkProtocol:ee,autolinkEmail:ee,atxHeading:l(be),blockQuote:l(At),characterEscape:ee,characterReference:ee,codeFenced:l(gt),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:l(gt,c),codeText:l(jt,c),codeTextData:ee,data:ee,codeFlowValue:ee,definition:l(Jt),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:l(Rt),hardBreakEscape:l(Me),hardBreakTrailing:l(Me),htmlFlow:l(qe,c),htmlFlowData:ee,htmlText:l(qe,c),htmlTextData:ee,image:l(ot),label:c,link:l(ft),listItem:l(Be),listItemValue:x,listOrdered:l(se,g),listUnordered:l(se),paragraph:l(Xe),reference:I,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:l(be),strong:l(Ge),thematicBreak:l(yt)},exit:{atxHeading:m(),atxHeadingSequence:P,autolink:m(),autolinkEmail:mt,autolinkProtocol:st,blockQuote:m(),characterEscapeValue:H,characterReferenceMarkerHexadecimal:$e,characterReferenceMarkerNumeric:$e,characterReferenceValue:Oe,characterReference:We,codeFenced:m(T),codeFencedFence:C,codeFencedFenceInfo:y,codeFencedFenceMeta:w,codeFlowValue:H,codeIndented:m(S),codeText:m(Z),codeTextData:H,data:H,definition:m(),definitionDestinationString:O,definitionLabelString:_,definitionTitleString:j,emphasis:m(),hardBreakEscape:m(ae),hardBreakTrailing:m(ae),htmlFlow:m(W),htmlFlowData:H,htmlText:m(F),htmlTextData:H,image:m(Q),label:ke,labelText:ne,lineEnding:K,link:m(U),listItem:m(),listOrdered:m(),listUnordered:m(),paragraph:m(),referenceString:Ae,resourceDestinationString:B,resourceTitleString:q,resource:le,setextHeading:m(X),setextHeadingLineSequence:$,setextHeadingText:D,strong:m(),thematicBreak:m()}};X5(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(he){let V={type:"root",children:[]};const ye={stack:[V],tokenStack:[],config:t,enter:d,exit:p,buffer:c,resume:h,data:n},Qe=[];let pe=-1;for(;++pe<he.length;)if(he[pe][1].type==="listOrdered"||he[pe][1].type==="listUnordered")if(he[pe][0]==="enter")Qe.push(pe);else{const ve=Qe.pop();pe=o(he,ve,pe)}for(pe=-1;++pe<he.length;){const ve=t[he[pe][0]];Y5.call(ve,he[pe][1].type)&&ve[he[pe][1].type].call(Object.assign({sliceSerialize:he[pe][2].sliceSerialize},ye),he[pe][1])}if(ye.tokenStack.length>0){const ve=ye.tokenStack[ye.tokenStack.length-1];(ve[1]||Cv).call(ye,void 0,ve[0])}for(V.position={start:Os(he.length>0?he[0][1].start:{line:1,column:1,offset:0}),end:Os(he.length>0?he[he.length-2][1].end:{line:1,column:1,offset:0})},pe=-1;++pe<t.transforms.length;)V=t.transforms[pe](V)||V;return V}function o(he,V,ye){let Qe=V-1,pe=-1,ve=!1,Ye,nt,xt,Dt;for(;++Qe<=ye;){const ct=he[Qe];switch(ct[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ct[0]==="enter"?pe++:pe--,Dt=void 0;break}case"lineEndingBlank":{ct[0]==="enter"&&(Ye&&!Dt&&!pe&&!xt&&(xt=Qe),Dt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Dt=void 0}if(!pe&&ct[0]==="enter"&&ct[1].type==="listItemPrefix"||pe===-1&&ct[0]==="exit"&&(ct[1].type==="listUnordered"||ct[1].type==="listOrdered")){if(Ye){let Xt=Qe;for(nt=void 0;Xt--;){const R=he[Xt];if(R[1].type==="lineEnding"||R[1].type==="lineEndingBlank"){if(R[0]==="exit")continue;nt&&(he[nt][1].type="lineEndingBlank",ve=!0),R[1].type="lineEnding",nt=Xt}else if(!(R[1].type==="linePrefix"||R[1].type==="blockQuotePrefix"||R[1].type==="blockQuotePrefixWhitespace"||R[1].type==="blockQuoteMarker"||R[1].type==="listItemIndent"))break}xt&&(!nt||xt<nt)&&(Ye._spread=!0),Ye.end=Object.assign({},nt?he[nt][1].start:ct[1].end),he.splice(nt||Qe,0,["exit",Ye,ct[2]]),Qe++,ye++}if(ct[1].type==="listItemPrefix"){const Xt={type:"listItem",_spread:!1,start:Object.assign({},ct[1].start),end:void 0};Ye=Xt,he.splice(Qe,0,["enter",Xt,ct[2]]),Qe++,ye++,xt=void 0,Dt=!0}}}return he[V][1]._spread=ve,ye}function l(he,V){return ye;function ye(Qe){d.call(this,he(Qe),Qe),V&&V.call(this,Qe)}}function c(){this.stack.push({type:"fragment",children:[]})}function d(he,V,ye){this.stack[this.stack.length-1].children.push(he),this.stack.push(he),this.tokenStack.push([V,ye||void 0]),he.position={start:Os(V.start),end:void 0}}function m(he){return V;function V(ye){he&&he.call(this,ye),p.call(this,ye)}}function p(he,V){const ye=this.stack.pop(),Qe=this.tokenStack.pop();if(Qe)Qe[0].type!==he.type&&(V?V.call(this,he,Qe[0]):(Qe[1]||Cv).call(this,he,Qe[0]));else throw new Error("Cannot close `"+he.type+"` ("+ec({start:he.start,end:he.end})+"): it’s not open");ye.position.end=Os(he.end)}function h(){return ig(this.stack.pop())}function g(){this.data.expectingFirstListItemValue=!0}function x(he){if(this.data.expectingFirstListItemValue){const V=this.stack[this.stack.length-2];V.start=Number.parseInt(this.sliceSerialize(he),10),this.data.expectingFirstListItemValue=void 0}}function y(){const he=this.resume(),V=this.stack[this.stack.length-1];V.lang=he}function w(){const he=this.resume(),V=this.stack[this.stack.length-1];V.meta=he}function C(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function T(){const he=this.resume(),V=this.stack[this.stack.length-1];V.value=he.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function S(){const he=this.resume(),V=this.stack[this.stack.length-1];V.value=he.replace(/(\r?\n|\r)$/g,"")}function _(he){const V=this.resume(),ye=this.stack[this.stack.length-1];ye.label=V,ye.identifier=da(this.sliceSerialize(he)).toLowerCase()}function j(){const he=this.resume(),V=this.stack[this.stack.length-1];V.title=he}function O(){const he=this.resume(),V=this.stack[this.stack.length-1];V.url=he}function P(he){const V=this.stack[this.stack.length-1];if(!V.depth){const ye=this.sliceSerialize(he).length;V.depth=ye}}function D(){this.data.setextHeadingSlurpLineEnding=!0}function $(he){const V=this.stack[this.stack.length-1];V.depth=this.sliceSerialize(he).codePointAt(0)===61?1:2}function X(){this.data.setextHeadingSlurpLineEnding=void 0}function ee(he){const ye=this.stack[this.stack.length-1].children;let Qe=ye[ye.length-1];(!Qe||Qe.type!=="text")&&(Qe=et(),Qe.position={start:Os(he.start),end:void 0},ye.push(Qe)),this.stack.push(Qe)}function H(he){const V=this.stack.pop();V.value+=this.sliceSerialize(he),V.position.end=Os(he.end)}function K(he){const V=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ye=V.children[V.children.length-1];ye.position.end=Os(he.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(V.type)&&(ee.call(this,he),H.call(this,he))}function ae(){this.data.atHardBreak=!0}function W(){const he=this.resume(),V=this.stack[this.stack.length-1];V.value=he}function F(){const he=this.resume(),V=this.stack[this.stack.length-1];V.value=he}function Z(){const he=this.resume(),V=this.stack[this.stack.length-1];V.value=he}function U(){const he=this.stack[this.stack.length-1];if(this.data.inReference){const V=this.data.referenceType||"shortcut";he.type+="Reference",he.referenceType=V,delete he.url,delete he.title}else delete he.identifier,delete he.label;this.data.referenceType=void 0}function Q(){const he=this.stack[this.stack.length-1];if(this.data.inReference){const V=this.data.referenceType||"shortcut";he.type+="Reference",he.referenceType=V,delete he.url,delete he.title}else delete he.identifier,delete he.label;this.data.referenceType=void 0}function ne(he){const V=this.sliceSerialize(he),ye=this.stack[this.stack.length-2];ye.label=GP(V),ye.identifier=da(V).toLowerCase()}function ke(){const he=this.stack[this.stack.length-1],V=this.resume(),ye=this.stack[this.stack.length-1];if(this.data.inReference=!0,ye.type==="link"){const Qe=he.children;ye.children=Qe}else ye.alt=V}function B(){const he=this.resume(),V=this.stack[this.stack.length-1];V.url=he}function q(){const he=this.resume(),V=this.stack[this.stack.length-1];V.title=he}function le(){this.data.inReference=void 0}function I(){this.data.referenceType="collapsed"}function Ae(he){const V=this.resume(),ye=this.stack[this.stack.length-1];ye.label=V,ye.identifier=da(this.sliceSerialize(he)).toLowerCase(),this.data.referenceType="full"}function $e(he){this.data.characterReferenceType=he.type}function Oe(he){const V=this.sliceSerialize(he),ye=this.data.characterReferenceType;let Qe;ye?(Qe=B5(V,ye==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Qe=og(V);const pe=this.stack[this.stack.length-1];pe.value+=Qe}function We(he){const V=this.stack.pop();V.position.end=Os(he.end)}function st(he){H.call(this,he);const V=this.stack[this.stack.length-1];V.url=this.sliceSerialize(he)}function mt(he){H.call(this,he);const V=this.stack[this.stack.length-1];V.url="mailto:"+this.sliceSerialize(he)}function At(){return{type:"blockquote",children:[]}}function gt(){return{type:"code",lang:null,meta:null,value:""}}function jt(){return{type:"inlineCode",value:""}}function Jt(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Rt(){return{type:"emphasis",children:[]}}function be(){return{type:"heading",depth:0,children:[]}}function Me(){return{type:"break"}}function qe(){return{type:"html",value:""}}function ot(){return{type:"image",title:null,url:"",alt:null}}function ft(){return{type:"link",title:null,url:"",children:[]}}function se(he){return{type:"list",ordered:he.type==="listOrdered",start:null,spread:he._spread,children:[]}}function Be(he){return{type:"listItem",spread:he._spread,checked:null,children:[]}}function Xe(){return{type:"paragraph",children:[]}}function Ge(){return{type:"strong",children:[]}}function et(){return{type:"text",value:""}}function yt(){return{type:"thematicBreak"}}}function Os(e){return{line:e.line,column:e.column,offset:e.offset}}function X5(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?X5(e,r):YP(e,r)}}function YP(e,t){let n;for(n in t)if(Y5.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function Cv(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+ec({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+ec({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+ec({start:t.start,end:t.end})+") is still open")}function XP(e){const t=this;t.parser=n;function n(r){return KP(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function QP(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 ZP(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
@@ -645,7 +645,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
645
645
|
`},p]}}const Sq=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_-]*/}}),Nq=["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"],Cq=["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"],Tq=[...Nq,...Cq],Aq=["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(),Vk=["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(),Kk=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),Eq=["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(),_q=Vk.concat(Kk).sort().reverse();function jq(e){const t=Sq(e),n=_q,r="and or not only",o="[\\w-]+",l="("+o+"|@\\{"+o+"\\})",c=[],d=[],m=function(j){return{className:"string",begin:"~?"+j+".*?"+j}},p=function(j,O,P){return{className:j,begin:O,relevance:P}},h={$pattern:/[a-z-]+/,keyword:r,attribute:Aq.join(" ")},g={begin:"\\(",end:"\\)",contains:d,keywords:h,relevance:0};d.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,g,p("variable","@@?"+o,10),p("variable","@\\{"+o+"\\}"),p("built_in","~?`[^`]*?`"),{className:"attribute",begin:o+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0},t.IMPORTANT,{beginKeywords:"and not"},t.FUNCTION_DISPATCH);const x=d.concat({begin:/\{/,end:/\}/,contains:c}),y={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(d)},w={begin:l+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+Eq.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:d}}]},C={className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:h,returnEnd:!0,contains:d,relevance:0}},T={className:"variable",variants:[{begin:"@"+o+"\\s*:",relevance:15},{begin:"@"+o}],starts:{end:"[;}]",returnEnd:!0,contains:x}},S={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,p("keyword","all\\b"),p("variable","@\\{"+o+"\\}"),{begin:"\\b("+Tq.join("|")+")\\b",className:"selector-tag"},t.CSS_NUMBER_MODE,p("selector-tag",l,0),p("selector-id","#"+l),p("selector-class","\\."+l,0),p("selector-tag","&",0),t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+Vk.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+Kk.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:x},{begin:"!important"},t.FUNCTION_DISPATCH]},_={begin:o+`:(:)?(${n.join("|")})`,returnBegin:!0,contains:[S]};return c.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,C,T,_,w,S,y,t.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:`[=>'/<($"]`,contains:c}}function Mq(e){const t="\\[=*\\[",n="\\]=*\\]",r={begin:t,end:n,contains:["self"]},o=[e.COMMENT("--(?!"+t+")","$"),e.COMMENT("--"+t,n,{contains:[r],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:o.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:o}].concat(o)},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:"string",begin:t,end:n,contains:[r],relevance:5}])}}function Rq(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]},r={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]},o={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,r,o,l,c]}}function Oq(e){const t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},r={begin:"^[-\\*]{3,}",end:"$"},o={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}]},d=/[A-Za-z][A-Za-z0-9+.-]*/,m={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,d,/:\/\/.*?\)/),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}]},p={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},h={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},g=e.inherit(p,{contains:[]}),x=e.inherit(h,{contains:[]});p.contains.push(x),h.contains.push(g);let y=[n,m];return[p,h,g,x].forEach(S=>{S.contains=S.contains.concat(y)}),y=y.concat(p,h),{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,p,h,{className:"quote",begin:"^>\\s+",contains:y,end:"$"},o,r,m,c,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function Dq(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_]*/,d={"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:d,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 Lq(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"],r=/[dualxmsipngr]{0,12}/,o={$pattern:/[\w.]+/,keyword:n.join(" ")},l={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:o},c={begin:/->\{/,end:/\}/},d={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:[d]},p={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},h=[e.BACKSLASH_ESCAPE,l,m],g=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],x=(C,T,S="\\1")=>{const _=S==="\\1"?S:t.concat(S,T);return t.concat(t.concat("(?:",C,")"),T,/(?:\\.|[^\\\/])*?/,_,/(?:\\.|[^\\\/])*?/,S,r)},y=(C,T,S)=>t.concat(t.concat("(?:",C,")"),T,/(?:\\.|[^\\\/])*?/,S,r),w=[m,e.HASH_COMMENT_MODE,e.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),c,{className:"string",contains:h,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}]},p,{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:x("s|tr|y",t.either(...g,{capture:!0}))},{begin:x("s|tr|y","\\(","\\)")},{begin:x("s|tr|y","\\[","\\]")},{begin:x("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:y("(?:m|qr)?",/\//,/\//)},{begin:y("m|qr",t.either(...g,{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,d]},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,d,p]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return l.contains=w,c.contains=w,{name:"Perl",aliases:["pl","pm"],keywords:o,contains:w}}function Iq(e){const t=e.regex,n=/(?![A-Za-z0-9])(?![$])/,r=t.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,n),o=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:"\\$+"+r},d={scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},m={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},p=e.inherit(e.APOS_STRING_MODE,{illegal:null}),h=e.inherit(e.QUOTE_STRING_MODE,{illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(m)}),g={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:e.QUOTE_STRING_MODE.contains.concat(m),"on:begin":(F,Z)=>{Z.data._beginMatch=F[1]||F[2]},"on:end":(F,Z)=>{Z.data._beginMatch!==F[1]&&Z.ignoreMatch()}},x=e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),y=`[
|
|
646
646
|
]`,w={scope:"string",variants:[h,p,g,x]},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"],S=["__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"],_=["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"],O={keyword:S,literal:(F=>{const Z=[];return F.forEach(U=>{Z.push(U),U.toLowerCase()===U?Z.push(U.toUpperCase()):Z.push(U.toLowerCase())}),Z})(T),built_in:_},P=F=>F.map(Z=>Z.replace(/\|\d+$/,"")),D={variants:[{match:[/new/,t.concat(y,"+"),t.concat("(?!",P(_).join("\\b|"),"\\b)"),o],scope:{1:"keyword",4:"title.class"}}]},$=t.concat(r,"\\b(?!\\()"),X={variants:[{match:[t.concat(/::/,t.lookahead(/(?!class\b)/)),$],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[o,t.concat(/::/,t.lookahead(/(?!class\b)/)),$],scope:{1:"title.class",3:"variable.constant"}},{match:[o,t.concat("::",t.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[o,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},ee={scope:"attr",match:t.concat(r,t.lookahead(":"),t.lookahead(/(?!::)/))},H={relevance:0,begin:/\(/,end:/\)/,keywords:O,contains:[ee,c,X,e.C_BLOCK_COMMENT_MODE,w,C,D]},K={relevance:0,match:[/\b/,t.concat("(?!fn\\b|function\\b|",P(S).join("\\b|"),"|",P(_).join("\\b|"),"\\b)"),r,t.concat(y,"*"),t.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[H]};H.contains.push(K);const ae=[ee,X,e.C_BLOCK_COMMENT_MODE,w,C,D],W={begin:t.concat(/#\[\s*\\?/,t.either(o,l)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:T,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:T,keyword:["new","array"]},contains:["self",...ae]},...ae,{scope:"meta",variants:[{match:o},{match:l}]}]};return{case_insensitive:!1,keywords:O,contains:[W,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}]}},d,{scope:"variable.language",match:/\$this\b/},c,K,X,{match:[/const/,/\s/,r],scope:{1:"keyword",3:"variable.constant"}},D,{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:O,contains:["self",W,c,X,e.C_BLOCK_COMMENT_MODE,w,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]},w,C]}}function Pq(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 zq(e){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}function Bq(e){const t=e.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["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"],d={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,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:/^(>>>|\.\.\.) /},p={className:"subst",begin:/\{/,end:/\}/,keywords:d,illegal:/#/},h={begin:/\{\{/,relevance:0},g={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,h,p]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,m,h,p]},{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,h,p]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,h,p]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},x="[0-9](_?[0-9])*",y=`(\\b(${x}))?\\.(${x})|\\b(${x})\\.`,w=`\\b|${r.join("|")}`,C={className:"number",relevance:0,variants:[{begin:`(\\b(${x})|(${y}))[eE][+-]?(${x})[jJ]?(?=${w})`},{begin:`(${y})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${w})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${w})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${w})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${w})`},{begin:`\\b(${x})[jJ](?=${w})`}]},T={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:d,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},S={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:d,contains:["self",m,C,g,e.HASH_COMMENT_MODE]}]};return p.contains=[g,C,m],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:d,illegal:/(<\/|\?)|=>/,contains:[m,C,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},g,T,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[S]},{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,S,g]}]}}function Uq(e){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function $q(e){const t=e.regex,n=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,r=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]?/),o=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,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:[o,r]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,r]},{scope:{1:"punctuation",2:"number"},match:[l,r]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,r]}]},{scope:{3:"operator"},match:[n,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:o},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:l},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}}function Hq(e){const t=e.regex,n="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",r=t.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),o=t.concat(r,/(::\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"]},d={className:"doctag",begin:"@[A-Za-z]+"},m={begin:"#<",end:">"},p=[e.COMMENT("#","$",{contains:[d]}),e.COMMENT("^=begin","^=end",{contains:[d],relevance:10}),e.COMMENT("^__END__",e.MATCH_NOTHING_RE)],h={className:"subst",begin:/#\{/,end:/\}/,keywords:c},g={className:"string",contains:[e.BACKSLASH_ESCAPE,h],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,h]})]}]},x="[1-9](_?[0-9])*|0",y="[0-9](_?[0-9])*",w={className:"number",relevance:0,variants:[{begin:`\\b(${x})(\\.(${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}]},D=[g,{variants:[{match:[/class\s+/,o,/\s+<\s+/,o]},{match:[/\b(class|module)\s+/,o]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:c},{match:[/(include|extend)\s+/,o],scope:{2:"title.class"},keywords:c},{relevance:0,match:[o,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:r,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:[g,{begin:n}],relevance:0},w,{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,h],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,p),relevance:0}].concat(m,p);h.contains=D,C.contains=D;const H=[{begin:/^\s*=>/,starts:{end:"$",contains:D}},{className:"meta.prompt",begin:"^("+"[>?]>"+"|"+"[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]"+"|"+"(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>"+")(?=[ ])",starts:{end:"$",keywords:c,contains:D}}];return p.unshift(m),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:c,illegal:/\/\*/,contains:[e.SHEBANG({binary:"ruby"})].concat(H).concat(p).concat(D)}}function Fq(e){const t=e.regex,n=/(r#)?/,r=t.concat(n,e.UNDERSCORE_IDENT_RE),o=t.concat(n,e.IDENT_RE),l={className:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!let|for|while|if|else|match\b)/,o,t.lookahead(/\s*\(/))},c="([ui](8|16|32|64|128|size)|f(32|64))?",d=["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"],p=["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!"],h=["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:h,keyword:d,literal:m,built_in:p},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+/,r],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,r,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:p,type:h}},{className:"punctuation",begin:"->"},l]}}const qq=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_-]*/}}),Gq=["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"],Vq=["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"],Kq=[...Gq,...Vq],Wq=["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(),Yq=["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(),Xq=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),Qq=["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 Zq(e){const t=qq(e),n=Xq,r=Yq,o="@[a-z-]+",l="and or not only",d={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("+Kq.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+r.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+n.join("|")+")"},d,{begin:/\(/,end:/\)/,contains:[t.CSS_NUMBER_MODE]},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+Qq.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,d,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:o,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:l,attribute:Wq.join(" ")},contains:[{begin:o,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},d,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.HEXCOLOR,t.CSS_NUMBER_MODE]},t.FUNCTION_DISPATCH]}}function Jq(e){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function eG(e){const t=e.regex,n=e.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},o={begin:/"/,end:/"/,contains:[{match:/""/}]},l=["true","false","unknown"],c=["double precision","large object","with timezone","without timezone"],d=["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"],p=["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"],h=["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"],g=["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"],x=["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=h,w=[...p,...m].filter(P=>!h.includes(P)),C={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},T={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},S={match:t.concat(/\b/,t.either(...y),/\s*\(/),relevance:0,keywords:{built_in:y}};function _(P){return t.concat(/\b/,t.either(...P.map(D=>D.replace(/\s+/,"\\s+"))),/\b/)}const j={scope:"keyword",match:_(x),relevance:0};function O(P,{exceptions:D,when:$}={}){const X=$;return D=D||[],P.map(ee=>ee.match(/\|\d+$/)||D.includes(ee)?ee:X(ee)?`${ee}|0`:ee)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:O(w,{when:P=>P.length<3}),literal:l,type:d,built_in:g},contains:[{scope:"type",match:_(c)},j,S,C,r,o,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,T]}}function Wk(e){return e?typeof e=="string"?e:e.source:null}function Wl(e){return dn("(?=",e,")")}function dn(...e){return e.map(n=>Wk(n)).join("")}function tG(e){const t=e[e.length-1];return typeof t=="object"&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function cr(...e){return"("+(tG(e).capture?"":"?:")+e.map(r=>Wk(r)).join("|")+")"}const Lg=e=>dn(/\b/,e,/\w$/.test(e)?/\b/:/\B/),nG=["Protocol","Type"].map(Lg),P2=["init","self"].map(Lg),rG=["Any","Self"],$p=["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"],z2=["false","nil","true"],aG=["assignment","associativity","higherThan","left","lowerThan","none","right"],sG=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],B2=["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"],Yk=cr(/[/=\-+!*%<>&|^~?]/,/[\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]/),Xk=cr(Yk,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),Hp=dn(Yk,Xk,"*"),Qk=cr(/[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]/),l0=cr(Qk,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),ba=dn(Qk,l0,"*"),pd=dn(/[A-Z]/,l0,"*"),iG=["attached","autoclosure",dn(/convention\(/,cr("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",dn(/objc\(/,ba,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],oG=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function lG(e){const t={match:/\s+/,relevance:0},n=e.COMMENT("/\\*","\\*/",{contains:["self"]}),r=[e.C_LINE_COMMENT_MODE,n],o={match:[/\./,cr(...nG,...P2)],className:{2:"keyword"}},l={match:dn(/\./,cr(...$p)),relevance:0},c=$p.filter(Me=>typeof Me=="string").concat(["_|0"]),d=$p.filter(Me=>typeof Me!="string").concat(rG).map(Lg),m={variants:[{className:"keyword",match:cr(...d,...P2)}]},p={$pattern:cr(/\b\w+/,/#\w+/),keyword:c.concat(sG),literal:z2},h=[o,l,m],g={match:dn(/\./,cr(...B2)),relevance:0},x={className:"built_in",match:dn(/\b/,cr(...B2),/(?=\()/)},y=[g,x],w={match:/->/,relevance:0},C={className:"operator",relevance:0,variants:[{match:Hp},{match:`\\.(\\.|${Xk})+`}]},T=[w,C],S="([0-9]_*)+",_="([0-9a-fA-F]_*)+",j={className:"number",relevance:0,variants:[{match:`\\b(${S})(\\.(${S}))?([eE][+-]?(${S}))?\\b`},{match:`\\b0x(${_})(\\.(${_}))?([pP][+-]?(${S}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},O=(Me="")=>({className:"subst",variants:[{match:dn(/\\/,Me,/[0\\tnr"']/)},{match:dn(/\\/,Me,/u\{[0-9a-fA-F]{1,8}\}/)}]}),P=(Me="")=>({className:"subst",match:dn(/\\/,Me,/[\t ]*(?:[\r\n]|\r\n)/)}),D=(Me="")=>({className:"subst",label:"interpol",begin:dn(/\\/,Me,/\(/),end:/\)/}),$=(Me="")=>({begin:dn(Me,/"""/),end:dn(/"""/,Me),contains:[O(Me),P(Me),D(Me)]}),X=(Me="")=>({begin:dn(Me,/"/),end:dn(/"/,Me),contains:[O(Me),D(Me)]}),ee={className:"string",variants:[$(),$("#"),$("##"),$("###"),X(),X("#"),X("##"),X("###")]},H=[e.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[e.BACKSLASH_ESCAPE]}],K={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:H},ae=Me=>{const qe=dn(Me,/\//),ot=dn(/\//,Me);return{begin:qe,end:ot,contains:[...H,{scope:"comment",begin:`#(?!.*${ot})`,end:/$/}]}},W={scope:"regexp",variants:[ae("###"),ae("##"),ae("#"),K]},F={match:dn(/`/,ba,/`/)},Z={className:"variable",match:/\$\d+/},U={className:"variable",match:`\\$${l0}+`},Q=[F,Z,U],ne={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:oG,contains:[...T,j,ee]}]}},ke={scope:"keyword",match:dn(/@/,cr(...iG),Wl(cr(/\(/,/\s+/)))},B={scope:"meta",match:dn(/@/,ba)},q=[ne,ke,B],le={match:Wl(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:dn(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,l0,"+")},{className:"type",match:pd,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:dn(/\s+&\s+/,Wl(pd)),relevance:0}]},I={begin:/</,end:/>/,keywords:p,contains:[...r,...h,...q,w,le]};le.contains.push(I);const Ae={match:dn(ba,/\s*:/),keywords:"_|0",relevance:0},$e={begin:/\(/,end:/\)/,relevance:0,keywords:p,contains:["self",Ae,...r,W,...h,...y,...T,j,ee,...Q,...q,le]},Oe={begin:/</,end:/>/,keywords:"repeat each",contains:[...r,le]},We={begin:cr(Wl(dn(ba,/\s*:/)),Wl(dn(ba,/\s+/,ba,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:ba}]},st={begin:/\(/,end:/\)/,keywords:p,contains:[We,...r,...h,...T,j,ee,...q,le,$e],endsParent:!0,illegal:/["']/},mt={match:[/(func|macro)/,/\s+/,cr(F.match,ba,Hp)],className:{1:"keyword",3:"title.function"},contains:[Oe,st,t],illegal:[/\[/,/%/]},At={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[Oe,st,t],illegal:/\[|%/},gt={match:[/operator/,/\s+/,Hp],className:{1:"keyword",3:"title"}},jt={begin:[/precedencegroup/,/\s+/,pd],className:{1:"keyword",3:"title"},contains:[le],keywords:[...aG,...z2],end:/}/},Jt={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"}},be={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,ba,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:p,contains:[Oe,...h,{begin:/:/,end:/\{/,keywords:p,contains:[{scope:"title.class.inherited",match:pd},...h],relevance:0}]};for(const Me of ee.variants){const qe=Me.contains.find(ft=>ft.label==="interpol");qe.keywords=p;const ot=[...h,...y,...T,j,ee,...Q];qe.contains=[...ot,{begin:/\(/,end:/\)/,contains:["self",...ot]}]}return{name:"Swift",keywords:p,contains:[...r,mt,At,Jt,Rt,be,gt,jt,{beginKeywords:"import",end:/$/,contains:[...r],relevance:0},W,...h,...y,...T,j,ee,...Q,...q,le,$e]}}const c0="[A-Za-z$_][0-9A-Za-z$_]*",Zk=["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"],Jk=["true","false","null","undefined","NaN","Infinity"],e3=["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"],t3=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],n3=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],r3=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],a3=[].concat(n3,e3,t3);function cG(e){const t=e.regex,n=(ne,{after:ke})=>{const B="</"+ne[0].slice(1);return ne.input.indexOf(B,ke)!==-1},r=c0,o={begin:"<>",end:"</>"},l=/<[A-Za-z0-9\\._:-]+\s*\/>/,c={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(ne,ke)=>{const B=ne[0].length+ne.index,q=ne.input[B];if(q==="<"||q===","){ke.ignoreMatch();return}q===">"&&(n(ne,{after:B})||ke.ignoreMatch());let le;const I=ne.input.substring(B);if(le=I.match(/^\s*=/)){ke.ignoreMatch();return}if((le=I.match(/^\s+extends\s+/))&&le.index===0){ke.ignoreMatch();return}}},d={$pattern:c0,keyword:Zk,literal:Jk,built_in:a3,"variable.language":r3},m="[0-9](_?[0-9])*",p=`\\.(${m})`,h="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",g={className:"number",variants:[{begin:`(\\b(${h})((${p})|\\.)?|(${p}))[eE][+-]?(${m})\\b`},{begin:`\\b(${h})\\b((${p})\\b|\\.)?|(${p})\\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},x={className:"subst",begin:"\\$\\{",end:"\\}",keywords:d,contains:[]},y={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,x],subLanguage:"xml"}},w={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,x],subLanguage:"css"}},C={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,x],subLanguage:"graphql"}},T={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,x]},_={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:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},j=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,C,T,{match:/\$\d+/},g];x.contains=j.concat({begin:/\{/,end:/\}/,keywords:d,contains:["self"].concat(j)});const O=[].concat(_,x.contains),P=O.concat([{begin:/(\s*)\(/,end:/\)/,keywords:d,contains:["self"].concat(O)}]),D={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:d,contains:P},$={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},X={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:{_:[...e3,...t3]}},ee={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},H={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[D],illegal:/%/},K={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function ae(ne){return t.concat("(?!",ne.join("|"),")")}const W={match:t.concat(/\b/,ae([...n3,"super","import"].map(ne=>`${ne}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},F={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},Z={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},D]},U="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",Q={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(U)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[D]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:d,exports:{PARAMS_CONTAINS:P,CLASS_REFERENCE:X},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),ee,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,C,T,_,{match:/\$\d+/},g,X,{scope:"attr",match:r+t.lookahead(":"),relevance:0},Q,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[_,e.REGEXP_MODE,{className:"function",begin:U,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:d,contains:P}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:o.begin,end:o.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"]}]}]},H,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[D,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},F,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[D]},W,K,$,Z,{match:/\$[(.]/}]}}function uG(e){const t=e.regex,n=cG(e),r=c0,o=["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:o},contains:[n.exports.CLASS_REFERENCE]},d={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},m=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],p={$pattern:c0,keyword:Zk.concat(m),literal:Jk,built_in:a3.concat(o),"variable.language":r3},h={className:"meta",begin:"@"+r},g=(C,T,S)=>{const _=C.contains.findIndex(j=>j.label===T);if(_===-1)throw new Error("can not find mode to replace");C.contains.splice(_,1,S)};Object.assign(n.keywords,p),n.exports.PARAMS_CONTAINS.push(h);const x=n.contains.find(C=>C.scope==="attr"),y=Object.assign({},x,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,x,y]),n.contains=n.contains.concat([h,l,c,y]),g(n,"shebang",e.SHEBANG()),g(n,"use_strict",d);const w=n.contains.find(C=>C.label==="func.def");return w.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function dG(e){const t=e.regex,n={className:"string",begin:/"(""|[^/n])"C\b/},r={className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},o=/\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)/,d=/\d{1,2}(:\d{1,2}){1,2}/,m={className:"literal",variants:[{begin:t.concat(/# */,t.either(l,o),/ *#/)},{begin:t.concat(/# */,d,/ *#/)},{begin:t.concat(/# */,c,/ *#/)},{begin:t.concat(/# */,t.either(l,o),/ +/,t.either(c,d),/ *#/)}]},p={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])|[%&])?/}]},h={className:"label",begin:/^\w+:/},g=e.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),x=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,r,m,p,h,g,x,{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:[x]}]}}function mG(e){e.regex;const t=e.COMMENT(/\(;/,/;\)/);t.contains.push("self");const n=e.COMMENT(/;;/,/$/),r=["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"],o={begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword",3:"title.function"}},l={className:"variable",begin:/\$[\w_]+/},c={match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},d={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"},p={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:r},contains:[n,t,{match:[/(?:offset|align)/,/\s*/,/=/],className:{1:"keyword",3:"operator"}},l,c,o,e.QUOTE_STRING_MODE,m,p,d]}}function fG(e){const t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,o={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:/\)/}),d=e.inherit(e.APOS_STRING_MODE,{className:"string"}),m=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),p={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[o]},{begin:/'/,end:/'/,contains:[o]},{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,d,c,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[l,c,m,d]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},o,{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:[p],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[p],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:p}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function pG(e){const t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",r={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},o={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,o]},d=e.inherit(c,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),x={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},w={begin:/\{/,end:/\}/,contains:[y],illegal:"\\n",relevance:0},C={begin:"\\[",end:"\\]",contains:[y],illegal:"\\n",relevance:0},T=[r,{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}},x,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},w,C,l,c],S=[...T];return S.pop(),S.push(d),y.contains=S,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:T}}const hG={arduino:XF,bash:QF,c:ZF,cpp:JF,csharp:eq,css:cq,diff:uq,go:dq,graphql:mq,ini:fq,java:pq,javascript:yq,json:vq,kotlin:kq,less:jq,lua:Mq,makefile:Rq,markdown:Oq,objectivec:Dq,perl:Lq,php:Iq,"php-template":Pq,plaintext:zq,python:Bq,"python-repl":Uq,r:$q,ruby:Hq,rust:Fq,scss:Zq,shell:Jq,sql:eG,swift:lG,typescript:uG,vbnet:dG,wasm:mG,xml:fG,yaml:pG};var Fp,U2;function gG(){if(U2)return Fp;U2=1;function e(G){return G instanceof Map?G.clear=G.delete=G.set=function(){throw new Error("map is read-only")}:G instanceof Set&&(G.add=G.clear=G.delete=function(){throw new Error("set is read-only")}),Object.freeze(G),Object.getOwnPropertyNames(G).forEach(ie=>{const Ne=G[ie],Le=typeof Ne;(Le==="object"||Le==="function")&&!Object.isFrozen(Ne)&&e(Ne)}),G}class t{constructor(ie){ie.data===void 0&&(ie.data={}),this.data=ie.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(G){return G.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function r(G,...ie){const Ne=Object.create(null);for(const Le in G)Ne[Le]=G[Le];return ie.forEach(function(Le){for(const Je in Le)Ne[Je]=Le[Je]}),Ne}const o="</span>",l=G=>!!G.scope,c=(G,{prefix:ie})=>{if(G.startsWith("language:"))return G.replace("language:","language-");if(G.includes(".")){const Ne=G.split(".");return[`${ie}${Ne.shift()}`,...Ne.map((Le,Je)=>`${Le}${"_".repeat(Je+1)}`)].join(" ")}return`${ie}${G}`};class d{constructor(ie,Ne){this.buffer="",this.classPrefix=Ne.classPrefix,ie.walk(this)}addText(ie){this.buffer+=n(ie)}openNode(ie){if(!l(ie))return;const Ne=c(ie.scope,{prefix:this.classPrefix});this.span(Ne)}closeNode(ie){l(ie)&&(this.buffer+=o)}value(){return this.buffer}span(ie){this.buffer+=`<span class="${ie}">`}}const m=(G={})=>{const ie={children:[]};return Object.assign(ie,G),ie};class p{constructor(){this.rootNode=m(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(ie){this.top.children.push(ie)}openNode(ie){const Ne=m({scope:ie});this.add(Ne),this.stack.push(Ne)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(ie){return this.constructor._walk(ie,this.rootNode)}static _walk(ie,Ne){return typeof Ne=="string"?ie.addText(Ne):Ne.children&&(ie.openNode(Ne),Ne.children.forEach(Le=>this._walk(ie,Le)),ie.closeNode(Ne)),ie}static _collapse(ie){typeof ie!="string"&&ie.children&&(ie.children.every(Ne=>typeof Ne=="string")?ie.children=[ie.children.join("")]:ie.children.forEach(Ne=>{p._collapse(Ne)}))}}class h extends p{constructor(ie){super(),this.options=ie}addText(ie){ie!==""&&this.add(ie)}startScope(ie){this.openNode(ie)}endScope(){this.closeNode()}__addSublanguage(ie,Ne){const Le=ie.root;Ne&&(Le.scope=`language:${Ne}`),this.add(Le)}toHTML(){return new d(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function g(G){return G?typeof G=="string"?G:G.source:null}function x(G){return C("(?=",G,")")}function y(G){return C("(?:",G,")*")}function w(G){return C("(?:",G,")?")}function C(...G){return G.map(Ne=>g(Ne)).join("")}function T(G){const ie=G[G.length-1];return typeof ie=="object"&&ie.constructor===Object?(G.splice(G.length-1,1),ie):{}}function S(...G){return"("+(T(G).capture?"":"?:")+G.map(Le=>g(Le)).join("|")+")"}function _(G){return new RegExp(G.toString()+"|").exec("").length-1}function j(G,ie){const Ne=G&&G.exec(ie);return Ne&&Ne.index===0}const O=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function P(G,{joinWith:ie}){let Ne=0;return G.map(Le=>{Ne+=1;const Je=Ne;let vt=g(Le),Ie="";for(;vt.length>0;){const tt=O.exec(vt);if(!tt){Ie+=vt;break}Ie+=vt.substring(0,tt.index),vt=vt.substring(tt.index+tt[0].length),tt[0][0]==="\\"&&tt[1]?Ie+="\\"+String(Number(tt[1])+Je):(Ie+=tt[0],tt[0]==="("&&Ne++)}return Ie}).map(Le=>`(${Le})`).join(ie)}const D=/\b\B/,$="[a-zA-Z]\\w*",X="[a-zA-Z_]\\w*",ee="\\b\\d+(\\.\\d+)?",H="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",K="\\b(0b[01]+)",ae="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",W=(G={})=>{const ie=/^#![ ]*\//;return G.binary&&(G.begin=C(ie,/.*\b/,G.binary,/\b.*/)),r({scope:"meta",begin:ie,end:/$/,relevance:0,"on:begin":(Ne,Le)=>{Ne.index!==0&&Le.ignoreMatch()}},G)},F={begin:"\\\\[\\s\\S]",relevance:0},Z={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[F]},U={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[F]},Q={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/},ne=function(G,ie,Ne={}){const Le=r({scope:"comment",begin:G,end:ie,contains:[]},Ne);Le.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 Je=S("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 Le.contains.push({begin:C(/[ ]+/,"(",Je,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),Le},ke=ne("//","$"),B=ne("/\\*","\\*/"),q=ne("#","$"),le={scope:"number",begin:ee,relevance:0},I={scope:"number",begin:H,relevance:0},Ae={scope:"number",begin:K,relevance:0},$e={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[F,{begin:/\[/,end:/\]/,relevance:0,contains:[F]}]},Oe={scope:"title",begin:$,relevance:0},We={scope:"title",begin:X,relevance:0},st={begin:"\\.\\s*"+X,relevance:0};var At=Object.freeze({__proto__:null,APOS_STRING_MODE:Z,BACKSLASH_ESCAPE:F,BINARY_NUMBER_MODE:Ae,BINARY_NUMBER_RE:K,COMMENT:ne,C_BLOCK_COMMENT_MODE:B,C_LINE_COMMENT_MODE:ke,C_NUMBER_MODE:I,C_NUMBER_RE:H,END_SAME_AS_BEGIN:function(G){return Object.assign(G,{"on:begin":(ie,Ne)=>{Ne.data._beginMatch=ie[1]},"on:end":(ie,Ne)=>{Ne.data._beginMatch!==ie[1]&&Ne.ignoreMatch()}})},HASH_COMMENT_MODE:q,IDENT_RE:$,MATCH_NOTHING_RE:D,METHOD_GUARD:st,NUMBER_MODE:le,NUMBER_RE:ee,PHRASAL_WORDS_MODE:Q,QUOTE_STRING_MODE:U,REGEXP_MODE:$e,RE_STARTERS_RE:ae,SHEBANG:W,TITLE_MODE:Oe,UNDERSCORE_IDENT_RE:X,UNDERSCORE_TITLE_MODE:We});function gt(G,ie){G.input[G.index-1]==="."&&ie.ignoreMatch()}function jt(G,ie){G.className!==void 0&&(G.scope=G.className,delete G.className)}function Jt(G,ie){ie&&G.beginKeywords&&(G.begin="\\b("+G.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",G.__beforeBegin=gt,G.keywords=G.keywords||G.beginKeywords,delete G.beginKeywords,G.relevance===void 0&&(G.relevance=0))}function Rt(G,ie){Array.isArray(G.illegal)&&(G.illegal=S(...G.illegal))}function be(G,ie){if(G.match){if(G.begin||G.end)throw new Error("begin & end are not supported with match");G.begin=G.match,delete G.match}}function Me(G,ie){G.relevance===void 0&&(G.relevance=1)}const qe=(G,ie)=>{if(!G.beforeMatch)return;if(G.starts)throw new Error("beforeMatch cannot be used with starts");const Ne=Object.assign({},G);Object.keys(G).forEach(Le=>{delete G[Le]}),G.keywords=Ne.keywords,G.begin=C(Ne.beforeMatch,x(Ne.begin)),G.starts={relevance:0,contains:[Object.assign(Ne,{endsParent:!0})]},G.relevance=0,delete Ne.beforeMatch},ot=["of","and","for","in","not","or","if","then","parent","list","value"],ft="keyword";function se(G,ie,Ne=ft){const Le=Object.create(null);return typeof G=="string"?Je(Ne,G.split(" ")):Array.isArray(G)?Je(Ne,G):Object.keys(G).forEach(function(vt){Object.assign(Le,se(G[vt],ie,vt))}),Le;function Je(vt,Ie){ie&&(Ie=Ie.map(tt=>tt.toLowerCase())),Ie.forEach(function(tt){const St=tt.split("|");Le[St[0]]=[vt,Be(St[0],St[1])]})}}function Be(G,ie){return ie?Number(ie):Xe(G)?0:1}function Xe(G){return ot.includes(G.toLowerCase())}const Ge={},et=G=>{console.error(G)},yt=(G,...ie)=>{console.log(`WARN: ${G}`,...ie)},he=(G,ie)=>{Ge[`${G}/${ie}`]||(console.log(`Deprecated as of ${G}. ${ie}`),Ge[`${G}/${ie}`]=!0)},V=new Error;function ye(G,ie,{key:Ne}){let Le=0;const Je=G[Ne],vt={},Ie={};for(let tt=1;tt<=ie.length;tt++)Ie[tt+Le]=Je[tt],vt[tt+Le]=!0,Le+=_(ie[tt-1]);G[Ne]=Ie,G[Ne]._emit=vt,G[Ne]._multi=!0}function Qe(G){if(Array.isArray(G.begin)){if(G.skip||G.excludeBegin||G.returnBegin)throw et("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),V;if(typeof G.beginScope!="object"||G.beginScope===null)throw et("beginScope must be object"),V;ye(G,G.begin,{key:"beginScope"}),G.begin=P(G.begin,{joinWith:""})}}function pe(G){if(Array.isArray(G.end)){if(G.skip||G.excludeEnd||G.returnEnd)throw et("skip, excludeEnd, returnEnd not compatible with endScope: {}"),V;if(typeof G.endScope!="object"||G.endScope===null)throw et("endScope must be object"),V;ye(G,G.end,{key:"endScope"}),G.end=P(G.end,{joinWith:""})}}function ve(G){G.scope&&typeof G.scope=="object"&&G.scope!==null&&(G.beginScope=G.scope,delete G.scope)}function Ye(G){ve(G),typeof G.beginScope=="string"&&(G.beginScope={_wrap:G.beginScope}),typeof G.endScope=="string"&&(G.endScope={_wrap:G.endScope}),Qe(G),pe(G)}function nt(G){function ie(Ie,tt){return new RegExp(g(Ie),"m"+(G.case_insensitive?"i":"")+(G.unicodeRegex?"u":"")+(tt?"g":""))}class Ne{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(tt,St){St.position=this.position++,this.matchIndexes[this.matchAt]=St,this.regexes.push([St,tt]),this.matchAt+=_(tt)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const tt=this.regexes.map(St=>St[1]);this.matcherRe=ie(P(tt,{joinWith:"|"}),!0),this.lastIndex=0}exec(tt){this.matcherRe.lastIndex=this.lastIndex;const St=this.matcherRe.exec(tt);if(!St)return null;const jn=St.findIndex((Ea,Oi)=>Oi>0&&Ea!==void 0),vn=this.matchIndexes[jn];return St.splice(0,jn),Object.assign(St,vn)}}class Le{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(tt){if(this.multiRegexes[tt])return this.multiRegexes[tt];const St=new Ne;return this.rules.slice(tt).forEach(([jn,vn])=>St.addRule(jn,vn)),St.compile(),this.multiRegexes[tt]=St,St}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(tt,St){this.rules.push([tt,St]),St.type==="begin"&&this.count++}exec(tt){const St=this.getMatcher(this.regexIndex);St.lastIndex=this.lastIndex;let jn=St.exec(tt);if(this.resumingScanAtSamePosition()&&!(jn&&jn.index===this.lastIndex)){const vn=this.getMatcher(0);vn.lastIndex=this.lastIndex+1,jn=vn.exec(tt)}return jn&&(this.regexIndex+=jn.position+1,this.regexIndex===this.count&&this.considerAll()),jn}}function Je(Ie){const tt=new Le;return Ie.contains.forEach(St=>tt.addRule(St.begin,{rule:St,type:"begin"})),Ie.terminatorEnd&&tt.addRule(Ie.terminatorEnd,{type:"end"}),Ie.illegal&&tt.addRule(Ie.illegal,{type:"illegal"}),tt}function vt(Ie,tt){const St=Ie;if(Ie.isCompiled)return St;[jt,be,Ye,qe].forEach(vn=>vn(Ie,tt)),G.compilerExtensions.forEach(vn=>vn(Ie,tt)),Ie.__beforeBegin=null,[Jt,Rt,Me].forEach(vn=>vn(Ie,tt)),Ie.isCompiled=!0;let jn=null;return typeof Ie.keywords=="object"&&Ie.keywords.$pattern&&(Ie.keywords=Object.assign({},Ie.keywords),jn=Ie.keywords.$pattern,delete Ie.keywords.$pattern),jn=jn||/\w+/,Ie.keywords&&(Ie.keywords=se(Ie.keywords,G.case_insensitive)),St.keywordPatternRe=ie(jn,!0),tt&&(Ie.begin||(Ie.begin=/\B|\b/),St.beginRe=ie(St.begin),!Ie.end&&!Ie.endsWithParent&&(Ie.end=/\B|\b/),Ie.end&&(St.endRe=ie(St.end)),St.terminatorEnd=g(St.end)||"",Ie.endsWithParent&&tt.terminatorEnd&&(St.terminatorEnd+=(Ie.end?"|":"")+tt.terminatorEnd)),Ie.illegal&&(St.illegalRe=ie(Ie.illegal)),Ie.contains||(Ie.contains=[]),Ie.contains=[].concat(...Ie.contains.map(function(vn){return Dt(vn==="self"?Ie:vn)})),Ie.contains.forEach(function(vn){vt(vn,St)}),Ie.starts&&vt(Ie.starts,tt),St.matcher=Je(St),St}if(G.compilerExtensions||(G.compilerExtensions=[]),G.contains&&G.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return G.classNameAliases=r(G.classNameAliases||{}),vt(G)}function xt(G){return G?G.endsWithParent||xt(G.starts):!1}function Dt(G){return G.variants&&!G.cachedVariants&&(G.cachedVariants=G.variants.map(function(ie){return r(G,{variants:null},ie)})),G.cachedVariants?G.cachedVariants:xt(G)?r(G,{starts:G.starts?r(G.starts):null}):Object.isFrozen(G)?r(G):G}var ct="11.11.1";class Xt extends Error{constructor(ie,Ne){super(ie),this.name="HTMLInjectionError",this.html=Ne}}const R=n,oe=r,_e=Symbol("nomatch"),de=7,Pe=function(G){const ie=Object.create(null),Ne=Object.create(null),Le=[];let Je=!0;const vt="Could not find the language '{}', did you forget to load/include a language module?",Ie={disableAutodetect:!0,name:"Plain text",contains:[]};let tt={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:h};function St(ze){return tt.noHighlightRe.test(ze)}function jn(ze){let wt=ze.className+" ";wt+=ze.parentNode?ze.parentNode.className:"";const Ut=tt.languageDetectRe.exec(wt);if(Ut){const rn=ir(Ut[1]);return rn||(yt(vt.replace("{}",Ut[1])),yt("Falling back to no-highlight mode for this block.",ze)),rn?Ut[1]:"no-highlight"}return wt.split(/\s+/).find(rn=>St(rn)||ir(rn))}function vn(ze,wt,Ut){let rn="",Rn="";typeof wt=="object"?(rn=ze,Ut=wt.ignoreIllegals,Rn=wt.language):(he("10.7.0","highlight(lang, code, ...args) has been deprecated."),he("10.7.0",`Please use highlight(code, options) instead.
|
|
647
647
|
https://github.com/highlightjs/highlight.js/issues/2277`),Rn=ze,rn=wt),Ut===void 0&&(Ut=!0);const tr={code:rn,language:Rn};Ws("before:highlight",tr);const Mr=tr.result?tr.result:Ea(tr.language,tr.code,Ut);return Mr.code=tr.code,Ws("after:highlight",Mr),Mr}function Ea(ze,wt,Ut,rn){const Rn=Object.create(null);function tr(Ze,pt){return Ze.keywords[pt]}function Mr(){if(!Tt.keywords){In.addText(an);return}let Ze=0;Tt.keywordPatternRe.lastIndex=0;let pt=Tt.keywordPatternRe.exec(an),Lt="";for(;pt;){Lt+=an.substring(Ze,pt.index);const Vt=Yn.case_insensitive?pt[0].toLowerCase():pt[0],Nn=tr(Tt,Vt);if(Nn){const[Kr,Jo]=Nn;if(In.addText(Lt),Lt="",Rn[Vt]=(Rn[Vt]||0)+1,Rn[Vt]<=de&&(ls+=Jo),Kr.startsWith("_"))Lt+=pt[0];else{const Ic=Yn.classNameAliases[Kr]||Kr;Rr(pt[0],Ic)}}else Lt+=pt[0];Ze=Tt.keywordPatternRe.lastIndex,pt=Tt.keywordPatternRe.exec(an)}Lt+=an.substring(Ze),In.addText(Lt)}function gr(){if(an==="")return;let Ze=null;if(typeof Tt.subLanguage=="string"){if(!ie[Tt.subLanguage]){In.addText(an);return}Ze=Ea(Tt.subLanguage,an,!0,Lc[Tt.subLanguage]),Lc[Tt.subLanguage]=Ze._top}else Ze=Di(an,Tt.subLanguage.length?Tt.subLanguage:null);Tt.relevance>0&&(ls+=Ze.relevance),In.__addSublanguage(Ze._emitter,Ze.language)}function hn(){Tt.subLanguage!=null?gr():Mr(),an=""}function Rr(Ze,pt){Ze!==""&&(In.startScope(pt),In.addText(Ze),In.endScope())}function Oc(Ze,pt){let Lt=1;const Vt=pt.length-1;for(;Lt<=Vt;){if(!Ze._emit[Lt]){Lt++;continue}const Nn=Yn.classNameAliases[Ze[Lt]]||Ze[Lt],Kr=pt[Lt];Nn?Rr(Kr,Nn):(an=Kr,Mr(),an=""),Lt++}}function Ii(Ze,pt){return Ze.scope&&typeof Ze.scope=="string"&&In.openNode(Yn.classNameAliases[Ze.scope]||Ze.scope),Ze.beginScope&&(Ze.beginScope._wrap?(Rr(an,Yn.classNameAliases[Ze.beginScope._wrap]||Ze.beginScope._wrap),an=""):Ze.beginScope._multi&&(Oc(Ze.beginScope,pt),an="")),Tt=Object.create(Ze,{parent:{value:Tt}}),Tt}function Xo(Ze,pt,Lt){let Vt=j(Ze.endRe,Lt);if(Vt){if(Ze["on:end"]){const Nn=new t(Ze);Ze["on:end"](pt,Nn),Nn.isMatchIgnored&&(Vt=!1)}if(Vt){for(;Ze.endsParent&&Ze.parent;)Ze=Ze.parent;return Ze}}if(Ze.endsWithParent)return Xo(Ze.parent,pt,Lt)}function Pi(Ze){return Tt.matcher.regexIndex===0?(an+=Ze[0],1):(cs=!0,0)}function F0(Ze){const pt=Ze[0],Lt=Ze.rule,Vt=new t(Lt),Nn=[Lt.__beforeBegin,Lt["on:begin"]];for(const Kr of Nn)if(Kr&&(Kr(Ze,Vt),Vt.isMatchIgnored))return Pi(pt);return Lt.skip?an+=pt:(Lt.excludeBegin&&(an+=pt),hn(),!Lt.returnBegin&&!Lt.excludeBegin&&(an=pt)),Ii(Lt,Ze),Lt.returnBegin?0:pt.length}function br(Ze){const pt=Ze[0],Lt=wt.substring(Ze.index),Vt=Xo(Tt,Ze,Lt);if(!Vt)return _e;const Nn=Tt;Tt.endScope&&Tt.endScope._wrap?(hn(),Rr(pt,Tt.endScope._wrap)):Tt.endScope&&Tt.endScope._multi?(hn(),Oc(Tt.endScope,Ze)):Nn.skip?an+=pt:(Nn.returnEnd||Nn.excludeEnd||(an+=pt),hn(),Nn.excludeEnd&&(an=pt));do Tt.scope&&In.closeNode(),!Tt.skip&&!Tt.subLanguage&&(ls+=Tt.relevance),Tt=Tt.parent;while(Tt!==Vt.parent);return Vt.starts&&Ii(Vt.starts,Ze),Nn.returnEnd?0:pt.length}function Qo(){const Ze=[];for(let pt=Tt;pt!==Yn;pt=pt.parent)pt.scope&&Ze.unshift(pt.scope);Ze.forEach(pt=>In.openNode(pt))}let Ys={};function zi(Ze,pt){const Lt=pt&&pt[0];if(an+=Ze,Lt==null)return hn(),0;if(Ys.type==="begin"&&pt.type==="end"&&Ys.index===pt.index&&Lt===""){if(an+=wt.slice(pt.index,pt.index+1),!Je){const Vt=new Error(`0 width match regex (${ze})`);throw Vt.languageName=ze,Vt.badRule=Ys.rule,Vt}return 1}if(Ys=pt,pt.type==="begin")return F0(pt);if(pt.type==="illegal"&&!Ut){const Vt=new Error('Illegal lexeme "'+Lt+'" for mode "'+(Tt.scope||"<unnamed>")+'"');throw Vt.mode=Tt,Vt}else if(pt.type==="end"){const Vt=br(pt);if(Vt!==_e)return Vt}if(pt.type==="illegal"&&Lt==="")return an+=`
|
|
648
|
-
`,1;if(Zo>1e5&&Zo>pt.index*3)throw new Error("potential infinite loop, way more iterations than matches");return an+=Lt,Lt.length}const Yn=ir(ze);if(!Yn)throw et(vt.replace("{}",ze)),new Error('Unknown language: "'+ze+'"');const Dc=nt(Yn);let Bi="",Tt=rn||Dc;const Lc={},In=new tt.__emitter(tt);Qo();let an="",ls=0,Ma=0,Zo=0,cs=!1;try{if(Yn.__emitTokens)Yn.__emitTokens(wt,In);else{for(Tt.matcher.considerAll();;){Zo++,cs?cs=!1:Tt.matcher.considerAll(),Tt.matcher.lastIndex=Ma;const Ze=Tt.matcher.exec(wt);if(!Ze)break;const pt=wt.substring(Ma,Ze.index),Lt=zi(pt,Ze);Ma=Ze.index+Lt}zi(wt.substring(Ma))}return In.finalize(),Bi=In.toHTML(),{language:ze,value:Bi,relevance:ls,illegal:!1,_emitter:In,_top:Tt}}catch(Ze){if(Ze.message&&Ze.message.includes("Illegal"))return{language:ze,value:R(wt),illegal:!0,relevance:0,_illegalBy:{message:Ze.message,index:Ma,context:wt.slice(Ma-100,Ma+100),mode:Ze.mode,resultSoFar:Bi},_emitter:In};if(Je)return{language:ze,value:R(wt),illegal:!1,relevance:0,errorRaised:Ze,_emitter:In,_top:Tt};throw Ze}}function Oi(ze){const wt={value:R(ze),illegal:!1,relevance:0,_top:Ie,_emitter:new tt.__emitter(tt)};return wt._emitter.addText(ze),wt}function Di(ze,wt){wt=wt||tt.languages||Object.keys(ie);const Ut=Oi(ze),rn=wt.filter(ir).filter(is).map(hn=>Ea(hn,ze,!1));rn.unshift(Ut);const Rn=rn.sort((hn,Rr)=>{if(hn.relevance!==Rr.relevance)return Rr.relevance-hn.relevance;if(hn.language&&Rr.language){if(ir(hn.language).supersetOf===Rr.language)return 1;if(ir(Rr.language).supersetOf===hn.language)return-1}return 0}),[tr,Mr]=Rn,gr=tr;return gr.secondBest=Mr,gr}function ma(ze,wt,Ut){const rn=wt&&Ne[wt]||Ut;ze.classList.add("hljs"),ze.classList.add(`language-${rn}`)}function Mn(ze){let wt=null;const Ut=jn(ze);if(St(Ut))return;if(Ws("before:highlightElement",{el:ze,language:Ut}),ze.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",ze);return}if(ze.children.length>0&&(tt.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(ze)),tt.throwUnescapedHTML))throw new Xt("One of your code blocks includes unescaped HTML.",ze.innerHTML);wt=ze;const rn=wt.textContent,Rn=Ut?vn(rn,{language:Ut,ignoreIllegals:!0}):Di(rn);ze.innerHTML=Rn.value,ze.dataset.highlighted="yes",ma(ze,Ut,Rn.language),ze.result={language:Rn.language,re:Rn.relevance,relevance:Rn.relevance},Rn.secondBest&&(ze.secondBest={language:Rn.secondBest.language,relevance:Rn.secondBest.relevance}),Ws("after:highlightElement",{el:ze,result:Rn,text:rn})}function er(ze){tt=oe(tt,ze)}const ss=()=>{Li(),he("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Wo(){Li(),he("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let jc=!1;function Li(){function ze(){Li()}if(document.readyState==="loading"){jc||window.addEventListener("DOMContentLoaded",ze,!1),jc=!0;return}document.querySelectorAll(tt.cssSelector).forEach(Mn)}function Mc(ze,wt){let Ut=null;try{Ut=wt(G)}catch(rn){if(et("Language definition for '{}' could not be registered.".replace("{}",ze)),Je)et(rn);else throw rn;Ut=Ie}Ut.name||(Ut.name=ze),ie[ze]=Ut,Ut.rawDefinition=wt.bind(null,G),Ut.aliases&&_a(Ut.aliases,{languageName:ze})}function Ks(ze){delete ie[ze];for(const wt of Object.keys(Ne))Ne[wt]===ze&&delete Ne[wt]}function Yo(){return Object.keys(ie)}function ir(ze){return ze=(ze||"").toLowerCase(),ie[ze]||ie[Ne[ze]]}function _a(ze,{languageName:wt}){typeof ze=="string"&&(ze=[ze]),ze.forEach(Ut=>{Ne[Ut.toLowerCase()]=wt})}function is(ze){const wt=ir(ze);return wt&&!wt.disableAutodetect}function os(ze){ze["before:highlightBlock"]&&!ze["before:highlightElement"]&&(ze["before:highlightElement"]=wt=>{ze["before:highlightBlock"](Object.assign({block:wt.el},wt))}),ze["after:highlightBlock"]&&!ze["after:highlightElement"]&&(ze["after:highlightElement"]=wt=>{ze["after:highlightBlock"](Object.assign({block:wt.el},wt))})}function Ln(ze){os(ze),Le.push(ze)}function Rc(ze){const wt=Le.indexOf(ze);wt!==-1&&Le.splice(wt,1)}function Ws(ze,wt){const Ut=ze;Le.forEach(function(rn){rn[Ut]&&rn[Ut](wt)})}function ja(ze){return he("10.7.0","highlightBlock will be removed entirely in v12.0"),he("10.7.0","Please use highlightElement now."),Mn(ze)}Object.assign(G,{highlight:vn,highlightAuto:Di,highlightAll:Li,highlightElement:Mn,highlightBlock:ja,configure:er,initHighlighting:ss,initHighlightingOnLoad:Wo,registerLanguage:Mc,unregisterLanguage:Ks,listLanguages:Yo,getLanguage:ir,registerAliases:_a,autoDetection:is,inherit:oe,addPlugin:Ln,removePlugin:Rc}),G.debugMode=function(){Je=!1},G.safeMode=function(){Je=!0},G.versionString=ct,G.regex={concat:C,lookahead:x,either:S,optional:w,anyNumberOfTimes:y};for(const ze in At)typeof At[ze]=="object"&&e(At[ze]);return Object.assign(G,At),G},Ve=Pe({});return Ve.newInstance=()=>Pe({}),Fp=Ve,Ve.HighlightJS=Ve,Ve.default=Ve,Fp}var bG=gG();const xG=wc(bG),$2={},yG="hljs-";function vG(e){const t=xG.newInstance();return e&&l(e),{highlight:n,highlightAuto:r,listLanguages:o,register:l,registerAlias:c,registered:d};function n(m,p,h){const g=h||$2,x=typeof g.prefix=="string"?g.prefix:yG;if(!t.getLanguage(m))throw new Error("Unknown language: `"+m+"` is not registered");t.configure({__emitter:wG,classPrefix:x});const y=t.highlight(p,{ignoreIllegals:!0,language:m});if(y.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:y.errorRaised});const w=y._emitter.root,C=w.data;return C.language=y.language,C.relevance=y.relevance,w}function r(m,p){const g=(p||$2).subset||o();let x=-1,y=0,w;for(;++x<g.length;){const C=g[x];if(!t.getLanguage(C))continue;const T=n(C,m,p);T.data&&T.data.relevance!==void 0&&T.data.relevance>y&&(y=T.data.relevance,w=T)}return w||{type:"root",children:[],data:{language:void 0,relevance:y}}}function o(){return t.listLanguages()}function l(m,p){if(typeof m=="string")t.registerLanguage(m,p);else{let h;for(h in m)Object.hasOwn(m,h)&&t.registerLanguage(h,m[h])}}function c(m,p){if(typeof m=="string")t.registerAliases(typeof p=="string"?p:[...p],{languageName:m});else{let h;for(h in m)if(Object.hasOwn(m,h)){const g=m[h];t.registerAliases(typeof g=="string"?g:[...g],{languageName:h})}}}function d(m){return!!t.getLanguage(m)}}class wG{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],r=n.children[n.children.length-1];r&&r.type==="text"?r.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const r=this.stack[this.stack.length-1],o=t.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:o}):r.children.push(...o)}openNode(t){const n=this,r=t.split(".").map(function(c,d){return d?c+"_".repeat(d):n.options.classPrefix+c}),o=this.stack[this.stack.length-1],l={type:"element",tagName:"span",properties:{className:r},children:[]};o.children.push(l),this.stack.push(l)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const kG={};function s3(e){const t=e||kG,n=t.aliases,r=t.detect||!1,o=t.languages||hG,l=t.plainText,c=t.prefix,d=t.subset;let m="hljs";const p=vG(o);if(n&&p.registerAlias(n),c){const h=c.indexOf("-");m=h===-1?c:c.slice(0,h)}return function(h,g){E0(h,"element",function(x,y,w){if(x.tagName!=="code"||!w||w.type!=="element"||w.tagName!=="pre")return;const C=SG(x);if(C===!1||!C&&!r||C&&l&&l.includes(C))return;Array.isArray(x.properties.className)||(x.properties.className=[]),x.properties.className.includes(m)||x.properties.className.unshift(m);const T=zk(x,{whitespace:"pre"});let S;try{S=C?p.highlight(C,T,{prefix:c}):p.highlightAuto(T,{prefix:c,subset:d})}catch(_){const j=_;if(C&&/Unknown language/.test(j.message)){g.message("Cannot highlight as `"+C+"`, it’s not registered",{ancestors:[w,x],cause:j,place:x.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw j}!C&&S.data&&S.data.language&&x.properties.className.push("language-"+S.data.language),S.children.length>0&&(x.children=S.children)})}}function SG(e){const t=e.properties.className;let n=-1;if(!Array.isArray(t))return;let r;for(;++n<t.length;){const o=String(t[n]);if(o==="no-highlight"||o==="nohighlight")return!1;!r&&o.slice(0,5)==="lang-"&&(r=o.slice(5)),!r&&o.slice(0,9)==="language-"&&(r=o.slice(9))}return r}const NG=10,Bh=new Map;function CG(e,t=3e3){Bh.set(e,Date.now()+t)}function TG(e){const t=Bh.get(e);return t==null?!1:Date.now()>t?(Bh.delete(e),!1):!0}function H2(e){if(e.kind==="file")return`file:${e.path}`;if(e.kind==="url")return`url:${e.browserId||e.url}`;const t=e.deliverable;return`deliverable:${t.id||`${t.reference||""}|${t.title||""}|${t.summary?.slice(0,48)||""}`||"unknown"}`}function AG(e){return e.kind==="deliverable"?e.deliverable.title||e.deliverable.reference||"Deliverable":e.kind==="url"?e.title||e.url:e.title||e.path.split(/[/\\]/).pop()||e.path}const i3=k.createContext(null);function EG({children:e}){const[t,n]=k.useState(()=>{try{return localStorage.getItem("markus_sidebar_c")==="1"}catch{return!1}}),[r,o]=k.useState([]),[l,c]=k.useState(null),[d,m]=k.useState(!1),[p,h]=k.useState(!1),g=k.useRef([]),x=k.useRef(null),y=k.useRef(null);y.current=l;const w=k.useCallback(W=>n(W),[]),C=k.useCallback(()=>n(W=>!W),[]),T=k.useCallback(W=>{const F=H2(W),Z=`tab_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;let U=null;o(Q=>{const ne=Q.find(q=>H2(q.payload)===F);if(ne)return U=ne.id,g.current=Q,Q;let B=[{id:Z,title:AG(W),payload:W},...Q];for(;B.length>NG;){let q=-1;for(let le=B.length-1;le>=0;le--)if(!B[le].pinned){q=le;break}if(q<0)break;B=B.filter((le,I)=>I!==q)}return U=Z,g.current=B,B}),U&&(c(U),x.current=U),n(!0)},[]),S=W=>{W?.kind==="url"&&W.browserId&&(CG(W.browserId),window.markusDesktop?.browser?.destroy(W.browserId))},_=k.useCallback(W=>{let F,Z,U=!1;const Q=y.current;o(ne=>{const ke=ne.findIndex(I=>I.id===W);if(ke<0)return ne;F=ne[ke]?.payload;const B=ne.filter(I=>I.id!==W);g.current=B,U=B.length===0;const le=(ne.some(I=>I.id===Q)?Q:ne[0]?.id??null)===W;return Z=void 0,(le||B.length===0)&&(Z=B[Math.min(ke,B.length-1)]?.id??null),B}),U&&m(!1),Z!==void 0&&(c(Z),x.current=Z),S(F)},[]),j=k.useCallback(()=>{let W=[];o(F=>(W=F.map(Z=>Z.payload),[])),c(null),m(!1),g.current=[],x.current=null;for(const F of W)S(F)},[]),O=k.useCallback(W=>{c(W),x.current=W},[]),P=k.useCallback((W,F)=>{o(Z=>{let U=!1;const Q=Z.map(ne=>{if(ne.payload.kind!=="url"||ne.payload.browserId!==W)return ne;const ke=F.url??ne.payload.url,B=F.title||ne.payload.title||ke,q=F.pageId??ne.payload.pageId;return ke===ne.payload.url&&B===(ne.payload.title||ne.title)&&q===ne.payload.pageId&&B===ne.title?ne:(U=!0,{...ne,title:B,payload:{...ne.payload,url:ke,title:B,...q!=null?{pageId:q}:{}}})});return U&&(g.current=Q),U?Q:Z})},[]),D=k.useCallback(()=>{o(W=>W.length===0?W:(g.current=W,y.current&&(x.current=y.current),[])),c(null),m(!1),window.markusDesktop?.browser?.hideAll?.()},[]),$=k.useCallback(()=>{const W=`tab_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,F=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;let Z,U=!1,Q=!1;o(ne=>{if(ne.length>0)return g.current=ne,y.current&&(x.current=y.current),Q=!0,Z=null,[];if(g.current.length>0){U=!0;const B=g.current;return Z=x.current&&B.some(le=>le.id===x.current)?x.current:B[0].id,B}U=!0;const ke={id:W,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:F}};return g.current=[ke],Z=ke.id,[ke]}),U&&n(!0),Q?(c(null),m(!1),window.markusDesktop?.browser?.hideAll?.()):Z!=null&&(c(Z),x.current=Z)},[]),X=k.useCallback(W=>m(W),[]),ee=k.useCallback(()=>m(W=>!W),[]),H=r.find(W=>W.id===l)??r[0]??null,K=H?.payload??null,ae=k.useMemo(()=>({leftCollapsed:t,setLeftCollapsed:w,toggleLeftCollapsed:C,rightPanel:K,rightPanelOpen:r.length>0,rightPanelTabs:r,activeRightPanelTabId:H?.id??null,openRightPanel:T,closeRightPanel:j,closeRightPanelTab:_,setActiveRightPanelTab:O,updateRightPanelBrowserTab:P,toggleRightPanel:$,collapseRightPanelOnly:D,rightPanelFullscreen:d,setRightPanelFullscreen:X,toggleRightPanelFullscreen:ee,hostAvailable:p,setHostAvailable:h}),[t,w,C,K,r,H,T,j,_,O,P,$,D,d,X,ee,p]);return s.jsx(i3.Provider,{value:ae,children:e})}function Ec(){return k.useContext(i3)}k.lazy(()=>qr(()=>Promise.resolve().then(()=>T3),void 0).then(e=>({default:e.MarkdownMessage})));const _G=k.lazy(()=>qr(()=>import("./ContentRenderer-Ccoj5KhH.js"),[]).then(e=>({default:e.ContentRenderer})));let wo=[],F2=60;function jG(e){const t=k.useRef(e);t.current=e;const[n]=k.useState(()=>++F2);return k.useEffect(()=>{const r=()=>t.current();wo.push(r);const o=l=>{l.key==="Escape"&&wo[wo.length-1]===r&&(l.preventDefault(),r())};return window.addEventListener("keydown",o,!0),()=>{window.removeEventListener("keydown",o,!0),wo=wo.filter(l=>l!==r),wo.length===0&&(F2=60)}},[]),n}const q2=500,Bs=new Map,u0=new Set,Pd=new Map;let zd=null;function MG(){if(Bs.size<=q2)return;const e=Bs.size-q2,t=Bs.keys();for(let n=0;n<e;n++){const{value:r,done:o}=t.next();if(o)break;Bs.delete(r)}}function G2(e,t){Bs.delete(e),Bs.set(e,t),MG()}function V2(e){const t=Pd.get(e);if(t)for(const n of t)n()}function RG(){zd=null;const e=[...u0];u0.clear(),e.length!==0&&Ce.files.check(e).then(({results:t})=>{for(const[n,r]of Object.entries(t))G2(n,r),V2(n)}).catch(()=>{for(const t of e)G2(t,{exists:!1,isFile:!1,type:"unknown"}),V2(t)})}function OG(e){Bs.has(e)||u0.has(e)||(u0.add(e),zd&&clearTimeout(zd),zd=setTimeout(RG,30))}function DG(e,t){let n=Pd.get(e);return n||(n=new Set,Pd.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Pd.delete(e)}}function LG(e){const t=k.useCallback(o=>DG(e,o),[e]),n=k.useCallback(()=>Bs.get(e),[e]),r=k.useSyncExternalStore(t,n,n);return k.useEffect(()=>{OG(e)},[e]),r}const IG=/^(?:\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|~\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|[A-Za-z]:(?:\\|\/)[\w.\-@+ ]+(?:(?:\\|\/)[\w.\-@+ ]*)*|\.\.?\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*)$/;function PG(e){return e.length<2||e.length>500?!1:IG.test(e)}function zG({filePath:e,onClose:t}){const n=jG(t),[r,o]=k.useState(!0),[l,c]=k.useState(null),[d,m]=k.useState(""),[p,h]=k.useState(""),[g,x]=k.useState(""),[y,w]=k.useState(""),[C,T]=k.useState("");k.useEffect(()=>{o(!0),c(null),Ce.files.preview(e).then(_=>{m(typeof _.content=="string"?_.content:""),h(_.type),x(_.name),w(_.mimeType||""),T(_.streamUrl||(_.path?Ce.files.streamUrl(_.path):"")||(_.type==="audio"||_.type==="video"?Ce.files.streamUrl(e):""))}).catch(_=>{c(String(_?.message||_))}).finally(()=>{o(!1)})},[e]);const S=g||e.split(/[/\\]/).pop()||e;return Sa.createPortal(s.jsx("div",{className:"fixed inset-0 bg-black/40 flex items-center justify-center",style:{zIndex:n},onClick:t,children:s.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:_=>_.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-default bg-surface-elevated/50 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("svg",{className:"w-4 h-4 shrink-0 text-fg-secondary",viewBox:"0 0 20 20",fill:"currentColor",children:s.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"})}),s.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:S}),s.jsx("span",{className:"text-xs text-fg-tertiary truncate hidden sm:inline",children:e})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx("button",{className:"text-xs text-fg-secondary hover:text-fg-primary px-2 py-1 rounded hover:bg-surface-elevated transition-colors",onClick:()=>Ce.files.reveal(e),title:"Reveal in file explorer",children:s.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:s.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"})})}),s.jsx("button",{className:"text-fg-secondary hover:text-fg-primary p-1 rounded hover:bg-surface-elevated transition-colors",onClick:t,children:s.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:s.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"})})})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[r&&s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"w-5 h-5 border-2 border-brand-500/30 border-t-brand-500 rounded-full animate-spin"})}),l&&s.jsxs("div",{className:"text-center py-12 text-fg-secondary text-sm",children:[s.jsx("p",{className:"text-red-400 mb-1",children:"Failed to load file"}),s.jsx("p",{className:"text-xs text-fg-tertiary",children:l})]}),!r&&!l&&p==="image"&&d&&s.jsx("div",{className:"flex justify-center",children:s.jsx("img",{src:`data:${y||"image/png"};base64,${d}`,alt:S,className:"max-w-full rounded"})}),!r&&!l&&p==="audio"&&C&&s.jsx("audio",{controls:!0,preload:"metadata",src:C,className:"w-full"}),!r&&!l&&p==="video"&&C&&s.jsx("video",{controls:!0,preload:"metadata",src:C,className:"w-full max-h-[60vh] rounded-lg bg-black"}),!r&&!l&&(p==="binary"||!d&&p!=="image"&&p!=="audio"&&p!=="video")&&s.jsxs("div",{className:"text-center py-8 space-y-3",children:[s.jsx("p",{className:"text-sm text-fg-secondary",children:"This file type cannot be previewed."}),s.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:()=>{Ce.files.reveal(e)},children:"Reveal in file explorer"})]}),!r&&!l&&d&&p!=="image"&&p!=="audio"&&p!=="video"&&p!=="binary"&&s.jsx(k.Suspense,{fallback:s.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading…"}),children:s.jsx(_G,{content:d,format:p==="text"?"text":p,className:"text-sm"})})]})]})}),document.body)}function BG({path:e}){const t=LG(e),[n,r]=k.useState(null),o=Ec(),l=t?.exists??!1,c=t?.type==="markdown"||t?.type==="html"||t?.type==="json"||t?.type==="text"||t?.type==="image"||t?.type==="audio"||t?.type==="video",d=k.useCallback(h=>{if(h.preventDefault(),h.stopPropagation(),!!l)if(c){if(o?.hostAvailable){o.openRightPanel({kind:"file",path:e});return}r(e)}else Ce.files.reveal(e)},[l,c,e,o]),m="inline w-3 h-3 align-[-0.125em]",p=c?s.jsx("svg",{className:m,viewBox:"0 0 20 20",fill:"currentColor",children:s.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"})}):s.jsx("svg",{className:m,viewBox:"0 0 20 20",fill:"currentColor",children:s.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 t?l?s.jsxs(s.Fragment,{children:[s.jsxs("code",{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:d,title:c?"Click to preview":"Click to reveal in file explorer",role:"button",tabIndex:0,children:[s.jsxs("span",{className:"whitespace-nowrap",children:[p,e.charAt(0)]}),e.slice(1)]}),n&&s.jsx(zG,{filePath:n,onClose:()=>r(null)})]}):s.jsx("code",{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:"File not found",children:e}):s.jsx("code",{className:"bg-surface-secondary px-1.5 py-0.5 rounded text-xs font-mono text-fg-secondary break-all",children:e})}let qp=null;function UG(){return qp||(qp=qr(()=>import("./mermaid.core-D9X_B1hr.js").then(e=>e.b9),__vite__mapDeps([0,1])).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:"loose",fontFamily:"inherit"}),e))),qp}function $G(){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 HG(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 FG(){return $G()}function qG(){return k.useSyncExternalStore(HG,FG)}function o3({code:e}){const t=k.useRef(null),[n,r]=k.useState(null),[o,l]=k.useState(!0),c=k.useId(),d=k.useRef(0),m=k.useRef(null),p=qG();return k.useEffect(()=>{if(!e.trim()||m.current&&m.current.code===e&&m.current.dark===p)return;let h=!1;return l(!0),r(null),d.current+=1,(async()=>{try{const g=await UG();if(h)return;g.default.initialize({startOnLoad:!1,theme:p?"dark":"default",securityLevel:"loose",fontFamily:"inherit"});const x=`mermaid-${c.replace(/:/g,"")}-${d.current}`,{svg:y}=await g.default.render(x,e.trim());if(h)return;t.current&&(t.current.innerHTML=y,m.current={code:e,dark:p})}catch(g){h||r(g instanceof Error?g.message:String(g))}finally{h||l(!1)}})(),()=>{h=!0}},[e,c,p]),n?s.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[s.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:[s.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.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"})}),s.jsx("span",{className:"text-[10px] font-medium text-red-400",children:"Mermaid render error"})]}),s.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):s.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[o&&s.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[s.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),"Rendering diagram…"]}),s.jsx("div",{ref:t,className:`flex justify-center [&>svg]:max-w-full${o?" hidden":""}`})]})}const GG="/assets/viz-global-C_AyN6D9.js";let hd=!1,Gp=null;function VG(){return hd?Promise.resolve():new Promise((e,t)=>{const n=document.querySelector("script[data-plantuml-viz]");if(n){globalThis.Viz?(hd=!0,e()):(n.addEventListener("load",()=>{hd=!0,e()}),n.addEventListener("error",()=>t(new Error("Failed to load viz-global.js"))));return}const r=document.createElement("script");r.setAttribute("data-plantuml-viz",""),r.src=GG,r.onload=()=>{hd=!0,e()},r.onerror=()=>t(new Error("Failed to load viz-global.js")),document.head.appendChild(r)})}function KG(){return Gp||(Gp=VG().then(()=>qr(()=>import("./plantuml-DezRDxd4.js"),[]))),Gp}let K2=Promise.resolve();function WG(e,t){const n=K2.then(()=>new Promise((r,o)=>{KG().then(({renderToString:l})=>{const c=e.split(/\r\n|\r|\n/);l(c,r,o,{dark:t})}).catch(o)}));return K2=n.then(()=>{},()=>{}),n}function YG(){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 XG(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 QG(){return k.useSyncExternalStore(XG,()=>YG())}function l3({code:e}){const[t,n]=k.useState(null),[r,o]=k.useState(null),[l,c]=k.useState(!0),d=k.useRef(null),m=QG();return k.useEffect(()=>{if(!e.trim()||d.current&&d.current.code===e&&d.current.dark===m)return;let p=!1;return c(!0),o(null),WG(e.trim(),m).then(h=>{p||(n(h),d.current={code:e,dark:m})}).catch(h=>{p||o(h instanceof Error?h.message:String(h))}).finally(()=>{p||c(!1)}),()=>{p=!0}},[e,m]),r?s.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[s.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:[s.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.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"})}),s.jsx("span",{className:"text-[10px] font-medium text-red-400",children:"PlantUML render error"})]}),s.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):s.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[l&&s.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[s.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),"Rendering diagram…"]}),t&&s.jsx("div",{className:`flex justify-center [&>svg]:max-w-full${l?" hidden":""}`,dangerouslySetInnerHTML:{__html:t}})]})}function ZG(e,t,n){const r=e.cloneNode(!0),o=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},d=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:${d.text};line-height:1.7;`,h1:`font-size:${c.h1}em;font-weight:700;color:${d.heading};margin:20px 0 10px;line-height:1.3;border-bottom:1px solid ${d.border};padding-bottom:6px;`,h2:`font-size:${c.h2}em;font-weight:700;color:${d.heading};margin:18px 0 8px;line-height:1.3;`,h3:`font-size:${c.h3}em;font-weight:600;color:${d.heading};margin:14px 0 6px;line-height:1.3;`,h4:`font-size:${c.h4}em;font-weight:600;color:${d.heading};margin:12px 0 4px;`,strong:`font-weight:600;color:${d.strong};`,em:"font-style:italic;",a:`color:${d.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:${d.text};`,blockquote:`border-left:3px solid ${d.blockquoteBorder};padding:2px 0 2px 14px;margin:10px 0;color:${d.blockquoteText};`,hr:`border:none;border-top:1px solid ${d.hrColor};margin:20px 0;`,table:"border-collapse:collapse;width:100%;margin:10px 0;",thead:`background:${d.tableHeaderBg};`,th:`border:1px solid ${d.tableBorder};padding:8px 12px;text-align:left;font-weight:600;color:${d.tableHeaderText};`,td:`border:1px solid ${d.tableBorder};padding:8px 12px;color:${d.text};`,img:"max-width:100%;height:auto;"};function p(h){h.removeAttribute("class");const g=h.tagName.toLowerCase();if(g==="pre"){h.setAttribute("style",`background:${d.preBg};color:${d.preText};padding:14px;border-radius:6px;overflow-x:auto;margin:10px 0;font-size:0.88em;line-height:1.5;border:1px solid ${d.preBorder};`);const x=h.querySelector("code");x&&(x.removeAttribute("class"),x.setAttribute("style","background:transparent;padding:0;border-radius:0;color:inherit;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;font-size:inherit;"));return}g==="code"?h.setAttribute("style",`background:${d.codeBg};color:${d.codeText};padding:2px 6px;border-radius:4px;font-size:0.9em;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;`):m[g]&&h.setAttribute("style",m[g]),Array.from(h.children).forEach(p)}return r.removeAttribute("class"),Array.from(r.children).forEach(h=>p(h)),`<div style="background:${d.bg};color:${d.text};padding:20px 24px;font-family:${o};font-size:${l};line-height:1.7;max-width:800px;">${r.innerHTML}</div>`}async function Ig(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 JG(e,t,n,r){const o=ZG(e,t,r);try{return await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([o],{type:"text/html"}),"text/plain":new Blob([n],{type:"text/plain"})})]),{ok:!0,method:"html"}}catch{return{ok:await Ig(n),method:"text"}}}function Uh({code:e,language:t,children:n}){const{t:r}=dt("common"),[o,l]=k.useState("rendered"),[c,d]=k.useState(!1),m=k.useCallback(async()=>{await Ig(e)&&(d(!0),setTimeout(()=>d(!1),1800))},[e]);return s.jsxs("div",{className:"not-prose my-2 rounded-lg overflow-hidden border border-border-subtle",children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle bg-surface-secondary",children:[s.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:t}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>l("rendered"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${o==="rendered"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),s.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"})]}),r("markdown.viewRendered")]})}),s.jsx("button",{onClick:()=>l("source"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${o==="source"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}),r("markdown.viewSource")]})})]})]}),o==="rendered"?s.jsx("div",{children:n}):s.jsxs("div",{className:"relative group/source",children:[s.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}),s.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:r("markdown.copyContent"),children:c?s.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.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"})})})]})]})}function Yl(e,t){const n=/```[\s\S]*?```|`[^`\n]+`/g;let r=0,o="";for(const l of e.matchAll(n))o+=t(e.slice(r,l.index)),o+=l[0],r=l.index+l[0].length;return o+=t(e.slice(r)),o}function eV(e){let t=e.replace(/\\\[([\s\S]*?)\\\]/g,(n,r)=>`$$${r}$$`);return t=t.replace(/\\\((.+?)\\\)/g,(n,r)=>`$${r}$`),t}const gd="#mention:";function tV(e,t){if(!t||t.length===0)return e.replace(/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu,(l,c,d)=>{const m=c??d;return`[@${m}](${gd}${encodeURIComponent(m)})`});const n=[...t].sort((l,c)=>c.length-l.length);let r="",o=0;for(;o<e.length;){const l=e.indexOf("@",o);if(l<0){r+=e.slice(o);break}if(r+=e.slice(o,l),e[l+1]==="["){const h=e.indexOf("]",l+2);if(h>l+2){const g=e.slice(l+2,h);r+=`[@${g}](${gd}${encodeURIComponent(g)})`,o=h+1;continue}}const c=e.slice(l+1),d=c.toLowerCase(),m=n.find(h=>d.startsWith(h.toLowerCase()));if(m){const h=c.slice(0,m.length);r+=`[@${h}](${gd}${encodeURIComponent(h)})`,o=l+1+m.length;continue}const p=c.match(/^([\w\p{L}\p{N}]+)/u);if(p){const h=p[1];r+=`[@${h}](${gd}${encodeURIComponent(h)})`,o=l+1+h.length;continue}r+="@",o=l+1}return r}const c3="#entity:",nV=new RegExp("(?<!\\[)(?<!\\()(?<!:)(?<!\\/)(?<!\\\\)\\b(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}\\b(?!\\]\\(#entity:)","gi"),rV=/`\[([^\]]+)\]\(#entity:((?:tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)`/gi;function aV(e,t){const n=e.slice(0,t),r=n.lastIndexOf("](");return r===-1?!1:n.indexOf(")",r+2)===-1}function sV(e){return e.replace(rV,(t,n,r)=>`[${n}](${c3}${r})`)}function iV(e){return e.replace(nV,(t,n,r)=>aV(e,r)?t:`[${t}](${c3}${t})`)}function oV(e){const t=e.trim();return t.startsWith("@startuml")&&t.endsWith("@enduml")}const lV=/^(graph\s|flowchart\s|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt|pie|gitGraph|mindmap|timeline|journey)/m;function cV(e){return lV.test(e.trim())}const uV={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 dV(e){return uV[e.toLowerCase()]??e.charAt(0).toUpperCase()+e.slice(1)}function mV(e){const t=e.match(/language-(\S+)/);return t?t[1]:null}const fV=[o3,l3];function pV(e){for(const t of k.Children.toArray(e))if(k.isValidElement(t)&&typeof t.props?.className=="string"){const n=t.props.className;return mV(n)}return null}function ac(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(!e)return"";if(Array.isArray(e))return e.map(ac).join("");if(k.isValidElement(e)){const t=e.props;return ac(t.children)}return""}function hV({children:e}){const{t}=dt("common"),n=pV(e),r=k.useRef(null),[o,l]=k.useState(!1),[c,d]=k.useState("rendered"),m=k.useCallback(async()=>{let h;c==="source"?h=ac(e):h=r.current?.querySelector("code")?.textContent??"";try{await navigator.clipboard.writeText(h),l(!0),setTimeout(()=>l(!1),1800)}catch{}},[c,e]);if(k.Children.toArray(e).some(h=>k.isValidElement(h)&&fV.includes(h.type))){const h=ac(e),g=n==="mermaid"||n==="plantuml"?n:"diagram";return s.jsx(Uh,{code:h,language:g,children:e})}return n==="mermaid"||n==="plantuml"?s.jsx(s.Fragment,{children:e}):s.jsxs("div",{className:"not-prose relative group/code my-2 rounded-lg overflow-hidden bg-surface-secondary border border-border-subtle",children:[n&&s.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle",children:[s.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:dV(n)}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>d("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")}),s.jsx("button",{onClick:()=>d("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")})]})]}),s.jsxs("div",{className:"relative",children:[c==="rendered"?s.jsx("pre",{ref:r,className:"p-3 overflow-x-auto text-xs [&>code]:p-0 [&>code]:rounded-none [&>code]:text-fg-secondary",children:k.Children.map(e,h=>k.isValidElement(h)?k.cloneElement(h,{style:{background:"transparent",padding:0}}):h)}):s.jsx("pre",{className:"p-3 overflow-x-auto text-xs font-mono text-fg-secondary whitespace-pre-wrap break-words",children:ac(e)}),s.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:o?s.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.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 u3=/^(?:\/|~\/|[A-Za-z]:[\\/]|\\\\)/,d3=/^\.{1,2}\//,gV=/\.[a-zA-Z0-9]{1,12}(?:$|[?#])/,m3=/^[A-Za-z]:[\\/]/,f3=/^\\\\[^\\]/;function p3(e){const t=e.trim();return t?!!(/^file:/i.test(t)||m3.test(t)||f3.test(t)||t.startsWith("~/")||t.startsWith("/")||d3.test(t)):!1}function Pg(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=t.replace(/\\+/g,"/"),t}function bV(e){return e.replace(/(!?\[[^\]]*]\()((?:[A-Za-z]:|\\\\)[^)\n]*)(\))/g,(t,n,r,o)=>`${n}${r.replace(/\\+/g,"/")}${o}`)}function h3(e){return e.trim().toLowerCase().replace(/[^\p{L}\p{N}\p{M}\s\-_]/gu,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function bd(e,t){if(!e)return e;if(u3.test(e))return e.startsWith("~/")?e:e.replace(/\\/g,"/");if(!t)return e;const r=`${t.replace(/\\/g,"/").replace(/\/+$/,"")}/${e.replace(/^\.\//,"")}`,o=r.split("/"),l=[];for(const d of o)!d||d==="."||(d===".."?l.pop():l.push(d));const c=l.join("/");return r.startsWith("/")?`/${c}`.replace(/^\/+/,"/"):c}function W2(e){const t=e.indexOf("#");return t<0?{path:e}:{path:e.slice(0,t),fragment:decodeURIComponent(e.slice(t+1))}}function Y2(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(m3.test(n)||f3.test(n)){const{path:l,fragment:c}=W2(n);return{kind:"file",path:bd(l,t),fragment:c}}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:Pg(n)}:{kind:"passthrough"};const{path:r,fragment:o}=W2(n);return u3.test(r)?{kind:"file",path:bd(r,t),fragment:o}:d3.test(r)?{kind:"file",path:bd(r,t),fragment:o}:r&&gV.test(r)&&!r.includes("://")?{kind:"file",path:bd(r,t),fragment:o}:{kind:"passthrough"}}function xV(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 r=e.querySelectorAll("h1,h2,h3,h4,h5,h6");for(const o of r)if(h3(o.textContent||"")===t||o.id===t){n=o;break}}return n?(n.scrollIntoView({behavior:"smooth",block:"start"}),!0):!1}function g3(e){return e.type==="text"?e.value??"":(e.children??[]).map(g3).join("")}function yV(){return e=>{const t=new Map,n=r=>{if(r.type==="element"&&r.tagName&&/^h[1-6]$/.test(r.tagName)){const o=g3(r).trim();let l=h3(o);if(l){const c=t.get(l)??0;t.set(l,c+1),c>0&&(l=`${l}-${c}`),r.properties={...r.properties??{},id:l}}}for(const o of r.children??[])n(o)};n(e)}}const b3="markus-copy-typography",X2={fontFamily:"default",fontSize:15,headingScale:"standard"};function x3(){try{const e=localStorage.getItem(b3);if(e)return{...X2,...JSON.parse(e)}}catch{}return X2}function vV(e){localStorage.setItem(b3,JSON.stringify(e))}function wV(e){const t={default:"-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif",serif:"Georgia, 'Times New Roman', Times, serif","sans-serif":"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif",mono:"'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace"},n={compact:{h1:1.3,h2:1.15,h3:1.05,h4:1},standard:{h1:1.6,h2:1.35,h3:1.15,h4:1},large:{h1:2,h2:1.6,h3:1.3,h4:1.1}};return{fontFamily:t[e.fontFamily]??t.default,fontSize:`${e.fontSize}px`,headingScales:n[e.headingScale]??n.standard}}function kV({onClose:e}){const{t}=dt("common"),[n,r]=k.useState(x3);k.useEffect(()=>{vV(n)},[n]);const o=k.useCallback((l,c)=>{r(d=>({...d,[l]:c}))},[]);return s.jsxs("div",{className:"px-3 py-2 space-y-3 max-w-[260px]",children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsx("span",{className:"font-medium text-fg-primary text-xs",children:t("markdown.typographySettings")}),s.jsx("button",{onClick:e,className:"text-fg-tertiary hover:text-fg-primary p-0.5",children:s.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),s.jsx("p",{className:"text-[10px] text-fg-tertiary",children:t("markdown.typographyDesc")}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:t("markdown.fontFamily")}),s.jsxs("select",{value:n.fontFamily,onChange:l=>o("fontFamily",l.target.value),className:"w-full px-2 py-1 text-xs rounded bg-surface-primary border border-border-subtle text-fg-secondary focus:outline-none focus:ring-1 focus:ring-brand-500/50",children:[s.jsx("option",{value:"default",children:t("markdown.fontDefault")}),s.jsx("option",{value:"serif",children:t("markdown.fontSerif")}),s.jsx("option",{value:"sans-serif",children:t("markdown.fontSansSerif")}),s.jsx("option",{value:"mono",children:t("markdown.fontMono")})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:[t("markdown.fontSize"),": ",n.fontSize,"px"]}),s.jsx("input",{type:"range",min:10,max:24,step:1,value:n.fontSize,onChange:l=>o("fontSize",Number(l.target.value)),className:"w-full h-1 rounded-full appearance-none bg-border-subtle [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-brand-500"}),s.jsxs("div",{className:"flex justify-between text-[9px] text-fg-tertiary mt-0.5",children:[s.jsx("span",{children:"10px"}),s.jsx("span",{children:"24px"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:t("markdown.headingScale")}),s.jsx("div",{className:"flex gap-1",children:["compact","standard","large"].map(l=>s.jsx("button",{onClick:()=>o("headingScale",l),className:`flex-1 px-2 py-1 rounded text-[10px] font-medium transition-colors ${n.headingScale===l?"bg-brand-600/20 text-brand-500":"bg-surface-primary text-fg-tertiary hover:text-fg-secondary border border-border-subtle"}`,children:t(`markdown.scale${l.charAt(0).toUpperCase()+l.slice(1)}`)},l))})]})]})}const SV=k.lazy(()=>qr(()=>Promise.resolve().then(()=>T3),void 0).then(e=>({default:e.MarkdownMessage}))),NV={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},Q2={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 CV({item:e,onClose:t,onOpenInPage:n}){const{t:r}=dt(["agent","common"]),o=NV[e.type]??{icon:"📎",color:"bg-surface-elevated text-fg-secondary"},l=Q2[e.status]??Q2.active,c=/^https?:\/\//i.test(e.reference??"");k.useEffect(()=>{const m=p=>{p.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]);const d=s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:t,children:[s.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),s.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:[s.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:[s.jsx("span",{className:`inline-flex items-center justify-center w-10 h-10 rounded-xl text-lg shrink-0 ${o.color}`,children:o.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:e.title}),s.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[s.jsx("span",{className:`px-1.5 py-0.5 text-[10px] rounded font-medium ${l.color}`,children:e.status}),s.jsx("span",{className:"text-[10px] text-fg-tertiary",children:e.type}),e.format&&s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-elevated rounded text-fg-secondary",children:e.format})]})]}),s.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:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),s.jsxs("div",{className:"px-5 py-4 space-y-4",children:[e.summary&&e.summary.trim()!==e.title.trim()&&s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:r("agent:deliverables.summary")}),s.jsx("div",{className:"mt-1.5",children:s.jsx(k.Suspense,{fallback:s.jsx("p",{className:"text-sm text-fg-secondary",children:e.summary}),children:s.jsx(SV,{content:e.summary,className:"text-sm text-fg-secondary"})})})]}),e.reference&&s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:r("agent:deliverables.reference")}),s.jsxs("div",{className:"mt-1.5 flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[s.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all flex-1 select-all",children:e.reference}),c?s.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:r("common:open")}):s.jsx("button",{onClick:()=>{Ce.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:r("common:open")})]})]}),e.diffStats&&s.jsxs("div",{className:"flex items-center gap-3 text-xs bg-surface-elevated rounded-lg px-3 py-2",children:[s.jsx("span",{className:"text-fg-tertiary font-medium",children:"Diff:"}),s.jsxs("span",{className:"text-fg-secondary",children:[e.diffStats.filesChanged," file",e.diffStats.filesChanged!==1?"s":""]}),s.jsxs("span",{className:"text-green-500",children:["+",e.diffStats.additions]}),s.jsxs("span",{className:"text-red-500",children:["-",e.diffStats.deletions]})]}),e.testResults&&s.jsxs("div",{className:"flex items-center gap-3 text-xs bg-surface-elevated rounded-lg px-3 py-2",children:[s.jsx("span",{className:"text-fg-tertiary font-medium",children:"Tests:"}),s.jsxs("span",{className:"text-green-500",children:[e.testResults.passed," passed"]}),e.testResults.failed>0&&s.jsxs("span",{className:"text-red-500",children:[e.testResults.failed," failed"]}),e.testResults.skipped>0&&s.jsxs("span",{className:"text-fg-tertiary",children:[e.testResults.skipped," skipped"]})]}),e.tags.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.tags.map(m=>s.jsx("span",{className:"px-2 py-0.5 text-[11px] bg-surface-elevated rounded-md text-fg-tertiary",children:m},m))}),s.jsxs("div",{className:"flex items-center gap-4 text-[10px] text-fg-tertiary flex-wrap pt-1 border-t border-border-default/50",children:[s.jsxs("span",{children:[r("agent:deliverables.created"),": ",new Date(e.createdAt).toLocaleString()]}),s.jsxs("span",{children:[r("agent:deliverables.updated"),": ",new Date(e.updatedAt).toLocaleString()]}),e.accessCount>0&&s.jsx("span",{children:r("agent:deliverables.accessed",{count:e.accessCount})})]})]}),s.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:[s.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:[s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),r("agent:deliverables.openInPage")]}),s.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:r("common:close")})]})]})]});return typeof document<"u"?Sa.createPortal(d,document.body):d}const TV={tsk:"task",req:"requirement",proj:"project",dlv:"deliverable",agt:"agent",team:"team"};function y3(e){return{task:"task",requirement:"requirement",project:"project",deliverable:"deliverable",agent:"agent",team:"team"}[e]}const v3={task:"📋",requirement:"📝",project:"📁",deliverable:"📦",agent:"🤖",team:"👥"},w3={task:"Task",requirement:"Requirement",project:"Project",deliverable:"Deliverable",agent:"Agent",team:"Team"},AV=/^(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}$/i;function d0(e){return AV.test(e.trim())}function EV(e){const t=e.split("_")[0]?.toLowerCase();return t?TV[t]:void 0}function k3(e){e.startsWith("tsk_")?at.navigate(me.WORK,{openTask:e}):e.startsWith("req_")?at.navigate(me.WORK,{openRequirement:e}):e.startsWith("proj_")?at.navigate(me.WORK,{projectId:e}):e.startsWith("dlv_")?at.navigate(me.DELIVERABLES,{openDeliverable:e}):e.startsWith("agt_")?at.navigate(me.TEAM,{agentId:e}):e.startsWith("team_")&&at.navigate(me.TEAM,{selectTeam:e})}const Vp=new Map,xd=new Map;async function _V(e,t){const n={id:e,type:t,title:e,loading:!1};try{switch(t){case"task":{const r=await Ce.tasks.get(e);return{...n,title:r.task.title,status:r.task.status}}case"requirement":{const r=await Ce.requirements.get(e);return{...n,title:r.requirement.title,status:r.requirement.status}}case"project":{const r=await Ce.projects.get(e);return{...n,title:r.project.name,status:r.project.status,summary:r.project.description}}case"deliverable":{const r=await Ce.deliverables.get(e);return{...n,title:r.deliverable.title,status:r.deliverable.status,summary:r.deliverable.summary,deliverable:r.deliverable}}case"agent":{const r=await Ce.agents.get(e);return{...n,title:r.name,summary:r.role}}case"team":{const o=(await Ce.teams.list()).teams.find(l=>l.id===e);return{...n,title:o?.name??e,notFound:!o}}}}catch{}return{...n,notFound:!0}}function S3(e,t){const n=t??EV(e),[r,o]=k.useState(()=>Vp.get(e)??{id:e,type:n??"task",title:e,loading:!!n});return k.useEffect(()=>{if(!n){o({id:e,type:"task",title:e,loading:!1,notFound:!0});return}const l=Vp.get(e);if(l){o(l);return}o(m=>({...m,type:n,loading:!0}));let c=!0,d=xd.get(e);return d||(d=_V(e,n),xd.set(e,d)),d.then(m=>{Vp.set(e,m),xd.delete(e),c&&o(m)}).catch(()=>{xd.delete(e),c&&o({id:e,type:n,title:e,loading:!1,notFound:!0})}),()=>{c=!1}},[e,n]),r}function N3(e){const t=(e.split("_")[0]?.length??3)+1;return e.length>t+8?`${e.slice(0,t+8)}…`:e}function sc({id:e,type:t,label:n}){const r=S3(e,t),o=Ec(),l=v3[r.type]??"🔗",c=n??(r.loading||r.notFound?N3(e):r.title),d=m=>{if(m.preventDefault(),m.stopPropagation(),r.type==="deliverable"&&r.deliverable&&o?.hostAvailable){o.openRightPanel({kind:"deliverable",deliverable:r.deliverable});return}k3(e)};return s.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:d,title:`${w3[r.type]}: ${r.notFound?e:r.title} (${e})`,children:[s.jsx("span",{className:"text-[10px]",children:l}),s.jsx("span",{className:"truncate max-w-[240px] align-baseline",children:c})]})}function jV({id:e,type:t,label:n}){const r=S3(e,t),[o,l]=k.useState(!1),c=Ec(),d=v3[r.type]??"🔗",m=()=>{if(r.type==="deliverable"&&r.deliverable){if(c?.hostAvailable){c.openRightPanel({kind:"deliverable",deliverable:r.deliverable});return}l(!0);return}k3(e)},p=r.loading?N3(e):n||(r.notFound?e:r.title);return s.jsxs("span",{className:"not-prose block my-2",children:[s.jsxs("button",{type:"button",onClick:m,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:[s.jsx("span",{className:"inline-flex items-center justify-center w-8 h-8 rounded-lg text-sm shrink-0 bg-brand-500/10",children:d}),s.jsxs("span",{className:"flex-1 min-w-0 block",children:[s.jsxs("span",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wide text-fg-tertiary font-medium",children:w3[r.type]}),r.status&&s.jsx("span",{className:"px-1.5 py-0.5 text-[10px] rounded font-medium bg-brand-500/10 text-brand-500",children:r.status})]}),s.jsx("span",{className:`block text-sm font-medium truncate mt-0.5 ${r.notFound?"font-mono text-fg-tertiary":"text-fg-primary"}`,children:p}),r.summary&&r.summary.trim()!==r.title.trim()&&s.jsx("span",{className:"block text-xs text-fg-tertiary mt-0.5 line-clamp-1",children:r.summary})]}),s.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:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),o&&r.deliverable&&s.jsx(CV,{item:r.deliverable,onClose:()=>l(!1),onOpenInPage:h=>{l(!1),at.navigate(me.DELIVERABLES,{openDeliverable:h})}})]})}class MV extends k.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t){this.state.error&&this.props.resetKeys&&!RV(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 RV(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 OV=/^(deliverable|task|requirement|project|agent|team|workflow):/i;function Z2(e){return OV.test(e)||p3(e)?e:sw(e)}const J2=[Mw,hF,Ok],e4=[yV,[WF,{strict:"ignore"}],[s3,{detect:!0,ignoreMissing:!0}]],$h="text-brand-500 hover:text-brand-500 underline break-all cursor-pointer",DV=/<think>([\s\S]*?)(<\/think>|$)/g;function LV(e){const t=[];let n=e.replace(DV,(r,o)=>{const l=o.trim();return l&&t.push(l),""});return n=n.replace(/<\/think>/g,"").replace(/<think>/g,""),{thinking:t,rest:n.trim()}}const t4="#mention:",m0="#entity:",IV=/^\[([^\]]+)\]\(#entity:((tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)$/i,C3=/^(workflow|task|requirement|project|deliverable|agent|team):(.+)$/;function Hh(e){return e.type==="text"?e.value??"":(e.children??[]).map(Hh).join("")}function PV(e){return e.type==="text"&&(e.value??"").trim()===""}function zV(e){if(!e?.children)return null;const t=e.children.filter(r=>!PV(r));if(t.length!==1)return null;const n=t[0];if(n.type==="element"&&n.tagName==="a"){const r=n.properties?.href;if(!r)return null;const o=Hh(n);if(r.startsWith(m0))return{id:r.slice(m0.length)};const l=r.match(C3);return l&&l[1]!=="workflow"?{id:l[2],type:y3(l[1]),label:o}:null}if(n.type==="element"&&n.tagName==="code"){const r=Hh(n).trim();if(d0(r))return{id:r}}if(n.type==="text"){const r=(n.value??"").trim();if(d0(r))return{id:r}}return null}const BV={p:({children:e})=>s.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:e}),h1:({children:e})=>s.jsx("h1",{className:"text-base font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h2:({children:e})=>s.jsx("h2",{className:"text-sm font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h3:({children:e})=>s.jsx("h3",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h4:({children:e})=>s.jsx("h4",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h5:({children:e})=>s.jsx("h5",{className:"text-xs font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h6:({children:e})=>s.jsx("h6",{className:"text-xs font-medium mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),ul:({children:e})=>s.jsx("ul",{className:"list-disc pl-4 mb-2 space-y-0.5",children:e}),ol:({children:e,start:t})=>s.jsx("ol",{start:t,className:"list-decimal pl-7 mb-2 space-y-0.5",children:e}),li:({children:e,value:t})=>s.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??""),r=n.trim();if(t?.includes("language-plantuml")||oV(r))return s.jsx(Uh,{code:r,language:"plantuml",children:s.jsx(l3,{code:r})});if(t?.includes("language-mermaid")||!t&&cV(r))return s.jsx(Uh,{code:r,language:"mermaid",children:s.jsx(o3,{code:r})});if(t?.includes("language-"))return s.jsx("code",{className:`${t} text-fg-secondary font-mono text-xs`,children:e});if(d0(n))return s.jsx(sc,{id:n.trim()});const o=n.match(IV);return o?s.jsx(sc,{id:o[2],label:o[1]}):PG(n)?s.jsx(BG,{path:n}):s.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})=>s.jsx(hV,{children:e}),strong:({children:e})=>s.jsx("strong",{className:"font-bold text-fg-primary",children:e}),em:({children:e})=>s.jsx("em",{className:"italic text-fg-secondary",children:e}),del:({children:e})=>s.jsx("del",{className:"line-through text-fg-tertiary",children:e}),blockquote:({children:e})=>s.jsx("blockquote",{className:"border-l-2 border-brand-500 pl-3 my-2 text-fg-secondary italic",children:e}),a:({href:e,children:t})=>s.jsx("a",{href:e,className:$h,children:t}),hr:()=>s.jsx("hr",{className:"border-border-default my-3"}),table:({children:e})=>s.jsx("div",{className:"overflow-x-auto my-2",children:s.jsx("table",{className:"min-w-full text-sm border-collapse border border-border-default",children:e})}),thead:({children:e})=>s.jsx("thead",{className:"bg-surface-secondary",children:e}),tbody:({children:e})=>s.jsx("tbody",{className:"divide-y divide-border-default",children:e}),tr:({children:e})=>s.jsx("tr",{className:"hover:bg-surface-elevated/50 transition-colors",children:e}),th:({children:e})=>s.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})=>s.jsx("td",{className:"px-3 py-2 text-sm text-fg-primary border border-border-default",children:e})},UV=/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i;function $V(e){const t=Pg(e);return p3(e)&&UV.test(t.split("?")[0]??t)}function HV(e,t){const n=Pg(e);if(n.startsWith("/")||n.startsWith("~/")||/^[A-Za-z]:\//.test(n)||n.startsWith("//"))return n;if((n.startsWith("./")||n.startsWith("../"))&&t){const o=((t.replace(/\\/g,"/").endsWith("/")?t.replace(/\\/g,"/"):`${t.replace(/\\/g,"/")}/`)+n).split("/"),l=[];for(const c of o)c===".."?l.pop():c!=="."&&c!==""&&l.push(c);return"/"+l.join("/")}return n}function FV(e){return`/api/files/image?path=${encodeURIComponent(e)}`}const ko=new Map;function qV({src:e,alt:t,onPreview:n,basePath:r}){const o=k.useMemo(()=>$V(e)?FV(HV(e,r)):e,[e,r]),l=o.startsWith("/api/files/image?"),c=ko.get(o),[d,m]=k.useState(c??(l?null:o)),[p,h]=k.useState(!!c),[g,x]=k.useState(!1),[y,w]=k.useState(null),[C,T]=k.useState(0),S=k.useRef(0),_=k.useCallback(()=>{ko.delete(o),x(!1),w(null),h(!1),m(l?null:`${o}${o.includes("?")?"&":"?"}retry=${Date.now()}`),T(j=>j+1)},[o,l]);return k.useEffect(()=>{if(!l)return;const j=ko.get(o);if(j){m(j),h(!0),x(!1),w(null);return}const O=++S.current;x(!1),w(null),h(!1),m(null),(async()=>{try{const P=await fetch(o,{credentials:"same-origin"});if(O!==S.current)return;if(!P.ok){let X=`HTTP ${P.status}`;try{const ee=await P.json();ee.error&&(X=ee.error)}catch{}throw new Error(X)}const D=await P.blob();if(O!==S.current)return;if(D.size===0)throw new Error("Empty image response");if(D.type&&!D.type.startsWith("image/")&&!D.type.includes("octet-stream"))throw new Error(`Unexpected content-type: ${D.type}`);const $=URL.createObjectURL(D);ko.set(o,$),m($),h(!0),x(!1),w(null)}catch(P){if(O!==S.current)return;const D=P instanceof Error?P.message:String(P);console.warn("[MarkdownImage] failed to load local image",o,P),w(D),x(!0),h(!1)}})()},[l,o,C]),k.useEffect(()=>{l||(m(o),h(!!ko.get(o)),x(!1),w(null))},[o,l,C]),g?s.jsxs("button",{type:"button",onClick:_,title:y??"Click to retry",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:[s.jsxs("svg",{className:"w-4 h-4 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),s.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),s.jsx("polyline",{points:"21 15 16 10 5 21"})]}),s.jsxs("span",{className:"truncate",children:["Failed to load image — click to retry",y?` (${y})`:""]})]}):s.jsxs("span",{className:"inline-block align-middle max-w-full",children:[!p&&s.jsx("span",{className:"block w-full min-h-[80px] max-w-[400px] bg-surface-elevated rounded-lg animate-pulse"}),d?s.jsx("img",{src:d,alt:t??"",onLoad:()=>{l||ko.set(o,o),h(!0)},onError:()=>{w("Image decode failed"),x(!0)},onClick:()=>n?.(d),className:`max-w-full h-auto rounded-lg cursor-pointer hover:opacity-90 transition-opacity my-1${p?"":" absolute opacity-0 pointer-events-none"}`,style:{maxHeight:"400px",objectFit:"contain"}}):null]})}async function n4(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch image (${t.status})`);return t.blob()}async function GV(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 r=n.getContext("2d");if(!r)throw new Error("Canvas unavailable");return r.drawImage(t,0,0),t.close(),new Promise((o,l)=>{n.toBlob(c=>c?o(c):l(new Error("PNG encode failed")),"image/png")})}function VV(e,t){try{const o=(e.startsWith("data:")?"":new URL(e,window.location.href).pathname).split("/").pop()||"";if(o&&/\.(png|jpe?g|gif|webp|svg|bmp)$/i.test(o))return decodeURIComponent(o)}catch{}return`image.${(t.type.split("/")[1]||"png").replace("jpeg","jpg")}`}function KV({src:e,onClose:t}){const{t:n}=dt("common"),[r,o]=k.useState(null),[l,c]=k.useState(null);zo(!0),k.useEffect(()=>{const g=x=>{x.key==="Escape"&&t()};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[t]);const d=k.useCallback(g=>{o(g),window.setTimeout(()=>o(null),1600)},[]),m=k.useCallback(async g=>{if(g.stopPropagation(),!l){c("copy");try{const x=await n4(e),y=await GV(x);await navigator.clipboard.write([new ClipboardItem({"image/png":y})]),d(n("imageCopied"))}catch{d(n("imageCopyFailed"))}finally{c(null)}}},[l,d,e,n]),p=k.useCallback(async g=>{if(g.stopPropagation(),!l){c("download");try{const x=await n4(e),y=URL.createObjectURL(x),w=document.createElement("a");w.href=y,w.download=VV(e,x),document.body.appendChild(w),w.click(),w.remove(),URL.revokeObjectURL(y),d(n("imageDownloaded"))}catch{d(n("imageDownloadFailed"))}finally{c(null)}}},[l,d,e,n]),h="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 Sa.createPortal(s.jsxs("div",{className:"fixed inset-0 z-[9999] bg-black/80 flex items-center justify-center p-4",onClick:t,children:[s.jsxs("div",{className:"absolute top-4 right-4 z-10 flex items-center gap-2",onClick:g=>g.stopPropagation(),children:[s.jsxs("button",{type:"button",className:h,onClick:m,disabled:!!l,title:n("copyImage"),children:[s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),s.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),n("copy")]}),s.jsxs("button",{type:"button",className:h,onClick:p,disabled:!!l,title:n("downloadImage"),children:[s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"}),s.jsx("polyline",{points:"7 10 12 15 17 10"}),s.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),n("downloadImage")]}),s.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:s.jsxs("svg",{className:"w-6 h-6 text-white",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),r&&s.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:r}),s.jsx("img",{src:e,alt:"Preview",className:"max-w-full max-h-[90vh] object-contain rounded-lg",onClick:g=>g.stopPropagation()})]}),document.body)}function WV(e=640){const[t,n]=k.useState(()=>window.innerWidth<e);return k.useEffect(()=>{const r=window.matchMedia(`(max-width: ${e-1}px)`),o=l=>n(l.matches);return r.addEventListener("change",o),n(r.matches),()=>r.removeEventListener("change",o)},[e]),t}function YV({content:e,contentRef:t}){const{t:n}=dt("common"),[r,o]=k.useState(!1),[l,c]=k.useState(!1),[d,m]=k.useState(!1),[p,h]=k.useState(null),g=k.useRef(null),x=WV();k.useEffect(()=>{if(!r)return;const T=S=>{g.current&&!g.current.contains(S.target)&&(o(!1),c(!1),m(!1))};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[r]);const y=k.useCallback(T=>{h(T),setTimeout(()=>h(null),1500)},[]),w=async()=>{const T=await Ig(e);y(n(T?"markdown.copied":"markdown.failed")),o(!1)},C=async T=>{const S=t.current?.firstElementChild;if(!S)return;const _=x3(),j=wV(_),O=await JG(S,T,e,{fontFamily:j.fontFamily,fontSize:j.fontSize,headingScales:j.headingScales}),P=n(T==="light"?"markdown.themeLight":"markdown.themeDark");y(O.ok?O.method==="html"?n("markdown.htmlCopied",{theme:P}):n("markdown.textCopied"):n("markdown.failed")),o(!1)};return s.jsxs("div",{className:"absolute top-1 right-1 z-10 opacity-0 group-hover/md:opacity-100 transition-opacity",ref:g,children:[p&&s.jsx("div",{className:"absolute right-0 top-full mt-1 z-20 px-2 py-0.5 rounded bg-surface-elevated border border-border-default text-[10px] text-fg-secondary whitespace-nowrap shadow-lg",children:p}),s.jsx("button",{onClick:()=>o(T=>!T),className:"p-1.5 rounded-lg bg-surface-elevated/80 hover:bg-surface-overlay text-fg-secondary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all",title:n("markdown.copyContent"),children:s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.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"})})}),r&&s.jsx("div",{className:"absolute right-0 top-full mt-1 bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 min-w-[180px]",children:d?s.jsx(kV,{onClose:()=>m(!1)}):l?s.jsxs("div",{className:"px-3 py-2 text-[11px] text-fg-secondary space-y-2 max-w-[260px]",children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsx("span",{className:"font-medium text-fg-primary text-xs",children:n("markdown.infoTitle")}),s.jsx("button",{onClick:()=>c(!1),className:"text-fg-tertiary hover:text-fg-primary p-0.5",children:s.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-fg-primary",children:n("markdown.mdAbbrev")})," — ",n("markdown.infoMdDesc")]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-fg-primary",children:"☀️"})," — ",n("markdown.infoHtmlLightDesc")]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-fg-primary",children:"🌙"})," — ",n("markdown.infoHtmlDarkDesc")]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-1 border-b border-border-subtle mb-1",children:[s.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium",children:n("markdown.copyContent")}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>m(!0),className:"p-0.5 rounded text-fg-tertiary hover:text-fg-primary transition-colors",title:n("markdown.typographySettings"),children:s.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),s.jsx("button",{onClick:()=>c(!0),className:"p-0.5 rounded text-fg-tertiary hover:text-fg-primary transition-colors",title:n("markdown.infoTitle"),children:s.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{strokeLinecap:"round",d:"M12 16v-4m0-4h.01"})]})})]})]}),s.jsxs("button",{onClick:w,className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[s.jsx("span",{className:"w-4 text-center text-fg-tertiary shrink-0 font-mono text-[10px]",children:n("markdown.mdAbbrev")}),n(x?"markdown.copyMdSourceShort":"markdown.copyMdSource")]}),s.jsxs("button",{onClick:()=>C("light"),className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[s.jsx("span",{className:"w-4 text-center shrink-0 text-[10px]",children:"☀️"}),n(x?"markdown.copyHtmlLightShort":"markdown.copyHtmlLight")]}),s.jsxs("button",{onClick:()=>C("dark"),className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[s.jsx("span",{className:"w-4 text-center shrink-0 text-[10px]",children:"🌙"}),n(x?"markdown.copyHtmlDarkShort":"markdown.copyHtmlDark")]})]})})]})}const Er=k.memo(function({content:t,className:n="",onMentionClick:r,knownNames:o,basePath:l}){const{thinking:c,rest:d}=LV(t),m=k.useRef(null),[p,h]=k.useState(null),g=Ec(),x=k.useCallback(T=>{let S=Yl(T,eV);return S=Yl(S,bV),S=Yl(S,sV),S=Yl(S,iV),S=Yl(S,_=>tV(_,o)),S},[o]),y=k.useMemo(()=>x(d),[d,x]),w=k.useCallback((T,S)=>{const _=Y2(S,l);if(_.kind!=="passthrough"){if(T.preventDefault(),T.stopPropagation(),_.kind==="fragment"){xV(m.current,_.id);return}if(_.kind==="file"){g?.hostAvailable?g.openRightPanel({kind:"file",path:_.path,title:_.path.split(/[/\\]/).pop()}):Ce.files.reveal(_.path).catch(()=>{});return}if(_.kind==="external"){if(g?.hostAvailable&&/^https?:\/\//i.test(_.url)){g.openRightPanel({kind:"url",url:_.url,title:_.url});return}Ai(_.url)}}},[l,g]),C=k.useMemo(()=>({...BV,img:({src:T,alt:S})=>s.jsx(qV,{src:T??"",alt:S,onPreview:h,basePath:l},T??""),p:({children:T,node:S})=>{const _=zV(S);return _?s.jsx(jV,{id:_.id,type:_.type,label:_.label}):s.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:T})},a:({href:T,children:S})=>{if(T?.startsWith(t4)){const j=decodeURIComponent(T.slice(t4.length));return s.jsx("span",{className:`text-brand-500 font-medium${r?" cursor-pointer hover:underline":""}`,onClick:r?O=>{O.preventDefault(),O.stopPropagation(),r(j,O)}:void 0,title:j,children:S})}if(T?.startsWith(m0))return s.jsx(sc,{id:T.slice(m0.length)});{const j=T?.match(C3);if(j){const[,O,P]=j;if(O==="workflow")return s.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:$=>{$.preventDefault(),$.stopPropagation(),at.navigate(me.WORK,{boardType:"workflows"})},title:`workflow: ${P}`,children:[s.jsx("span",{className:"text-[10px]",children:"⚙️"}),s.jsx("span",{children:S})]});const D=y3(O);if(D)return s.jsx(sc,{id:P,type:D,label:S})}}if(T&&d0(T))return s.jsx(sc,{id:T.trim(),label:S});const _=Y2(T,l);return _.kind==="fragment"||_.kind==="file"||_.kind==="external"?s.jsx("a",{href:T,className:$h,onClick:j=>w(j,T),title:_.kind==="fragment"?`#${_.id}`:_.kind==="file"?_.path:_.url,children:S}):s.jsx("a",{href:T,className:$h,onClick:j=>{pc()&&T&&!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(T)&&j.preventDefault()},children:S})}}),[r,l,w]);return s.jsxs("div",{className:"relative group/md",children:[s.jsx(YV,{content:t,contentRef:m}),s.jsx("div",{ref:m,children:s.jsx(MV,{resetKeys:[y],fallback:s.jsx("div",{className:`prose prose-sm max-w-none break-words whitespace-pre-wrap pr-8 text-fg-secondary ${n}`,children:d}),children:s.jsxs("div",{className:`prose prose-sm max-w-none break-words pr-8 text-fg-secondary ${n}`,children:[c.length>0&&(()=>{const T=c.join(`
|
|
648
|
+
`,1;if(Zo>1e5&&Zo>pt.index*3)throw new Error("potential infinite loop, way more iterations than matches");return an+=Lt,Lt.length}const Yn=ir(ze);if(!Yn)throw et(vt.replace("{}",ze)),new Error('Unknown language: "'+ze+'"');const Dc=nt(Yn);let Bi="",Tt=rn||Dc;const Lc={},In=new tt.__emitter(tt);Qo();let an="",ls=0,Ma=0,Zo=0,cs=!1;try{if(Yn.__emitTokens)Yn.__emitTokens(wt,In);else{for(Tt.matcher.considerAll();;){Zo++,cs?cs=!1:Tt.matcher.considerAll(),Tt.matcher.lastIndex=Ma;const Ze=Tt.matcher.exec(wt);if(!Ze)break;const pt=wt.substring(Ma,Ze.index),Lt=zi(pt,Ze);Ma=Ze.index+Lt}zi(wt.substring(Ma))}return In.finalize(),Bi=In.toHTML(),{language:ze,value:Bi,relevance:ls,illegal:!1,_emitter:In,_top:Tt}}catch(Ze){if(Ze.message&&Ze.message.includes("Illegal"))return{language:ze,value:R(wt),illegal:!0,relevance:0,_illegalBy:{message:Ze.message,index:Ma,context:wt.slice(Ma-100,Ma+100),mode:Ze.mode,resultSoFar:Bi},_emitter:In};if(Je)return{language:ze,value:R(wt),illegal:!1,relevance:0,errorRaised:Ze,_emitter:In,_top:Tt};throw Ze}}function Oi(ze){const wt={value:R(ze),illegal:!1,relevance:0,_top:Ie,_emitter:new tt.__emitter(tt)};return wt._emitter.addText(ze),wt}function Di(ze,wt){wt=wt||tt.languages||Object.keys(ie);const Ut=Oi(ze),rn=wt.filter(ir).filter(is).map(hn=>Ea(hn,ze,!1));rn.unshift(Ut);const Rn=rn.sort((hn,Rr)=>{if(hn.relevance!==Rr.relevance)return Rr.relevance-hn.relevance;if(hn.language&&Rr.language){if(ir(hn.language).supersetOf===Rr.language)return 1;if(ir(Rr.language).supersetOf===hn.language)return-1}return 0}),[tr,Mr]=Rn,gr=tr;return gr.secondBest=Mr,gr}function ma(ze,wt,Ut){const rn=wt&&Ne[wt]||Ut;ze.classList.add("hljs"),ze.classList.add(`language-${rn}`)}function Mn(ze){let wt=null;const Ut=jn(ze);if(St(Ut))return;if(Ws("before:highlightElement",{el:ze,language:Ut}),ze.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",ze);return}if(ze.children.length>0&&(tt.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(ze)),tt.throwUnescapedHTML))throw new Xt("One of your code blocks includes unescaped HTML.",ze.innerHTML);wt=ze;const rn=wt.textContent,Rn=Ut?vn(rn,{language:Ut,ignoreIllegals:!0}):Di(rn);ze.innerHTML=Rn.value,ze.dataset.highlighted="yes",ma(ze,Ut,Rn.language),ze.result={language:Rn.language,re:Rn.relevance,relevance:Rn.relevance},Rn.secondBest&&(ze.secondBest={language:Rn.secondBest.language,relevance:Rn.secondBest.relevance}),Ws("after:highlightElement",{el:ze,result:Rn,text:rn})}function er(ze){tt=oe(tt,ze)}const ss=()=>{Li(),he("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Wo(){Li(),he("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let jc=!1;function Li(){function ze(){Li()}if(document.readyState==="loading"){jc||window.addEventListener("DOMContentLoaded",ze,!1),jc=!0;return}document.querySelectorAll(tt.cssSelector).forEach(Mn)}function Mc(ze,wt){let Ut=null;try{Ut=wt(G)}catch(rn){if(et("Language definition for '{}' could not be registered.".replace("{}",ze)),Je)et(rn);else throw rn;Ut=Ie}Ut.name||(Ut.name=ze),ie[ze]=Ut,Ut.rawDefinition=wt.bind(null,G),Ut.aliases&&_a(Ut.aliases,{languageName:ze})}function Ks(ze){delete ie[ze];for(const wt of Object.keys(Ne))Ne[wt]===ze&&delete Ne[wt]}function Yo(){return Object.keys(ie)}function ir(ze){return ze=(ze||"").toLowerCase(),ie[ze]||ie[Ne[ze]]}function _a(ze,{languageName:wt}){typeof ze=="string"&&(ze=[ze]),ze.forEach(Ut=>{Ne[Ut.toLowerCase()]=wt})}function is(ze){const wt=ir(ze);return wt&&!wt.disableAutodetect}function os(ze){ze["before:highlightBlock"]&&!ze["before:highlightElement"]&&(ze["before:highlightElement"]=wt=>{ze["before:highlightBlock"](Object.assign({block:wt.el},wt))}),ze["after:highlightBlock"]&&!ze["after:highlightElement"]&&(ze["after:highlightElement"]=wt=>{ze["after:highlightBlock"](Object.assign({block:wt.el},wt))})}function Ln(ze){os(ze),Le.push(ze)}function Rc(ze){const wt=Le.indexOf(ze);wt!==-1&&Le.splice(wt,1)}function Ws(ze,wt){const Ut=ze;Le.forEach(function(rn){rn[Ut]&&rn[Ut](wt)})}function ja(ze){return he("10.7.0","highlightBlock will be removed entirely in v12.0"),he("10.7.0","Please use highlightElement now."),Mn(ze)}Object.assign(G,{highlight:vn,highlightAuto:Di,highlightAll:Li,highlightElement:Mn,highlightBlock:ja,configure:er,initHighlighting:ss,initHighlightingOnLoad:Wo,registerLanguage:Mc,unregisterLanguage:Ks,listLanguages:Yo,getLanguage:ir,registerAliases:_a,autoDetection:is,inherit:oe,addPlugin:Ln,removePlugin:Rc}),G.debugMode=function(){Je=!1},G.safeMode=function(){Je=!0},G.versionString=ct,G.regex={concat:C,lookahead:x,either:S,optional:w,anyNumberOfTimes:y};for(const ze in At)typeof At[ze]=="object"&&e(At[ze]);return Object.assign(G,At),G},Ve=Pe({});return Ve.newInstance=()=>Pe({}),Fp=Ve,Ve.HighlightJS=Ve,Ve.default=Ve,Fp}var bG=gG();const xG=wc(bG),$2={},yG="hljs-";function vG(e){const t=xG.newInstance();return e&&l(e),{highlight:n,highlightAuto:r,listLanguages:o,register:l,registerAlias:c,registered:d};function n(m,p,h){const g=h||$2,x=typeof g.prefix=="string"?g.prefix:yG;if(!t.getLanguage(m))throw new Error("Unknown language: `"+m+"` is not registered");t.configure({__emitter:wG,classPrefix:x});const y=t.highlight(p,{ignoreIllegals:!0,language:m});if(y.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:y.errorRaised});const w=y._emitter.root,C=w.data;return C.language=y.language,C.relevance=y.relevance,w}function r(m,p){const g=(p||$2).subset||o();let x=-1,y=0,w;for(;++x<g.length;){const C=g[x];if(!t.getLanguage(C))continue;const T=n(C,m,p);T.data&&T.data.relevance!==void 0&&T.data.relevance>y&&(y=T.data.relevance,w=T)}return w||{type:"root",children:[],data:{language:void 0,relevance:y}}}function o(){return t.listLanguages()}function l(m,p){if(typeof m=="string")t.registerLanguage(m,p);else{let h;for(h in m)Object.hasOwn(m,h)&&t.registerLanguage(h,m[h])}}function c(m,p){if(typeof m=="string")t.registerAliases(typeof p=="string"?p:[...p],{languageName:m});else{let h;for(h in m)if(Object.hasOwn(m,h)){const g=m[h];t.registerAliases(typeof g=="string"?g:[...g],{languageName:h})}}}function d(m){return!!t.getLanguage(m)}}class wG{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],r=n.children[n.children.length-1];r&&r.type==="text"?r.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const r=this.stack[this.stack.length-1],o=t.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:o}):r.children.push(...o)}openNode(t){const n=this,r=t.split(".").map(function(c,d){return d?c+"_".repeat(d):n.options.classPrefix+c}),o=this.stack[this.stack.length-1],l={type:"element",tagName:"span",properties:{className:r},children:[]};o.children.push(l),this.stack.push(l)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const kG={};function s3(e){const t=e||kG,n=t.aliases,r=t.detect||!1,o=t.languages||hG,l=t.plainText,c=t.prefix,d=t.subset;let m="hljs";const p=vG(o);if(n&&p.registerAlias(n),c){const h=c.indexOf("-");m=h===-1?c:c.slice(0,h)}return function(h,g){E0(h,"element",function(x,y,w){if(x.tagName!=="code"||!w||w.type!=="element"||w.tagName!=="pre")return;const C=SG(x);if(C===!1||!C&&!r||C&&l&&l.includes(C))return;Array.isArray(x.properties.className)||(x.properties.className=[]),x.properties.className.includes(m)||x.properties.className.unshift(m);const T=zk(x,{whitespace:"pre"});let S;try{S=C?p.highlight(C,T,{prefix:c}):p.highlightAuto(T,{prefix:c,subset:d})}catch(_){const j=_;if(C&&/Unknown language/.test(j.message)){g.message("Cannot highlight as `"+C+"`, it’s not registered",{ancestors:[w,x],cause:j,place:x.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw j}!C&&S.data&&S.data.language&&x.properties.className.push("language-"+S.data.language),S.children.length>0&&(x.children=S.children)})}}function SG(e){const t=e.properties.className;let n=-1;if(!Array.isArray(t))return;let r;for(;++n<t.length;){const o=String(t[n]);if(o==="no-highlight"||o==="nohighlight")return!1;!r&&o.slice(0,5)==="lang-"&&(r=o.slice(5)),!r&&o.slice(0,9)==="language-"&&(r=o.slice(9))}return r}const NG=10,Bh=new Map;function CG(e,t=3e3){Bh.set(e,Date.now()+t)}function TG(e){const t=Bh.get(e);return t==null?!1:Date.now()>t?(Bh.delete(e),!1):!0}function H2(e){if(e.kind==="file")return`file:${e.path}`;if(e.kind==="url")return`url:${e.browserId||e.url}`;const t=e.deliverable;return`deliverable:${t.id||`${t.reference||""}|${t.title||""}|${t.summary?.slice(0,48)||""}`||"unknown"}`}function AG(e){return e.kind==="deliverable"?e.deliverable.title||e.deliverable.reference||"Deliverable":e.kind==="url"?e.title||e.url:e.title||e.path.split(/[/\\]/).pop()||e.path}const i3=k.createContext(null);function EG({children:e}){const[t,n]=k.useState(()=>{try{return localStorage.getItem("markus_sidebar_c")==="1"}catch{return!1}}),[r,o]=k.useState([]),[l,c]=k.useState(null),[d,m]=k.useState(!1),[p,h]=k.useState(!1),g=k.useRef([]),x=k.useRef(null),y=k.useRef(null);y.current=l;const w=k.useCallback(W=>n(W),[]),C=k.useCallback(()=>n(W=>!W),[]),T=k.useCallback(W=>{const F=H2(W),Z=`tab_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;let U=null;o(Q=>{const ne=Q.find(q=>H2(q.payload)===F);if(ne)return U=ne.id,g.current=Q,Q;let B=[{id:Z,title:AG(W),payload:W},...Q];for(;B.length>NG;){let q=-1;for(let le=B.length-1;le>=0;le--)if(!B[le].pinned){q=le;break}if(q<0)break;B=B.filter((le,I)=>I!==q)}return U=Z,g.current=B,B}),U&&(c(U),x.current=U),n(!0)},[]),S=W=>{W?.kind==="url"&&W.browserId&&(CG(W.browserId),window.markusDesktop?.browser?.destroy(W.browserId))},_=k.useCallback(W=>{let F,Z,U=!1;const Q=y.current;o(ne=>{const ke=ne.findIndex(I=>I.id===W);if(ke<0)return ne;F=ne[ke]?.payload;const B=ne.filter(I=>I.id!==W);g.current=B,U=B.length===0;const le=(ne.some(I=>I.id===Q)?Q:ne[0]?.id??null)===W;return Z=void 0,(le||B.length===0)&&(Z=B[Math.min(ke,B.length-1)]?.id??null),B}),U&&m(!1),Z!==void 0&&(c(Z),x.current=Z),S(F)},[]),j=k.useCallback(()=>{let W=[];o(F=>(W=F.map(Z=>Z.payload),[])),c(null),m(!1),g.current=[],x.current=null;for(const F of W)S(F)},[]),O=k.useCallback(W=>{c(W),x.current=W},[]),P=k.useCallback((W,F)=>{o(Z=>{let U=!1;const Q=Z.map(ne=>{if(ne.payload.kind!=="url"||ne.payload.browserId!==W)return ne;const ke=F.url??ne.payload.url,B=F.title||ne.payload.title||ke,q=F.pageId??ne.payload.pageId;return ke===ne.payload.url&&B===(ne.payload.title||ne.title)&&q===ne.payload.pageId&&B===ne.title?ne:(U=!0,{...ne,title:B,payload:{...ne.payload,url:ke,title:B,...q!=null?{pageId:q}:{}}})});return U&&(g.current=Q),U?Q:Z})},[]),D=k.useCallback(()=>{o(W=>W.length===0?W:(g.current=W,y.current&&(x.current=y.current),[])),c(null),m(!1),window.markusDesktop?.browser?.hideAll?.()},[]),$=k.useCallback(()=>{const W=`tab_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,F=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;let Z,U=!1,Q=!1;o(ne=>{if(ne.length>0)return g.current=ne,y.current&&(x.current=y.current),Q=!0,Z=null,[];if(g.current.length>0){U=!0;const B=g.current;return Z=x.current&&B.some(le=>le.id===x.current)?x.current:B[0].id,B}U=!0;const ke={id:W,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:F}};return g.current=[ke],Z=ke.id,[ke]}),U&&n(!0),Q?(c(null),m(!1),window.markusDesktop?.browser?.hideAll?.()):Z!=null&&(c(Z),x.current=Z)},[]),X=k.useCallback(W=>m(W),[]),ee=k.useCallback(()=>m(W=>!W),[]),H=r.find(W=>W.id===l)??r[0]??null,K=H?.payload??null,ae=k.useMemo(()=>({leftCollapsed:t,setLeftCollapsed:w,toggleLeftCollapsed:C,rightPanel:K,rightPanelOpen:r.length>0,rightPanelTabs:r,activeRightPanelTabId:H?.id??null,openRightPanel:T,closeRightPanel:j,closeRightPanelTab:_,setActiveRightPanelTab:O,updateRightPanelBrowserTab:P,toggleRightPanel:$,collapseRightPanelOnly:D,rightPanelFullscreen:d,setRightPanelFullscreen:X,toggleRightPanelFullscreen:ee,hostAvailable:p,setHostAvailable:h}),[t,w,C,K,r,H,T,j,_,O,P,$,D,d,X,ee,p]);return s.jsx(i3.Provider,{value:ae,children:e})}function Ec(){return k.useContext(i3)}k.lazy(()=>qr(()=>Promise.resolve().then(()=>T3),void 0).then(e=>({default:e.MarkdownMessage})));const _G=k.lazy(()=>qr(()=>import("./ContentRenderer-CQ9uMng0.js"),[]).then(e=>({default:e.ContentRenderer})));let wo=[],F2=60;function jG(e){const t=k.useRef(e);t.current=e;const[n]=k.useState(()=>++F2);return k.useEffect(()=>{const r=()=>t.current();wo.push(r);const o=l=>{l.key==="Escape"&&wo[wo.length-1]===r&&(l.preventDefault(),r())};return window.addEventListener("keydown",o,!0),()=>{window.removeEventListener("keydown",o,!0),wo=wo.filter(l=>l!==r),wo.length===0&&(F2=60)}},[]),n}const q2=500,Bs=new Map,u0=new Set,Pd=new Map;let zd=null;function MG(){if(Bs.size<=q2)return;const e=Bs.size-q2,t=Bs.keys();for(let n=0;n<e;n++){const{value:r,done:o}=t.next();if(o)break;Bs.delete(r)}}function G2(e,t){Bs.delete(e),Bs.set(e,t),MG()}function V2(e){const t=Pd.get(e);if(t)for(const n of t)n()}function RG(){zd=null;const e=[...u0];u0.clear(),e.length!==0&&Ce.files.check(e).then(({results:t})=>{for(const[n,r]of Object.entries(t))G2(n,r),V2(n)}).catch(()=>{for(const t of e)G2(t,{exists:!1,isFile:!1,type:"unknown"}),V2(t)})}function OG(e){Bs.has(e)||u0.has(e)||(u0.add(e),zd&&clearTimeout(zd),zd=setTimeout(RG,30))}function DG(e,t){let n=Pd.get(e);return n||(n=new Set,Pd.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Pd.delete(e)}}function LG(e){const t=k.useCallback(o=>DG(e,o),[e]),n=k.useCallback(()=>Bs.get(e),[e]),r=k.useSyncExternalStore(t,n,n);return k.useEffect(()=>{OG(e)},[e]),r}const IG=/^(?:\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|~\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|[A-Za-z]:(?:\\|\/)[\w.\-@+ ]+(?:(?:\\|\/)[\w.\-@+ ]*)*|\.\.?\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*)$/;function PG(e){return e.length<2||e.length>500?!1:IG.test(e)}function zG({filePath:e,onClose:t}){const n=jG(t),[r,o]=k.useState(!0),[l,c]=k.useState(null),[d,m]=k.useState(""),[p,h]=k.useState(""),[g,x]=k.useState(""),[y,w]=k.useState(""),[C,T]=k.useState("");k.useEffect(()=>{o(!0),c(null),Ce.files.preview(e).then(_=>{m(typeof _.content=="string"?_.content:""),h(_.type),x(_.name),w(_.mimeType||""),T(_.streamUrl||(_.path?Ce.files.streamUrl(_.path):"")||(_.type==="audio"||_.type==="video"?Ce.files.streamUrl(e):""))}).catch(_=>{c(String(_?.message||_))}).finally(()=>{o(!1)})},[e]);const S=g||e.split(/[/\\]/).pop()||e;return Sa.createPortal(s.jsx("div",{className:"fixed inset-0 bg-black/40 flex items-center justify-center",style:{zIndex:n},onClick:t,children:s.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:_=>_.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-default bg-surface-elevated/50 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("svg",{className:"w-4 h-4 shrink-0 text-fg-secondary",viewBox:"0 0 20 20",fill:"currentColor",children:s.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"})}),s.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:S}),s.jsx("span",{className:"text-xs text-fg-tertiary truncate hidden sm:inline",children:e})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx("button",{className:"text-xs text-fg-secondary hover:text-fg-primary px-2 py-1 rounded hover:bg-surface-elevated transition-colors",onClick:()=>Ce.files.reveal(e),title:"Reveal in file explorer",children:s.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:s.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"})})}),s.jsx("button",{className:"text-fg-secondary hover:text-fg-primary p-1 rounded hover:bg-surface-elevated transition-colors",onClick:t,children:s.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:s.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"})})})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[r&&s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"w-5 h-5 border-2 border-brand-500/30 border-t-brand-500 rounded-full animate-spin"})}),l&&s.jsxs("div",{className:"text-center py-12 text-fg-secondary text-sm",children:[s.jsx("p",{className:"text-red-400 mb-1",children:"Failed to load file"}),s.jsx("p",{className:"text-xs text-fg-tertiary",children:l})]}),!r&&!l&&p==="image"&&d&&s.jsx("div",{className:"flex justify-center",children:s.jsx("img",{src:`data:${y||"image/png"};base64,${d}`,alt:S,className:"max-w-full rounded"})}),!r&&!l&&p==="audio"&&C&&s.jsx("audio",{controls:!0,preload:"metadata",src:C,className:"w-full"}),!r&&!l&&p==="video"&&C&&s.jsx("video",{controls:!0,preload:"metadata",src:C,className:"w-full max-h-[60vh] rounded-lg bg-black"}),!r&&!l&&(p==="binary"||!d&&p!=="image"&&p!=="audio"&&p!=="video")&&s.jsxs("div",{className:"text-center py-8 space-y-3",children:[s.jsx("p",{className:"text-sm text-fg-secondary",children:"This file type cannot be previewed."}),s.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:()=>{Ce.files.reveal(e)},children:"Reveal in file explorer"})]}),!r&&!l&&d&&p!=="image"&&p!=="audio"&&p!=="video"&&p!=="binary"&&s.jsx(k.Suspense,{fallback:s.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading…"}),children:s.jsx(_G,{content:d,format:p==="text"?"text":p,className:"text-sm"})})]})]})}),document.body)}function BG({path:e}){const t=LG(e),[n,r]=k.useState(null),o=Ec(),l=t?.exists??!1,c=t?.type==="markdown"||t?.type==="html"||t?.type==="json"||t?.type==="text"||t?.type==="image"||t?.type==="audio"||t?.type==="video",d=k.useCallback(h=>{if(h.preventDefault(),h.stopPropagation(),!!l)if(c){if(o?.hostAvailable){o.openRightPanel({kind:"file",path:e});return}r(e)}else Ce.files.reveal(e)},[l,c,e,o]),m="inline w-3 h-3 align-[-0.125em]",p=c?s.jsx("svg",{className:m,viewBox:"0 0 20 20",fill:"currentColor",children:s.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"})}):s.jsx("svg",{className:m,viewBox:"0 0 20 20",fill:"currentColor",children:s.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 t?l?s.jsxs(s.Fragment,{children:[s.jsxs("code",{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:d,title:c?"Click to preview":"Click to reveal in file explorer",role:"button",tabIndex:0,children:[s.jsxs("span",{className:"whitespace-nowrap",children:[p,e.charAt(0)]}),e.slice(1)]}),n&&s.jsx(zG,{filePath:n,onClose:()=>r(null)})]}):s.jsx("code",{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:"File not found",children:e}):s.jsx("code",{className:"bg-surface-secondary px-1.5 py-0.5 rounded text-xs font-mono text-fg-secondary break-all",children:e})}let qp=null;function UG(){return qp||(qp=qr(()=>import("./mermaid.core-Cxm0p7KD.js").then(e=>e.b9),__vite__mapDeps([0,1])).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:"loose",fontFamily:"inherit"}),e))),qp}function $G(){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 HG(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 FG(){return $G()}function qG(){return k.useSyncExternalStore(HG,FG)}function o3({code:e}){const t=k.useRef(null),[n,r]=k.useState(null),[o,l]=k.useState(!0),c=k.useId(),d=k.useRef(0),m=k.useRef(null),p=qG();return k.useEffect(()=>{if(!e.trim()||m.current&&m.current.code===e&&m.current.dark===p)return;let h=!1;return l(!0),r(null),d.current+=1,(async()=>{try{const g=await UG();if(h)return;g.default.initialize({startOnLoad:!1,theme:p?"dark":"default",securityLevel:"loose",fontFamily:"inherit"});const x=`mermaid-${c.replace(/:/g,"")}-${d.current}`,{svg:y}=await g.default.render(x,e.trim());if(h)return;t.current&&(t.current.innerHTML=y,m.current={code:e,dark:p})}catch(g){h||r(g instanceof Error?g.message:String(g))}finally{h||l(!1)}})(),()=>{h=!0}},[e,c,p]),n?s.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[s.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:[s.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.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"})}),s.jsx("span",{className:"text-[10px] font-medium text-red-400",children:"Mermaid render error"})]}),s.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):s.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[o&&s.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[s.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),"Rendering diagram…"]}),s.jsx("div",{ref:t,className:`flex justify-center [&>svg]:max-w-full${o?" hidden":""}`})]})}const GG="/assets/viz-global-C_AyN6D9.js";let hd=!1,Gp=null;function VG(){return hd?Promise.resolve():new Promise((e,t)=>{const n=document.querySelector("script[data-plantuml-viz]");if(n){globalThis.Viz?(hd=!0,e()):(n.addEventListener("load",()=>{hd=!0,e()}),n.addEventListener("error",()=>t(new Error("Failed to load viz-global.js"))));return}const r=document.createElement("script");r.setAttribute("data-plantuml-viz",""),r.src=GG,r.onload=()=>{hd=!0,e()},r.onerror=()=>t(new Error("Failed to load viz-global.js")),document.head.appendChild(r)})}function KG(){return Gp||(Gp=VG().then(()=>qr(()=>import("./plantuml-DezRDxd4.js"),[]))),Gp}let K2=Promise.resolve();function WG(e,t){const n=K2.then(()=>new Promise((r,o)=>{KG().then(({renderToString:l})=>{const c=e.split(/\r\n|\r|\n/);l(c,r,o,{dark:t})}).catch(o)}));return K2=n.then(()=>{},()=>{}),n}function YG(){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 XG(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 QG(){return k.useSyncExternalStore(XG,()=>YG())}function l3({code:e}){const[t,n]=k.useState(null),[r,o]=k.useState(null),[l,c]=k.useState(!0),d=k.useRef(null),m=QG();return k.useEffect(()=>{if(!e.trim()||d.current&&d.current.code===e&&d.current.dark===m)return;let p=!1;return c(!0),o(null),WG(e.trim(),m).then(h=>{p||(n(h),d.current={code:e,dark:m})}).catch(h=>{p||o(h instanceof Error?h.message:String(h))}).finally(()=>{p||c(!1)}),()=>{p=!0}},[e,m]),r?s.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[s.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:[s.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.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"})}),s.jsx("span",{className:"text-[10px] font-medium text-red-400",children:"PlantUML render error"})]}),s.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):s.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[l&&s.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[s.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),"Rendering diagram…"]}),t&&s.jsx("div",{className:`flex justify-center [&>svg]:max-w-full${l?" hidden":""}`,dangerouslySetInnerHTML:{__html:t}})]})}function ZG(e,t,n){const r=e.cloneNode(!0),o=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},d=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:${d.text};line-height:1.7;`,h1:`font-size:${c.h1}em;font-weight:700;color:${d.heading};margin:20px 0 10px;line-height:1.3;border-bottom:1px solid ${d.border};padding-bottom:6px;`,h2:`font-size:${c.h2}em;font-weight:700;color:${d.heading};margin:18px 0 8px;line-height:1.3;`,h3:`font-size:${c.h3}em;font-weight:600;color:${d.heading};margin:14px 0 6px;line-height:1.3;`,h4:`font-size:${c.h4}em;font-weight:600;color:${d.heading};margin:12px 0 4px;`,strong:`font-weight:600;color:${d.strong};`,em:"font-style:italic;",a:`color:${d.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:${d.text};`,blockquote:`border-left:3px solid ${d.blockquoteBorder};padding:2px 0 2px 14px;margin:10px 0;color:${d.blockquoteText};`,hr:`border:none;border-top:1px solid ${d.hrColor};margin:20px 0;`,table:"border-collapse:collapse;width:100%;margin:10px 0;",thead:`background:${d.tableHeaderBg};`,th:`border:1px solid ${d.tableBorder};padding:8px 12px;text-align:left;font-weight:600;color:${d.tableHeaderText};`,td:`border:1px solid ${d.tableBorder};padding:8px 12px;color:${d.text};`,img:"max-width:100%;height:auto;"};function p(h){h.removeAttribute("class");const g=h.tagName.toLowerCase();if(g==="pre"){h.setAttribute("style",`background:${d.preBg};color:${d.preText};padding:14px;border-radius:6px;overflow-x:auto;margin:10px 0;font-size:0.88em;line-height:1.5;border:1px solid ${d.preBorder};`);const x=h.querySelector("code");x&&(x.removeAttribute("class"),x.setAttribute("style","background:transparent;padding:0;border-radius:0;color:inherit;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;font-size:inherit;"));return}g==="code"?h.setAttribute("style",`background:${d.codeBg};color:${d.codeText};padding:2px 6px;border-radius:4px;font-size:0.9em;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;`):m[g]&&h.setAttribute("style",m[g]),Array.from(h.children).forEach(p)}return r.removeAttribute("class"),Array.from(r.children).forEach(h=>p(h)),`<div style="background:${d.bg};color:${d.text};padding:20px 24px;font-family:${o};font-size:${l};line-height:1.7;max-width:800px;">${r.innerHTML}</div>`}async function Ig(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 JG(e,t,n,r){const o=ZG(e,t,r);try{return await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([o],{type:"text/html"}),"text/plain":new Blob([n],{type:"text/plain"})})]),{ok:!0,method:"html"}}catch{return{ok:await Ig(n),method:"text"}}}function Uh({code:e,language:t,children:n}){const{t:r}=dt("common"),[o,l]=k.useState("rendered"),[c,d]=k.useState(!1),m=k.useCallback(async()=>{await Ig(e)&&(d(!0),setTimeout(()=>d(!1),1800))},[e]);return s.jsxs("div",{className:"not-prose my-2 rounded-lg overflow-hidden border border-border-subtle",children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle bg-surface-secondary",children:[s.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:t}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>l("rendered"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${o==="rendered"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),s.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"})]}),r("markdown.viewRendered")]})}),s.jsx("button",{onClick:()=>l("source"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${o==="source"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}),r("markdown.viewSource")]})})]})]}),o==="rendered"?s.jsx("div",{children:n}):s.jsxs("div",{className:"relative group/source",children:[s.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}),s.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:r("markdown.copyContent"),children:c?s.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.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"})})})]})]})}function Yl(e,t){const n=/```[\s\S]*?```|`[^`\n]+`/g;let r=0,o="";for(const l of e.matchAll(n))o+=t(e.slice(r,l.index)),o+=l[0],r=l.index+l[0].length;return o+=t(e.slice(r)),o}function eV(e){let t=e.replace(/\\\[([\s\S]*?)\\\]/g,(n,r)=>`$$${r}$$`);return t=t.replace(/\\\((.+?)\\\)/g,(n,r)=>`$${r}$`),t}const gd="#mention:";function tV(e,t){if(!t||t.length===0)return e.replace(/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu,(l,c,d)=>{const m=c??d;return`[@${m}](${gd}${encodeURIComponent(m)})`});const n=[...t].sort((l,c)=>c.length-l.length);let r="",o=0;for(;o<e.length;){const l=e.indexOf("@",o);if(l<0){r+=e.slice(o);break}if(r+=e.slice(o,l),e[l+1]==="["){const h=e.indexOf("]",l+2);if(h>l+2){const g=e.slice(l+2,h);r+=`[@${g}](${gd}${encodeURIComponent(g)})`,o=h+1;continue}}const c=e.slice(l+1),d=c.toLowerCase(),m=n.find(h=>d.startsWith(h.toLowerCase()));if(m){const h=c.slice(0,m.length);r+=`[@${h}](${gd}${encodeURIComponent(h)})`,o=l+1+m.length;continue}const p=c.match(/^([\w\p{L}\p{N}]+)/u);if(p){const h=p[1];r+=`[@${h}](${gd}${encodeURIComponent(h)})`,o=l+1+h.length;continue}r+="@",o=l+1}return r}const c3="#entity:",nV=new RegExp("(?<!\\[)(?<!\\()(?<!:)(?<!\\/)(?<!\\\\)\\b(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}\\b(?!\\]\\(#entity:)","gi"),rV=/`\[([^\]]+)\]\(#entity:((?:tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)`/gi;function aV(e,t){const n=e.slice(0,t),r=n.lastIndexOf("](");return r===-1?!1:n.indexOf(")",r+2)===-1}function sV(e){return e.replace(rV,(t,n,r)=>`[${n}](${c3}${r})`)}function iV(e){return e.replace(nV,(t,n,r)=>aV(e,r)?t:`[${t}](${c3}${t})`)}function oV(e){const t=e.trim();return t.startsWith("@startuml")&&t.endsWith("@enduml")}const lV=/^(graph\s|flowchart\s|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt|pie|gitGraph|mindmap|timeline|journey)/m;function cV(e){return lV.test(e.trim())}const uV={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 dV(e){return uV[e.toLowerCase()]??e.charAt(0).toUpperCase()+e.slice(1)}function mV(e){const t=e.match(/language-(\S+)/);return t?t[1]:null}const fV=[o3,l3];function pV(e){for(const t of k.Children.toArray(e))if(k.isValidElement(t)&&typeof t.props?.className=="string"){const n=t.props.className;return mV(n)}return null}function ac(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(!e)return"";if(Array.isArray(e))return e.map(ac).join("");if(k.isValidElement(e)){const t=e.props;return ac(t.children)}return""}function hV({children:e}){const{t}=dt("common"),n=pV(e),r=k.useRef(null),[o,l]=k.useState(!1),[c,d]=k.useState("rendered"),m=k.useCallback(async()=>{let h;c==="source"?h=ac(e):h=r.current?.querySelector("code")?.textContent??"";try{await navigator.clipboard.writeText(h),l(!0),setTimeout(()=>l(!1),1800)}catch{}},[c,e]);if(k.Children.toArray(e).some(h=>k.isValidElement(h)&&fV.includes(h.type))){const h=ac(e),g=n==="mermaid"||n==="plantuml"?n:"diagram";return s.jsx(Uh,{code:h,language:g,children:e})}return n==="mermaid"||n==="plantuml"?s.jsx(s.Fragment,{children:e}):s.jsxs("div",{className:"not-prose relative group/code my-2 rounded-lg overflow-hidden bg-surface-secondary border border-border-subtle",children:[n&&s.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle",children:[s.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:dV(n)}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>d("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")}),s.jsx("button",{onClick:()=>d("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")})]})]}),s.jsxs("div",{className:"relative",children:[c==="rendered"?s.jsx("pre",{ref:r,className:"p-3 overflow-x-auto text-xs [&>code]:p-0 [&>code]:rounded-none [&>code]:text-fg-secondary",children:k.Children.map(e,h=>k.isValidElement(h)?k.cloneElement(h,{style:{background:"transparent",padding:0}}):h)}):s.jsx("pre",{className:"p-3 overflow-x-auto text-xs font-mono text-fg-secondary whitespace-pre-wrap break-words",children:ac(e)}),s.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:o?s.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.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 u3=/^(?:\/|~\/|[A-Za-z]:[\\/]|\\\\)/,d3=/^\.{1,2}\//,gV=/\.[a-zA-Z0-9]{1,12}(?:$|[?#])/,m3=/^[A-Za-z]:[\\/]/,f3=/^\\\\[^\\]/;function p3(e){const t=e.trim();return t?!!(/^file:/i.test(t)||m3.test(t)||f3.test(t)||t.startsWith("~/")||t.startsWith("/")||d3.test(t)):!1}function Pg(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=t.replace(/\\+/g,"/"),t}function bV(e){return e.replace(/(!?\[[^\]]*]\()((?:[A-Za-z]:|\\\\)[^)\n]*)(\))/g,(t,n,r,o)=>`${n}${r.replace(/\\+/g,"/")}${o}`)}function h3(e){return e.trim().toLowerCase().replace(/[^\p{L}\p{N}\p{M}\s\-_]/gu,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function bd(e,t){if(!e)return e;if(u3.test(e))return e.startsWith("~/")?e:e.replace(/\\/g,"/");if(!t)return e;const r=`${t.replace(/\\/g,"/").replace(/\/+$/,"")}/${e.replace(/^\.\//,"")}`,o=r.split("/"),l=[];for(const d of o)!d||d==="."||(d===".."?l.pop():l.push(d));const c=l.join("/");return r.startsWith("/")?`/${c}`.replace(/^\/+/,"/"):c}function W2(e){const t=e.indexOf("#");return t<0?{path:e}:{path:e.slice(0,t),fragment:decodeURIComponent(e.slice(t+1))}}function Y2(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(m3.test(n)||f3.test(n)){const{path:l,fragment:c}=W2(n);return{kind:"file",path:bd(l,t),fragment:c}}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:Pg(n)}:{kind:"passthrough"};const{path:r,fragment:o}=W2(n);return u3.test(r)?{kind:"file",path:bd(r,t),fragment:o}:d3.test(r)?{kind:"file",path:bd(r,t),fragment:o}:r&&gV.test(r)&&!r.includes("://")?{kind:"file",path:bd(r,t),fragment:o}:{kind:"passthrough"}}function xV(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 r=e.querySelectorAll("h1,h2,h3,h4,h5,h6");for(const o of r)if(h3(o.textContent||"")===t||o.id===t){n=o;break}}return n?(n.scrollIntoView({behavior:"smooth",block:"start"}),!0):!1}function g3(e){return e.type==="text"?e.value??"":(e.children??[]).map(g3).join("")}function yV(){return e=>{const t=new Map,n=r=>{if(r.type==="element"&&r.tagName&&/^h[1-6]$/.test(r.tagName)){const o=g3(r).trim();let l=h3(o);if(l){const c=t.get(l)??0;t.set(l,c+1),c>0&&(l=`${l}-${c}`),r.properties={...r.properties??{},id:l}}}for(const o of r.children??[])n(o)};n(e)}}const b3="markus-copy-typography",X2={fontFamily:"default",fontSize:15,headingScale:"standard"};function x3(){try{const e=localStorage.getItem(b3);if(e)return{...X2,...JSON.parse(e)}}catch{}return X2}function vV(e){localStorage.setItem(b3,JSON.stringify(e))}function wV(e){const t={default:"-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif",serif:"Georgia, 'Times New Roman', Times, serif","sans-serif":"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif",mono:"'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace"},n={compact:{h1:1.3,h2:1.15,h3:1.05,h4:1},standard:{h1:1.6,h2:1.35,h3:1.15,h4:1},large:{h1:2,h2:1.6,h3:1.3,h4:1.1}};return{fontFamily:t[e.fontFamily]??t.default,fontSize:`${e.fontSize}px`,headingScales:n[e.headingScale]??n.standard}}function kV({onClose:e}){const{t}=dt("common"),[n,r]=k.useState(x3);k.useEffect(()=>{vV(n)},[n]);const o=k.useCallback((l,c)=>{r(d=>({...d,[l]:c}))},[]);return s.jsxs("div",{className:"px-3 py-2 space-y-3 max-w-[260px]",children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsx("span",{className:"font-medium text-fg-primary text-xs",children:t("markdown.typographySettings")}),s.jsx("button",{onClick:e,className:"text-fg-tertiary hover:text-fg-primary p-0.5",children:s.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),s.jsx("p",{className:"text-[10px] text-fg-tertiary",children:t("markdown.typographyDesc")}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:t("markdown.fontFamily")}),s.jsxs("select",{value:n.fontFamily,onChange:l=>o("fontFamily",l.target.value),className:"w-full px-2 py-1 text-xs rounded bg-surface-primary border border-border-subtle text-fg-secondary focus:outline-none focus:ring-1 focus:ring-brand-500/50",children:[s.jsx("option",{value:"default",children:t("markdown.fontDefault")}),s.jsx("option",{value:"serif",children:t("markdown.fontSerif")}),s.jsx("option",{value:"sans-serif",children:t("markdown.fontSansSerif")}),s.jsx("option",{value:"mono",children:t("markdown.fontMono")})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:[t("markdown.fontSize"),": ",n.fontSize,"px"]}),s.jsx("input",{type:"range",min:10,max:24,step:1,value:n.fontSize,onChange:l=>o("fontSize",Number(l.target.value)),className:"w-full h-1 rounded-full appearance-none bg-border-subtle [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-brand-500"}),s.jsxs("div",{className:"flex justify-between text-[9px] text-fg-tertiary mt-0.5",children:[s.jsx("span",{children:"10px"}),s.jsx("span",{children:"24px"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:t("markdown.headingScale")}),s.jsx("div",{className:"flex gap-1",children:["compact","standard","large"].map(l=>s.jsx("button",{onClick:()=>o("headingScale",l),className:`flex-1 px-2 py-1 rounded text-[10px] font-medium transition-colors ${n.headingScale===l?"bg-brand-600/20 text-brand-500":"bg-surface-primary text-fg-tertiary hover:text-fg-secondary border border-border-subtle"}`,children:t(`markdown.scale${l.charAt(0).toUpperCase()+l.slice(1)}`)},l))})]})]})}const SV=k.lazy(()=>qr(()=>Promise.resolve().then(()=>T3),void 0).then(e=>({default:e.MarkdownMessage}))),NV={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},Q2={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 CV({item:e,onClose:t,onOpenInPage:n}){const{t:r}=dt(["agent","common"]),o=NV[e.type]??{icon:"📎",color:"bg-surface-elevated text-fg-secondary"},l=Q2[e.status]??Q2.active,c=/^https?:\/\//i.test(e.reference??"");k.useEffect(()=>{const m=p=>{p.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]);const d=s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:t,children:[s.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),s.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:[s.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:[s.jsx("span",{className:`inline-flex items-center justify-center w-10 h-10 rounded-xl text-lg shrink-0 ${o.color}`,children:o.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:e.title}),s.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[s.jsx("span",{className:`px-1.5 py-0.5 text-[10px] rounded font-medium ${l.color}`,children:e.status}),s.jsx("span",{className:"text-[10px] text-fg-tertiary",children:e.type}),e.format&&s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-elevated rounded text-fg-secondary",children:e.format})]})]}),s.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:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),s.jsxs("div",{className:"px-5 py-4 space-y-4",children:[e.summary&&e.summary.trim()!==e.title.trim()&&s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:r("agent:deliverables.summary")}),s.jsx("div",{className:"mt-1.5",children:s.jsx(k.Suspense,{fallback:s.jsx("p",{className:"text-sm text-fg-secondary",children:e.summary}),children:s.jsx(SV,{content:e.summary,className:"text-sm text-fg-secondary"})})})]}),e.reference&&s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:r("agent:deliverables.reference")}),s.jsxs("div",{className:"mt-1.5 flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[s.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all flex-1 select-all",children:e.reference}),c?s.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:r("common:open")}):s.jsx("button",{onClick:()=>{Ce.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:r("common:open")})]})]}),e.diffStats&&s.jsxs("div",{className:"flex items-center gap-3 text-xs bg-surface-elevated rounded-lg px-3 py-2",children:[s.jsx("span",{className:"text-fg-tertiary font-medium",children:"Diff:"}),s.jsxs("span",{className:"text-fg-secondary",children:[e.diffStats.filesChanged," file",e.diffStats.filesChanged!==1?"s":""]}),s.jsxs("span",{className:"text-green-500",children:["+",e.diffStats.additions]}),s.jsxs("span",{className:"text-red-500",children:["-",e.diffStats.deletions]})]}),e.testResults&&s.jsxs("div",{className:"flex items-center gap-3 text-xs bg-surface-elevated rounded-lg px-3 py-2",children:[s.jsx("span",{className:"text-fg-tertiary font-medium",children:"Tests:"}),s.jsxs("span",{className:"text-green-500",children:[e.testResults.passed," passed"]}),e.testResults.failed>0&&s.jsxs("span",{className:"text-red-500",children:[e.testResults.failed," failed"]}),e.testResults.skipped>0&&s.jsxs("span",{className:"text-fg-tertiary",children:[e.testResults.skipped," skipped"]})]}),e.tags.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.tags.map(m=>s.jsx("span",{className:"px-2 py-0.5 text-[11px] bg-surface-elevated rounded-md text-fg-tertiary",children:m},m))}),s.jsxs("div",{className:"flex items-center gap-4 text-[10px] text-fg-tertiary flex-wrap pt-1 border-t border-border-default/50",children:[s.jsxs("span",{children:[r("agent:deliverables.created"),": ",new Date(e.createdAt).toLocaleString()]}),s.jsxs("span",{children:[r("agent:deliverables.updated"),": ",new Date(e.updatedAt).toLocaleString()]}),e.accessCount>0&&s.jsx("span",{children:r("agent:deliverables.accessed",{count:e.accessCount})})]})]}),s.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:[s.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:[s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),r("agent:deliverables.openInPage")]}),s.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:r("common:close")})]})]})]});return typeof document<"u"?Sa.createPortal(d,document.body):d}const TV={tsk:"task",req:"requirement",proj:"project",dlv:"deliverable",agt:"agent",team:"team"};function y3(e){return{task:"task",requirement:"requirement",project:"project",deliverable:"deliverable",agent:"agent",team:"team"}[e]}const v3={task:"📋",requirement:"📝",project:"📁",deliverable:"📦",agent:"🤖",team:"👥"},w3={task:"Task",requirement:"Requirement",project:"Project",deliverable:"Deliverable",agent:"Agent",team:"Team"},AV=/^(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}$/i;function d0(e){return AV.test(e.trim())}function EV(e){const t=e.split("_")[0]?.toLowerCase();return t?TV[t]:void 0}function k3(e){e.startsWith("tsk_")?at.navigate(me.WORK,{openTask:e}):e.startsWith("req_")?at.navigate(me.WORK,{openRequirement:e}):e.startsWith("proj_")?at.navigate(me.WORK,{projectId:e}):e.startsWith("dlv_")?at.navigate(me.DELIVERABLES,{openDeliverable:e}):e.startsWith("agt_")?at.navigate(me.TEAM,{agentId:e}):e.startsWith("team_")&&at.navigate(me.TEAM,{selectTeam:e})}const Vp=new Map,xd=new Map;async function _V(e,t){const n={id:e,type:t,title:e,loading:!1};try{switch(t){case"task":{const r=await Ce.tasks.get(e);return{...n,title:r.task.title,status:r.task.status}}case"requirement":{const r=await Ce.requirements.get(e);return{...n,title:r.requirement.title,status:r.requirement.status}}case"project":{const r=await Ce.projects.get(e);return{...n,title:r.project.name,status:r.project.status,summary:r.project.description}}case"deliverable":{const r=await Ce.deliverables.get(e);return{...n,title:r.deliverable.title,status:r.deliverable.status,summary:r.deliverable.summary,deliverable:r.deliverable}}case"agent":{const r=await Ce.agents.get(e);return{...n,title:r.name,summary:r.role}}case"team":{const o=(await Ce.teams.list()).teams.find(l=>l.id===e);return{...n,title:o?.name??e,notFound:!o}}}}catch{}return{...n,notFound:!0}}function S3(e,t){const n=t??EV(e),[r,o]=k.useState(()=>Vp.get(e)??{id:e,type:n??"task",title:e,loading:!!n});return k.useEffect(()=>{if(!n){o({id:e,type:"task",title:e,loading:!1,notFound:!0});return}const l=Vp.get(e);if(l){o(l);return}o(m=>({...m,type:n,loading:!0}));let c=!0,d=xd.get(e);return d||(d=_V(e,n),xd.set(e,d)),d.then(m=>{Vp.set(e,m),xd.delete(e),c&&o(m)}).catch(()=>{xd.delete(e),c&&o({id:e,type:n,title:e,loading:!1,notFound:!0})}),()=>{c=!1}},[e,n]),r}function N3(e){const t=(e.split("_")[0]?.length??3)+1;return e.length>t+8?`${e.slice(0,t+8)}…`:e}function sc({id:e,type:t,label:n}){const r=S3(e,t),o=Ec(),l=v3[r.type]??"🔗",c=n??(r.loading||r.notFound?N3(e):r.title),d=m=>{if(m.preventDefault(),m.stopPropagation(),r.type==="deliverable"&&r.deliverable&&o?.hostAvailable){o.openRightPanel({kind:"deliverable",deliverable:r.deliverable});return}k3(e)};return s.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:d,title:`${w3[r.type]}: ${r.notFound?e:r.title} (${e})`,children:[s.jsx("span",{className:"text-[10px]",children:l}),s.jsx("span",{className:"truncate max-w-[240px] align-baseline",children:c})]})}function jV({id:e,type:t,label:n}){const r=S3(e,t),[o,l]=k.useState(!1),c=Ec(),d=v3[r.type]??"🔗",m=()=>{if(r.type==="deliverable"&&r.deliverable){if(c?.hostAvailable){c.openRightPanel({kind:"deliverable",deliverable:r.deliverable});return}l(!0);return}k3(e)},p=r.loading?N3(e):n||(r.notFound?e:r.title);return s.jsxs("span",{className:"not-prose block my-2",children:[s.jsxs("button",{type:"button",onClick:m,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:[s.jsx("span",{className:"inline-flex items-center justify-center w-8 h-8 rounded-lg text-sm shrink-0 bg-brand-500/10",children:d}),s.jsxs("span",{className:"flex-1 min-w-0 block",children:[s.jsxs("span",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wide text-fg-tertiary font-medium",children:w3[r.type]}),r.status&&s.jsx("span",{className:"px-1.5 py-0.5 text-[10px] rounded font-medium bg-brand-500/10 text-brand-500",children:r.status})]}),s.jsx("span",{className:`block text-sm font-medium truncate mt-0.5 ${r.notFound?"font-mono text-fg-tertiary":"text-fg-primary"}`,children:p}),r.summary&&r.summary.trim()!==r.title.trim()&&s.jsx("span",{className:"block text-xs text-fg-tertiary mt-0.5 line-clamp-1",children:r.summary})]}),s.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:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),o&&r.deliverable&&s.jsx(CV,{item:r.deliverable,onClose:()=>l(!1),onOpenInPage:h=>{l(!1),at.navigate(me.DELIVERABLES,{openDeliverable:h})}})]})}class MV extends k.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t){this.state.error&&this.props.resetKeys&&!RV(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 RV(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 OV=/^(deliverable|task|requirement|project|agent|team|workflow):/i;function Z2(e){return OV.test(e)||p3(e)?e:sw(e)}const J2=[Mw,hF,Ok],e4=[yV,[WF,{strict:"ignore"}],[s3,{detect:!0,ignoreMissing:!0}]],$h="text-brand-500 hover:text-brand-500 underline break-all cursor-pointer",DV=/<think>([\s\S]*?)(<\/think>|$)/g;function LV(e){const t=[];let n=e.replace(DV,(r,o)=>{const l=o.trim();return l&&t.push(l),""});return n=n.replace(/<\/think>/g,"").replace(/<think>/g,""),{thinking:t,rest:n.trim()}}const t4="#mention:",m0="#entity:",IV=/^\[([^\]]+)\]\(#entity:((tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)$/i,C3=/^(workflow|task|requirement|project|deliverable|agent|team):(.+)$/;function Hh(e){return e.type==="text"?e.value??"":(e.children??[]).map(Hh).join("")}function PV(e){return e.type==="text"&&(e.value??"").trim()===""}function zV(e){if(!e?.children)return null;const t=e.children.filter(r=>!PV(r));if(t.length!==1)return null;const n=t[0];if(n.type==="element"&&n.tagName==="a"){const r=n.properties?.href;if(!r)return null;const o=Hh(n);if(r.startsWith(m0))return{id:r.slice(m0.length)};const l=r.match(C3);return l&&l[1]!=="workflow"?{id:l[2],type:y3(l[1]),label:o}:null}if(n.type==="element"&&n.tagName==="code"){const r=Hh(n).trim();if(d0(r))return{id:r}}if(n.type==="text"){const r=(n.value??"").trim();if(d0(r))return{id:r}}return null}const BV={p:({children:e})=>s.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:e}),h1:({children:e})=>s.jsx("h1",{className:"text-base font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h2:({children:e})=>s.jsx("h2",{className:"text-sm font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h3:({children:e})=>s.jsx("h3",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h4:({children:e})=>s.jsx("h4",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h5:({children:e})=>s.jsx("h5",{className:"text-xs font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h6:({children:e})=>s.jsx("h6",{className:"text-xs font-medium mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),ul:({children:e})=>s.jsx("ul",{className:"list-disc pl-4 mb-2 space-y-0.5",children:e}),ol:({children:e,start:t})=>s.jsx("ol",{start:t,className:"list-decimal pl-7 mb-2 space-y-0.5",children:e}),li:({children:e,value:t})=>s.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??""),r=n.trim();if(t?.includes("language-plantuml")||oV(r))return s.jsx(Uh,{code:r,language:"plantuml",children:s.jsx(l3,{code:r})});if(t?.includes("language-mermaid")||!t&&cV(r))return s.jsx(Uh,{code:r,language:"mermaid",children:s.jsx(o3,{code:r})});if(t?.includes("language-"))return s.jsx("code",{className:`${t} text-fg-secondary font-mono text-xs`,children:e});if(d0(n))return s.jsx(sc,{id:n.trim()});const o=n.match(IV);return o?s.jsx(sc,{id:o[2],label:o[1]}):PG(n)?s.jsx(BG,{path:n}):s.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})=>s.jsx(hV,{children:e}),strong:({children:e})=>s.jsx("strong",{className:"font-bold text-fg-primary",children:e}),em:({children:e})=>s.jsx("em",{className:"italic text-fg-secondary",children:e}),del:({children:e})=>s.jsx("del",{className:"line-through text-fg-tertiary",children:e}),blockquote:({children:e})=>s.jsx("blockquote",{className:"border-l-2 border-brand-500 pl-3 my-2 text-fg-secondary italic",children:e}),a:({href:e,children:t})=>s.jsx("a",{href:e,className:$h,children:t}),hr:()=>s.jsx("hr",{className:"border-border-default my-3"}),table:({children:e})=>s.jsx("div",{className:"overflow-x-auto my-2",children:s.jsx("table",{className:"min-w-full text-sm border-collapse border border-border-default",children:e})}),thead:({children:e})=>s.jsx("thead",{className:"bg-surface-secondary",children:e}),tbody:({children:e})=>s.jsx("tbody",{className:"divide-y divide-border-default",children:e}),tr:({children:e})=>s.jsx("tr",{className:"hover:bg-surface-elevated/50 transition-colors",children:e}),th:({children:e})=>s.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})=>s.jsx("td",{className:"px-3 py-2 text-sm text-fg-primary border border-border-default",children:e})},UV=/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i;function $V(e){const t=Pg(e);return p3(e)&&UV.test(t.split("?")[0]??t)}function HV(e,t){const n=Pg(e);if(n.startsWith("/")||n.startsWith("~/")||/^[A-Za-z]:\//.test(n)||n.startsWith("//"))return n;if((n.startsWith("./")||n.startsWith("../"))&&t){const o=((t.replace(/\\/g,"/").endsWith("/")?t.replace(/\\/g,"/"):`${t.replace(/\\/g,"/")}/`)+n).split("/"),l=[];for(const c of o)c===".."?l.pop():c!=="."&&c!==""&&l.push(c);return"/"+l.join("/")}return n}function FV(e){return`/api/files/image?path=${encodeURIComponent(e)}`}const ko=new Map;function qV({src:e,alt:t,onPreview:n,basePath:r}){const o=k.useMemo(()=>$V(e)?FV(HV(e,r)):e,[e,r]),l=o.startsWith("/api/files/image?"),c=ko.get(o),[d,m]=k.useState(c??(l?null:o)),[p,h]=k.useState(!!c),[g,x]=k.useState(!1),[y,w]=k.useState(null),[C,T]=k.useState(0),S=k.useRef(0),_=k.useCallback(()=>{ko.delete(o),x(!1),w(null),h(!1),m(l?null:`${o}${o.includes("?")?"&":"?"}retry=${Date.now()}`),T(j=>j+1)},[o,l]);return k.useEffect(()=>{if(!l)return;const j=ko.get(o);if(j){m(j),h(!0),x(!1),w(null);return}const O=++S.current;x(!1),w(null),h(!1),m(null),(async()=>{try{const P=await fetch(o,{credentials:"same-origin"});if(O!==S.current)return;if(!P.ok){let X=`HTTP ${P.status}`;try{const ee=await P.json();ee.error&&(X=ee.error)}catch{}throw new Error(X)}const D=await P.blob();if(O!==S.current)return;if(D.size===0)throw new Error("Empty image response");if(D.type&&!D.type.startsWith("image/")&&!D.type.includes("octet-stream"))throw new Error(`Unexpected content-type: ${D.type}`);const $=URL.createObjectURL(D);ko.set(o,$),m($),h(!0),x(!1),w(null)}catch(P){if(O!==S.current)return;const D=P instanceof Error?P.message:String(P);console.warn("[MarkdownImage] failed to load local image",o,P),w(D),x(!0),h(!1)}})()},[l,o,C]),k.useEffect(()=>{l||(m(o),h(!!ko.get(o)),x(!1),w(null))},[o,l,C]),g?s.jsxs("button",{type:"button",onClick:_,title:y??"Click to retry",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:[s.jsxs("svg",{className:"w-4 h-4 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),s.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),s.jsx("polyline",{points:"21 15 16 10 5 21"})]}),s.jsxs("span",{className:"truncate",children:["Failed to load image — click to retry",y?` (${y})`:""]})]}):s.jsxs("span",{className:"inline-block align-middle max-w-full",children:[!p&&s.jsx("span",{className:"block w-full min-h-[80px] max-w-[400px] bg-surface-elevated rounded-lg animate-pulse"}),d?s.jsx("img",{src:d,alt:t??"",onLoad:()=>{l||ko.set(o,o),h(!0)},onError:()=>{w("Image decode failed"),x(!0)},onClick:()=>n?.(d),className:`max-w-full h-auto rounded-lg cursor-pointer hover:opacity-90 transition-opacity my-1${p?"":" absolute opacity-0 pointer-events-none"}`,style:{maxHeight:"400px",objectFit:"contain"}}):null]})}async function n4(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch image (${t.status})`);return t.blob()}async function GV(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 r=n.getContext("2d");if(!r)throw new Error("Canvas unavailable");return r.drawImage(t,0,0),t.close(),new Promise((o,l)=>{n.toBlob(c=>c?o(c):l(new Error("PNG encode failed")),"image/png")})}function VV(e,t){try{const o=(e.startsWith("data:")?"":new URL(e,window.location.href).pathname).split("/").pop()||"";if(o&&/\.(png|jpe?g|gif|webp|svg|bmp)$/i.test(o))return decodeURIComponent(o)}catch{}return`image.${(t.type.split("/")[1]||"png").replace("jpeg","jpg")}`}function KV({src:e,onClose:t}){const{t:n}=dt("common"),[r,o]=k.useState(null),[l,c]=k.useState(null);zo(!0),k.useEffect(()=>{const g=x=>{x.key==="Escape"&&t()};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[t]);const d=k.useCallback(g=>{o(g),window.setTimeout(()=>o(null),1600)},[]),m=k.useCallback(async g=>{if(g.stopPropagation(),!l){c("copy");try{const x=await n4(e),y=await GV(x);await navigator.clipboard.write([new ClipboardItem({"image/png":y})]),d(n("imageCopied"))}catch{d(n("imageCopyFailed"))}finally{c(null)}}},[l,d,e,n]),p=k.useCallback(async g=>{if(g.stopPropagation(),!l){c("download");try{const x=await n4(e),y=URL.createObjectURL(x),w=document.createElement("a");w.href=y,w.download=VV(e,x),document.body.appendChild(w),w.click(),w.remove(),URL.revokeObjectURL(y),d(n("imageDownloaded"))}catch{d(n("imageDownloadFailed"))}finally{c(null)}}},[l,d,e,n]),h="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 Sa.createPortal(s.jsxs("div",{className:"fixed inset-0 z-[9999] bg-black/80 flex items-center justify-center p-4",onClick:t,children:[s.jsxs("div",{className:"absolute top-4 right-4 z-10 flex items-center gap-2",onClick:g=>g.stopPropagation(),children:[s.jsxs("button",{type:"button",className:h,onClick:m,disabled:!!l,title:n("copyImage"),children:[s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),s.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),n("copy")]}),s.jsxs("button",{type:"button",className:h,onClick:p,disabled:!!l,title:n("downloadImage"),children:[s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"}),s.jsx("polyline",{points:"7 10 12 15 17 10"}),s.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),n("downloadImage")]}),s.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:s.jsxs("svg",{className:"w-6 h-6 text-white",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),r&&s.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:r}),s.jsx("img",{src:e,alt:"Preview",className:"max-w-full max-h-[90vh] object-contain rounded-lg",onClick:g=>g.stopPropagation()})]}),document.body)}function WV(e=640){const[t,n]=k.useState(()=>window.innerWidth<e);return k.useEffect(()=>{const r=window.matchMedia(`(max-width: ${e-1}px)`),o=l=>n(l.matches);return r.addEventListener("change",o),n(r.matches),()=>r.removeEventListener("change",o)},[e]),t}function YV({content:e,contentRef:t}){const{t:n}=dt("common"),[r,o]=k.useState(!1),[l,c]=k.useState(!1),[d,m]=k.useState(!1),[p,h]=k.useState(null),g=k.useRef(null),x=WV();k.useEffect(()=>{if(!r)return;const T=S=>{g.current&&!g.current.contains(S.target)&&(o(!1),c(!1),m(!1))};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[r]);const y=k.useCallback(T=>{h(T),setTimeout(()=>h(null),1500)},[]),w=async()=>{const T=await Ig(e);y(n(T?"markdown.copied":"markdown.failed")),o(!1)},C=async T=>{const S=t.current?.firstElementChild;if(!S)return;const _=x3(),j=wV(_),O=await JG(S,T,e,{fontFamily:j.fontFamily,fontSize:j.fontSize,headingScales:j.headingScales}),P=n(T==="light"?"markdown.themeLight":"markdown.themeDark");y(O.ok?O.method==="html"?n("markdown.htmlCopied",{theme:P}):n("markdown.textCopied"):n("markdown.failed")),o(!1)};return s.jsxs("div",{className:"absolute top-1 right-1 z-10 opacity-0 group-hover/md:opacity-100 transition-opacity",ref:g,children:[p&&s.jsx("div",{className:"absolute right-0 top-full mt-1 z-20 px-2 py-0.5 rounded bg-surface-elevated border border-border-default text-[10px] text-fg-secondary whitespace-nowrap shadow-lg",children:p}),s.jsx("button",{onClick:()=>o(T=>!T),className:"p-1.5 rounded-lg bg-surface-elevated/80 hover:bg-surface-overlay text-fg-secondary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all",title:n("markdown.copyContent"),children:s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.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"})})}),r&&s.jsx("div",{className:"absolute right-0 top-full mt-1 bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 min-w-[180px]",children:d?s.jsx(kV,{onClose:()=>m(!1)}):l?s.jsxs("div",{className:"px-3 py-2 text-[11px] text-fg-secondary space-y-2 max-w-[260px]",children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsx("span",{className:"font-medium text-fg-primary text-xs",children:n("markdown.infoTitle")}),s.jsx("button",{onClick:()=>c(!1),className:"text-fg-tertiary hover:text-fg-primary p-0.5",children:s.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-fg-primary",children:n("markdown.mdAbbrev")})," — ",n("markdown.infoMdDesc")]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-fg-primary",children:"☀️"})," — ",n("markdown.infoHtmlLightDesc")]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-fg-primary",children:"🌙"})," — ",n("markdown.infoHtmlDarkDesc")]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-1 border-b border-border-subtle mb-1",children:[s.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium",children:n("markdown.copyContent")}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>m(!0),className:"p-0.5 rounded text-fg-tertiary hover:text-fg-primary transition-colors",title:n("markdown.typographySettings"),children:s.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),s.jsx("button",{onClick:()=>c(!0),className:"p-0.5 rounded text-fg-tertiary hover:text-fg-primary transition-colors",title:n("markdown.infoTitle"),children:s.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{strokeLinecap:"round",d:"M12 16v-4m0-4h.01"})]})})]})]}),s.jsxs("button",{onClick:w,className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[s.jsx("span",{className:"w-4 text-center text-fg-tertiary shrink-0 font-mono text-[10px]",children:n("markdown.mdAbbrev")}),n(x?"markdown.copyMdSourceShort":"markdown.copyMdSource")]}),s.jsxs("button",{onClick:()=>C("light"),className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[s.jsx("span",{className:"w-4 text-center shrink-0 text-[10px]",children:"☀️"}),n(x?"markdown.copyHtmlLightShort":"markdown.copyHtmlLight")]}),s.jsxs("button",{onClick:()=>C("dark"),className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[s.jsx("span",{className:"w-4 text-center shrink-0 text-[10px]",children:"🌙"}),n(x?"markdown.copyHtmlDarkShort":"markdown.copyHtmlDark")]})]})})]})}const Er=k.memo(function({content:t,className:n="",onMentionClick:r,knownNames:o,basePath:l}){const{thinking:c,rest:d}=LV(t),m=k.useRef(null),[p,h]=k.useState(null),g=Ec(),x=k.useCallback(T=>{let S=Yl(T,eV);return S=Yl(S,bV),S=Yl(S,sV),S=Yl(S,iV),S=Yl(S,_=>tV(_,o)),S},[o]),y=k.useMemo(()=>x(d),[d,x]),w=k.useCallback((T,S)=>{const _=Y2(S,l);if(_.kind!=="passthrough"){if(T.preventDefault(),T.stopPropagation(),_.kind==="fragment"){xV(m.current,_.id);return}if(_.kind==="file"){g?.hostAvailable?g.openRightPanel({kind:"file",path:_.path,title:_.path.split(/[/\\]/).pop()}):Ce.files.reveal(_.path).catch(()=>{});return}if(_.kind==="external"){if(g?.hostAvailable&&/^https?:\/\//i.test(_.url)){g.openRightPanel({kind:"url",url:_.url,title:_.url});return}Ai(_.url)}}},[l,g]),C=k.useMemo(()=>({...BV,img:({src:T,alt:S})=>s.jsx(qV,{src:T??"",alt:S,onPreview:h,basePath:l},T??""),p:({children:T,node:S})=>{const _=zV(S);return _?s.jsx(jV,{id:_.id,type:_.type,label:_.label}):s.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:T})},a:({href:T,children:S})=>{if(T?.startsWith(t4)){const j=decodeURIComponent(T.slice(t4.length));return s.jsx("span",{className:`text-brand-500 font-medium${r?" cursor-pointer hover:underline":""}`,onClick:r?O=>{O.preventDefault(),O.stopPropagation(),r(j,O)}:void 0,title:j,children:S})}if(T?.startsWith(m0))return s.jsx(sc,{id:T.slice(m0.length)});{const j=T?.match(C3);if(j){const[,O,P]=j;if(O==="workflow")return s.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:$=>{$.preventDefault(),$.stopPropagation(),at.navigate(me.WORK,{boardType:"workflows"})},title:`workflow: ${P}`,children:[s.jsx("span",{className:"text-[10px]",children:"⚙️"}),s.jsx("span",{children:S})]});const D=y3(O);if(D)return s.jsx(sc,{id:P,type:D,label:S})}}if(T&&d0(T))return s.jsx(sc,{id:T.trim(),label:S});const _=Y2(T,l);return _.kind==="fragment"||_.kind==="file"||_.kind==="external"?s.jsx("a",{href:T,className:$h,onClick:j=>w(j,T),title:_.kind==="fragment"?`#${_.id}`:_.kind==="file"?_.path:_.url,children:S}):s.jsx("a",{href:T,className:$h,onClick:j=>{pc()&&T&&!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(T)&&j.preventDefault()},children:S})}}),[r,l,w]);return s.jsxs("div",{className:"relative group/md",children:[s.jsx(YV,{content:t,contentRef:m}),s.jsx("div",{ref:m,children:s.jsx(MV,{resetKeys:[y],fallback:s.jsx("div",{className:`prose prose-sm max-w-none break-words whitespace-pre-wrap pr-8 text-fg-secondary ${n}`,children:d}),children:s.jsxs("div",{className:`prose prose-sm max-w-none break-words pr-8 text-fg-secondary ${n}`,children:[c.length>0&&(()=>{const T=c.join(`
|
|
649
649
|
|
|
650
650
|
`),S=T.split(`
|
|
651
651
|
`)[0]??"",_=S.length>80?S.slice(0,80)+"…":S;return s.jsxs("details",{className:"mb-3 rounded-lg bg-surface-elevated/60 border border-border-default/50 overflow-hidden group/think",children:[s.jsxs("summary",{className:"cursor-pointer select-none px-3 py-2 text-xs text-fg-secondary hover:text-fg-secondary transition-colors flex items-center gap-1.5 min-w-0",children:[s.jsx("svg",{className:"w-3 h-3 shrink-0 transition-transform group-open/think:rotate-90",viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z",clipRule:"evenodd"})}),s.jsx("span",{className:"shrink-0",children:"Thinking"}),s.jsx("span",{className:"truncate text-fg-tertiary ml-1 group-open/think:hidden",children:_})]}),s.jsx("div",{className:"px-3 pb-3 border-t border-border-default/50",children:s.jsx("div",{className:"mt-2 pl-3 border-l-2 border-brand-500/40 text-xs text-fg-secondary leading-relaxed",children:s.jsx(wh,{remarkPlugins:J2,rehypePlugins:e4,components:C,urlTransform:Z2,children:x(T)})})})]})})(),s.jsx(wh,{remarkPlugins:J2,rehypePlugins:e4,components:C,urlTransform:Z2,children:y})]})})}),p&&s.jsx(KV,{src:p,onClose:()=>h(null)})]})},(e,t)=>e.content===t.content&&e.className===t.className&&e.basePath===t.basePath&&e.onMentionClick===t.onMentionClick&&XV(e.knownNames,t.knownNames));function XV(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 T3=Object.freeze(Object.defineProperty({__proto__:null,MarkdownMessage:Er},Symbol.toStringTag,{value:"Module"})),Fh={suppressAdjustUntil:0};function vc(e=2500){const t=typeof performance<"u"?performance.now():Date.now();Fh.suppressAdjustUntil=Math.max(Fh.suppressAdjustUntil,t+e)}function oY(){return(typeof performance<"u"?performance.now():Date.now())<Fh.suppressAdjustUntil}const r4={shell_execute:{label:"Running command",icon:"⌨"},file_read:{label:"Reading file",icon:"📄"},file_write:{label:"Writing file",icon:"✏"},file_edit:{label:"Editing file",icon:"✏"},apply_patch:{label:"Applying patch",icon:"🔀"},list_directory:{label:"Listing directory",icon:"📂"},glob_find:{label:"Finding files",icon:"🔍"},grep_search:{label:"Searching code",icon:"🔍"},web_fetch:{label:"Fetching page",icon:"🌐"},web_search:{label:"Searching web",icon:"🔍"},web_extract:{label:"Extracting content",icon:"📑"},create_task:{label:"Creating task",icon:"📌"},task_create:{label:"Creating task",icon:"📌"},create_subtask:{label:"Adding subtask",icon:"📌"},update_task:{label:"Updating task",icon:"✅"},task_update:{label:"Updating task",icon:"✅"},add_task_note:{label:"Adding note",icon:"📝"},task_add_note:{label:"Adding note",icon:"📝"},task_list:{label:"Listing tasks",icon:"📋"},task_get:{label:"Getting task",icon:"📋"},task_note:{label:"Adding note",icon:"📝"},task_assign:{label:"Assigning task",icon:"👥"},task_submit_review:{label:"Submitting for review",icon:"✅"},task_comment:{label:"Commenting task",icon:"💬"},subtask_create:{label:"Adding subtask",icon:"📌"},subtask_complete:{label:"Completing subtask",icon:"✅"},subtask_cancel:{label:"Cancelling subtask",icon:"🚫"},subtask_list:{label:"Listing subtasks",icon:"📋"},requirement_propose:{label:"Proposing requirement",icon:"📋"},requirement_list:{label:"Listing requirements",icon:"📋"},requirement_get:{label:"Getting requirement",icon:"📋"},requirement_update:{label:"Updating requirement",icon:"📋"},requirement_update_status:{label:"Updating req status",icon:"✅"},requirement_resubmit:{label:"Resubmitting requirement",icon:"📋"},requirement_comment:{label:"Commenting requirement",icon:"💬"},list_projects:{label:"Listing projects",icon:"🗂"},get_project:{label:"Getting project",icon:"🗂"},create_project:{label:"Creating project",icon:"🗂"},update_project:{label:"Updating project",icon:"🗂"},deliverable_create:{label:"Creating deliverable",icon:"📦"},deliverable_search:{label:"Searching deliverables",icon:"🔍"},deliverable_list:{label:"Listing deliverables",icon:"📦"},deliverable_update:{label:"Updating deliverable",icon:"📦"},git_status:{label:"Git status",icon:"🔀"},git_diff:{label:"Git diff",icon:"🔀"},git_log:{label:"Git log",icon:"📜"},git_branch:{label:"Git branch",icon:"🌿"},git_add:{label:"Git add",icon:"➕"},git_commit:{label:"Git commit",icon:"💾"},project_structure:{label:"Project structure",icon:"🗂"},code_stats:{label:"Code stats",icon:"📊"},navigate_page:{label:"Opening page",icon:"🌐"},new_page:{label:"Opening new tab",icon:"🌐"},close_page:{label:"Closing tab",icon:"🌐"},select_page:{label:"Switching tab",icon:"🌐"},list_pages:{label:"Listing tabs",icon:"🌐"},click:{label:"Clicking element",icon:"👆"},hover:{label:"Hovering element",icon:"👆"},fill:{label:"Filling field",icon:"⌨"},fill_form:{label:"Filling form",icon:"⌨"},type_text:{label:"Typing text",icon:"⌨"},press_key:{label:"Pressing key",icon:"⌨"},take_screenshot:{label:"Screenshot",icon:"📸"},take_snapshot:{label:"Page snapshot",icon:"📋"},evaluate_script:{label:"Running script",icon:"⚙"},wait_for:{label:"Waiting",icon:"⏳"},list_console_messages:{label:"Console logs",icon:"🔍"},list_network_requests:{label:"Network requests",icon:"🔍"},lighthouse_audit:{label:"Running audit",icon:"📊"},agent_send_message:{label:"Messaging colleague",icon:"💬"},agent_list_colleagues:{label:"Checking team",icon:"👥"},memory_save:{label:"Saving memory",icon:"💾"},memory_search:{label:"Searching memory",icon:"🔍"},memory_list:{label:"Listing memory",icon:"💾"},memory_update:{label:"Updating memory",icon:"💾"},recall_activity:{label:"Recalling activity",icon:"📜"},update_working_memory:{label:"Updating notes",icon:"📝"},notify_user:{label:"Notifying user",icon:"🔔"},request_user_input:{label:"Requesting input",icon:"❓"},request_user_approval:{label:"Requesting approval",icon:"❓"},schedule_wakeup:{label:"Scheduling wakeup",icon:"⏰"},cancel_wakeup:{label:"Cancelling wakeup",icon:"⏰"},set_heartbeat_interval:{label:"Setting heartbeat",icon:"⏱"},discover_tools:{label:"Discovering tools",icon:"🧰"},check_mailbox:{label:"Checking mailbox",icon:"📥"},goal_create:{label:"Creating goal",icon:"🎯"},goal_update:{label:"Updating goal",icon:"🎯"},goal_status:{label:"Goal status",icon:"🎯"},background_exec:{label:"Background command",icon:"⌨"},process:{label:"Managing process",icon:"⚙"},feishu_send_message:{label:"Sending Feishu msg",icon:"✉"},feishu_search_docs:{label:"Searching Feishu",icon:"🔍"},spawn_subagent:{label:"Spawn Subagent",icon:"◎"},spawn_subagents:{label:"Spawn Subagents",icon:"◎"},invoke_coding_tool:{label:"Invoke Coding Tool",icon:"🛠"},coding_tool_apply:{label:"Apply Coding Result",icon:"🔀"},generate_image:{label:"Generating image",icon:"🖼"},text_to_speech:{label:"Generating speech",icon:"🔊"},speech_to_text:{label:"Transcribing audio",icon:"🎙"},generate_video:{label:"Generating video",icon:"🎬"},llm_list_providers:{label:"Listing providers",icon:"⚙"},llm_switch_model:{label:"Switching model",icon:"⚙"},llm_switch_default_provider:{label:"Switching provider",icon:"⚙"},llm_add_provider:{label:"Adding provider",icon:"⚙"},llm_edit_provider:{label:"Editing provider",icon:"⚙"},llm_add_model:{label:"Adding model",icon:"⚙"},llm_get_capability_routing:{label:"Checking capability routing",icon:"⚙"},llm_set_capability_routing:{label:"Setting capability routing",icon:"⚙"},team_list:{label:"Listing teams",icon:"👥"},team_status:{label:"Team status",icon:"👥"},team_start:{label:"Starting team",icon:"👥"},team_stop:{label:"Stopping team",icon:"👥"},team_update:{label:"Updating team",icon:"👥"},agent_start:{label:"Starting agent",icon:"◎"},agent_stop:{label:"Stopping agent",icon:"◎"},agent_update:{label:"Updating agent",icon:"◎"},agent_delegate_task:{label:"Delegating task",icon:"📌"},agent_broadcast_status:{label:"Broadcasting status",icon:"📣"},agent_create_group_chat:{label:"Creating group chat",icon:"💬"},agent_list_group_chats:{label:"Listing group chats",icon:"💬"},agent_send_group_message:{label:"Sending group message",icon:"💬"},delete_project:{label:"Deleting project",icon:"🗂"},project_stats:{label:"Project stats",icon:"📊"},hub_search:{label:"Searching Hub",icon:"🔍"},hub_install:{label:"Installing from Hub",icon:"📦"},package_list:{label:"Listing packages",icon:"📦"},package_install:{label:"Installing package",icon:"📦"},memory_delete:{label:"Deleting memory",icon:"💾"},memory_update_longterm:{label:"Updating long-term memory",icon:"💾"},clear_working_memory:{label:"Clearing notes",icon:"📝"},clear_notebook:{label:"Clearing notebook",icon:"📝"},update_notebook:{label:"Updating notebook",icon:"📝"},recall_context:{label:"Recalling context",icon:"📜"},defer_mailbox_item:{label:"Deferring mailbox item",icon:"📥"},drop_mailbox_item:{label:"Dropping mailbox item",icon:"📥"},prioritize_mailbox_item:{label:"Prioritizing mailbox",icon:"📥"},delegate_message:{label:"Delegating message",icon:"💬"},task_board_health:{label:"Checking task board",icon:"📋"},task_check_duplicates:{label:"Checking duplicates",icon:"📋"},task_cleanup_duplicates:{label:"Cleaning duplicates",icon:"📋"},workflow_list:{label:"Listing workflows",icon:"🔄"},workflow_create:{label:"Creating workflow",icon:"🔄"},workflow_update:{label:"Updating workflow",icon:"🔄"},workflow_delete:{label:"Deleting workflow",icon:"🔄"},workflow_run:{label:"Running workflow",icon:"🔄"},workflow_status:{label:"Workflow status",icon:"🔄"},workflow_cancel:{label:"Cancelling workflow",icon:"🔄"},open_page:{label:"Opening page",icon:"🌐"},resize_page:{label:"Resizing page",icon:"🌐"},drag:{label:"Dragging element",icon:"👆"},upload_file:{label:"Uploading file",icon:"📎"},emulate:{label:"Emulating device",icon:"📱"},handle_dialog:{label:"Handling dialog",icon:"💬"},get_console_message:{label:"Console message",icon:"🔍"},get_network_request:{label:"Network request",icon:"🔍"}},a4={shell_execute:"square-terminal",background_exec:"square-terminal",process:"settings",file_read:"file-text",file_write:"edit",file_edit:"edit",apply_patch:"git-branch",list_directory:"folder",glob_find:"search",grep_search:"search",web_fetch:"globe",web_search:"search",web_extract:"file-text",create_task:"clipboard",task_create:"clipboard",create_subtask:"clipboard",update_task:"check-circle",task_update:"check-circle",add_task_note:"edit",task_add_note:"edit",task_note:"edit",task_list:"clipboard",task_get:"clipboard",task_assign:"users",task_submit_review:"check-circle",task_comment:"message-square",subtask_create:"clipboard",subtask_complete:"check-circle",subtask_cancel:"alert-circle",subtask_list:"clipboard",requirement_propose:"clipboard",requirement_list:"clipboard",requirement_get:"clipboard",requirement_update:"clipboard",requirement_update_status:"check-circle",requirement_resubmit:"clipboard",requirement_comment:"message-square",list_projects:"layers",get_project:"layers",create_project:"layers",update_project:"layers",deliverable_create:"package",deliverable_search:"search",deliverable_list:"package",deliverable_update:"edit",git_status:"git-branch",git_diff:"git-branch",git_log:"book-open",git_branch:"git-branch",git_add:"git-branch",git_commit:"save",project_structure:"layers",code_stats:"bar-chart",navigate_page:"globe",new_page:"globe",close_page:"globe",select_page:"globe",list_pages:"globe",click:"target",hover:"target",fill:"terminal",fill_form:"terminal",type_text:"terminal",press_key:"terminal",take_screenshot:"camera",take_snapshot:"camera",evaluate_script:"code",wait_for:"clock",list_console_messages:"terminal",list_network_requests:"globe",lighthouse_audit:"bar-chart",agent_send_message:"message-square",agent_list_colleagues:"users",memory_save:"database",memory_search:"search",memory_list:"database",memory_update:"database",recall_activity:"book-open",update_working_memory:"edit",notify_user:"megaphone",request_user_input:"message-square",request_user_approval:"check-circle",schedule_wakeup:"clock",cancel_wakeup:"clock",set_heartbeat_interval:"clock",discover_tools:"wrench",check_mailbox:"message-square",goal_create:"target",goal_update:"target",goal_status:"target",feishu_send_message:"message-square",feishu_search_docs:"search",spawn_subagent:"bot",spawn_subagents:"bot",invoke_coding_tool:"wrench",coding_tool_apply:"git-branch",generate_image:"camera",text_to_speech:"headphones",speech_to_text:"headphones",generate_video:"camera",llm_list_providers:"settings",llm_switch_model:"settings",llm_switch_default_provider:"settings",llm_add_provider:"settings",llm_edit_provider:"settings",llm_add_model:"settings",llm_get_capability_routing:"settings",llm_set_capability_routing:"settings",team_list:"users",team_status:"users",team_start:"users",team_stop:"users",team_update:"users",agent_start:"bot",agent_stop:"bot",agent_update:"bot",agent_delegate_task:"clipboard",agent_broadcast_status:"megaphone",agent_create_group_chat:"message-square",agent_list_group_chats:"message-square",agent_send_group_message:"message-square",delete_project:"layers",project_stats:"bar-chart",hub_search:"search",hub_install:"package",package_list:"package",package_install:"package",memory_delete:"database",memory_update_longterm:"database",clear_working_memory:"edit",clear_notebook:"edit",update_notebook:"edit",recall_context:"book-open",defer_mailbox_item:"message-square",drop_mailbox_item:"message-square",prioritize_mailbox_item:"message-square",delegate_message:"message-square",task_board_health:"clipboard",task_check_duplicates:"clipboard",task_cleanup_duplicates:"clipboard",workflow_list:"git-branch",workflow_create:"git-branch",workflow_update:"git-branch",workflow_delete:"git-branch",workflow_run:"git-branch",workflow_status:"git-branch",workflow_cancel:"git-branch",open_page:"globe",resize_page:"globe",drag:"target",upload_file:"file-text",emulate:"settings",handle_dialog:"message-square",get_console_message:"terminal",get_network_request:"globe"};function Ci(e){const t=e.includes("__")?e.split("__").pop():e,n=r4[t]??r4[e],r=a4[t]??a4[e]??"settings";return n?{...n,iconName:r,key:t}:{label:t.replace(/_/g," ").replace(/\b\w/g,o=>o.toUpperCase()),icon:"⚙",iconName:r,key:t}}function Po(e){return e==null?"":e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function QV(e){const t=new Date(e);if(isNaN(t.getTime()))return e;const n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0"),o=String(t.getHours()).padStart(2,"0"),l=String(t.getMinutes()).padStart(2,"0"),c=String(t.getSeconds()).padStart(2,"0");return`${n}-${r} ${o}:${l}:${c}`}function qh(e,t){return e.length<=t?e:e.slice(0,t)+"…"}function s4(e){try{const t=JSON.parse(e);return JSON.stringify(t,null,2)}catch{return e}}function A3(e){return!e||typeof e!="object"?[]:Object.entries(e).filter(([,n])=>n!=null).map(([n,r])=>({key:n,value:typeof r=="string"?r:JSON.stringify(r,null,2)}))}function ZV(e){if(e.tool!=="shell_execute"||!e.args||typeof e.args!="object")return null;const t=e.args.command;return typeof t=="string"?t:null}function lY(e,t){const n=new Map;let r=null;for(const o of e)if(o.type==="tool_start"&&(o.content==="spawn_subagent"||o.content==="spawn_subagents"))r=o.seq,n.set(o.seq,[]);else if(o.type==="tool_end"&&(o.content==="spawn_subagent"||o.content==="spawn_subagents")){if(r!==null){const l=n.get(r);l&&n.set(o.seq,l)}r=null}else if(r!==null&&o.type.startsWith("subagent_")){const l=o.type.replace("subagent_",""),c=o.metadata;n.get(r)?.push({eventType:l,content:o.content,metadata:c})}return t.map(o=>{if(o.type!=="tool")return o;const l=o.key;if(!l)return o;const c=l.replace(/^(?:t[se]_|e[se]_)/,""),d=parseInt(c,10);if(isNaN(d))return o;const m=n.get(d);return!m||m.length===0?o:{...o,info:{...o.info,subagentLogs:m}}})}function i4(e){const t=new Set;for(let n=0;n<e.length;n++){const r=e[n];if(r.type==="tool"&&(r.info.status==="done"||r.info.status==="error"))for(let o=n-1;o>=0;o--){const l=e[o];if(l.type==="tool"&&l.info.status==="running"&&l.info.tool===r.info.tool&&!t.has(o)){t.add(o);break}}}return e.filter((n,r)=>!t.has(r))}function E3(e){const t=QV(e.createdAt),n=e.createdAt,r=e.metadata;switch(e.type){case"text":return r?.isThinking?{type:"thinking",content:e.content,time:t,timestamp:n}:{type:"text",content:e.content,time:t,timestamp:n};case"status":{const o=r?.action;return o&&["chat","chat_stream","task_execution","respond_in_session"].includes(o)?null:{type:"status",content:e.content,time:t,timestamp:n}}case"error":return{type:"error",content:e.content,time:t,timestamp:n};case"tool_start":return{type:"tool",time:t,timestamp:n,key:`es_${e.seq}`,info:{tool:e.content,status:"running",args:r?.arguments,subagentLogs:r?.subagentLogs}};case"tool_end":return{type:"tool",time:t,timestamp:n,key:`ee_${e.seq}`,info:{tool:e.content,status:r?.success===!1?"error":"done",args:r?.arguments,result:r?.result,error:r?.error,durationMs:r?.durationMs,subagentLogs:r?.subagentLogs}};default:return null}}function _3(e,t){if(e!=="task_create"&&e!=="create_task"||!t)return null;try{const n=JSON.parse(t);if(!n.task)return null;const r=n.task;return{taskId:r.id,title:r.title,description:r.description,assignedAgentId:r.assignedAgentId,priority:r.priority}}catch{return null}}function j3(e,t){if(e!=="requirement_propose"||!t)return null;try{const n=JSON.parse(t);if(n.status!=="success"||!n.requirement)return null;const r=n.requirement;return r.status!=="pending"?null:{requirementId:r.id,title:r.title,description:r.description,priority:r.priority}}catch{return null}}const M3={code:s.jsxs(s.Fragment,{children:[s.jsx("polyline",{points:"16 18 22 12 16 6"}),s.jsx("polyline",{points:"8 6 2 12 8 18"})]}),search:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("path",{d:"m21 21-4.3-4.3"})]}),clipboard:s.jsxs(s.Fragment,{children:[s.jsx("rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}),s.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":s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"m9 12 2 2 4-4"})]}),server:s.jsxs(s.Fragment,{children:[s.jsx("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),s.jsx("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),s.jsx("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),s.jsx("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]}),"file-text":s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),s.jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),s.jsx("path",{d:"M10 9H8"}),s.jsx("path",{d:"M16 13H8"}),s.jsx("path",{d:"M16 17H8"})]}),"book-open":s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 7v14"}),s.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:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),s.jsx("circle",{cx:"9",cy:"7",r:"4"}),s.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),s.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),"dollar-sign":s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"12",x2:"12",y1:"2",y2:"22"}),s.jsx("path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"})]}),megaphone:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"m3 11 18-5v12L3 14v-3z"}),s.jsx("path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6"})]}),edit:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 20h9"}),s.jsx("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4Z"})]}),headphones:s.jsx(s.Fragment,{children:s.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:s.jsxs(s.Fragment,{children:[s.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"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),target:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("circle",{cx:"12",cy:"12",r:"6"}),s.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),zap:s.jsx(s.Fragment,{children:s.jsx("polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2"})}),terminal:s.jsxs(s.Fragment,{children:[s.jsx("polyline",{points:"4 17 10 11 4 5"}),s.jsx("line",{x1:"12",x2:"20",y1:"19",y2:"19"})]}),sparkles:s.jsxs(s.Fragment,{children:[s.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"}),s.jsx("path",{d:"M20 3v4"}),s.jsx("path",{d:"M22 5h-4"})]}),wrench:s.jsx(s.Fragment,{children:s.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:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"}),s.jsx("path",{d:"M2 12h20"})]}),link:s.jsxs(s.Fragment,{children:[s.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"}),s.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:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 8V4H8"}),s.jsx("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),s.jsx("path",{d:"M2 14h2"}),s.jsx("path",{d:"M20 14h2"}),s.jsx("path",{d:"M15 13v2"}),s.jsx("path",{d:"M9 13v2"})]}),"message-square":s.jsx(s.Fragment,{children:s.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:s.jsxs(s.Fragment,{children:[s.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"}),s.jsx("path",{d:"M18 14h-8"}),s.jsx("path",{d:"M15 18h-5"}),s.jsx("path",{d:"M10 6h8v4h-8V6Z"})]}),layers:s.jsxs(s.Fragment,{children:[s.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"}),s.jsx("path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65"}),s.jsx("path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65"})]}),"bar-chart":s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"12",x2:"12",y1:"20",y2:"10"}),s.jsx("line",{x1:"18",x2:"18",y1:"20",y2:"4"}),s.jsx("line",{x1:"6",x2:"6",y1:"20",y2:"16"})]}),folder:s.jsx(s.Fragment,{children:s.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":s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"6",x2:"6",y1:"3",y2:"15"}),s.jsx("circle",{cx:"18",cy:"6",r:"3"}),s.jsx("circle",{cx:"6",cy:"18",r:"3"}),s.jsx("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),save:s.jsxs(s.Fragment,{children:[s.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"}),s.jsx("path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7"}),s.jsx("path",{d:"M7 3v4a1 1 0 0 0 1 1h7"})]}),camera:s.jsxs(s.Fragment,{children:[s.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"}),s.jsx("circle",{cx:"12",cy:"13",r:"3"})]}),clock:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),database:s.jsxs(s.Fragment,{children:[s.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),s.jsx("path",{d:"M3 5v14a9 3 0 0 0 18 0V5"}),s.jsx("path",{d:"M3 12a9 3 0 0 0 18 0"})]}),lightbulb:s.jsxs(s.Fragment,{children:[s.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"}),s.jsx("path",{d:"M9 18h6"}),s.jsx("path",{d:"M10 22h4"})]}),"alert-circle":s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),s.jsx("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]}),"square-terminal":s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"m7 11 2-2-2-2"}),s.jsx("path",{d:"M11 13h4"}),s.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"})]}),package:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"m7.5 4.27 9 5.15"}),s.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"}),s.jsx("path",{d:"m3.3 7 8.7 5 8.7-5"}),s.jsx("path",{d:"M12 22V12"})]})};function JV(e){return!!e&&e in M3}function Vo({name:e,size:t=24,className:n=""}){const r=M3[e];return r?s.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:r}):null}const o4={"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"},l4={development:"code",开发工具:"code",devops:"server",data:"bar-chart",数据分析:"bar-chart",productivity:"zap",效率提升:"zap",communication:"message-square",通讯协作:"message-square",browser:"globe",内容创作:"edit","AI 智能":"sparkles"};function Bd(e,t){const n=(e||"").toLowerCase();return o4[n]?o4[n]:t&&l4[t]?l4[t]:"layers"}function eK(e){const t=[];for(const n of e)if(n.phase!=="output"){if(n.phase==="start"){const r=`${n.tool}_${n.ts}`;t.push({key:r,tool:n.tool,status:"running"})}else for(let r=t.length-1;r>=0;r--)if(t[r].tool===n.tool&&t[r].status==="running"){t[r]={...t[r],status:n.success===!1?"error":"done"};break}}return t}function R3(){return s.jsxs("svg",{className:"w-3 h-3 animate-spin text-brand-500 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}function tK(){return s.jsx("span",{className:"flex items-center gap-0.5",children:[0,150,300].map(e=>s.jsx("span",{className:"w-1 h-1 rounded-full bg-brand-400 animate-bounce",style:{animationDelay:`${e}ms`,animationDuration:"1s"}},e))})}function c4({item:e}){const{t}=dt("common"),n=Ci(e.tool);return s.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[s.jsx(Vo,{name:n.iconName,size:15,className:`shrink-0 ${e.status==="running"?"text-brand-500":e.status==="error"?"text-red-500":"text-green-500"}`}),s.jsxs("span",{className:`text-xs ${e.status==="running"?"activity-text-shimmer":e.status==="error"?"text-fg-tertiary":"text-fg-secondary"}`,children:[t(`execution.tools.${n.key}`,{defaultValue:n.label}),e.status==="running"?"…":""]}),e.status==="running"&&s.jsx(R3,{})]})}function nK({activities:e,isActive:t,persistent:n}){const{t:r}=dt("common"),o=eK(e),[l,c]=k.useState(!1),d=o.length>0,m=d&&o.every(w=>w.status!=="running");if(n&&m){const w=o.filter(T=>T.status==="error").length,C=o.filter(T=>T.status==="done").length;return s.jsxs("div",{className:"mb-3 border-b border-border-default/50 pb-2",children:[s.jsxs("button",{onClick:()=>c(T=>!T),className:"flex items-center gap-1.5 text-xs text-fg-tertiary hover:text-fg-secondary transition-colors select-none",children:[s.jsx("span",{className:`transition-transform duration-150 ${l?"rotate-90":""}`,children:"▶"}),s.jsx("span",{className:"font-medium",children:r("activity.step",{count:C})}),w>0&&s.jsxs("span",{className:"text-red-500 ml-0.5",children:["· ",r("activity.failed",{count:w})]}),!l&&s.jsxs("span",{className:"ml-1 flex items-center gap-1",children:[o.slice(0,5).map(T=>{const S=Ci(T.tool);return s.jsx(Vo,{name:S.iconName,size:13,className:`shrink-0 ${T.status==="error"?"text-red-500":"text-green-500"}`},T.key)}),o.length>5&&s.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["+",o.length-5]})]})]}),l&&s.jsx("div",{className:"mt-2 space-y-0.5",children:o.map((T,S)=>s.jsx(c4,{item:T,idx:S,total:o.length},T.key))})]})}if(!d)return s.jsxs("div",{className:"flex items-center gap-1.5 text-xs py-0.5",children:[s.jsx("span",{className:"mr-0.5 activity-text-shimmer",children:r("activity.thinking")}),s.jsx(tK,{})]});const p=o.filter(w=>w.status==="error").length;let h=null;for(let w=o.length-1;w>=0;w--)if(o[w].status==="running"){h=o[w];break}const g=o[o.length-1];let x;if(h){const w=Ci(h.tool);x=`${r(`execution.tools.${w.key}`,{defaultValue:w.label})}…`}else if(t&&m)x=r("activity.writingResponse");else{const w=Ci(g.tool);x=r(`execution.tools.${w.key}`,{defaultValue:w.label})}const y=!!h||t&&m;return s.jsxs("div",{className:"mb-1",children:[s.jsxs("button",{onClick:w=>{w.stopPropagation(),c(C=>!C)},className:"flex items-center gap-1.5 text-xs w-full min-w-0 select-none text-fg-tertiary hover:text-fg-secondary transition-colors",children:[s.jsx("span",{className:`shrink-0 transition-transform duration-150 ${l?"rotate-90":""}`,children:"▶"}),s.jsx("span",{className:`truncate font-medium ${y?"activity-text-shimmer":"text-fg-secondary"}`,children:x}),s.jsxs("span",{className:"shrink-0",children:["· ",r("activity.step",{count:o.length})]}),p>0&&s.jsxs("span",{className:"text-red-500 shrink-0",children:["· ",r("activity.failed",{count:p})]}),y&&s.jsx(R3,{})]}),l&&s.jsx("div",{className:"mt-1 space-y-0.5",children:o.map((w,C)=>s.jsx(c4,{item:w,idx:C,total:o.length},w.key))})]})}const rK={"claude-code":{label:"Claude Code",icon:"🤖",badgeClass:"bg-orange-500/15 text-orange-500"},codex:{label:"Codex",icon:"⬡",badgeClass:"bg-emerald-500/15 text-emerald-500"},"cursor-agent":{label:"Cursor",icon:"▶",badgeClass:"bg-blue-500/15 text-blue-500"}},Ro=["created","context_injected","running"],aK=new Set(["completed","failed","cancelled","timeout"]),u4={created:"Created",context_injected:"Context injected",running:"Running",completed:"Completed",failed:"Failed",cancelled:"Cancelled",timeout:"Timed out"};function sK(e){return rK[e]??{label:e.replace(/-/g," ").replace(/\b\w/g,t=>t.toUpperCase()),icon:"⚙",badgeClass:"bg-surface-elevated text-fg-tertiary"}}function iK(e,t){if(e.cost?.durationMs!=null)return e.cost.durationMs;const n=e.startedAt??e.createdAt,r=new Date(n).getTime();if(!Number.isNaN(r)){if(e.completedAt){const o=new Date(e.completedAt).getTime();return Number.isNaN(o)?void 0:Math.max(0,o-r)}if(e.status==="running"||e.status==="context_injected")return Math.max(0,t-r)}}function oK(e){if(e==="completed"||aK.has(e))return Ro.length;const t=Ro.indexOf(e);return t>=0?t:0}function lK({session:e,className:t}){const n=sK(e.tool),[r,o]=k.useState(!1),[l,c]=k.useState(()=>Date.now()),d=e.status==="running"||e.status==="context_injected"||e.status==="created",m=e.status==="failed"||e.status==="timeout"||e.result?.success===!1,p=e.status==="completed"||e.result?.success===!0;k.useEffect(()=>{if(!d)return;const w=setInterval(()=>c(Date.now()),1e3);return()=>clearInterval(w)},[d]);const h=k.useMemo(()=>iK(e,l),[e,l]),g=oK(e.status),x=e.result?.rawOutput??(p||m?e.result?.summary:void 0),y=d?"border-brand-500/40 bg-brand-500/5":m?"border-red-500/30 bg-red-500/5":p?"border-green-500/30 bg-green-500/5":"border-border-default bg-surface-secondary/30";return s.jsxs("div",{className:`my-2 rounded-lg border ${y} p-3 max-w-2xl transition-colors ${t??""}`,children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"text-sm mt-0.5",children:n.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[s.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${n.badgeClass}`,children:n.label}),s.jsx("span",{className:`text-[10px] font-medium ${d?"text-brand-500":m?"text-red-500":p?"text-green-500":"text-fg-tertiary"}`,children:u4[e.status]??e.status}),h!=null&&s.jsx("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:Po(h)}),e.cost?.estimatedCostUsd!=null&&s.jsxs("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:["$",e.cost.estimatedCostUsd.toFixed(4)]})]}),s.jsx("div",{className:"text-xs text-fg-secondary mt-1 line-clamp-2",children:e.prompt})]}),d&&s.jsxs("svg",{className:"w-3.5 h-3.5 animate-spin text-brand-500 shrink-0 mt-0.5",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})]}),s.jsxs("div",{className:"flex items-center gap-1 mt-3 ml-6",children:[Ro.map((w,C)=>{const T=g>C||g===C&&!d&&p,S=g===C&&d,_=m&&C===Ro.length-1&&e.status!=="completed";return s.jsxs("div",{className:"flex items-center gap-1 flex-1 min-w-0",children:[s.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${_?"bg-red-500":T?"bg-green-500":S?"bg-brand-500 animate-pulse":"bg-gray-600"}`,title:u4[w]}),C<Ro.length-1&&s.jsx("div",{className:`h-px flex-1 ${T?"bg-green-500/50":"bg-border-default/60"}`})]},w)}),s.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${m?"bg-red-500":p?"bg-green-500":"bg-gray-600"}`,title:m?"Failed":"Done"})]}),(e.progressMessage||e.progressPercent!=null)&&d&&s.jsxs("div",{className:"mt-2 ml-6 space-y-1",children:[e.progressPercent!=null&&s.jsx("div",{className:"h-1 bg-surface-elevated rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-brand-500 transition-all duration-300",style:{width:`${Math.min(100,Math.max(0,e.progressPercent))}%`}})}),e.progressMessage&&s.jsx("div",{className:"text-[11px] text-fg-tertiary font-mono truncate",children:e.progressMessage})]}),e.result&&!d&&s.jsxs("div",{className:"mt-2 ml-6 space-y-1.5",children:[e.result.summary&&s.jsx("div",{className:"text-xs text-fg-secondary",children:e.result.summary}),e.result.diffStats&&s.jsxs("div",{className:"flex items-center gap-3 text-[10px] font-mono",children:[s.jsxs("span",{className:"text-fg-tertiary",children:[e.result.diffStats.filesChanged," files"]}),s.jsxs("span",{className:"text-green-500",children:["+",e.result.diffStats.additions]}),s.jsxs("span",{className:"text-red-500",children:["−",e.result.diffStats.deletions]})]}),e.cost&&(e.cost.inputTokens!=null||e.cost.outputTokens!=null)&&s.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[e.cost.inputTokens!=null&&s.jsxs("span",{children:[e.cost.inputTokens.toLocaleString()," in"]}),e.cost.inputTokens!=null&&e.cost.outputTokens!=null&&s.jsx("span",{className:"mx-1",children:"·"}),e.cost.outputTokens!=null&&s.jsxs("span",{children:[e.cost.outputTokens.toLocaleString()," out"]})]})]}),x&&s.jsxs("div",{className:"mt-2 ml-6 border-t border-border-default/30 pt-2",children:[s.jsxs("button",{type:"button",onClick:()=>o(!r),className:"flex items-center gap-1.5 text-[10px] text-fg-tertiary hover:text-fg-secondary transition-colors",children:[s.jsx("svg",{className:`w-3 h-3 transition-transform ${r?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),s.jsx("span",{className:"font-medium uppercase tracking-wider",children:"Raw output"})]}),r&&s.jsx("pre",{className:"mt-2 text-[11px] text-fg-tertiary bg-surface-elevated/70 rounded-lg px-3 py-2 overflow-x-auto max-h-48 overflow-y-auto whitespace-pre-wrap break-all font-mono",children:x})]})]})}function cK({label:e}){const{t}=dt("common");return s.jsxs("div",{className:"flex items-center gap-1.5 text-xs py-0.5",children:[s.jsx("span",{className:"activity-text-shimmer",children:e??t("execution.thinking")}),s.jsx("span",{className:"flex gap-0.5",children:[0,150,300].map(n=>s.jsx("span",{className:"w-1 h-1 rounded-full bg-brand-400 animate-bounce",style:{animationDelay:`${n}ms`,animationDuration:"1s"}},n))})]})}const d4=150;function uK({content:e,className:t}){const[n,r]=k.useState(e),o=k.useRef(0),l=k.useRef(null);k.useEffect(()=>{const d=Date.now(),m=d-o.current;return m>=d4?(o.current=d,r(e)):l.current||(l.current=setTimeout(()=>{o.current=Date.now(),l.current=null,r(e)},d4-m)),()=>{l.current&&(clearTimeout(l.current),l.current=null)}},[e]);const c=k.useMemo(()=>n,[n]);return s.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg px-3 py-2.5 my-1 min-w-0 overflow-hidden",children:[s.jsx(Er,{content:c,className:t??"text-sm text-fg-secondary break-words"}),s.jsx("span",{className:"inline-block w-0.5 h-4 bg-brand-400 animate-pulse ml-0.5 align-middle"})]})}const f0=8e3,yd=120;function Kp({text:e,className:t}){const{t:n}=dt("common"),[r,o]=k.useState(!1),l=e.length>f0,c=!l||r?e:`${e.slice(0,f0)}
|
|
@@ -658,7 +658,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Rn=ze,rn=wt),Ut===void
|
|
|
658
658
|
`;return e.startsWith(r)?e.slice(r.length):e}function pY(e,t=12e4){if(e.length<2)return e;const n=[];for(const r of e){const o=n[n.length-1];if(r.sender==="user"&&o?.sender==="user"&&o.text===r.text&&o.text.length>0&&o.text.length<=500){const l=o.rawCreatedAt?Date.parse(o.rawCreatedAt):NaN,c=r.rawCreatedAt?Date.parse(r.rawCreatedAt):NaN;if(!Number.isFinite(l)||!Number.isFinite(c)||Math.abs(c-l)<=t)continue}n.push(r)}return n}function hY(e,t){const n=e.senderType==="system"||e.senderType==="agent"&&e.text.startsWith("⚠"),r=e.senderType==="human"&&(!t||e.senderId===t);let o=e.text;r&&e.replyToId&&e.replyToSender&&e.replyToText&&(o=I3(o,e.replyToSender,e.replyToText));const l={id:e.id,sender:r?"user":"agent",text:o,time:new Date(e.createdAt).toLocaleTimeString(),rawCreatedAt:e.createdAt,agentName:r?void 0:e.senderName,agentId:r?void 0:e.senderId,isError:n,replyToId:e.replyToId,replyToSender:e.replyToSender,replyToText:e.replyToText},c=e.metadata;if(c?.images?.length&&(l.images=c.images),c&&e.senderType==="agent"){const d=[];if(c.thinking?.length&&d.push({type:"text",content:"",thinking:c.thinking.join(`
|
|
659
659
|
|
|
660
660
|
`)}),c.toolCalls?.length)for(let m=0;m<c.toolCalls.length;m++){const p=c.toolCalls[m];d.push({type:"tool",key:`${p.tool}_${m}`,tool:p.tool,status:p.status==="error"?"error":"done",args:p.arguments,result:p.result,durationMs:p.durationMs})}d.length>0&&(d.push({type:"text",content:e.text}),l.segments=d)}return l}function gY(e,t,n){const r=t?new Date(t):new Date;if(isNaN(r.getTime()))return e;const o=new Date,l=new Date(o.getFullYear(),o.getMonth(),o.getDate()).getTime(),c=r.getTime(),d=r.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"});return c>=l?d:c>=l-864e5?`${n?.yesterday??"Yesterday"} ${d}`:r.toLocaleDateString(void 0,{month:"short",day:"numeric"})+" "+d}function bY(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?"":`${t.getFullYear()}-${t.getMonth()+1}-${t.getDate()}`}function xY(e,t){const n=new Date(e);if(isNaN(n.getTime()))return"";const r=new Date,o=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime(),l=n.getTime();return l>=o?t?.today??"Today":l>=o-864e5?t?.yesterday??"Yesterday":n.toLocaleDateString(void 0,{weekday:"long",year:"numeric",month:"long",day:"numeric"})}function yY(e,t){let n=0,r=null;return((...o)=>{const l=Date.now(),c=t-(l-n);if(c<=0)return r&&(clearTimeout(r),r=null),n=l,e(...o);r||(r=setTimeout(()=>{n=Date.now(),r=null,e(...o)},c))})}function vY({priority:e}){const t=e==="high"||e==="critical";return s.jsxs("div",{className:`inline-flex items-center gap-1 mt-1.5 px-2 py-0.5 rounded-full text-[10px] font-medium ${t?"bg-amber-500/10 text-amber-500 border border-amber-500/20":"bg-brand-500/10 text-brand-400 border border-brand-500/20"}`,children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),s.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),s.jsxs("span",{children:["Notification",e&&e!=="normal"?` · ${e}`:""]})]})}function wY({name:e,agentId:t,agents:n,onViewProfile:r}){const{t:o}=dt(["team","common"]),[l,c]=k.useState(!1),d=k.useRef(null),m=t?n.find(p=>p.id===t):n.find(p=>p.name===e);return k.useEffect(()=>{if(!l)return;const p=h=>{d.current&&!d.current.contains(h.target)&&c(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[l]),m?s.jsxs("span",{ref:d,className:"relative inline-block",children:[s.jsx("button",{onClick:()=>c(!l),className:"text-fg-tertiary hover:text-brand-500 cursor-pointer transition-colors",children:e}),l&&s.jsxs("div",{className:"absolute left-0 top-full mt-1.5 bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-40 w-56 p-3 space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Us,{name:m.name,avatarUrl:m.avatarUrl,size:28,bgClass:"bg-brand-500/15 text-brand-600"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-xs text-fg-primary font-medium truncate",children:m.name}),s.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[m.role," · ",m.agentRole??o("page.workerRole")]})]}),s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${m.status==="working"?"bg-blue-400 animate-pulse":m.status==="error"?"bg-red-400":"bg-green-400"}`})]}),s.jsx("button",{onClick:()=>{c(!1),r?.(m.id)},className:"w-full text-center text-[10px] text-brand-500 hover:text-brand-500 border border-border-default hover:border-gray-600 rounded-lg py-1 transition-colors",children:o("page.viewProfileArrow")})]})]}):s.jsx("span",{children:e})}function kY({agent:e,anchorRect:t,onClose:n,onViewProfile:r}){const{t:o}=dt(["common","team"]),l=k.useRef(null);k.useEffect(()=>{const p=h=>{l.current&&!l.current.contains(h.target)&&n()};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[n]);const c=e.status==="idle"?"bg-green-400":e.status==="working"?"bg-blue-400 animate-pulse":e.status==="error"?"bg-red-400":"bg-gray-500",d=e.status==="idle"?o("common:status.online"):e.status==="working"?o("common:status.working"):e.status==="error"?o("common:status.error"):o("common:status.offline"),m=k.useCallback(p=>{if(!p)return;l.current=p;const h=p.getBoundingClientRect(),g=window.innerWidth,x=window.innerHeight,y=8;h.right>g-y&&(p.style.left=`${Math.max(y,g-h.width-y)}px`),h.left<y&&(p.style.left=`${y}px`),h.bottom>x-y&&(p.style.top=`${Math.max(y,x-h.height-y)}px`)},[]);return s.jsxs("div",{ref:m,className:"fixed z-50 w-64 max-w-[calc(100vw-1rem)] bg-surface-secondary border border-border-default rounded-xl shadow-2xl p-4 space-y-3",style:{top:t.top+40,left:t.left},children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Us,{name:e.name,avatarUrl:e.avatarUrl,size:40,bgClass:"bg-brand-500/15 text-brand-600"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary font-medium truncate",children:e.name}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:e.role}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c}`}),s.jsx("span",{className:"text-[10px] text-fg-secondary",children:d}),e.agentRole&&s.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["· ",e.agentRole]})]})]})]}),s.jsx("button",{onClick:()=>{n(),r(e.id)},className:"w-full py-1.5 text-xs text-brand-500 hover:text-brand-500 border border-border-default hover:border-gray-600 rounded-lg transition-colors text-center",children:o("team:page.viewProfileArrow")})]})}function AK(e){const t=String(e);return t.includes("MARKUS_UPSTREAM_ERROR")?!1:t.includes("CU_EXCEEDED")||t.includes("CU_MONTHLY_EXCEEDED")}const P3="markus:credit-notif-muted";let b4=0;function SY(){try{if(localStorage.getItem(P3))return}catch{}const e=Date.now();e-b4<5*6e4||(b4=e,window.dispatchEvent(new CustomEvent("markus:credit-exhausted")))}function EK(){try{localStorage.setItem(P3,"1")}catch{}}function NY(e,t){const n=String(e);if(n.includes("AbortError")||n.includes("abort"))return"";let r="";const o=n.match(/\{[\s\S]*\}/);if(o)try{const d=JSON.parse(o[0]);r=d.error?.message??d.message??""}catch{}if(!r){const d=n.lastIndexOf(": ");d>=0&&(r=n.slice(d+2).trim())}const l=(d,m)=>t(`team:errors.${d}`,m);if(n.includes("MARKUS_UPSTREAM_ERROR"))return l("aiUpstreamBillingMismatch",{detail:r||l("defaultUpstreamBillingMismatch")});if(AK(n)||n.includes("CU_EXCEEDED"))return l("markusCuExceeded");if(n.includes("CU_WINDOW_EXCEEDED"))return l("markusWindowExceeded");if(n.includes("MARKUS_RATE_LIMITED"))return l("markusRateLimited");if(/not available in your region/i.test(n))return l("aiRegionBlocked",{model:(n.match(/\[(?:markus|openrouter):([^\]]+)\]/i)?.[1]||"").trim()||"—"});if(n.includes("401")||/unauthorized|invalid.?api.?key/i.test(n))return l("ai401",{detail:r||l("defaultInvalidApiKey")});if(n.includes("429")||/rate.?limit/i.test(n))return l("ai429",{detail:r||l("defaultTooManyRequests")});if(/\b409\b/.test(n)||/conflict/i.test(n))return l("ai409",{detail:r||l("defaultConflict")});if(n.includes("502")||/bad.?gateway/i.test(n))return l("ai502",{detail:r||l("defaultUpstreamDown")});if(n.includes("503")||/service.?unavailable/i.test(n))return l("ai503",{detail:r||l("defaultServiceDown")});const c=(r||n).replace(/https?:\/\/[^\s]*openrouter\.ai[^\s]*/gi,"").trim();return l("aiGeneric",{detail:(c||n).slice(0,120)})}function CY({msg:e,onCopy:t,onRetry:n,onResume:r,onReply:o,onRemember:l,isCopied:c,isLastAgentMsg:d,showRemember:m}){const{t:p}=dt(["team","common"]),h=e.isError||e.sender==="agent"&&e.text.startsWith("⚠"),g=e.isStopped,x=!!e.emptyReply||e.sender==="agent"&&!e.text?.trim()&&!e.segments?.some(C=>C.type==="text"&&(C.content||C.thinking)||C.type==="tool"),y=d!==!1,w=wK(m,e.sender)&&!!l;return s.jsxs("div",{className:"flex items-center flex-wrap gap-0.5 mt-1",children:[s.jsxs("button",{onClick:()=>t(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-fg-tertiary hover:text-fg-primary hover:bg-surface-overlay/60 transition-colors",title:p("common:copy"),children:[c?s.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})}):s.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),s.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),p(c?"common:copied":"common:copy")]}),y&&r&&s.jsxs("button",{onClick:()=>r(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-green-500 hover:text-green-400 hover:bg-green-500/10 transition-colors",title:p("page.messageActions.resumeTitle"),children:[s.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),p("page.messageActions.resumeTitle")]}),y&&g&&n&&s.jsxs("button",{onClick:()=>n(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-brand-500 hover:text-brand-500 hover:bg-brand-500/10 transition-colors",title:p("page.messageActions.reaskTitle"),children:[s.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("polyline",{points:"23 4 23 10 17 10"}),s.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),p("page.messageActions.reaskTitle")]}),y&&(h||x)&&!g&&n&&s.jsxs("button",{onClick:()=>n(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-amber-600 hover:text-amber-600 hover:bg-amber-500/10 transition-colors",title:p("page.messageActions.retryTitle"),children:[s.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("polyline",{points:"23 4 23 10 17 10"}),s.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),p("page.messageActions.retryTitle")]}),y&&!h&&!x&&!g&&e.sender==="agent"&&n&&s.jsxs("button",{onClick:()=>n(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-fg-tertiary hover:text-fg-primary hover:bg-surface-overlay/60 transition-colors",title:p("page.messageActions.retryTitle"),children:[s.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("polyline",{points:"23 4 23 10 17 10"}),s.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),p("page.messageActions.retryTitle")]}),o&&s.jsxs("button",{onClick:()=>o(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-fg-tertiary hover:text-fg-primary hover:bg-surface-overlay/60 transition-colors",title:p("page.messageActions.replyTitle"),children:[s.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("polyline",{points:"9 17 4 12 9 7"}),s.jsx("path",{d:"M20 18v-2a4 4 0 00-4-4H4"})]}),p("page.messageActions.replyTitle")]}),w&&s.jsxs("button",{type:"button",onClick:()=>l(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-fg-tertiary hover:text-fg-primary hover:bg-surface-overlay/60 transition-colors",title:p("page.messageActions.rememberTitle"),children:[s.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M12 2a7 7 0 00-4 12.7V19a1 1 0 001 1h6a1 1 0 001-1v-4.3A7 7 0 0012 2z"}),s.jsx("path",{d:"M9 22h6"})]}),p("page.messageActions.rememberTitle")]}),e.sender==="agent"&&s.jsx("span",{className:"ml-1 px-1 text-[10px] leading-none text-fg-tertiary/70 select-none whitespace-nowrap",children:p("page.messageActions.aiGeneratedDisclaimer")})]})}function TY({busy:e,onConfirm:t,onCancel:n}){const{t:r}=dt(["team","common"]),[o,l]=k.useState("");return Sa.createPortal(s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10050] p-4",onClick:n,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[400px] max-w-[calc(100vw-2rem)] shadow-2xl",onClick:c=>c.stopPropagation(),children:[s.jsx("h3",{className:"font-semibold text-base text-fg-primary",children:r("page.messageActions.rememberModalTitle")}),s.jsx("p",{className:"text-sm text-fg-secondary mt-1.5 leading-relaxed",children:r("page.messageActions.rememberModalHint")}),s.jsx("textarea",{value:o,onChange:c=>l(c.target.value),placeholder:r("page.messageActions.rememberModalPlaceholder"),rows:3,disabled:e,className:"mt-3 w-full px-3 py-2 text-sm bg-surface-primary border border-border-default rounded-lg outline-none focus:border-brand-500/50 resize-y min-h-[72px]"}),s.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[s.jsx("button",{type:"button",onClick:n,disabled:e,className:"px-4 py-1.5 text-sm text-fg-secondary hover:text-fg-primary rounded-lg transition-colors",children:r("page.messageActions.rememberCancel")}),s.jsx("button",{type:"button",onClick:()=>t(o),disabled:e,className:"px-4 py-1.5 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-60 text-white rounded-lg transition-colors",children:e?r("common:loading",{defaultValue:"…"}):r("page.messageActions.rememberConfirm")})]})]})}),document.body)}function x4(e,t,n){if(!e)return[];const r=[];let o=0;const l=t??"";let d=n?new Date(n).getTime():Date.now();const m=e.some(j=>j.createdAt),p=j=>{if(j.createdAt)return j.createdAt;if(m)return new Date(d).toISOString();const O=new Date(d).toISOString();return j.type==="tool"&&j.durationMs?d+=j.durationMs:d+=1e3,O};let h=!1,g="",x="",y="";const w=()=>{const j=g.trim();j&&r.push({id:`cseg_${o}`,sourceType:"chat",sourceId:"",agentId:l,seq:o++,type:"text",content:j,createdAt:y,metadata:{isThinking:!0}}),g=""},C=()=>{const j=x.trim();j&&r.push({id:`cseg_${o}`,sourceType:"chat",sourceId:"",agentId:l,seq:o++,type:"text",content:j,createdAt:y}),x=""},T="<think>",S="</think>",_=j=>{let O=0;for(;O<j.length;)if(h){const P=j.indexOf(S,O);P===-1?(g+=j.slice(O),O=j.length):(g+=j.slice(O,P),h=!1,w(),O=P+S.length)}else{const P=j.indexOf(T,O);P===-1?(x+=j.slice(O),O=j.length):(x+=j.slice(O,P),C(),h=!0,O=P+T.length)}};for(const j of e)if(y=p(j),j.type==="tool"){h||C();const O=j.createdAt&&j.durationMs?new Date(new Date(j.createdAt).getTime()-j.durationMs).toISOString():y;r.push({id:`cseg_${o}`,sourceType:"chat",sourceId:"",agentId:l,seq:o++,type:"tool_start",content:j.tool,metadata:{arguments:j.args,...j.status==="running"&&j.subagentLogs?.length?{subagentLogs:j.subagentLogs}:{}},createdAt:O}),j.status!=="running"&&r.push({id:`cseg_${o}`,sourceType:"chat",sourceId:"",agentId:l,seq:o++,type:"tool_end",content:j.tool,metadata:{arguments:j.args,result:j.result,error:j.error,durationMs:j.durationMs,success:j.status!=="error",...j.subagentLogs?.length?{subagentLogs:j.subagentLogs}:{}},createdAt:y})}else j.thinking&&(h||C(),g+=j.thinking,w()),_(zg(j.content).cleaned);return h?w():C(),r}const AY=k.memo(function({msg:t,isStreaming:n,liveActivities:r,onMentionClick:o,knownNames:l}){const{t:c}=dt(["team","common"]),d=t.segments,m=t.isStopped,p=j=>j.type==="text"?j.content.length+(j.thinking?.length??0):(j.result?.length??0)+(j.subagentLogs?.length??0)*1e3+(j.liveOutput?.length??0),h=d?d.length+":"+(d.length>0?p(d[d.length-1]):0):"",g=d?d.reduce((j,O)=>j+(O.type==="tool"?O.subagentLogs?.length??0:0),0):0,x=k.useMemo(()=>d&&d.length>0?x4(d,t.agentId,t.rawCreatedAt):[],[h,g,t.agentId,t.rawCreatedAt]),y=t.committedSegments,w=y?y.length+":"+(y.length>0?p(y[y.length-1]):0):"",C=y?y.reduce((j,O)=>j+(O.type==="tool"?O.subagentLogs?.length??0:0),0):0,T=k.useMemo(()=>n?x:y&&y.length>0?x4(y,t.agentId,t.rawCreatedAt):x,[n,w,C,t.agentId,t.rawCreatedAt,x]);if(d!==void 0&&d.length>0){const j=d.some(H=>H.type==="tool"),O=d.filter(H=>H.type==="text"),P=n?null:O.map(H=>H.content).join(""),D=H=>H.replace(/\n*<!--\s*notify_context:\s*[\s\S]*?-->/g,"").replace(/<think>[\s\S]*?(<\/think>|$)/g,"").replace(/<(invoke|function_calls|antml:\w+)\b[\s\S]*?(<\/\1>|$)/g,"").replace(/<\/?(invoke|function_calls|antml:\w+)[^>]*>/g,"").trim()||null,X=(P?D(P):null)||(!n&&t.text?D(t.text):null),ee=[];for(const H of d){if(H.type!=="tool")continue;const K=_3(H.tool,H.result);if(K){ee.push({key:`task-${K.taskId}`,kind:"task",info:K});continue}const ae=j3(H.tool,H.result);ae&&ee.push({key:`req-${ae.requirementId}`,kind:"req",info:ae})}return s.jsxs("div",{className:"space-y-2 min-h-[1em] min-w-0 overflow-x-hidden",children:[j||n?s.jsx(vK,{entries:T,isActive:n,embedded:!0,hideApprovalCards:!0}):X&&s.jsx(Er,{content:X,onMentionClick:o,knownNames:l}),ee.map(H=>H.kind==="task"?s.jsx(D3,{info:H.info},H.key):s.jsx(L3,{info:H.info},H.key)),!n&&!X&&!j&&ee.length===0&&!m&&(t.emptyReply||!t.isError)&&s.jsx("div",{className:"flex items-start gap-1.5 text-[13px] text-fg-tertiary leading-relaxed",children:s.jsx("span",{children:c("page.emptyReply")})}),!n&&(t.isError||t.text.startsWith("⚠"))&&t.text&&!d?.some(H=>H.type==="text"&&H.content&&(H.content===t.text||H.content.startsWith("⚠")))&&s.jsx("p",{className:"mt-1.5 text-[13px] text-fg-tertiary leading-relaxed whitespace-pre-wrap",children:t.text.replace(/^⚠\s*/,"")}),m&&s.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5 text-[11px] text-fg-tertiary",children:[s.jsx("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),s.jsx("span",{children:c("page.stopped")})]})]})}const S=(t.activities?.length??0)>0,_=t.text?t.text.replace(/<think>[\s\S]*?(<\/think>|$)/g,"").replace(/<(invoke|function_calls|antml:\w+)\b[\s\S]*?(<\/\1>|$)/g,"").replace(/<\/?(invoke|function_calls|antml:\w+)[^>]*>/g,"").trim():"";return s.jsxs(s.Fragment,{children:[(n||S)&&s.jsx(nK,{activities:n?r:t.activities??[],isActive:n,persistent:!n&&S}),_?t.isError||_.startsWith("⚠")?s.jsx("p",{className:"text-[13px] text-fg-tertiary leading-relaxed whitespace-pre-wrap",children:_.replace(/^⚠\s*/,"")}):s.jsx(Er,{content:_,onMentionClick:o,knownNames:l}):null,!n&&!_&&!S&&!m&&t.sender==="agent"&&(t.emptyReply||!t.isError)&&s.jsx("div",{className:"flex items-start gap-1.5 text-[13px] text-fg-tertiary leading-relaxed",children:s.jsx("span",{children:c("page.emptyReply")})}),m&&s.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5 text-[11px] text-fg-tertiary",children:[s.jsx("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),s.jsx("span",{children:c("page.stopped")})]})]})});function _K(e){return e.questions&&e.questions.length>0?e.questions:e.options&&e.options.length>0?[{id:"q1",prompt:e.description||e.title,inputType:"choice",options:e.options,allowMultiple:!1,allowFreeform:e.allowFreeform}]:[{id:"q1",prompt:e.description||e.title,inputType:"text",allowFreeform:!0}]}function jK({approval:e,submitting:t,readOnly:n,onClose:r,onSubmit:o}){const{t:l}=dt(["team","common"]);zo(!0);const c=k.useMemo(()=>_K(e),[e]),[d,m]=k.useState(0),[p,h]=k.useState(()=>{if(n&&e.answers&&e.answers.length>0){const P={};for(const D of e.answers)P[D.questionId]={selectedOptionIds:D.selectedOptionIds??[],text:D.text??""};return P}return{}}),g=c[d],x=d===c.length-1,y=c.length>1,w=P=>p[P]??{selectedOptionIds:[],text:""},C=(P,D)=>{h($=>({...$,[P]:{...w(P),...D}}))},T=(P,D)=>{const $=w(P.id);if(P.allowMultiple){const X=$.selectedOptionIds.includes(D);C(P.id,{selectedOptionIds:X?$.selectedOptionIds.filter(ee=>ee!==D):[...$.selectedOptionIds,D],text:X?$.text:""})}else{const X=$.selectedOptionIds.includes(D);C(P.id,{selectedOptionIds:X?[]:[D],text:X?$.text:""})}},S=P=>{const D=w(P.id);return P.inputType==="choice"?D.selectedOptionIds.length>0?!0:!!(P.allowFreeform&&D.text.trim()):D.text.trim().length>0},_=c.every(S),j=()=>c.map(P=>{const D=w(P.id),$={questionId:P.id};return D.selectedOptionIds.length>0&&($.selectedOptionIds=D.selectedOptionIds),D.text.trim()&&($.text=D.text.trim()),$}),O=()=>{const P=j();let D=!0,$;if(!e.questions?.length&&e.options?.length){const ee=P[0];$=ee?.selectedOptionIds?.[0]??(ee?.text?"custom":void 0),D=$!=="reject"&&$!=="request_changes"}const X=P.map(ee=>ee.text).filter(Boolean).join(`
|
|
661
|
-
`)||void 0;o({approved:D,comment:X,selectedOption:$,answers:P})};return Sa.createPortal(s.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onMouseDown:P=>{P.target===P.currentTarget&&r()},children:s.jsxs("div",{className:"w-full max-w-2xl max-h-[85vh] flex flex-col bg-surface-secondary border border-border-default rounded-2xl shadow-2xl overflow-hidden",children:[s.jsxs("div",{className:"flex items-start gap-3 px-6 py-4 border-b border-border-default shrink-0",children:[s.jsx("div",{className:"w-9 h-9 rounded-lg bg-amber-500/15 text-amber-500 flex items-center justify-center shrink-0",children:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20z"}),s.jsx("path",{d:"M12 8v4"}),s.jsx("path",{d:"M12 16h.01"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h2",{className:"text-base font-semibold text-fg-primary leading-snug",children:e.title}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("p",{className:"text-xs text-fg-tertiary",children:e.agentName}),n&&s.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium bg-green-500/15 text-green-600",children:[s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}),l("team:userInput.submitted",{defaultValue:"Submitted"})]})]})]}),s.jsx("button",{onClick:r,className:"p-1.5 text-fg-tertiary hover:text-fg-primary rounded-md hover:bg-surface-overlay transition-colors shrink-0",title:l("common:close"),children:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]})})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[y&&s.jsx("div",{className:"flex items-center gap-2",children:c.map((P,D)=>s.jsx("button",{onClick:()=>m(D),className:`h-1.5 flex-1 rounded-full transition-colors ${D===d?"bg-brand-500":S(P)?"bg-green-500/60":"bg-border-default"}`,title:`${D+1}. ${P.prompt.slice(0,40)}`},P.id))}),y&&s.jsx("div",{className:"text-[11px] font-medium text-fg-tertiary",children:l("team:userInput.questionProgress",{current:d+1,total:c.length,defaultValue:`Question ${d+1} of ${c.length}`})}),s.jsx("div",{className:"text-sm text-fg-primary leading-relaxed",children:s.jsx(Er,{content:g.prompt})}),g.inputType==="choice"&&g.options&&s.jsx("div",{className:"space-y-2",children:g.options.map((P,D)=>{const $=w(g.id).selectedOptionIds.includes(P.id);return s.jsxs("button",{onClick:n?void 0:()=>T(g,P.id),disabled:n,className:`w-full px-4 py-3 text-left rounded-xl border transition-colors flex items-start gap-3 ${$?"border-brand-500 bg-brand-500/10":`border-border-default ${n?"":"hover:bg-surface-overlay"}`} ${n?"cursor-default":""} ${n&&!$?"opacity-50":""}`,children:[s.jsx("span",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[11px] font-bold shrink-0 mt-0.5 ${$?"bg-brand-600 text-white":"bg-surface-overlay text-fg-tertiary"}`,children:$?s.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}):String.fromCharCode(65+D)}),s.jsxs("span",{className:"flex-1 min-w-0 text-sm text-fg-primary [&_p]:my-0 [&_p]:text-sm",children:[s.jsx(Er,{content:P.label}),P.description&&s.jsx("span",{className:"block text-xs text-fg-tertiary mt-1 [&_p]:my-0 [&_p]:text-xs",children:s.jsx(Er,{content:P.description})})]})]},P.id)})}),(g.inputType==="text"||g.allowFreeform)&&(!n||w(g.id).text)&&s.jsx("textarea",{rows:g.inputType==="text"?4:2,readOnly:n,placeholder:g.inputType==="text"?l("team:userInput.textPlaceholder",{defaultValue:"Type your answer…"}):l("team:userInput.freeformPlaceholder",{defaultValue:"Or write your own answer…"}),value:w(g.id).text,onChange:P=>{const D=P.target.value;C(g.id,{text:D,selectedOptionIds:D.trim()&&g.inputType==="choice"?[]:w(g.id).selectedOptionIds})},className:`w-full px-3.5 py-2.5 text-sm bg-surface-overlay border border-border-default rounded-xl text-fg-primary placeholder:text-fg-tertiary focus:outline-none resize-y ${n?"cursor-default opacity-80":"focus:ring-1 focus:ring-brand-500/50"}`})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2 px-6 py-4 border-t border-border-default shrink-0",children:[s.jsx("div",{children:y&&d>0&&s.jsx("button",{onClick:()=>m(P=>Math.max(0,P-1)),className:"px-4 py-2 text-sm font-medium text-fg-secondary border border-border-default rounded-lg hover:bg-surface-overlay transition-colors",children:l("team:userInput.previous",{defaultValue:"Previous"})})}),s.jsx("div",{className:"flex items-center gap-2",children:y&&!x?s.jsx("button",{disabled:!n&&!S(g),onClick:()=>m(P=>Math.min(c.length-1,P+1)),className:"px-5 py-2 text-sm font-medium bg-brand-600 text-white rounded-lg hover:bg-brand-700 disabled:opacity-50 transition-colors",children:l("team:userInput.next",{defaultValue:"Next"})}):n?s.jsx("button",{onClick:r,className:"px-5 py-2 text-sm font-medium text-fg-secondary border border-border-default rounded-lg hover:bg-surface-overlay transition-colors",children:l("common:close",{defaultValue:"Close"})}):s.jsxs("button",{disabled:t||!_,onClick:O,className:"px-5 py-2 text-sm font-medium bg-brand-600 text-white rounded-lg hover:bg-brand-700 disabled:opacity-50 transition-colors inline-flex items-center gap-2",children:[t&&s.jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),l("team:userInput.submit",{defaultValue:"Submit"})]})})]})]})}),document.body)}function vd(e){return Array.isArray(e.questions)&&e.questions.length>0}const wd={urgent:"bg-red-500",high:"bg-amber-500",normal:"bg-blue-500",low:"bg-gray-400"},So={approval_request:"M9 12l2 2 4-4 M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z",task_completed:"M22 11.08V12a10 10 0 1 1-5.93-9.14 M22 4L12 14.01l-3-3",task_created:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",task_review:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",task_failed:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",requirement_created:"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",requirement_decision:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",agent_report:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8",direct_message:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",group_message:"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",system:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"},y4={approval_request:"text-amber-500",task_completed:"text-green-500",task_failed:"text-red-500",task_created:"text-blue-500",task_review:"text-purple-500",requirement_created:"text-amber-500",requirement_decision:"text-green-500",agent_report:"text-blue-500",direct_message:"text-green-500",group_message:"text-brand-500",system:"text-fg-tertiary"};function No(e,t){const n=Date.now()-new Date(e).getTime(),r=Math.floor(n/6e4);if(r<1)return t("common:time.now");if(r<60)return t("common:time.minutesAgo",{count:r});const o=Math.floor(r/60);return o<24?t("common:time.hoursAgo",{count:o}):t("common:time.daysAgo",{count:Math.floor(o/24)})}const v4="markus:template-updates-ack";let Wp=!1,kd=null;function MK(e){return e.map(t=>`${t.name}@${t.availableVersion}`).sort().join(",")}function w4(e,t){if(e.type!=="system"||!e.metadata?.templateUpdates)return!1;if(!t)return!0;const n=e.metadata.templateUpdatesFingerprint;return!n||n===t}function Sd(e,t){const n=e.actionType;if(n==="open_chat")return t("team:notifications.actionHints.openChat");if(n==="navigate")return t("team:notifications.actionHints.viewDetails");const r=e.metadata??{};switch(e.type){case"task_completed":case"task_created":case"task_review":case"task_failed":return r.taskId?t("team:notifications.actionHints.viewTask"):null;case"requirement_created":case"requirement_decision":return r.requirementId?t("team:notifications.actionHints.viewRequirement"):null;case"agent_report":return r.agentId?t("team:notifications.actionHints.viewAgent"):null;case"direct_message":return t("team:notifications.actionHints.openChat");case"group_message":return t("team:notifications.actionHints.openChat");case"approval_request":return t("team:notifications.actionHints.viewApproval");case"system":return r.templateUpdates?t("common:templateUpdates.actionHint"):null;default:return r.taskId?t("team:notifications.actionHints.viewTask"):r.requirementId?t("team:notifications.actionHints.viewRequirement"):r.agentId?t("team:notifications.actionHints.viewAgent"):null}}function Yp(){try{const e=new AudioContext,t=e.currentTime,n=e.createGain();n.connect(e.destination),n.gain.setValueAtTime(.15,t),n.gain.exponentialRampToValueAtTime(.01,t+.6);const r=e.createOscillator();r.type="sine",r.frequency.setValueAtTime(880,t),r.frequency.setValueAtTime(1174.66,t+.15),r.connect(n),r.start(t),r.stop(t+.6),r.onended=()=>e.close()}catch{}}function RK({collapsed:e,userId:t,embeddedMode:n,onClose:r,sidebarMode:o,isActive:l,label:c,iconPath:d}){const{t:m}=dt(["team","common"]),[p,h]=k.useState(!1),[g,x]=k.useState("approvals"),[y,w]=k.useState([]),[C,T]=k.useState([]),[S,_]=k.useState(null),[j,O]=k.useState(null),[P,D]=k.useState(null),[$,X]=k.useState({}),[ee,H]=k.useState(0),K=k.useRef(null),ae=k.useRef(null),[W,F]=k.useState({top:0,left:0,width:448,maxHeight:576}),Z=k.useRef(null),U=k.useRef(!1),[Q,ne]=k.useState(!0),[ke,B]=k.useState(!1),q=k.useRef(null),le=k.useRef("approvals"),[I,Ae]=k.useState(!1),$e=30,Oe=k.useCallback(async()=>{try{Ya("/approvals"),Ya("/notifications");const[R,oe]=await Promise.all([Ce.notifications.list(t,!1,{limit:$e,offset:0}),Ce.approvals.list()]);w(R.notifications);const _e=R.unreadCount??R.notifications.filter(de=>!de.read).length;if(H(_e),ne(R.totalCount!=null?R.notifications.length<R.totalCount:R.notifications.length>=$e),T(oe.approvals),!U.current){const de=oe.approvals.filter(Pe=>Pe.status==="pending").length;Z.current=de,U.current=!0}}catch{}},[t]),We=k.useCallback(async()=>{if(!(ke||!Q)){B(!0);try{const R=await Ce.notifications.list(t,!1,{limit:$e,offset:y.length});R.notifications.length>0&&w(oe=>[...oe,...R.notifications.filter(_e=>!oe.some(de=>de.id===_e.id))]),ne(R.totalCount!=null?y.length+R.notifications.length<R.totalCount:R.notifications.length>=$e)}catch{}B(!1)}},[t,y.length,ke,Q]),st=k.useCallback(R=>{const oe=R.detail;if(!oe)return;const{taskId:_e,requirementId:de}=oe;!_e&&!de||w(Pe=>{const Ve=Pe.filter(G=>!G.read&&(_e&&G.metadata?.taskId===_e||de&&G.metadata?.requirementId===de));if(Ve.length===0)return Pe;for(const G of Ve)Ce.notifications.markRead(G.id).catch(()=>{});return H(G=>Math.max(0,G-Ve.length)),Pe.map(G=>Ve.some(ie=>ie.id===G.id)?{...G,read:!0}:G)})},[]),mt=k.useRef(y);mt.current=y;const At=k.useCallback(async()=>{if(!mt.current.some(oe=>!oe.read&&oe.type==="system"&&oe.metadata?.creditExhausted))try{await Ce.notifications.create({title:m("credits.notificationTitle",{ns:"common"}),body:m("credits.notificationBody",{ns:"common"}),type:"system",priority:"urgent",metadata:{creditExhausted:!0}}),Oe(),Yp()}catch{}},[Oe,m]),gt=k.useCallback(async()=>{if(!Wp){Wp=!0;try{const{updates:R}=await Ce.skills.updates();if(!R.length)return;const oe=MK(R);try{if(localStorage.getItem(v4)===oe)return}catch{}if(kd===oe||mt.current.some(de=>!de.read&&w4(de,oe)))return;try{const Pe=(await Ce.notifications.list(t,!0,{limit:50,type:"system"})).notifications.filter(Ve=>w4(Ve,oe)).sort((Ve,G)=>new Date(G.createdAt).getTime()-new Date(Ve.createdAt).getTime());if(Pe.length>0){for(const Ve of Pe.slice(1))Ce.notifications.markRead(Ve.id).catch(()=>{});Pe.length>1&&Oe(),kd=oe;return}}catch{}kd=oe,await Ce.notifications.create({title:m("templateUpdates.notificationTitle",{ns:"common"}),body:m("templateUpdates.notificationBody",{ns:"common",count:R.length}),type:"system",priority:"high",metadata:{templateUpdates:!0,templateUpdatesFingerprint:oe,count:R.length,skills:R.map(de=>de.name)}}),Oe(),Yp()}catch{kd=null}finally{Wp=!1}}},[Oe,m,t]);k.useEffect(()=>{Oe();const R=setInterval(Oe,6e4);let oe=null;const _e=()=>{oe||(oe=setTimeout(()=>{oe=null,Oe()},400))},de=()=>_e(),Pe=()=>{h(!0),Oe()};window.addEventListener("markus:notifications-changed",de),window.addEventListener("markus:mark-read-by-ref",st),window.addEventListener("markus:open-notifications",Pe),window.addEventListener("markus:credit-exhausted",At);const Ve=va.on("notification",_e),G=va.on("approval:requested",_e);return()=>{clearInterval(R),oe&&clearTimeout(oe),window.removeEventListener("markus:notifications-changed",de),window.removeEventListener("markus:mark-read-by-ref",st),window.removeEventListener("markus:open-notifications",Pe),window.removeEventListener("markus:credit-exhausted",At),Ve(),G()}},[Oe,st,At]),k.useEffect(()=>{gt();const R=setInterval(()=>{gt()},5*6e4),oe=()=>{gt()};return window.addEventListener("markus:data-changed",oe),()=>{clearInterval(R),window.removeEventListener("markus:data-changed",oe)}},[t]);const jt=k.useCallback(()=>{if(!K.current)return;const R=K.current.getBoundingClientRect(),oe=window.innerWidth,_e=window.innerHeight,de=Math.min(448,oe-16),Pe=Math.min(576,_e-16);let Ve=R.right+8,G=R.top;Ve+de>oe-8&&(Ve=Math.max(8,oe-de-8)),G+Pe>_e-8&&(G=Math.max(8,_e-Pe-8)),F({top:G,left:Ve,width:de,maxHeight:Pe})},[]);k.useLayoutEffect(()=>{p&&jt()},[p,jt]),k.useEffect(()=>{if(p)return window.addEventListener("resize",jt),()=>window.removeEventListener("resize",jt)},[p,jt]),k.useEffect(()=>{if(!p)return;const R=oe=>{K.current?.contains(oe.target)||ae.current?.contains(oe.target)||h(!1)};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[p]),k.useEffect(()=>{if(!p)return;const R=C.some(_e=>_e.status==="pending"),oe=y.some(_e=>!_e.read);x(R&&!oe?"approvals":!R&&oe?"notifications":le.current)},[p]);const Jt=new Set(C.filter(R=>R.status==="pending").map(R=>R.id)),Rt=new Set(C.map(R=>R.id)),be=y.filter(R=>!(R.type==="approval_request"&&R.metadata?.approvalId&&Rt.has(R.metadata.approvalId))),Me=y.filter(R=>R.type==="approval_request"&&!R.read&&R.metadata?.approvalId&&Jt.has(R.metadata.approvalId)).length,qe=Math.max(0,ee-Me),ot=Jt.size,ft=qe+ot;k.useEffect(()=>{Z.current!==null&&ot>Z.current&&Yp(),Z.current=ot},[ot]);const se=async R=>{await Ce.notifications.markRead(R),w(oe=>oe.map(_e=>_e.id===R?{..._e,read:!0}:_e)),H(oe=>Math.max(0,oe-1)),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))},Be=R=>{const oe=R.metadata??{},_e=R.actionType,de=R.actionTarget;if(_e==="open_chat"&&de)try{const Pe=typeof de=="string"?JSON.parse(de):de;if(Pe.agentId){const Ve={agentId:Pe.agentId};Pe.sessionId&&(Ve.sessionId=Pe.sessionId),at.navigate(me.TEAM,Ve);return}}catch{}if(_e==="navigate"&&de)try{const Pe=typeof de=="string"?JSON.parse(de):de;if(Pe.path){if(Pe.path.startsWith("/team")){const Ve={},G=new URLSearchParams(Pe.path.split("?")[1]||"");for(const[ie,Ne]of G.entries())Ve[ie]=Ne;at.navigate(me.TEAM,Ve);return}if(Pe.path.startsWith("/work")){const Ve={},G=new URLSearchParams(Pe.path.split("?")[1]||"");for(const[ie,Ne]of G.entries())Ve[ie]=Ne;at.navigate(me.WORK,Ve);return}}}catch{}switch(R.type){case"approval_request":{const Pe=oe.approvalId,Ve=Pe?C.find(Le=>Le.id===Pe):void 0;if(Ve&&vd(Ve)){O(Ve);break}const G=Ve?.details?.taskId??oe.taskId,ie=Ve?.details?.requirementId??oe.requirementId,Ne=Ve?.details?.agentId??Ve?.agentId;G?at.navigate(me.WORK,{openTask:G}):ie?at.navigate(me.WORK,{openRequirement:ie}):Ne?at.navigate(me.TEAM,{agentId:Ne}):at.navigate(me.WORK);break}case"task_completed":case"task_created":case"task_review":case"task_failed":oe.taskId?at.navigate(me.WORK,{openTask:oe.taskId}):at.navigate(me.WORK);break;case"requirement_created":case"requirement_decision":oe.requirementId?at.navigate(me.WORK,{openRequirement:oe.requirementId}):at.navigate(me.WORK);break;case"agent_report":case"system":{if(oe.creditExhausted){Ae(!0);return}if(oe.templateUpdates){const Pe=oe.templateUpdatesFingerprint;if(Pe)try{localStorage.setItem(v4,Pe)}catch{}localStorage.setItem("markus_nav_storeTab","installed"),at.navigate(me.STORE);return}if(oe.agentId){const Pe={agentId:oe.agentId};oe.sessionId&&(Pe.sessionId=oe.sessionId),at.navigate(me.TEAM,Pe)}else at.navigate(me.TEAM);break}case"direct_message":{const Pe=oe.senderId;Pe?at.navigate(me.TEAM,{dm:Pe}):at.navigate(me.TEAM);break}case"group_message":{const Pe=oe.channel;Pe?at.navigate(me.TEAM,{channel:Pe}):at.navigate(me.TEAM);break}default:oe.taskId?at.navigate(me.WORK,{openTask:oe.taskId}):oe.requirementId?at.navigate(me.WORK,{openRequirement:oe.requirementId}):oe.projectId?at.navigate(me.WORK,{projectId:oe.projectId}):oe.agentId&&at.navigate(me.TEAM,{agentId:oe.agentId});break}},Xe=async R=>{const oe=R.metadata??{},_e=R.actionType,de=R.type==="agent_report"&&!oe.creditExhausted&&!oe.templateUpdates&&(_e==="open_chat"||!!oe.agentId&&_e!=="navigate");!R.read&&!de&&se(R.id);const Pe=oe.taskId,Ve=oe.requirementId;if(!de&&(Pe||Ve)){const G=y.filter(ie=>ie.id!==R.id&&!ie.read&&(Pe&&ie.metadata?.taskId===Pe||Ve&&ie.metadata?.requirementId===Ve));for(const ie of G)se(ie.id)}Be(R)},Ge=async(R,oe,_e,de,Pe)=>{_(R);try{const{approval:Ve}=await Ce.approvals.respond(R,oe,t,_e,de,Pe);T(Le=>Le.map(Je=>Je.id===R?Ve:Je)),O(null),D(null),X(Le=>{const Je={...Le};return delete Je[R],Je});const G=Ve.details?.taskId,ie=Ve.details?.requirementId,Ne=y.filter(Le=>!Le.read&&(Le.type==="approval_request"&&Le.metadata?.approvalId===R||G&&Le.metadata?.taskId===G||ie&&Le.metadata?.requirementId===ie));if(Ne.length>0){for(const Je of Ne)Ce.notifications.markRead(Je.id).catch(()=>{});const Le=new Set(Ne.map(Je=>Je.id));w(Je=>Je.map(vt=>Le.has(vt.id)?{...vt,read:!0}:vt)),H(Je=>Math.max(0,Je-Ne.length))}Ya("/approvals"),Ya("/notifications"),Ya("/tasks"),Ya("/taskboard"),Ya("/requirements"),window.dispatchEvent(new CustomEvent("markus:data-changed")),window.dispatchEvent(new CustomEvent("markus:notifications-changed")),setTimeout(()=>Oe(),800)}catch{}_(null)},et=async()=>{try{if(!t)return;await Ce.notifications.markAllRead(t),w(R=>R.map(oe=>({...oe,read:!0}))),H(0),Ya("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}catch{const R=be.filter(oe=>!oe.read);await Promise.all(R.map(oe=>Ce.notifications.markRead(oe.id))),w(oe=>oe.map(_e=>({..._e,read:!0}))),H(0),Ya("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}},yt=R=>{const oe=R.details?.subType;return oe==="requirement_resubmit"?m("team:notifications.approvalType.requirementResubmit"):oe==="requirement"||R.details?.requirementId?m("team:notifications.approvalType.requirement"):oe==="task_review"?m("team:notifications.approvalType.taskReview"):oe==="task"||R.details?.taskId?m("team:notifications.approvalType.task"):R.details?.toolName?m("team:notifications.approvalType.toolExecution"):null},he=R=>{const oe=[];oe.push(R.agentName);const _e=R.details?.taskTitle,de=R.details?.taskId;_e?oe.push(_e):de&&oe.push(`Task ${de.slice(0,8)}`);const Pe=R.details?.requirementId;return Pe&&!de&&oe.push(`Req ${Pe.slice(0,8)}`),oe.join(" · ")},V=[...C].sort((R,oe)=>new Date(oe.requestedAt).getTime()-new Date(R.requestedAt).getTime()),ye=V.filter(R=>R.status==="pending"),Qe=V.filter(R=>R.status!=="pending"),pe=R=>{const oe=R.details?.taskId,_e=R.details?.requirementId,de=R.details?.agentId??R.agentId;oe?at.navigate(me.WORK,{openTask:oe}):_e?at.navigate(me.WORK,{openRequirement:_e}):de?at.navigate(me.TEAM,{agentId:de}):at.navigate(me.WORK)},ve=()=>{h(!1),r?.()},Ye=R=>s.jsxs("button",{disabled:S===R.id,onClick:()=>O(R),className:"w-full px-3 py-2 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors inline-flex items-center justify-center gap-1.5",children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.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"})}),m("team:userInput.respond",{defaultValue:"Respond"}),R.questions&&R.questions.length>1?` (${R.questions.length})`:""]}),nt=j?s.jsx(jK,{approval:j,submitting:S===j.id,readOnly:j.status!=="pending",onClose:()=>O(null),onSubmit:R=>Ge(j.id,R.approved,R.comment,R.selectedOption,R.answers)}):null,xt=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex border-b border-border-default shrink-0",children:[s.jsxs("button",{onClick:()=>{x("approvals"),le.current="approvals"},className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${g==="approvals"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:[m("team:notifications.approvals"),ot>0?` (${ot})`:""]}),s.jsxs("button",{onClick:()=>{x("notifications"),le.current="notifications"},className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${g==="notifications"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:[m("team:notifications.notifications"),qe>0?` (${qe})`:""]}),s.jsx("button",{onClick:ve,className:"px-2 py-2 text-fg-tertiary hover:text-fg-primary transition-colors shrink-0",title:m("common:close"),children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]})})]}),g==="notifications"&&ee>0&&s.jsx("div",{className:"flex justify-end px-3 py-1.5 border-b border-border-default/50 shrink-0",children:s.jsx("button",{onClick:et,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:m("team:notifications.markAllRead")})}),s.jsxs("div",{ref:q,className:"flex-1 overflow-y-auto",onScroll:R=>{if(g!=="notifications"||!Q||ke)return;const oe=R.currentTarget;oe.scrollTop+oe.clientHeight>=oe.scrollHeight-80&&We()},children:[g==="approvals"&&(C.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noApprovals")}):s.jsxs("div",{className:"divide-y divide-border-default/50",children:[ye.map(R=>{const oe=R.details?.command,_e=oe?R.description.replace(/\s*Command:.*$/,""):R.description;return s.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[s.jsxs("div",{className:"cursor-pointer hover:bg-surface-overlay/50 -mx-3 -mt-3 px-3 pt-3 pb-1 rounded-t-md transition-colors",onClick:()=>pe(R),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-amber-500 mt-0.5 shrink-0",children:s.jsx("path",{d:So.approval_request})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[yt(R)&&s.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:yt(R)}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:R.title}),s.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:No(R.requestedAt,m)})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:R.agentName})]})]}),s.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:s.jsx(Er,{content:_e,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),oe&&s.jsx("pre",{className:"text-[11px] text-fg-primary bg-surface-overlay border border-border-default rounded-md px-2.5 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono leading-relaxed mt-2",children:oe})]}),(()=>{if(vd(R))return Ye(R);const de=R.details?.subType,Pe=de==="task"||de==="requirement"||de==="requirement_resubmit",Ve=R.options&&R.options.length>0,G=($[R.id]??"").trim();return Ve?s.jsxs("div",{className:"space-y-1.5",children:[R.options.map((ie,Ne)=>s.jsxs("button",{disabled:S===R.id,onClick:()=>Ge(R.id,ie.id!=="reject",G||void 0,ie.id),className:`w-full px-3 py-2 text-left text-[11px] font-medium rounded-md disabled:opacity-50 transition-colors flex items-center gap-2 ${ie.id==="reject"||ie.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:ie.description,children:[s.jsx("span",{className:"w-5 h-5 rounded-full bg-white/20 flex items-center justify-center text-[10px] font-bold shrink-0",children:String.fromCharCode(65+Ne)}),ie.label]},ie.id)),s.jsxs("div",{className:"flex gap-1.5 mt-1",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:$[R.id]??"",onChange:ie=>X(Ne=>({...Ne,[R.id]:ie.target.value})),onKeyDown:ie=>{ie.key==="Enter"&&($[R.id]??"").trim()&&Ge(R.id,!0,($[R.id]??"").trim(),"custom")},className:"flex-1 px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),s.jsx("button",{disabled:S===R.id||!($[R.id]??"").trim(),onClick:()=>Ge(R.id,!0,($[R.id]??"").trim(),"custom"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors",children:m("common:send")})]})]}):Pe?s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{disabled:S===R.id,onClick:()=>Ge(R.id,!0,void 0,"approve"),className:"px-3 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}),m("common:approve")]}),s.jsxs("button",{disabled:S===R.id,onClick:()=>Ge(R.id,!1,void 0,"reject"),className:"px-3 py-1.5 text-[11px] font-medium bg-red-600/80 text-white rounded-md hover:bg-red-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]}),m("common:reject")]}),P!==R.id&&s.jsxs("button",{disabled:S===R.id,onClick:()=>D(R.id),className:"px-3 py-1.5 text-[11px] font-medium border border-amber-500/50 text-amber-500 rounded-md hover:bg-amber-500/10 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),s.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),m("team:notifications.needsAdjustment")]})]}),P===R.id&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:$[R.id]??"",onChange:ie=>X(Ne=>({...Ne,[R.id]:ie.target.value})),onKeyDown:ie=>{ie.key==="Enter"&&($[R.id]??"").trim()&&Ge(R.id,!1,($[R.id]??"").trim(),"needs_adjustment"),ie.key==="Escape"&&D(null)},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-amber-500/50"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:S===R.id||!($[R.id]??"").trim(),onClick:()=>Ge(R.id,!1,($[R.id]??"").trim(),"needs_adjustment"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-amber-600 text-white rounded-md hover:bg-amber-700 disabled:opacity-50 transition-colors",children:m("team:notifications.confirmAdjustment")}),s.jsx("button",{onClick:()=>D(null),className:"px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay transition-colors",children:m("common:cancel")})]})]})]}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.commentPlaceholder"),value:$[R.id]??"",onChange:ie=>X(Ne=>({...Ne,[R.id]:ie.target.value})),onKeyDown:ie=>{ie.key==="Enter"&&Ge(R.id,!0,G||void 0,"approve")},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:S===R.id,onClick:()=>Ge(R.id,!0,G||void 0,"approve"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors",children:m("common:approve")}),s.jsx("button",{disabled:S===R.id,onClick:()=>Ge(R.id,!1,G||void 0,"reject"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay disabled:opacity-50 transition-colors",children:m("common:reject")})]})]})})()]},R.id)}),Qe.length>0&&s.jsxs(s.Fragment,{children:[ye.length>0&&s.jsx("div",{className:"px-3 py-1.5 text-[10px] font-medium text-fg-tertiary uppercase tracking-wider bg-surface-overlay/30",children:m("team:notifications.approvalHistory")}),Qe.slice(0,50).map(R=>s.jsxs("button",{onClick:()=>vd(R)?O(R):pe(R),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors group",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${R.status==="approved"?"bg-green-500":R.status==="cancelled"||R.status==="expired"?"bg-gray-400":"bg-red-500"}`}),yt(R)&&s.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium shrink-0",children:yt(R)}),s.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1 group-hover:text-fg-primary",children:R.title}),s.jsx("span",{className:`text-[10px] font-medium shrink-0 ${R.status==="approved"?"text-green-500":R.status==="cancelled"||R.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${R.status}`,{defaultValue:R.status})})]}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 pl-3.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted truncate",children:he(R)}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:No(R.respondedAt??R.requestedAt,m)})]}),R.responseComment&&s.jsxs("p",{className:"text-[10px] text-fg-muted mt-0.5 pl-3.5 truncate",children:["“",R.responseComment,"”"]})]},R.id))]})]})),g==="notifications"&&(be.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noNotifications")}):s.jsxs("div",{className:"divide-y divide-border-default/50",children:[be.map(R=>{const oe=y4[R.type]??"text-fg-tertiary";return s.jsxs("div",{role:"button",tabIndex:0,onClick:()=>Xe(R),onKeyDown:_e=>{(_e.key==="Enter"||_e.key===" ")&&(_e.preventDefault(),Xe(R))},className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors cursor-pointer ${R.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"shrink-0 mt-0.5",children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:oe,children:s.jsx("path",{d:So[R.type]??So.system})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[!R.read&&s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${wd[R.priority]??wd.normal}`}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:R.title})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:s.jsx(Er,{content:R.body,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted",children:No(R.createdAt,m)}),Sd(R,m)&&s.jsx("span",{className:`text-[10px] font-medium ${oe}`,children:Sd(R,m)})]})]})]},R.id)}),ke&&s.jsx("div",{className:"py-3 text-center",children:s.jsxs("svg",{className:"animate-spin h-4 w-4 text-fg-tertiary mx-auto",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})})]}))]})]}),Dt=k.useCallback(R=>{R?.mute&&EK()},[]),ct=k.useCallback(R=>{Dt(R),Ae(!1)},[Dt]),Xt=I?s.jsx(dr,{title:m("credits.dialogTitle",{ns:"common"}),message:m("credits.dialogDesc",{ns:"common"}),variant:"primary",cancelLabel:m("credits.configureModels",{ns:"common"}),confirmLabel:m("credits.topUp",{ns:"common"}),checkboxes:[{id:"mute",label:m("credits.dontRemind",{ns:"common"})}],onCancel:()=>Ae(!1),onCancelClick:R=>{ct(R),at.navigate(me.SETTINGS),setTimeout(()=>{window.location.hash="settings/providers"},50)},onConfirm:R=>{const oe=`${it.getUrl().replace(/\/$/,"")}/settings?tab=billing`;ct(R),Ai(oe)}}):null;if(n){const R=["approvals","notifications"],oe=R.indexOf(g),_e=(()=>{let de=0,Pe=0;return{onTouchStart:Ve=>{de=Ve.touches[0].clientX,Pe=Ve.touches[0].clientY},onTouchEnd:Ve=>{const G=Ve.changedTouches[0].clientX-de,ie=Ve.changedTouches[0].clientY-Pe;Math.abs(G)>60&&Math.abs(G)>Math.abs(ie)*1.5&&(G<0&&oe<R.length-1&&x(R[oe+1]),G>0&&oe>0&&x(R[oe-1]))}}})();return s.jsxs(s.Fragment,{children:[Xt,s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[nt,s.jsx("div",{className:"flex border-b border-border-default shrink-0",children:R.map(de=>s.jsx("button",{onClick:()=>x(de),className:`flex-1 px-3 py-3 text-sm font-medium transition-colors ${g===de?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary"}`,children:de==="approvals"?s.jsxs(s.Fragment,{children:[m("team:notifications.approvals"),ot>0?` (${ot})`:""]}):s.jsxs(s.Fragment,{children:[m("team:notifications.notifications"),qe>0?` (${qe})`:""]})},de))}),g==="notifications"&&ee>0&&s.jsx("div",{className:"flex justify-end px-3 py-1.5 border-b border-border-default/50 shrink-0",children:s.jsx("button",{onClick:et,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:m("team:notifications.markAllRead")})}),s.jsx("div",{className:"flex-1 overflow-hidden relative",..._e,children:s.jsxs("div",{className:"flex h-full transition-transform duration-300 ease-out",style:{transform:`translateX(-${oe*100}%)`},children:[s.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:C.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noApprovals")}):s.jsxs("div",{className:"divide-y divide-border-default/50",children:[ye.map(de=>{const Pe=de.details?.command,Ve=Pe?de.description.replace(/\s*Command:.*$/,""):de.description;return s.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[s.jsxs("div",{className:"cursor-pointer hover:bg-surface-overlay/50 -mx-3 -mt-3 px-3 pt-3 pb-1 rounded-t-md transition-colors",onClick:()=>pe(de),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-amber-500 mt-0.5 shrink-0",children:s.jsx("path",{d:So.approval_request})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[yt(de)&&s.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:yt(de)}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:de.title}),s.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:No(de.requestedAt,m)})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:de.agentName})]})]}),s.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:s.jsx(Er,{content:Ve,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),Pe&&s.jsx("pre",{className:"text-[11px] text-fg-primary bg-surface-overlay border border-border-default rounded-md px-2.5 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono leading-relaxed mt-2",children:Pe})]}),(()=>{if(vd(de))return Ye(de);const G=de.details?.subType,ie=G==="task"||G==="requirement"||G==="requirement_resubmit",Ne=de.options&&de.options.length>0,Le=($[de.id]??"").trim();return Ne?s.jsxs("div",{className:"space-y-1.5",children:[de.options.map((Je,vt)=>s.jsxs("button",{disabled:S===de.id,onClick:()=>Ge(de.id,Je.id!=="reject",Le||void 0,Je.id),className:`w-full px-3 py-2 text-left text-[11px] font-medium rounded-md disabled:opacity-50 transition-colors flex items-center gap-2 ${Je.id==="reject"||Je.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:Je.description,children:[s.jsx("span",{className:"w-5 h-5 rounded-full bg-white/20 flex items-center justify-center text-[10px] font-bold shrink-0",children:String.fromCharCode(65+vt)}),Je.label]},Je.id)),s.jsxs("div",{className:"flex gap-1.5 mt-1",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:$[de.id]??"",onChange:Je=>X(vt=>({...vt,[de.id]:Je.target.value})),onKeyDown:Je=>{Je.key==="Enter"&&($[de.id]??"").trim()&&Ge(de.id,!0,($[de.id]??"").trim(),"custom")},className:"flex-1 px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),s.jsx("button",{disabled:S===de.id||!($[de.id]??"").trim(),onClick:()=>Ge(de.id,!0,($[de.id]??"").trim(),"custom"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors",children:m("common:send")})]})]}):ie?s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{disabled:S===de.id,onClick:()=>Ge(de.id,!0,void 0,"approve"),className:"px-3 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}),m("common:approve")]}),s.jsxs("button",{disabled:S===de.id,onClick:()=>Ge(de.id,!1,void 0,"reject"),className:"px-3 py-1.5 text-[11px] font-medium bg-red-600/80 text-white rounded-md hover:bg-red-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]}),m("common:reject")]}),P!==de.id&&s.jsxs("button",{disabled:S===de.id,onClick:()=>D(de.id),className:"px-3 py-1.5 text-[11px] font-medium border border-amber-500/50 text-amber-500 rounded-md hover:bg-amber-500/10 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),s.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),m("team:notifications.needsAdjustment")]})]}),P===de.id&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:$[de.id]??"",onChange:Je=>X(vt=>({...vt,[de.id]:Je.target.value})),onKeyDown:Je=>{Je.key==="Enter"&&($[de.id]??"").trim()&&Ge(de.id,!1,($[de.id]??"").trim(),"needs_adjustment"),Je.key==="Escape"&&D(null)},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-amber-500/50"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:S===de.id||!($[de.id]??"").trim(),onClick:()=>Ge(de.id,!1,($[de.id]??"").trim(),"needs_adjustment"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-amber-600 text-white rounded-md hover:bg-amber-700 disabled:opacity-50 transition-colors",children:m("team:notifications.confirmAdjustment")}),s.jsx("button",{onClick:()=>D(null),className:"px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay transition-colors",children:m("common:cancel")})]})]})]}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.commentPlaceholder"),value:$[de.id]??"",onChange:Je=>X(vt=>({...vt,[de.id]:Je.target.value})),onKeyDown:Je=>{Je.key==="Enter"&&Ge(de.id,!0,Le||void 0,"approve")},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:S===de.id,onClick:()=>Ge(de.id,!0,Le||void 0,"approve"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors",children:m("common:approve")}),s.jsx("button",{disabled:S===de.id,onClick:()=>Ge(de.id,!1,Le||void 0,"reject"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay disabled:opacity-50 transition-colors",children:m("common:reject")})]})]})})()]},de.id)}),Qe.length>0&&s.jsxs(s.Fragment,{children:[ye.length>0&&s.jsx("div",{className:"px-3 py-1.5 text-[10px] font-medium text-fg-tertiary uppercase tracking-wider bg-surface-overlay/30",children:m("team:notifications.approvalHistory")}),Qe.slice(0,50).map(de=>s.jsxs("button",{onClick:()=>pe(de),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${de.status==="approved"?"bg-green-500":de.status==="cancelled"||de.status==="expired"?"bg-gray-400":"bg-red-500"}`}),s.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:de.title}),s.jsx("span",{className:`text-[10px] font-medium shrink-0 ${de.status==="approved"?"text-green-500":de.status==="cancelled"||de.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${de.status}`,{defaultValue:de.status})})]}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 pl-3.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted truncate",children:he(de)}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:No(de.respondedAt??de.requestedAt,m)})]})]},de.id))]})]})}),s.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:be.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noNotifications")}):s.jsx("div",{className:"divide-y divide-border-default/50",children:be.slice(0,50).map(de=>{const Pe=y4[de.type]??"text-fg-tertiary";return s.jsxs("button",{onClick:()=>Xe(de),className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors ${de.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"shrink-0 mt-0.5",children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:Pe,children:s.jsx("path",{d:So[de.type]??So.system})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[!de.read&&s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${wd[de.priority]??wd.normal}`}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:de.title})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:s.jsx(Er,{content:de.body,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted",children:No(de.createdAt,m)}),Sd(de,m)&&s.jsx("span",{className:`text-[10px] font-medium ${Pe}`,children:Sd(de,m)})]})]})]},de.id)})})})]})})]})]})}if(o){const R=d||"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9 M13.73 21a2 2 0 0 1-3.46 0";return s.jsxs(s.Fragment,{children:[nt,s.jsxs("button",{ref:K,onClick:()=>{h(!p),p||Oe()},title:e?c||m("team:notifications.bellTitle"):void 0,className:`w-full flex items-center ${e?"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 relative text-fg-primary ${p||l?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[s.jsx("svg",{width:e?16:18,height:e?16:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("path",{d:R})}),e?s.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:c}):s.jsx("span",{className:"truncate",children:c}),ft>0&&s.jsx("span",{className:`absolute ${e?"top-0.5 right-1":"top-1 left-[22px]"} min-w-[16px] h-4 px-1 rounded-full bg-red-500 text-white text-[10px] font-bold flex items-center justify-center leading-none`,children:ft>99?m("common:badgeOverLimit"):ft})]}),p&&Sa.createPortal(s.jsx("div",{ref:ae,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:W.top,left:W.left,width:W.width,maxHeight:W.maxHeight},children:xt}),document.body),Xt]})}return s.jsxs(s.Fragment,{children:[nt,s.jsxs("button",{ref:K,onClick:()=>{h(!p),p||Oe()},className:`relative flex items-center justify-center rounded-md transition-colors ${e?"w-8 h-8":"w-7 h-7"} ${p?"bg-surface-overlay text-fg-primary":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay"}`,title:m("team:notifications.bellTitle"),children:[s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),s.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),ft>0&&s.jsx("span",{className:"absolute -top-0.5 -right-0.5 min-w-[16px] h-4 px-1 rounded-full bg-red-500 text-white text-[10px] font-bold flex items-center justify-center leading-none",children:ft>99?m("common:badgeOverLimit"):ft})]}),p&&Sa.createPortal(s.jsx("div",{ref:ae,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:W.top,left:W.left,width:W.width,maxHeight:W.maxHeight},children:xt}),document.body),Xt]})}function Nd({d:e,size:t=14}){return s.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:s.jsx("path",{d:e})})}const Xp=200;function OK({authUser:e,onLogout:t,onEditProfile:n,showSettingsLink:r=!1,collapsed:o=!1,showVersion:l=!1}){const{t:c}=dt(["nav","common"]),[d,m]=k.useState(!1),[p,h]=k.useState(!1),[g,x]=k.useState(()=>it.isAuthenticated()),[y,w]=k.useState(()=>sa()),[C,T]=k.useState({top:0,left:0}),S=k.useRef(null),_=k.useRef(null),j=k.useCallback(W=>{if(w(sa()),!it.isAuthenticated()){x(!1);return}if(!W?.validate){x(!0);return}m5().then(F=>{x(F),w(sa())})},[]);k.useEffect(()=>{j({validate:!0});const W=()=>j(),F=()=>j({validate:!0});return window.addEventListener("markus:hub-auth",W),window.addEventListener("focus",F),()=>{window.removeEventListener("markus:hub-auth",W),window.removeEventListener("focus",F)}},[j]);const O=k.useCallback(()=>{if(!S.current)return;const W=S.current.getBoundingClientRect(),F=window.innerWidth,Z=window.innerHeight,U=_.current?.offsetHeight??220;let Q=W.right+8;Q+Xp>F-8&&(Q=Math.max(8,W.left-Xp-8));let ne=W.top-U-8;ne<8&&(ne=Math.min(W.bottom+8,Z-U-8)),T({top:Math.max(8,ne),left:Q})},[]);k.useLayoutEffect(()=>{if(!d)return;O();const W=requestAnimationFrame(()=>O());return()=>cancelAnimationFrame(W)},[d,O,o]),k.useEffect(()=>{if(!d)return;const W=Z=>{const U=Z.target;S.current?.contains(U)||_.current?.contains(U)||m(!1)},F=()=>O();return document.addEventListener("mousedown",W),window.addEventListener("resize",F),window.addEventListener("scroll",F,!0),()=>{document.removeEventListener("mousedown",W),window.removeEventListener("resize",F),window.removeEventListener("scroll",F,!0)}},[d,O]);const P=e?.name||y?.displayName||y?.username||c("common:userPlaceholder"),D=e?.email||y?.email||"",$=h5(e?.avatarUrl,y?.avatarUrl),X=g?"bg-emerald-500":"bg-fg-muted",ee=g?y?.username?c("sidebar.hubConnectedAs",{username:y.username}):c("sidebar.hubConnected"):c("sidebar.hubDisconnected"),H=!!(g&&y?.username&&e?.name&&y.username.toLowerCase()!==e.name.toLowerCase()&&y.email?.toLowerCase()!==e.email?.toLowerCase()),K=()=>{m(!1),j({validate:!0}),at.navigate(me.SETTINGS,{tab:"account"})},ae=d&&Sa.createPortal(s.jsxs("div",{ref:_,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:Xp},children:[s.jsxs("div",{className:"px-3.5 py-3 border-b border-border-default flex items-start gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:P}),D&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5 truncate",children:D})]}),n&&s.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:s.jsx(Nd,{d:"M12 20h9M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z",size:14})})]}),s.jsxs("button",{type:"button",onClick:K,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:[s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${X}`}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"text-xs text-fg-secondary block truncate",children:ee}),H&&y?.username&&s.jsx("span",{className:"text-[10px] text-amber-500/90 block truncate mt-0.5",children:c("sidebar.hubAccountMismatch",{username:y.username})})]}),s.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:s.jsx("path",{d:"m9 18 6-6-6-6"})})]}),s.jsxs("div",{className:"py-1",children:[r&&s.jsxs("button",{type:"button",onClick:()=>{m(!1),at.navigate(me.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:[s.jsx(Nd,{d:dc[me.SETTINGS]}),c("settings")]}),window.markusDesktop&&s.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:[s.jsx(Nd,{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&&s.jsxs("button",{type:"button",onClick:()=>{m(!1),h(!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:[s.jsx(Nd,{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 s.jsxs("div",{className:`relative ${o?"flex justify-center":"flex items-center justify-between gap-2 w-full"}`,children:[s.jsxs("button",{ref:S,type:"button",onClick:()=>m(W=>!W),title:P,className:`relative inline-flex items-center justify-center rounded-full transition-opacity hover:opacity-90 ${o?"p-0.5":""}`,children:[s.jsx(Us,{name:P,avatarUrl:$,size:o?28:32,fallback:"icon"}),s.jsx("span",{className:`absolute bottom-0 right-0 w-2.5 h-2.5 rounded-full border-2 border-surface-secondary ${X}`,title:ee})]}),l&&!o&&s.jsxs("span",{className:"text-[10px] text-fg-muted select-none shrink-0",children:["v","0.9.1"]}),ae,p&&t&&s.jsx(dr,{title:c("common:signOutConfirmTitle"),message:c("common:signOutConfirmMessage"),confirmLabel:c("common:signOut"),variant:"primary",onConfirm:()=>{h(!1),t()},onCancel:()=>h(!1)})]})}function DK({d:e,size:t=18}){return s.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:s.jsx("path",{d:e})})}function LK({currentPage:e,onNavigate:t,authUser:n,collapsed:r,onToggleCollapse:o,onLogout:l}){const{t:c}=dt(["nav","common"]);return s.jsxs("aside",{className:"markus-app-sidebar h-dvh bg-surface-secondary flex flex-col shrink-0 overflow-hidden",children:[s.jsx("div",{"data-electron-drag":!0,className:`electron-mac-sidebar-header flex items-center ${r?"px-2 py-3.5 justify-center":"px-4 h-14 justify-between"}`,children:s.jsxs("button",{"data-no-drag":!0,onClick:o,title:c(r?"sidebar.expandSidebar":"sidebar.collapseSidebar"),className:"flex items-center gap-2.5 min-w-0 group",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-8 h-8 rounded-lg shrink-0"}),!r&&s.jsx("span",{className:"text-[15px] font-bold tracking-tight text-fg-primary whitespace-nowrap",children:"Markus"})]})}),s.jsx("nav",{className:`${r?"p-1":"px-3 py-2"} flex-1 overflow-y-auto scrollbar-thin`,children:gD.map((d,m)=>{const p=bD.filter(g=>g.section===d.key);if(p.length===0)return null;const h=c(`sections.${d.key}`);return s.jsx("div",{children:s.jsxs("div",{className:m>0?"mt-3":"",children:[!r&&h&&s.jsx("div",{className:"px-3 py-1.5 mb-1 text-[10px] font-semibold text-fg-muted uppercase tracking-[0.1em]",children:h}),r&&m>0&&s.jsx("div",{className:"my-3"}),p.map(g=>{if(g.id===me.NOTIFICATIONS)return s.jsx(RK,{sidebarMode:!0,collapsed:r,userId:n?.id,label:c(g.id),iconPath:dc[g.id],isActive:e===g.id},g.id);const x=e===g.id;return s.jsxs("button",{onClick:()=>t(g.id),title:r?c(g.id):void 0,className:`w-full flex items-center ${r?"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 ${x?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[s.jsx(DK,{d:dc[g.id]??"",size:r?16:18}),r?s.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:c(g.id)}):s.jsx("span",{className:"truncate",children:c(g.id)})]},g.id)})]})},d.key)})}),s.jsx("div",{className:`shrink-0 border-t border-border-subtle ${r?"p-1.5 flex justify-center":"px-3 py-2.5"}`,children:s.jsx(OK,{authUser:n,onLogout:l,onEditProfile:()=>{window.dispatchEvent(new Event("markus:open-edit-profile"))},showSettingsLink:!1,collapsed:r,showVersion:!r})})]})}const IK=6e4;let Ps={},bi={};const Gh=new Set,Vh=new Set;let z3=0,ic=null,Cd=0,Ud=null;function p0(){for(const e of Gh)e()}async function Kh(){try{const e=await Ce.unread.getCounts();Ps=e.counts??{},bi=e.sessionAgentMap??{},p0()}catch{}}function PK(){ic||(Kh(),ic=setInterval(Kh,IK),Ud=va.on("chat:unread_update",e=>{const t=e.payload?.conversationKey;t&&!Vh.has(t)&&Date.now()>z3&&(Ps[t]=(Ps[t]??0)+1,p0())}))}function zK(){ic&&(clearInterval(ic),ic=null),Ud&&(Ud(),Ud=null)}function BK(e){const t=e?.enabled??!0,[n,r]=k.useState(Ps),[o,l]=k.useState(bi),c=k.useCallback(async()=>{await Kh()},[]),d=k.useCallback(async w=>{const C=new Date().toISOString();delete Ps[w],p0();try{await Ce.unread.markRead(w,C)}catch{}},[]),m=k.useCallback(async()=>{Ps={},p0();try{await Ce.unread.markAllRead()}catch{}},[]),p=k.useCallback(w=>{Vh.add(w)},[]),h=k.useCallback(w=>{Vh.delete(w),z3=Date.now()+150},[]);k.useEffect(()=>{if(!t)return;Cd++,PK();let w=bi;const C=()=>{r({...Ps}),w!==bi&&(w=bi,l({...bi}))};return Gh.add(C),r({...Ps}),l({...bi}),()=>{Gh.delete(C),Cd--,Cd<=0&&(Cd=0,zK())}},[t]);const g=k.useMemo(()=>Object.values(n).reduce((w,C)=>w+C,0),[n]),x=k.useCallback(w=>n[`session:${w}`]??0,[n]),y=k.useCallback(w=>n[`channel:${w}`]??0,[n]);return{counts:n,totalUnread:g,sessionAgentMap:o,getSessionUnread:x,getChannelUnread:y,markRead:d,markAllRead:m,refresh:c,setActiveKey:p,clearActiveKey:h}}function EY(e,t){return k.useMemo(()=>{const n=new Map;for(const[r,o]of Object.entries(t))if(r.startsWith("session:")){const l=r.slice(8),c=e[l];c&&n.set(c,(n.get(c)??0)+o)}return n},[e,t])}function UK({currentPage:e,onNavigate:t,userId:n}){const{t:r}=dt("nav"),[o,l]=k.useState(0),{counts:c}=BK({enabled:!0}),d=k.useMemo(()=>{let p=0;for(const h of Object.values(c))p+=h;return p},[c]),m=k.useCallback(async()=>{try{const p=await Ce.notifications.list(n,!1);l(p.unreadCount??p.notifications.filter(h=>!h.read).length)}catch{}},[n]);return k.useEffect(()=>{m();const p=setInterval(()=>{document.visibilityState==="visible"&&m()},3e4),h=()=>m();return window.addEventListener("markus:notifications-changed",h),()=>{clearInterval(p),window.removeEventListener("markus:notifications-changed",h)}},[m]),s.jsx("nav",{className:"fixed bottom-0 left-0 right-0 z-50 bg-surface-secondary flex items-stretch h-14 safe-area-bottom",children:xD.map(p=>{const h=p.group.includes(e),g=p.id===me.NOTIFICATIONS,x=p.id===me.TEAM;return s.jsxs("button",{onClick:()=>t(p.id),className:`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${h?"text-fg-primary":"text-fg-tertiary active:text-fg-secondary"}`,children:[s.jsxs("div",{className:"relative",children:[s.jsx("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:h?2:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("path",{d:dc[p.id]})}),g&&o>0&&s.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:o>99?"99+":o}),x&&d>0&&s.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:d>99?"99+":d})]}),s.jsx("span",{className:`text-[10px] leading-tight ${h?"font-semibold":""}`,children:r(p.id)})]},p.id)})})}const h0=new Map;function hi(e,t){h0.has(e)||h0.set(e,t().catch(()=>{}))}function wi(e){const t=h0.get(e);return h0.delete(e),t}const Tr={builderArtifacts:"builder.artifacts",builderAgents:"builder.agents",builderHubMyItems:"builder.hubMyItems",builderInstalled:"builder.installed",hubAgents:"hub.agents",hubTeams:"hub.teams",hubSkills:"hub.skills"},Ti={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 Ko(e){const t=(e||"").toLowerCase();return t==="team"?"team":t==="skill"?"skill":t==="connector"||t==="mcp"?"connector":"agent"}function B3(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 $K={agent:258,team:205,skill:32,connector:162};function Bg(e,t){const n=$K[e],r=B3(t),o=((n+(r%68-34))%360+360)%360,l=(o+22+(r>>>8)%24)%360;return`linear-gradient(${120+r%44}deg, hsl(${o} 72% 56%), hsl(${l} 66% 43%))`}const k4=["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 U3(e){return k4[B3(e+"g")%k4.length]}function $3(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 HK(e){return!e||$3(e)?!1:[...e].length<=4&&new RegExp("\\p{Extended_Pictographic}","u").test(e)}function FK(e,t="user"){const n=t==="org"?"shapes":"thumbs",r=encodeURIComponent(e);return`https://api.dicebear.com/9.x/${n}/svg?seed=${r}&radius=50&backgroundType=gradientLinear`}function Eo(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 S4(e,t="usd"){return!e||e<=0?"Free":`${t.toLowerCase()==="usd"?"$":""}${(e/100).toFixed(e%100===0?0:2)}`}const N4={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"}},qK=["development","devops","management","productivity","browser","custom","general"],GK=[{label:"Tech",emojis:["✦","◈","⬡","⚡","🤖","🧠","💡","🎯","🔧","📦","🚀","💻","🛠️","⭐","🔥","💎","⚙️","🧩","🔌","💾","🖥️","📡","🔬","🧪","🏗️","📱","🎮","🕹️","📟","💽","🖨️","⌨️"]},{label:"People",emojis:["👤","👥","🧑💻","👨💼","👩🔬","🧙","🦸","🤝","💪","🎓","👷","🕵️","🧑🎨","🧑🏫","👨🚀","🥷","🧑🏭","🧑⚕️","🧑🔧","🧑🍳","👨🎤","🦹","🧝","🧞","🧑✈️","💂","🤴","👸","🧛","🧟","🧜","🧚"]},{label:"Objects",emojis:["📝","📊","🗂️","📁","🔍","🔑","🌐","💬","🔒","🎨","📐","🗃️","📋","✏️","🖊️","📌","📎","🧲","🪝","🧰","🪜","🧬","🔭","💊","🩺","📕","📗","📘","📙","📓","🗒️","📰"]},{label:"Symbols",emojis:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","♠️","♥️","♦️","♣️","🎵","🎶","💯","✅","❌","⭕","🔴","🟠","🟡","🟢","🔵","🟣","⚫","⚪","🟤","🔶","🔷","▶️","⏸️","⏹️"]},{label:"Nature",emojis:["🌟","🌈","🌊","🌿","🍀","🔮","💫","✨","🌙","☀️","🦋","🐉","🦊","🐺","🦅","🐙","🦁","🐯","🦄","🐲","🌸","🌺","🍄","🌵","🎄","🌴","🍁","🌻","🐝","🦎","🐍","🦈"]},{label:"Activity",emojis:["🎯","🏆","🥇","🎖️","🏅","🎪","🎭","🎬","🎤","🎧","🎼","🎹","🥁","🎸","🎺","🎻","⚽","🏀","🎾","🏐","🎲","🧸","🪁","🎰","🎳","🏹","🥊","🤺","⛷️","🏄","🚴","🧗"]}],VK={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 Qp({value:e,onChange:t,renderAs:n="span",className:r,editClassName:o,placeholder:l,multiline:c,readOnly:d}){if(d){const j=e||l,P=`${r??""} ${!e?"text-fg-muted italic":""}`;return n==="h1"?s.jsx("h1",{className:P,children:j}):n==="p"?s.jsx("p",{className:P,children:j}):s.jsx("span",{className:P,children:j})}const[m,p]=k.useState(!1),[h,g]=k.useState(e),x=k.useRef(null);k.useEffect(()=>{g(e)},[e]),k.useEffect(()=>{m&&x.current?.focus()},[m]);const y=()=>{p(!1),h!==e&&t(h)},w=()=>{g(e),p(!1)},C=j=>{j.key==="Escape"&&w(),j.key==="Enter"&&!c&&y()};if(m){const j=`bg-transparent outline-none w-full ${o??r??""} ring-1 ring-brand-500/50 rounded px-1 -mx-1`;return c?s.jsx("textarea",{ref:x,value:h,onChange:O=>g(O.target.value),onBlur:y,onKeyDown:C,className:`${j} resize-y min-h-[60px]`,placeholder:l}):s.jsx("input",{ref:x,value:h,onChange:O=>g(O.target.value),onBlur:y,onKeyDown:C,className:j,placeholder:l})}const T=e||l,S=!e,_="cursor-text hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all";return n==="h1"?s.jsx("h1",{onClick:()=>p(!0),className:`${r??""} ${_} ${S?"text-fg-muted italic":""}`,children:T}):n==="p"?s.jsx("p",{onClick:()=>p(!0),className:`${r??""} ${_} ${S?"text-fg-muted italic":""}`,children:T}):n==="badge"?s.jsx("span",{onClick:()=>p(!0),className:`${r??""} ${_} ${S?"text-fg-muted italic":""}`,children:T}):s.jsx("span",{onClick:()=>p(!0),className:`${r??""} ${_} ${S?"text-fg-muted italic":""}`,children:T})}function KK({value:e,options:t,onChange:n,className:r,readOnly:o}){if(o)return s.jsx("span",{className:r,children:e});const[l,c]=k.useState(!1),[d,m]=k.useState(e),p=k.useRef(null),h=k.useRef(null);k.useEffect(()=>{l&&(m(e),setTimeout(()=>p.current?.focus(),0))},[l,e]);const g=t.filter(y=>y.toLowerCase().includes(d.toLowerCase())),x=y=>{const w=y.trim();w&&w!==e&&n(w),c(!1)};return l?s.jsxs("div",{ref:h,className:"relative inline-block",children:[s.jsx("input",{ref:p,value:d,onChange:y=>m(y.target.value),onKeyDown:y=>{y.key==="Enter"?(y.preventDefault(),x(d)):y.key==="Escape"&&c(!1)},onBlur:y=>{h.current?.contains(y.relatedTarget)||x(d)},className:`${r??""} bg-transparent outline-none ring-1 ring-brand-500/50 rounded w-28`}),g.length>0&&s.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:g.map(y=>s.jsx("button",{onMouseDown:w=>{w.preventDefault(),x(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))})]}):s.jsx("span",{onClick:()=>c(!0),className:`${r??""} cursor-pointer hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all`,children:e})}function WK({tags:e,onChange:t,readOnly:n}){if(n)return s.jsx("div",{className:"flex flex-wrap items-center gap-1.5 min-h-[24px]",children:e.map(h=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:h},h))});const{t:r}=dt(["builder"]),[o,l]=k.useState(!1),[c,d]=k.useState(""),m=k.useRef(null);k.useEffect(()=>{o&&m.current?.focus()},[o]);const p=h=>{if((h.key==="Enter"||h.key===",")&&c.trim()){h.preventDefault();const g=c.trim().toLowerCase();e.includes(g)||t([...e,g]),d("")}else h.key==="Backspace"&&!c&&e.length>0?t(e.slice(0,-1)):h.key==="Escape"&&(l(!1),d(""))};return o?s.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(h=>s.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:[h,s.jsx("button",{onClick:()=>t(e.filter(g=>g!==h)),className:"text-fg-muted hover:text-red-500",children:"×"})]},h)),s.jsx("input",{ref:m,value:c,onChange:h=>d(h.target.value),onKeyDown:p,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:r("detail.typeTagAndEnter")})]}):s.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(h=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:h},h)):s.jsx("span",{className:"text-[10px] text-fg-muted italic",children:r("detail.typeTagAndEnter")})})}function Wh({content:e}){return s.jsx("div",{className:`prose prose-invert prose-sm max-w-none
|
|
661
|
+
`)||void 0;o({approved:D,comment:X,selectedOption:$,answers:P})};return Sa.createPortal(s.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onMouseDown:P=>{P.target===P.currentTarget&&r()},children:s.jsxs("div",{className:"w-full max-w-2xl max-h-[85vh] flex flex-col bg-surface-secondary border border-border-default rounded-2xl shadow-2xl overflow-hidden",children:[s.jsxs("div",{className:"flex items-start gap-3 px-6 py-4 border-b border-border-default shrink-0",children:[s.jsx("div",{className:"w-9 h-9 rounded-lg bg-amber-500/15 text-amber-500 flex items-center justify-center shrink-0",children:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20z"}),s.jsx("path",{d:"M12 8v4"}),s.jsx("path",{d:"M12 16h.01"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h2",{className:"text-base font-semibold text-fg-primary leading-snug",children:e.title}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("p",{className:"text-xs text-fg-tertiary",children:e.agentName}),n&&s.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium bg-green-500/15 text-green-600",children:[s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}),l("team:userInput.submitted",{defaultValue:"Submitted"})]})]})]}),s.jsx("button",{onClick:r,className:"p-1.5 text-fg-tertiary hover:text-fg-primary rounded-md hover:bg-surface-overlay transition-colors shrink-0",title:l("common:close"),children:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]})})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[y&&s.jsx("div",{className:"flex items-center gap-2",children:c.map((P,D)=>s.jsx("button",{onClick:()=>m(D),className:`h-1.5 flex-1 rounded-full transition-colors ${D===d?"bg-brand-500":S(P)?"bg-green-500/60":"bg-border-default"}`,title:`${D+1}. ${P.prompt.slice(0,40)}`},P.id))}),y&&s.jsx("div",{className:"text-[11px] font-medium text-fg-tertiary",children:l("team:userInput.questionProgress",{current:d+1,total:c.length,defaultValue:`Question ${d+1} of ${c.length}`})}),s.jsx("div",{className:"text-sm text-fg-primary leading-relaxed",children:s.jsx(Er,{content:g.prompt})}),g.inputType==="choice"&&g.options&&s.jsx("div",{className:"space-y-2",children:g.options.map((P,D)=>{const $=w(g.id).selectedOptionIds.includes(P.id);return s.jsxs("button",{onClick:n?void 0:()=>T(g,P.id),disabled:n,className:`w-full px-4 py-3 text-left rounded-xl border transition-colors flex items-start gap-3 ${$?"border-brand-500 bg-brand-500/10":`border-border-default ${n?"":"hover:bg-surface-overlay"}`} ${n?"cursor-default":""} ${n&&!$?"opacity-50":""}`,children:[s.jsx("span",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[11px] font-bold shrink-0 mt-0.5 ${$?"bg-brand-600 text-white":"bg-surface-overlay text-fg-tertiary"}`,children:$?s.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}):String.fromCharCode(65+D)}),s.jsxs("span",{className:"flex-1 min-w-0 text-sm text-fg-primary [&_p]:my-0 [&_p]:text-sm",children:[s.jsx(Er,{content:P.label}),P.description&&s.jsx("span",{className:"block text-xs text-fg-tertiary mt-1 [&_p]:my-0 [&_p]:text-xs",children:s.jsx(Er,{content:P.description})})]})]},P.id)})}),(g.inputType==="text"||g.allowFreeform)&&(!n||w(g.id).text)&&s.jsx("textarea",{rows:g.inputType==="text"?4:2,readOnly:n,placeholder:g.inputType==="text"?l("team:userInput.textPlaceholder",{defaultValue:"Type your answer…"}):l("team:userInput.freeformPlaceholder",{defaultValue:"Or write your own answer…"}),value:w(g.id).text,onChange:P=>{const D=P.target.value;C(g.id,{text:D,selectedOptionIds:D.trim()&&g.inputType==="choice"?[]:w(g.id).selectedOptionIds})},className:`w-full px-3.5 py-2.5 text-sm bg-surface-overlay border border-border-default rounded-xl text-fg-primary placeholder:text-fg-tertiary focus:outline-none resize-y ${n?"cursor-default opacity-80":"focus:ring-1 focus:ring-brand-500/50"}`})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2 px-6 py-4 border-t border-border-default shrink-0",children:[s.jsx("div",{children:y&&d>0&&s.jsx("button",{onClick:()=>m(P=>Math.max(0,P-1)),className:"px-4 py-2 text-sm font-medium text-fg-secondary border border-border-default rounded-lg hover:bg-surface-overlay transition-colors",children:l("team:userInput.previous",{defaultValue:"Previous"})})}),s.jsx("div",{className:"flex items-center gap-2",children:y&&!x?s.jsx("button",{disabled:!n&&!S(g),onClick:()=>m(P=>Math.min(c.length-1,P+1)),className:"px-5 py-2 text-sm font-medium bg-brand-600 text-white rounded-lg hover:bg-brand-700 disabled:opacity-50 transition-colors",children:l("team:userInput.next",{defaultValue:"Next"})}):n?s.jsx("button",{onClick:r,className:"px-5 py-2 text-sm font-medium text-fg-secondary border border-border-default rounded-lg hover:bg-surface-overlay transition-colors",children:l("common:close",{defaultValue:"Close"})}):s.jsxs("button",{disabled:t||!_,onClick:O,className:"px-5 py-2 text-sm font-medium bg-brand-600 text-white rounded-lg hover:bg-brand-700 disabled:opacity-50 transition-colors inline-flex items-center gap-2",children:[t&&s.jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),l("team:userInput.submit",{defaultValue:"Submit"})]})})]})]})}),document.body)}function vd(e){return Array.isArray(e.questions)&&e.questions.length>0}const wd={urgent:"bg-red-500",high:"bg-amber-500",normal:"bg-blue-500",low:"bg-gray-400"},So={approval_request:"M9 12l2 2 4-4 M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z",task_completed:"M22 11.08V12a10 10 0 1 1-5.93-9.14 M22 4L12 14.01l-3-3",task_created:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",task_review:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",task_failed:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",requirement_created:"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",requirement_decision:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",agent_report:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8",direct_message:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",group_message:"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",system:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"},y4={approval_request:"text-amber-500",task_completed:"text-green-500",task_failed:"text-red-500",task_created:"text-blue-500",task_review:"text-purple-500",requirement_created:"text-amber-500",requirement_decision:"text-green-500",agent_report:"text-blue-500",direct_message:"text-green-500",group_message:"text-brand-500",system:"text-fg-tertiary"};function No(e,t){const n=Date.now()-new Date(e).getTime(),r=Math.floor(n/6e4);if(r<1)return t("common:time.now");if(r<60)return t("common:time.minutesAgo",{count:r});const o=Math.floor(r/60);return o<24?t("common:time.hoursAgo",{count:o}):t("common:time.daysAgo",{count:Math.floor(o/24)})}const v4="markus:template-updates-ack";let Wp=!1,kd=null;function MK(e){return e.map(t=>`${t.name}@${t.availableVersion}`).sort().join(",")}function w4(e,t){if(e.type!=="system"||!e.metadata?.templateUpdates)return!1;if(!t)return!0;const n=e.metadata.templateUpdatesFingerprint;return!n||n===t}function Sd(e,t){const n=e.actionType;if(n==="open_chat")return t("team:notifications.actionHints.openChat");if(n==="navigate")return t("team:notifications.actionHints.viewDetails");const r=e.metadata??{};switch(e.type){case"task_completed":case"task_created":case"task_review":case"task_failed":return r.taskId?t("team:notifications.actionHints.viewTask"):null;case"requirement_created":case"requirement_decision":return r.requirementId?t("team:notifications.actionHints.viewRequirement"):null;case"agent_report":return r.agentId?t("team:notifications.actionHints.viewAgent"):null;case"direct_message":return t("team:notifications.actionHints.openChat");case"group_message":return t("team:notifications.actionHints.openChat");case"approval_request":return t("team:notifications.actionHints.viewApproval");case"system":return r.templateUpdates?t("common:templateUpdates.actionHint"):null;default:return r.taskId?t("team:notifications.actionHints.viewTask"):r.requirementId?t("team:notifications.actionHints.viewRequirement"):r.agentId?t("team:notifications.actionHints.viewAgent"):null}}function Yp(){try{const e=new AudioContext,t=e.currentTime,n=e.createGain();n.connect(e.destination),n.gain.setValueAtTime(.15,t),n.gain.exponentialRampToValueAtTime(.01,t+.6);const r=e.createOscillator();r.type="sine",r.frequency.setValueAtTime(880,t),r.frequency.setValueAtTime(1174.66,t+.15),r.connect(n),r.start(t),r.stop(t+.6),r.onended=()=>e.close()}catch{}}function RK({collapsed:e,userId:t,embeddedMode:n,onClose:r,sidebarMode:o,isActive:l,label:c,iconPath:d}){const{t:m}=dt(["team","common"]),[p,h]=k.useState(!1),[g,x]=k.useState("approvals"),[y,w]=k.useState([]),[C,T]=k.useState([]),[S,_]=k.useState(null),[j,O]=k.useState(null),[P,D]=k.useState(null),[$,X]=k.useState({}),[ee,H]=k.useState(0),K=k.useRef(null),ae=k.useRef(null),[W,F]=k.useState({top:0,left:0,width:448,maxHeight:576}),Z=k.useRef(null),U=k.useRef(!1),[Q,ne]=k.useState(!0),[ke,B]=k.useState(!1),q=k.useRef(null),le=k.useRef("approvals"),[I,Ae]=k.useState(!1),$e=30,Oe=k.useCallback(async()=>{try{Ya("/approvals"),Ya("/notifications");const[R,oe]=await Promise.all([Ce.notifications.list(t,!1,{limit:$e,offset:0}),Ce.approvals.list()]);w(R.notifications);const _e=R.unreadCount??R.notifications.filter(de=>!de.read).length;if(H(_e),ne(R.totalCount!=null?R.notifications.length<R.totalCount:R.notifications.length>=$e),T(oe.approvals),!U.current){const de=oe.approvals.filter(Pe=>Pe.status==="pending").length;Z.current=de,U.current=!0}}catch{}},[t]),We=k.useCallback(async()=>{if(!(ke||!Q)){B(!0);try{const R=await Ce.notifications.list(t,!1,{limit:$e,offset:y.length});R.notifications.length>0&&w(oe=>[...oe,...R.notifications.filter(_e=>!oe.some(de=>de.id===_e.id))]),ne(R.totalCount!=null?y.length+R.notifications.length<R.totalCount:R.notifications.length>=$e)}catch{}B(!1)}},[t,y.length,ke,Q]),st=k.useCallback(R=>{const oe=R.detail;if(!oe)return;const{taskId:_e,requirementId:de}=oe;!_e&&!de||w(Pe=>{const Ve=Pe.filter(G=>!G.read&&(_e&&G.metadata?.taskId===_e||de&&G.metadata?.requirementId===de));if(Ve.length===0)return Pe;for(const G of Ve)Ce.notifications.markRead(G.id).catch(()=>{});return H(G=>Math.max(0,G-Ve.length)),Pe.map(G=>Ve.some(ie=>ie.id===G.id)?{...G,read:!0}:G)})},[]),mt=k.useRef(y);mt.current=y;const At=k.useCallback(async()=>{if(!mt.current.some(oe=>!oe.read&&oe.type==="system"&&oe.metadata?.creditExhausted))try{await Ce.notifications.create({title:m("credits.notificationTitle",{ns:"common"}),body:m("credits.notificationBody",{ns:"common"}),type:"system",priority:"urgent",metadata:{creditExhausted:!0}}),Oe(),Yp()}catch{}},[Oe,m]),gt=k.useCallback(async()=>{if(!Wp){Wp=!0;try{const{updates:R}=await Ce.skills.updates();if(!R.length)return;const oe=MK(R);try{if(localStorage.getItem(v4)===oe)return}catch{}if(kd===oe||mt.current.some(de=>!de.read&&w4(de,oe)))return;try{const Pe=(await Ce.notifications.list(t,!0,{limit:50,type:"system"})).notifications.filter(Ve=>w4(Ve,oe)).sort((Ve,G)=>new Date(G.createdAt).getTime()-new Date(Ve.createdAt).getTime());if(Pe.length>0){for(const Ve of Pe.slice(1))Ce.notifications.markRead(Ve.id).catch(()=>{});Pe.length>1&&Oe(),kd=oe;return}}catch{}kd=oe,await Ce.notifications.create({title:m("templateUpdates.notificationTitle",{ns:"common"}),body:m("templateUpdates.notificationBody",{ns:"common",count:R.length}),type:"system",priority:"high",metadata:{templateUpdates:!0,templateUpdatesFingerprint:oe,count:R.length,skills:R.map(de=>de.name)}}),Oe(),Yp()}catch{kd=null}finally{Wp=!1}}},[Oe,m,t]);k.useEffect(()=>{Oe();const R=setInterval(Oe,6e4);let oe=null;const _e=()=>{oe||(oe=setTimeout(()=>{oe=null,Oe()},400))},de=()=>_e(),Pe=()=>{h(!0),Oe()};window.addEventListener("markus:notifications-changed",de),window.addEventListener("markus:mark-read-by-ref",st),window.addEventListener("markus:open-notifications",Pe),window.addEventListener("markus:credit-exhausted",At);const Ve=va.on("notification",_e),G=va.on("approval:requested",_e);return()=>{clearInterval(R),oe&&clearTimeout(oe),window.removeEventListener("markus:notifications-changed",de),window.removeEventListener("markus:mark-read-by-ref",st),window.removeEventListener("markus:open-notifications",Pe),window.removeEventListener("markus:credit-exhausted",At),Ve(),G()}},[Oe,st,At]),k.useEffect(()=>{gt();const R=setInterval(()=>{gt()},5*6e4),oe=()=>{gt()};return window.addEventListener("markus:data-changed",oe),()=>{clearInterval(R),window.removeEventListener("markus:data-changed",oe)}},[t]);const jt=k.useCallback(()=>{if(!K.current)return;const R=K.current.getBoundingClientRect(),oe=window.innerWidth,_e=window.innerHeight,de=Math.min(448,oe-16),Pe=Math.min(576,_e-16);let Ve=R.right+8,G=R.top;Ve+de>oe-8&&(Ve=Math.max(8,oe-de-8)),G+Pe>_e-8&&(G=Math.max(8,_e-Pe-8)),F({top:G,left:Ve,width:de,maxHeight:Pe})},[]);k.useLayoutEffect(()=>{p&&jt()},[p,jt]),k.useEffect(()=>{if(p)return window.addEventListener("resize",jt),()=>window.removeEventListener("resize",jt)},[p,jt]),k.useEffect(()=>{if(!p)return;const R=oe=>{K.current?.contains(oe.target)||ae.current?.contains(oe.target)||h(!1)};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[p]),k.useEffect(()=>{if(!p)return;const R=C.some(_e=>_e.status==="pending"),oe=y.some(_e=>!_e.read);x(R&&!oe?"approvals":!R&&oe?"notifications":le.current)},[p]);const Jt=new Set(C.filter(R=>R.status==="pending").map(R=>R.id)),Rt=new Set(C.map(R=>R.id)),be=y.filter(R=>!(R.type==="approval_request"&&R.metadata?.approvalId&&Rt.has(R.metadata.approvalId))),Me=y.filter(R=>R.type==="approval_request"&&!R.read&&R.metadata?.approvalId&&Jt.has(R.metadata.approvalId)).length,qe=Math.max(0,ee-Me),ot=Jt.size,ft=qe+ot;k.useEffect(()=>{Z.current!==null&&ot>Z.current&&Yp(),Z.current=ot},[ot]);const se=async R=>{await Ce.notifications.markRead(R),w(oe=>oe.map(_e=>_e.id===R?{..._e,read:!0}:_e)),H(oe=>Math.max(0,oe-1)),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))},Be=R=>{const oe=R.metadata??{},_e=R.actionType,de=R.actionTarget;if(_e==="open_chat"&&de)try{const Pe=typeof de=="string"?JSON.parse(de):de;if(Pe.agentId){const Ve={agentId:Pe.agentId};Pe.sessionId&&(Ve.sessionId=Pe.sessionId),at.navigate(me.TEAM,Ve);return}}catch{}if(_e==="navigate"&&de)try{const Pe=typeof de=="string"?JSON.parse(de):de;if(Pe.path){if(Pe.path.startsWith("/team")){const Ve={},G=new URLSearchParams(Pe.path.split("?")[1]||"");for(const[ie,Ne]of G.entries())Ve[ie]=Ne;at.navigate(me.TEAM,Ve);return}if(Pe.path.startsWith("/work")){const Ve={},G=new URLSearchParams(Pe.path.split("?")[1]||"");for(const[ie,Ne]of G.entries())Ve[ie]=Ne;at.navigate(me.WORK,Ve);return}}}catch{}switch(R.type){case"approval_request":{const Pe=oe.approvalId,Ve=Pe?C.find(Le=>Le.id===Pe):void 0;if(Ve&&vd(Ve)){O(Ve);break}const G=Ve?.details?.taskId??oe.taskId,ie=Ve?.details?.requirementId??oe.requirementId,Ne=Ve?.details?.agentId??Ve?.agentId;G?at.navigate(me.WORK,{openTask:G}):ie?at.navigate(me.WORK,{openRequirement:ie}):Ne?at.navigate(me.TEAM,{agentId:Ne}):at.navigate(me.WORK);break}case"task_completed":case"task_created":case"task_review":case"task_failed":oe.taskId?at.navigate(me.WORK,{openTask:oe.taskId}):at.navigate(me.WORK);break;case"requirement_created":case"requirement_decision":oe.requirementId?at.navigate(me.WORK,{openRequirement:oe.requirementId}):at.navigate(me.WORK);break;case"agent_report":case"system":{if(oe.creditExhausted){Ae(!0);return}if(oe.templateUpdates){const Pe=oe.templateUpdatesFingerprint;if(Pe)try{localStorage.setItem(v4,Pe)}catch{}localStorage.setItem("markus_nav_storeTab","installed"),at.navigate(me.STORE);return}if(oe.agentId){const Pe={agentId:oe.agentId};oe.sessionId&&(Pe.sessionId=oe.sessionId),at.navigate(me.TEAM,Pe)}else at.navigate(me.TEAM);break}case"direct_message":{const Pe=oe.senderId;Pe?at.navigate(me.TEAM,{dm:Pe}):at.navigate(me.TEAM);break}case"group_message":{const Pe=oe.channel;Pe?at.navigate(me.TEAM,{channel:Pe}):at.navigate(me.TEAM);break}default:oe.taskId?at.navigate(me.WORK,{openTask:oe.taskId}):oe.requirementId?at.navigate(me.WORK,{openRequirement:oe.requirementId}):oe.projectId?at.navigate(me.WORK,{projectId:oe.projectId}):oe.agentId&&at.navigate(me.TEAM,{agentId:oe.agentId});break}},Xe=async R=>{const oe=R.metadata??{},_e=R.actionType,de=R.type==="agent_report"&&!oe.creditExhausted&&!oe.templateUpdates&&(_e==="open_chat"||!!oe.agentId&&_e!=="navigate");!R.read&&!de&&se(R.id);const Pe=oe.taskId,Ve=oe.requirementId;if(!de&&(Pe||Ve)){const G=y.filter(ie=>ie.id!==R.id&&!ie.read&&(Pe&&ie.metadata?.taskId===Pe||Ve&&ie.metadata?.requirementId===Ve));for(const ie of G)se(ie.id)}Be(R)},Ge=async(R,oe,_e,de,Pe)=>{_(R);try{const{approval:Ve}=await Ce.approvals.respond(R,oe,t,_e,de,Pe);T(Le=>Le.map(Je=>Je.id===R?Ve:Je)),O(null),D(null),X(Le=>{const Je={...Le};return delete Je[R],Je});const G=Ve.details?.taskId,ie=Ve.details?.requirementId,Ne=y.filter(Le=>!Le.read&&(Le.type==="approval_request"&&Le.metadata?.approvalId===R||G&&Le.metadata?.taskId===G||ie&&Le.metadata?.requirementId===ie));if(Ne.length>0){for(const Je of Ne)Ce.notifications.markRead(Je.id).catch(()=>{});const Le=new Set(Ne.map(Je=>Je.id));w(Je=>Je.map(vt=>Le.has(vt.id)?{...vt,read:!0}:vt)),H(Je=>Math.max(0,Je-Ne.length))}Ya("/approvals"),Ya("/notifications"),Ya("/tasks"),Ya("/taskboard"),Ya("/requirements"),window.dispatchEvent(new CustomEvent("markus:data-changed")),window.dispatchEvent(new CustomEvent("markus:notifications-changed")),setTimeout(()=>Oe(),800)}catch{}_(null)},et=async()=>{try{if(!t)return;await Ce.notifications.markAllRead(t),w(R=>R.map(oe=>({...oe,read:!0}))),H(0),Ya("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}catch{const R=be.filter(oe=>!oe.read);await Promise.all(R.map(oe=>Ce.notifications.markRead(oe.id))),w(oe=>oe.map(_e=>({..._e,read:!0}))),H(0),Ya("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}},yt=R=>{const oe=R.details?.subType;return oe==="requirement_resubmit"?m("team:notifications.approvalType.requirementResubmit"):oe==="requirement"||R.details?.requirementId?m("team:notifications.approvalType.requirement"):oe==="task_review"?m("team:notifications.approvalType.taskReview"):oe==="task"||R.details?.taskId?m("team:notifications.approvalType.task"):R.details?.toolName?m("team:notifications.approvalType.toolExecution"):null},he=R=>{const oe=[];oe.push(R.agentName);const _e=R.details?.taskTitle,de=R.details?.taskId;_e?oe.push(_e):de&&oe.push(`Task ${de.slice(0,8)}`);const Pe=R.details?.requirementId;return Pe&&!de&&oe.push(`Req ${Pe.slice(0,8)}`),oe.join(" · ")},V=[...C].sort((R,oe)=>new Date(oe.requestedAt).getTime()-new Date(R.requestedAt).getTime()),ye=V.filter(R=>R.status==="pending"),Qe=V.filter(R=>R.status!=="pending"),pe=R=>{const oe=R.details?.taskId,_e=R.details?.requirementId,de=R.details?.agentId??R.agentId;oe?at.navigate(me.WORK,{openTask:oe}):_e?at.navigate(me.WORK,{openRequirement:_e}):de?at.navigate(me.TEAM,{agentId:de}):at.navigate(me.WORK)},ve=()=>{h(!1),r?.()},Ye=R=>s.jsxs("button",{disabled:S===R.id,onClick:()=>O(R),className:"w-full px-3 py-2 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors inline-flex items-center justify-center gap-1.5",children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.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"})}),m("team:userInput.respond",{defaultValue:"Respond"}),R.questions&&R.questions.length>1?` (${R.questions.length})`:""]}),nt=j?s.jsx(jK,{approval:j,submitting:S===j.id,readOnly:j.status!=="pending",onClose:()=>O(null),onSubmit:R=>Ge(j.id,R.approved,R.comment,R.selectedOption,R.answers)}):null,xt=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex border-b border-border-default shrink-0",children:[s.jsxs("button",{onClick:()=>{x("approvals"),le.current="approvals"},className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${g==="approvals"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:[m("team:notifications.approvals"),ot>0?` (${ot})`:""]}),s.jsxs("button",{onClick:()=>{x("notifications"),le.current="notifications"},className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${g==="notifications"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:[m("team:notifications.notifications"),qe>0?` (${qe})`:""]}),s.jsx("button",{onClick:ve,className:"px-2 py-2 text-fg-tertiary hover:text-fg-primary transition-colors shrink-0",title:m("common:close"),children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]})})]}),g==="notifications"&&ee>0&&s.jsx("div",{className:"flex justify-end px-3 py-1.5 border-b border-border-default/50 shrink-0",children:s.jsx("button",{onClick:et,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:m("team:notifications.markAllRead")})}),s.jsxs("div",{ref:q,className:"flex-1 overflow-y-auto",onScroll:R=>{if(g!=="notifications"||!Q||ke)return;const oe=R.currentTarget;oe.scrollTop+oe.clientHeight>=oe.scrollHeight-80&&We()},children:[g==="approvals"&&(C.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noApprovals")}):s.jsxs("div",{className:"divide-y divide-border-default/50",children:[ye.map(R=>{const oe=R.details?.command,_e=oe?R.description.replace(/\s*Command:.*$/,""):R.description;return s.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[s.jsxs("div",{className:"cursor-pointer hover:bg-surface-overlay/50 -mx-3 -mt-3 px-3 pt-3 pb-1 rounded-t-md transition-colors",onClick:()=>pe(R),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-amber-500 mt-0.5 shrink-0",children:s.jsx("path",{d:So.approval_request})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[yt(R)&&s.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:yt(R)}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:R.title}),s.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:No(R.requestedAt,m)})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:R.agentName})]})]}),s.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:s.jsx(Er,{content:_e,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),oe&&s.jsx("pre",{className:"text-[11px] text-fg-primary bg-surface-overlay border border-border-default rounded-md px-2.5 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono leading-relaxed mt-2",children:oe})]}),(()=>{if(vd(R))return Ye(R);const de=R.details?.subType,Pe=de==="task"||de==="requirement"||de==="requirement_resubmit",Ve=R.options&&R.options.length>0,G=($[R.id]??"").trim();return Ve?s.jsxs("div",{className:"space-y-1.5",children:[R.options.map((ie,Ne)=>s.jsxs("button",{disabled:S===R.id,onClick:()=>Ge(R.id,ie.id!=="reject",G||void 0,ie.id),className:`w-full px-3 py-2 text-left text-[11px] font-medium rounded-md disabled:opacity-50 transition-colors flex items-center gap-2 ${ie.id==="reject"||ie.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:ie.description,children:[s.jsx("span",{className:"w-5 h-5 rounded-full bg-white/20 flex items-center justify-center text-[10px] font-bold shrink-0",children:String.fromCharCode(65+Ne)}),ie.label]},ie.id)),s.jsxs("div",{className:"flex gap-1.5 mt-1",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:$[R.id]??"",onChange:ie=>X(Ne=>({...Ne,[R.id]:ie.target.value})),onKeyDown:ie=>{ie.key==="Enter"&&($[R.id]??"").trim()&&Ge(R.id,!0,($[R.id]??"").trim(),"custom")},className:"flex-1 px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),s.jsx("button",{disabled:S===R.id||!($[R.id]??"").trim(),onClick:()=>Ge(R.id,!0,($[R.id]??"").trim(),"custom"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors",children:m("common:send")})]})]}):Pe?s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{disabled:S===R.id,onClick:()=>Ge(R.id,!0,void 0,"approve"),className:"px-3 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}),m("common:approve")]}),s.jsxs("button",{disabled:S===R.id,onClick:()=>Ge(R.id,!1,void 0,"reject"),className:"px-3 py-1.5 text-[11px] font-medium bg-red-600/80 text-white rounded-md hover:bg-red-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]}),m("common:reject")]}),P!==R.id&&s.jsxs("button",{disabled:S===R.id,onClick:()=>D(R.id),className:"px-3 py-1.5 text-[11px] font-medium border border-amber-500/50 text-amber-500 rounded-md hover:bg-amber-500/10 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),s.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),m("team:notifications.needsAdjustment")]})]}),P===R.id&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:$[R.id]??"",onChange:ie=>X(Ne=>({...Ne,[R.id]:ie.target.value})),onKeyDown:ie=>{ie.key==="Enter"&&($[R.id]??"").trim()&&Ge(R.id,!1,($[R.id]??"").trim(),"needs_adjustment"),ie.key==="Escape"&&D(null)},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-amber-500/50"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:S===R.id||!($[R.id]??"").trim(),onClick:()=>Ge(R.id,!1,($[R.id]??"").trim(),"needs_adjustment"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-amber-600 text-white rounded-md hover:bg-amber-700 disabled:opacity-50 transition-colors",children:m("team:notifications.confirmAdjustment")}),s.jsx("button",{onClick:()=>D(null),className:"px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay transition-colors",children:m("common:cancel")})]})]})]}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.commentPlaceholder"),value:$[R.id]??"",onChange:ie=>X(Ne=>({...Ne,[R.id]:ie.target.value})),onKeyDown:ie=>{ie.key==="Enter"&&Ge(R.id,!0,G||void 0,"approve")},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:S===R.id,onClick:()=>Ge(R.id,!0,G||void 0,"approve"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors",children:m("common:approve")}),s.jsx("button",{disabled:S===R.id,onClick:()=>Ge(R.id,!1,G||void 0,"reject"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay disabled:opacity-50 transition-colors",children:m("common:reject")})]})]})})()]},R.id)}),Qe.length>0&&s.jsxs(s.Fragment,{children:[ye.length>0&&s.jsx("div",{className:"px-3 py-1.5 text-[10px] font-medium text-fg-tertiary uppercase tracking-wider bg-surface-overlay/30",children:m("team:notifications.approvalHistory")}),Qe.slice(0,50).map(R=>s.jsxs("button",{onClick:()=>vd(R)?O(R):pe(R),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors group",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${R.status==="approved"?"bg-green-500":R.status==="cancelled"||R.status==="expired"?"bg-gray-400":"bg-red-500"}`}),yt(R)&&s.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium shrink-0",children:yt(R)}),s.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1 group-hover:text-fg-primary",children:R.title}),s.jsx("span",{className:`text-[10px] font-medium shrink-0 ${R.status==="approved"?"text-green-500":R.status==="cancelled"||R.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${R.status}`,{defaultValue:R.status})})]}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 pl-3.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted truncate",children:he(R)}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:No(R.respondedAt??R.requestedAt,m)})]}),R.responseComment&&s.jsxs("p",{className:"text-[10px] text-fg-muted mt-0.5 pl-3.5 truncate",children:["“",R.responseComment,"”"]})]},R.id))]})]})),g==="notifications"&&(be.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noNotifications")}):s.jsxs("div",{className:"divide-y divide-border-default/50",children:[be.map(R=>{const oe=y4[R.type]??"text-fg-tertiary";return s.jsxs("div",{role:"button",tabIndex:0,onClick:()=>Xe(R),onKeyDown:_e=>{(_e.key==="Enter"||_e.key===" ")&&(_e.preventDefault(),Xe(R))},className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors cursor-pointer ${R.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"shrink-0 mt-0.5",children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:oe,children:s.jsx("path",{d:So[R.type]??So.system})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[!R.read&&s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${wd[R.priority]??wd.normal}`}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:R.title})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:s.jsx(Er,{content:R.body,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted",children:No(R.createdAt,m)}),Sd(R,m)&&s.jsx("span",{className:`text-[10px] font-medium ${oe}`,children:Sd(R,m)})]})]})]},R.id)}),ke&&s.jsx("div",{className:"py-3 text-center",children:s.jsxs("svg",{className:"animate-spin h-4 w-4 text-fg-tertiary mx-auto",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})})]}))]})]}),Dt=k.useCallback(R=>{R?.mute&&EK()},[]),ct=k.useCallback(R=>{Dt(R),Ae(!1)},[Dt]),Xt=I?s.jsx(dr,{title:m("credits.dialogTitle",{ns:"common"}),message:m("credits.dialogDesc",{ns:"common"}),variant:"primary",cancelLabel:m("credits.configureModels",{ns:"common"}),confirmLabel:m("credits.topUp",{ns:"common"}),checkboxes:[{id:"mute",label:m("credits.dontRemind",{ns:"common"})}],onCancel:()=>Ae(!1),onCancelClick:R=>{ct(R),at.navigate(me.SETTINGS),setTimeout(()=>{window.location.hash="settings/providers"},50)},onConfirm:R=>{const oe=`${it.getUrl().replace(/\/$/,"")}/settings?tab=billing`;ct(R),Ai(oe)}}):null;if(n){const R=["approvals","notifications"],oe=R.indexOf(g),_e=(()=>{let de=0,Pe=0;return{onTouchStart:Ve=>{de=Ve.touches[0].clientX,Pe=Ve.touches[0].clientY},onTouchEnd:Ve=>{const G=Ve.changedTouches[0].clientX-de,ie=Ve.changedTouches[0].clientY-Pe;Math.abs(G)>60&&Math.abs(G)>Math.abs(ie)*1.5&&(G<0&&oe<R.length-1&&x(R[oe+1]),G>0&&oe>0&&x(R[oe-1]))}}})();return s.jsxs(s.Fragment,{children:[Xt,s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[nt,s.jsx("div",{className:"flex border-b border-border-default shrink-0",children:R.map(de=>s.jsx("button",{onClick:()=>x(de),className:`flex-1 px-3 py-3 text-sm font-medium transition-colors ${g===de?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary"}`,children:de==="approvals"?s.jsxs(s.Fragment,{children:[m("team:notifications.approvals"),ot>0?` (${ot})`:""]}):s.jsxs(s.Fragment,{children:[m("team:notifications.notifications"),qe>0?` (${qe})`:""]})},de))}),g==="notifications"&&ee>0&&s.jsx("div",{className:"flex justify-end px-3 py-1.5 border-b border-border-default/50 shrink-0",children:s.jsx("button",{onClick:et,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:m("team:notifications.markAllRead")})}),s.jsx("div",{className:"flex-1 overflow-hidden relative",..._e,children:s.jsxs("div",{className:"flex h-full transition-transform duration-300 ease-out",style:{transform:`translateX(-${oe*100}%)`},children:[s.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:C.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noApprovals")}):s.jsxs("div",{className:"divide-y divide-border-default/50",children:[ye.map(de=>{const Pe=de.details?.command,Ve=Pe?de.description.replace(/\s*Command:.*$/,""):de.description;return s.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[s.jsxs("div",{className:"cursor-pointer hover:bg-surface-overlay/50 -mx-3 -mt-3 px-3 pt-3 pb-1 rounded-t-md transition-colors",onClick:()=>pe(de),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-amber-500 mt-0.5 shrink-0",children:s.jsx("path",{d:So.approval_request})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[yt(de)&&s.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:yt(de)}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:de.title}),s.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:No(de.requestedAt,m)})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:de.agentName})]})]}),s.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:s.jsx(Er,{content:Ve,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),Pe&&s.jsx("pre",{className:"text-[11px] text-fg-primary bg-surface-overlay border border-border-default rounded-md px-2.5 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono leading-relaxed mt-2",children:Pe})]}),(()=>{if(vd(de))return Ye(de);const G=de.details?.subType,ie=G==="task"||G==="requirement"||G==="requirement_resubmit",Ne=de.options&&de.options.length>0,Le=($[de.id]??"").trim();return Ne?s.jsxs("div",{className:"space-y-1.5",children:[de.options.map((Je,vt)=>s.jsxs("button",{disabled:S===de.id,onClick:()=>Ge(de.id,Je.id!=="reject",Le||void 0,Je.id),className:`w-full px-3 py-2 text-left text-[11px] font-medium rounded-md disabled:opacity-50 transition-colors flex items-center gap-2 ${Je.id==="reject"||Je.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:Je.description,children:[s.jsx("span",{className:"w-5 h-5 rounded-full bg-white/20 flex items-center justify-center text-[10px] font-bold shrink-0",children:String.fromCharCode(65+vt)}),Je.label]},Je.id)),s.jsxs("div",{className:"flex gap-1.5 mt-1",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:$[de.id]??"",onChange:Je=>X(vt=>({...vt,[de.id]:Je.target.value})),onKeyDown:Je=>{Je.key==="Enter"&&($[de.id]??"").trim()&&Ge(de.id,!0,($[de.id]??"").trim(),"custom")},className:"flex-1 px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),s.jsx("button",{disabled:S===de.id||!($[de.id]??"").trim(),onClick:()=>Ge(de.id,!0,($[de.id]??"").trim(),"custom"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors",children:m("common:send")})]})]}):ie?s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{disabled:S===de.id,onClick:()=>Ge(de.id,!0,void 0,"approve"),className:"px-3 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}),m("common:approve")]}),s.jsxs("button",{disabled:S===de.id,onClick:()=>Ge(de.id,!1,void 0,"reject"),className:"px-3 py-1.5 text-[11px] font-medium bg-red-600/80 text-white rounded-md hover:bg-red-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]}),m("common:reject")]}),P!==de.id&&s.jsxs("button",{disabled:S===de.id,onClick:()=>D(de.id),className:"px-3 py-1.5 text-[11px] font-medium border border-amber-500/50 text-amber-500 rounded-md hover:bg-amber-500/10 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),s.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),m("team:notifications.needsAdjustment")]})]}),P===de.id&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:$[de.id]??"",onChange:Je=>X(vt=>({...vt,[de.id]:Je.target.value})),onKeyDown:Je=>{Je.key==="Enter"&&($[de.id]??"").trim()&&Ge(de.id,!1,($[de.id]??"").trim(),"needs_adjustment"),Je.key==="Escape"&&D(null)},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-amber-500/50"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:S===de.id||!($[de.id]??"").trim(),onClick:()=>Ge(de.id,!1,($[de.id]??"").trim(),"needs_adjustment"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-amber-600 text-white rounded-md hover:bg-amber-700 disabled:opacity-50 transition-colors",children:m("team:notifications.confirmAdjustment")}),s.jsx("button",{onClick:()=>D(null),className:"px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay transition-colors",children:m("common:cancel")})]})]})]}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.commentPlaceholder"),value:$[de.id]??"",onChange:Je=>X(vt=>({...vt,[de.id]:Je.target.value})),onKeyDown:Je=>{Je.key==="Enter"&&Ge(de.id,!0,Le||void 0,"approve")},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:S===de.id,onClick:()=>Ge(de.id,!0,Le||void 0,"approve"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors",children:m("common:approve")}),s.jsx("button",{disabled:S===de.id,onClick:()=>Ge(de.id,!1,Le||void 0,"reject"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay disabled:opacity-50 transition-colors",children:m("common:reject")})]})]})})()]},de.id)}),Qe.length>0&&s.jsxs(s.Fragment,{children:[ye.length>0&&s.jsx("div",{className:"px-3 py-1.5 text-[10px] font-medium text-fg-tertiary uppercase tracking-wider bg-surface-overlay/30",children:m("team:notifications.approvalHistory")}),Qe.slice(0,50).map(de=>s.jsxs("button",{onClick:()=>pe(de),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${de.status==="approved"?"bg-green-500":de.status==="cancelled"||de.status==="expired"?"bg-gray-400":"bg-red-500"}`}),s.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:de.title}),s.jsx("span",{className:`text-[10px] font-medium shrink-0 ${de.status==="approved"?"text-green-500":de.status==="cancelled"||de.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${de.status}`,{defaultValue:de.status})})]}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 pl-3.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted truncate",children:he(de)}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:No(de.respondedAt??de.requestedAt,m)})]})]},de.id))]})]})}),s.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:be.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noNotifications")}):s.jsx("div",{className:"divide-y divide-border-default/50",children:be.slice(0,50).map(de=>{const Pe=y4[de.type]??"text-fg-tertiary";return s.jsxs("button",{onClick:()=>Xe(de),className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors ${de.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"shrink-0 mt-0.5",children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:Pe,children:s.jsx("path",{d:So[de.type]??So.system})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[!de.read&&s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${wd[de.priority]??wd.normal}`}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:de.title})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:s.jsx(Er,{content:de.body,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted",children:No(de.createdAt,m)}),Sd(de,m)&&s.jsx("span",{className:`text-[10px] font-medium ${Pe}`,children:Sd(de,m)})]})]})]},de.id)})})})]})})]})]})}if(o){const R=d||"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9 M13.73 21a2 2 0 0 1-3.46 0";return s.jsxs(s.Fragment,{children:[nt,s.jsxs("button",{ref:K,onClick:()=>{h(!p),p||Oe()},title:e?c||m("team:notifications.bellTitle"):void 0,className:`w-full flex items-center ${e?"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 relative text-fg-primary ${p||l?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[s.jsx("svg",{width:e?16:18,height:e?16:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("path",{d:R})}),e?s.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:c}):s.jsx("span",{className:"truncate",children:c}),ft>0&&s.jsx("span",{className:`absolute ${e?"top-0.5 right-1":"top-1 left-[22px]"} min-w-[16px] h-4 px-1 rounded-full bg-red-500 text-white text-[10px] font-bold flex items-center justify-center leading-none`,children:ft>99?m("common:badgeOverLimit"):ft})]}),p&&Sa.createPortal(s.jsx("div",{ref:ae,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:W.top,left:W.left,width:W.width,maxHeight:W.maxHeight},children:xt}),document.body),Xt]})}return s.jsxs(s.Fragment,{children:[nt,s.jsxs("button",{ref:K,onClick:()=>{h(!p),p||Oe()},className:`relative flex items-center justify-center rounded-md transition-colors ${e?"w-8 h-8":"w-7 h-7"} ${p?"bg-surface-overlay text-fg-primary":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay"}`,title:m("team:notifications.bellTitle"),children:[s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),s.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),ft>0&&s.jsx("span",{className:"absolute -top-0.5 -right-0.5 min-w-[16px] h-4 px-1 rounded-full bg-red-500 text-white text-[10px] font-bold flex items-center justify-center leading-none",children:ft>99?m("common:badgeOverLimit"):ft})]}),p&&Sa.createPortal(s.jsx("div",{ref:ae,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:W.top,left:W.left,width:W.width,maxHeight:W.maxHeight},children:xt}),document.body),Xt]})}function Nd({d:e,size:t=14}){return s.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:s.jsx("path",{d:e})})}const Xp=200;function OK({authUser:e,onLogout:t,onEditProfile:n,showSettingsLink:r=!1,collapsed:o=!1,showVersion:l=!1}){const{t:c}=dt(["nav","common"]),[d,m]=k.useState(!1),[p,h]=k.useState(!1),[g,x]=k.useState(()=>it.isAuthenticated()),[y,w]=k.useState(()=>sa()),[C,T]=k.useState({top:0,left:0}),S=k.useRef(null),_=k.useRef(null),j=k.useCallback(W=>{if(w(sa()),!it.isAuthenticated()){x(!1);return}if(!W?.validate){x(!0);return}m5().then(F=>{x(F),w(sa())})},[]);k.useEffect(()=>{j({validate:!0});const W=()=>j(),F=()=>j({validate:!0});return window.addEventListener("markus:hub-auth",W),window.addEventListener("focus",F),()=>{window.removeEventListener("markus:hub-auth",W),window.removeEventListener("focus",F)}},[j]);const O=k.useCallback(()=>{if(!S.current)return;const W=S.current.getBoundingClientRect(),F=window.innerWidth,Z=window.innerHeight,U=_.current?.offsetHeight??220;let Q=W.right+8;Q+Xp>F-8&&(Q=Math.max(8,W.left-Xp-8));let ne=W.top-U-8;ne<8&&(ne=Math.min(W.bottom+8,Z-U-8)),T({top:Math.max(8,ne),left:Q})},[]);k.useLayoutEffect(()=>{if(!d)return;O();const W=requestAnimationFrame(()=>O());return()=>cancelAnimationFrame(W)},[d,O,o]),k.useEffect(()=>{if(!d)return;const W=Z=>{const U=Z.target;S.current?.contains(U)||_.current?.contains(U)||m(!1)},F=()=>O();return document.addEventListener("mousedown",W),window.addEventListener("resize",F),window.addEventListener("scroll",F,!0),()=>{document.removeEventListener("mousedown",W),window.removeEventListener("resize",F),window.removeEventListener("scroll",F,!0)}},[d,O]);const P=e?.name||y?.displayName||y?.username||c("common:userPlaceholder"),D=e?.email||y?.email||"",$=h5(e?.avatarUrl,y?.avatarUrl),X=g?"bg-emerald-500":"bg-fg-muted",ee=g?y?.username?c("sidebar.hubConnectedAs",{username:y.username}):c("sidebar.hubConnected"):c("sidebar.hubDisconnected"),H=!!(g&&y?.username&&e?.name&&y.username.toLowerCase()!==e.name.toLowerCase()&&y.email?.toLowerCase()!==e.email?.toLowerCase()),K=()=>{m(!1),j({validate:!0}),at.navigate(me.SETTINGS,{tab:"account"})},ae=d&&Sa.createPortal(s.jsxs("div",{ref:_,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:Xp},children:[s.jsxs("div",{className:"px-3.5 py-3 border-b border-border-default flex items-start gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:P}),D&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5 truncate",children:D})]}),n&&s.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:s.jsx(Nd,{d:"M12 20h9M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z",size:14})})]}),s.jsxs("button",{type:"button",onClick:K,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:[s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${X}`}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"text-xs text-fg-secondary block truncate",children:ee}),H&&y?.username&&s.jsx("span",{className:"text-[10px] text-amber-500/90 block truncate mt-0.5",children:c("sidebar.hubAccountMismatch",{username:y.username})})]}),s.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:s.jsx("path",{d:"m9 18 6-6-6-6"})})]}),s.jsxs("div",{className:"py-1",children:[r&&s.jsxs("button",{type:"button",onClick:()=>{m(!1),at.navigate(me.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:[s.jsx(Nd,{d:dc[me.SETTINGS]}),c("settings")]}),window.markusDesktop&&s.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:[s.jsx(Nd,{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&&s.jsxs("button",{type:"button",onClick:()=>{m(!1),h(!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:[s.jsx(Nd,{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 s.jsxs("div",{className:`relative ${o?"flex justify-center":"flex items-center justify-between gap-2 w-full"}`,children:[s.jsxs("button",{ref:S,type:"button",onClick:()=>m(W=>!W),title:P,className:`relative inline-flex items-center justify-center rounded-full transition-opacity hover:opacity-90 ${o?"p-0.5":""}`,children:[s.jsx(Us,{name:P,avatarUrl:$,size:o?28:32,fallback:"icon"}),s.jsx("span",{className:`absolute bottom-0 right-0 w-2.5 h-2.5 rounded-full border-2 border-surface-secondary ${X}`,title:ee})]}),l&&!o&&s.jsxs("span",{className:"text-[10px] text-fg-muted select-none shrink-0",children:["v","0.9.2"]}),ae,p&&t&&s.jsx(dr,{title:c("common:signOutConfirmTitle"),message:c("common:signOutConfirmMessage"),confirmLabel:c("common:signOut"),variant:"primary",onConfirm:()=>{h(!1),t()},onCancel:()=>h(!1)})]})}function DK({d:e,size:t=18}){return s.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:s.jsx("path",{d:e})})}function LK({currentPage:e,onNavigate:t,authUser:n,collapsed:r,onToggleCollapse:o,onLogout:l}){const{t:c}=dt(["nav","common"]);return s.jsxs("aside",{className:"markus-app-sidebar h-dvh bg-surface-secondary flex flex-col shrink-0 overflow-hidden",children:[s.jsx("div",{"data-electron-drag":!0,className:`electron-mac-sidebar-header flex items-center ${r?"px-2 py-3.5 justify-center":"px-4 h-14 justify-between"}`,children:s.jsxs("button",{"data-no-drag":!0,onClick:o,title:c(r?"sidebar.expandSidebar":"sidebar.collapseSidebar"),className:"flex items-center gap-2.5 min-w-0 group",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-8 h-8 rounded-lg shrink-0"}),!r&&s.jsx("span",{className:"text-[15px] font-bold tracking-tight text-fg-primary whitespace-nowrap",children:"Markus"})]})}),s.jsx("nav",{className:`${r?"p-1":"px-3 py-2"} flex-1 overflow-y-auto scrollbar-thin`,children:gD.map((d,m)=>{const p=bD.filter(g=>g.section===d.key);if(p.length===0)return null;const h=c(`sections.${d.key}`);return s.jsx("div",{children:s.jsxs("div",{className:m>0?"mt-3":"",children:[!r&&h&&s.jsx("div",{className:"px-3 py-1.5 mb-1 text-[10px] font-semibold text-fg-muted uppercase tracking-[0.1em]",children:h}),r&&m>0&&s.jsx("div",{className:"my-3"}),p.map(g=>{if(g.id===me.NOTIFICATIONS)return s.jsx(RK,{sidebarMode:!0,collapsed:r,userId:n?.id,label:c(g.id),iconPath:dc[g.id],isActive:e===g.id},g.id);const x=e===g.id;return s.jsxs("button",{onClick:()=>t(g.id),title:r?c(g.id):void 0,className:`w-full flex items-center ${r?"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 ${x?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[s.jsx(DK,{d:dc[g.id]??"",size:r?16:18}),r?s.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:c(g.id)}):s.jsx("span",{className:"truncate",children:c(g.id)})]},g.id)})]})},d.key)})}),s.jsx("div",{className:`shrink-0 border-t border-border-subtle ${r?"p-1.5 flex justify-center":"px-3 py-2.5"}`,children:s.jsx(OK,{authUser:n,onLogout:l,onEditProfile:()=>{window.dispatchEvent(new Event("markus:open-edit-profile"))},showSettingsLink:!1,collapsed:r,showVersion:!r})})]})}const IK=6e4;let Ps={},bi={};const Gh=new Set,Vh=new Set;let z3=0,ic=null,Cd=0,Ud=null;function p0(){for(const e of Gh)e()}async function Kh(){try{const e=await Ce.unread.getCounts();Ps=e.counts??{},bi=e.sessionAgentMap??{},p0()}catch{}}function PK(){ic||(Kh(),ic=setInterval(Kh,IK),Ud=va.on("chat:unread_update",e=>{const t=e.payload?.conversationKey;t&&!Vh.has(t)&&Date.now()>z3&&(Ps[t]=(Ps[t]??0)+1,p0())}))}function zK(){ic&&(clearInterval(ic),ic=null),Ud&&(Ud(),Ud=null)}function BK(e){const t=e?.enabled??!0,[n,r]=k.useState(Ps),[o,l]=k.useState(bi),c=k.useCallback(async()=>{await Kh()},[]),d=k.useCallback(async w=>{const C=new Date().toISOString();delete Ps[w],p0();try{await Ce.unread.markRead(w,C)}catch{}},[]),m=k.useCallback(async()=>{Ps={},p0();try{await Ce.unread.markAllRead()}catch{}},[]),p=k.useCallback(w=>{Vh.add(w)},[]),h=k.useCallback(w=>{Vh.delete(w),z3=Date.now()+150},[]);k.useEffect(()=>{if(!t)return;Cd++,PK();let w=bi;const C=()=>{r({...Ps}),w!==bi&&(w=bi,l({...bi}))};return Gh.add(C),r({...Ps}),l({...bi}),()=>{Gh.delete(C),Cd--,Cd<=0&&(Cd=0,zK())}},[t]);const g=k.useMemo(()=>Object.values(n).reduce((w,C)=>w+C,0),[n]),x=k.useCallback(w=>n[`session:${w}`]??0,[n]),y=k.useCallback(w=>n[`channel:${w}`]??0,[n]);return{counts:n,totalUnread:g,sessionAgentMap:o,getSessionUnread:x,getChannelUnread:y,markRead:d,markAllRead:m,refresh:c,setActiveKey:p,clearActiveKey:h}}function EY(e,t){return k.useMemo(()=>{const n=new Map;for(const[r,o]of Object.entries(t))if(r.startsWith("session:")){const l=r.slice(8),c=e[l];c&&n.set(c,(n.get(c)??0)+o)}return n},[e,t])}function UK({currentPage:e,onNavigate:t,userId:n}){const{t:r}=dt("nav"),[o,l]=k.useState(0),{counts:c}=BK({enabled:!0}),d=k.useMemo(()=>{let p=0;for(const h of Object.values(c))p+=h;return p},[c]),m=k.useCallback(async()=>{try{const p=await Ce.notifications.list(n,!1);l(p.unreadCount??p.notifications.filter(h=>!h.read).length)}catch{}},[n]);return k.useEffect(()=>{m();const p=setInterval(()=>{document.visibilityState==="visible"&&m()},3e4),h=()=>m();return window.addEventListener("markus:notifications-changed",h),()=>{clearInterval(p),window.removeEventListener("markus:notifications-changed",h)}},[m]),s.jsx("nav",{className:"fixed bottom-0 left-0 right-0 z-50 bg-surface-secondary flex items-stretch h-14 safe-area-bottom",children:xD.map(p=>{const h=p.group.includes(e),g=p.id===me.NOTIFICATIONS,x=p.id===me.TEAM;return s.jsxs("button",{onClick:()=>t(p.id),className:`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${h?"text-fg-primary":"text-fg-tertiary active:text-fg-secondary"}`,children:[s.jsxs("div",{className:"relative",children:[s.jsx("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:h?2:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("path",{d:dc[p.id]})}),g&&o>0&&s.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:o>99?"99+":o}),x&&d>0&&s.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:d>99?"99+":d})]}),s.jsx("span",{className:`text-[10px] leading-tight ${h?"font-semibold":""}`,children:r(p.id)})]},p.id)})})}const h0=new Map;function hi(e,t){h0.has(e)||h0.set(e,t().catch(()=>{}))}function wi(e){const t=h0.get(e);return h0.delete(e),t}const Tr={builderArtifacts:"builder.artifacts",builderAgents:"builder.agents",builderHubMyItems:"builder.hubMyItems",builderInstalled:"builder.installed",hubAgents:"hub.agents",hubTeams:"hub.teams",hubSkills:"hub.skills"},Ti={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 Ko(e){const t=(e||"").toLowerCase();return t==="team"?"team":t==="skill"?"skill":t==="connector"||t==="mcp"?"connector":"agent"}function B3(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 $K={agent:258,team:205,skill:32,connector:162};function Bg(e,t){const n=$K[e],r=B3(t),o=((n+(r%68-34))%360+360)%360,l=(o+22+(r>>>8)%24)%360;return`linear-gradient(${120+r%44}deg, hsl(${o} 72% 56%), hsl(${l} 66% 43%))`}const k4=["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 U3(e){return k4[B3(e+"g")%k4.length]}function $3(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 HK(e){return!e||$3(e)?!1:[...e].length<=4&&new RegExp("\\p{Extended_Pictographic}","u").test(e)}function FK(e,t="user"){const n=t==="org"?"shapes":"thumbs",r=encodeURIComponent(e);return`https://api.dicebear.com/9.x/${n}/svg?seed=${r}&radius=50&backgroundType=gradientLinear`}function Eo(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 S4(e,t="usd"){return!e||e<=0?"Free":`${t.toLowerCase()==="usd"?"$":""}${(e/100).toFixed(e%100===0?0:2)}`}const N4={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"}},qK=["development","devops","management","productivity","browser","custom","general"],GK=[{label:"Tech",emojis:["✦","◈","⬡","⚡","🤖","🧠","💡","🎯","🔧","📦","🚀","💻","🛠️","⭐","🔥","💎","⚙️","🧩","🔌","💾","🖥️","📡","🔬","🧪","🏗️","📱","🎮","🕹️","📟","💽","🖨️","⌨️"]},{label:"People",emojis:["👤","👥","🧑💻","👨💼","👩🔬","🧙","🦸","🤝","💪","🎓","👷","🕵️","🧑🎨","🧑🏫","👨🚀","🥷","🧑🏭","🧑⚕️","🧑🔧","🧑🍳","👨🎤","🦹","🧝","🧞","🧑✈️","💂","🤴","👸","🧛","🧟","🧜","🧚"]},{label:"Objects",emojis:["📝","📊","🗂️","📁","🔍","🔑","🌐","💬","🔒","🎨","📐","🗃️","📋","✏️","🖊️","📌","📎","🧲","🪝","🧰","🪜","🧬","🔭","💊","🩺","📕","📗","📘","📙","📓","🗒️","📰"]},{label:"Symbols",emojis:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","♠️","♥️","♦️","♣️","🎵","🎶","💯","✅","❌","⭕","🔴","🟠","🟡","🟢","🔵","🟣","⚫","⚪","🟤","🔶","🔷","▶️","⏸️","⏹️"]},{label:"Nature",emojis:["🌟","🌈","🌊","🌿","🍀","🔮","💫","✨","🌙","☀️","🦋","🐉","🦊","🐺","🦅","🐙","🦁","🐯","🦄","🐲","🌸","🌺","🍄","🌵","🎄","🌴","🍁","🌻","🐝","🦎","🐍","🦈"]},{label:"Activity",emojis:["🎯","🏆","🥇","🎖️","🏅","🎪","🎭","🎬","🎤","🎧","🎼","🎹","🥁","🎸","🎺","🎻","⚽","🏀","🎾","🏐","🎲","🧸","🪁","🎰","🎳","🏹","🥊","🤺","⛷️","🏄","🚴","🧗"]}],VK={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 Qp({value:e,onChange:t,renderAs:n="span",className:r,editClassName:o,placeholder:l,multiline:c,readOnly:d}){if(d){const j=e||l,P=`${r??""} ${!e?"text-fg-muted italic":""}`;return n==="h1"?s.jsx("h1",{className:P,children:j}):n==="p"?s.jsx("p",{className:P,children:j}):s.jsx("span",{className:P,children:j})}const[m,p]=k.useState(!1),[h,g]=k.useState(e),x=k.useRef(null);k.useEffect(()=>{g(e)},[e]),k.useEffect(()=>{m&&x.current?.focus()},[m]);const y=()=>{p(!1),h!==e&&t(h)},w=()=>{g(e),p(!1)},C=j=>{j.key==="Escape"&&w(),j.key==="Enter"&&!c&&y()};if(m){const j=`bg-transparent outline-none w-full ${o??r??""} ring-1 ring-brand-500/50 rounded px-1 -mx-1`;return c?s.jsx("textarea",{ref:x,value:h,onChange:O=>g(O.target.value),onBlur:y,onKeyDown:C,className:`${j} resize-y min-h-[60px]`,placeholder:l}):s.jsx("input",{ref:x,value:h,onChange:O=>g(O.target.value),onBlur:y,onKeyDown:C,className:j,placeholder:l})}const T=e||l,S=!e,_="cursor-text hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all";return n==="h1"?s.jsx("h1",{onClick:()=>p(!0),className:`${r??""} ${_} ${S?"text-fg-muted italic":""}`,children:T}):n==="p"?s.jsx("p",{onClick:()=>p(!0),className:`${r??""} ${_} ${S?"text-fg-muted italic":""}`,children:T}):n==="badge"?s.jsx("span",{onClick:()=>p(!0),className:`${r??""} ${_} ${S?"text-fg-muted italic":""}`,children:T}):s.jsx("span",{onClick:()=>p(!0),className:`${r??""} ${_} ${S?"text-fg-muted italic":""}`,children:T})}function KK({value:e,options:t,onChange:n,className:r,readOnly:o}){if(o)return s.jsx("span",{className:r,children:e});const[l,c]=k.useState(!1),[d,m]=k.useState(e),p=k.useRef(null),h=k.useRef(null);k.useEffect(()=>{l&&(m(e),setTimeout(()=>p.current?.focus(),0))},[l,e]);const g=t.filter(y=>y.toLowerCase().includes(d.toLowerCase())),x=y=>{const w=y.trim();w&&w!==e&&n(w),c(!1)};return l?s.jsxs("div",{ref:h,className:"relative inline-block",children:[s.jsx("input",{ref:p,value:d,onChange:y=>m(y.target.value),onKeyDown:y=>{y.key==="Enter"?(y.preventDefault(),x(d)):y.key==="Escape"&&c(!1)},onBlur:y=>{h.current?.contains(y.relatedTarget)||x(d)},className:`${r??""} bg-transparent outline-none ring-1 ring-brand-500/50 rounded w-28`}),g.length>0&&s.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:g.map(y=>s.jsx("button",{onMouseDown:w=>{w.preventDefault(),x(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))})]}):s.jsx("span",{onClick:()=>c(!0),className:`${r??""} cursor-pointer hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all`,children:e})}function WK({tags:e,onChange:t,readOnly:n}){if(n)return s.jsx("div",{className:"flex flex-wrap items-center gap-1.5 min-h-[24px]",children:e.map(h=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:h},h))});const{t:r}=dt(["builder"]),[o,l]=k.useState(!1),[c,d]=k.useState(""),m=k.useRef(null);k.useEffect(()=>{o&&m.current?.focus()},[o]);const p=h=>{if((h.key==="Enter"||h.key===",")&&c.trim()){h.preventDefault();const g=c.trim().toLowerCase();e.includes(g)||t([...e,g]),d("")}else h.key==="Backspace"&&!c&&e.length>0?t(e.slice(0,-1)):h.key==="Escape"&&(l(!1),d(""))};return o?s.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(h=>s.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:[h,s.jsx("button",{onClick:()=>t(e.filter(g=>g!==h)),className:"text-fg-muted hover:text-red-500",children:"×"})]},h)),s.jsx("input",{ref:m,value:c,onChange:h=>d(h.target.value),onKeyDown:p,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:r("detail.typeTagAndEnter")})]}):s.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(h=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:h},h)):s.jsx("span",{className:"text-[10px] text-fg-muted italic",children:r("detail.typeTagAndEnter")})})}function Wh({content:e}){return s.jsx("div",{className:`prose prose-invert prose-sm max-w-none
|
|
662
662
|
prose-headings:text-fg-primary prose-headings:font-semibold
|
|
663
663
|
prose-p:text-fg-secondary prose-p:leading-relaxed
|
|
664
664
|
prose-a:text-brand-400 prose-a:no-underline hover:prose-a:underline
|
|
@@ -667,4 +667,4 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Rn=ze,rn=wt),Ut===void
|
|
|
667
667
|
prose-strong:text-fg-primary
|
|
668
668
|
prose-li:text-fg-secondary
|
|
669
669
|
prose-hr:border-border-default
|
|
670
|
-
prose-blockquote:border-brand-500/40 prose-blockquote:text-fg-secondary`,children:s.jsx(wh,{remarkPlugins:[Mw,Ok],rehypePlugins:[[s3,{detect:!0,ignoreMissing:!0}]],children:e})})}function Zp({filename:e,content:t,onSave:n,embedded:r,readOnly:o}){const{t:l}=dt(["builder","common"]),[c,d]=k.useState(!1),[m,p]=k.useState(t),[h,g]=k.useState(!1),x=/\.(md|mdx|markdown)$/i.test(e),y=k.useRef(null);k.useEffect(()=>{p(t)},[t]),k.useEffect(()=>{if(c&&y.current){const T=y.current;T.style.height="auto",T.style.height=Math.max(200,T.scrollHeight)+"px"}},[c,m]);const w=async()=>{g(!0),await n(m),g(!1),d(!1)},C=o?null:s.jsx("div",{className:"flex items-center gap-2",children:c?s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>{p(t),d(!1)},className:"text-[10px] px-2.5 py-1 rounded-md text-fg-tertiary hover:text-fg-secondary border border-border-default transition-colors",children:l("common:cancel")}),s.jsx("button",{onClick:w,disabled:h,className:"text-[10px] px-2.5 py-1 rounded-md bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50",children:l(h?"common:saving":"common:save")})]}):s.jsxs("button",{onClick:()=>d(!0),className:"text-[10px] px-2.5 py-1 rounded-md text-fg-tertiary hover:text-fg-secondary border border-border-default transition-colors inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),s.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),l("detail.edit")]})});return r?s.jsxs("div",{children:[s.jsx("div",{className:"flex items-center justify-end px-4 py-2 border-b border-border-default bg-surface-elevated/20",children:C}),c?s.jsx("textarea",{ref:y,value:m,onChange:T=>p(T.target.value),className:"w-full bg-surface-elevated/20 text-sm text-fg-primary font-mono p-4 focus:outline-none resize-y min-h-[200px] leading-relaxed",spellCheck:!1}):s.jsx("div",{className:"p-4",children:x?s.jsx(Wh,{content:t}):s.jsx("pre",{className:"text-xs leading-relaxed text-fg-secondary whitespace-pre-wrap font-mono",children:t})})]}):s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border-default bg-surface-elevated/30",children:[s.jsx("span",{className:"text-xs font-medium text-fg-secondary font-mono",children:e}),C]}),c?s.jsx("textarea",{ref:y,value:m,onChange:T=>p(T.target.value),className:"w-full bg-surface-elevated/20 text-sm text-fg-primary font-mono p-4 focus:outline-none resize-y min-h-[200px] leading-relaxed",spellCheck:!1}):s.jsx("div",{className:"p-4",children:x?s.jsx(Wh,{content:t}):s.jsx("pre",{className:"text-xs leading-relaxed text-fg-secondary whitespace-pre-wrap font-mono",children:t})})]})}const C4={"README.md":0,"ROLE.md":1,"HEARTBEAT.md":2,"POLICIES.md":3,"CONTEXT.md":4,"ANNOUNCEMENT.md":0,"NORMS.md":1};function YK(e){return[...e].sort(([t],[n])=>{const r=C4[t]??99,o=C4[n]??99;return r!==o?r-o:t.localeCompare(n)})}function g0({files:e,onSave:t,noHeader:n,readOnly:r}){const o=k.useMemo(()=>YK(e),[e]),[l,c]=k.useState(0);if(o.length===1)return n?s.jsx(Zp,{filename:o[0][0],content:o[0][1],onSave:h=>t(o[0][0],h),readOnly:r}):s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-4 uppercase tracking-wider",children:"Files"}),s.jsx(Zp,{filename:o[0][0],content:o[0][1],onSave:h=>t(o[0][0],h),readOnly:r})]});const[d,m]=o[l]??o[0],p=s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsx("div",{className:"flex items-center gap-0 overflow-x-auto bg-surface-elevated/30",children:o.map(([h],g)=>s.jsx("button",{onClick:()=>c(g),className:`px-4 py-2.5 text-xs font-medium whitespace-nowrap border-b-2 transition-colors ${g===l?"border-brand-500 text-brand-400 bg-surface-secondary/50":"border-transparent text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/50"}`,children:h},h))}),s.jsx(Zp,{filename:d,content:m,onSave:h=>t(d,h),embedded:!0,readOnly:r},d)]});return n?p:s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-4 uppercase tracking-wider",children:"Files"}),p]})}function XK({images:e,artifactType:t,artifactName:n,onUpload:r,onRemove:o,readOnly:l}){const{t:c}=dt(["builder"]),d=k.useRef(null);return e.length===0?l?null:s.jsxs("div",{className:"border-2 border-dashed border-border-default rounded-xl p-6 text-center text-fg-muted text-sm cursor-pointer hover:border-brand-500/30 transition-colors",onClick:()=>d.current?.click(),onDragOver:m=>m.preventDefault(),onDrop:m=>{m.preventDefault();const p=m.dataTransfer.files[0];p?.type.startsWith("image/")&&r(p)},children:[s.jsxs("svg",{className:"w-8 h-8 mx-auto mb-2 text-fg-muted/50",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),s.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),s.jsx("polyline",{points:"21 15 16 10 5 21"})]}),s.jsx("span",{className:"block",children:c("images.dropOrClick")}),s.jsx("span",{className:"block text-xs text-fg-muted/60 mt-1",children:c("images.hint")}),s.jsx("input",{ref:d,type:"file",accept:"image/*",className:"hidden",onChange:m=>{const p=m.target.files?.[0];p&&r(p),m.target.value=""}})]}):s.jsxs("div",{children:[s.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2",children:[e.map(m=>{const p=m.split("/").pop()??m;return s.jsxs("div",{className:"relative group shrink-0 rounded-lg border border-border-default overflow-hidden bg-surface-elevated",children:[s.jsx("img",{src:`/api/builder/artifacts/${t}s/${encodeURIComponent(n)}/images/${encodeURIComponent(p)}`,alt:p,className:"h-32 w-auto object-cover"}),!l&&s.jsx("button",{onClick:()=>o(p),className:"absolute top-1.5 right-1.5 w-5 h-5 rounded-full bg-red-600/80 text-white flex items-center justify-center text-[10px] opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]},m)}),!l&&s.jsx("button",{onClick:()=>d.current?.click(),className:"shrink-0 h-32 w-24 rounded-lg border-2 border-dashed border-border-default flex items-center justify-center text-fg-muted hover:border-brand-500/30 hover:text-brand-400 transition-colors",children:s.jsxs("svg",{className:"w-6 h-6",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),s.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]}),!l&&s.jsx("input",{ref:d,type:"file",accept:"image/*",className:"hidden",onChange:m=>{const p=m.target.files?.[0];p&&r(p),m.target.value=""}})]})}function QK({members:e,teamTopFiles:t,files:n,onFileSave:r,readOnly:o}){const{t:l}=dt(["builder"]),[c,d]=k.useState(0),m=k.useMemo(()=>{const C=new Set;for(const T of Object.keys(n)){const S=T.match(/^members\/([^/]+)\//);S&&C.add(S[1])}return[...C]},[n]),p=k.useMemo(()=>{const C=new Map,T=new Set;for(let j=0;j<e.length;j++){const O=Xd(e[j].name);m.includes(O)&&!T.has(O)&&(C.set(j,O),T.add(O))}for(let j=0;j<e.length;j++){if(C.has(j))continue;const O=e[j].roleName;if(O){const P=Xd(O);m.includes(P)&&!T.has(P)&&(C.set(j,P),T.add(P))}}for(let j=0;j<e.length;j++){if(C.has(j))continue;const O=e[j].name;for(const P of m){if(T.has(P))continue;const D=n[`members/${P}/ROLE.md`];if(!D)continue;const $=D.match(/^#\s+(.+)$/m)?.[1]?.trim();if($&&($.toLowerCase().includes(O.toLowerCase())||O.toLowerCase().includes($.toLowerCase()))){C.set(j,P),T.add(P);break}}}const S=m.filter(j=>!T.has(j));let _=0;for(let j=0;j<e.length;j++)C.has(j)||_<S.length&&(C.set(j,S[_]),_++);return C},[e,m,n]),h=k.useCallback((C,T)=>{const S=p.get(T);return S?Object.entries(n).filter(([_])=>_.startsWith(`members/${S}/`)):[]},[n,p]),g=k.useMemo(()=>{const C=[{label:l("detail.overview")}];for(const T of e)C.push({label:T.name,role:T.role});return C},[e,l]),x=c>0?e[c-1]:null,y=c-1;return s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsx("div",{className:"flex items-center gap-0 overflow-x-auto bg-surface-elevated/30 border-b border-border-default",children:g.map((C,T)=>{const S=T===c,_=C.role==="manager",j=T===0?S?"border-brand-500 text-brand-400":"border-transparent text-fg-tertiary hover:text-fg-secondary":_?S?"border-amber-500 text-amber-400":"border-transparent text-fg-tertiary hover:text-fg-secondary":S?"border-blue-500 text-blue-400":"border-transparent text-fg-tertiary hover:text-fg-secondary";return s.jsxs("button",{onClick:()=>d(T),className:`px-4 py-2.5 text-xs font-medium whitespace-nowrap border-b-2 transition-colors flex items-center gap-1.5 ${j} ${S?"bg-surface-secondary/50":"hover:bg-surface-elevated/50"}`,children:[T===0&&s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),s.jsx("polyline",{points:"9 22 9 12 15 12 15 22"})]}),T>0&&s.jsx("span",{className:`w-4 h-4 rounded-full text-[9px] font-bold flex items-center justify-center shrink-0 ${_?"bg-amber-500/20 text-amber-400":"bg-blue-500/20 text-blue-400"}`,children:(C.label[0]??"?").toUpperCase()}),C.label]},T)})}),s.jsx("div",{className:"p-5",children:c===0?s.jsxs("div",{className:"space-y-6",children:[t.length>0&&s.jsx(g0,{noHeader:!0,files:t,onSave:w,readOnly:o}),s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-3",children:l("sidebar.composition")}),s.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:e.map((C,T)=>{const S=C.role==="manager";return s.jsxs("button",{onClick:()=>d(T+1),className:"text-left rounded-lg border border-border-default bg-surface-elevated/30 px-4 py-3 flex gap-3 items-center hover:border-gray-600 transition-colors cursor-pointer",children:[s.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold shrink-0 ${S?"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:(C.name[0]??"?").toUpperCase()}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-xs font-medium text-fg-primary truncate",children:C.name}),s.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full font-medium ${S?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:C.role}),C.count>1&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["×",C.count]})]}),C.skills&&C.skills.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[C.skills.slice(0,3).map(_=>s.jsx("span",{className:"text-[9px] px-1.5 py-0.5 bg-surface-elevated text-fg-muted rounded border border-border-default",children:_},_)),C.skills.length>3&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",C.skills.length-3]})]})]}),s.jsx("svg",{className:"w-3.5 h-3.5 text-fg-muted shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"9 18 15 12 9 6"})})]},T)})})]})]}):x?s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:`w-12 h-12 rounded-full flex items-center justify-center text-lg font-bold shrink-0 ${x.role==="manager"?"bg-amber-500/15 text-amber-400 ring-2 ring-amber-500/30":"bg-blue-500/15 text-blue-400 ring-2 ring-blue-500/30"}`,children:(x.name[0]??"?").toUpperCase()}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"text-sm font-semibold text-fg-primary",children:x.name}),s.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full font-medium ${x.role==="manager"?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:x.role}),x.count>1&&s.jsxs("span",{className:"text-[10px] text-fg-muted",children:["×",x.count]})]}),x.roleName&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5 italic",children:x.roleName})]})]}),x.skills&&x.skills.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5",children:x.skills.map(C=>s.jsx("span",{className:"text-[10px] px-2.5 py-1 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:C},C))}),(()=>{const C=h(x.name,y);return C.length===0?s.jsx("p",{className:"text-xs text-fg-muted italic",children:"No files for this member yet."}):s.jsx(g0,{noHeader:!0,readOnly:o,files:C.map(([T,S])=>[T.replace(/^members\/[^/]+\//,""),S]),onSave:(T,S)=>{const _=C.find(([j])=>j.endsWith(`/${T}`));_&&r(_[0],S)}})})()]}):null})]});function w(C,T){r(C,T)}}function _i({type:e,name:t,onBack:n,authUser:r,readOnly:o,initialManifest:l,actionSlot:c,contentSlot:d}){const{t:m}=dt(["builder","common"]),p=Bo(),[h,g]=k.useState(!0),[x,y]=k.useState(t),[w,C]=k.useState({}),[T,S]=k.useState(null),[_,j]=k.useState(""),[O,P]=k.useState("idle"),[D,$]=k.useState({shared:!1}),[X,ee]=k.useState(!1),[H,K]=k.useState(!1),[ae,W]=k.useState(!1),[F,Z]=k.useState(!1),[U,Q]=k.useState(!1),[ne,ke]=k.useState(!1),[B,q]=k.useState(null),[le,I]=k.useState(""),[Ae,$e]=k.useState(""),[Oe,We]=k.useState(""),[st,mt]=k.useState(""),[At,gt]=k.useState([]),[jt,Jt]=k.useState(""),Rt=k.useRef(null),be=k.useRef(l);be.current=l,k.useEffect(()=>{y(t)},[t]);const Me=k.useCallback(async()=>{const pe=be.current;if(pe){S(pe),I(pe.displayName||pe.name||t),$e(pe.description||""),We(pe.version||"1.0.0"),mt(pe.category||"general"),gt(pe.tags||[]),Jt(pe.icon||""),C(pe.files??{}),g(!1);return}g(!0);try{let ve=t;try{const xt=await Ce.builder.artifacts.ensureSlugSafe(e,t);ve=xt.name,y(ve),xt.converted&&(history.replaceState(null,"",Ni(me.BUILDER,`${e}/${encodeURIComponent(ve)}`)),window.dispatchEvent(new CustomEvent("markus:data-changed")))}catch{y(t)}const Ye=await Ce.builder.artifacts.get(e,ve);C(Ye.files??{}),j(Ye.path??"");const nt=Ye.files[`${e}.json`]??Ye.files["agent.json"]??Ye.files["team.json"]??Ye.files["skill.json"];if(nt){const xt=JSON.parse(nt);S(xt),I(xt.displayName||xt.name||t),$e(xt.description||""),We(xt.version||"1.0.0"),mt(xt.category||"general"),gt(xt.tags||[]),Jt(xt.icon||"")}}catch(ve){console.error("Failed to load artifact:",ve)}finally{g(!1)}},[e,t]);k.useEffect(()=>{Me()},[Me]),k.useEffect(()=>{l?.files&&C(l.files)},[l?.files]),k.useEffect(()=>{if(!o){try{const pe=localStorage.getItem("markus_builder_shared_map");if(pe){const ve=JSON.parse(pe),Ye=`${e}/${t}`;ve[Ye]&&$({shared:!0,id:ve[Ye].id,slug:ve[Ye].slug,version:ve[Ye].version,visibility:ve[Ye].visibility??"public"})}}catch{}it.myItems().then(pe=>{const ve=pe?.items??[],Ye=e==="agent"?"agent":e==="team"?"team":"skill";for(const nt of ve)if(nt.itemType===Ye&&(nt.slug===t||nt.name===t)){$({shared:!0,id:nt.id,slug:nt.slug,version:nt.version,visibility:nt.visibility??"public",moderationStatus:nt.moderationStatus,pendingReview:nt.pendingReview});return}}).catch(()=>{})}},[e,t,o]);const qe=k.useCallback(async pe=>{if(!(!T||o)){P("saving");try{const ve={...T,...pe};await Ce.builder.artifacts.save(e,ve),S(ve),P("saved"),setTimeout(()=>P(Ye=>Ye==="saved"?"idle":Ye),2e3)}catch{P("error"),setTimeout(()=>P("idle"),3e3)}}},[T,e]),ot=k.useCallback(pe=>{Rt.current&&clearTimeout(Rt.current),Rt.current=setTimeout(()=>qe(pe),800)},[qe]),ft=k.useCallback((pe,ve)=>{const Ye={};pe==="displayName"?(I(ve),Ye.displayName=ve,K(!0)):pe==="description"?($e(ve),Ye.description=ve,K(!0)):pe==="version"?(We(ve),Ye.version=ve,K(!1),W(!1)):pe==="category"?(mt(ve),Ye.category=ve,K(!0)):pe==="tags"?(gt(ve),Ye.tags=ve,K(!0)):pe==="icon"&&(Jt(ve),Ye.icon=ve||void 0,K(!0)),ot({...T,...Ye})},[T,ot]),se=k.useCallback(async(pe,ve)=>{try{const Ye={...w,[pe]:ve};C(Ye);const nt={...T,files:Ye};await Ce.builder.artifacts.save(e,nt),P("saved"),K(!0),setTimeout(()=>P(xt=>xt==="saved"?"idle":xt),2e3)}catch{P("error")}},[w,e,T]),Be=k.useCallback(async pe=>{if(T){ee(!0);try{await it.ensureAuth();const ve=await Ce.builder.artifacts.ensureSlugSafe(e,x,T.displayName||T.name||x),Ye=ve.name,nt=ve.slug||fc(Ye);if(!nt)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 xt=ve.displayName||T.displayName||T.name||x;ve.converted&&(y(Ye),S(ie=>ie&&{...ie,name:nt,displayName:xt}),history.replaceState(null,"",Ni(me.BUILDER,`${e}/${encodeURIComponent(Ye)}`)),window.dispatchEvent(new CustomEvent("markus:data-changed")));const Dt={...T,name:nt,displayName:xt},ct=Dt.description||"",Xt=Dt.category||"general",R=Dt.tags??[];let oe=Dt.icon||void 0;const _e=Dt.version||"1.0.0";if(oe&&!oe.startsWith("http")&&/\.(png|jpe?g|gif|webp|svg)$/i.test(oe)){const ie=oe.split("/").pop()??oe;try{const Ne=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(Ye)}/images/${encodeURIComponent(ie)}`);if(Ne.ok){const Le=await Ne.blob(),Je=new File([Le],ie,{type:Le.type}),vt=await it.uploadImage(Je);vt?.url&&(oe=vt.url)}}catch{}}let de;const Pe=[],Ve=Dt.screenshots??[];for(let ie=0;ie<Ve.length;ie++){const Ne=Ve[ie],Le=Ne.split("/").pop()??Ne;try{const Je=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(Ye)}/images/${encodeURIComponent(Le)}`);if(Je.ok){const vt=await Je.blob(),Ie=new File([vt],Le,{type:vt.type}),tt=await it.uploadImage(Ie);tt?.url&&(Pe.push({url:tt.url,alt:Le,order:ie}),ie===0&&(de=tt.url))}}catch{}}const G=await it.publishViaProxy({itemType:e==="team"?"team":e==="skill"?"skill":"agent",name:xt,slug:nt,description:ct,category:Xt,tags:R,icon:oe,version:_e,config:Dt,files:Object.keys(w).length>0?w:void 0,thumbnailUrl:de,images:Pe.length>0?Pe:void 0,priceCents:pe?.priceCents,donationsEnabled:pe?.donationsEnabled,visibility:pe?.visibility,orgId:pe?.orgId});G.id&&($({shared:!0,id:G.id,slug:G.slug??nt,version:_e,visibility:G.visibility??pe?.visibility??"public",moderationStatus:G.moderationStatus,pendingReview:G.pendingReview}),K(!1),(G.visibility??pe?.visibility??"public")!=="org"&&(G.moderationStatus==="pending"||G.pendingReview)?q({title:m("common:share"),message:ve.converted?m("share.convertedAndSubmitted",{previous:t,slug:nt}):G.updated?m("share.updateSubmitted"):m("share.submittedForReview"),variant:"primary"}):ve.converted&&q({title:m("common:share"),message:m("share.convertedSlug",{previous:t,slug:nt}),variant:"primary"}))}catch(ve){console.error("Share to Hub failed:",ve),q({title:m("common:share"),message:ve instanceof Error?ve.message:String(ve),variant:"danger"})}finally{ee(!1)}}},[T,w,e,t,x,m]),Xe=async pe=>{const ve=new FormData;ve.append("image",pe);try{await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images`,{method:"POST",body:ve,credentials:"include"}),await Me(),K(!0)}catch(Ye){console.error("Image upload failed:",Ye)}},Ge=async pe=>{try{await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images/${encodeURIComponent(pe)}`,{method:"DELETE",credentials:"include"}),await Me(),K(!0)}catch(ve){console.error("Image remove failed:",ve)}},et=N4[e]??N4.agent,yt=T?.screenshots??[],he=T?.skill?.skillFile?w[T.skill.skillFile]:w["SKILL.md"]??w["README.md"],V=k.useMemo(()=>e!=="agent"?[]:Object.entries(w).filter(([pe])=>!pe.endsWith(".json")&&!pe.startsWith("images/")&&!pe.startsWith("members/")),[w,e]),ye=k.useMemo(()=>e!=="team"?[]:Object.entries(w).filter(([pe])=>!pe.endsWith(".json")&&!pe.startsWith("images/")&&!pe.startsWith("members/")),[w,e]),Qe=k.useMemo(()=>{if(e==="agent"||e==="team")return[];const pe=new Set;if(e==="skill"){const ve=T?.skill?.skillFile;ve&&w[ve]&&pe.add(ve),!ve&&w["SKILL.md"]&&pe.add("SKILL.md"),!ve&&!w["SKILL.md"]&&w["README.md"]&&pe.add("README.md")}return Object.entries(w).filter(([ve])=>!ve.endsWith(".json")&&!ve.startsWith("images/")&&!ve.startsWith("members/")&&!pe.has(ve))},[w,e,T?.skill?.skillFile]);return h?s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:"px-6 py-8",children:[s.jsxs("button",{onClick:n,className:"text-xs text-brand-400 hover:text-brand-300 mb-4 inline-flex items-center gap-1",children:[s.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:s.jsx("polyline",{points:"15 18 9 12 15 6"})}),m("detail.backToBuilder")]}),s.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse py-20 text-center",children:m("common:loading")})]})}):T?s.jsxs("div",{className:"flex-1 overflow-y-auto",children:[s.jsxs("div",{className:`${p?"px-4 py-5":"px-6 py-8"}`,children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("button",{onClick:n,className:"text-xs text-brand-400 hover:text-brand-300 inline-flex items-center gap-1",children:[s.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:s.jsx("polyline",{points:"15 18 9 12 15 6"})}),m(o?"common:back":"detail.backToBuilder")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[!o&&O==="saving"&&s.jsx("span",{className:"text-[10px] text-fg-muted animate-pulse",children:m("detail.saving")}),!o&&O==="saved"&&s.jsxs("span",{className:"text-[10px] text-green-500 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})}),m("detail.saved")]}),!o&&O==="error"&&s.jsx("span",{className:"text-[10px] text-red-500",children:m("detail.saveFailed")}),c,!o&&D.shared&&(()=>{const pe=it.getUser(),ve=pe&&D.slug?`${it.getUrl()}/@${encodeURIComponent(pe.username)}/${encodeURIComponent(D.slug)}`:null,Ye=Oe||T?.version||"1.0.0",nt=D.version!==Ye;return s.jsxs(s.Fragment,{children:[D.moderationStatus==="pending"?s.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.underReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),m("share.underReview")]}):D.moderationStatus==="rejected"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-red-500/30 text-red-400 inline-flex items-center gap-1",title:m("share.rejectedTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),s.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),m("share.rejected")]}):D.pendingReview?s.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:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),m("share.updateUnderReview")]}):null,ve&&s.jsxs("a",{href:ve,target:"_blank",rel:"noopener noreferrer",onClick:xt=>{pc()&&(xt.preventDefault(),Ai(ve))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1.5 ${D.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/50":D.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:[D.visibility==="org"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}):D.visibility==="unlisted"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.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"}),s.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"})]}):s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),D.visibility==="org"?m("visibility.sharedOrg"):D.visibility==="unlisted"?m("visibility.sharedUnlisted"):m("share.viewOnHub")]}),nt&&s.jsx("button",{onClick:()=>{Be({visibility:D.visibility})},disabled:X,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:X?m("share.updating"):m("share.updateVersion",{version:Ye})})]})})(),!o&&!D.shared&&s.jsx("button",{onClick:()=>Q(!0),disabled:X,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50",children:m(X?"share.sharing":"share.toHub")})]})]}),!o&&H&&!ae&&s.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:[s.jsx("span",{className:"text-xs text-amber-800 dark:text-amber-300",children:m("versionBump.contentModified")}),s.jsx("button",{onClick:()=>W(!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")})]}),!o&&ae&&s.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:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-xs text-amber-800 dark:text-amber-300",children:m("versionBump.newVersion")}),s.jsx("input",{type:"text",defaultValue:(()=>{const pe=(Oe||"1.0.0").split(".");return pe[2]=String(Number(pe[2]??0)+1),pe.join(".")})(),className:"text-xs px-2 py-1 rounded bg-surface-elevated border border-border-default text-fg-primary w-24 font-mono",onKeyDown:pe=>{pe.key==="Enter"&&ft("version",pe.target.value)}}),s.jsx("button",{onClick:pe=>{const ve=pe.target.parentElement?.querySelector("input");ve&&ft("version",ve.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")}),s.jsx("button",{onClick:()=>W(!1),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:m("common:cancel")})]}),D.shared&&s.jsx("p",{className:"text-[10px] text-fg-tertiary mt-2",children:"After bumping the version, you can share the new version to Hub."})]}),s.jsxs("div",{className:`flex gap-8 ${p?"flex-col":""}`,children:[s.jsxs("div",{className:`${p?"w-full":"flex-1 min-w-0"}`,children:[s.jsxs("div",{className:"flex items-start gap-4 mb-6",children:[s.jsxs("div",{className:"relative",children:[s.jsx("div",{onClick:()=>!o&&ke(!ne),className:`w-16 h-16 rounded-xl ${et.bg} flex items-center justify-center text-3xl shrink-0 ${o?"":"cursor-pointer hover:ring-2"} ${et.ring} transition-all overflow-hidden`,children:jt&&jt.startsWith("images/")?s.jsx("img",{src:`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images/${encodeURIComponent(jt.replace("images/",""))}`,alt:"",className:"w-full h-full object-cover"}):jt&&(jt.startsWith("http")||jt.startsWith("/"))?s.jsx("img",{src:jt,alt:"",className:"w-full h-full object-cover"}):(()=>{const pe=jt||"";if(pe&&[...pe].length<=2&&new RegExp("\\p{Emoji}","u").test(pe))return pe;const Ye=Ti[Ko(e)].accent;return s.jsx("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:s.jsx("path",{d:U3(le||t||e),fill:Ye})})})()}),!o&&ne&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>ke(!1)}),s.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:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.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:jt,onKeyDown:pe=>{pe.key==="Enter"&&(ft("icon",pe.target.value),ke(!1))}}),s.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"),s.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:async pe=>{const ve=pe.target.files?.[0];if(!ve)return;const Ye=new FormData;Ye.append("image",ve);try{const nt=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images`,{method:"POST",body:Ye,credentials:"include"});if(nt.ok){const Dt=(await nt.json()).path;if(Jt(Dt),ke(!1),T){const ct={...T,icon:Dt};S(ct),await Ce.builder.artifacts.save(e,ct)}K(!0)}}catch{}}})]}),jt&&s.jsx("button",{onClick:()=>{ft("icon",""),ke(!1)},className:"text-[10px] text-fg-tertiary hover:text-red-400 px-1",children:"✕"})]}),s.jsx("div",{className:"max-h-64 overflow-y-auto",children:GK.map(pe=>s.jsxs("div",{className:"mb-2.5",children:[s.jsx("div",{className:"text-[10px] text-fg-tertiary mb-1 sticky top-0 bg-surface-secondary py-0.5",children:pe.label}),s.jsx("div",{className:"flex flex-wrap gap-0.5",children:pe.emojis.map(ve=>s.jsx("button",{onClick:()=>{ft("icon",ve),ke(!1)},className:`w-7 h-7 rounded flex items-center justify-center text-base hover:bg-surface-elevated transition-colors ${jt===ve?"ring-1.5 ring-brand-500 bg-brand-500/10":""}`,children:ve},ve))})]},pe.label))})]})]})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx(Qp,{value:le,onChange:pe=>ft("displayName",pe),renderAs:"h1",className:"text-xl font-bold text-fg-primary",placeholder:m("detail.untitled"),readOnly:o}),s.jsx("span",{className:`text-[10px] font-medium uppercase tracking-wider px-2 py-0.5 rounded-full ${et.bg} ${et.color}`,children:et.label}),s.jsx(Qp,{value:Oe,onChange:pe=>ft("version",pe),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:o})]}),s.jsx(Qp,{value:Ae,onChange:pe=>ft("description",pe),renderAs:"p",className:"text-sm text-fg-secondary mt-1.5 leading-relaxed",placeholder:m("detail.addDescription"),multiline:!0,readOnly:o}),s.jsxs("div",{className:"flex items-center gap-2 mt-2 flex-wrap",children:[s.jsx(KK,{value:st,options:qK,onChange:pe=>ft("category",pe),className:"text-xs px-2 py-0.5 rounded bg-surface-elevated text-fg-tertiary",readOnly:o}),s.jsx(WK,{tags:At,onChange:pe=>ft("tags",pe),readOnly:o})]})]})]}),s.jsx("div",{className:"mb-8",children:s.jsx(XK,{images:yt,artifactType:e,artifactName:t,onUpload:Xe,onRemove:Ge,readOnly:o})}),d&&s.jsx("div",{className:"mb-8",children:d}),e==="team"&&T.team&&s.jsx("div",{className:"mb-8",children:s.jsx(QK,{members:T.team.members,teamTopFiles:ye,files:w,onFileSave:se,readOnly:o})}),e==="agent"&&V.length>0&&s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-4 uppercase tracking-wider",children:"About This Agent"}),s.jsx(g0,{noHeader:!0,files:V,onSave:se,readOnly:o})]}),e==="skill"&&s.jsxs("div",{className:"mb-8",children:[T.skill?.requiredPermissions&&T.skill.requiredPermissions.length>0&&s.jsxs("div",{className:"mb-6",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:m("sidebar.permissions")}),s.jsx("div",{className:"flex flex-wrap gap-2",children:T.skill.requiredPermissions.map(pe=>{const ve=VK[pe];return s.jsxs("span",{className:`inline-flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg border font-medium ${ve?.color??"bg-surface-elevated text-fg-secondary border-border-default"}`,children:[s.jsx("span",{className:"font-mono text-[10px]",children:ve?.icon??"?"})," ",pe]},pe)})})]}),T.skill?.mcpServers&&Object.keys(T.skill.mcpServers).length>0&&s.jsxs("div",{className:"mb-6",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:"Integrations"}),s.jsx("div",{className:"grid gap-2",children:Object.entries(T.skill.mcpServers).map(([pe,ve])=>s.jsxs("div",{className:"rounded-lg border border-border-default bg-surface-secondary/40 px-4 py-3 flex items-center gap-3",children:[s.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:"◎"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs font-medium text-fg-primary",children:pe}),s.jsx("div",{className:"text-[10px] text-fg-muted font-mono truncate",children:typeof ve=="object"?JSON.stringify(ve).slice(0,80):String(ve)})]})]},pe))})]}),he&&s.jsxs("div",{children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:"Instructions"}),s.jsx("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:s.jsx(Wh,{content:he})})]})]}),Qe.length>0&&s.jsx(g0,{files:Qe,onSave:se,readOnly:o})]}),s.jsx("div",{className:`${p?"w-full":"w-72 shrink-0"}`,children:s.jsxs("div",{className:`${p?"":"sticky top-6"} space-y-4`,children:[s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.info")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.type")}),s.jsx("span",{className:`font-medium ${et.color}`,children:et.label})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.category")}),s.jsx("span",{className:"text-fg-secondary",children:st})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.version")}),s.jsx("span",{className:"text-fg-secondary font-mono",children:Oe})]}),T.author&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.author")}),s.jsx("span",{className:"text-fg-secondary",children:typeof T.author=="string"?T.author:T.author?.name??""})]})]})]}),e==="agent"&&T.agent&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.agentSpecs")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[T.agent.roleName&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.role")}),s.jsx("span",{className:"text-fg-secondary",children:T.agent.roleName})]}),T.agent.llmProvider&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.provider")}),s.jsx("span",{className:"text-fg-secondary",children:T.agent.llmProvider})]}),T.agent.llmModel&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.model")}),s.jsx("span",{className:"text-fg-secondary font-mono",children:T.agent.llmModel})]}),T.agent.temperature!==void 0&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.temperature")}),s.jsx("span",{className:"text-fg-secondary",children:T.agent.temperature})]})]})]}),e==="team"&&T.team&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.composition")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.totalMembers")}),s.jsx("span",{className:"text-fg-secondary",children:T.team.members.reduce((pe,ve)=>pe+ve.count,0)})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.managers")}),s.jsx("span",{className:"text-amber-400",children:T.team.members.filter(pe=>pe.role==="manager").reduce((pe,ve)=>pe+ve.count,0)})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.workers")}),s.jsx("span",{className:"text-blue-400",children:T.team.members.filter(pe=>pe.role!=="manager").reduce((pe,ve)=>pe+ve.count,0)})]})]})]}),e==="skill"&&T.skill&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.skillInfo")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[T.skill.alwaysOn!==void 0&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.alwaysOn")}),s.jsx("span",{className:T.skill.alwaysOn?"text-green-400":"text-fg-secondary",children:T.skill.alwaysOn?m("sidebar.yes"):m("sidebar.no")})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.skillFile")}),s.jsx("span",{className:"text-fg-secondary font-mono truncate ml-2",children:T.skill.skillFile})]}),T.skill.requiredPermissions&&T.skill.requiredPermissions.length>0&&s.jsxs("div",{children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.permissions")}),s.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:T.skill.requiredPermissions.map(pe=>s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-elevated text-fg-muted rounded border border-border-default",children:pe},pe))})]})]})]}),T.dependencies&&(T.dependencies.skills?.length||T.dependencies.env?.length)?s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.dependencies")}),T.dependencies.skills?.length?s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-fg-muted mb-1",children:m("sidebar.skills")}),s.jsx("div",{className:"flex flex-wrap gap-1",children:T.dependencies.skills.map(pe=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-secondary rounded border border-border-default",children:pe},pe))})]}):null,T.dependencies.env?.length?s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-fg-muted mb-1",children:m("sidebar.environment")}),s.jsx("div",{className:"flex flex-wrap gap-1",children:T.dependencies.env.map(pe=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-secondary rounded font-mono border border-border-default",children:pe},pe))})]}):null]}):null,!o&&_&&s.jsxs("button",{onClick:()=>Ce.system.openPath(_).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:_,children:[s.jsx("span",{className:"text-fg-tertiary block mb-0.5",children:m("sidebar.openInFinder")}),_.replace(/.*\.markus\//,"~/.markus/")]})]})})]})]}),!o&&F&&s.jsx(JK,{onClose:()=>Z(!1),onConfirm:(pe,ve)=>{Z(!1),Be({donationsEnabled:!1,priceCents:pe==="paid"?ve:void 0})},isUpdate:D.shared}),!o&&U&&s.jsx(ZK,{onClose:()=>Q(!1),onConfirm:(pe,ve,Ye,nt)=>{Q(!1),Be({visibility:pe,orgId:ve,priceCents:Ye,donationsEnabled:nt})}}),B&&s.jsx(dr,{alertOnly:!0,variant:B.variant??"primary",title:B.title,message:B.message,onConfirm:()=>q(null),onCancel:()=>q(null)})]}):s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:"px-6 py-8",children:[s.jsxs("button",{onClick:n,className:"text-xs text-brand-400 hover:text-brand-300 mb-4 inline-flex items-center gap-1",children:[s.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:s.jsx("polyline",{points:"15 18 9 12 15 6"})}),m("detail.backToBuilder")]}),s.jsx("div",{className:"text-fg-tertiary text-sm py-20 text-center",children:m("detail.notFound")})]})})}function ZK({onClose:e,onConfirm:t}){const{t:n}=dt(["builder","common"]),[r,o]=k.useState("public"),[l,c]=k.useState([]),[d,m]=k.useState(""),[p,h]=k.useState(!1),[g,x]=k.useState(0),[y,w]=k.useState(!1);k.useEffect(()=>{r==="org"&&l.length===0&&(h(!0),it.myOrgs().then(S=>{c(S.memberships),S.memberships.length>0&&m(S.memberships[0].id)}).catch(()=>{}).finally(()=>h(!1)))},[r,l.length]);const C=r==="public"||r==="unlisted",T=[{value:"public",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),s.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:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.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:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.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"}),s.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 s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:e,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:S=>S.stopPropagation(),children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-1",children:n("visibility.label")}),s.jsx("p",{className:"text-[11px] text-fg-tertiary mb-4 leading-relaxed",children:n("visibility.subtitle")}),s.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-fg-tertiary font-semibold mb-2",children:["1 · ",n("visibility.public")," / ",n("visibility.org")]}),s.jsx("div",{className:"space-y-2 mb-5",children:T.map(S=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${r===S.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"visibility",checked:r===S.value,onChange:()=>o(S.value),className:"accent-brand-500"}),s.jsx("div",{className:"flex items-center gap-2 text-fg-secondary",children:S.icon}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:S.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:S.desc})]})]},S.value))}),r==="org"&&s.jsxs("div",{className:"mb-5",children:[s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("visibility.orgSelect")}),p?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:"Loading..."}):l.length===0?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:n("visibility.orgNone")}):s.jsx("select",{value:d,onChange:S=>m(S.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(S=>s.jsx("option",{value:S.id,children:S.name},S.id))})]}),C&&s.jsxs("div",{className:"mb-5",children:[s.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-fg-tertiary font-semibold mb-2",children:["2 · ",n("pricing.label")]}),s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("pricing.label")}),s.jsx("div",{className:"grid grid-cols-4 gap-2 mb-3",children:H3.map(S=>s.jsx("button",{type:"button",onClick:()=>x(S.cents),className:`text-sm px-2 py-2 rounded-lg border transition-colors ${g===S.cents?"border-brand-500 bg-brand-500/10 text-fg-primary":"border-border-default text-fg-secondary hover:border-gray-600"}`,children:S.label},S.cents))}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:y,onChange:S=>w(S.target.checked),className:"accent-brand-500"}),s.jsx("span",{className:"text-xs text-fg-secondary",children:n("pricing.enableTips")})]})]}),C&&s.jsx("div",{className:"mb-4 text-[11px] text-fg-tertiary rounded-lg border border-border-default px-3 py-2",children:n("pricing.reviewNote")}),s.jsxs("div",{className:"flex gap-3",children:[s.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")}),s.jsx("button",{onClick:()=>t(r,r==="org"?d:void 0,C&&g>0?g:void 0,C?y:void 0),disabled:r==="org"&&!d,className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n("shareMode.share")})]})]})})}const H3=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function JK({onClose:e,onConfirm:t,isUpdate:n}){const{t:r}=dt(["builder","common"]),[o,l]=k.useState(0);return s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:e,children:s.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:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:r(n?"shareMode.titleUpdate":"share.toHub")}),s.jsx("div",{className:"space-y-2 mb-5",children:H3.map(c=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${o===c.cents?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"sharePrice",checked:o===c.cents,onChange:()=>l(c.cents),className:"accent-brand-500"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:c.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:c.cents===0?r("shareMode.freeDesc"):r("shareMode.paidDesc")})]})]},c.cents))}),s.jsxs("div",{className:"flex gap-3",children:[s.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:r("common:cancel")}),s.jsx("button",{onClick:()=>t(o>0?"paid":"free",o),className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:r(n?"shareMode.update":"shareMode.share")})]})]})})}function b0(e,t){return!e||!$3(e)?null:e.startsWith("http")||e.startsWith("data:")?e:e.startsWith("/")&&t?`${t}${e}`:e}function eW({type:e,seed:t,icon:n,hubBase:r,size:o=44,className:l="",rounded:c="rounded-xl"}){const d=Ko(e),m=b0(n,r),p=k.useMemo(()=>Bg(d,t),[d,t]),h=k.useMemo(()=>U3(t),[t]),[g,x]=k.useState(!1);return m&&!g?s.jsx("img",{src:m,alt:"",onError:()=>x(!0),style:{width:o,height:o},className:`${c} object-cover shrink-0 ${l}`}):HK(n)?s.jsx("div",{style:{width:o,height:o,background:p,fontSize:o*.5},className:`${c} shrink-0 flex items-center justify-center shadow-inner ${l}`,children:s.jsx("span",{className:"drop-shadow-sm",children:n})}):n&&JV(n)?s.jsx("div",{style:{width:o,height:o,background:p},className:`${c} shrink-0 flex items-center justify-center text-white shadow-inner ${l}`,children:s.jsx(Vo,{name:n,size:o*.52,className:"drop-shadow-sm"})}):s.jsx("div",{style:{width:o,height:o,background:p},className:`${c} shrink-0 flex items-center justify-center shadow-inner ${l}`,children:s.jsx("svg",{width:o*.55,height:o*.55,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:s.jsx("path",{d:h,fill:"rgba(255,255,255,0.92)"})})})}function x0({name:e,username:t,avatarUrl:n,hubBase:r,size:o=24,className:l="",verified:c}){const d=t||e||"markus",m=b0(n,r),[p,h]=k.useState(!1),g=m&&!p?m:FK(d);return s.jsxs("span",{className:`relative inline-flex shrink-0 ${l}`,style:{width:o,height:o},children:[s.jsx("img",{src:g,alt:e||t||"",onError:()=>h(!0),className:"w-full h-full rounded-full object-cover ring-1 ring-white/10 bg-surface-elevated"}),c&&s.jsx("span",{className:"absolute -right-0.5 -bottom-0.5 flex items-center justify-center rounded-full bg-brand-500 ring-2 ring-surface-primary",style:{width:o*.42,height:o*.42},children:s.jsx("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%",fill:"white","aria-hidden":!0,children:s.jsx("path",{d:"M9 16.2l-3.5-3.5 1.4-1.4L9 13.4l7.1-7.1 1.4 1.4z"})})})]})}function tW({type:e,className:t=""}){const n=Ko(e),r=Ti[n];return s.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 ${r.gradient} ${t}`,children:r.label})}function T4({rating:e=0}){const t=Math.round(e);return s.jsx("span",{className:"inline-flex items-center","aria-label":`${e} out of 5`,children:[0,1,2,3,4].map(n=>s.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:s.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 ia(e){const{type:t,name:n,description:r,seed:o,icon:l,cover:c,hubBase:d,author:m,authorLabel:p,version:h,category:g,tags:x,rating:y=0,ratingCount:w=0,downloadCount:C=0,priceCents:T,currency:S="usd",installed:_,glowing:j,selected:O,showTypeBadge:P=!0,hideStats:D=!1,cornerLabel:$,actions:X,footerLeft:ee,headerAction:H,onClick:K,className:ae=""}=e,W=Ko(t),F=Ti[W],Z=o||n,U=(T??0)>0,Q=!!b0(c||void 0,d),ne=Bg(W,Z),ke=p??m?.displayName??m?.username??"",[B,q]=k.useState(null),le=_?s.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:s.jsx("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3.5",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})})}):$?s.jsx("span",{className:"chip",children:$}):U?s.jsx("span",{className:"badge-paid",children:S4(T,S)}):null;if(Q){const I=b0(c||void 0,d);return s.jsxs("div",{onClick:K,style:{aspectRatio:B??void 0},className:`group asset-card card-shine relative flex flex-col overflow-hidden min-h-[180px] ${K?"cursor-pointer":""} ${O?"ring-1 ring-brand-500/60":""} ${j?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${ae}`,children:[s.jsx("img",{src:I,alt:"",onLoad:Ae=>{const $e=Ae.currentTarget;$e.naturalWidth&&$e.naturalHeight&&q(Math.min(1.9,Math.max(1,$e.naturalWidth/$e.naturalHeight)))},className:"absolute inset-0 w-full h-full object-cover transition-transform duration-[600ms] group-hover:scale-[1.05]"}),s.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/90 via-black/50 to-black/5"}),s.jsx("div",{className:"absolute inset-x-0 top-0 h-20 bg-gradient-to-b from-black/50 to-transparent"}),s.jsxs("div",{className:"relative flex items-start justify-between gap-2 p-3",children:[s.jsx("span",{children:P&&s.jsx(tW,{type:W})}),s.jsxs("span",{className:"flex items-center gap-1.5",onClick:Ae=>Ae.stopPropagation(),children:[_?s.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:s.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})})}):$?s.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:$}):H?null:s.jsx("span",{className:U?"badge-paid":"badge-free",children:S4(T,S)}),H]})]}),s.jsxs("div",{className:"relative mt-auto p-4 pt-10 flex flex-col gap-2 text-white",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-[15px] font-semibold truncate drop-shadow-md",children:n}),h&&s.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",h]})]}),ke&&s.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-white/85",children:[m&&s.jsx(x0,{name:m.displayName,username:m.username,avatarUrl:m.avatarUrl,hubBase:d,size:15}),s.jsx("span",{className:"truncate",children:ke})]}),r&&s.jsx("p",{className:"text-[12.5px] text-white/80 truncate leading-snug drop-shadow-sm",children:r}),(g||x&&x.length>0)&&s.jsxs("div",{className:"flex flex-nowrap gap-1.5 overflow-hidden",children:[g&&s.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:g}),x?.slice(0,3).map(Ae=>s.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:Ae},Ae))]}),(!D||X)&&s.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1 shrink-0",children:[D?s.jsx("span",{}):s.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-white/80",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(T4,{rating:y}),w>0&&s.jsxs("span",{className:"text-white/60",children:["(",Eo(w),")"]})]}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":!0,children:s.jsx("path",{d:"M12 3v12m0 0l-4-4m4 4l4-4M5 21h14"})}),Eo(C)]})]}),X&&s.jsx("div",{className:"flex items-center gap-2",onClick:Ae=>Ae.stopPropagation(),children:X})]})]})]})}return s.jsxs("div",{onClick:K,className:`group asset-card card-shine relative flex flex-col ${K?"cursor-pointer":""} ${O?"ring-1 ring-brand-500/60":""} ${j?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${ae}`,children:[s.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, ${F.accent}, transparent)`}}),s.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:ne}}),H&&s.jsx("div",{className:"absolute top-2.5 right-2.5 z-10",onClick:I=>I.stopPropagation(),children:H}),s.jsxs("div",{className:"relative p-4 flex flex-col flex-1 gap-2.5",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(eW,{type:W,seed:Z,icon:l,hubBase:d,size:46,rounded:"rounded-2xl",className:"ring-1 ring-white/10 shadow-sm shadow-black/20"}),s.jsxs("div",{className:`min-w-0 flex-1 ${H?"pr-7":""}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg-primary truncate group-hover:text-brand-300 transition-colors",children:n}),h&&s.jsxs("span",{className:"chip shrink-0",children:["v",h]}),le&&s.jsx("span",{className:"ml-auto shrink-0",children:le})]}),(ke||P)&&s.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-[11px] text-fg-tertiary min-w-0",children:[m&&s.jsx(x0,{name:m.displayName,username:m.username,avatarUrl:m.avatarUrl,hubBase:d,size:15}),ke&&s.jsx("span",{className:"truncate",children:ke}),P&&s.jsxs(s.Fragment,{children:[ke&&s.jsx("span",{className:"text-fg-muted",children:"·"}),s.jsx("span",{className:"font-semibold shrink-0",style:{color:F.accent},children:F.label})]})]})]})]}),r&&s.jsx("p",{className:"text-[13px] text-fg-secondary truncate leading-snug",children:r}),(g||x&&x.length>0)&&s.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[g&&s.jsx("span",{className:"chip-accent capitalize",children:g}),x?.slice(0,3).map(I=>s.jsx("span",{className:"chip",children:I},I)),(x?.length??0)>3&&s.jsxs("span",{className:"text-[10px] text-fg-muted self-center",children:["+",(x?.length??0)-3]})]}),(()=>{const I=ee??(D?null:s.jsxs("span",{className:"flex items-center gap-3 text-[11px] text-fg-tertiary",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(T4,{rating:y}),s.jsx("span",{className:"text-fg-muted",children:w>0?`(${Eo(w)})`:""})]}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":!0,children:s.jsx("path",{d:"M12 3v12m0 0l-4-4m4 4l4-4M5 21h14"})}),Eo(C)]})]}));return!I&&!X?null:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 pt-2 mt-auto border-t border-border-subtle/60",onClick:Ae=>Ae.stopPropagation(),children:[I&&s.jsx("div",{className:"min-w-0 flex items-center gap-2",children:I}),X&&s.jsx("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:X})]})})()]})]})}function Ar({children:e,maxCardWidth:t=400,gap:n="1rem",className:r=""}){const o=k.useRef(null),[l,c]=k.useState(0);k.useEffect(()=>{const h=o.current;if(!h)return;c(h.clientWidth);const g=new ResizeObserver(x=>{for(const y of x)c(y.contentRect.width)});return g.observe(h),()=>g.disconnect()},[]);const d=Math.max(1,Math.ceil((l||t)/t)),m=k.Children.toArray(e),p=Array.from({length:d},()=>[]);return m.forEach((h,g)=>{p[g%d].push(h)}),s.jsx("div",{ref:o,className:`flex items-start ${r}`,style:{gap:n},children:p.map((h,g)=>s.jsx("div",{className:"flex flex-col flex-1 min-w-0",style:{gap:n,maxWidth:t},children:h},g))})}function nW(e){const t=e.indexOf(".markus/builder-artifacts/");return t>=0?"~/"+e.slice(t):e}const rW=[{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 aW(){const[e,t]=k.useState(()=>{const r=window.location.hash.slice(1).split("/");return cc(r[0])===me.BUILDER&&r[1]&&r[2]?{type:r[1],name:decodeURIComponent(r[2])}:null});return k.useEffect(()=>{const n=()=>{const o=window.location.hash.slice(1).split("/");cc(o[0])===me.BUILDER&&o[1]&&o[2]?t({type:o[1],name:decodeURIComponent(o[2])}):t(null)};return window.addEventListener("hashchange",n),()=>window.removeEventListener("hashchange",n)},[]),e}const F3="markus_builder_shared_map";function sW(){try{const e=localStorage.getItem(F3);if(!e)return new Map;const t=JSON.parse(e);return new Map(Object.entries(t))}catch{return new Map}}function Td(e){try{localStorage.setItem(F3,JSON.stringify(Object.fromEntries(e)))}catch{}}function q3({authUser:e}={}){const{t}=dt(["builder","common"]),n=Bo(),r=aW(),[o,l]=k.useState([]),[c,d]=k.useState([]),[m,p]=k.useState(!1),[h,g]=k.useState("all"),[x,y]=k.useState(null),[w,C]=k.useState(new Map),[T,S]=k.useState(null),[_,j]=k.useState(null),[O,P]=k.useState(null),[D,$]=k.useState(sW),[X,ee]=k.useState(null),[H,K]=k.useState(null),[ae,W]=k.useState(null),[F,Z]=k.useState(null),[U,Q]=k.useState(null),[ne,ke]=k.useState("creations"),[B,q]=k.useState([]),[le,I]=k.useState(""),[Ae,$e]=k.useState([]),[Oe,We]=k.useState(!1),[st,mt]=k.useState("all"),At=k.useCallback(()=>{p(!0),Promise.all([(wi(Tr.builderArtifacts)??Ce.builder.artifacts.list()).then(se=>se?.artifacts??[]).catch(()=>[]),(wi(Tr.builderAgents)??Ce.agents.list()).then(se=>se?.agents??[]).catch(()=>[]),(wi(Tr.builderHubMyItems)??it.myItems()).then(se=>se?.items??[]).catch(()=>[]),(wi(Tr.builderInstalled)??Ce.builder.artifacts.installed()).then(se=>se?.installed??{}).catch(()=>({}))]).then(([se,Be,Xe,Ge])=>{if(d(se),l(Be),Xe.length>0){const yt=new Map;for(const he of Xe){const V=he.itemType==="agent"?"agent":he.itemType==="team"?"team":"skill";for(const ye of se)ye.type===V&&(he.slug===ye.name||he.name===(ye.meta.displayName||ye.meta.name||ye.name))&&yt.set(`${ye.type}/${ye.name}`,{id:he.id,name:he.name,slug:he.slug||ye.name,version:he.version||"1.0.0",visibility:he.visibility??"public",moderationStatus:he.moderationStatus,pendingReview:he.pendingReview})}yt.size>0&&$(he=>{const V=new Map(he);for(const[ye,Qe]of yt)V.set(ye,Qe);return Td(V),V})}const et=new Map;for(const yt of se){const he=`${yt.type}/${yt.name}`,V=Ge[he];V&&et.set(he,{agentId:V.agentId,agentIds:V.agentIds,teamId:V.teamId})}C(et)}).finally(()=>p(!1))},[]);k.useEffect(()=>{At();const se=Be=>{Be.detail?.page===me.BUILDER&&At()};return window.addEventListener("markus:navigate",se),()=>window.removeEventListener("markus:navigate",se)},[At]);const gt=se=>{const Be=o.find(Xe=>Xe.role==="Secretary"||Xe.name==="Secretary");Be?at.navigate(me.TEAM,{agentId:Be.id,prefillMessage:se}):at.navigate(me.TEAM,{prefillMessage:se})},jt=async se=>{const Be=`${se.type}/${se.name}`;if(!w.has(Be)){y({key:Be,action:"install"});try{const Xe=await Ce.builder.artifacts.install(se.type,se.name),Ge={};Xe.agent&&typeof Xe.agent=="object"&&(Ge.agentId=Xe.agent.id),Xe.team&&typeof Xe.team=="object"&&(Ge.teamId=Xe.team.id),Array.isArray(Xe.agents)&&(Ge.agentIds=Xe.agents.map(et=>et.id)),C(et=>new Map(et).set(Be,Ge)),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(Xe){console.error("Install failed:",Xe),K({title:t("common:install"),message:t("installFailed",{error:String(Xe)}),variant:"danger"})}finally{y(null)}}},Jt=async se=>{const Be=`${se.type}/${se.name}`;if(w.has(Be)){y({key:Be,action:"uninstall"});try{await Ce.builder.artifacts.uninstall(se.type,se.name),C(Xe=>{const Ge=new Map(Xe);return Ge.delete(Be),Ge}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(Xe){console.error("Uninstall failed:",Xe),K({title:t("common:uninstall"),message:t("uninstallFailed",{error:String(Xe)}),variant:"danger"})}finally{y(null)}}},Rt=async(se,Be)=>{const Xe=`${se.type}/${se.name}`;y({key:Xe,action:"share"});try{const Ge=await Ce.builder.artifacts.ensureSlugSafe(se.type,se.name,se.meta.displayName||se.meta.name||se.name),et=Ge.name,yt=Ge.slug||fc(et);if(!yt)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 he=`${se.type}/${et}`;Ge.converted&&(d(oe=>oe.map(_e=>_e.type===se.type&&_e.name===se.name?{..._e,name:et,path:Ge.path,meta:{..._e.meta,name:et,displayName:Ge.displayName??_e.meta.displayName??se.name}}:_e)),$(oe=>{const _e=new Map(oe),de=_e.get(Xe);return de&&(_e.delete(Xe),_e.set(he,{...de,slug:yt,name:Ge.displayName??de.name})),Td(_e),_e}),C(oe=>{const _e=new Map(oe),de=_e.get(Xe);return de&&(_e.delete(Xe),_e.set(he,de)),_e}));const V=await Ce.builder.artifacts.get(se.type,et);let ye={...se.meta,name:et,displayName:Ge.displayName??se.meta.displayName??se.name};try{const oe=V.files?.[`${se.type}.json`]??V.files?.["agent.json"]??V.files?.["team.json"]??V.files?.["skill.json"];oe&&(ye={...JSON.parse(oe),...ye,name:et,displayName:ye.displayName})}catch{}const Qe=ye.displayName||ye.name||et,pe=ye.description||"",ve=ye.category||"general",Ye=Array.isArray(ye.tags)?ye.tags:[];let nt=ye.icon||void 0;const xt=ye.version||"1.0.0";if(nt&&!nt.startsWith("http")&&/\.(png|jpe?g|gif|webp|svg)$/i.test(nt)){const oe=nt.split("/").pop()??nt;try{const _e=await fetch(`/api/builder/artifacts/${se.type}s/${encodeURIComponent(et)}/images/${encodeURIComponent(oe)}`);if(_e.ok){const de=await _e.blob(),Pe=new File([de],oe,{type:de.type}),Ve=await it.uploadImage(Pe);Ve?.url&&(nt=Ve.url)}}catch{}}let Dt;const ct=[],Xt=Array.isArray(ye.screenshots)?ye.screenshots:[];for(let oe=0;oe<Xt.length;oe++){const _e=Xt[oe],de=_e.split("/").pop()??_e;try{const Pe=await fetch(`/api/builder/artifacts/${se.type}s/${encodeURIComponent(et)}/images/${encodeURIComponent(de)}`);if(Pe.ok){const Ve=await Pe.blob(),G=new File([Ve],de,{type:Ve.type}),ie=await it.uploadImage(G);ie?.url&&(ct.push({url:ie.url,alt:de,order:oe}),(oe===0||ye.thumbnail===_e)&&(Dt=ie.url))}}catch{}}const R=await it.publishViaProxy({itemType:se.type==="team"?"team":se.type==="skill"?"skill":"agent",name:Qe,slug:yt,description:pe,category:ve,tags:Ye,icon:nt,version:xt,config:{...ye,name:et,displayName:Qe},files:V.files&&Object.keys(V.files).length>0?V.files:void 0,thumbnailUrl:Dt,images:ct.length>0?ct:void 0,priceCents:Be?.priceCents,donationsEnabled:Be?.donationsEnabled,visibility:Be?.visibility,orgId:Be?.orgId});R.id&&($(_e=>{const de=new Map(_e);return de.set(he,{id:R.id,name:Qe,slug:R.slug??yt,version:xt,visibility:R.visibility??Be?.visibility??"public",moderationStatus:R.moderationStatus,pendingReview:R.pendingReview}),Td(de),de}),(R.visibility??Be?.visibility??"public")!=="org"&&(R.moderationStatus==="pending"||R.pendingReview)?K({title:t("common:share"),message:Ge.converted?t("share.convertedAndSubmitted",{previous:se.name,slug:yt}):R.updated?t("share.updateSubmitted"):t("share.submittedForReview"),variant:"primary"}):Ge.converted&&K({title:t("common:share"),message:t("share.convertedSlug",{previous:se.name,slug:yt}),variant:"primary"}))}catch(Ge){console.error("Share failed:",Ge),K({title:t("common:share"),message:t("shareFailed",{error:Ge instanceof Error?Ge.message:String(Ge)}),variant:"danger"})}finally{y(null)}},be=async()=>{if(!X)return;const{key:se}=X,Be=D.get(se);if(ee(null),!Be)return;const Xe=Be.id;y({key:se,action:"hubDelete"});try{await it.deleteItem(Xe),$(Ge=>{const et=new Map(Ge);return et.delete(se),Td(et),et})}catch(Ge){console.error("Hub delete failed:",Ge),K({title:t("unshare"),message:t("hubDeleteFailed",{error:String(Ge)}),variant:"danger"})}finally{y(null)}},Me=async()=>{if(!T)return;const se=T,Be=`${se.type}/${se.name}`;S(null),y({key:Be,action:"delete"});try{await Ce.builder.artifacts.delete(se.type,se.name),d(Xe=>Xe.filter(Ge=>!(Ge.type===se.type&&Ge.name===se.name))),C(Xe=>{const Ge=new Map(Xe);return Ge.delete(Be),Ge}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(Xe){console.error("Delete failed:",Xe)}finally{y(null)}},qe=h==="all"?c:c.filter(se=>se.type===h);k.useEffect(()=>{ne!=="orgAssets"||B.length>0||it.myOrgs().then(se=>{q(se.memberships),se.memberships.length>0&&!le&&I(se.memberships[0].id)}).catch(()=>{})},[ne,B.length,le]),k.useEffect(()=>{ne!=="orgAssets"||!le||(We(!0),it.browseItems({orgId:le,limit:100}).then(se=>$e(se.items??[])).catch(()=>$e([])).finally(()=>We(!1)))},[ne,le]);const ot=st==="all"?Ae:Ae.filter(se=>se.itemType===st),ft=se=>{history.pushState(null,"",Ni(me.BUILDER,`${se.type}/${encodeURIComponent(se.name)}`)),window.dispatchEvent(new HashChangeEvent("hashchange"))};return r?s.jsx(_i,{type:r.type,name:r.name,authUser:e,onBack:()=>{history.pushState(null,"",Ni(me.BUILDER)),window.dispatchEvent(new HashChangeEvent("hashchange"))}}):s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:`max-w-5xl mx-auto w-full ${n?"px-4 py-5":"px-6 py-6"}`,children:[s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-bold text-fg-primary",children:t("title")}),s.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:t("subtitle")})]}),s.jsx("button",{onClick:At,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")})]}),s.jsx("div",{className:`grid ${n?"grid-cols-1 gap-2":"grid-cols-3 gap-3"}`,children:rW.map(se=>{const Be=t(`prompts.${se.id}Prompt`),Xe=t(`prompts.${se.id}Examples`,{returnObjects:!0}),Ge=Array.isArray(Xe)?Xe:[];return s.jsx("button",{onClick:()=>gt(Be),className:`group text-left w-full rounded-xl border ${se.borderColor} bg-surface-secondary/60 p-4 transition-all hover:bg-surface-secondary/80 hover:shadow-lg`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:`w-10 h-10 text-xl rounded-lg ${se.bgColor} flex items-center justify-center shrink-0`,children:se.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:`text-sm font-semibold bg-gradient-to-r ${se.color} bg-clip-text text-transparent`,children:t(`prompts.${se.id}`)}),s.jsx("p",{className:"text-[11px] text-fg-tertiary mt-1 leading-relaxed",children:t(`prompts.${se.id}Desc`)}),Ge.length>0&&s.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:Ge.slice(0,2).map((et,yt)=>s.jsxs("span",{className:"text-[10px] text-fg-muted bg-surface-elevated/60 rounded-full px-2 py-0.5 border border-border-default",onClick:he=>{he.stopPropagation(),gt(Be+et)},children:["“",et,"”"]},yt))})]})]})},se.id)})})]}),s.jsx("div",{className:"mb-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{onClick:()=>ke("creations"),className:`text-sm font-semibold transition-colors ${ne==="creations"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("myCreations.title")}),s.jsx("button",{onClick:()=>ke("orgAssets"),className:`text-sm font-semibold transition-colors ${ne==="orgAssets"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("orgAssets.title")})]}),ne==="creations"&&s.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(se=>s.jsx("button",{onClick:()=>g(se),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${h===se?"bg-brand-600 text-white":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(se==="all"?"myCreations.filterAll":se==="agent"?"myCreations.filterAgents":se==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},se))}),ne==="orgAssets"&&s.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(se=>s.jsx("button",{onClick:()=>mt(se),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${st===se?"bg-brand-600 text-white":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(se==="all"?"myCreations.filterAll":se==="agent"?"myCreations.filterAgents":se==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},se))})]})}),ne==="orgAssets"&&B.length>0&&s.jsx("div",{className:"flex gap-2 mb-3 overflow-x-auto pb-1",children:B.map(se=>s.jsx("button",{onClick:()=>I(se.id),className:`text-xs px-3 py-1.5 rounded-full whitespace-nowrap border transition-colors ${le===se.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:se.name},se.id))}),ne==="orgAssets"&&(B.length===0&&!Oe?s.jsx("div",{className:"text-center py-12",children:s.jsx("div",{className:"text-fg-tertiary text-sm",children:t("orgAssets.noOrgs")})}):Oe?s.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("orgAssets.loading")}):ot.length===0?s.jsx("div",{className:"text-center py-12",children:s.jsx("div",{className:"text-fg-tertiary text-sm",children:t("orgAssets.noItems")})}):s.jsx(Ar,{children:ot.map(se=>{const Be=se.author?.username&&se.slug?`${it.getUrl()}/@${encodeURIComponent(se.author.username)}/${encodeURIComponent(se.slug)}`:null;return s.jsx(ia,{type:se.itemType,name:se.name,description:se.description,seed:se.slug||se.id||se.name,icon:se.icon,cover:se.thumbnailUrl,hubBase:it.getUrl(),author:se.author,version:se.version,rating:parseFloat(se.avgRating)||0,ratingCount:se.ratingCount,downloadCount:se.downloadCount,actions:Be?s.jsxs("a",{href:Be,target:"_blank",rel:"noopener noreferrer",onClick:Xe=>{Xe.stopPropagation(),pc()&&(Xe.preventDefault(),Ai(Be))},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:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),"Hub"]}):void 0},se.id)})})),ne==="creations"&&(m&&c.length===0?s.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("myCreations.loadingArtifacts")}):qe.length===0?s.jsxs("div",{className:"text-center py-12",children:[s.jsx("div",{className:"text-fg-tertiary text-sm",children:t("myCreations.noArtifacts")}),s.jsx("div",{className:"text-fg-muted text-xs mt-1",children:t("myCreations.noArtifactsHint")})]}):s.jsx(Ar,{children:qe.map(se=>{const Be=se.meta.displayName||se.meta.name||se.name,Xe=se.meta.description||"",Ge=`${se.type}/${se.name}`,et=x?.key===Ge?x.action:null,yt=D.get(Ge),he=se.meta.version||"1.0.0",V=!!yt,ye=V&&yt.version!==he,Qe=()=>{const ct=it.getUser();return!yt||!ct?null:`${it.getUrl()}/@${encodeURIComponent(ct.username)}/${encodeURIComponent(yt.slug)}`},pe=V&&(yt?.moderationStatus==="pending"||yt?.moderationStatus==="rejected"||!!yt?.pendingReview),ve=s.jsxs("div",{className:"flex items-center gap-1.5 justify-end",onClick:ct=>ct.stopPropagation(),children:[w.has(Ge)?s.jsxs("button",{onClick:()=>P(se),disabled:!!et,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:[s.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:[s.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),s.jsx("polyline",{points:"17 8 12 3 7 8"}),s.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]}),t(et==="uninstall"?"common:uninstalling":"common:uninstall")]}):s.jsxs("button",{onClick:()=>j(se),disabled:!!et,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:[s.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:[s.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),s.jsx("polyline",{points:"7 10 12 15 17 10"}),s.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),t(et==="install"?"common:installing":"common:install")]}),V&&pe?yt?.moderationStatus==="pending"?s.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:t("share.underReviewTip"),children:[s.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:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),t("share.underReview")]}):yt?.moderationStatus==="rejected"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-red-500/30 text-red-400 inline-flex items-center gap-1",title:t("share.rejectedTip"),children:[s.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:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),s.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),t("share.rejected")]}):s.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:t("share.updateUnderReviewTip"),children:[s.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:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),t("share.updateUnderReview")]}):V?s.jsxs(s.Fragment,{children:[ye&&s.jsxs("button",{onClick:()=>{const ct=yt?.visibility??"public";Rt(se,{visibility:ct})},disabled:!!et,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:[s.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:[s.jsx("polyline",{points:"23 4 23 10 17 10"}),s.jsx("polyline",{points:"1 20 1 14 7 14"}),s.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"})]}),et==="share"?t("common:sharing"):t("share.updateVersion",{version:he})]}),s.jsxs("a",{href:Qe()??"#",target:"_blank",rel:"noopener noreferrer",onClick:ct=>{const Xt=Qe();pc()&&Xt&&(ct.preventDefault(),Ai(Xt))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1 ${yt?.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/40":yt?.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:[yt?.visibility==="org"?s.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:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}):yt?.visibility==="unlisted"?s.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:[s.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"}),s.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"})]}):s.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:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),yt?.visibility==="org"?t("visibility.sharedOrg"):yt?.visibility==="unlisted"?t("visibility.sharedUnlisted"):t("visibility.shared")]}),s.jsxs("button",{onClick:()=>ee({key:Ge,name:Be}),disabled:!!et,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:[s.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:[s.jsx("path",{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M5.17 11.75l-1.71 1.71a5 5 0 0 0 7.07 7.07l1.71-1.71"}),s.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"})]}),t("unshare")]})]}):s.jsxs("button",{onClick:async()=>{await it.ensureAuth(),Array.isArray(se.meta.screenshots)&&se.meta.screenshots.length>0?Q(se):W(se)},disabled:!!et,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:[s.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:[s.jsx("circle",{cx:"18",cy:"5",r:"3"}),s.jsx("circle",{cx:"6",cy:"12",r:"3"}),s.jsx("circle",{cx:"18",cy:"19",r:"3"}),s.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),s.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),t(et==="share"?"common:sharing":"common:share")]})]}),Ye=s.jsx("button",{onClick:()=>S(se),disabled:!!et,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:s.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:[s.jsx("polyline",{points:"3 6 5 6 21 6"}),s.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"})]})}),nt=se.meta.icon,Dt=!!nt&&/\.(png|jpe?g|gif|webp|svg)$/i.test(nt)?nt.startsWith("http")||nt.startsWith("/")?nt:`/api/builder/artifacts/${se.type}s/${encodeURIComponent(se.name)}/images/${encodeURIComponent(nt.split("/").pop()??"")}`:nt;return s.jsx(ia,{type:se.type,name:Be,description:Xe,seed:Ge,icon:Dt,version:he,footerLeft:s.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary min-w-0",children:[s.jsx("button",{onClick:ct=>{ct.stopPropagation(),Ce.system.openPath(se.path).catch(()=>{})},className:"hover:text-fg-secondary transition-colors truncate min-w-0",title:se.path,children:nW(se.path)}),s.jsx("span",{className:"shrink-0",children:"·"}),s.jsx("span",{className:"shrink-0",children:new Date(se.updatedAt).toLocaleDateString()})]}),headerAction:Ye,actions:ve,onClick:()=>ft(se)},Ge)})})),_&&s.jsx(dr,{variant:"primary",title:t("confirmInstall"),message:t("confirmInstallMsg",{name:_.meta.displayName||_.meta.name||_.name}),confirmLabel:t("common:install"),onConfirm:()=>{const se=_;j(null),jt(se)},onCancel:()=>j(null)}),O&&s.jsx(dr,{variant:"primary",title:t("confirmUninstall"),message:t("confirmUninstallMsg",{name:O.meta.displayName||O.meta.name||O.name}),confirmLabel:t("common:uninstall"),onConfirm:()=>{const se=O;P(null),Jt(se)},onCancel:()=>P(null)}),T&&s.jsx(dr,{title:t("confirmDeleteLocal"),message:t("deleteCannotUndo",{name:T.meta.displayName||T.meta.name||T.name}),confirmLabel:t("common:delete"),onConfirm:Me,onCancel:()=>S(null)}),X&&s.jsx(dr,{title:t("confirmUnshare"),message:t("removeFromHub",{name:X.name}),confirmLabel:t("unshare"),onConfirm:()=>{be()},onCancel:()=>ee(null)}),H&&s.jsx(dr,{alertOnly:!0,variant:H.variant??"primary",title:H.title,message:H.message,onConfirm:()=>K(null),onCancel:()=>K(null)}),ae&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>W(null),children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:se=>se.stopPropagation(),children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-2",children:t("common:share")}),s.jsx("p",{className:"text-sm text-fg-secondary mb-5",children:t("share.imagePrompt")}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:()=>{const se=ae;W(null),Q(se)},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")}),s.jsx("button",{onClick:()=>{const se=ae;W(null),ft(se)},className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:t("share.addImagesFirst")})]})]})}),F&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>Z(null),children:s.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:se=>se.stopPropagation(),children:s.jsx(oW,{isUpdate:D.has(`${F.type}/${F.name}`),onCancel:()=>Z(null),onConfirm:(se,Be)=>{const Xe=F;Z(null),Rt(Xe,{priceCents:Be>0?Be:void 0})}})})}),U&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>Q(null),children:s.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:se=>se.stopPropagation(),children:s.jsx(iW,{onCancel:()=>Q(null),onConfirm:(se,Be,Xe,Ge)=>{const et=U;Q(null),Rt(et,{visibility:se,orgId:Be,priceCents:Xe,donationsEnabled:Ge})}})})})]})})}function iW({onCancel:e,onConfirm:t}){const{t:n}=dt(["builder","common"]),[r,o]=k.useState("public"),[l,c]=k.useState([]),[d,m]=k.useState(""),[p,h]=k.useState(!1),[g,x]=k.useState(0),[y,w]=k.useState(!1);k.useEffect(()=>{r==="org"&&l.length===0&&(h(!0),it.myOrgs().then(S=>{c(S.memberships),S.memberships.length>0&&m(S.memberships[0].id)}).catch(()=>{}).finally(()=>h(!1)))},[r,l.length]);const C=r==="public"||r==="unlisted",T=[{value:"public",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),s.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:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.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:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.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"}),s.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 s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:n("visibility.label")}),s.jsx("div",{className:"space-y-2 mb-5",children:T.map(S=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${r===S.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"visibility",checked:r===S.value,onChange:()=>o(S.value),className:"accent-brand-500"}),s.jsx("div",{className:"flex items-center gap-2 text-fg-secondary",children:S.icon}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:S.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:S.desc})]})]},S.value))}),r==="org"&&s.jsxs("div",{className:"mb-5",children:[s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("visibility.orgSelect")}),p?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:"Loading..."}):l.length===0?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:n("visibility.orgNone")}):s.jsx("select",{value:d,onChange:S=>m(S.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(S=>s.jsx("option",{value:S.id,children:S.name},S.id))})]}),C&&s.jsxs("div",{className:"mb-5",children:[s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("pricing.label")}),s.jsx("div",{className:"grid grid-cols-4 gap-2 mb-3",children:G3.map(S=>s.jsx("button",{type:"button",onClick:()=>x(S.cents),className:`text-sm px-2 py-2 rounded-lg border transition-colors ${g===S.cents?"border-brand-500 bg-brand-500/10 text-fg-primary":"border-border-default text-fg-secondary hover:border-gray-600"}`,children:S.label},S.cents))}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:y,onChange:S=>w(S.target.checked),className:"accent-brand-500"}),s.jsx("span",{className:"text-xs text-fg-secondary",children:n("pricing.enableTips")})]})]}),C&&s.jsx("div",{className:"mb-4 text-[11px] text-fg-tertiary rounded-lg border border-border-default px-3 py-2",children:n("pricing.reviewNote")}),s.jsxs("div",{className:"flex gap-3",children:[s.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")}),s.jsx("button",{onClick:()=>t(r,r==="org"?d:void 0,C&&g>0?g:void 0,C?y:void 0),disabled:r==="org"&&!d,className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n("shareMode.share")})]})]})}const G3=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function oW({isUpdate:e,onCancel:t,onConfirm:n}){const{t:r}=dt(["builder","common"]),[o,l]=k.useState(0);return s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:r(e?"shareMode.titleUpdate":"shareMode.title")}),s.jsx("div",{className:"space-y-2 mb-5",children:G3.map(c=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${o===c.cents?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"sharePrice",checked:o===c.cents,onChange:()=>l(c.cents),className:"accent-brand-500"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:c.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:c.cents===0?r("shareMode.freeDesc"):r("shareMode.paidDesc")})]})]},c.cents))}),s.jsxs("div",{className:"flex gap-3",children:[s.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:r("common:cancel")}),s.jsx("button",{onClick:()=>n(o>0?"paid":"free",o),className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:r(e?"shareMode.update":"shareMode.share")})]})]})}const lW=Object.freeze(Object.defineProperty({__proto__:null,AgentBuilder:q3},Symbol.toStringTag,{value:"Module"}));async function V3(e,t){if(!t)return{items:e,highlighted:null,missing:!1};const n=e.find(r=>r.id===t);if(n)return{items:[n,...e.filter(r=>r.id!==t)],highlighted:n,missing:!1};try{const{item:r}=await it.getItem(t);return r?{items:[r,...e],highlighted:r,missing:!1}:{items:e,highlighted:null,missing:!0}}catch{return{items:e,highlighted:null,missing:!0}}}function cW(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const l=n[o]??0,c=r[o]??0;if(l>c)return!0;if(l<c)return!1}return!1}function y0(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function A4(e,t){return e.i18n?.[t]?.description||e.description}const uW={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function dW({authUser:e,highlightItemId:t,onHighlightDone:n}={}){const{t:r,i18n:o}=dt(["store","common"]),l=o.language,[c,d]=k.useState(""),[m,p]=k.useState([]),[h,g]=k.useState([]),[x,y]=k.useState(null),[w,C]=k.useState({}),[T,S]=k.useState(!1),[_,j]=k.useState(!0),[O,P]=k.useState(new Map),[D,$]=k.useState(new Set),[X,ee]=k.useState(null),[H,K]=k.useState(null),ae=k.useCallback(async()=>{try{const[Z,U]=await Promise.all([Ce.builder.artifacts.list().catch(()=>({artifacts:[]})),Ce.builder.artifacts.installed().catch(()=>({installed:{}}))]),Q=new Map;for(const ne of Z.artifacts){if(ne.type!=="agent")continue;const ke=!!U.installed[`agent/${ne.name}`];Q.set(ne.name,{installed:ke,localVersion:ne.meta.version||void 0,localUpdatedAt:ne.updatedAt})}P(Q)}catch{}},[]),W=k.useCallback(async()=>{j(!0);try{const Z=c?it.search({type:"agent",q:c,limit:50}):wi(Tr.hubAgents)??it.search({type:"agent",limit:50}),U=new URLSearchParams;c&&U.set("q",c);const Q=fetch("/api/templates?"+U.toString()).then(q=>q.json()).catch(()=>({templates:[]})),[ne,ke]=await Promise.all([Z.catch(()=>({items:[],total:0})),Q,ae(),it.isAuthenticated()?it.purchases.mine().then(q=>$(new Set(q.purchases.map(le=>le.itemId)))).catch(()=>{}):Promise.resolve()]),B=await V3(ne?.items??[],t);g(B.items),p(Array.isArray(ke.templates)?ke.templates:[]),B.missing&&n?.()}catch{p([]),g([])}finally{j(!1)}},[c,ae,t,n]);k.useEffect(()=>{W()},[W]),k.useEffect(()=>{if(!x){C({});return}fetch(`/api/templates/${encodeURIComponent(x.id)}/files`,{credentials:"include"}).then(Z=>Z.json()).then(Z=>C(Z.files??{})).catch(()=>C({}))},[x]);const F=async(Z,U,Q)=>{try{const ne=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:Z,name:U,orgId:"default",teamId:Q})});if(!ne.ok)throw new Error(`Failed: ${ne.status}`);S(!1),y(null)}catch(ne){K({title:r("common:create",{defaultValue:"Create"}),message:`Failed to create agent: ${ne}`,variant:"danger"})}};if(X)return s.jsx(_i,{type:X.type,name:X.name,onBack:()=>ee(null)});if(x){const Z={type:"agent",name:x.id,displayName:y0(x,l),version:x.version,description:A4(x,l),author:x.author,category:x.category,tags:x.tags,icon:x.icon,files:w,agent:{roleName:x.roleId,agentRole:x.agentRole==="manager"?"manager":"worker"},dependencies:{skills:x.skills}},U=s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:r("agentStore.roleConfig")}),s.jsxs("div",{className:"space-y-2.5 text-sm",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-20",children:r("agentStore.role")}),s.jsx("span",{className:"text-fg-secondary font-mono text-xs bg-surface-elevated px-2 py-0.5 rounded",children:x.roleId})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-20",children:r("agentStore.position")}),s.jsx("span",{className:`px-2 py-0.5 rounded text-xs capitalize ${uW[x.agentRole]??""}`,children:x.agentRole})]})]})]}),s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:r("agentStore.skills")}),s.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[x.skills.map(Q=>s.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:Q},Q)),x.skills.length===0&&s.jsx("span",{className:"text-xs text-fg-tertiary italic",children:r("agentStore.noSkills")})]})]})]}),x.starterTasks&&x.starterTasks.length>0&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:r("agentStore.starterTasks")}),s.jsx("div",{className:"space-y-2",children:x.starterTasks.map((Q,ne)=>s.jsxs("div",{className:"flex items-start gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[s.jsx("span",{className:`inline-block w-2 h-2 rounded-full shrink-0 mt-1 ${Q.priority==="high"?"bg-red-400":Q.priority==="medium"?"bg-amber-400":"bg-green-400"}`}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm text-fg-primary",children:Q.title}),Q.description&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:Q.description})]})]},ne))})]})]});return s.jsxs(s.Fragment,{children:[s.jsx(_i,{type:"agent",name:x.id,onBack:()=>y(null),readOnly:!0,initialManifest:Z,actionSlot:s.jsx("button",{onClick:()=>S(!0),className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors font-medium",children:r("agentStore.hireAgent")}),contentSlot:U}),T&&s.jsx(E4,{template:x,lang:l,onClose:()=>S(!1),onHire:F}),H&&s.jsx(dr,{alertOnly:!0,variant:H.variant??"danger",title:H.title,message:H.message,onConfirm:()=>K(null),onCancel:()=>K(null)})]})}return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{"data-electron-drag":!0,className:"px-6 h-14 flex items-center justify-between shrink-0 gap-3",children:[s.jsx("h2",{className:"text-lg font-semibold",children:r("agentStore.title")}),s.jsx("input",{type:"text",placeholder:r("agentStore.searchPlaceholder"),value:c,onChange:Z=>d(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"})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:_?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((Z,U)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},U))}):m.length===0&&h.length===0?s.jsxs("div",{className:"text-center py-20",children:[s.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),s.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:c?r("agentStore.noResults",{search:c}):r("agentStore.noAgents")}),s.jsx("div",{className:"text-fg-tertiary text-sm",children:r(c?"agentStore.noResultsHint":"agentStore.noAgentsHint")})]}):s.jsxs(s.Fragment,{children:[m.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[s.jsx("h3",{className:"section-title",children:r("agentStore.builtin")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:r("agentStore.available",{count:m.length})})]}),s.jsx(Ar,{columns:3,children:m.map(Z=>s.jsx(ia,{type:"agent",name:y0(Z,l),description:A4(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:r("agentStore.builtin"),onClick:()=>y(Z)},Z.id))})]}),h.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:r("agentStore.markusHub")}),s.jsx(Ar,{columns:3,children:h.map(Z=>s.jsx(mW,{item:Z,localInfo:O.get(_c(Z)),purchased:Kd(Z,D),onStatusChange:ae,highlight:Z.id===t,onHighlightDone:n,onViewDetail:U=>ee({type:"agent",name:U})},Z.id))})]})]})}),T&&x&&s.jsx(E4,{template:x,lang:l,onClose:()=>S(!1),onHire:F}),H&&s.jsx(dr,{alertOnly:!0,variant:H.variant??"danger",title:H.title,message:H.message,onConfirm:()=>K(null),onCancel:()=>K(null)})]})}function _c(e,t){if(e.slug&&e.slug.trim())return e.slug.trim();const n=t&&typeof t.name=="string"?t.name.trim():"";return Xd(n||e.name,"hub-pkg")}function ki(e){return(async()=>{const t=await it.download(e.id),n=t.name||e.name,r=t.config??{},o=_c(e,r),l=t.itemType==="team"?"team":t.itemType==="skill"?"skill":"agent",c={type:"hub",hubItemId:e.id},d=(t.version||e.version||(typeof r.version=="string"?r.version:"")||"").trim()||void 0;if(t.files&&Object.keys(t.files).length>0)await Ce.builder.artifacts.import(l,o,t.files,c,d);else{const m={...r,...d?{version:d}:{},name:o,displayName:r.displayName||n,description:e.description,source:c};await Ce.builder.artifacts.save(l,m)}return await Ce.builder.artifacts.install(l,o),window.dispatchEvent(new CustomEvent("markus:data-changed")),n})()}async function Ug(e,t){t("checking"),await it.ensureAuth();const n=await it.purchases.checkout(e.id);if(n.alreadyOwned)return t("installing"),await ki(e),"installed";try{if((await it.creator.getBalance()).availableBalance>=(e.priceCents??0)){const l=await it.purchases.payWithEarnings(e.id);if(l.ok||l.alreadyOwned)return t("installing"),await ki(e),"installed"}}catch{}if(!n.checkoutUrl)throw new Error("No checkout URL");t("checkout_opened");const r=window.open(n.checkoutUrl,"_blank","noopener");return new Promise((o,l)=>{const c=setInterval(async()=>{const d=r?r.closed:!1;try{if((await it.purchases.checkout(e.id)).alreadyOwned){clearInterval(c),t("installing");try{await ki(e),o("installed")}catch(p){l(p)}return}}catch{}if(d){clearInterval(c);try{if((await it.purchases.checkout(e.id)).alreadyOwned){t("installing"),await ki(e),o("installed");return}}catch{}o("cancelled")}},2e3)})}function mW({item:e,localInfo:t,purchased:n,onStatusChange:r,highlight:o,onHighlightDone:l,onViewDetail:c}){const{t:d}=dt(["store"]),[m,p]=k.useState(!1),[h,g]=k.useState(""),x=k.useRef(null),[y,w]=k.useState(!1);k.useEffect(()=>{if(o&&x.current){x.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const X=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(X)}},[o,l]);const C=t?.installed??!1,T=C&&e.version&&t?.localVersion&&cW(e.version,t.localVersion),S=(e.priceCents??0)>0,_=async X=>{if(X.stopPropagation(),!m){p(!0),g("");try{await ki(e),g(T?d("card.upgraded"):d("card.installed")+"!"),r()}catch(ee){const H=ee instanceof Error?ee.message:"";H.includes("402")||H.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{p(!1)}}},j=async X=>{if(X.stopPropagation(),!m){p(!0),g("");try{await Ug(e,H=>{H==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):H==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),r()):g("")}catch(ee){g(ee instanceof Error?ee.message:d("card.failed"))}finally{p(!1)}}},O=S?`$${((e.priceCents??0)/100).toFixed(2)}`:null,P=e.slug&&e.author?.username?`${it.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,D=()=>{C&&c?c(_c(e)):P&&window.open(P,"_blank","noopener,noreferrer")},$=s.jsxs(s.Fragment,{children:[T?s.jsx("button",{onClick:X=>{_(X)},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?d("card.upgrading"):d("card.upgrade",{version:e.version})}):C?s.jsxs("button",{onClick:X=>{_(X)},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:[d("card.installed"),t?.localVersion?` v${t.localVersion}`:""]}):S&&!n?s.jsx("button",{onClick:X=>{j(X)},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?h||d("card.installing"):s.jsxs(s.Fragment,{children:[d("card.buy","Buy")," ",O]})}):s.jsx("button",{onClick:X=>{_(X)},disabled:m,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:d(m?"card.installing":"card.install")}),h&&!(S&&!n)&&s.jsx("span",{className:`text-[10px] ${h===d("card.failed")||h===d("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:h})]});return s.jsx("div",{ref:x,className:y?"animate-pulse":"",children:s.jsx(ia,{type:"agent",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"bot",cover:e.thumbnailUrl,hubBase:it.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:D,actions:$})})}function E4({template:e,lang:t,onClose:n,onHire:r}){const{t:o}=dt(["store"]),[l,c]=k.useState(`${y0(e,t)} Agent`),[d,m]=k.useState(""),[p,h]=k.useState([]),[g,x]=k.useState(!1);k.useEffect(()=>{fetch("/api/teams",{credentials:"include"}).then(w=>w.json()).then(w=>h(w.teams??[])).catch(()=>{})},[]);const y=async()=>{if(l.trim()){x(!0);try{await r(e.id,l.trim(),d||void 0)}finally{x(!1)}}};return s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:n,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[440px] shadow-2xl",onClick:w=>w.stopPropagation(),children:[s.jsx("div",{className:"flex items-center gap-3 mb-5",children:s.jsxs("div",{children:[s.jsx("h3",{className:"text-base font-semibold",children:o("hireModal.title")}),s.jsx("p",{className:"text-xs text-fg-tertiary",children:o("hireModal.creating",{name:y0(e,t)})})]})}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:o("hireModal.agentName")}),s.jsx("input",{type:"text",value:l,onChange:w=>c(w.target.value),className:"input-field",autoFocus:!0})]}),p.length>0&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:o("hireModal.assignTeam")}),s.jsxs("select",{value:d,onChange:w=>m(w.target.value),className:"input-field",children:[s.jsx("option",{value:"",children:o("hireModal.noTeam")}),p.map(w=>s.jsx("option",{value:w.id,children:w.name},w.id))]})]}),s.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg p-3",children:[s.jsx("div",{className:"text-xs text-fg-tertiary mb-2 font-medium",children:o("hireModal.agentConfig")}),s.jsxs("div",{className:"grid grid-cols-2 gap-y-1.5 gap-x-4 text-xs",children:[s.jsx("div",{className:"text-fg-tertiary",children:o("hireModal.role")}),s.jsx("div",{className:"text-fg-secondary font-mono",children:e.roleId}),s.jsx("div",{className:"text-fg-tertiary",children:o("hireModal.position")}),s.jsx("div",{className:"text-fg-secondary capitalize",children:e.agentRole}),s.jsx("div",{className:"text-fg-tertiary",children:o("hireModal.skills")}),s.jsx("div",{className:"text-fg-secondary",children:e.skills.join(", ")||o("hireModal.none")})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[s.jsx("button",{onClick:n,className:"btn-secondary",children:o("hireModal.cancel")}),s.jsx("button",{onClick:y,disabled:!l.trim()||g,className:"btn-primary",children:o(g?"hireModal.creating_progress":"hireModal.create")})]})]})})}function Jp(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function _4(e,t){return e.i18n?.[t]?.description||e.description}function j4(e,t,n){return e.i18n?.[n]?.members?.[t]||t}function fW(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const l=n[o]??0,c=r[o]??0;if(l>c)return!0;if(l<c)return!1}return!1}function pW({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:r}=dt(["store","common"]),o=r.language,[l,c]=k.useState(""),[d,m]=k.useState([]),[p,h]=k.useState([]),[g,x]=k.useState(null),[y,w]=k.useState({}),[C,T]=k.useState(!0),[S,_]=k.useState(!1),[j,O]=k.useState(null),[P,D]=k.useState(new Map),[$,X]=k.useState(new Set),[ee,H]=k.useState(null),K=k.useCallback(async()=>{try{const[F,Z]=await Promise.all([Ce.builder.artifacts.list().catch(()=>({artifacts:[]})),Ce.builder.artifacts.installed().catch(()=>({installed:{}}))]),U=new Map;for(const Q of F.artifacts){if(Q.type!=="team")continue;const ne=!!Z.installed[`team/${Q.name}`];U.set(Q.name,{installed:ne,localVersion:Q.meta.version||void 0,localUpdatedAt:Q.updatedAt})}D(U)}catch{}},[]),ae=k.useCallback(async()=>{T(!0);try{const F=l?it.search({type:"team",q:l,limit:50}):wi(Tr.hubTeams)??it.search({type:"team",limit:50}),[Z,U]=await Promise.all([F.catch(()=>({items:[],total:0})),Ce.teamTemplates.list(l||void 0).catch(()=>({templates:[]})),K(),it.isAuthenticated()?it.purchases.mine().then(ne=>X(new Set(ne.purchases.map(ke=>ke.itemId)))).catch(()=>{}):Promise.resolve()]),Q=await V3(Z?.items??[],e);h(Q.items),m(U?.templates??[]),Q.missing&&t?.()}catch{m([]),h([])}finally{T(!1)}},[l,K,e,t]);k.useEffect(()=>{ae()},[ae]),k.useEffect(()=>{if(!g){w({});return}fetch(`/api/team-templates/${encodeURIComponent(g.id)}/files`,{credentials:"include"}).then(F=>F.json()).then(F=>w(F.files??{})).catch(()=>w({}))},[g]);const W=async F=>{_(!0),O(null);try{const U=(await Ce.teams.create(F.name,F.description)).team.id;let Q,ne=0;const ke=[];for(const q of F.members){const le=q.count??1;for(let I=0;I<le;I++){const Ae=q.name??`${F.name} Agent ${I+1}`,$e=le>1?`${Ae} ${I+1}`:Ae,Oe=q.roleName??q.templateId;try{const We=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:$e,...Oe?{roleName:Oe}:{},orgId:"default",teamId:U,agentRole:q.role??"worker",skills:q.skills??[]})});if(We.ok){ne++;const st=await We.json();q.role==="manager"&&!Q&&(Q=st.agent?.id)}else{const st=await We.json().catch(()=>({error:`HTTP ${We.status}`}));ke.push(`${$e}: ${st.error??We.statusText}`)}}catch(We){ke.push(`${$e}: ${String(We)}`)}}}Q&&await Ce.teams.update(U,{managerId:Q,managerType:"agent"}).catch(()=>{});const B=ke.length>0?` (${ke.length} failed: ${ke[0]})`:"";O({ok:ne>0,message:`Team "${Jp(F,o)}" deployed with ${ne} agent(s)${B}`})}catch(Z){O({ok:!1,message:`Failed: ${Z}`})}finally{_(!1)}};if(ee)return s.jsx(_i,{type:ee.type,name:ee.name,onBack:()=>H(null)});if(g){const F={...y};g.announcements&&(F["ANNOUNCEMENT.md"]=g.announcements),g.norms&&(F["NORMS.md"]=g.norms);const Z={type:"team",name:g.id,displayName:Jp(g,o),version:g.version,description:_4(g,o),author:g.author,category:g.category??"general",tags:g.tags??[],files:F,team:{members:g.members.map(Q=>({name:j4(g,Q.name??Q.roleName??Q.templateId??"Agent",o),role:Q.role??"worker",roleName:Q.roleName??Q.templateId,count:Q.count??1,skills:Q.skills??[]}))}},U=s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsx("div",{className:"px-5 py-3 border-b border-border-default bg-surface-elevated/30",children:s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider",children:n("teamStore.teamComposition")})}),s.jsx("div",{className:"p-5 space-y-2",children:g.members.map((Q,ne)=>{const ke=j4(g,Q.name??Q.roleName??Q.templateId??"Agent",o);return s.jsxs("div",{className:"flex items-center gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[s.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center text-sm font-bold shrink-0 ${Q.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:(ke[0]??"?").toUpperCase()}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-fg-primary font-medium",children:ke}),s.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] capitalize font-medium ${Q.role==="manager"?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:Q.role??"worker"}),(Q.count??1)>1&&s.jsxs("span",{className:"text-[10px] text-fg-muted",children:["×",Q.count]})]}),(Q.roleName||Q.templateId)&&s.jsx("div",{className:"text-[10px] text-fg-tertiary font-mono mt-0.5",children:Q.roleName??Q.templateId})]}),Q.skills&&Q.skills.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 shrink-0",children:[Q.skills.slice(0,3).map(B=>s.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-surface-elevated text-fg-muted rounded border border-border-default",children:B},B)),Q.skills.length>3&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",Q.skills.length-3]})]})]},ne)})})]});return s.jsx(s.Fragment,{children:s.jsx(_i,{type:"team",name:g.id,onBack:()=>{x(null),O(null)},readOnly:!0,initialManifest:Z,contentSlot:U,actionSlot:s.jsxs(s.Fragment,{children:[j&&s.jsx("span",{className:`text-xs ${j.ok?"text-green-500":"text-red-500"}`,children:j.message}),s.jsx("button",{onClick:()=>{W(g)},disabled:S,className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors font-medium disabled:opacity-50",children:n(S?"teamStore.deploying":"teamStore.deployTeam")})]})})})}return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{"data-electron-drag":!0,className:"px-6 h-14 flex items-center justify-between shrink-0 gap-3",children:[s.jsx("h2",{className:"text-lg font-semibold",children:n("teamStore.title")}),s.jsx("input",{type:"text",placeholder:n("teamStore.searchPlaceholder"),value:l,onChange:F=>c(F.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"})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:C?s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:Array.from({length:4}).map((F,Z)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},Z))}):d.length===0&&p.length===0?s.jsxs("div",{className:"text-center py-20",children:[s.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"◉"}),s.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:l?n("teamStore.noResults",{search:l}):n("teamStore.noTeams")}),s.jsx("div",{className:"text-fg-tertiary text-sm",children:n(l?"teamStore.noResultsHint":"teamStore.noTeamsHint")})]}):s.jsxs(s.Fragment,{children:[d.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[s.jsx("h3",{className:"section-title",children:n("teamStore.builtin")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:n("teamStore.available",{count:d.length})})]}),s.jsx(Ar,{columns:2,children:d.map(F=>s.jsx(ia,{type:"team",name:Jp(F,o),description:_4(F,o),seed:F.id,icon:F.icon||"users",version:F.version,category:F.category,tags:F.tags,authorLabel:F.author,hideStats:!0,showTypeBadge:!1,cornerLabel:n("teamStore.builtin"),onClick:()=>x(F)},F.id))})]}),p.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:n("teamStore.markusHub")}),s.jsx(Ar,{columns:2,children:p.map(F=>s.jsx(hW,{item:F,localInfo:P.get(_c(F)),purchased:Kd(F,$),onStatusChange:K,highlight:F.id===e,onHighlightDone:t,onViewDetail:Z=>H({type:"team",name:Z})},F.id))})]})]})})]})}function hW({item:e,localInfo:t,purchased:n,onStatusChange:r,highlight:o,onHighlightDone:l,onViewDetail:c}){const{t:d}=dt(["store"]),[m,p]=k.useState(!1),[h,g]=k.useState(""),x=k.useRef(null),[y,w]=k.useState(!1);k.useEffect(()=>{if(o&&x.current){x.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const X=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(X)}},[o,l]);const C=t?.installed??!1,T=C&&e.version&&t?.localVersion&&fW(e.version,t.localVersion),S=(e.priceCents??0)>0,_=S?`$${((e.priceCents??0)/100).toFixed(2)}`:null,j=async X=>{if(X.stopPropagation(),!m){p(!0),g("");try{await ki(e),g(T?d("card.upgraded"):d("card.installed")+"!"),r()}catch(ee){const H=ee instanceof Error?ee.message:"";H.includes("402")||H.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{p(!1)}}},O=async X=>{if(X.stopPropagation(),!m){p(!0),g("");try{await Ug(e,H=>{H==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):H==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),r()):g("")}catch(ee){g(ee instanceof Error?ee.message:d("card.failed"))}finally{p(!1)}}},P=e.slug&&e.author?.username?`${it.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,D=()=>{C&&c?c(_c(e)):P&&window.open(P,"_blank","noopener,noreferrer")},$=s.jsxs(s.Fragment,{children:[T?s.jsx("button",{onClick:X=>{j(X)},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?d("card.upgrading"):d("card.upgrade",{version:e.version})}):C?s.jsxs("button",{onClick:X=>{j(X)},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:[d("card.installed"),t?.localVersion?` v${t.localVersion}`:""]}):S&&!n?s.jsx("button",{onClick:X=>{O(X)},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?h||d("card.installing"):s.jsxs(s.Fragment,{children:[d("card.buy","Buy")," ",_]})}):s.jsx("button",{onClick:X=>{j(X)},disabled:m,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:d(m?"card.installing":"card.install")}),h&&s.jsx("span",{className:`text-[10px] ${h===d("card.failed")||h===d("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:h})]});return s.jsx("div",{ref:x,className:y?"animate-pulse":"",children:s.jsx(ia,{type:"team",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"users",cover:e.thumbnailUrl,hubBase:it.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:D,actions:$})})}function eh(e,t){return e.i18n?.[t]?.displayName||e.name}function th(e,t){return e.i18n?.[t]?.description||e.description||""}function K3(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const l=n[o]??0,c=r[o]??0;if(l>c)return!0;if(l<c)return!1}return!1}const gW={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 bW({item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o}){const{t:l}=dt(["store"]),[c,d]=k.useState(!1),m=e.name.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed",p=t.find(S=>S.name===e.name||S.name===m||!!e.slug&&S.name===e.slug),h=!!p,g=h&&e.version&&p?.version&&K3(e.version,p.version),x=(e.priceCents??0)>0,[y,w]=k.useState(""),C=async()=>{if(!c){d(!0),w("");try{await ki(e),r(g?`Upgraded ${e.name}`:`Installed ${e.name}`,"success"),o()}catch(S){const _=S instanceof Error?S.message:"";_.includes("402")||_.includes("Purchase required")?r(l("card.purchaseRequired"),"error"):r(l("card.failed"),"error")}finally{d(!1)}}},T=async()=>{if(!c){d(!0),w("");try{await Ug(e,_=>{_==="checkout_opened"?w(l("card.waitingPurchase","Waiting for purchase...")):_==="installing"&&w(l("card.installing"))})==="installed"&&(r(`Purchased & installed ${e.name}`,"success"),o()),w("")}catch(S){r(S instanceof Error?S.message:l("card.failed"),"error"),w("")}finally{d(!1)}}};if(g)return s.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(h)return s.jsxs("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:[l("card.installed"),p?.version?` (v${p.version})`:""]});if(x&&!n){const S=`$${((e.priceCents??0)/100).toFixed(2)}`;return s.jsx("span",{className:"inline-flex items-center gap-1.5",children:s.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"):s.jsxs(s.Fragment,{children:[l("card.buy","Buy")," ",S]})})})}return s.jsx("button",{onClick:()=>{C()},disabled:c,className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:l(c?"card.installing":"card.install")})}function M4({item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o,highlight:l,onHighlightDone:c,type:d="skill"}){const m=k.useRef(null),[p,h]=k.useState(!1);k.useEffect(()=>{if(l&&m.current){m.current.scrollIntoView({behavior:"smooth",block:"center"}),h(!0);const y=setTimeout(()=>{h(!1)},4e3);return()=>clearTimeout(y)}},[l,c]);const g=e.slug&&e.author?.username?`${it.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,x=()=>{g&&window.open(g,"_blank","noopener,noreferrer")};return s.jsx("div",{ref:m,className:p?"animate-pulse":"",children:s.jsx(ia,{type:d,showTypeBadge:d!=="skill",name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||Bd(e.slug||e.name,e.category),cover:e.thumbnailUrl,hubBase:it.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:x,actions:s.jsx(bW,{item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o})})})}function xW({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:r}=dt(["store","common"]),o=r.language,l=Bo(),[c,d]=k.useState("skills"),[m,p]=k.useState(null),[h,g]=k.useState(new Set),[x,y]=k.useState([]),[w,C]=k.useState(null),[T,S]=k.useState([]),[_,j]=k.useState(0),[O,P]=k.useState(1),[D,$]=k.useState([]),[X,ee]=k.useState(""),[H,K]=k.useState("score"),[ae,W]=k.useState(""),[F,Z]=k.useState(!1),[U,Q]=k.useState([]),[ne,ke]=k.useState(!1),[B,q]=k.useState([]),[le,I]=k.useState(""),[Ae,$e]=k.useState(!1),[Oe,We]=k.useState([]),[st,mt]=k.useState([]),[At,gt]=k.useState(new Set),[jt,Jt]=k.useState(!1),[Rt,be]=k.useState(""),Me=[{id:"skills",labelKey:"skillStore.tabs.all"},{id:"skillhub",labelKey:"skillStore.tabs.skillhub"},{id:"skillssh",labelKey:"skillStore.tabs.skillssh"}],qe=(V,ye="success")=>{p({text:V,type:ye}),setTimeout(()=>p(null),ye==="error"?1e4:4e3)},ot=k.useCallback(async()=>{try{const V=await Ce.skills.list();y(V.skills)}catch{}},[]),ft=k.useCallback(async()=>{ke(!0);try{const V=await Ce.skills.builtin();Q(V.skills)}catch{}ke(!1)},[]),se=k.useCallback(async V=>{Z(!0);try{const ye=await Ce.skills.registrySkillhub({q:V?.q,category:V?.category,page:V?.page??1,limit:24,sort:V?.sort??H});S(ye.skills),j(ye.total),ye.categories?.length&&$(ye.categories)}catch{}Z(!1)},[H]),Be=k.useCallback(async V=>{$e(!0);try{const ye=await Ce.skills.registrySkillssh(V);q(ye.skills)}catch{}$e(!1)},[]),Xe=k.useCallback(async V=>{Jt(!0);try{const ye=V?it.search({type:"skill",q:V,limit:50}):wi(Tr.hubSkills)??it.search({type:"skill",limit:50}),Qe=it.search({subtype:"connector",q:V||void 0,limit:50}).catch(()=>({items:[]})),[pe,ve]=await Promise.all([ye,Qe,it.isAuthenticated()?it.purchases.mine().then(xt=>gt(new Set(xt.purchases.map(Dt=>Dt.itemId)))).catch(()=>{}):Promise.resolve()]);let Ye=pe?.items??[],nt=ve?.items??[];if(e){const xt=Ye.some(ct=>ct.id===e),Dt=nt.some(ct=>ct.id===e);if(!xt&&!Dt)try{const{item:ct}=await it.getItem(e);ct?.subtype==="connector"?nt=[ct,...nt]:ct?Ye=[ct,...Ye]:t?.()}catch{t?.()}else xt&&(Ye=[Ye.find(Xt=>Xt.id===e),...Ye.filter(Xt=>Xt.id!==e)]),Dt&&(nt=[nt.find(Xt=>Xt.id===e),...nt.filter(Xt=>Xt.id!==e)])}We(Ye),mt(nt)}catch{}Jt(!1)},[e,t]);k.useEffect(()=>{ot(),ft(),se(),Be()},[]),k.useEffect(()=>{c==="skills"&&Xe(Rt)},[c,Rt,Xe]);const Ge=async V=>{g(ye=>new Set(ye).add(V.name));try{const ye=await Ce.skills.install({name:V.name,source:"skillhub",slug:V.slug,sourceUrl:V.homepage,description:V.description_zh??V.description,category:"custom",version:V.version});await ot(),qe(`"${V.name}" installed (${ye.method}) → ${ye.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{qe(`Download failed for "${V.name}". You can try manually from: ${V.homepage}`,"error")}g(ye=>{const Qe=new Set(ye);return Qe.delete(V.name),Qe})},et=async V=>{g(ye=>new Set(ye).add(V.name));try{const ye=await Ce.skills.install({name:V.name,source:"skillssh",sourceUrl:V.url,githubRepo:`${V.author}/${V.repo}`,githubSkillPath:V.name});await ot(),qe(`"${V.name}" installed (${ye.method}) → ${ye.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{qe(`Download failed for "${V.name}". You can try manually from: ${V.url}`,"error")}g(ye=>{const Qe=new Set(ye);return Qe.delete(V.name),Qe})},yt=async V=>{g(ye=>new Set(ye).add(V.name));try{const ye=await Ce.skills.install({name:V.name,source:"builtin"});await ot(),await ft(),qe(`"${V.name}" installed (${ye.method}) → ${ye.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(ye){qe(`Install failed for "${V.name}": ${ye}`,"error")}g(ye=>{const Qe=new Set(ye);return Qe.delete(V.name),Qe})},he=B.filter(V=>{if(!le)return!0;const ye=le.toLowerCase();return V.name.toLowerCase().includes(ye)||V.repo.toLowerCase().includes(ye)});if(w){const V=w,ye={};V.instructions&&(ye["SKILL.md"]=V.instructions);const Qe={type:"skill",name:V.name,displayName:eh(V,o),version:V.version,description:th(V,o),author:V.author??"",category:V.category??"general",tags:V.tags,files:ye,skill:{skillFile:V.instructions?"SKILL.md":"",requiredPermissions:V.requiredPermissions,mcpServers:void 0,alwaysOn:!1}},pe=V.installed&&V.installedVersion&&K3(V.version,V.installedVersion)?s.jsx("button",{onClick:()=>{yt(V)},disabled:h.has(V.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:h.has(V.name)?n("card.upgrading"):n("card.upgrade",{version:V.version})}):V.installed?s.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:[s.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})}),n("card.installed"),V.installedVersion?` v${V.installedVersion}`:""]}):s.jsx("button",{onClick:()=>{yt(V)},disabled:h.has(V.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:h.has(V.name)?n("card.installing"):n("card.install")}),ve=s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.details")}),s.jsxs("div",{className:"space-y-2.5 text-sm",children:[V.category&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.category")}),s.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium capitalize ${gW[V.category]??"bg-gray-500/15 text-fg-secondary"}`,children:V.category})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.version")}),s.jsx("span",{className:"text-fg-secondary font-mono text-xs",children:V.version})]}),V.hasMcpServers&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.integration")}),s.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] bg-purple-500/15 text-purple-400",children:"MCP"})]}),V.hasInstructions&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.instructions")}),s.jsx("span",{className:"text-green-500 text-xs",children:"✓"})]})]})]}),(V.requiredPermissions.length>0||V.tags.length>0)&&s.jsxs("div",{className:"space-y-4",children:[V.requiredPermissions.length>0&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.permissions")}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:V.requiredPermissions.map(Ye=>s.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:Ye},Ye))})]}),V.tags.length>0&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.tags")}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:V.tags.map(Ye=>s.jsx("span",{className:"px-2.5 py-1 text-xs bg-surface-elevated text-fg-secondary rounded-lg border border-border-default/50",children:Ye},Ye))})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx(_i,{type:"skill",name:V.name,onBack:()=>C(null),readOnly:!0,initialManifest:Qe,actionSlot:pe,contentSlot:ve}),m&&s.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 s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:`${l?"px-4":"px-6"} shrink-0`,children:[s.jsx("div",{"data-electron-drag":!0,className:"flex items-center h-14",children:s.jsx("h2",{className:"text-lg font-semibold",children:n("skillStore.title")})}),s.jsx("div",{className:`flex ${l?"flex-wrap":""} gap-1 pb-2 overflow-x-auto scrollbar-hide`,children:Me.map(V=>s.jsx("button",{onClick:()=>d(V.id),className:`px-3 py-1.5 text-xs rounded-lg transition-colors shrink-0 ${c===V.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:n(V.labelKey)},V.id))})]}),m&&s.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 V=Rt.trim().toLowerCase(),ye=V?U.filter(ve=>eh(ve,o).toLowerCase().includes(V)||th(ve,o).toLowerCase().includes(V)):U,Qe=ne&&jt,pe=ye.length===0&&Oe.length===0&&st.length===0;return s.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"} space-y-8`,children:[s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("input",{value:Rt,onChange:ve=>be(ve.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"}`})}),Qe&&pe?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((ve,Ye)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},Ye))}):pe?s.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[s.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◇"}),s.jsx("div",{children:n("skillStore.noBuiltin")}),s.jsx("div",{className:"text-xs mt-1",children:n("skillStore.noBuiltinHint")})]}):s.jsxs(s.Fragment,{children:[ye.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[s.jsx("h3",{className:"section-title",children:n("skillStore.tabs.builtin")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:n("skillStore.builtinCount",{count:ye.length})})]}),s.jsx(Ar,{columns:3,children:ye.map(ve=>s.jsx(ia,{type:"skill",name:eh(ve,o),description:th(ve,o),seed:ve.name,icon:Bd(ve.name,ve.category),version:ve.version,category:ve.category,tags:ve.tags,authorLabel:ve.author||void 0,installed:ve.installed,hideStats:!0,showTypeBadge:!1,cornerLabel:ve.installed?void 0:n("skillStore.tabs.builtin"),onClick:()=>C(ve)},ve.name))})]}),Oe.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:n("skillStore.tabs.markusHub")}),s.jsx(Ar,{columns:3,children:Oe.map(ve=>s.jsx(M4,{item:ve,installedSkills:x,purchased:Kd(ve,At),onMsg:qe,onRefresh:()=>{ot(),Xe(Rt)},highlight:ve.id===e,onHighlightDone:t},ve.id))})]}),st.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"mb-3",children:[s.jsx("h3",{className:"section-title",children:n("tabs.connectors")}),s.jsx("p",{className:"text-xs text-fg-tertiary mt-0.5",children:n("connectorStore.emptyHint","连接器让智能体接入外部工具与服务 (MCP)")})]}),s.jsx(Ar,{columns:3,children:st.map(ve=>s.jsx(M4,{item:ve,type:"connector",installedSkills:x,purchased:Kd(ve,At),onMsg:qe,onRefresh:()=>{ot(),Xe(Rt)},highlight:ve.id===e,onHighlightDone:t},ve.id))})]})]})]})})(),c==="skillhub"&&s.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`,children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[s.jsxs("select",{value:X,onChange:V=>{ee(V.target.value),P(1),se({q:ae||void 0,category:V.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:[s.jsx("option",{value:"",children:n("skillStore.allCategories")}),D.map(V=>s.jsx("option",{value:V,children:V},V))]}),s.jsxs("select",{value:H,onChange:V=>{K(V.target.value),P(1),se({q:ae||void 0,category:X||void 0,page:1,sort:V.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:[s.jsx("option",{value:"score",children:n("skillStore.sortScore")}),s.jsx("option",{value:"downloads",children:n("skillStore.sortDownloads")}),s.jsx("option",{value:"stars",children:n("skillStore.sortStars")}),s.jsx("option",{value:"installs",children:n("skillStore.sortInstalls")})]}),!l&&s.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:s.jsx("a",{href:"https://skillhub.tencent.com",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),s.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[s.jsx("input",{value:ae,onChange:V=>W(V.target.value),onKeyDown:V=>{V.key==="Enter"&&(P(1),se({q:ae||void 0,category:X||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"}),s.jsx("button",{onClick:()=>{P(1),se({q:ae||void 0,category:X||void 0,page:1})},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg shrink-0",children:"Search"})]}),F?s.jsx("div",{className:"text-center text-fg-tertiary py-20",children:s.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillhub")})}):T.length===0?s.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[s.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◎"}),s.jsx("div",{children:n("skillStore.noSkillhub")})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"text-xs text-fg-tertiary mb-3",children:n("skillStore.skillhubTotal",{count:_.toLocaleString()})}),s.jsx(Ar,{columns:3,children:T.map(V=>{const ye=x.some(Qe=>Qe.name===V.name||Qe.name===V.slug);return s.jsx(ia,{type:"skill",name:V.name,description:V.description_zh??V.description??"",seed:V.slug,icon:Bd(V.slug||V.name,V.tags?.[0]),version:V.version,authorLabel:"SkillHub",showTypeBadge:!1,tags:V.tags,installed:ye,hideStats:!0,onClick:()=>window.open(V.homepage,"_blank","noopener,noreferrer"),footerLeft:s.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary",children:[V.stars>0&&s.jsxs("span",{className:"text-amber-600",children:["★ ",V.stars.toLocaleString()]}),V.downloads>0&&s.jsxs("span",{children:[V.downloads>=1e4?`${(V.downloads/1e4).toFixed(1)}万`:V.downloads.toLocaleString()," ",n("skillStore.downloads")]})]}),actions:ye?void 0:s.jsx("button",{onClick:()=>{Ge(V)},disabled:h.has(V.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:h.has(V.name)?"...":n("card.install")})},V.slug)})}),_>24&&s.jsxs("div",{className:"flex items-center justify-center gap-2 mt-6",children:[s.jsx("button",{disabled:O<=1,onClick:()=>{const V=O-1;P(V),se({q:ae||void 0,category:X||void 0,page:V})},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")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:n("skillStore.pageInfo",{current:O,total:Math.ceil(_/24)})}),s.jsx("button",{disabled:O>=Math.ceil(_/24),onClick:()=>{const V=O+1;P(V),se({q:ae||void 0,category:X||void 0,page:V})},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"&&s.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`,children:[s.jsxs("div",{className:`flex ${l?"flex-wrap":""} items-center gap-2 mb-5`,children:[s.jsx("input",{value:le,onChange:V=>I(V.target.value),onKeyDown:V=>{V.key==="Enter"&&le.trim()&&Be(le)},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"}`}),s.jsx("button",{onClick:()=>{le.trim()&&Be(le)},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg shrink-0",children:"Search"}),!l&&s.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:s.jsx("a",{href:"https://skills.sh",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),Ae?s.jsx("div",{className:"text-center text-fg-tertiary py-20",children:s.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillssh")})}):he.length===0?s.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[s.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"⬡"}),s.jsx("div",{children:n("skillStore.browseSkillssh")}),s.jsx("div",{className:"text-xs mt-1",children:n("skillStore.browseSkillsshHint")})]}):s.jsx(Ar,{columns:3,children:he.map(V=>{const ye=x.some(Qe=>Qe.name===V.name);return s.jsx(ia,{type:"skill",name:V.name,description:V.description||"",seed:`${V.author}-${V.name}`,icon:Bd(V.name),authorLabel:`${V.author}/${V.repo}`,showTypeBadge:!1,installed:ye,hideStats:!0,cornerLabel:ye?void 0:"skills.sh",onClick:()=>window.open(V.url,"_blank","noopener,noreferrer"),footerLeft:V.installs?s.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[V.installs," installs"]}):void 0,actions:ye?void 0:s.jsx("button",{onClick:()=>{et(V)},disabled:h.has(V.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:h.has(V.name)?"...":n("card.install")})},`${V.author}-${V.name}`)})})]})]})}const yW=["agent","team","skill","connector"];function nh({title:e,subtitle:t,onMore:n,moreLabel:r}){return s.jsxs("div",{className:"flex items-end justify-between mb-3",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"section-title",children:e}),t&&s.jsx("p",{className:"section-subtitle",children:t})]}),n&&s.jsxs("button",{className:"section-link",onClick:n,children:[r??"View all"," →"]})]})}function vW({item:e,onOpen:t}){const n=Ko(e.subtype==="connector"?"connector":e.itemType),r=Bg(n,e.slug||e.name),o=Ti[n];return s.jsxs("button",{onClick:t,className:"group relative w-full overflow-hidden rounded-2xl text-left h-44 md:h-52",style:{background:r},children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-black/55 via-black/20 to-transparent"}),s.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:s.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"})}),s.jsxs("div",{className:"relative h-full flex flex-col justify-end p-5 md:p-6",children:[s.jsxs("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:["★ Featured · ",o.label]}),s.jsx("h2",{className:"text-xl md:text-2xl font-bold text-white drop-shadow-sm",children:e.name}),s.jsx("p",{className:"text-sm text-white/85 truncate max-w-lg mt-1",children:e.description}),s.jsxs("div",{className:"flex items-center gap-3 mt-3 text-white/80 text-xs",children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(x0,{name:e.author?.displayName,username:e.author?.username,avatarUrl:e.author?.avatarUrl,hubBase:it.getUrl(),size:18}),e.author?.displayName||e.author?.username]}),s.jsxs("span",{children:["↓ ",Eo(e.downloadCount)]}),(e.priceCents??0)>0?s.jsxs("span",{className:"badge-paid",children:["$",((e.priceCents??0)/100).toFixed(0)]}):s.jsx("span",{className:"badge-free",children:"Free"})]})]})]})}function R4({items:e,onOpen:t}){return s.jsx(Ar,{columns:3,children:e.map(n=>s.jsx(ia,{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:it.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 O4(){return s.jsx(Ar,{columns:3,children:Array.from({length:6}).map((e,t)=>s.jsx("div",{className:"h-64 rounded-2xl skeleton"},t))})}function wW({onOpenType:e}){const{t}=dt(["store","common"]),[n,r]=k.useState([]),[o,l]=k.useState(!0);k.useEffect(()=>{let g=!1;return(async()=>{l(!0);try{const x=await it.search({limit:60,sort:"popular"});g||r(x.items??[])}catch{g||r([])}finally{g||l(!1)}})(),()=>{g=!0}},[]);const c=k.useMemo(()=>{const g=n.filter(y=>y.featured);return(g.length>0?g:n).slice(0,3)},[n]),d=k.useMemo(()=>[...n].sort((g,x)=>(x.trendingScore??x.downloadCount)-(g.trendingScore??g.downloadCount)).slice(0,10),[n]),m=k.useMemo(()=>[...n].sort((g,x)=>(x.createdAt||"").localeCompare(g.createdAt||"")).slice(0,10),[n]),p=k.useMemo(()=>{const g=new Map;for(const x of n){const y=x.author?.username||x.author?.id;if(!y)continue;const w=g.get(y)??{author:x.author,downloads:0,count:0};w.downloads+=x.downloadCount||0,w.count+=1,g.set(y,w)}return[...g.values()].sort((x,y)=>y.downloads-x.downloads).slice(0,6)},[n]),h=g=>e(Ko(g.subtype==="connector"?"connector":g.itemType),g.id);return s.jsxs("div",{className:"flex-1 overflow-y-auto px-5 md:px-7 py-5 space-y-8",children:[s.jsxs("div",{className:"hero-glow rounded-2xl border border-border-subtle bg-surface-secondary p-5 md:p-6",children:[s.jsx("h1",{className:"text-2xl font-bold text-gradient tracking-tight",children:t("discover.title","Markus 广场")}),s.jsx("p",{className:"text-sm text-fg-tertiary mt-1 max-w-2xl",children:t("discover.subtitle","发现社区共享的智能体、AI 小队、技能与连接器 — 由创作者共建的开放生态。")}),s.jsx("div",{className:"flex flex-wrap gap-2 mt-4",children:yW.map(g=>s.jsxs("button",{onClick:()=>e(g),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 ${Ti[g].gradient} hover:opacity-90 transition-opacity`,children:[Ti[g].labelZh,s.jsx("span",{className:"opacity-70",children:Ti[g].label})]},g))})]}),o?s.jsx("div",{className:"h-52 rounded-2xl skeleton"}):c.length>0?s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:c.map(g=>s.jsx(vW,{item:g,onOpen:()=>h(g)},g.id))}):null,s.jsxs("section",{children:[s.jsx(nh,{title:t("discover.trending","热门趋势"),subtitle:t("discover.trendingSub","社区中下载与评分增长最快的资产")}),o?s.jsx(O4,{}):d.length>0?s.jsx(R4,{items:d,onOpen:h}):s.jsx(kW,{})]}),s.jsxs("section",{children:[s.jsx(nh,{title:t("discover.fresh","新鲜上架"),subtitle:t("discover.freshSub","来自创作者的最新作品")}),o?s.jsx(O4,{}):m.length>0?s.jsx(R4,{items:m,onOpen:h}):null]}),p.length>0&&s.jsxs("section",{children:[s.jsx(nh,{title:t("discover.topCreators","顶尖创作者"),subtitle:t("discover.topCreatorsSub","生态贡献榜")}),s.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:p.map((g,x)=>s.jsxs("div",{className:"asset-card p-4 flex flex-col items-center text-center",children:[s.jsxs("div",{className:"relative",children:[s.jsx(x0,{name:g.author?.displayName,username:g.author?.username,avatarUrl:g.author?.avatarUrl,hubBase:it.getUrl(),size:48,verified:x<3}),x<3&&s.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:x+1})]}),s.jsx("div",{className:"text-sm font-semibold text-fg-primary truncate w-full mt-2",children:g.author?.displayName||g.author?.username}),s.jsxs("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:[g.count," 作品 · ↓ ",Eo(g.downloads)]})]},g.author?.username||x))})]})]})}function kW(){const{t:e}=dt(["store"]);return s.jsxs("div",{className:"text-center py-12 rounded-2xl border border-dashed border-border-default",children:[s.jsx("div",{className:"text-3xl mb-2 opacity-40",children:"✦"}),s.jsx("div",{className:"text-fg-secondary font-medium",children:e("discover.empty","生态正在成长中")}),s.jsx("div",{className:"text-fg-tertiary text-sm mt-1",children:e("discover.emptyHint","成为首批创作者,分享你的第一个资产")})]})}function Ad(e,t,n){return e.i18n?.[n]?.[t]}function SW(){const{t:e,i18n:t}=dt(["store","common"]),n=Bo(),r=t.language,[o,l]=k.useState([]),[c,d]=k.useState({}),[m,p]=k.useState(new Set),[h,g]=k.useState(null),[x,y]=k.useState(!0),[w,C]=k.useState(""),[T,S]=k.useState("all"),[_,j]=k.useState(null),O=k.useCallback(async()=>{y(!0);try{const[$,X,ee,H]=await Promise.all([Ce.builder.artifacts.list().catch(()=>({artifacts:[]})),Ce.builder.artifacts.installed().catch(()=>({installed:{}})),Ce.skills.updates().catch(()=>({updates:[],count:0})),Ce.skills.builtin().catch(()=>({skills:[]}))]),K={};for(const F of ee.updates)K[F.name]={availableVersion:F.availableVersion,installedVersion:F.installedVersion,displayName:F.displayName,description:F.description};d(K);const ae=$.artifacts.filter(F=>{const Z=`${F.type}/${F.name}`;return!!X.installed[Z]}),W=new Set(ae.filter(F=>F.type==="skill").map(F=>F.name));for(const F of H.skills)!F.installed||W.has(F.name)||!(X.installed[`skill/${F.name}`]||K[F.name])&&!F.updateAvailable||!X.installed[`skill/${F.name}`]&&!K[F.name]||(ae.push({type:"skill",name:F.name,meta:{displayName:F.i18n?.[r]?.displayName||F.name,description:F.i18n?.[r]?.description||F.description||"",version:F.installedVersion||F.version,author:F.author,category:F.category,tags:F.tags,i18n:F.i18n},path:"",updatedAt:""}),W.add(F.name));for(const[F,Z]of Object.entries(K))W.has(F)||(ae.push({type:"skill",name:F,meta:{displayName:Z.displayName||F,description:Z.description||"",version:Z.installedVersion},path:"",updatedAt:""}),W.add(F));l(ae)}catch{}y(!1)},[r]);k.useEffect(()=>{O()},[O]),k.useEffect(()=>{const $=()=>{O()};return window.addEventListener("markus:data-changed",$),()=>window.removeEventListener("markus:data-changed",$)},[O]),k.useEffect(()=>{if(!h)return;const $=setTimeout(()=>g(null),3e3);return()=>clearTimeout($)},[h]);const P=async($,X)=>{if(!m.has($)){p(ee=>new Set(ee).add($));try{await Ce.skills.install({name:$,source:"builtin"});try{localStorage.removeItem("markus:template-updates-ack")}catch{}g({text:e("installedTab.updateSuccess",{name:$,version:X}),type:"success"}),window.dispatchEvent(new CustomEvent("markus:data-changed")),await O()}catch{g({text:e("installedTab.updateFailed",{name:$}),type:"error"})}p(ee=>{const H=new Set(ee);return H.delete($),H})}},D=o.filter($=>{if(T!=="all"&&$.type!==T)return!1;if(!w)return!0;const X=w.toLowerCase(),ee=(Ad($.meta,"displayName",r)||$.meta.displayName||$.name).toLowerCase(),H=(Ad($.meta,"description",r)||$.meta.description||"").toLowerCase();return ee.includes(X)||H.includes(X)}).sort(($,X)=>{const ee=$.type==="skill"&&c[$.name]?1:0;return(X.type==="skill"&&c[X.name]?1:0)-ee});return _?s.jsx(_i,{type:_.type,name:_.name,onBack:()=>j(null)}):s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{"data-electron-drag":!0,className:`${n?"px-4":"px-6"} h-14 flex items-center shrink-0 gap-3`,children:[s.jsx("h2",{className:"text-lg font-semibold",children:e("installedTab.title")}),Object.keys(c).length>0&&s.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]})]}),s.jsxs("div",{className:`flex flex-wrap items-center gap-2 ${n?"px-4":"px-6"} py-2 shrink-0`,children:[s.jsx("div",{className:"flex gap-1",children:["all","agent","team","skill"].map($=>s.jsx("button",{onClick:()=>S($),className:`px-3 py-1 text-xs rounded-md transition-colors ${T===$?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:e(`installedTab.filter${$==="all"?"All":$==="agent"?"Agents":$==="team"?"Teams":"Skills"}`)},$))}),s.jsx("div",{className:"flex-1 min-w-[120px]",children:s.jsx("input",{type:"text",placeholder:e("installedTab.searchPlaceholder"),value:w,onChange:$=>C($.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"})})]}),s.jsx("div",{className:`flex-1 overflow-y-auto ${n?"p-4":"p-7"}`,children:x?s.jsx("div",{className:"text-center text-fg-tertiary py-20 animate-pulse",children:e("installedTab.loading")}):D.length===0?s.jsxs("div",{className:"text-center py-20",children:[s.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),s.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:e("installedTab.noItems")}),s.jsx("div",{className:"text-fg-tertiary text-sm",children:e("installedTab.noItemsHint")})]}):s.jsx(Ar,{columns:3,children:D.map($=>{const X=Ad($.meta,"displayName",r)||$.meta.displayName||$.name,ee=Ad($.meta,"description",r)||$.meta.description||"",H=$.meta.version||"",K=$.meta.author||"",ae=$.meta.tags??[],W=$.meta.category||"",F=$.meta.icon,Z=$.type==="skill"?c[$.name]:void 0;return s.jsx(ia,{type:$.type,name:X,description:ee,seed:$.name,icon:F,author:null,authorLabel:K||void 0,version:Z?Z.installedVersion:H,category:W,tags:ae,installed:!Z,hideStats:!0,cornerLabel:Z?e("installedTab.updateAvailable"):void 0,onClick:()=>{$.path&&j({type:$.type,name:$.name})},actions:Z?s.jsx("button",{type:"button",disabled:m.has($.name),onClick:()=>{P($.name,Z.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($.name)?e("installedTab.updating"):e("installedTab.updateTo",{version:Z.availableVersion})}):void 0},`${$.type}/${$.name}`)})})}),h&&s.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 ${h.type==="success"?"bg-emerald-600 text-white":"bg-red-600 text-white"}`,children:h.text})]})}const NW=50,CW=30;function TW(e,t,n,r){const o=k.useRef(0),l=k.useRef(0),c=k.useCallback(m=>{o.current=m.touches[0].clientX,l.current=m.touches[0].clientY},[]),d=k.useCallback(m=>{const p=m.changedTouches[0].clientX-o.current,h=m.changedTouches[0].clientY-l.current,g=Math.abs(p),x=Math.abs(h);if(g<NW||Math.atan2(x,g)*(180/Math.PI)>CW)return;if(r?.scrollContainerRef?.current){const C=r.scrollContainerRef.current,T=C.scrollLeft<=1,S=C.scrollLeft+C.clientWidth>=C.scrollWidth-1;if(p>0&&!T||p<0&&!S)return}const w=e.findIndex(C=>C.id===t);p<0&&w<e.length-1?n(e[w+1].id):p>0&&w>0?n(e[w-1].id):p>0&&w===0&&r?.onSwipeOutLeft?r.onSwipeOutLeft():p<0&&w===e.length-1&&r?.onSwipeOutRight&&r.onSwipeOutRight()},[e,t,n,r]);return{onTouchStart:c,onTouchEnd:d}}const AW=["builder","discover","agents","teams","skills","installed"],EW={agent:"agents",team:"teams",skill:"skills",connector:"skills"};function Yh(e){return!!e&&AW.includes(e)}function D4(){const e=localStorage.getItem("markus_nav_installItem"),t=localStorage.getItem("markus_nav_storeTab");return{tab:Yh(t)?t:"builder",installId:e}}function _W({authUser:e}){const{t}=dt(["nav","store","common"]),n=k.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]),[r]=k.useState(D4),[o,l]=k.useState(r.tab),[c,d]=k.useState(r.installId),m=TW(n,o,l);k.useEffect(()=>{const h=D4();h.installId&&(d(h.installId),Yh(h.tab)&&l(h.tab),localStorage.removeItem("markus_nav_installItem"),localStorage.removeItem("markus_nav_storeTab"))},[]),k.useEffect(()=>{const h=g=>{const x=g.detail,y=x.params?.storeTab??localStorage.getItem("markus_nav_storeTab");Yh(y)&&l(y);const w=x.params?.installItem??localStorage.getItem("markus_nav_installItem");w&&d(w),localStorage.removeItem("markus_nav_storeTab"),localStorage.removeItem("markus_nav_installItem")};return window.addEventListener("markus:navigate",h),()=>window.removeEventListener("markus:navigate",h)},[]);const p=(h,g)=>{g&&d(g),l(EW[h]??"agents")};return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:m.onTouchStart,onTouchEnd:m.onTouchEnd,children:[s.jsxs("div",{className:"flex items-center shrink-0 overflow-x-auto scrollbar-hide",children:[s.jsx(x5,{className:"ml-2"}),n.map(h=>s.jsx("button",{onClick:()=>l(h.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 ${o===h.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:h.label},h.id))]}),s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[o==="builder"&&s.jsx(q3,{authUser:e}),o==="discover"&&s.jsx(wW,{onOpenType:p}),o==="agents"&&s.jsx(dW,{authUser:e,highlightItemId:c,onHighlightDone:()=>d(null)}),o==="teams"&&s.jsx(pW,{highlightItemId:c,onHighlightDone:()=>d(null)}),o==="skills"&&s.jsx(xW,{highlightItemId:c,onHighlightDone:()=>d(null)}),o==="installed"&&s.jsx(SW,{})]})]})}const L4="usageType",rh="profile";function jW({onComplete:e,theme:t,onThemeChange:n,skipProfile:r,onProfileUpdated:o}){const{t:l}=dt(["onboarding","common"]),[c,d]=k.useState(0),[m,p]=k.useState(""),[h,g]=k.useState(""),[x,y]=k.useState(""),[w,C]=k.useState(""),[T,S]=k.useState(!1),[_,j]=k.useState(""),[O,P]=k.useState(!1),[D,$]=k.useState(null);k.useEffect(()=>{Ce.auth.me().then(({user:be})=>{be.name&&p(be.name),be.email&&g(be.email),be.avatarUrl&&$(be.avatarUrl);const Me=be.name||be.email?.split("@")[0]||"";Me&&K(qe=>qe||l("usageType.defaultOrgName",{name:Me}))}).catch(()=>{}),Ce.settings.getOrg().then(({org:be})=>{be?.name&&be.name!=="My Organization"&&K(be.name)}).catch(()=>{}),yn()&&Ce.hubOrgs.invitations().then(be=>{be.invitations?.length>0&&ke(be.invitations)}).catch(()=>{})},[]);const[X,ee]=k.useState(null),[H,K]=k.useState(""),[ae,W]=k.useState(!1),[F,Z]=k.useState(!1),[U,Q]=k.useState(""),[ne,ke]=k.useState([]),[B,q]=k.useState(null),[le,I]=k.useState(null),Ae=async()=>{const be=H.trim();if(be){W(!0),Q("");try{if(await Ce.settings.updateOrg(be),yn()){const Me=await Ce.hubOrgs.mine(),qe=Me.orgs?.find(ot=>ot.role==="owner")??Me.orgs?.[0];qe?.id?await Ce.hubOrgs.update(qe.id,{name:be}):await Ce.hubOrgs.create(be)}Z(!0)}catch{Q(l("usageType.orgNameSaveFailed"))}finally{W(!1)}}},[$e,Oe]=k.useState(!0),We=async()=>{if(j(""),!m.trim()){j(l("profile.errors.nameRequired"));return}if(!h.trim()){j(l("profile.errors.emailRequired"));return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(h.trim())){j(l("profile.errors.emailInvalid"));return}if(x&&x.length<6){j(l("profile.errors.passwordTooShort"));return}if(x&&x!==w){j(l("profile.errors.passwordMismatch"));return}S(!0);try{const{user:be}=await Ce.auth.updateProfile(m.trim(),h.trim());x&&await Ce.auth.changePassword("",x),o?.(be),P(!0)}catch{j(l("profile.errors.saveFailed"))}finally{S(!1)}},st=[{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")}],mt=[{id:"welcome",title:l("welcome.title"),subtitle:l("welcome.subtitle"),content:s.jsx("p",{className:"text-fg-secondary text-sm leading-relaxed",children:s.jsx(Q7,{i18nKey:"welcome.description",ns:"onboarding",components:{strong:s.jsx("strong",{className:"text-fg-primary"})}})})},{id:L4,title:l("usageType.title",{defaultValue:"How will you use Markus?"}),subtitle:l("usageType.subtitle",{defaultValue:"This helps us tailor your experience."}),content:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("button",{onClick:()=>{ee("personal"),Z(!0)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${X==="personal"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[s.jsx("span",{className:"text-2xl",children:"👤"}),s.jsxs("div",{children:[s.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:l("usageType.personal",{defaultValue:"Personal"})}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:l("usageType.personalDesc",{defaultValue:"Individual use with your own AI agents."})})]})]}),s.jsxs("button",{onClick:()=>{ee("organization"),Z(!1)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${X==="organization"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[s.jsx("span",{className:"text-2xl",children:"🏢"}),s.jsxs("div",{children:[s.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:l("usageType.organization",{defaultValue:"Team & Enterprise"})}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:l("usageType.organizationDesc",{defaultValue:"For teams sharing licenses and collaborating."})})]})]})]}),X==="organization"&&s.jsxs("div",{className:"space-y-4 mt-4",children:[ne.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-xs text-fg-tertiary font-medium",children:l("usageType.pendingInvitations")}),ne.map(be=>s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 rounded-xl border border-amber-500/20 bg-amber-500/5",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:be.orgName}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:l("usageType.invitedBy",{name:be.invitedBy})})]}),s.jsx("button",{onClick:async()=>{q(be.orgId);try{await Ce.hubOrgs.acceptInvitation(be.orgId),I(be.orgId),Z(!0)}catch{}finally{q(null)}},disabled:B===be.orgId||le===be.orgId,className:"px-3 py-1.5 text-xs rounded-lg bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white transition-colors",children:le===be.orgId?l("usageType.accepted"):B===be.orgId?l("usageType.accepting"):l("usageType.acceptAndJoin")})]},be.orgId)),s.jsx("div",{className:"text-[11px] text-fg-tertiary text-center pt-1",children:l("usageType.orCreateNew")})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("usageType.orgNameLabel")}),s.jsx("input",{type:"text",value:H,onChange:be=>{K(be.target.value),Z(!1),Q("")},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"})]}),U&&s.jsx("p",{className:"text-xs text-red-500",children:U}),s.jsx("button",{onClick:()=>{Ae()},disabled:ae||!H.trim()||F,className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:l(ae?"common:saving":F?"usageType.orgNameSaved":"usageType.setOrgName")})]})]})},{id:rh,title:l("profile.title"),subtitle:l("profile.subtitle"),content:O?s.jsxs("div",{className:"flex items-center gap-3 bg-green-500/10 border border-green-500/30 rounded-xl p-4",children:[s.jsx("span",{className:"text-green-600 text-lg",children:"✓"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-green-600",children:l("profile.saved")}),s.jsxs("div",{className:"text-xs text-fg-secondary mt-0.5",children:[m," · ",h]})]})]}):s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"flex justify-center",children:s.jsx(b5,{currentUrl:D,name:m,size:64,targetType:"user"})}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.nameLabel")," ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"text",value:m,onChange:be=>p(be.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})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.emailLabel")," ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"email",value:h,onChange:be=>g(be.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"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("profile.newPasswordLabel")}),s.jsx("input",{type:"password",value:x,onChange:be=>y(be.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"})]}),x&&s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("profile.confirmPasswordLabel")}),s.jsx("input",{type:"password",value:w,onChange:be=>C(be.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"})]}),_&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:_}),s.jsx("button",{onClick:()=>{We()},disabled:T||!m.trim()||!h.trim(),className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:l(T?"common:saving":"profile.saveProfile")})]})},{id:"theme",title:l("theme.title"),subtitle:l("theme.subtitle"),content:s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"grid grid-cols-3 gap-3",children:st.map(be=>s.jsxs("button",{onClick:()=>n(be.value),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-5 transition-all ${t===be.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[s.jsx("span",{className:"text-2xl",children:be.icon}),s.jsx("span",{className:"text-sm font-medium text-fg-primary",children:be.label}),s.jsx("span",{className:"text-[11px] text-fg-tertiary leading-tight text-center",children:be.desc})]},be.value))}),s.jsxs("label",{className:"flex items-center gap-2.5 p-3 bg-surface-elevated/30 rounded-lg cursor-pointer group",children:[s.jsx("input",{type:"checkbox",checked:$e,onChange:be=>Oe(be.target.checked),className:"accent-brand-500 shrink-0"}),s.jsx("span",{className:"text-[11px] text-fg-tertiary",children:l("done.telemetry")})]})]})}],At=r?mt.filter(be=>be.id!==rh):mt,gt=At.findIndex(be=>be.id===L4),jt=At.findIndex(be=>be.id===rh),Jt=()=>{c===gt&>>=0&&!X||c===gt&&X==="organization"&&!F||c===jt&&jt>=0&&!O||(c<At.length-1?d(c+1):(fetch("/api/settings/telemetry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:$e})}).catch(()=>{}),e()))},Rt=At[c];return s.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4",children:s.jsx("div",{className:"w-full max-w-lg",children:s.jsxs("div",{className:"bg-surface-elevated rounded-2xl p-8",children:[s.jsx("div",{className:"flex gap-1.5 mb-8",children:At.map((be,Me)=>s.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${Me<=c?"bg-brand-500":"bg-surface-elevated"}`},Me))}),s.jsx("h2",{className:"text-2xl font-bold text-fg-primary",children:Rt.title}),s.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:Rt.subtitle}),Rt.content,s.jsxs("div",{className:"flex justify-between mt-8",children:[c>0?s.jsx("button",{onClick:()=>d(c-1),className:"px-4 py-2 text-sm text-fg-secondary hover:text-fg-primary transition-colors",children:l("common:back")}):s.jsx("span",{}),s.jsx("button",{onClick:Jt,disabled:jt>=0&&c===jt&&!O||gt>=0&&c===gt&&(!X||X==="organization"&&!F),className:`px-6 py-2.5 text-white text-sm rounded-xl transition-colors ${jt>=0&&c===jt&&!O||gt>=0&&c===gt&&(!X||X==="organization"&&!F)?"bg-brand-600/40 cursor-not-allowed":"bg-brand-600 hover:bg-brand-500"}`,children:c===At.length-1?l("getStarted"):l("common:next")})]})]})})})}const I4="markus:legal-consent",MW="https://markus.global";function RW({onLogin:e,hasOwner:t}){const{t:n,i18n:r}=dt("auth"),[o,l]=k.useState(null),[c,d]=k.useState(""),[m,p]=k.useState(!1),[h,g]=k.useState(""),[x,y]=k.useState(""),[w,C]=k.useState(!1),[T,S]=k.useState(!1),_=K=>{const ae=(r.language||"").toLowerCase().startsWith("zh")?"?lang=zh":"";return`${MW}${K}${ae}`},j=()=>{try{localStorage.setItem(I4,JSON.stringify({acceptedAt:new Date().toISOString(),terms:!0,privacy:!0}))}catch{}},O=()=>T?(j(),!0):(C(!1),requestAnimationFrame(()=>C(!0)),!1),P=async()=>{const K=yn(),ae=sa();if(!K||!ae){d(n("login.hubUnavailable"));return}const W=await Ce.auth.hubLogin(K,ae);if(window.markusDesktop?.clearPendingDeepLinkAuth?.(),W.cloudAiReady===!1)try{sessionStorage.setItem("markus:cloud-ai-warning",W.cloudAiError?n("login.cloudAiNotReady",{error:W.cloudAiError}):n("login.cloudAiNotReadyGeneric"))}catch{}e(W.user,W.needsOnboarding??!1,{fromHub:!0})},D=async(K,ae=!1)=>{if(!(!ae&&!O())){d(""),l(K??"hub");try{if(ae&&yn()&&sa()){await P();return}await na(K),await P()}catch(W){const F=W instanceof Error?W.message:"";if(!F.includes("cancelled")){if(!ae&&yn())return D(K,!0);d(F||n("login.hubUnavailable"))}}finally{l(null)}}},$=()=>{AD(),l(null),d("")};k.useEffect(()=>{const K=window.markusDesktop;if(!K?.peekPendingDeepLinkAuth&&!K?.consumePendingDeepLinkAuth)return;let ae=!1;return(async()=>{const W=K.peekPendingDeepLinkAuth?await K.peekPendingDeepLinkAuth():null;if(ae||!W)return;let F=!1;try{F=!!localStorage.getItem(I4)}catch{}if(!T&&!F){d(n("login.consentRequired"));return}F&&!T&&S(!0),j();const Z=K.consumePendingDeepLinkAuth?await K.consumePendingDeepLinkAuth():W;if(!(ae||!Z)){d(""),l("hub");try{if(!await TD(Z)||!yn()||!sa()){d(n("login.hubUnavailable"));return}await P()}catch{d(n("login.hubUnavailable"))}finally{ae||l(null)}}})().catch(()=>{}),()=>{ae=!0}},[T]);const X=async K=>{if(K.preventDefault(),!(!h.trim()||!x)&&O()){d(""),l("local");try{const{user:ae,needsOnboarding:W}=await Ce.auth.login(h.trim(),x);e(ae,W??!1)}catch{d(n("login.invalidCredentials"))}finally{l(null)}}},ee=n(t?"login.welcomeBack":"login.getStarted"),H="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 s.jsxs("div",{className:"min-h-dvh bg-surface-primary flex flex-col items-center justify-center p-4 relative overflow-hidden",children:[s.jsxs("div",{className:"pointer-events-none absolute inset-0 overflow-hidden",children:[s.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]"}),s.jsx("div",{className:"absolute top-1/4 -left-40 h-[26rem] w-[26rem] rounded-full bg-brand-400/10 blur-[100px]"}),s.jsx("div",{className:"absolute -bottom-40 -right-32 h-[34rem] w-[34rem] rounded-full bg-brand-600/10 blur-[110px]"})]}),s.jsxs("div",{className:"w-full max-w-[26rem] relative z-10 flex-1 flex flex-col justify-center",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.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"}),s.jsx("div",{className:"text-[1.75rem] leading-none font-extrabold tracking-tight text-fg-primary mb-2",children:"Markus"}),s.jsx("div",{className:"text-sm text-fg-tertiary",children:ee})]}),s.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?s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-base font-semibold text-fg-primary",children:n("login.localTitle")}),s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:n("login.localAccountHint")})]}),s.jsxs("form",{onSubmit:X,className:"space-y-3",children:[s.jsx("input",{type:"email",value:h,onChange:K=>g(K.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}),s.jsx("input",{type:"password",value:x,onChange:K=>y(K.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&&s.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&&s.jsx("p",{className:"text-[11px] text-fg-tertiary",children:n("login.defaultCredentials")}),s.jsx("button",{type:"submit",disabled:o==="local"||!h||!x,className:"w-full h-11 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-semibold rounded-xl transition-all shadow-md shadow-brand-900/30 hover:shadow-lg active:scale-[0.99]",children:n(o==="local"?"login.signingIn":"login.signIn")})]}),s.jsx("div",{className:"text-center",children:s.jsx("button",{onClick:()=>{p(!1),d("")},className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors",children:n("login.backToHub")})})]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("button",{onClick:()=>D("google"),disabled:!!o,className:H,children:[s.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[s.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"}),s.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"}),s.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"}),s.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(o==="google"?"login.connectingHub":"login.withGoogle")]}),s.jsxs("button",{onClick:()=>D("github"),disabled:!!o,className:H,children:[s.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:s.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(o==="github"?"login.connectingHub":"login.withGithub")]}),s.jsxs("button",{onClick:()=>D("email"),disabled:!!o,className:H,children:[s.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:s.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(o==="email"?"login.connectingHub":"login.withEmail")]}),o&&(o==="google"||o==="github"||o==="email"||o==="hub")&&s.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:[s.jsx("p",{children:n("login.browserOpened")}),s.jsx("button",{type:"button",onClick:$,className:"text-brand-500 hover:text-brand-400 underline font-medium",children:n("login.cancelWaiting")})]}),c&&s.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}),s.jsxs("div",{className:"flex items-center gap-3 py-1 text-[11px] text-fg-tertiary",children:[s.jsx("span",{className:"h-px flex-1 bg-border-default"}),n("login.or"),s.jsx("span",{className:"h-px flex-1 bg-border-default"})]}),s.jsx("button",{onClick:()=>{p(!0),d("")},disabled:!!o,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")})]})}),s.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 ${w?"animate-shake text-fg-primary font-medium":"text-fg-tertiary"}`,children:[s.jsx("input",{type:"checkbox",checked:T,onChange:K=>{S(K.target.checked),K.target.checked&&C(!1)},className:"mt-0.5 h-3.5 w-3.5 shrink-0 accent-brand-600 cursor-pointer"}),s.jsxs("span",{className:"text-center",children:[n("login.consentPrefix")," ",s.jsx("a",{href:_("/terms"),target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-400 underline",children:n("login.termsLink")})," ",n("login.consentAnd")," ",s.jsx("a",{href:_("/privacy"),target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-400 underline",children:n("login.privacyLink")})]})]})]}),s.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:[s.jsx("a",{href:"https://markus.global",target:"_blank",rel:"noopener noreferrer",className:"hover:text-fg-secondary transition-colors",children:"markus.global"}),s.jsx("a",{href:"mailto:business@markus.global",className:"hover:text-fg-secondary transition-colors",children:n("login.contactSales")})]})]})}function OW({token:e,onComplete:t}){const{t:n}=dt("auth"),[r,o]=k.useState(null),[l,c]=k.useState(""),[d,m]=k.useState(""),[p,h]=k.useState(""),[g,x]=k.useState(!1),[y,w]=k.useState(!1),[C,T]=k.useState(!1);k.useEffect(()=>{Ce.auth.inviteInfo(e).then(_=>o(_)).catch(()=>T(!0))},[e]);const S=async _=>{if(_.preventDefault(),h(""),l.length<6){h(n("invite.passwordMinLength"));return}if(l!==d){h(n("invite.passwordsDoNotMatch"));return}x(!0);try{await Ce.auth.setup(e,l),w(!0),setTimeout(()=>{window.location.hash="",t()},2e3)}catch{h(n("invite.error"))}finally{x(!1)}};return s.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),s.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),s.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),s.jsx("div",{className:"text-sm text-fg-tertiary",children:n("invite.subtitle")})]}),s.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?s.jsxs("div",{className:"text-center space-y-3",children:[s.jsx("div",{className:"text-red-500 text-3xl",children:"⚠"}),s.jsx("p",{className:"text-sm text-fg-secondary",children:n("invite.invalidLink")}),s.jsx("button",{onClick:()=>{window.location.hash="",t()},className:"text-sm text-brand-500 hover:text-brand-400",children:n("login.signIn")})]}):y?s.jsxs("div",{className:"text-center space-y-3",children:[s.jsx("div",{className:"text-green-500 text-3xl",children:"✓"}),s.jsx("p",{className:"text-sm text-fg-secondary",children:n("invite.setupComplete")})]}):r?s.jsxs("form",{onSubmit:S,className:"space-y-5",children:[s.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n("invite.greeting",{name:r.name})}),s.jsx("p",{className:"text-xs text-fg-tertiary text-center",children:r.email}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("invite.setPassword")}),s.jsx("input",{type:"password",value:l,onChange:_=>c(_.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})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("invite.confirmPassword")}),s.jsx("input",{type:"password",value:d,onChange:_=>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})]}),p&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:p}),s.jsx("button",{type:"submit",disabled:g||!l||!d,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-all shadow-md shadow-brand-900/40 hover:shadow-lg hover:shadow-brand-900/50",children:n(g?"invite.settingUp":"invite.setupAccount")})]}):s.jsx("div",{className:"text-center text-fg-tertiary text-sm animate-pulse py-4",children:"Loading…"})})]})]})}function DW({onComplete:e,isFirstTime:t}){const{t:n}=dt("auth"),[r,o]=k.useState(""),[l,c]=k.useState(""),[d,m]=k.useState(""),[p,h]=k.useState(""),[g,x]=k.useState(!1),y=async w=>{if(w.preventDefault(),h(""),l.length<6){h(n("changePassword.passwordMinLength"));return}if(l!==d){h(n("changePassword.passwordsDoNotMatch"));return}x(!0);try{await Ce.auth.changePassword(r,l),e()}catch{h(n("changePassword.failedToChange"))}finally{x(!1)}};return s.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),s.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),s.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),s.jsx("div",{className:"text-sm text-fg-tertiary",children:n("login.subtitle")})]}),s.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:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n(t?"changePassword.setYourPassword":"changePassword.changePassword")}),t&&s.jsx("p",{className:"text-xs text-amber-600/80 text-center mt-2",children:n("changePassword.defaultPasswordWarning")})]}),!t&&s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.currentPassword")}),s.jsx("input",{type:"password",value:r,onChange:w=>o(w.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"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.newPassword")}),s.jsx("input",{type:"password",value:l,onChange:w=>c(w.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})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.confirmNewPassword")}),s.jsx("input",{type:"password",value:d,onChange:w=>m(w.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})]}),p&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:p}),s.jsx("button",{type:"submit",disabled:g||!l||!d,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-colors",children:n(g?"changePassword.saving":t?"changePassword.setPasswordAndContinue":"changePassword.changePassword")})]})]})]})}function LW({side:e,defaultWidth:t,minWidth:n,maxWidth:r,collapsedWidth:o=0,storageKey:l}){const[c,d]=k.useState(()=>{try{const C=localStorage.getItem(`${l}_w`);if(C)return Math.max(n,Math.min(r,parseInt(C,10)))}catch{}return t}),[m,p]=k.useState(()=>{try{return localStorage.getItem(`${l}_c`)==="1"}catch{return!1}}),h=k.useRef(!1),g=k.useRef(n),x=k.useRef(r);g.current=n,x.current=r,k.useEffect(()=>{try{localStorage.setItem(`${l}_w`,String(c))}catch{}},[c,l]),k.useEffect(()=>{try{localStorage.setItem(`${l}_c`,m?"1":"0")}catch{}},[m,l]),k.useEffect(()=>{d(C=>Math.max(n,Math.min(r,C)))},[n,r]);const y=k.useCallback(C=>{C.preventDefault(),h.current=!0;const T=C.clientX,S=c,_=O=>{if(!h.current)return;const P=e==="left"?O.clientX-T:T-O.clientX;d(Math.max(g.current,Math.min(x.current,S+P)))},j=()=>{h.current=!1,document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",j),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",_),document.addEventListener("mouseup",j),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[c,e]),w=k.useCallback(()=>p(C=>!C),[]);return{width:m?o:c,rawWidth:c,collapsed:m,toggle:w,setCollapsed:p,setWidth:d,onResizeStart:y}}const _Y=[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"cyberpunk",label:"Cyberpunk"},{value:"mono",label:"Mono"}],Xh="markus-theme";function P4(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 IW(){try{const e=localStorage.getItem(Xh);if(e==="midnight")return localStorage.setItem(Xh,"dark"),"dark";if(e==="light"||e==="dark"||e==="system"||e==="cyberpunk"||e==="mono")return e}catch{}return"system"}function PW(){const[e,t]=k.useState(IW),n=k.useCallback(r=>{t(r);try{localStorage.setItem(Xh,r)}catch{}P4(r)},[]);return k.useEffect(()=>{P4(e)},[e]),{mode:e,setMode:n}}const $d={agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]},zW={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},BW=["agents","tasks","requirements","projects","deliverables","workflows"];let z4="",B4="all",U4=$d,$4=!1;function UW({onClose:e,currentPage:t}){const{t:n}=dt(["common","home","work"]);zo(!0);const[r,o]=k.useState(z4),[l,c]=k.useState(B4),[d,m]=k.useState(U4),[p,h]=k.useState(!1),[g,x]=k.useState($4),[y,w]=k.useState(-1);k.useEffect(()=>{z4=r},[r]),k.useEffect(()=>{B4=l},[l]),k.useEffect(()=>{U4=d},[d]),k.useEffect(()=>{$4=g},[g]);const C=k.useRef(null),T=k.useRef(void 0),S=k.useRef(null),_=k.useRef(null);k.useEffect(()=>{setTimeout(()=>{C.current?.focus(),C.current?.select()},100)},[]);const j=k.useCallback(async W=>{if(!W.trim()){m($d),x(!1),w(-1);return}h(!0),x(!0),w(-1);const F=W.toLowerCase();try{const[Z,U,Q,ne,ke,B]=await Promise.allSettled([Ce.agents.list(),Ce.tasks.list({search:W,pageSize:20}),Ce.requirements.list(),Ce.projects.list(),Ce.deliverables.search({q:W,limit:20}),Ce.teams.list()]),q=Z.status==="fulfilled"?Z.value.agents.filter(We=>We.name?.toLowerCase().includes(F)||We.role?.toLowerCase().includes(F)):[],le=U.status==="fulfilled"?U.value.tasks:[],I=Q.status==="fulfilled"?Q.value.requirements.filter(We=>We.title?.toLowerCase().includes(F)||We.description?.toLowerCase().includes(F)):[],Ae=ne.status==="fulfilled"?ne.value.projects.filter(We=>We.name?.toLowerCase().includes(F)||We.description?.toLowerCase().includes(F)):[],$e=ke.status==="fulfilled"?ke.value.results:[],Oe=[];if(B.status==="fulfilled"){const We=await Promise.allSettled(B.value.teams.map(st=>Ce.workflows.list(st.id)));for(const st of We)if(st.status==="fulfilled")for(const mt of st.value.workflows)(mt.name.toLowerCase().includes(F)||(mt.displayName||"").toLowerCase().includes(F)||mt.description?.toLowerCase().includes(F))&&Oe.push(mt)}m({agents:q,tasks:le,requirements:I,projects:Ae,deliverables:$e,workflows:Oe})}catch{m($d)}finally{h(!1)}},[]),O=W=>{o(W),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>j(W),400)},P=k.useCallback((W,F)=>{e(),at.navigate(W,F)},[e]),D=[{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:"工作流"})}],$=k.useMemo(()=>zW[t||""]||BW,[t]),X=k.useMemo(()=>{const W=[],F=l==="all"?8:void 0,Z=U=>{if(l!=="all"&&l!==U)return;const Q=d[U].length;if(U==="workflows"){const ne=F?d.workflows.slice(0,F):d.workflows;for(const ke of ne)W.push({id:ke.name,type:"workflow",page:me.WORK,params:{boardType:"workflows"}})}else{const ne=d[U],ke=F?ne.slice(0,F):ne;for(const B of ke)switch(U){case"agents":W.push({id:B.id,type:"agent",page:me.TEAM,params:{agentId:B.id}});break;case"tasks":W.push({id:B.id,type:"task",page:me.WORK,params:{openTask:B.id}});break;case"requirements":W.push({id:B.id,type:"requirement",page:me.WORK,params:{openRequirement:B.id}});break;case"projects":W.push({id:B.id,type:"project",page:me.WORK,params:{projectId:B.id}});break;case"deliverables":W.push({id:B.id,type:"deliverable",page:me.DELIVERABLES,params:{openDeliverable:B.id}});break}}F&&Q>F&&W.push({id:`more_${U}`,type:"showMore",page:"",expandCategory:U,totalCount:Q})};for(const U of $)Z(U);return W},[d,l,$]),ee=k.useCallback(W=>{if(W.type==="showMore"&&W.expandCategory){c(W.expandCategory),w(-1);return}P(W.page,W.params)},[P]);k.useEffect(()=>{const W=_.current;if(!W||y<0)return;const F=W.querySelector(`[data-idx="${y}"]`);F&&F.scrollIntoView({block:"nearest"})},[y]);const H=k.useCallback(W=>{if(W.key==="Escape"){e();return}if(W.key==="Tab"){W.preventDefault();const U=D.map(ke=>ke.id),Q=U.indexOf(l),ne=W.shiftKey?Q<=0?U.length-1:Q-1:Q>=U.length-1?0:Q+1;c(U[ne]),w(-1);return}const F=W.ctrlKey&&W.key==="n"||W.key==="ArrowDown",Z=W.ctrlKey&&W.key==="p"||W.key==="ArrowUp";if(F||Z){W.preventDefault(),w(U=>{const Q=X.length-1;return Q<0?-1:F?U>=Q?0:U+1:U<=0?Q:U-1});return}W.key==="Enter"&&(W.preventDefault(),y>=0&&y<X.length&&ee(X[y]))},[e,X,y,ee,D,l]);k.useEffect(()=>(document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)),[H]);const K=X.length>0;let ae=0;return s.jsx("div",{ref:S,className:"fixed inset-0 bg-black/50 flex items-start justify-center z-50 pt-[8vh]",onClick:W=>{W.target===S.current&&e()},children:s.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:[s.jsxs("div",{className:"shrink-0 px-5 pt-4 pb-3 border-b border-border-default space-y-3",children:[s.jsxs("div",{className:"relative",children:[s.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:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),s.jsx("input",{ref:C,value:r,onChange:W=>O(W.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"}),r&&s.jsx("button",{onClick:()=>{o(""),m($d),x(!1),w(-1),C.current?.focus()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-fg-tertiary hover:text-fg-secondary",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),s.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:D.map(W=>s.jsx("button",{onClick:()=>{c(W.id),w(-1)},className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${l===W.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:W.label},W.id))})]}),s.jsxs("div",{ref:_,className:"flex-1 overflow-y-auto px-5 py-3",children:[p&&s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:n("common:loading")})}),!p&&g&&!K&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[s.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:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),s.jsx("p",{className:"text-sm text-fg-tertiary",children:n("common:noResults",{defaultValue:"没有找到相关结果"})})]}),!p&&K&&s.jsx("div",{className:"space-y-4",children:$.map(W=>{if(l!=="all"&&l!==W)return null;const F=l==="all"?8:void 0,Z=U=>{const Q=ae++,ne=U==="agents"?d.agents.length:U==="tasks"?d.tasks.length:U==="requirements"?d.requirements.length:U==="projects"?d.projects.length:U==="workflows"?d.workflows.length:d.deliverables.length;return s.jsxs("button",{"data-idx":Q,onClick:()=>{c(U),w(-1)},className:`mt-1 w-full text-xs py-1.5 rounded-lg transition-colors ${Q===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:"查看全部"})," (",ne,")"]})};return W==="agents"&&d.agents.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:agents",{defaultValue:"智能体"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.agents.slice(0,F):d.agents).map(U=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(me.TEAM,{agentId:U.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx(Us,{name:U.name||"Agent",avatarUrl:U.avatarUrl,size:28}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:U.name}),s.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:U.role||U.status})]}),s.jsx($W,{status:U.status})]},U.id)})}),F&&d.agents.length>F&&Z("agents")]},"agents"):W==="tasks"&&d.tasks.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:tasks",{defaultValue:"任务"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.tasks.slice(0,F):d.tasks).map(U=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(me.WORK,{openTask:U.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx(HW,{status:U.status}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:U.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[U.status," · ",U.priority||""]})]})]},U.id)})}),F&&d.tasks.length>F&&Z("tasks")]},"tasks"):W==="requirements"&&d.requirements.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:requirements",{defaultValue:"需求"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.requirements.slice(0,F):d.requirements).map(U=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(me.WORK,{openRequirement:U.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${U.status==="approved"?"text-green-500 bg-green-500/15":U.status==="pending"?"text-amber-500 bg-amber-500/15":U.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),s.jsx("polyline",{points:"14 2 14 8 20 8"}),s.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),s.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:U.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[U.status," · ",U.priority||""]})]})]},U.id)})}),F&&d.requirements.length>F&&Z("requirements")]},"requirements"):W==="projects"&&d.projects.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:projects",{defaultValue:"项目"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.projects.slice(0,F):d.projects).map(U=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(me.WORK,{projectId:U.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:s.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"})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:U.name}),U.description&&s.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:U.description})]})]},U.id)})}),F&&d.projects.length>F&&Z("projects")]},"projects"):W==="deliverables"&&d.deliverables.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:deliverables",{defaultValue:"交付物"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.deliverables.slice(0,F):d.deliverables).map(U=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(me.DELIVERABLES,{openDeliverable:U.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-purple-500/15 flex items-center justify-center shrink-0",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-purple-500",children:[s.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),s.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:U.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[U.type," · ",U.status]})]})]},U.id)})}),F&&d.deliverables.length>F&&Z("deliverables")]},"deliverables"):W==="workflows"&&d.workflows.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:workflows",{defaultValue:"工作流"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.workflows.slice(0,F):d.workflows).map(U=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(me.WORK,{boardType:"workflows"}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-teal-500/15 flex items-center justify-center shrink-0",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-teal-500",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.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"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:U.displayName||U.name}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[U.stepCount," steps · v",U.version]})]})]},U.name)})}),F&&d.workflows.length>F&&Z("workflows")]},"workflows"):null})}),!p&&!g&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[s.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:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),s.jsx("p",{className:"text-sm text-fg-tertiary",children:n("common:searchHint",{defaultValue:"输入关键词搜索"})})]})]}),s.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:[s.jsxs("span",{children:[s.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:"唤起/关闭"})]}),s.jsxs("span",{children:[s.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:"切换分类"})]}),s.jsxs("span",{children:[s.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:"导航"})]}),s.jsxs("span",{children:[s.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:"打开"})]}),s.jsxs("span",{children:[s.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 $W({status:e}){const t=e==="active"||e==="idle"?"bg-green-500":e==="working"||e==="busy"?"bg-blue-500":"bg-gray-400";return s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${t}`})}function HW({status:e}){const t=e==="completed"?"text-green-500 bg-green-500/15":e==="in_progress"?"text-blue-500 bg-blue-500/15":e==="pending"?"text-amber-500 bg-amber-500/15":"text-fg-tertiary bg-surface-elevated";return s.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${t}`,children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M9 11l3 3L22 4"}),s.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})})}function FW({authUser:e,onClose:t,onSaved:n,onUserUpdated:r}){const{t:o}=dt("common");zo(!0);const[l,c]=k.useState(e.name||""),[d,m]=k.useState(e.email||""),[p,h]=k.useState(!1),[g,x]=k.useState(""),[y,w]=k.useState(()=>h5(e.avatarUrl,sa()?.avatarUrl)),C=async T=>{if(T.preventDefault(),!l.trim()){x(o("profile.nameRequired"));return}if(d&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d.trim())){x(o("profile.invalidEmail"));return}h(!0),x("");try{const{user:S}=await Ce.auth.updateProfile(l.trim(),d.trim());n({...S,avatarUrl:y??S.avatarUrl})}catch{x(o("profile.failedToSave"))}finally{h(!1)}};return s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10000]",onClick:t,children:s.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:[s.jsx("h3",{className:"text-base font-semibold mb-5",children:o("profile.editProfile")}),s.jsx("div",{className:"flex justify-center mb-5",children:s.jsx(b5,{currentUrl:y,name:l,size:72,targetType:"user",targetId:e.id,onUploaded:T=>{w(T),r?.({...e,avatarUrl:T})}})}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:o("profile.name")}),s.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:o("profile.email")}),s.jsx("input",{value:d,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"})]}),g&&s.jsx("div",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:g})]}),s.jsxs("div",{className:"flex justify-end gap-3 mt-5",children:[s.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:o("cancel")}),s.jsx("button",{type:"submit",disabled:p,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white rounded-lg",children:o(p?"saving":"save")})]})]})})}const H4=k.lazy(()=>qr(()=>import("./Team-CpIDXpOi.js"),__vite__mapDeps([2,3,4])).then(e=>({default:e.TeamPage}))),F4=k.lazy(()=>qr(()=>import("./Settings-BzI3q_dx.js"),[]).then(e=>({default:e.Settings}))),qW=k.lazy(()=>qr(()=>import("./Store-DweBtEGf.js"),[]).then(e=>({default:e.StorePage}))),GW=k.lazy(()=>qr(()=>Promise.resolve().then(()=>lW),void 0).then(e=>({default:e.AgentBuilder}))),q4=k.lazy(()=>qr(()=>import("./Work-CMguHPuO.js"),__vite__mapDeps([5,4,1,6,3,7])).then(e=>({default:e.WorkPage}))),G4=k.lazy(()=>qr(()=>import("./Deliverables-Cfdx-Yeu.js"),__vite__mapDeps([8,4])).then(e=>({default:e.DeliverablesPage}))),VW=k.lazy(()=>qr(()=>import("./Notifications-CKTZO9fn.js"),[]).then(e=>({default:e.NotificationsPage}))),KW=k.lazy(()=>qr(()=>import("./Search-_yYhKio7.js"),[]).then(e=>({default:e.SearchPage}))),WW={visibility:"hidden",position:"absolute",inset:0,pointerEvents:"none",zIndex:-1};function YW(e){try{const t=navigator.language,n=Intl.DateTimeFormat().resolvedOptions().timeZone,r=e.preferences??{};if(r.locale===t&&r.timezone===n)return;Ce.auth.updatePreferences({locale:t,timezone:n}).catch(()=>{})}catch{}}function XW(){return s.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm animate-pulse",children:"Loading..."})}const QW=k.memo(function({id:t,activePage:n,children:r}){const o=t===n;return s.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",style:o?void 0:WW,children:s.jsx(k.Suspense,{fallback:s.jsx(XW,{}),children:r})})},(e,t)=>{const n=e.id===e.activePage,r=t.id===t.activePage;return n!==r?!1:r?e.children===t.children:!0}),Ed={};function W3(e){return typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches?o5[e]??e:e}function V4(){return W3(uc())}function ZW(){const{t:e}=dt("common"),[t,n]=k.useState(V4),[r,o]=k.useState(()=>!localStorage.getItem("markus_onboarded")),[l,c]=k.useState(!0),d=Bo(),m=PW(),p=LW({side:"left",defaultWidth:160,minWidth:140,maxWidth:400,collapsedWidth:64,storageKey:"markus_sidebar"}),[h,g]=k.useState(()=>new Set([V4()])),[x,y]=k.useState("loading"),[w,C]=k.useState(!1),[T,S]=k.useState(null),[_,j]=k.useState({hasOwner:!1,hasMultipleUsers:!1}),[O,P]=k.useState(!1),[D,$]=k.useState(!1),[X,ee]=k.useState(null),[H,K]=k.useState(!1),[ae,W]=k.useState(null),[F,Z]=k.useState(()=>{const be=localStorage.getItem("markus_update_dismissed");return be||null}),[U,Q]=k.useState(!1),ne=Ec(),ke=ne?.leftCollapsed??!1,B=ne?.toggleLeftCollapsed,q=ne?.toggleRightPanel,le=ne?.openRightPanel,I=ne?.closeRightPanelTab,Ae=ne?.updateRightPanelBrowserTab,$e=k.useRef(ne?.rightPanelTabs);$e.current=ne?.rightPanelTabs,k.useEffect(()=>{const be=window.markusDesktop?.browser?.onPageEvent;if(!(!be||!le))return be(Me=>{if(Me.type==="closed"){const qe=$e.current?.find(ot=>ot.payload.kind==="url"&&ot.payload.browserId===Me.browserId);qe&&I&&I(qe.id);return}if(Me.type==="navigated"){Me.browserId&&Ae&&Ae(Me.browserId,{url:Me.url,title:Me.title||Me.url});return}if(Me.type==="opened"||Me.type==="selected"){if(!Me.url&&!Me.browserId||Me.browserId.startsWith("eb_")||TG(Me.browserId))return;le({kind:"url",url:Me.url||"about:blank",title:Me.title||Me.url||"Browser",browserId:Me.browserId,pageId:Me.pageId})}})},[le,I,Ae]);const Oe=ne?.rightPanelOpen??!1;k.useLayoutEffect(()=>{const be=t===me.TEAM&&Oe;rp(be)},[t,Oe]),k.useEffect(()=>{window.markusDesktop?.browser?.hideAll?.()},[]);const We=k.useRef(!1);k.useEffect(()=>{if(!We.current){We.current=!0;return}p.setCollapsed(ke)},[ke,p.setCollapsed]),k.useEffect(()=>{if(d)return;const be=navigator.platform.toUpperCase().includes("MAC"),Me=ot=>{be&&ot.metaKey&&!ot.ctrlKey&&ot.key==="p"?(ot.preventDefault(),Q(ft=>!ft)):!be&&ot.ctrlKey&&!ot.metaKey&&ot.key==="p"&&(ot.preventDefault(),Q(ft=>!ft))},qe=()=>Q(!0);return document.addEventListener("keydown",Me),window.addEventListener("markus:open-search",qe),()=>{document.removeEventListener("keydown",Me),window.removeEventListener("markus:open-search",qe)}},[d]),k.useEffect(()=>{if(d||!B||!q)return;const be=navigator.platform.toUpperCase().includes("MAC"),Me=qe=>{if(!(be?qe.metaKey&&!qe.ctrlKey:qe.ctrlKey&&!qe.metaKey)||qe.altKey||qe.shiftKey)return;const ft=qe.key.toLowerCase();ft==="b"?(qe.preventDefault(),B()):ft==="l"&&(qe.preventDefault(),q())};return document.addEventListener("keydown",Me),()=>document.removeEventListener("keydown",Me)},[d,B,q]);const st=k.useCallback((be,Me)=>{let qe=cc(be);d?qe=o5[qe]??qe:qe===me.NOTIFICATIONS&&(qe=me.HOME),qe!==me.TEAM&&rp(!1);const ot=uc(),ft=window.location.hash.slice(1);if(ft!==lh(ot)?Ed[ot]=ft:delete Ed[ot],qe===me.SETTINGS&&Me?.tab){const Be=`settings/${Me.tab}`;Ed[qe]=Be,history.pushState(null,"","#"+Be),window.dispatchEvent(new HashChangeEvent("hashchange")),n(qe),g(Xe=>Xe.has(qe)?Xe:new Set([...Xe,qe]));return}const se=qe!==me.WORK?Ed[qe]:void 0;se&&se!==lh(qe)?(history.pushState(null,"",Ni(qe)),history.pushState(null,"","#"+se)):history.pushState(null,"",Ni(qe)),window.dispatchEvent(new HashChangeEvent("hashchange")),n(qe),g(Be=>Be.has(qe)?Be:new Set([...Be,qe]))},[d]);k.useEffect(()=>{at.setHandler((be,Me)=>st(be,Me))},[st]),k.useEffect(()=>{const be=()=>C(!0);return window.addEventListener("markus:open-edit-profile",be),()=>window.removeEventListener("markus:open-edit-profile",be)},[]),k.useEffect(()=>{if(!window.markusDesktop)return;!d&&t!==me.SETTINGS&&!p.collapsed?window.markusDesktop.setTrafficLightPosition(16,16):window.markusDesktop.setTrafficLightPosition(6,16)},[p.collapsed,t,d]),k.useEffect(()=>{window.markusDesktop&&window.markusDesktop.onNotificationClick(be=>{if(be.openNotifications&&window.dispatchEvent(new CustomEvent("markus:open-notifications")),be.page){const Me=cc(be.page);be.params&&Object.entries(be.params).forEach(([qe,ot])=>localStorage.setItem(`markus_nav_${qe}`,ot)),st(Me),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:Me,params:be.params}}))}})},[st]);const mt=k.useCallback(()=>{fetch("/api/settings/llm").then(be=>be.ok?be.json():null).then(be=>{if(be?.providers){const Me=Object.values(be.providers).some(qe=>qe.configured);ee(Me)}}).catch(()=>{})},[]),At=k.useCallback((be,Me)=>{if(!be)return;const ot=Me&&{agent:"agents",team:"teams",skill:"skills"}[Me]||"agents";localStorage.setItem("markus_nav_installItem",be),localStorage.setItem("markus_nav_storeTab",ot);const ft=new URLSearchParams(window.location.search);ft.get("install")||(ft.set("install",be),Me&&ft.set("type",Me));const se=ft.toString();window.history.replaceState(null,"",`${window.location.pathname}?${se}${Ni(me.STORE)}`);const Be=()=>at.navigate(me.STORE,{storeTab:ot,installItem:be});Be(),setTimeout(Be,500),setTimeout(Be,1500)},[]);k.useEffect(()=>{const be=new URLSearchParams(window.location.search),Me=be.get("install");Me&&At(Me,be.get("type"));const qe=window.markusDesktop;qe?.onDeepLinkInstall?.(({id:se,type:Be})=>At(se,Be)),qe?.consumePendingDeepLinkInstall?.().then(se=>{se?.id&&At(se.id,se.type)}),Ce.auth.me().then(({user:se})=>{y(se),S(!0),YW(se),va.connect(se.id),mt(),Ce.health().then(Xe=>{Xe.updateAvailable&&Xe.latestVersion&&W({latestVersion:Xe.latestVersion,currentVersion:Xe.version})}).catch(()=>{});const Be=()=>{hi(Tr.builderArtifacts,()=>Ce.builder.artifacts.list()),hi(Tr.builderAgents,()=>Ce.agents.list()),hi(Tr.builderHubMyItems,()=>it.myItems()),hi(Tr.builderInstalled,()=>Ce.builder.artifacts.installed()),hi(Tr.hubAgents,()=>it.search({type:"agent",limit:50})),hi(Tr.hubTeams,()=>it.search({type:"team",limit:50})),hi(Tr.hubSkills,()=>it.search({type:"skill",limit:50}))};typeof requestIdleCallback=="function"?requestIdleCallback(Be,{timeout:5e3}):setTimeout(Be,3e3)}).catch(()=>{y(null),Ce.auth.status().then(({initialized:se,hasOwner:Be,hasMultipleUsers:Xe})=>{S(se),j({hasOwner:Be,hasMultipleUsers:Xe})}).catch(()=>S(!0))}),va.connect();const ot=va.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),ft=()=>{const se=W3(uc());se!==me.TEAM&&rp(!1),n(se),g(Be=>Be.has(se)?Be:new Set([...Be,se]))};return window.addEventListener("hashchange",ft),window.addEventListener("popstate",ft),()=>{ot(),va.disconnect(),window.removeEventListener("hashchange",ft),window.removeEventListener("popstate",ft)}},[]);const gt=x!=="loading"&&x!==null?x:void 0,jt=k.useMemo(()=>d?{[me.HOME]:s.jsx(ev,{authUser:gt}),[me.TEAM]:s.jsx(H4,{authUser:gt}),[me.BUILDER]:s.jsx(_W,{authUser:gt}),[me.SETTINGS]:s.jsx(F4,{theme:m.mode,onThemeChange:m.setMode,authUser:gt,onLogout:()=>{Ce.auth.logout().catch(()=>{}),_o(),y(null)},onUserUpdated:be=>y(be)}),[me.WORK]:s.jsx(q4,{authUser:gt}),[me.DELIVERABLES]:s.jsx(G4,{authUser:gt}),[me.NOTIFICATIONS]:s.jsx(VW,{authUser:gt}),[me.SEARCH]:s.jsx(KW,{})}:{[me.HOME]:s.jsx(ev,{authUser:gt}),[me.TEAM]:s.jsx(H4,{authUser:gt}),[me.SETTINGS]:s.jsx(F4,{theme:m.mode,onThemeChange:m.setMode,authUser:gt,onLogout:()=>{Ce.auth.logout().catch(()=>{}),_o(),y(null)},onUserUpdated:be=>y(be)}),[me.STORE]:s.jsx(qW,{authUser:gt}),[me.BUILDER]:s.jsx(GW,{authUser:gt}),[me.WORK]:s.jsx(q4,{authUser:gt}),[me.DELIVERABLES]:s.jsx(G4,{authUser:gt})},[gt?.id,gt?.role,m.mode,d]);if(x==="loading"||x===null&&T===null)return s.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center",children:s.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:e("loading")})});const Rt=(typeof window<"u"?window.location.hash:"").match(/^#invite\?token=([a-f0-9]+)/);return Rt?s.jsx(OW,{token:Rt[1],onComplete:()=>{window.location.hash="",localStorage.removeItem("markus_onboarded"),o(!0),P(!0),y("loading"),Ce.auth.me().then(be=>y(be.user)).catch(()=>y(null))}}):x===null?s.jsx(RW,{hasOwner:_.hasOwner,hasMultipleUsers:_.hasMultipleUsers,onLogin:(be,Me,qe)=>{y(be),va.connect(be.id),Me?(localStorage.removeItem("markus_onboarded"),o(!0),qe?.fromHub&&P(!0)):localStorage.getItem("markus_onboarded")||(localStorage.setItem("markus_onboarded","1"),o(!1))}}):D?s.jsx(DW,{onComplete:()=>$(!1),isFirstTime:!0}):r?s.jsx(jW,{theme:m.mode,onThemeChange:m.setMode,skipProfile:O,onProfileUpdated:be=>{const Me={id:be.id,name:be.name,email:be.email,role:be.role,orgId:be.orgId??"default",avatarUrl:be.avatarUrl};y(Me)},onComplete:()=>{localStorage.setItem("markus_onboarded","1"),o(!1),P(!1),Ce.auth.me().then(be=>y(be.user)).catch(()=>{}),mt(),st(me.HOME)}}):s.jsxs("div",{className:`flex h-dvh bg-surface-primary text-fg-primary overflow-x-hidden ${d?"flex-col":""}`,children:[!d&&t!==me.SETTINGS&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"relative z-40 shrink-0",style:{width:p.width},children:s.jsx(LK,{currentPage:t,onNavigate:be=>{st(be),c(!1)},authUser:x,collapsed:p.collapsed,onToggleCollapse:p.toggle,onLogout:()=>{Ce.auth.logout().catch(()=>{}),_o(),y(null)}})}),s.jsx("div",{className:`${p.collapsed?"w-0":"w-1.5 cursor-col-resize"} shrink-0 group relative z-10 flex items-center justify-center`,onMouseDown:p.collapsed?void 0:p.onResizeStart,children:!p.collapsed&&s.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"})})]}),s.jsxs("div",{className:`flex-1 overflow-hidden flex flex-col min-w-0 ${d&&t!==me.SETTINGS&&t!==me.SEARCH?"pb-14":""}`,children:[X===!1&&!H&&t!==me.SETTINGS&&s.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:[s.jsx("span",{className:d?"text-xs":"",children:e("llmBanner.message")}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.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")}),s.jsx("button",{onClick:()=>K(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:e("dismiss")})]})]}),ae&&F!==ae.latestVersion&&s.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:[s.jsx("span",{className:d?"text-xs":"",children:e("update.available",{latest:ae.latestVersion,current:ae.currentVersion})}),s.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[s.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")}),s.jsx("button",{onClick:()=>{Z(ae.latestVersion),localStorage.setItem("markus_update_dismissed",ae.latestVersion)},className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]}),s.jsx("main",{className:"flex-1 overflow-hidden flex flex-col relative",children:Object.keys(jt).map(be=>h.has(be)?s.jsx(QW,{id:be,activePage:t,children:jt[be]},be):null)})]}),d&&t!==me.SETTINGS&&t!==me.SEARCH&&s.jsx(UK,{currentPage:t,onNavigate:st,userId:gt?.id}),d&&s.jsx(OD,{authUser:gt,onNavigate:st}),!d&&U&&s.jsx(UW,{onClose:()=>Q(!1),currentPage:t}),w&>&&s.jsx(FW,{authUser:gt,onClose:()=>C(!1),onUserUpdated:be=>y(be),onSaved:be=>{C(!1),y(be)}})]})}s7.createRoot(document.getElementById("root")).render(s.jsx(k.StrictMode,{children:s.jsx(EG,{children:s.jsx(ZW,{})})}));export{vK as $,Us as A,RD as B,LW as C,cc as D,Ig as E,wc as F,zo as G,Q7 as H,SW as I,dr as J,tY as K,nY as L,x5 as M,RK as N,Ai as O,me as P,Xd as Q,TY as R,wW as S,dW as T,xK as U,NV as V,Q2 as W,CV as X,aY as Y,cY as Z,qr as _,Bo as a,rY as a0,Ci as a1,Vo as a2,Ec as a3,hY as a4,BK as a5,EY as a6,yY as a7,oY as a8,pY as a9,T3 as aA,Ya as aa,wY as ab,MV as ac,vY as ad,kY as ae,jK as af,AK as ag,SY as ah,v0 as ai,J7 as aj,JW as ak,Ni as al,vD as am,E3 as an,lY as ao,i4 as ap,g4 as aq,uK as ar,cK as as,pc as at,_Y as au,eY as av,sa as aw,yn as ax,na as ay,iY as az,TW as b,pW as c,xW as d,Sa as e,Ce as f,mY as g,it as h,ki as i,s as j,TK as k,NY as l,bY as m,at as n,xY as o,gY as p,AY as q,k as r,zg as s,Er as t,dt as u,CY as v,va as w,fY as x,uY as y,dY as z};
|
|
670
|
+
prose-blockquote:border-brand-500/40 prose-blockquote:text-fg-secondary`,children:s.jsx(wh,{remarkPlugins:[Mw,Ok],rehypePlugins:[[s3,{detect:!0,ignoreMissing:!0}]],children:e})})}function Zp({filename:e,content:t,onSave:n,embedded:r,readOnly:o}){const{t:l}=dt(["builder","common"]),[c,d]=k.useState(!1),[m,p]=k.useState(t),[h,g]=k.useState(!1),x=/\.(md|mdx|markdown)$/i.test(e),y=k.useRef(null);k.useEffect(()=>{p(t)},[t]),k.useEffect(()=>{if(c&&y.current){const T=y.current;T.style.height="auto",T.style.height=Math.max(200,T.scrollHeight)+"px"}},[c,m]);const w=async()=>{g(!0),await n(m),g(!1),d(!1)},C=o?null:s.jsx("div",{className:"flex items-center gap-2",children:c?s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>{p(t),d(!1)},className:"text-[10px] px-2.5 py-1 rounded-md text-fg-tertiary hover:text-fg-secondary border border-border-default transition-colors",children:l("common:cancel")}),s.jsx("button",{onClick:w,disabled:h,className:"text-[10px] px-2.5 py-1 rounded-md bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50",children:l(h?"common:saving":"common:save")})]}):s.jsxs("button",{onClick:()=>d(!0),className:"text-[10px] px-2.5 py-1 rounded-md text-fg-tertiary hover:text-fg-secondary border border-border-default transition-colors inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),s.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),l("detail.edit")]})});return r?s.jsxs("div",{children:[s.jsx("div",{className:"flex items-center justify-end px-4 py-2 border-b border-border-default bg-surface-elevated/20",children:C}),c?s.jsx("textarea",{ref:y,value:m,onChange:T=>p(T.target.value),className:"w-full bg-surface-elevated/20 text-sm text-fg-primary font-mono p-4 focus:outline-none resize-y min-h-[200px] leading-relaxed",spellCheck:!1}):s.jsx("div",{className:"p-4",children:x?s.jsx(Wh,{content:t}):s.jsx("pre",{className:"text-xs leading-relaxed text-fg-secondary whitespace-pre-wrap font-mono",children:t})})]}):s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border-default bg-surface-elevated/30",children:[s.jsx("span",{className:"text-xs font-medium text-fg-secondary font-mono",children:e}),C]}),c?s.jsx("textarea",{ref:y,value:m,onChange:T=>p(T.target.value),className:"w-full bg-surface-elevated/20 text-sm text-fg-primary font-mono p-4 focus:outline-none resize-y min-h-[200px] leading-relaxed",spellCheck:!1}):s.jsx("div",{className:"p-4",children:x?s.jsx(Wh,{content:t}):s.jsx("pre",{className:"text-xs leading-relaxed text-fg-secondary whitespace-pre-wrap font-mono",children:t})})]})}const C4={"README.md":0,"ROLE.md":1,"HEARTBEAT.md":2,"POLICIES.md":3,"CONTEXT.md":4,"ANNOUNCEMENT.md":0,"NORMS.md":1};function YK(e){return[...e].sort(([t],[n])=>{const r=C4[t]??99,o=C4[n]??99;return r!==o?r-o:t.localeCompare(n)})}function g0({files:e,onSave:t,noHeader:n,readOnly:r}){const o=k.useMemo(()=>YK(e),[e]),[l,c]=k.useState(0);if(o.length===1)return n?s.jsx(Zp,{filename:o[0][0],content:o[0][1],onSave:h=>t(o[0][0],h),readOnly:r}):s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-4 uppercase tracking-wider",children:"Files"}),s.jsx(Zp,{filename:o[0][0],content:o[0][1],onSave:h=>t(o[0][0],h),readOnly:r})]});const[d,m]=o[l]??o[0],p=s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsx("div",{className:"flex items-center gap-0 overflow-x-auto bg-surface-elevated/30",children:o.map(([h],g)=>s.jsx("button",{onClick:()=>c(g),className:`px-4 py-2.5 text-xs font-medium whitespace-nowrap border-b-2 transition-colors ${g===l?"border-brand-500 text-brand-400 bg-surface-secondary/50":"border-transparent text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/50"}`,children:h},h))}),s.jsx(Zp,{filename:d,content:m,onSave:h=>t(d,h),embedded:!0,readOnly:r},d)]});return n?p:s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-4 uppercase tracking-wider",children:"Files"}),p]})}function XK({images:e,artifactType:t,artifactName:n,onUpload:r,onRemove:o,readOnly:l}){const{t:c}=dt(["builder"]),d=k.useRef(null);return e.length===0?l?null:s.jsxs("div",{className:"border-2 border-dashed border-border-default rounded-xl p-6 text-center text-fg-muted text-sm cursor-pointer hover:border-brand-500/30 transition-colors",onClick:()=>d.current?.click(),onDragOver:m=>m.preventDefault(),onDrop:m=>{m.preventDefault();const p=m.dataTransfer.files[0];p?.type.startsWith("image/")&&r(p)},children:[s.jsxs("svg",{className:"w-8 h-8 mx-auto mb-2 text-fg-muted/50",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),s.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),s.jsx("polyline",{points:"21 15 16 10 5 21"})]}),s.jsx("span",{className:"block",children:c("images.dropOrClick")}),s.jsx("span",{className:"block text-xs text-fg-muted/60 mt-1",children:c("images.hint")}),s.jsx("input",{ref:d,type:"file",accept:"image/*",className:"hidden",onChange:m=>{const p=m.target.files?.[0];p&&r(p),m.target.value=""}})]}):s.jsxs("div",{children:[s.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2",children:[e.map(m=>{const p=m.split("/").pop()??m;return s.jsxs("div",{className:"relative group shrink-0 rounded-lg border border-border-default overflow-hidden bg-surface-elevated",children:[s.jsx("img",{src:`/api/builder/artifacts/${t}s/${encodeURIComponent(n)}/images/${encodeURIComponent(p)}`,alt:p,className:"h-32 w-auto object-cover"}),!l&&s.jsx("button",{onClick:()=>o(p),className:"absolute top-1.5 right-1.5 w-5 h-5 rounded-full bg-red-600/80 text-white flex items-center justify-center text-[10px] opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]},m)}),!l&&s.jsx("button",{onClick:()=>d.current?.click(),className:"shrink-0 h-32 w-24 rounded-lg border-2 border-dashed border-border-default flex items-center justify-center text-fg-muted hover:border-brand-500/30 hover:text-brand-400 transition-colors",children:s.jsxs("svg",{className:"w-6 h-6",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),s.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]}),!l&&s.jsx("input",{ref:d,type:"file",accept:"image/*",className:"hidden",onChange:m=>{const p=m.target.files?.[0];p&&r(p),m.target.value=""}})]})}function QK({members:e,teamTopFiles:t,files:n,onFileSave:r,readOnly:o}){const{t:l}=dt(["builder"]),[c,d]=k.useState(0),m=k.useMemo(()=>{const C=new Set;for(const T of Object.keys(n)){const S=T.match(/^members\/([^/]+)\//);S&&C.add(S[1])}return[...C]},[n]),p=k.useMemo(()=>{const C=new Map,T=new Set;for(let j=0;j<e.length;j++){const O=Xd(e[j].name);m.includes(O)&&!T.has(O)&&(C.set(j,O),T.add(O))}for(let j=0;j<e.length;j++){if(C.has(j))continue;const O=e[j].roleName;if(O){const P=Xd(O);m.includes(P)&&!T.has(P)&&(C.set(j,P),T.add(P))}}for(let j=0;j<e.length;j++){if(C.has(j))continue;const O=e[j].name;for(const P of m){if(T.has(P))continue;const D=n[`members/${P}/ROLE.md`];if(!D)continue;const $=D.match(/^#\s+(.+)$/m)?.[1]?.trim();if($&&($.toLowerCase().includes(O.toLowerCase())||O.toLowerCase().includes($.toLowerCase()))){C.set(j,P),T.add(P);break}}}const S=m.filter(j=>!T.has(j));let _=0;for(let j=0;j<e.length;j++)C.has(j)||_<S.length&&(C.set(j,S[_]),_++);return C},[e,m,n]),h=k.useCallback((C,T)=>{const S=p.get(T);return S?Object.entries(n).filter(([_])=>_.startsWith(`members/${S}/`)):[]},[n,p]),g=k.useMemo(()=>{const C=[{label:l("detail.overview")}];for(const T of e)C.push({label:T.name,role:T.role});return C},[e,l]),x=c>0?e[c-1]:null,y=c-1;return s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsx("div",{className:"flex items-center gap-0 overflow-x-auto bg-surface-elevated/30 border-b border-border-default",children:g.map((C,T)=>{const S=T===c,_=C.role==="manager",j=T===0?S?"border-brand-500 text-brand-400":"border-transparent text-fg-tertiary hover:text-fg-secondary":_?S?"border-amber-500 text-amber-400":"border-transparent text-fg-tertiary hover:text-fg-secondary":S?"border-blue-500 text-blue-400":"border-transparent text-fg-tertiary hover:text-fg-secondary";return s.jsxs("button",{onClick:()=>d(T),className:`px-4 py-2.5 text-xs font-medium whitespace-nowrap border-b-2 transition-colors flex items-center gap-1.5 ${j} ${S?"bg-surface-secondary/50":"hover:bg-surface-elevated/50"}`,children:[T===0&&s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),s.jsx("polyline",{points:"9 22 9 12 15 12 15 22"})]}),T>0&&s.jsx("span",{className:`w-4 h-4 rounded-full text-[9px] font-bold flex items-center justify-center shrink-0 ${_?"bg-amber-500/20 text-amber-400":"bg-blue-500/20 text-blue-400"}`,children:(C.label[0]??"?").toUpperCase()}),C.label]},T)})}),s.jsx("div",{className:"p-5",children:c===0?s.jsxs("div",{className:"space-y-6",children:[t.length>0&&s.jsx(g0,{noHeader:!0,files:t,onSave:w,readOnly:o}),s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-3",children:l("sidebar.composition")}),s.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:e.map((C,T)=>{const S=C.role==="manager";return s.jsxs("button",{onClick:()=>d(T+1),className:"text-left rounded-lg border border-border-default bg-surface-elevated/30 px-4 py-3 flex gap-3 items-center hover:border-gray-600 transition-colors cursor-pointer",children:[s.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold shrink-0 ${S?"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:(C.name[0]??"?").toUpperCase()}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-xs font-medium text-fg-primary truncate",children:C.name}),s.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full font-medium ${S?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:C.role}),C.count>1&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["×",C.count]})]}),C.skills&&C.skills.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[C.skills.slice(0,3).map(_=>s.jsx("span",{className:"text-[9px] px-1.5 py-0.5 bg-surface-elevated text-fg-muted rounded border border-border-default",children:_},_)),C.skills.length>3&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",C.skills.length-3]})]})]}),s.jsx("svg",{className:"w-3.5 h-3.5 text-fg-muted shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"9 18 15 12 9 6"})})]},T)})})]})]}):x?s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:`w-12 h-12 rounded-full flex items-center justify-center text-lg font-bold shrink-0 ${x.role==="manager"?"bg-amber-500/15 text-amber-400 ring-2 ring-amber-500/30":"bg-blue-500/15 text-blue-400 ring-2 ring-blue-500/30"}`,children:(x.name[0]??"?").toUpperCase()}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"text-sm font-semibold text-fg-primary",children:x.name}),s.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full font-medium ${x.role==="manager"?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:x.role}),x.count>1&&s.jsxs("span",{className:"text-[10px] text-fg-muted",children:["×",x.count]})]}),x.roleName&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5 italic",children:x.roleName})]})]}),x.skills&&x.skills.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5",children:x.skills.map(C=>s.jsx("span",{className:"text-[10px] px-2.5 py-1 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:C},C))}),(()=>{const C=h(x.name,y);return C.length===0?s.jsx("p",{className:"text-xs text-fg-muted italic",children:"No files for this member yet."}):s.jsx(g0,{noHeader:!0,readOnly:o,files:C.map(([T,S])=>[T.replace(/^members\/[^/]+\//,""),S]),onSave:(T,S)=>{const _=C.find(([j])=>j.endsWith(`/${T}`));_&&r(_[0],S)}})})()]}):null})]});function w(C,T){r(C,T)}}function _i({type:e,name:t,onBack:n,authUser:r,readOnly:o,initialManifest:l,actionSlot:c,contentSlot:d}){const{t:m}=dt(["builder","common"]),p=Bo(),[h,g]=k.useState(!0),[x,y]=k.useState(t),[w,C]=k.useState({}),[T,S]=k.useState(null),[_,j]=k.useState(""),[O,P]=k.useState("idle"),[D,$]=k.useState({shared:!1}),[X,ee]=k.useState(!1),[H,K]=k.useState(!1),[ae,W]=k.useState(!1),[F,Z]=k.useState(!1),[U,Q]=k.useState(!1),[ne,ke]=k.useState(!1),[B,q]=k.useState(null),[le,I]=k.useState(""),[Ae,$e]=k.useState(""),[Oe,We]=k.useState(""),[st,mt]=k.useState(""),[At,gt]=k.useState([]),[jt,Jt]=k.useState(""),Rt=k.useRef(null),be=k.useRef(l);be.current=l,k.useEffect(()=>{y(t)},[t]);const Me=k.useCallback(async()=>{const pe=be.current;if(pe){S(pe),I(pe.displayName||pe.name||t),$e(pe.description||""),We(pe.version||"1.0.0"),mt(pe.category||"general"),gt(pe.tags||[]),Jt(pe.icon||""),C(pe.files??{}),g(!1);return}g(!0);try{let ve=t;try{const xt=await Ce.builder.artifacts.ensureSlugSafe(e,t);ve=xt.name,y(ve),xt.converted&&(history.replaceState(null,"",Ni(me.BUILDER,`${e}/${encodeURIComponent(ve)}`)),window.dispatchEvent(new CustomEvent("markus:data-changed")))}catch{y(t)}const Ye=await Ce.builder.artifacts.get(e,ve);C(Ye.files??{}),j(Ye.path??"");const nt=Ye.files[`${e}.json`]??Ye.files["agent.json"]??Ye.files["team.json"]??Ye.files["skill.json"];if(nt){const xt=JSON.parse(nt);S(xt),I(xt.displayName||xt.name||t),$e(xt.description||""),We(xt.version||"1.0.0"),mt(xt.category||"general"),gt(xt.tags||[]),Jt(xt.icon||"")}}catch(ve){console.error("Failed to load artifact:",ve)}finally{g(!1)}},[e,t]);k.useEffect(()=>{Me()},[Me]),k.useEffect(()=>{l?.files&&C(l.files)},[l?.files]),k.useEffect(()=>{if(!o){try{const pe=localStorage.getItem("markus_builder_shared_map");if(pe){const ve=JSON.parse(pe),Ye=`${e}/${t}`;ve[Ye]&&$({shared:!0,id:ve[Ye].id,slug:ve[Ye].slug,version:ve[Ye].version,visibility:ve[Ye].visibility??"public"})}}catch{}it.myItems().then(pe=>{const ve=pe?.items??[],Ye=e==="agent"?"agent":e==="team"?"team":"skill";for(const nt of ve)if(nt.itemType===Ye&&(nt.slug===t||nt.name===t)){$({shared:!0,id:nt.id,slug:nt.slug,version:nt.version,visibility:nt.visibility??"public",moderationStatus:nt.moderationStatus,pendingReview:nt.pendingReview});return}}).catch(()=>{})}},[e,t,o]);const qe=k.useCallback(async pe=>{if(!(!T||o)){P("saving");try{const ve={...T,...pe};await Ce.builder.artifacts.save(e,ve),S(ve),P("saved"),setTimeout(()=>P(Ye=>Ye==="saved"?"idle":Ye),2e3)}catch{P("error"),setTimeout(()=>P("idle"),3e3)}}},[T,e]),ot=k.useCallback(pe=>{Rt.current&&clearTimeout(Rt.current),Rt.current=setTimeout(()=>qe(pe),800)},[qe]),ft=k.useCallback((pe,ve)=>{const Ye={};pe==="displayName"?(I(ve),Ye.displayName=ve,K(!0)):pe==="description"?($e(ve),Ye.description=ve,K(!0)):pe==="version"?(We(ve),Ye.version=ve,K(!1),W(!1)):pe==="category"?(mt(ve),Ye.category=ve,K(!0)):pe==="tags"?(gt(ve),Ye.tags=ve,K(!0)):pe==="icon"&&(Jt(ve),Ye.icon=ve||void 0,K(!0)),ot({...T,...Ye})},[T,ot]),se=k.useCallback(async(pe,ve)=>{try{const Ye={...w,[pe]:ve};C(Ye);const nt={...T,files:Ye};await Ce.builder.artifacts.save(e,nt),P("saved"),K(!0),setTimeout(()=>P(xt=>xt==="saved"?"idle":xt),2e3)}catch{P("error")}},[w,e,T]),Be=k.useCallback(async pe=>{if(T){ee(!0);try{await it.ensureAuth();const ve=await Ce.builder.artifacts.ensureSlugSafe(e,x,T.displayName||T.name||x),Ye=ve.name,nt=ve.slug||fc(Ye);if(!nt)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 xt=ve.displayName||T.displayName||T.name||x;ve.converted&&(y(Ye),S(ie=>ie&&{...ie,name:nt,displayName:xt}),history.replaceState(null,"",Ni(me.BUILDER,`${e}/${encodeURIComponent(Ye)}`)),window.dispatchEvent(new CustomEvent("markus:data-changed")));const Dt={...T,name:nt,displayName:xt},ct=Dt.description||"",Xt=Dt.category||"general",R=Dt.tags??[];let oe=Dt.icon||void 0;const _e=Dt.version||"1.0.0";if(oe&&!oe.startsWith("http")&&/\.(png|jpe?g|gif|webp|svg)$/i.test(oe)){const ie=oe.split("/").pop()??oe;try{const Ne=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(Ye)}/images/${encodeURIComponent(ie)}`);if(Ne.ok){const Le=await Ne.blob(),Je=new File([Le],ie,{type:Le.type}),vt=await it.uploadImage(Je);vt?.url&&(oe=vt.url)}}catch{}}let de;const Pe=[],Ve=Dt.screenshots??[];for(let ie=0;ie<Ve.length;ie++){const Ne=Ve[ie],Le=Ne.split("/").pop()??Ne;try{const Je=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(Ye)}/images/${encodeURIComponent(Le)}`);if(Je.ok){const vt=await Je.blob(),Ie=new File([vt],Le,{type:vt.type}),tt=await it.uploadImage(Ie);tt?.url&&(Pe.push({url:tt.url,alt:Le,order:ie}),ie===0&&(de=tt.url))}}catch{}}const G=await it.publishViaProxy({itemType:e==="team"?"team":e==="skill"?"skill":"agent",name:xt,slug:nt,description:ct,category:Xt,tags:R,icon:oe,version:_e,config:Dt,files:Object.keys(w).length>0?w:void 0,thumbnailUrl:de,images:Pe.length>0?Pe:void 0,priceCents:pe?.priceCents,donationsEnabled:pe?.donationsEnabled,visibility:pe?.visibility,orgId:pe?.orgId});G.id&&($({shared:!0,id:G.id,slug:G.slug??nt,version:_e,visibility:G.visibility??pe?.visibility??"public",moderationStatus:G.moderationStatus,pendingReview:G.pendingReview}),K(!1),(G.visibility??pe?.visibility??"public")!=="org"&&(G.moderationStatus==="pending"||G.pendingReview)?q({title:m("common:share"),message:ve.converted?m("share.convertedAndSubmitted",{previous:t,slug:nt}):G.updated?m("share.updateSubmitted"):m("share.submittedForReview"),variant:"primary"}):ve.converted&&q({title:m("common:share"),message:m("share.convertedSlug",{previous:t,slug:nt}),variant:"primary"}))}catch(ve){console.error("Share to Hub failed:",ve),q({title:m("common:share"),message:ve instanceof Error?ve.message:String(ve),variant:"danger"})}finally{ee(!1)}}},[T,w,e,t,x,m]),Xe=async pe=>{const ve=new FormData;ve.append("image",pe);try{await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images`,{method:"POST",body:ve,credentials:"include"}),await Me(),K(!0)}catch(Ye){console.error("Image upload failed:",Ye)}},Ge=async pe=>{try{await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images/${encodeURIComponent(pe)}`,{method:"DELETE",credentials:"include"}),await Me(),K(!0)}catch(ve){console.error("Image remove failed:",ve)}},et=N4[e]??N4.agent,yt=T?.screenshots??[],he=T?.skill?.skillFile?w[T.skill.skillFile]:w["SKILL.md"]??w["README.md"],V=k.useMemo(()=>e!=="agent"?[]:Object.entries(w).filter(([pe])=>!pe.endsWith(".json")&&!pe.startsWith("images/")&&!pe.startsWith("members/")),[w,e]),ye=k.useMemo(()=>e!=="team"?[]:Object.entries(w).filter(([pe])=>!pe.endsWith(".json")&&!pe.startsWith("images/")&&!pe.startsWith("members/")),[w,e]),Qe=k.useMemo(()=>{if(e==="agent"||e==="team")return[];const pe=new Set;if(e==="skill"){const ve=T?.skill?.skillFile;ve&&w[ve]&&pe.add(ve),!ve&&w["SKILL.md"]&&pe.add("SKILL.md"),!ve&&!w["SKILL.md"]&&w["README.md"]&&pe.add("README.md")}return Object.entries(w).filter(([ve])=>!ve.endsWith(".json")&&!ve.startsWith("images/")&&!ve.startsWith("members/")&&!pe.has(ve))},[w,e,T?.skill?.skillFile]);return h?s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:"px-6 py-8",children:[s.jsxs("button",{onClick:n,className:"text-xs text-brand-400 hover:text-brand-300 mb-4 inline-flex items-center gap-1",children:[s.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:s.jsx("polyline",{points:"15 18 9 12 15 6"})}),m("detail.backToBuilder")]}),s.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse py-20 text-center",children:m("common:loading")})]})}):T?s.jsxs("div",{className:"flex-1 overflow-y-auto",children:[s.jsxs("div",{className:`${p?"px-4 py-5":"px-6 py-8"}`,children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("button",{onClick:n,className:"text-xs text-brand-400 hover:text-brand-300 inline-flex items-center gap-1",children:[s.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:s.jsx("polyline",{points:"15 18 9 12 15 6"})}),m(o?"common:back":"detail.backToBuilder")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[!o&&O==="saving"&&s.jsx("span",{className:"text-[10px] text-fg-muted animate-pulse",children:m("detail.saving")}),!o&&O==="saved"&&s.jsxs("span",{className:"text-[10px] text-green-500 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})}),m("detail.saved")]}),!o&&O==="error"&&s.jsx("span",{className:"text-[10px] text-red-500",children:m("detail.saveFailed")}),c,!o&&D.shared&&(()=>{const pe=it.getUser(),ve=pe&&D.slug?`${it.getUrl()}/@${encodeURIComponent(pe.username)}/${encodeURIComponent(D.slug)}`:null,Ye=Oe||T?.version||"1.0.0",nt=D.version!==Ye;return s.jsxs(s.Fragment,{children:[D.moderationStatus==="pending"?s.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.underReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),m("share.underReview")]}):D.moderationStatus==="rejected"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-red-500/30 text-red-400 inline-flex items-center gap-1",title:m("share.rejectedTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),s.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),m("share.rejected")]}):D.pendingReview?s.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:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),m("share.updateUnderReview")]}):null,ve&&s.jsxs("a",{href:ve,target:"_blank",rel:"noopener noreferrer",onClick:xt=>{pc()&&(xt.preventDefault(),Ai(ve))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1.5 ${D.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/50":D.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:[D.visibility==="org"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}):D.visibility==="unlisted"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.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"}),s.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"})]}):s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),D.visibility==="org"?m("visibility.sharedOrg"):D.visibility==="unlisted"?m("visibility.sharedUnlisted"):m("share.viewOnHub")]}),nt&&s.jsx("button",{onClick:()=>{Be({visibility:D.visibility})},disabled:X,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:X?m("share.updating"):m("share.updateVersion",{version:Ye})})]})})(),!o&&!D.shared&&s.jsx("button",{onClick:()=>Q(!0),disabled:X,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50",children:m(X?"share.sharing":"share.toHub")})]})]}),!o&&H&&!ae&&s.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:[s.jsx("span",{className:"text-xs text-amber-800 dark:text-amber-300",children:m("versionBump.contentModified")}),s.jsx("button",{onClick:()=>W(!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")})]}),!o&&ae&&s.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:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-xs text-amber-800 dark:text-amber-300",children:m("versionBump.newVersion")}),s.jsx("input",{type:"text",defaultValue:(()=>{const pe=(Oe||"1.0.0").split(".");return pe[2]=String(Number(pe[2]??0)+1),pe.join(".")})(),className:"text-xs px-2 py-1 rounded bg-surface-elevated border border-border-default text-fg-primary w-24 font-mono",onKeyDown:pe=>{pe.key==="Enter"&&ft("version",pe.target.value)}}),s.jsx("button",{onClick:pe=>{const ve=pe.target.parentElement?.querySelector("input");ve&&ft("version",ve.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")}),s.jsx("button",{onClick:()=>W(!1),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:m("common:cancel")})]}),D.shared&&s.jsx("p",{className:"text-[10px] text-fg-tertiary mt-2",children:"After bumping the version, you can share the new version to Hub."})]}),s.jsxs("div",{className:`flex gap-8 ${p?"flex-col":""}`,children:[s.jsxs("div",{className:`${p?"w-full":"flex-1 min-w-0"}`,children:[s.jsxs("div",{className:"flex items-start gap-4 mb-6",children:[s.jsxs("div",{className:"relative",children:[s.jsx("div",{onClick:()=>!o&&ke(!ne),className:`w-16 h-16 rounded-xl ${et.bg} flex items-center justify-center text-3xl shrink-0 ${o?"":"cursor-pointer hover:ring-2"} ${et.ring} transition-all overflow-hidden`,children:jt&&jt.startsWith("images/")?s.jsx("img",{src:`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images/${encodeURIComponent(jt.replace("images/",""))}`,alt:"",className:"w-full h-full object-cover"}):jt&&(jt.startsWith("http")||jt.startsWith("/"))?s.jsx("img",{src:jt,alt:"",className:"w-full h-full object-cover"}):(()=>{const pe=jt||"";if(pe&&[...pe].length<=2&&new RegExp("\\p{Emoji}","u").test(pe))return pe;const Ye=Ti[Ko(e)].accent;return s.jsx("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:s.jsx("path",{d:U3(le||t||e),fill:Ye})})})()}),!o&&ne&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>ke(!1)}),s.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:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.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:jt,onKeyDown:pe=>{pe.key==="Enter"&&(ft("icon",pe.target.value),ke(!1))}}),s.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"),s.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:async pe=>{const ve=pe.target.files?.[0];if(!ve)return;const Ye=new FormData;Ye.append("image",ve);try{const nt=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images`,{method:"POST",body:Ye,credentials:"include"});if(nt.ok){const Dt=(await nt.json()).path;if(Jt(Dt),ke(!1),T){const ct={...T,icon:Dt};S(ct),await Ce.builder.artifacts.save(e,ct)}K(!0)}}catch{}}})]}),jt&&s.jsx("button",{onClick:()=>{ft("icon",""),ke(!1)},className:"text-[10px] text-fg-tertiary hover:text-red-400 px-1",children:"✕"})]}),s.jsx("div",{className:"max-h-64 overflow-y-auto",children:GK.map(pe=>s.jsxs("div",{className:"mb-2.5",children:[s.jsx("div",{className:"text-[10px] text-fg-tertiary mb-1 sticky top-0 bg-surface-secondary py-0.5",children:pe.label}),s.jsx("div",{className:"flex flex-wrap gap-0.5",children:pe.emojis.map(ve=>s.jsx("button",{onClick:()=>{ft("icon",ve),ke(!1)},className:`w-7 h-7 rounded flex items-center justify-center text-base hover:bg-surface-elevated transition-colors ${jt===ve?"ring-1.5 ring-brand-500 bg-brand-500/10":""}`,children:ve},ve))})]},pe.label))})]})]})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx(Qp,{value:le,onChange:pe=>ft("displayName",pe),renderAs:"h1",className:"text-xl font-bold text-fg-primary",placeholder:m("detail.untitled"),readOnly:o}),s.jsx("span",{className:`text-[10px] font-medium uppercase tracking-wider px-2 py-0.5 rounded-full ${et.bg} ${et.color}`,children:et.label}),s.jsx(Qp,{value:Oe,onChange:pe=>ft("version",pe),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:o})]}),s.jsx(Qp,{value:Ae,onChange:pe=>ft("description",pe),renderAs:"p",className:"text-sm text-fg-secondary mt-1.5 leading-relaxed",placeholder:m("detail.addDescription"),multiline:!0,readOnly:o}),s.jsxs("div",{className:"flex items-center gap-2 mt-2 flex-wrap",children:[s.jsx(KK,{value:st,options:qK,onChange:pe=>ft("category",pe),className:"text-xs px-2 py-0.5 rounded bg-surface-elevated text-fg-tertiary",readOnly:o}),s.jsx(WK,{tags:At,onChange:pe=>ft("tags",pe),readOnly:o})]})]})]}),s.jsx("div",{className:"mb-8",children:s.jsx(XK,{images:yt,artifactType:e,artifactName:t,onUpload:Xe,onRemove:Ge,readOnly:o})}),d&&s.jsx("div",{className:"mb-8",children:d}),e==="team"&&T.team&&s.jsx("div",{className:"mb-8",children:s.jsx(QK,{members:T.team.members,teamTopFiles:ye,files:w,onFileSave:se,readOnly:o})}),e==="agent"&&V.length>0&&s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-4 uppercase tracking-wider",children:"About This Agent"}),s.jsx(g0,{noHeader:!0,files:V,onSave:se,readOnly:o})]}),e==="skill"&&s.jsxs("div",{className:"mb-8",children:[T.skill?.requiredPermissions&&T.skill.requiredPermissions.length>0&&s.jsxs("div",{className:"mb-6",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:m("sidebar.permissions")}),s.jsx("div",{className:"flex flex-wrap gap-2",children:T.skill.requiredPermissions.map(pe=>{const ve=VK[pe];return s.jsxs("span",{className:`inline-flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg border font-medium ${ve?.color??"bg-surface-elevated text-fg-secondary border-border-default"}`,children:[s.jsx("span",{className:"font-mono text-[10px]",children:ve?.icon??"?"})," ",pe]},pe)})})]}),T.skill?.mcpServers&&Object.keys(T.skill.mcpServers).length>0&&s.jsxs("div",{className:"mb-6",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:"Integrations"}),s.jsx("div",{className:"grid gap-2",children:Object.entries(T.skill.mcpServers).map(([pe,ve])=>s.jsxs("div",{className:"rounded-lg border border-border-default bg-surface-secondary/40 px-4 py-3 flex items-center gap-3",children:[s.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:"◎"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs font-medium text-fg-primary",children:pe}),s.jsx("div",{className:"text-[10px] text-fg-muted font-mono truncate",children:typeof ve=="object"?JSON.stringify(ve).slice(0,80):String(ve)})]})]},pe))})]}),he&&s.jsxs("div",{children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:"Instructions"}),s.jsx("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:s.jsx(Wh,{content:he})})]})]}),Qe.length>0&&s.jsx(g0,{files:Qe,onSave:se,readOnly:o})]}),s.jsx("div",{className:`${p?"w-full":"w-72 shrink-0"}`,children:s.jsxs("div",{className:`${p?"":"sticky top-6"} space-y-4`,children:[s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.info")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.type")}),s.jsx("span",{className:`font-medium ${et.color}`,children:et.label})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.category")}),s.jsx("span",{className:"text-fg-secondary",children:st})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.version")}),s.jsx("span",{className:"text-fg-secondary font-mono",children:Oe})]}),T.author&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.author")}),s.jsx("span",{className:"text-fg-secondary",children:typeof T.author=="string"?T.author:T.author?.name??""})]})]})]}),e==="agent"&&T.agent&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.agentSpecs")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[T.agent.roleName&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.role")}),s.jsx("span",{className:"text-fg-secondary",children:T.agent.roleName})]}),T.agent.llmProvider&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.provider")}),s.jsx("span",{className:"text-fg-secondary",children:T.agent.llmProvider})]}),T.agent.llmModel&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.model")}),s.jsx("span",{className:"text-fg-secondary font-mono",children:T.agent.llmModel})]}),T.agent.temperature!==void 0&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.temperature")}),s.jsx("span",{className:"text-fg-secondary",children:T.agent.temperature})]})]})]}),e==="team"&&T.team&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.composition")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.totalMembers")}),s.jsx("span",{className:"text-fg-secondary",children:T.team.members.reduce((pe,ve)=>pe+ve.count,0)})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.managers")}),s.jsx("span",{className:"text-amber-400",children:T.team.members.filter(pe=>pe.role==="manager").reduce((pe,ve)=>pe+ve.count,0)})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.workers")}),s.jsx("span",{className:"text-blue-400",children:T.team.members.filter(pe=>pe.role!=="manager").reduce((pe,ve)=>pe+ve.count,0)})]})]})]}),e==="skill"&&T.skill&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.skillInfo")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[T.skill.alwaysOn!==void 0&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.alwaysOn")}),s.jsx("span",{className:T.skill.alwaysOn?"text-green-400":"text-fg-secondary",children:T.skill.alwaysOn?m("sidebar.yes"):m("sidebar.no")})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.skillFile")}),s.jsx("span",{className:"text-fg-secondary font-mono truncate ml-2",children:T.skill.skillFile})]}),T.skill.requiredPermissions&&T.skill.requiredPermissions.length>0&&s.jsxs("div",{children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.permissions")}),s.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:T.skill.requiredPermissions.map(pe=>s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-elevated text-fg-muted rounded border border-border-default",children:pe},pe))})]})]})]}),T.dependencies&&(T.dependencies.skills?.length||T.dependencies.env?.length)?s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.dependencies")}),T.dependencies.skills?.length?s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-fg-muted mb-1",children:m("sidebar.skills")}),s.jsx("div",{className:"flex flex-wrap gap-1",children:T.dependencies.skills.map(pe=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-secondary rounded border border-border-default",children:pe},pe))})]}):null,T.dependencies.env?.length?s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-fg-muted mb-1",children:m("sidebar.environment")}),s.jsx("div",{className:"flex flex-wrap gap-1",children:T.dependencies.env.map(pe=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-secondary rounded font-mono border border-border-default",children:pe},pe))})]}):null]}):null,!o&&_&&s.jsxs("button",{onClick:()=>Ce.system.openPath(_).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:_,children:[s.jsx("span",{className:"text-fg-tertiary block mb-0.5",children:m("sidebar.openInFinder")}),_.replace(/.*\.markus\//,"~/.markus/")]})]})})]})]}),!o&&F&&s.jsx(JK,{onClose:()=>Z(!1),onConfirm:(pe,ve)=>{Z(!1),Be({donationsEnabled:!1,priceCents:pe==="paid"?ve:void 0})},isUpdate:D.shared}),!o&&U&&s.jsx(ZK,{onClose:()=>Q(!1),onConfirm:(pe,ve,Ye,nt)=>{Q(!1),Be({visibility:pe,orgId:ve,priceCents:Ye,donationsEnabled:nt})}}),B&&s.jsx(dr,{alertOnly:!0,variant:B.variant??"primary",title:B.title,message:B.message,onConfirm:()=>q(null),onCancel:()=>q(null)})]}):s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:"px-6 py-8",children:[s.jsxs("button",{onClick:n,className:"text-xs text-brand-400 hover:text-brand-300 mb-4 inline-flex items-center gap-1",children:[s.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:s.jsx("polyline",{points:"15 18 9 12 15 6"})}),m("detail.backToBuilder")]}),s.jsx("div",{className:"text-fg-tertiary text-sm py-20 text-center",children:m("detail.notFound")})]})})}function ZK({onClose:e,onConfirm:t}){const{t:n}=dt(["builder","common"]),[r,o]=k.useState("public"),[l,c]=k.useState([]),[d,m]=k.useState(""),[p,h]=k.useState(!1),[g,x]=k.useState(0),[y,w]=k.useState(!1);k.useEffect(()=>{r==="org"&&l.length===0&&(h(!0),it.myOrgs().then(S=>{c(S.memberships),S.memberships.length>0&&m(S.memberships[0].id)}).catch(()=>{}).finally(()=>h(!1)))},[r,l.length]);const C=r==="public"||r==="unlisted",T=[{value:"public",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),s.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:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.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:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.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"}),s.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 s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:e,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:S=>S.stopPropagation(),children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-1",children:n("visibility.label")}),s.jsx("p",{className:"text-[11px] text-fg-tertiary mb-4 leading-relaxed",children:n("visibility.subtitle")}),s.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-fg-tertiary font-semibold mb-2",children:["1 · ",n("visibility.public")," / ",n("visibility.org")]}),s.jsx("div",{className:"space-y-2 mb-5",children:T.map(S=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${r===S.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"visibility",checked:r===S.value,onChange:()=>o(S.value),className:"accent-brand-500"}),s.jsx("div",{className:"flex items-center gap-2 text-fg-secondary",children:S.icon}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:S.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:S.desc})]})]},S.value))}),r==="org"&&s.jsxs("div",{className:"mb-5",children:[s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("visibility.orgSelect")}),p?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:"Loading..."}):l.length===0?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:n("visibility.orgNone")}):s.jsx("select",{value:d,onChange:S=>m(S.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(S=>s.jsx("option",{value:S.id,children:S.name},S.id))})]}),C&&s.jsxs("div",{className:"mb-5",children:[s.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-fg-tertiary font-semibold mb-2",children:["2 · ",n("pricing.label")]}),s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("pricing.label")}),s.jsx("div",{className:"grid grid-cols-4 gap-2 mb-3",children:H3.map(S=>s.jsx("button",{type:"button",onClick:()=>x(S.cents),className:`text-sm px-2 py-2 rounded-lg border transition-colors ${g===S.cents?"border-brand-500 bg-brand-500/10 text-fg-primary":"border-border-default text-fg-secondary hover:border-gray-600"}`,children:S.label},S.cents))}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:y,onChange:S=>w(S.target.checked),className:"accent-brand-500"}),s.jsx("span",{className:"text-xs text-fg-secondary",children:n("pricing.enableTips")})]})]}),C&&s.jsx("div",{className:"mb-4 text-[11px] text-fg-tertiary rounded-lg border border-border-default px-3 py-2",children:n("pricing.reviewNote")}),s.jsxs("div",{className:"flex gap-3",children:[s.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")}),s.jsx("button",{onClick:()=>t(r,r==="org"?d:void 0,C&&g>0?g:void 0,C?y:void 0),disabled:r==="org"&&!d,className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n("shareMode.share")})]})]})})}const H3=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function JK({onClose:e,onConfirm:t,isUpdate:n}){const{t:r}=dt(["builder","common"]),[o,l]=k.useState(0);return s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:e,children:s.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:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:r(n?"shareMode.titleUpdate":"share.toHub")}),s.jsx("div",{className:"space-y-2 mb-5",children:H3.map(c=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${o===c.cents?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"sharePrice",checked:o===c.cents,onChange:()=>l(c.cents),className:"accent-brand-500"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:c.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:c.cents===0?r("shareMode.freeDesc"):r("shareMode.paidDesc")})]})]},c.cents))}),s.jsxs("div",{className:"flex gap-3",children:[s.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:r("common:cancel")}),s.jsx("button",{onClick:()=>t(o>0?"paid":"free",o),className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:r(n?"shareMode.update":"shareMode.share")})]})]})})}function b0(e,t){return!e||!$3(e)?null:e.startsWith("http")||e.startsWith("data:")?e:e.startsWith("/")&&t?`${t}${e}`:e}function eW({type:e,seed:t,icon:n,hubBase:r,size:o=44,className:l="",rounded:c="rounded-xl"}){const d=Ko(e),m=b0(n,r),p=k.useMemo(()=>Bg(d,t),[d,t]),h=k.useMemo(()=>U3(t),[t]),[g,x]=k.useState(!1);return m&&!g?s.jsx("img",{src:m,alt:"",onError:()=>x(!0),style:{width:o,height:o},className:`${c} object-cover shrink-0 ${l}`}):HK(n)?s.jsx("div",{style:{width:o,height:o,background:p,fontSize:o*.5},className:`${c} shrink-0 flex items-center justify-center shadow-inner ${l}`,children:s.jsx("span",{className:"drop-shadow-sm",children:n})}):n&&JV(n)?s.jsx("div",{style:{width:o,height:o,background:p},className:`${c} shrink-0 flex items-center justify-center text-white shadow-inner ${l}`,children:s.jsx(Vo,{name:n,size:o*.52,className:"drop-shadow-sm"})}):s.jsx("div",{style:{width:o,height:o,background:p},className:`${c} shrink-0 flex items-center justify-center shadow-inner ${l}`,children:s.jsx("svg",{width:o*.55,height:o*.55,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:s.jsx("path",{d:h,fill:"rgba(255,255,255,0.92)"})})})}function x0({name:e,username:t,avatarUrl:n,hubBase:r,size:o=24,className:l="",verified:c}){const d=t||e||"markus",m=b0(n,r),[p,h]=k.useState(!1),g=m&&!p?m:FK(d);return s.jsxs("span",{className:`relative inline-flex shrink-0 ${l}`,style:{width:o,height:o},children:[s.jsx("img",{src:g,alt:e||t||"",onError:()=>h(!0),className:"w-full h-full rounded-full object-cover ring-1 ring-white/10 bg-surface-elevated"}),c&&s.jsx("span",{className:"absolute -right-0.5 -bottom-0.5 flex items-center justify-center rounded-full bg-brand-500 ring-2 ring-surface-primary",style:{width:o*.42,height:o*.42},children:s.jsx("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%",fill:"white","aria-hidden":!0,children:s.jsx("path",{d:"M9 16.2l-3.5-3.5 1.4-1.4L9 13.4l7.1-7.1 1.4 1.4z"})})})]})}function tW({type:e,className:t=""}){const n=Ko(e),r=Ti[n];return s.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 ${r.gradient} ${t}`,children:r.label})}function T4({rating:e=0}){const t=Math.round(e);return s.jsx("span",{className:"inline-flex items-center","aria-label":`${e} out of 5`,children:[0,1,2,3,4].map(n=>s.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:s.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 ia(e){const{type:t,name:n,description:r,seed:o,icon:l,cover:c,hubBase:d,author:m,authorLabel:p,version:h,category:g,tags:x,rating:y=0,ratingCount:w=0,downloadCount:C=0,priceCents:T,currency:S="usd",installed:_,glowing:j,selected:O,showTypeBadge:P=!0,hideStats:D=!1,cornerLabel:$,actions:X,footerLeft:ee,headerAction:H,onClick:K,className:ae=""}=e,W=Ko(t),F=Ti[W],Z=o||n,U=(T??0)>0,Q=!!b0(c||void 0,d),ne=Bg(W,Z),ke=p??m?.displayName??m?.username??"",[B,q]=k.useState(null),le=_?s.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:s.jsx("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3.5",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})})}):$?s.jsx("span",{className:"chip",children:$}):U?s.jsx("span",{className:"badge-paid",children:S4(T,S)}):null;if(Q){const I=b0(c||void 0,d);return s.jsxs("div",{onClick:K,style:{aspectRatio:B??void 0},className:`group asset-card card-shine relative flex flex-col overflow-hidden min-h-[180px] ${K?"cursor-pointer":""} ${O?"ring-1 ring-brand-500/60":""} ${j?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${ae}`,children:[s.jsx("img",{src:I,alt:"",onLoad:Ae=>{const $e=Ae.currentTarget;$e.naturalWidth&&$e.naturalHeight&&q(Math.min(1.9,Math.max(1,$e.naturalWidth/$e.naturalHeight)))},className:"absolute inset-0 w-full h-full object-cover transition-transform duration-[600ms] group-hover:scale-[1.05]"}),s.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/90 via-black/50 to-black/5"}),s.jsx("div",{className:"absolute inset-x-0 top-0 h-20 bg-gradient-to-b from-black/50 to-transparent"}),s.jsxs("div",{className:"relative flex items-start justify-between gap-2 p-3",children:[s.jsx("span",{children:P&&s.jsx(tW,{type:W})}),s.jsxs("span",{className:"flex items-center gap-1.5",onClick:Ae=>Ae.stopPropagation(),children:[_?s.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:s.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})})}):$?s.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:$}):H?null:s.jsx("span",{className:U?"badge-paid":"badge-free",children:S4(T,S)}),H]})]}),s.jsxs("div",{className:"relative mt-auto p-4 pt-10 flex flex-col gap-2 text-white",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-[15px] font-semibold truncate drop-shadow-md",children:n}),h&&s.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",h]})]}),ke&&s.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-white/85",children:[m&&s.jsx(x0,{name:m.displayName,username:m.username,avatarUrl:m.avatarUrl,hubBase:d,size:15}),s.jsx("span",{className:"truncate",children:ke})]}),r&&s.jsx("p",{className:"text-[12.5px] text-white/80 truncate leading-snug drop-shadow-sm",children:r}),(g||x&&x.length>0)&&s.jsxs("div",{className:"flex flex-nowrap gap-1.5 overflow-hidden",children:[g&&s.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:g}),x?.slice(0,3).map(Ae=>s.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:Ae},Ae))]}),(!D||X)&&s.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1 shrink-0",children:[D?s.jsx("span",{}):s.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-white/80",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(T4,{rating:y}),w>0&&s.jsxs("span",{className:"text-white/60",children:["(",Eo(w),")"]})]}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":!0,children:s.jsx("path",{d:"M12 3v12m0 0l-4-4m4 4l4-4M5 21h14"})}),Eo(C)]})]}),X&&s.jsx("div",{className:"flex items-center gap-2",onClick:Ae=>Ae.stopPropagation(),children:X})]})]})]})}return s.jsxs("div",{onClick:K,className:`group asset-card card-shine relative flex flex-col ${K?"cursor-pointer":""} ${O?"ring-1 ring-brand-500/60":""} ${j?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${ae}`,children:[s.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, ${F.accent}, transparent)`}}),s.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:ne}}),H&&s.jsx("div",{className:"absolute top-2.5 right-2.5 z-10",onClick:I=>I.stopPropagation(),children:H}),s.jsxs("div",{className:"relative p-4 flex flex-col flex-1 gap-2.5",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(eW,{type:W,seed:Z,icon:l,hubBase:d,size:46,rounded:"rounded-2xl",className:"ring-1 ring-white/10 shadow-sm shadow-black/20"}),s.jsxs("div",{className:`min-w-0 flex-1 ${H?"pr-7":""}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg-primary truncate group-hover:text-brand-300 transition-colors",children:n}),h&&s.jsxs("span",{className:"chip shrink-0",children:["v",h]}),le&&s.jsx("span",{className:"ml-auto shrink-0",children:le})]}),(ke||P)&&s.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-[11px] text-fg-tertiary min-w-0",children:[m&&s.jsx(x0,{name:m.displayName,username:m.username,avatarUrl:m.avatarUrl,hubBase:d,size:15}),ke&&s.jsx("span",{className:"truncate",children:ke}),P&&s.jsxs(s.Fragment,{children:[ke&&s.jsx("span",{className:"text-fg-muted",children:"·"}),s.jsx("span",{className:"font-semibold shrink-0",style:{color:F.accent},children:F.label})]})]})]})]}),r&&s.jsx("p",{className:"text-[13px] text-fg-secondary truncate leading-snug",children:r}),(g||x&&x.length>0)&&s.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[g&&s.jsx("span",{className:"chip-accent capitalize",children:g}),x?.slice(0,3).map(I=>s.jsx("span",{className:"chip",children:I},I)),(x?.length??0)>3&&s.jsxs("span",{className:"text-[10px] text-fg-muted self-center",children:["+",(x?.length??0)-3]})]}),(()=>{const I=ee??(D?null:s.jsxs("span",{className:"flex items-center gap-3 text-[11px] text-fg-tertiary",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(T4,{rating:y}),s.jsx("span",{className:"text-fg-muted",children:w>0?`(${Eo(w)})`:""})]}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":!0,children:s.jsx("path",{d:"M12 3v12m0 0l-4-4m4 4l4-4M5 21h14"})}),Eo(C)]})]}));return!I&&!X?null:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 pt-2 mt-auto border-t border-border-subtle/60",onClick:Ae=>Ae.stopPropagation(),children:[I&&s.jsx("div",{className:"min-w-0 flex items-center gap-2",children:I}),X&&s.jsx("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:X})]})})()]})]})}function Ar({children:e,maxCardWidth:t=400,gap:n="1rem",className:r=""}){const o=k.useRef(null),[l,c]=k.useState(0);k.useEffect(()=>{const h=o.current;if(!h)return;c(h.clientWidth);const g=new ResizeObserver(x=>{for(const y of x)c(y.contentRect.width)});return g.observe(h),()=>g.disconnect()},[]);const d=Math.max(1,Math.ceil((l||t)/t)),m=k.Children.toArray(e),p=Array.from({length:d},()=>[]);return m.forEach((h,g)=>{p[g%d].push(h)}),s.jsx("div",{ref:o,className:`flex items-start ${r}`,style:{gap:n},children:p.map((h,g)=>s.jsx("div",{className:"flex flex-col flex-1 min-w-0",style:{gap:n,maxWidth:t},children:h},g))})}function nW(e){const t=e.indexOf(".markus/builder-artifacts/");return t>=0?"~/"+e.slice(t):e}const rW=[{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 aW(){const[e,t]=k.useState(()=>{const r=window.location.hash.slice(1).split("/");return cc(r[0])===me.BUILDER&&r[1]&&r[2]?{type:r[1],name:decodeURIComponent(r[2])}:null});return k.useEffect(()=>{const n=()=>{const o=window.location.hash.slice(1).split("/");cc(o[0])===me.BUILDER&&o[1]&&o[2]?t({type:o[1],name:decodeURIComponent(o[2])}):t(null)};return window.addEventListener("hashchange",n),()=>window.removeEventListener("hashchange",n)},[]),e}const F3="markus_builder_shared_map";function sW(){try{const e=localStorage.getItem(F3);if(!e)return new Map;const t=JSON.parse(e);return new Map(Object.entries(t))}catch{return new Map}}function Td(e){try{localStorage.setItem(F3,JSON.stringify(Object.fromEntries(e)))}catch{}}function q3({authUser:e}={}){const{t}=dt(["builder","common"]),n=Bo(),r=aW(),[o,l]=k.useState([]),[c,d]=k.useState([]),[m,p]=k.useState(!1),[h,g]=k.useState("all"),[x,y]=k.useState(null),[w,C]=k.useState(new Map),[T,S]=k.useState(null),[_,j]=k.useState(null),[O,P]=k.useState(null),[D,$]=k.useState(sW),[X,ee]=k.useState(null),[H,K]=k.useState(null),[ae,W]=k.useState(null),[F,Z]=k.useState(null),[U,Q]=k.useState(null),[ne,ke]=k.useState("creations"),[B,q]=k.useState([]),[le,I]=k.useState(""),[Ae,$e]=k.useState([]),[Oe,We]=k.useState(!1),[st,mt]=k.useState("all"),At=k.useCallback(()=>{p(!0),Promise.all([(wi(Tr.builderArtifacts)??Ce.builder.artifacts.list()).then(se=>se?.artifacts??[]).catch(()=>[]),(wi(Tr.builderAgents)??Ce.agents.list()).then(se=>se?.agents??[]).catch(()=>[]),(wi(Tr.builderHubMyItems)??it.myItems()).then(se=>se?.items??[]).catch(()=>[]),(wi(Tr.builderInstalled)??Ce.builder.artifacts.installed()).then(se=>se?.installed??{}).catch(()=>({}))]).then(([se,Be,Xe,Ge])=>{if(d(se),l(Be),Xe.length>0){const yt=new Map;for(const he of Xe){const V=he.itemType==="agent"?"agent":he.itemType==="team"?"team":"skill";for(const ye of se)ye.type===V&&(he.slug===ye.name||he.name===(ye.meta.displayName||ye.meta.name||ye.name))&&yt.set(`${ye.type}/${ye.name}`,{id:he.id,name:he.name,slug:he.slug||ye.name,version:he.version||"1.0.0",visibility:he.visibility??"public",moderationStatus:he.moderationStatus,pendingReview:he.pendingReview})}yt.size>0&&$(he=>{const V=new Map(he);for(const[ye,Qe]of yt)V.set(ye,Qe);return Td(V),V})}const et=new Map;for(const yt of se){const he=`${yt.type}/${yt.name}`,V=Ge[he];V&&et.set(he,{agentId:V.agentId,agentIds:V.agentIds,teamId:V.teamId})}C(et)}).finally(()=>p(!1))},[]);k.useEffect(()=>{At();const se=Be=>{Be.detail?.page===me.BUILDER&&At()};return window.addEventListener("markus:navigate",se),()=>window.removeEventListener("markus:navigate",se)},[At]);const gt=se=>{const Be=o.find(Xe=>Xe.role==="Secretary"||Xe.name==="Secretary");Be?at.navigate(me.TEAM,{agentId:Be.id,prefillMessage:se}):at.navigate(me.TEAM,{prefillMessage:se})},jt=async se=>{const Be=`${se.type}/${se.name}`;if(!w.has(Be)){y({key:Be,action:"install"});try{const Xe=await Ce.builder.artifacts.install(se.type,se.name),Ge={};Xe.agent&&typeof Xe.agent=="object"&&(Ge.agentId=Xe.agent.id),Xe.team&&typeof Xe.team=="object"&&(Ge.teamId=Xe.team.id),Array.isArray(Xe.agents)&&(Ge.agentIds=Xe.agents.map(et=>et.id)),C(et=>new Map(et).set(Be,Ge)),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(Xe){console.error("Install failed:",Xe),K({title:t("common:install"),message:t("installFailed",{error:String(Xe)}),variant:"danger"})}finally{y(null)}}},Jt=async se=>{const Be=`${se.type}/${se.name}`;if(w.has(Be)){y({key:Be,action:"uninstall"});try{await Ce.builder.artifacts.uninstall(se.type,se.name),C(Xe=>{const Ge=new Map(Xe);return Ge.delete(Be),Ge}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(Xe){console.error("Uninstall failed:",Xe),K({title:t("common:uninstall"),message:t("uninstallFailed",{error:String(Xe)}),variant:"danger"})}finally{y(null)}}},Rt=async(se,Be)=>{const Xe=`${se.type}/${se.name}`;y({key:Xe,action:"share"});try{const Ge=await Ce.builder.artifacts.ensureSlugSafe(se.type,se.name,se.meta.displayName||se.meta.name||se.name),et=Ge.name,yt=Ge.slug||fc(et);if(!yt)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 he=`${se.type}/${et}`;Ge.converted&&(d(oe=>oe.map(_e=>_e.type===se.type&&_e.name===se.name?{..._e,name:et,path:Ge.path,meta:{..._e.meta,name:et,displayName:Ge.displayName??_e.meta.displayName??se.name}}:_e)),$(oe=>{const _e=new Map(oe),de=_e.get(Xe);return de&&(_e.delete(Xe),_e.set(he,{...de,slug:yt,name:Ge.displayName??de.name})),Td(_e),_e}),C(oe=>{const _e=new Map(oe),de=_e.get(Xe);return de&&(_e.delete(Xe),_e.set(he,de)),_e}));const V=await Ce.builder.artifacts.get(se.type,et);let ye={...se.meta,name:et,displayName:Ge.displayName??se.meta.displayName??se.name};try{const oe=V.files?.[`${se.type}.json`]??V.files?.["agent.json"]??V.files?.["team.json"]??V.files?.["skill.json"];oe&&(ye={...JSON.parse(oe),...ye,name:et,displayName:ye.displayName})}catch{}const Qe=ye.displayName||ye.name||et,pe=ye.description||"",ve=ye.category||"general",Ye=Array.isArray(ye.tags)?ye.tags:[];let nt=ye.icon||void 0;const xt=ye.version||"1.0.0";if(nt&&!nt.startsWith("http")&&/\.(png|jpe?g|gif|webp|svg)$/i.test(nt)){const oe=nt.split("/").pop()??nt;try{const _e=await fetch(`/api/builder/artifacts/${se.type}s/${encodeURIComponent(et)}/images/${encodeURIComponent(oe)}`);if(_e.ok){const de=await _e.blob(),Pe=new File([de],oe,{type:de.type}),Ve=await it.uploadImage(Pe);Ve?.url&&(nt=Ve.url)}}catch{}}let Dt;const ct=[],Xt=Array.isArray(ye.screenshots)?ye.screenshots:[];for(let oe=0;oe<Xt.length;oe++){const _e=Xt[oe],de=_e.split("/").pop()??_e;try{const Pe=await fetch(`/api/builder/artifacts/${se.type}s/${encodeURIComponent(et)}/images/${encodeURIComponent(de)}`);if(Pe.ok){const Ve=await Pe.blob(),G=new File([Ve],de,{type:Ve.type}),ie=await it.uploadImage(G);ie?.url&&(ct.push({url:ie.url,alt:de,order:oe}),(oe===0||ye.thumbnail===_e)&&(Dt=ie.url))}}catch{}}const R=await it.publishViaProxy({itemType:se.type==="team"?"team":se.type==="skill"?"skill":"agent",name:Qe,slug:yt,description:pe,category:ve,tags:Ye,icon:nt,version:xt,config:{...ye,name:et,displayName:Qe},files:V.files&&Object.keys(V.files).length>0?V.files:void 0,thumbnailUrl:Dt,images:ct.length>0?ct:void 0,priceCents:Be?.priceCents,donationsEnabled:Be?.donationsEnabled,visibility:Be?.visibility,orgId:Be?.orgId});R.id&&($(_e=>{const de=new Map(_e);return de.set(he,{id:R.id,name:Qe,slug:R.slug??yt,version:xt,visibility:R.visibility??Be?.visibility??"public",moderationStatus:R.moderationStatus,pendingReview:R.pendingReview}),Td(de),de}),(R.visibility??Be?.visibility??"public")!=="org"&&(R.moderationStatus==="pending"||R.pendingReview)?K({title:t("common:share"),message:Ge.converted?t("share.convertedAndSubmitted",{previous:se.name,slug:yt}):R.updated?t("share.updateSubmitted"):t("share.submittedForReview"),variant:"primary"}):Ge.converted&&K({title:t("common:share"),message:t("share.convertedSlug",{previous:se.name,slug:yt}),variant:"primary"}))}catch(Ge){console.error("Share failed:",Ge),K({title:t("common:share"),message:t("shareFailed",{error:Ge instanceof Error?Ge.message:String(Ge)}),variant:"danger"})}finally{y(null)}},be=async()=>{if(!X)return;const{key:se}=X,Be=D.get(se);if(ee(null),!Be)return;const Xe=Be.id;y({key:se,action:"hubDelete"});try{await it.deleteItem(Xe),$(Ge=>{const et=new Map(Ge);return et.delete(se),Td(et),et})}catch(Ge){console.error("Hub delete failed:",Ge),K({title:t("unshare"),message:t("hubDeleteFailed",{error:String(Ge)}),variant:"danger"})}finally{y(null)}},Me=async()=>{if(!T)return;const se=T,Be=`${se.type}/${se.name}`;S(null),y({key:Be,action:"delete"});try{await Ce.builder.artifacts.delete(se.type,se.name),d(Xe=>Xe.filter(Ge=>!(Ge.type===se.type&&Ge.name===se.name))),C(Xe=>{const Ge=new Map(Xe);return Ge.delete(Be),Ge}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(Xe){console.error("Delete failed:",Xe)}finally{y(null)}},qe=h==="all"?c:c.filter(se=>se.type===h);k.useEffect(()=>{ne!=="orgAssets"||B.length>0||it.myOrgs().then(se=>{q(se.memberships),se.memberships.length>0&&!le&&I(se.memberships[0].id)}).catch(()=>{})},[ne,B.length,le]),k.useEffect(()=>{ne!=="orgAssets"||!le||(We(!0),it.browseItems({orgId:le,limit:100}).then(se=>$e(se.items??[])).catch(()=>$e([])).finally(()=>We(!1)))},[ne,le]);const ot=st==="all"?Ae:Ae.filter(se=>se.itemType===st),ft=se=>{history.pushState(null,"",Ni(me.BUILDER,`${se.type}/${encodeURIComponent(se.name)}`)),window.dispatchEvent(new HashChangeEvent("hashchange"))};return r?s.jsx(_i,{type:r.type,name:r.name,authUser:e,onBack:()=>{history.pushState(null,"",Ni(me.BUILDER)),window.dispatchEvent(new HashChangeEvent("hashchange"))}}):s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:`max-w-5xl mx-auto w-full ${n?"px-4 py-5":"px-6 py-6"}`,children:[s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-bold text-fg-primary",children:t("title")}),s.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:t("subtitle")})]}),s.jsx("button",{onClick:At,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")})]}),s.jsx("div",{className:`grid ${n?"grid-cols-1 gap-2":"grid-cols-3 gap-3"}`,children:rW.map(se=>{const Be=t(`prompts.${se.id}Prompt`),Xe=t(`prompts.${se.id}Examples`,{returnObjects:!0}),Ge=Array.isArray(Xe)?Xe:[];return s.jsx("button",{onClick:()=>gt(Be),className:`group text-left w-full rounded-xl border ${se.borderColor} bg-surface-secondary/60 p-4 transition-all hover:bg-surface-secondary/80 hover:shadow-lg`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:`w-10 h-10 text-xl rounded-lg ${se.bgColor} flex items-center justify-center shrink-0`,children:se.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:`text-sm font-semibold bg-gradient-to-r ${se.color} bg-clip-text text-transparent`,children:t(`prompts.${se.id}`)}),s.jsx("p",{className:"text-[11px] text-fg-tertiary mt-1 leading-relaxed",children:t(`prompts.${se.id}Desc`)}),Ge.length>0&&s.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:Ge.slice(0,2).map((et,yt)=>s.jsxs("span",{className:"text-[10px] text-fg-muted bg-surface-elevated/60 rounded-full px-2 py-0.5 border border-border-default",onClick:he=>{he.stopPropagation(),gt(Be+et)},children:["“",et,"”"]},yt))})]})]})},se.id)})})]}),s.jsx("div",{className:"mb-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{onClick:()=>ke("creations"),className:`text-sm font-semibold transition-colors ${ne==="creations"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("myCreations.title")}),s.jsx("button",{onClick:()=>ke("orgAssets"),className:`text-sm font-semibold transition-colors ${ne==="orgAssets"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("orgAssets.title")})]}),ne==="creations"&&s.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(se=>s.jsx("button",{onClick:()=>g(se),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${h===se?"bg-brand-600 text-white":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(se==="all"?"myCreations.filterAll":se==="agent"?"myCreations.filterAgents":se==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},se))}),ne==="orgAssets"&&s.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(se=>s.jsx("button",{onClick:()=>mt(se),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${st===se?"bg-brand-600 text-white":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(se==="all"?"myCreations.filterAll":se==="agent"?"myCreations.filterAgents":se==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},se))})]})}),ne==="orgAssets"&&B.length>0&&s.jsx("div",{className:"flex gap-2 mb-3 overflow-x-auto pb-1",children:B.map(se=>s.jsx("button",{onClick:()=>I(se.id),className:`text-xs px-3 py-1.5 rounded-full whitespace-nowrap border transition-colors ${le===se.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:se.name},se.id))}),ne==="orgAssets"&&(B.length===0&&!Oe?s.jsx("div",{className:"text-center py-12",children:s.jsx("div",{className:"text-fg-tertiary text-sm",children:t("orgAssets.noOrgs")})}):Oe?s.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("orgAssets.loading")}):ot.length===0?s.jsx("div",{className:"text-center py-12",children:s.jsx("div",{className:"text-fg-tertiary text-sm",children:t("orgAssets.noItems")})}):s.jsx(Ar,{children:ot.map(se=>{const Be=se.author?.username&&se.slug?`${it.getUrl()}/@${encodeURIComponent(se.author.username)}/${encodeURIComponent(se.slug)}`:null;return s.jsx(ia,{type:se.itemType,name:se.name,description:se.description,seed:se.slug||se.id||se.name,icon:se.icon,cover:se.thumbnailUrl,hubBase:it.getUrl(),author:se.author,version:se.version,rating:parseFloat(se.avgRating)||0,ratingCount:se.ratingCount,downloadCount:se.downloadCount,actions:Be?s.jsxs("a",{href:Be,target:"_blank",rel:"noopener noreferrer",onClick:Xe=>{Xe.stopPropagation(),pc()&&(Xe.preventDefault(),Ai(Be))},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:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),"Hub"]}):void 0},se.id)})})),ne==="creations"&&(m&&c.length===0?s.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("myCreations.loadingArtifacts")}):qe.length===0?s.jsxs("div",{className:"text-center py-12",children:[s.jsx("div",{className:"text-fg-tertiary text-sm",children:t("myCreations.noArtifacts")}),s.jsx("div",{className:"text-fg-muted text-xs mt-1",children:t("myCreations.noArtifactsHint")})]}):s.jsx(Ar,{children:qe.map(se=>{const Be=se.meta.displayName||se.meta.name||se.name,Xe=se.meta.description||"",Ge=`${se.type}/${se.name}`,et=x?.key===Ge?x.action:null,yt=D.get(Ge),he=se.meta.version||"1.0.0",V=!!yt,ye=V&&yt.version!==he,Qe=()=>{const ct=it.getUser();return!yt||!ct?null:`${it.getUrl()}/@${encodeURIComponent(ct.username)}/${encodeURIComponent(yt.slug)}`},pe=V&&(yt?.moderationStatus==="pending"||yt?.moderationStatus==="rejected"||!!yt?.pendingReview),ve=s.jsxs("div",{className:"flex items-center gap-1.5 justify-end",onClick:ct=>ct.stopPropagation(),children:[w.has(Ge)?s.jsxs("button",{onClick:()=>P(se),disabled:!!et,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:[s.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:[s.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),s.jsx("polyline",{points:"17 8 12 3 7 8"}),s.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]}),t(et==="uninstall"?"common:uninstalling":"common:uninstall")]}):s.jsxs("button",{onClick:()=>j(se),disabled:!!et,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:[s.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:[s.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),s.jsx("polyline",{points:"7 10 12 15 17 10"}),s.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),t(et==="install"?"common:installing":"common:install")]}),V&&pe?yt?.moderationStatus==="pending"?s.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:t("share.underReviewTip"),children:[s.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:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),t("share.underReview")]}):yt?.moderationStatus==="rejected"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-red-500/30 text-red-400 inline-flex items-center gap-1",title:t("share.rejectedTip"),children:[s.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:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),s.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),t("share.rejected")]}):s.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:t("share.updateUnderReviewTip"),children:[s.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:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),t("share.updateUnderReview")]}):V?s.jsxs(s.Fragment,{children:[ye&&s.jsxs("button",{onClick:()=>{const ct=yt?.visibility??"public";Rt(se,{visibility:ct})},disabled:!!et,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:[s.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:[s.jsx("polyline",{points:"23 4 23 10 17 10"}),s.jsx("polyline",{points:"1 20 1 14 7 14"}),s.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"})]}),et==="share"?t("common:sharing"):t("share.updateVersion",{version:he})]}),s.jsxs("a",{href:Qe()??"#",target:"_blank",rel:"noopener noreferrer",onClick:ct=>{const Xt=Qe();pc()&&Xt&&(ct.preventDefault(),Ai(Xt))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1 ${yt?.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/40":yt?.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:[yt?.visibility==="org"?s.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:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}):yt?.visibility==="unlisted"?s.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:[s.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"}),s.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"})]}):s.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:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),yt?.visibility==="org"?t("visibility.sharedOrg"):yt?.visibility==="unlisted"?t("visibility.sharedUnlisted"):t("visibility.shared")]}),s.jsxs("button",{onClick:()=>ee({key:Ge,name:Be}),disabled:!!et,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:[s.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:[s.jsx("path",{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M5.17 11.75l-1.71 1.71a5 5 0 0 0 7.07 7.07l1.71-1.71"}),s.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"})]}),t("unshare")]})]}):s.jsxs("button",{onClick:async()=>{await it.ensureAuth(),Array.isArray(se.meta.screenshots)&&se.meta.screenshots.length>0?Q(se):W(se)},disabled:!!et,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:[s.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:[s.jsx("circle",{cx:"18",cy:"5",r:"3"}),s.jsx("circle",{cx:"6",cy:"12",r:"3"}),s.jsx("circle",{cx:"18",cy:"19",r:"3"}),s.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),s.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),t(et==="share"?"common:sharing":"common:share")]})]}),Ye=s.jsx("button",{onClick:()=>S(se),disabled:!!et,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:s.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:[s.jsx("polyline",{points:"3 6 5 6 21 6"}),s.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"})]})}),nt=se.meta.icon,Dt=!!nt&&/\.(png|jpe?g|gif|webp|svg)$/i.test(nt)?nt.startsWith("http")||nt.startsWith("/")?nt:`/api/builder/artifacts/${se.type}s/${encodeURIComponent(se.name)}/images/${encodeURIComponent(nt.split("/").pop()??"")}`:nt;return s.jsx(ia,{type:se.type,name:Be,description:Xe,seed:Ge,icon:Dt,version:he,footerLeft:s.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary min-w-0",children:[s.jsx("button",{onClick:ct=>{ct.stopPropagation(),Ce.system.openPath(se.path).catch(()=>{})},className:"hover:text-fg-secondary transition-colors truncate min-w-0",title:se.path,children:nW(se.path)}),s.jsx("span",{className:"shrink-0",children:"·"}),s.jsx("span",{className:"shrink-0",children:new Date(se.updatedAt).toLocaleDateString()})]}),headerAction:Ye,actions:ve,onClick:()=>ft(se)},Ge)})})),_&&s.jsx(dr,{variant:"primary",title:t("confirmInstall"),message:t("confirmInstallMsg",{name:_.meta.displayName||_.meta.name||_.name}),confirmLabel:t("common:install"),onConfirm:()=>{const se=_;j(null),jt(se)},onCancel:()=>j(null)}),O&&s.jsx(dr,{variant:"primary",title:t("confirmUninstall"),message:t("confirmUninstallMsg",{name:O.meta.displayName||O.meta.name||O.name}),confirmLabel:t("common:uninstall"),onConfirm:()=>{const se=O;P(null),Jt(se)},onCancel:()=>P(null)}),T&&s.jsx(dr,{title:t("confirmDeleteLocal"),message:t("deleteCannotUndo",{name:T.meta.displayName||T.meta.name||T.name}),confirmLabel:t("common:delete"),onConfirm:Me,onCancel:()=>S(null)}),X&&s.jsx(dr,{title:t("confirmUnshare"),message:t("removeFromHub",{name:X.name}),confirmLabel:t("unshare"),onConfirm:()=>{be()},onCancel:()=>ee(null)}),H&&s.jsx(dr,{alertOnly:!0,variant:H.variant??"primary",title:H.title,message:H.message,onConfirm:()=>K(null),onCancel:()=>K(null)}),ae&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>W(null),children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:se=>se.stopPropagation(),children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-2",children:t("common:share")}),s.jsx("p",{className:"text-sm text-fg-secondary mb-5",children:t("share.imagePrompt")}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:()=>{const se=ae;W(null),Q(se)},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")}),s.jsx("button",{onClick:()=>{const se=ae;W(null),ft(se)},className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:t("share.addImagesFirst")})]})]})}),F&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>Z(null),children:s.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:se=>se.stopPropagation(),children:s.jsx(oW,{isUpdate:D.has(`${F.type}/${F.name}`),onCancel:()=>Z(null),onConfirm:(se,Be)=>{const Xe=F;Z(null),Rt(Xe,{priceCents:Be>0?Be:void 0})}})})}),U&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>Q(null),children:s.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:se=>se.stopPropagation(),children:s.jsx(iW,{onCancel:()=>Q(null),onConfirm:(se,Be,Xe,Ge)=>{const et=U;Q(null),Rt(et,{visibility:se,orgId:Be,priceCents:Xe,donationsEnabled:Ge})}})})})]})})}function iW({onCancel:e,onConfirm:t}){const{t:n}=dt(["builder","common"]),[r,o]=k.useState("public"),[l,c]=k.useState([]),[d,m]=k.useState(""),[p,h]=k.useState(!1),[g,x]=k.useState(0),[y,w]=k.useState(!1);k.useEffect(()=>{r==="org"&&l.length===0&&(h(!0),it.myOrgs().then(S=>{c(S.memberships),S.memberships.length>0&&m(S.memberships[0].id)}).catch(()=>{}).finally(()=>h(!1)))},[r,l.length]);const C=r==="public"||r==="unlisted",T=[{value:"public",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),s.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:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.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:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.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"}),s.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 s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:n("visibility.label")}),s.jsx("div",{className:"space-y-2 mb-5",children:T.map(S=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${r===S.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"visibility",checked:r===S.value,onChange:()=>o(S.value),className:"accent-brand-500"}),s.jsx("div",{className:"flex items-center gap-2 text-fg-secondary",children:S.icon}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:S.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:S.desc})]})]},S.value))}),r==="org"&&s.jsxs("div",{className:"mb-5",children:[s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("visibility.orgSelect")}),p?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:"Loading..."}):l.length===0?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:n("visibility.orgNone")}):s.jsx("select",{value:d,onChange:S=>m(S.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(S=>s.jsx("option",{value:S.id,children:S.name},S.id))})]}),C&&s.jsxs("div",{className:"mb-5",children:[s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("pricing.label")}),s.jsx("div",{className:"grid grid-cols-4 gap-2 mb-3",children:G3.map(S=>s.jsx("button",{type:"button",onClick:()=>x(S.cents),className:`text-sm px-2 py-2 rounded-lg border transition-colors ${g===S.cents?"border-brand-500 bg-brand-500/10 text-fg-primary":"border-border-default text-fg-secondary hover:border-gray-600"}`,children:S.label},S.cents))}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:y,onChange:S=>w(S.target.checked),className:"accent-brand-500"}),s.jsx("span",{className:"text-xs text-fg-secondary",children:n("pricing.enableTips")})]})]}),C&&s.jsx("div",{className:"mb-4 text-[11px] text-fg-tertiary rounded-lg border border-border-default px-3 py-2",children:n("pricing.reviewNote")}),s.jsxs("div",{className:"flex gap-3",children:[s.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")}),s.jsx("button",{onClick:()=>t(r,r==="org"?d:void 0,C&&g>0?g:void 0,C?y:void 0),disabled:r==="org"&&!d,className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n("shareMode.share")})]})]})}const G3=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function oW({isUpdate:e,onCancel:t,onConfirm:n}){const{t:r}=dt(["builder","common"]),[o,l]=k.useState(0);return s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:r(e?"shareMode.titleUpdate":"shareMode.title")}),s.jsx("div",{className:"space-y-2 mb-5",children:G3.map(c=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${o===c.cents?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"sharePrice",checked:o===c.cents,onChange:()=>l(c.cents),className:"accent-brand-500"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:c.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:c.cents===0?r("shareMode.freeDesc"):r("shareMode.paidDesc")})]})]},c.cents))}),s.jsxs("div",{className:"flex gap-3",children:[s.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:r("common:cancel")}),s.jsx("button",{onClick:()=>n(o>0?"paid":"free",o),className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:r(e?"shareMode.update":"shareMode.share")})]})]})}const lW=Object.freeze(Object.defineProperty({__proto__:null,AgentBuilder:q3},Symbol.toStringTag,{value:"Module"}));async function V3(e,t){if(!t)return{items:e,highlighted:null,missing:!1};const n=e.find(r=>r.id===t);if(n)return{items:[n,...e.filter(r=>r.id!==t)],highlighted:n,missing:!1};try{const{item:r}=await it.getItem(t);return r?{items:[r,...e],highlighted:r,missing:!1}:{items:e,highlighted:null,missing:!0}}catch{return{items:e,highlighted:null,missing:!0}}}function cW(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const l=n[o]??0,c=r[o]??0;if(l>c)return!0;if(l<c)return!1}return!1}function y0(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function A4(e,t){return e.i18n?.[t]?.description||e.description}const uW={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function dW({authUser:e,highlightItemId:t,onHighlightDone:n}={}){const{t:r,i18n:o}=dt(["store","common"]),l=o.language,[c,d]=k.useState(""),[m,p]=k.useState([]),[h,g]=k.useState([]),[x,y]=k.useState(null),[w,C]=k.useState({}),[T,S]=k.useState(!1),[_,j]=k.useState(!0),[O,P]=k.useState(new Map),[D,$]=k.useState(new Set),[X,ee]=k.useState(null),[H,K]=k.useState(null),ae=k.useCallback(async()=>{try{const[Z,U]=await Promise.all([Ce.builder.artifacts.list().catch(()=>({artifacts:[]})),Ce.builder.artifacts.installed().catch(()=>({installed:{}}))]),Q=new Map;for(const ne of Z.artifacts){if(ne.type!=="agent")continue;const ke=!!U.installed[`agent/${ne.name}`];Q.set(ne.name,{installed:ke,localVersion:ne.meta.version||void 0,localUpdatedAt:ne.updatedAt})}P(Q)}catch{}},[]),W=k.useCallback(async()=>{j(!0);try{const Z=c?it.search({type:"agent",q:c,limit:50}):wi(Tr.hubAgents)??it.search({type:"agent",limit:50}),U=new URLSearchParams;c&&U.set("q",c);const Q=fetch("/api/templates?"+U.toString()).then(q=>q.json()).catch(()=>({templates:[]})),[ne,ke]=await Promise.all([Z.catch(()=>({items:[],total:0})),Q,ae(),it.isAuthenticated()?it.purchases.mine().then(q=>$(new Set(q.purchases.map(le=>le.itemId)))).catch(()=>{}):Promise.resolve()]),B=await V3(ne?.items??[],t);g(B.items),p(Array.isArray(ke.templates)?ke.templates:[]),B.missing&&n?.()}catch{p([]),g([])}finally{j(!1)}},[c,ae,t,n]);k.useEffect(()=>{W()},[W]),k.useEffect(()=>{if(!x){C({});return}fetch(`/api/templates/${encodeURIComponent(x.id)}/files`,{credentials:"include"}).then(Z=>Z.json()).then(Z=>C(Z.files??{})).catch(()=>C({}))},[x]);const F=async(Z,U,Q)=>{try{const ne=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:Z,name:U,orgId:"default",teamId:Q})});if(!ne.ok)throw new Error(`Failed: ${ne.status}`);S(!1),y(null)}catch(ne){K({title:r("common:create",{defaultValue:"Create"}),message:`Failed to create agent: ${ne}`,variant:"danger"})}};if(X)return s.jsx(_i,{type:X.type,name:X.name,onBack:()=>ee(null)});if(x){const Z={type:"agent",name:x.id,displayName:y0(x,l),version:x.version,description:A4(x,l),author:x.author,category:x.category,tags:x.tags,icon:x.icon,files:w,agent:{roleName:x.roleId,agentRole:x.agentRole==="manager"?"manager":"worker"},dependencies:{skills:x.skills}},U=s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:r("agentStore.roleConfig")}),s.jsxs("div",{className:"space-y-2.5 text-sm",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-20",children:r("agentStore.role")}),s.jsx("span",{className:"text-fg-secondary font-mono text-xs bg-surface-elevated px-2 py-0.5 rounded",children:x.roleId})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-20",children:r("agentStore.position")}),s.jsx("span",{className:`px-2 py-0.5 rounded text-xs capitalize ${uW[x.agentRole]??""}`,children:x.agentRole})]})]})]}),s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:r("agentStore.skills")}),s.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[x.skills.map(Q=>s.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:Q},Q)),x.skills.length===0&&s.jsx("span",{className:"text-xs text-fg-tertiary italic",children:r("agentStore.noSkills")})]})]})]}),x.starterTasks&&x.starterTasks.length>0&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:r("agentStore.starterTasks")}),s.jsx("div",{className:"space-y-2",children:x.starterTasks.map((Q,ne)=>s.jsxs("div",{className:"flex items-start gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[s.jsx("span",{className:`inline-block w-2 h-2 rounded-full shrink-0 mt-1 ${Q.priority==="high"?"bg-red-400":Q.priority==="medium"?"bg-amber-400":"bg-green-400"}`}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm text-fg-primary",children:Q.title}),Q.description&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:Q.description})]})]},ne))})]})]});return s.jsxs(s.Fragment,{children:[s.jsx(_i,{type:"agent",name:x.id,onBack:()=>y(null),readOnly:!0,initialManifest:Z,actionSlot:s.jsx("button",{onClick:()=>S(!0),className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors font-medium",children:r("agentStore.hireAgent")}),contentSlot:U}),T&&s.jsx(E4,{template:x,lang:l,onClose:()=>S(!1),onHire:F}),H&&s.jsx(dr,{alertOnly:!0,variant:H.variant??"danger",title:H.title,message:H.message,onConfirm:()=>K(null),onCancel:()=>K(null)})]})}return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{"data-electron-drag":!0,className:"px-6 h-14 flex items-center justify-between shrink-0 gap-3",children:[s.jsx("h2",{className:"text-lg font-semibold",children:r("agentStore.title")}),s.jsx("input",{type:"text",placeholder:r("agentStore.searchPlaceholder"),value:c,onChange:Z=>d(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"})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:_?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((Z,U)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},U))}):m.length===0&&h.length===0?s.jsxs("div",{className:"text-center py-20",children:[s.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),s.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:c?r("agentStore.noResults",{search:c}):r("agentStore.noAgents")}),s.jsx("div",{className:"text-fg-tertiary text-sm",children:r(c?"agentStore.noResultsHint":"agentStore.noAgentsHint")})]}):s.jsxs(s.Fragment,{children:[m.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[s.jsx("h3",{className:"section-title",children:r("agentStore.builtin")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:r("agentStore.available",{count:m.length})})]}),s.jsx(Ar,{columns:3,children:m.map(Z=>s.jsx(ia,{type:"agent",name:y0(Z,l),description:A4(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:r("agentStore.builtin"),onClick:()=>y(Z)},Z.id))})]}),h.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:r("agentStore.markusHub")}),s.jsx(Ar,{columns:3,children:h.map(Z=>s.jsx(mW,{item:Z,localInfo:O.get(_c(Z)),purchased:Kd(Z,D),onStatusChange:ae,highlight:Z.id===t,onHighlightDone:n,onViewDetail:U=>ee({type:"agent",name:U})},Z.id))})]})]})}),T&&x&&s.jsx(E4,{template:x,lang:l,onClose:()=>S(!1),onHire:F}),H&&s.jsx(dr,{alertOnly:!0,variant:H.variant??"danger",title:H.title,message:H.message,onConfirm:()=>K(null),onCancel:()=>K(null)})]})}function _c(e,t){if(e.slug&&e.slug.trim())return e.slug.trim();const n=t&&typeof t.name=="string"?t.name.trim():"";return Xd(n||e.name,"hub-pkg")}function ki(e){return(async()=>{const t=await it.download(e.id),n=t.name||e.name,r=t.config??{},o=_c(e,r),l=t.itemType==="team"?"team":t.itemType==="skill"?"skill":"agent",c={type:"hub",hubItemId:e.id},d=(t.version||e.version||(typeof r.version=="string"?r.version:"")||"").trim()||void 0;if(t.files&&Object.keys(t.files).length>0)await Ce.builder.artifacts.import(l,o,t.files,c,d);else{const m={...r,...d?{version:d}:{},name:o,displayName:r.displayName||n,description:e.description,source:c};await Ce.builder.artifacts.save(l,m)}return await Ce.builder.artifacts.install(l,o),window.dispatchEvent(new CustomEvent("markus:data-changed")),n})()}async function Ug(e,t){t("checking"),await it.ensureAuth();const n=await it.purchases.checkout(e.id);if(n.alreadyOwned)return t("installing"),await ki(e),"installed";try{if((await it.creator.getBalance()).availableBalance>=(e.priceCents??0)){const l=await it.purchases.payWithEarnings(e.id);if(l.ok||l.alreadyOwned)return t("installing"),await ki(e),"installed"}}catch{}if(!n.checkoutUrl)throw new Error("No checkout URL");t("checkout_opened");const r=window.open(n.checkoutUrl,"_blank","noopener");return new Promise((o,l)=>{const c=setInterval(async()=>{const d=r?r.closed:!1;try{if((await it.purchases.checkout(e.id)).alreadyOwned){clearInterval(c),t("installing");try{await ki(e),o("installed")}catch(p){l(p)}return}}catch{}if(d){clearInterval(c);try{if((await it.purchases.checkout(e.id)).alreadyOwned){t("installing"),await ki(e),o("installed");return}}catch{}o("cancelled")}},2e3)})}function mW({item:e,localInfo:t,purchased:n,onStatusChange:r,highlight:o,onHighlightDone:l,onViewDetail:c}){const{t:d}=dt(["store"]),[m,p]=k.useState(!1),[h,g]=k.useState(""),x=k.useRef(null),[y,w]=k.useState(!1);k.useEffect(()=>{if(o&&x.current){x.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const X=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(X)}},[o,l]);const C=t?.installed??!1,T=C&&e.version&&t?.localVersion&&cW(e.version,t.localVersion),S=(e.priceCents??0)>0,_=async X=>{if(X.stopPropagation(),!m){p(!0),g("");try{await ki(e),g(T?d("card.upgraded"):d("card.installed")+"!"),r()}catch(ee){const H=ee instanceof Error?ee.message:"";H.includes("402")||H.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{p(!1)}}},j=async X=>{if(X.stopPropagation(),!m){p(!0),g("");try{await Ug(e,H=>{H==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):H==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),r()):g("")}catch(ee){g(ee instanceof Error?ee.message:d("card.failed"))}finally{p(!1)}}},O=S?`$${((e.priceCents??0)/100).toFixed(2)}`:null,P=e.slug&&e.author?.username?`${it.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,D=()=>{C&&c?c(_c(e)):P&&window.open(P,"_blank","noopener,noreferrer")},$=s.jsxs(s.Fragment,{children:[T?s.jsx("button",{onClick:X=>{_(X)},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?d("card.upgrading"):d("card.upgrade",{version:e.version})}):C?s.jsxs("button",{onClick:X=>{_(X)},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:[d("card.installed"),t?.localVersion?` v${t.localVersion}`:""]}):S&&!n?s.jsx("button",{onClick:X=>{j(X)},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?h||d("card.installing"):s.jsxs(s.Fragment,{children:[d("card.buy","Buy")," ",O]})}):s.jsx("button",{onClick:X=>{_(X)},disabled:m,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:d(m?"card.installing":"card.install")}),h&&!(S&&!n)&&s.jsx("span",{className:`text-[10px] ${h===d("card.failed")||h===d("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:h})]});return s.jsx("div",{ref:x,className:y?"animate-pulse":"",children:s.jsx(ia,{type:"agent",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"bot",cover:e.thumbnailUrl,hubBase:it.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:D,actions:$})})}function E4({template:e,lang:t,onClose:n,onHire:r}){const{t:o}=dt(["store"]),[l,c]=k.useState(`${y0(e,t)} Agent`),[d,m]=k.useState(""),[p,h]=k.useState([]),[g,x]=k.useState(!1);k.useEffect(()=>{fetch("/api/teams",{credentials:"include"}).then(w=>w.json()).then(w=>h(w.teams??[])).catch(()=>{})},[]);const y=async()=>{if(l.trim()){x(!0);try{await r(e.id,l.trim(),d||void 0)}finally{x(!1)}}};return s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:n,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[440px] shadow-2xl",onClick:w=>w.stopPropagation(),children:[s.jsx("div",{className:"flex items-center gap-3 mb-5",children:s.jsxs("div",{children:[s.jsx("h3",{className:"text-base font-semibold",children:o("hireModal.title")}),s.jsx("p",{className:"text-xs text-fg-tertiary",children:o("hireModal.creating",{name:y0(e,t)})})]})}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:o("hireModal.agentName")}),s.jsx("input",{type:"text",value:l,onChange:w=>c(w.target.value),className:"input-field",autoFocus:!0})]}),p.length>0&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:o("hireModal.assignTeam")}),s.jsxs("select",{value:d,onChange:w=>m(w.target.value),className:"input-field",children:[s.jsx("option",{value:"",children:o("hireModal.noTeam")}),p.map(w=>s.jsx("option",{value:w.id,children:w.name},w.id))]})]}),s.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg p-3",children:[s.jsx("div",{className:"text-xs text-fg-tertiary mb-2 font-medium",children:o("hireModal.agentConfig")}),s.jsxs("div",{className:"grid grid-cols-2 gap-y-1.5 gap-x-4 text-xs",children:[s.jsx("div",{className:"text-fg-tertiary",children:o("hireModal.role")}),s.jsx("div",{className:"text-fg-secondary font-mono",children:e.roleId}),s.jsx("div",{className:"text-fg-tertiary",children:o("hireModal.position")}),s.jsx("div",{className:"text-fg-secondary capitalize",children:e.agentRole}),s.jsx("div",{className:"text-fg-tertiary",children:o("hireModal.skills")}),s.jsx("div",{className:"text-fg-secondary",children:e.skills.join(", ")||o("hireModal.none")})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[s.jsx("button",{onClick:n,className:"btn-secondary",children:o("hireModal.cancel")}),s.jsx("button",{onClick:y,disabled:!l.trim()||g,className:"btn-primary",children:o(g?"hireModal.creating_progress":"hireModal.create")})]})]})})}function Jp(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function _4(e,t){return e.i18n?.[t]?.description||e.description}function j4(e,t,n){return e.i18n?.[n]?.members?.[t]||t}function fW(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const l=n[o]??0,c=r[o]??0;if(l>c)return!0;if(l<c)return!1}return!1}function pW({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:r}=dt(["store","common"]),o=r.language,[l,c]=k.useState(""),[d,m]=k.useState([]),[p,h]=k.useState([]),[g,x]=k.useState(null),[y,w]=k.useState({}),[C,T]=k.useState(!0),[S,_]=k.useState(!1),[j,O]=k.useState(null),[P,D]=k.useState(new Map),[$,X]=k.useState(new Set),[ee,H]=k.useState(null),K=k.useCallback(async()=>{try{const[F,Z]=await Promise.all([Ce.builder.artifacts.list().catch(()=>({artifacts:[]})),Ce.builder.artifacts.installed().catch(()=>({installed:{}}))]),U=new Map;for(const Q of F.artifacts){if(Q.type!=="team")continue;const ne=!!Z.installed[`team/${Q.name}`];U.set(Q.name,{installed:ne,localVersion:Q.meta.version||void 0,localUpdatedAt:Q.updatedAt})}D(U)}catch{}},[]),ae=k.useCallback(async()=>{T(!0);try{const F=l?it.search({type:"team",q:l,limit:50}):wi(Tr.hubTeams)??it.search({type:"team",limit:50}),[Z,U]=await Promise.all([F.catch(()=>({items:[],total:0})),Ce.teamTemplates.list(l||void 0).catch(()=>({templates:[]})),K(),it.isAuthenticated()?it.purchases.mine().then(ne=>X(new Set(ne.purchases.map(ke=>ke.itemId)))).catch(()=>{}):Promise.resolve()]),Q=await V3(Z?.items??[],e);h(Q.items),m(U?.templates??[]),Q.missing&&t?.()}catch{m([]),h([])}finally{T(!1)}},[l,K,e,t]);k.useEffect(()=>{ae()},[ae]),k.useEffect(()=>{if(!g){w({});return}fetch(`/api/team-templates/${encodeURIComponent(g.id)}/files`,{credentials:"include"}).then(F=>F.json()).then(F=>w(F.files??{})).catch(()=>w({}))},[g]);const W=async F=>{_(!0),O(null);try{const U=(await Ce.teams.create(F.name,F.description)).team.id;let Q,ne=0;const ke=[];for(const q of F.members){const le=q.count??1;for(let I=0;I<le;I++){const Ae=q.name??`${F.name} Agent ${I+1}`,$e=le>1?`${Ae} ${I+1}`:Ae,Oe=q.roleName??q.templateId;try{const We=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:$e,...Oe?{roleName:Oe}:{},orgId:"default",teamId:U,agentRole:q.role??"worker",skills:q.skills??[]})});if(We.ok){ne++;const st=await We.json();q.role==="manager"&&!Q&&(Q=st.agent?.id)}else{const st=await We.json().catch(()=>({error:`HTTP ${We.status}`}));ke.push(`${$e}: ${st.error??We.statusText}`)}}catch(We){ke.push(`${$e}: ${String(We)}`)}}}Q&&await Ce.teams.update(U,{managerId:Q,managerType:"agent"}).catch(()=>{});const B=ke.length>0?` (${ke.length} failed: ${ke[0]})`:"";O({ok:ne>0,message:`Team "${Jp(F,o)}" deployed with ${ne} agent(s)${B}`})}catch(Z){O({ok:!1,message:`Failed: ${Z}`})}finally{_(!1)}};if(ee)return s.jsx(_i,{type:ee.type,name:ee.name,onBack:()=>H(null)});if(g){const F={...y};g.announcements&&(F["ANNOUNCEMENT.md"]=g.announcements),g.norms&&(F["NORMS.md"]=g.norms);const Z={type:"team",name:g.id,displayName:Jp(g,o),version:g.version,description:_4(g,o),author:g.author,category:g.category??"general",tags:g.tags??[],files:F,team:{members:g.members.map(Q=>({name:j4(g,Q.name??Q.roleName??Q.templateId??"Agent",o),role:Q.role??"worker",roleName:Q.roleName??Q.templateId,count:Q.count??1,skills:Q.skills??[]}))}},U=s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsx("div",{className:"px-5 py-3 border-b border-border-default bg-surface-elevated/30",children:s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider",children:n("teamStore.teamComposition")})}),s.jsx("div",{className:"p-5 space-y-2",children:g.members.map((Q,ne)=>{const ke=j4(g,Q.name??Q.roleName??Q.templateId??"Agent",o);return s.jsxs("div",{className:"flex items-center gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[s.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center text-sm font-bold shrink-0 ${Q.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:(ke[0]??"?").toUpperCase()}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-fg-primary font-medium",children:ke}),s.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] capitalize font-medium ${Q.role==="manager"?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:Q.role??"worker"}),(Q.count??1)>1&&s.jsxs("span",{className:"text-[10px] text-fg-muted",children:["×",Q.count]})]}),(Q.roleName||Q.templateId)&&s.jsx("div",{className:"text-[10px] text-fg-tertiary font-mono mt-0.5",children:Q.roleName??Q.templateId})]}),Q.skills&&Q.skills.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 shrink-0",children:[Q.skills.slice(0,3).map(B=>s.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-surface-elevated text-fg-muted rounded border border-border-default",children:B},B)),Q.skills.length>3&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",Q.skills.length-3]})]})]},ne)})})]});return s.jsx(s.Fragment,{children:s.jsx(_i,{type:"team",name:g.id,onBack:()=>{x(null),O(null)},readOnly:!0,initialManifest:Z,contentSlot:U,actionSlot:s.jsxs(s.Fragment,{children:[j&&s.jsx("span",{className:`text-xs ${j.ok?"text-green-500":"text-red-500"}`,children:j.message}),s.jsx("button",{onClick:()=>{W(g)},disabled:S,className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors font-medium disabled:opacity-50",children:n(S?"teamStore.deploying":"teamStore.deployTeam")})]})})})}return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{"data-electron-drag":!0,className:"px-6 h-14 flex items-center justify-between shrink-0 gap-3",children:[s.jsx("h2",{className:"text-lg font-semibold",children:n("teamStore.title")}),s.jsx("input",{type:"text",placeholder:n("teamStore.searchPlaceholder"),value:l,onChange:F=>c(F.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"})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:C?s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:Array.from({length:4}).map((F,Z)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},Z))}):d.length===0&&p.length===0?s.jsxs("div",{className:"text-center py-20",children:[s.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"◉"}),s.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:l?n("teamStore.noResults",{search:l}):n("teamStore.noTeams")}),s.jsx("div",{className:"text-fg-tertiary text-sm",children:n(l?"teamStore.noResultsHint":"teamStore.noTeamsHint")})]}):s.jsxs(s.Fragment,{children:[d.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[s.jsx("h3",{className:"section-title",children:n("teamStore.builtin")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:n("teamStore.available",{count:d.length})})]}),s.jsx(Ar,{columns:2,children:d.map(F=>s.jsx(ia,{type:"team",name:Jp(F,o),description:_4(F,o),seed:F.id,icon:F.icon||"users",version:F.version,category:F.category,tags:F.tags,authorLabel:F.author,hideStats:!0,showTypeBadge:!1,cornerLabel:n("teamStore.builtin"),onClick:()=>x(F)},F.id))})]}),p.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:n("teamStore.markusHub")}),s.jsx(Ar,{columns:2,children:p.map(F=>s.jsx(hW,{item:F,localInfo:P.get(_c(F)),purchased:Kd(F,$),onStatusChange:K,highlight:F.id===e,onHighlightDone:t,onViewDetail:Z=>H({type:"team",name:Z})},F.id))})]})]})})]})}function hW({item:e,localInfo:t,purchased:n,onStatusChange:r,highlight:o,onHighlightDone:l,onViewDetail:c}){const{t:d}=dt(["store"]),[m,p]=k.useState(!1),[h,g]=k.useState(""),x=k.useRef(null),[y,w]=k.useState(!1);k.useEffect(()=>{if(o&&x.current){x.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const X=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(X)}},[o,l]);const C=t?.installed??!1,T=C&&e.version&&t?.localVersion&&fW(e.version,t.localVersion),S=(e.priceCents??0)>0,_=S?`$${((e.priceCents??0)/100).toFixed(2)}`:null,j=async X=>{if(X.stopPropagation(),!m){p(!0),g("");try{await ki(e),g(T?d("card.upgraded"):d("card.installed")+"!"),r()}catch(ee){const H=ee instanceof Error?ee.message:"";H.includes("402")||H.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{p(!1)}}},O=async X=>{if(X.stopPropagation(),!m){p(!0),g("");try{await Ug(e,H=>{H==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):H==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),r()):g("")}catch(ee){g(ee instanceof Error?ee.message:d("card.failed"))}finally{p(!1)}}},P=e.slug&&e.author?.username?`${it.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,D=()=>{C&&c?c(_c(e)):P&&window.open(P,"_blank","noopener,noreferrer")},$=s.jsxs(s.Fragment,{children:[T?s.jsx("button",{onClick:X=>{j(X)},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?d("card.upgrading"):d("card.upgrade",{version:e.version})}):C?s.jsxs("button",{onClick:X=>{j(X)},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:[d("card.installed"),t?.localVersion?` v${t.localVersion}`:""]}):S&&!n?s.jsx("button",{onClick:X=>{O(X)},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?h||d("card.installing"):s.jsxs(s.Fragment,{children:[d("card.buy","Buy")," ",_]})}):s.jsx("button",{onClick:X=>{j(X)},disabled:m,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:d(m?"card.installing":"card.install")}),h&&s.jsx("span",{className:`text-[10px] ${h===d("card.failed")||h===d("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:h})]});return s.jsx("div",{ref:x,className:y?"animate-pulse":"",children:s.jsx(ia,{type:"team",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"users",cover:e.thumbnailUrl,hubBase:it.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:D,actions:$})})}function eh(e,t){return e.i18n?.[t]?.displayName||e.name}function th(e,t){return e.i18n?.[t]?.description||e.description||""}function K3(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const l=n[o]??0,c=r[o]??0;if(l>c)return!0;if(l<c)return!1}return!1}const gW={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 bW({item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o}){const{t:l}=dt(["store"]),[c,d]=k.useState(!1),m=e.name.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed",p=t.find(S=>S.name===e.name||S.name===m||!!e.slug&&S.name===e.slug),h=!!p,g=h&&e.version&&p?.version&&K3(e.version,p.version),x=(e.priceCents??0)>0,[y,w]=k.useState(""),C=async()=>{if(!c){d(!0),w("");try{await ki(e),r(g?`Upgraded ${e.name}`:`Installed ${e.name}`,"success"),o()}catch(S){const _=S instanceof Error?S.message:"";_.includes("402")||_.includes("Purchase required")?r(l("card.purchaseRequired"),"error"):r(l("card.failed"),"error")}finally{d(!1)}}},T=async()=>{if(!c){d(!0),w("");try{await Ug(e,_=>{_==="checkout_opened"?w(l("card.waitingPurchase","Waiting for purchase...")):_==="installing"&&w(l("card.installing"))})==="installed"&&(r(`Purchased & installed ${e.name}`,"success"),o()),w("")}catch(S){r(S instanceof Error?S.message:l("card.failed"),"error"),w("")}finally{d(!1)}}};if(g)return s.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(h)return s.jsxs("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:[l("card.installed"),p?.version?` (v${p.version})`:""]});if(x&&!n){const S=`$${((e.priceCents??0)/100).toFixed(2)}`;return s.jsx("span",{className:"inline-flex items-center gap-1.5",children:s.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"):s.jsxs(s.Fragment,{children:[l("card.buy","Buy")," ",S]})})})}return s.jsx("button",{onClick:()=>{C()},disabled:c,className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:l(c?"card.installing":"card.install")})}function M4({item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o,highlight:l,onHighlightDone:c,type:d="skill"}){const m=k.useRef(null),[p,h]=k.useState(!1);k.useEffect(()=>{if(l&&m.current){m.current.scrollIntoView({behavior:"smooth",block:"center"}),h(!0);const y=setTimeout(()=>{h(!1)},4e3);return()=>clearTimeout(y)}},[l,c]);const g=e.slug&&e.author?.username?`${it.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,x=()=>{g&&window.open(g,"_blank","noopener,noreferrer")};return s.jsx("div",{ref:m,className:p?"animate-pulse":"",children:s.jsx(ia,{type:d,showTypeBadge:d!=="skill",name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||Bd(e.slug||e.name,e.category),cover:e.thumbnailUrl,hubBase:it.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:x,actions:s.jsx(bW,{item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o})})})}function xW({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:r}=dt(["store","common"]),o=r.language,l=Bo(),[c,d]=k.useState("skills"),[m,p]=k.useState(null),[h,g]=k.useState(new Set),[x,y]=k.useState([]),[w,C]=k.useState(null),[T,S]=k.useState([]),[_,j]=k.useState(0),[O,P]=k.useState(1),[D,$]=k.useState([]),[X,ee]=k.useState(""),[H,K]=k.useState("score"),[ae,W]=k.useState(""),[F,Z]=k.useState(!1),[U,Q]=k.useState([]),[ne,ke]=k.useState(!1),[B,q]=k.useState([]),[le,I]=k.useState(""),[Ae,$e]=k.useState(!1),[Oe,We]=k.useState([]),[st,mt]=k.useState([]),[At,gt]=k.useState(new Set),[jt,Jt]=k.useState(!1),[Rt,be]=k.useState(""),Me=[{id:"skills",labelKey:"skillStore.tabs.all"},{id:"skillhub",labelKey:"skillStore.tabs.skillhub"},{id:"skillssh",labelKey:"skillStore.tabs.skillssh"}],qe=(V,ye="success")=>{p({text:V,type:ye}),setTimeout(()=>p(null),ye==="error"?1e4:4e3)},ot=k.useCallback(async()=>{try{const V=await Ce.skills.list();y(V.skills)}catch{}},[]),ft=k.useCallback(async()=>{ke(!0);try{const V=await Ce.skills.builtin();Q(V.skills)}catch{}ke(!1)},[]),se=k.useCallback(async V=>{Z(!0);try{const ye=await Ce.skills.registrySkillhub({q:V?.q,category:V?.category,page:V?.page??1,limit:24,sort:V?.sort??H});S(ye.skills),j(ye.total),ye.categories?.length&&$(ye.categories)}catch{}Z(!1)},[H]),Be=k.useCallback(async V=>{$e(!0);try{const ye=await Ce.skills.registrySkillssh(V);q(ye.skills)}catch{}$e(!1)},[]),Xe=k.useCallback(async V=>{Jt(!0);try{const ye=V?it.search({type:"skill",q:V,limit:50}):wi(Tr.hubSkills)??it.search({type:"skill",limit:50}),Qe=it.search({subtype:"connector",q:V||void 0,limit:50}).catch(()=>({items:[]})),[pe,ve]=await Promise.all([ye,Qe,it.isAuthenticated()?it.purchases.mine().then(xt=>gt(new Set(xt.purchases.map(Dt=>Dt.itemId)))).catch(()=>{}):Promise.resolve()]);let Ye=pe?.items??[],nt=ve?.items??[];if(e){const xt=Ye.some(ct=>ct.id===e),Dt=nt.some(ct=>ct.id===e);if(!xt&&!Dt)try{const{item:ct}=await it.getItem(e);ct?.subtype==="connector"?nt=[ct,...nt]:ct?Ye=[ct,...Ye]:t?.()}catch{t?.()}else xt&&(Ye=[Ye.find(Xt=>Xt.id===e),...Ye.filter(Xt=>Xt.id!==e)]),Dt&&(nt=[nt.find(Xt=>Xt.id===e),...nt.filter(Xt=>Xt.id!==e)])}We(Ye),mt(nt)}catch{}Jt(!1)},[e,t]);k.useEffect(()=>{ot(),ft(),se(),Be()},[]),k.useEffect(()=>{c==="skills"&&Xe(Rt)},[c,Rt,Xe]);const Ge=async V=>{g(ye=>new Set(ye).add(V.name));try{const ye=await Ce.skills.install({name:V.name,source:"skillhub",slug:V.slug,sourceUrl:V.homepage,description:V.description_zh??V.description,category:"custom",version:V.version});await ot(),qe(`"${V.name}" installed (${ye.method}) → ${ye.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{qe(`Download failed for "${V.name}". You can try manually from: ${V.homepage}`,"error")}g(ye=>{const Qe=new Set(ye);return Qe.delete(V.name),Qe})},et=async V=>{g(ye=>new Set(ye).add(V.name));try{const ye=await Ce.skills.install({name:V.name,source:"skillssh",sourceUrl:V.url,githubRepo:`${V.author}/${V.repo}`,githubSkillPath:V.name});await ot(),qe(`"${V.name}" installed (${ye.method}) → ${ye.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{qe(`Download failed for "${V.name}". You can try manually from: ${V.url}`,"error")}g(ye=>{const Qe=new Set(ye);return Qe.delete(V.name),Qe})},yt=async V=>{g(ye=>new Set(ye).add(V.name));try{const ye=await Ce.skills.install({name:V.name,source:"builtin"});await ot(),await ft(),qe(`"${V.name}" installed (${ye.method}) → ${ye.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(ye){qe(`Install failed for "${V.name}": ${ye}`,"error")}g(ye=>{const Qe=new Set(ye);return Qe.delete(V.name),Qe})},he=B.filter(V=>{if(!le)return!0;const ye=le.toLowerCase();return V.name.toLowerCase().includes(ye)||V.repo.toLowerCase().includes(ye)});if(w){const V=w,ye={};V.instructions&&(ye["SKILL.md"]=V.instructions);const Qe={type:"skill",name:V.name,displayName:eh(V,o),version:V.version,description:th(V,o),author:V.author??"",category:V.category??"general",tags:V.tags,files:ye,skill:{skillFile:V.instructions?"SKILL.md":"",requiredPermissions:V.requiredPermissions,mcpServers:void 0,alwaysOn:!1}},pe=V.installed&&V.installedVersion&&K3(V.version,V.installedVersion)?s.jsx("button",{onClick:()=>{yt(V)},disabled:h.has(V.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:h.has(V.name)?n("card.upgrading"):n("card.upgrade",{version:V.version})}):V.installed?s.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:[s.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})}),n("card.installed"),V.installedVersion?` v${V.installedVersion}`:""]}):s.jsx("button",{onClick:()=>{yt(V)},disabled:h.has(V.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:h.has(V.name)?n("card.installing"):n("card.install")}),ve=s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.details")}),s.jsxs("div",{className:"space-y-2.5 text-sm",children:[V.category&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.category")}),s.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium capitalize ${gW[V.category]??"bg-gray-500/15 text-fg-secondary"}`,children:V.category})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.version")}),s.jsx("span",{className:"text-fg-secondary font-mono text-xs",children:V.version})]}),V.hasMcpServers&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.integration")}),s.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] bg-purple-500/15 text-purple-400",children:"MCP"})]}),V.hasInstructions&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.instructions")}),s.jsx("span",{className:"text-green-500 text-xs",children:"✓"})]})]})]}),(V.requiredPermissions.length>0||V.tags.length>0)&&s.jsxs("div",{className:"space-y-4",children:[V.requiredPermissions.length>0&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.permissions")}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:V.requiredPermissions.map(Ye=>s.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:Ye},Ye))})]}),V.tags.length>0&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.tags")}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:V.tags.map(Ye=>s.jsx("span",{className:"px-2.5 py-1 text-xs bg-surface-elevated text-fg-secondary rounded-lg border border-border-default/50",children:Ye},Ye))})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx(_i,{type:"skill",name:V.name,onBack:()=>C(null),readOnly:!0,initialManifest:Qe,actionSlot:pe,contentSlot:ve}),m&&s.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 s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:`${l?"px-4":"px-6"} shrink-0`,children:[s.jsx("div",{"data-electron-drag":!0,className:"flex items-center h-14",children:s.jsx("h2",{className:"text-lg font-semibold",children:n("skillStore.title")})}),s.jsx("div",{className:`flex ${l?"flex-wrap":""} gap-1 pb-2 overflow-x-auto scrollbar-hide`,children:Me.map(V=>s.jsx("button",{onClick:()=>d(V.id),className:`px-3 py-1.5 text-xs rounded-lg transition-colors shrink-0 ${c===V.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:n(V.labelKey)},V.id))})]}),m&&s.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 V=Rt.trim().toLowerCase(),ye=V?U.filter(ve=>eh(ve,o).toLowerCase().includes(V)||th(ve,o).toLowerCase().includes(V)):U,Qe=ne&&jt,pe=ye.length===0&&Oe.length===0&&st.length===0;return s.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"} space-y-8`,children:[s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("input",{value:Rt,onChange:ve=>be(ve.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"}`})}),Qe&&pe?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((ve,Ye)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},Ye))}):pe?s.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[s.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◇"}),s.jsx("div",{children:n("skillStore.noBuiltin")}),s.jsx("div",{className:"text-xs mt-1",children:n("skillStore.noBuiltinHint")})]}):s.jsxs(s.Fragment,{children:[ye.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[s.jsx("h3",{className:"section-title",children:n("skillStore.tabs.builtin")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:n("skillStore.builtinCount",{count:ye.length})})]}),s.jsx(Ar,{columns:3,children:ye.map(ve=>s.jsx(ia,{type:"skill",name:eh(ve,o),description:th(ve,o),seed:ve.name,icon:Bd(ve.name,ve.category),version:ve.version,category:ve.category,tags:ve.tags,authorLabel:ve.author||void 0,installed:ve.installed,hideStats:!0,showTypeBadge:!1,cornerLabel:ve.installed?void 0:n("skillStore.tabs.builtin"),onClick:()=>C(ve)},ve.name))})]}),Oe.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:n("skillStore.tabs.markusHub")}),s.jsx(Ar,{columns:3,children:Oe.map(ve=>s.jsx(M4,{item:ve,installedSkills:x,purchased:Kd(ve,At),onMsg:qe,onRefresh:()=>{ot(),Xe(Rt)},highlight:ve.id===e,onHighlightDone:t},ve.id))})]}),st.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"mb-3",children:[s.jsx("h3",{className:"section-title",children:n("tabs.connectors")}),s.jsx("p",{className:"text-xs text-fg-tertiary mt-0.5",children:n("connectorStore.emptyHint","连接器让智能体接入外部工具与服务 (MCP)")})]}),s.jsx(Ar,{columns:3,children:st.map(ve=>s.jsx(M4,{item:ve,type:"connector",installedSkills:x,purchased:Kd(ve,At),onMsg:qe,onRefresh:()=>{ot(),Xe(Rt)},highlight:ve.id===e,onHighlightDone:t},ve.id))})]})]})]})})(),c==="skillhub"&&s.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`,children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[s.jsxs("select",{value:X,onChange:V=>{ee(V.target.value),P(1),se({q:ae||void 0,category:V.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:[s.jsx("option",{value:"",children:n("skillStore.allCategories")}),D.map(V=>s.jsx("option",{value:V,children:V},V))]}),s.jsxs("select",{value:H,onChange:V=>{K(V.target.value),P(1),se({q:ae||void 0,category:X||void 0,page:1,sort:V.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:[s.jsx("option",{value:"score",children:n("skillStore.sortScore")}),s.jsx("option",{value:"downloads",children:n("skillStore.sortDownloads")}),s.jsx("option",{value:"stars",children:n("skillStore.sortStars")}),s.jsx("option",{value:"installs",children:n("skillStore.sortInstalls")})]}),!l&&s.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:s.jsx("a",{href:"https://skillhub.tencent.com",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),s.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[s.jsx("input",{value:ae,onChange:V=>W(V.target.value),onKeyDown:V=>{V.key==="Enter"&&(P(1),se({q:ae||void 0,category:X||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"}),s.jsx("button",{onClick:()=>{P(1),se({q:ae||void 0,category:X||void 0,page:1})},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg shrink-0",children:"Search"})]}),F?s.jsx("div",{className:"text-center text-fg-tertiary py-20",children:s.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillhub")})}):T.length===0?s.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[s.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◎"}),s.jsx("div",{children:n("skillStore.noSkillhub")})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"text-xs text-fg-tertiary mb-3",children:n("skillStore.skillhubTotal",{count:_.toLocaleString()})}),s.jsx(Ar,{columns:3,children:T.map(V=>{const ye=x.some(Qe=>Qe.name===V.name||Qe.name===V.slug);return s.jsx(ia,{type:"skill",name:V.name,description:V.description_zh??V.description??"",seed:V.slug,icon:Bd(V.slug||V.name,V.tags?.[0]),version:V.version,authorLabel:"SkillHub",showTypeBadge:!1,tags:V.tags,installed:ye,hideStats:!0,onClick:()=>window.open(V.homepage,"_blank","noopener,noreferrer"),footerLeft:s.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary",children:[V.stars>0&&s.jsxs("span",{className:"text-amber-600",children:["★ ",V.stars.toLocaleString()]}),V.downloads>0&&s.jsxs("span",{children:[V.downloads>=1e4?`${(V.downloads/1e4).toFixed(1)}万`:V.downloads.toLocaleString()," ",n("skillStore.downloads")]})]}),actions:ye?void 0:s.jsx("button",{onClick:()=>{Ge(V)},disabled:h.has(V.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:h.has(V.name)?"...":n("card.install")})},V.slug)})}),_>24&&s.jsxs("div",{className:"flex items-center justify-center gap-2 mt-6",children:[s.jsx("button",{disabled:O<=1,onClick:()=>{const V=O-1;P(V),se({q:ae||void 0,category:X||void 0,page:V})},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")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:n("skillStore.pageInfo",{current:O,total:Math.ceil(_/24)})}),s.jsx("button",{disabled:O>=Math.ceil(_/24),onClick:()=>{const V=O+1;P(V),se({q:ae||void 0,category:X||void 0,page:V})},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"&&s.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`,children:[s.jsxs("div",{className:`flex ${l?"flex-wrap":""} items-center gap-2 mb-5`,children:[s.jsx("input",{value:le,onChange:V=>I(V.target.value),onKeyDown:V=>{V.key==="Enter"&&le.trim()&&Be(le)},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"}`}),s.jsx("button",{onClick:()=>{le.trim()&&Be(le)},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg shrink-0",children:"Search"}),!l&&s.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:s.jsx("a",{href:"https://skills.sh",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),Ae?s.jsx("div",{className:"text-center text-fg-tertiary py-20",children:s.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillssh")})}):he.length===0?s.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[s.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"⬡"}),s.jsx("div",{children:n("skillStore.browseSkillssh")}),s.jsx("div",{className:"text-xs mt-1",children:n("skillStore.browseSkillsshHint")})]}):s.jsx(Ar,{columns:3,children:he.map(V=>{const ye=x.some(Qe=>Qe.name===V.name);return s.jsx(ia,{type:"skill",name:V.name,description:V.description||"",seed:`${V.author}-${V.name}`,icon:Bd(V.name),authorLabel:`${V.author}/${V.repo}`,showTypeBadge:!1,installed:ye,hideStats:!0,cornerLabel:ye?void 0:"skills.sh",onClick:()=>window.open(V.url,"_blank","noopener,noreferrer"),footerLeft:V.installs?s.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[V.installs," installs"]}):void 0,actions:ye?void 0:s.jsx("button",{onClick:()=>{et(V)},disabled:h.has(V.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:h.has(V.name)?"...":n("card.install")})},`${V.author}-${V.name}`)})})]})]})}const yW=["agent","team","skill","connector"];function nh({title:e,subtitle:t,onMore:n,moreLabel:r}){return s.jsxs("div",{className:"flex items-end justify-between mb-3",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"section-title",children:e}),t&&s.jsx("p",{className:"section-subtitle",children:t})]}),n&&s.jsxs("button",{className:"section-link",onClick:n,children:[r??"View all"," →"]})]})}function vW({item:e,onOpen:t}){const n=Ko(e.subtype==="connector"?"connector":e.itemType),r=Bg(n,e.slug||e.name),o=Ti[n];return s.jsxs("button",{onClick:t,className:"group relative w-full overflow-hidden rounded-2xl text-left h-44 md:h-52",style:{background:r},children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-black/55 via-black/20 to-transparent"}),s.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:s.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"})}),s.jsxs("div",{className:"relative h-full flex flex-col justify-end p-5 md:p-6",children:[s.jsxs("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:["★ Featured · ",o.label]}),s.jsx("h2",{className:"text-xl md:text-2xl font-bold text-white drop-shadow-sm",children:e.name}),s.jsx("p",{className:"text-sm text-white/85 truncate max-w-lg mt-1",children:e.description}),s.jsxs("div",{className:"flex items-center gap-3 mt-3 text-white/80 text-xs",children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(x0,{name:e.author?.displayName,username:e.author?.username,avatarUrl:e.author?.avatarUrl,hubBase:it.getUrl(),size:18}),e.author?.displayName||e.author?.username]}),s.jsxs("span",{children:["↓ ",Eo(e.downloadCount)]}),(e.priceCents??0)>0?s.jsxs("span",{className:"badge-paid",children:["$",((e.priceCents??0)/100).toFixed(0)]}):s.jsx("span",{className:"badge-free",children:"Free"})]})]})]})}function R4({items:e,onOpen:t}){return s.jsx(Ar,{columns:3,children:e.map(n=>s.jsx(ia,{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:it.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 O4(){return s.jsx(Ar,{columns:3,children:Array.from({length:6}).map((e,t)=>s.jsx("div",{className:"h-64 rounded-2xl skeleton"},t))})}function wW({onOpenType:e}){const{t}=dt(["store","common"]),[n,r]=k.useState([]),[o,l]=k.useState(!0);k.useEffect(()=>{let g=!1;return(async()=>{l(!0);try{const x=await it.search({limit:60,sort:"popular"});g||r(x.items??[])}catch{g||r([])}finally{g||l(!1)}})(),()=>{g=!0}},[]);const c=k.useMemo(()=>{const g=n.filter(y=>y.featured);return(g.length>0?g:n).slice(0,3)},[n]),d=k.useMemo(()=>[...n].sort((g,x)=>(x.trendingScore??x.downloadCount)-(g.trendingScore??g.downloadCount)).slice(0,10),[n]),m=k.useMemo(()=>[...n].sort((g,x)=>(x.createdAt||"").localeCompare(g.createdAt||"")).slice(0,10),[n]),p=k.useMemo(()=>{const g=new Map;for(const x of n){const y=x.author?.username||x.author?.id;if(!y)continue;const w=g.get(y)??{author:x.author,downloads:0,count:0};w.downloads+=x.downloadCount||0,w.count+=1,g.set(y,w)}return[...g.values()].sort((x,y)=>y.downloads-x.downloads).slice(0,6)},[n]),h=g=>e(Ko(g.subtype==="connector"?"connector":g.itemType),g.id);return s.jsxs("div",{className:"flex-1 overflow-y-auto px-5 md:px-7 py-5 space-y-8",children:[s.jsxs("div",{className:"hero-glow rounded-2xl border border-border-subtle bg-surface-secondary p-5 md:p-6",children:[s.jsx("h1",{className:"text-2xl font-bold text-gradient tracking-tight",children:t("discover.title","Markus 广场")}),s.jsx("p",{className:"text-sm text-fg-tertiary mt-1 max-w-2xl",children:t("discover.subtitle","发现社区共享的智能体、AI 小队、技能与连接器 — 由创作者共建的开放生态。")}),s.jsx("div",{className:"flex flex-wrap gap-2 mt-4",children:yW.map(g=>s.jsxs("button",{onClick:()=>e(g),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 ${Ti[g].gradient} hover:opacity-90 transition-opacity`,children:[Ti[g].labelZh,s.jsx("span",{className:"opacity-70",children:Ti[g].label})]},g))})]}),o?s.jsx("div",{className:"h-52 rounded-2xl skeleton"}):c.length>0?s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:c.map(g=>s.jsx(vW,{item:g,onOpen:()=>h(g)},g.id))}):null,s.jsxs("section",{children:[s.jsx(nh,{title:t("discover.trending","热门趋势"),subtitle:t("discover.trendingSub","社区中下载与评分增长最快的资产")}),o?s.jsx(O4,{}):d.length>0?s.jsx(R4,{items:d,onOpen:h}):s.jsx(kW,{})]}),s.jsxs("section",{children:[s.jsx(nh,{title:t("discover.fresh","新鲜上架"),subtitle:t("discover.freshSub","来自创作者的最新作品")}),o?s.jsx(O4,{}):m.length>0?s.jsx(R4,{items:m,onOpen:h}):null]}),p.length>0&&s.jsxs("section",{children:[s.jsx(nh,{title:t("discover.topCreators","顶尖创作者"),subtitle:t("discover.topCreatorsSub","生态贡献榜")}),s.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:p.map((g,x)=>s.jsxs("div",{className:"asset-card p-4 flex flex-col items-center text-center",children:[s.jsxs("div",{className:"relative",children:[s.jsx(x0,{name:g.author?.displayName,username:g.author?.username,avatarUrl:g.author?.avatarUrl,hubBase:it.getUrl(),size:48,verified:x<3}),x<3&&s.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:x+1})]}),s.jsx("div",{className:"text-sm font-semibold text-fg-primary truncate w-full mt-2",children:g.author?.displayName||g.author?.username}),s.jsxs("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:[g.count," 作品 · ↓ ",Eo(g.downloads)]})]},g.author?.username||x))})]})]})}function kW(){const{t:e}=dt(["store"]);return s.jsxs("div",{className:"text-center py-12 rounded-2xl border border-dashed border-border-default",children:[s.jsx("div",{className:"text-3xl mb-2 opacity-40",children:"✦"}),s.jsx("div",{className:"text-fg-secondary font-medium",children:e("discover.empty","生态正在成长中")}),s.jsx("div",{className:"text-fg-tertiary text-sm mt-1",children:e("discover.emptyHint","成为首批创作者,分享你的第一个资产")})]})}function Ad(e,t,n){return e.i18n?.[n]?.[t]}function SW(){const{t:e,i18n:t}=dt(["store","common"]),n=Bo(),r=t.language,[o,l]=k.useState([]),[c,d]=k.useState({}),[m,p]=k.useState(new Set),[h,g]=k.useState(null),[x,y]=k.useState(!0),[w,C]=k.useState(""),[T,S]=k.useState("all"),[_,j]=k.useState(null),O=k.useCallback(async()=>{y(!0);try{const[$,X,ee,H]=await Promise.all([Ce.builder.artifacts.list().catch(()=>({artifacts:[]})),Ce.builder.artifacts.installed().catch(()=>({installed:{}})),Ce.skills.updates().catch(()=>({updates:[],count:0})),Ce.skills.builtin().catch(()=>({skills:[]}))]),K={};for(const F of ee.updates)K[F.name]={availableVersion:F.availableVersion,installedVersion:F.installedVersion,displayName:F.displayName,description:F.description};d(K);const ae=$.artifacts.filter(F=>{const Z=`${F.type}/${F.name}`;return!!X.installed[Z]}),W=new Set(ae.filter(F=>F.type==="skill").map(F=>F.name));for(const F of H.skills)!F.installed||W.has(F.name)||!(X.installed[`skill/${F.name}`]||K[F.name])&&!F.updateAvailable||!X.installed[`skill/${F.name}`]&&!K[F.name]||(ae.push({type:"skill",name:F.name,meta:{displayName:F.i18n?.[r]?.displayName||F.name,description:F.i18n?.[r]?.description||F.description||"",version:F.installedVersion||F.version,author:F.author,category:F.category,tags:F.tags,i18n:F.i18n},path:"",updatedAt:""}),W.add(F.name));for(const[F,Z]of Object.entries(K))W.has(F)||(ae.push({type:"skill",name:F,meta:{displayName:Z.displayName||F,description:Z.description||"",version:Z.installedVersion},path:"",updatedAt:""}),W.add(F));l(ae)}catch{}y(!1)},[r]);k.useEffect(()=>{O()},[O]),k.useEffect(()=>{const $=()=>{O()};return window.addEventListener("markus:data-changed",$),()=>window.removeEventListener("markus:data-changed",$)},[O]),k.useEffect(()=>{if(!h)return;const $=setTimeout(()=>g(null),3e3);return()=>clearTimeout($)},[h]);const P=async($,X)=>{if(!m.has($)){p(ee=>new Set(ee).add($));try{await Ce.skills.install({name:$,source:"builtin"});try{localStorage.removeItem("markus:template-updates-ack")}catch{}g({text:e("installedTab.updateSuccess",{name:$,version:X}),type:"success"}),window.dispatchEvent(new CustomEvent("markus:data-changed")),await O()}catch{g({text:e("installedTab.updateFailed",{name:$}),type:"error"})}p(ee=>{const H=new Set(ee);return H.delete($),H})}},D=o.filter($=>{if(T!=="all"&&$.type!==T)return!1;if(!w)return!0;const X=w.toLowerCase(),ee=(Ad($.meta,"displayName",r)||$.meta.displayName||$.name).toLowerCase(),H=(Ad($.meta,"description",r)||$.meta.description||"").toLowerCase();return ee.includes(X)||H.includes(X)}).sort(($,X)=>{const ee=$.type==="skill"&&c[$.name]?1:0;return(X.type==="skill"&&c[X.name]?1:0)-ee});return _?s.jsx(_i,{type:_.type,name:_.name,onBack:()=>j(null)}):s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{"data-electron-drag":!0,className:`${n?"px-4":"px-6"} h-14 flex items-center shrink-0 gap-3`,children:[s.jsx("h2",{className:"text-lg font-semibold",children:e("installedTab.title")}),Object.keys(c).length>0&&s.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]})]}),s.jsxs("div",{className:`flex flex-wrap items-center gap-2 ${n?"px-4":"px-6"} py-2 shrink-0`,children:[s.jsx("div",{className:"flex gap-1",children:["all","agent","team","skill"].map($=>s.jsx("button",{onClick:()=>S($),className:`px-3 py-1 text-xs rounded-md transition-colors ${T===$?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:e(`installedTab.filter${$==="all"?"All":$==="agent"?"Agents":$==="team"?"Teams":"Skills"}`)},$))}),s.jsx("div",{className:"flex-1 min-w-[120px]",children:s.jsx("input",{type:"text",placeholder:e("installedTab.searchPlaceholder"),value:w,onChange:$=>C($.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"})})]}),s.jsx("div",{className:`flex-1 overflow-y-auto ${n?"p-4":"p-7"}`,children:x?s.jsx("div",{className:"text-center text-fg-tertiary py-20 animate-pulse",children:e("installedTab.loading")}):D.length===0?s.jsxs("div",{className:"text-center py-20",children:[s.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),s.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:e("installedTab.noItems")}),s.jsx("div",{className:"text-fg-tertiary text-sm",children:e("installedTab.noItemsHint")})]}):s.jsx(Ar,{columns:3,children:D.map($=>{const X=Ad($.meta,"displayName",r)||$.meta.displayName||$.name,ee=Ad($.meta,"description",r)||$.meta.description||"",H=$.meta.version||"",K=$.meta.author||"",ae=$.meta.tags??[],W=$.meta.category||"",F=$.meta.icon,Z=$.type==="skill"?c[$.name]:void 0;return s.jsx(ia,{type:$.type,name:X,description:ee,seed:$.name,icon:F,author:null,authorLabel:K||void 0,version:Z?Z.installedVersion:H,category:W,tags:ae,installed:!Z,hideStats:!0,cornerLabel:Z?e("installedTab.updateAvailable"):void 0,onClick:()=>{$.path&&j({type:$.type,name:$.name})},actions:Z?s.jsx("button",{type:"button",disabled:m.has($.name),onClick:()=>{P($.name,Z.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($.name)?e("installedTab.updating"):e("installedTab.updateTo",{version:Z.availableVersion})}):void 0},`${$.type}/${$.name}`)})})}),h&&s.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 ${h.type==="success"?"bg-emerald-600 text-white":"bg-red-600 text-white"}`,children:h.text})]})}const NW=50,CW=30;function TW(e,t,n,r){const o=k.useRef(0),l=k.useRef(0),c=k.useCallback(m=>{o.current=m.touches[0].clientX,l.current=m.touches[0].clientY},[]),d=k.useCallback(m=>{const p=m.changedTouches[0].clientX-o.current,h=m.changedTouches[0].clientY-l.current,g=Math.abs(p),x=Math.abs(h);if(g<NW||Math.atan2(x,g)*(180/Math.PI)>CW)return;if(r?.scrollContainerRef?.current){const C=r.scrollContainerRef.current,T=C.scrollLeft<=1,S=C.scrollLeft+C.clientWidth>=C.scrollWidth-1;if(p>0&&!T||p<0&&!S)return}const w=e.findIndex(C=>C.id===t);p<0&&w<e.length-1?n(e[w+1].id):p>0&&w>0?n(e[w-1].id):p>0&&w===0&&r?.onSwipeOutLeft?r.onSwipeOutLeft():p<0&&w===e.length-1&&r?.onSwipeOutRight&&r.onSwipeOutRight()},[e,t,n,r]);return{onTouchStart:c,onTouchEnd:d}}const AW=["builder","discover","agents","teams","skills","installed"],EW={agent:"agents",team:"teams",skill:"skills",connector:"skills"};function Yh(e){return!!e&&AW.includes(e)}function D4(){const e=localStorage.getItem("markus_nav_installItem"),t=localStorage.getItem("markus_nav_storeTab");return{tab:Yh(t)?t:"builder",installId:e}}function _W({authUser:e}){const{t}=dt(["nav","store","common"]),n=k.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]),[r]=k.useState(D4),[o,l]=k.useState(r.tab),[c,d]=k.useState(r.installId),m=TW(n,o,l);k.useEffect(()=>{const h=D4();h.installId&&(d(h.installId),Yh(h.tab)&&l(h.tab),localStorage.removeItem("markus_nav_installItem"),localStorage.removeItem("markus_nav_storeTab"))},[]),k.useEffect(()=>{const h=g=>{const x=g.detail,y=x.params?.storeTab??localStorage.getItem("markus_nav_storeTab");Yh(y)&&l(y);const w=x.params?.installItem??localStorage.getItem("markus_nav_installItem");w&&d(w),localStorage.removeItem("markus_nav_storeTab"),localStorage.removeItem("markus_nav_installItem")};return window.addEventListener("markus:navigate",h),()=>window.removeEventListener("markus:navigate",h)},[]);const p=(h,g)=>{g&&d(g),l(EW[h]??"agents")};return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:m.onTouchStart,onTouchEnd:m.onTouchEnd,children:[s.jsxs("div",{className:"flex items-center shrink-0 overflow-x-auto scrollbar-hide",children:[s.jsx(x5,{className:"ml-2"}),n.map(h=>s.jsx("button",{onClick:()=>l(h.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 ${o===h.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:h.label},h.id))]}),s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[o==="builder"&&s.jsx(q3,{authUser:e}),o==="discover"&&s.jsx(wW,{onOpenType:p}),o==="agents"&&s.jsx(dW,{authUser:e,highlightItemId:c,onHighlightDone:()=>d(null)}),o==="teams"&&s.jsx(pW,{highlightItemId:c,onHighlightDone:()=>d(null)}),o==="skills"&&s.jsx(xW,{highlightItemId:c,onHighlightDone:()=>d(null)}),o==="installed"&&s.jsx(SW,{})]})]})}const L4="usageType",rh="profile";function jW({onComplete:e,theme:t,onThemeChange:n,skipProfile:r,onProfileUpdated:o}){const{t:l}=dt(["onboarding","common"]),[c,d]=k.useState(0),[m,p]=k.useState(""),[h,g]=k.useState(""),[x,y]=k.useState(""),[w,C]=k.useState(""),[T,S]=k.useState(!1),[_,j]=k.useState(""),[O,P]=k.useState(!1),[D,$]=k.useState(null);k.useEffect(()=>{Ce.auth.me().then(({user:be})=>{be.name&&p(be.name),be.email&&g(be.email),be.avatarUrl&&$(be.avatarUrl);const Me=be.name||be.email?.split("@")[0]||"";Me&&K(qe=>qe||l("usageType.defaultOrgName",{name:Me}))}).catch(()=>{}),Ce.settings.getOrg().then(({org:be})=>{be?.name&&be.name!=="My Organization"&&K(be.name)}).catch(()=>{}),yn()&&Ce.hubOrgs.invitations().then(be=>{be.invitations?.length>0&&ke(be.invitations)}).catch(()=>{})},[]);const[X,ee]=k.useState(null),[H,K]=k.useState(""),[ae,W]=k.useState(!1),[F,Z]=k.useState(!1),[U,Q]=k.useState(""),[ne,ke]=k.useState([]),[B,q]=k.useState(null),[le,I]=k.useState(null),Ae=async()=>{const be=H.trim();if(be){W(!0),Q("");try{if(await Ce.settings.updateOrg(be),yn()){const Me=await Ce.hubOrgs.mine(),qe=Me.orgs?.find(ot=>ot.role==="owner")??Me.orgs?.[0];qe?.id?await Ce.hubOrgs.update(qe.id,{name:be}):await Ce.hubOrgs.create(be)}Z(!0)}catch{Q(l("usageType.orgNameSaveFailed"))}finally{W(!1)}}},[$e,Oe]=k.useState(!0),We=async()=>{if(j(""),!m.trim()){j(l("profile.errors.nameRequired"));return}if(!h.trim()){j(l("profile.errors.emailRequired"));return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(h.trim())){j(l("profile.errors.emailInvalid"));return}if(x&&x.length<6){j(l("profile.errors.passwordTooShort"));return}if(x&&x!==w){j(l("profile.errors.passwordMismatch"));return}S(!0);try{const{user:be}=await Ce.auth.updateProfile(m.trim(),h.trim());x&&await Ce.auth.changePassword("",x),o?.(be),P(!0)}catch{j(l("profile.errors.saveFailed"))}finally{S(!1)}},st=[{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")}],mt=[{id:"welcome",title:l("welcome.title"),subtitle:l("welcome.subtitle"),content:s.jsx("p",{className:"text-fg-secondary text-sm leading-relaxed",children:s.jsx(Q7,{i18nKey:"welcome.description",ns:"onboarding",components:{strong:s.jsx("strong",{className:"text-fg-primary"})}})})},{id:L4,title:l("usageType.title",{defaultValue:"How will you use Markus?"}),subtitle:l("usageType.subtitle",{defaultValue:"This helps us tailor your experience."}),content:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("button",{onClick:()=>{ee("personal"),Z(!0)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${X==="personal"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[s.jsx("span",{className:"text-2xl",children:"👤"}),s.jsxs("div",{children:[s.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:l("usageType.personal",{defaultValue:"Personal"})}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:l("usageType.personalDesc",{defaultValue:"Individual use with your own AI agents."})})]})]}),s.jsxs("button",{onClick:()=>{ee("organization"),Z(!1)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${X==="organization"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[s.jsx("span",{className:"text-2xl",children:"🏢"}),s.jsxs("div",{children:[s.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:l("usageType.organization",{defaultValue:"Team & Enterprise"})}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:l("usageType.organizationDesc",{defaultValue:"For teams sharing licenses and collaborating."})})]})]})]}),X==="organization"&&s.jsxs("div",{className:"space-y-4 mt-4",children:[ne.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-xs text-fg-tertiary font-medium",children:l("usageType.pendingInvitations")}),ne.map(be=>s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 rounded-xl border border-amber-500/20 bg-amber-500/5",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:be.orgName}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:l("usageType.invitedBy",{name:be.invitedBy})})]}),s.jsx("button",{onClick:async()=>{q(be.orgId);try{await Ce.hubOrgs.acceptInvitation(be.orgId),I(be.orgId),Z(!0)}catch{}finally{q(null)}},disabled:B===be.orgId||le===be.orgId,className:"px-3 py-1.5 text-xs rounded-lg bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white transition-colors",children:le===be.orgId?l("usageType.accepted"):B===be.orgId?l("usageType.accepting"):l("usageType.acceptAndJoin")})]},be.orgId)),s.jsx("div",{className:"text-[11px] text-fg-tertiary text-center pt-1",children:l("usageType.orCreateNew")})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("usageType.orgNameLabel")}),s.jsx("input",{type:"text",value:H,onChange:be=>{K(be.target.value),Z(!1),Q("")},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"})]}),U&&s.jsx("p",{className:"text-xs text-red-500",children:U}),s.jsx("button",{onClick:()=>{Ae()},disabled:ae||!H.trim()||F,className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:l(ae?"common:saving":F?"usageType.orgNameSaved":"usageType.setOrgName")})]})]})},{id:rh,title:l("profile.title"),subtitle:l("profile.subtitle"),content:O?s.jsxs("div",{className:"flex items-center gap-3 bg-green-500/10 border border-green-500/30 rounded-xl p-4",children:[s.jsx("span",{className:"text-green-600 text-lg",children:"✓"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-green-600",children:l("profile.saved")}),s.jsxs("div",{className:"text-xs text-fg-secondary mt-0.5",children:[m," · ",h]})]})]}):s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"flex justify-center",children:s.jsx(b5,{currentUrl:D,name:m,size:64,targetType:"user"})}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.nameLabel")," ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"text",value:m,onChange:be=>p(be.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})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.emailLabel")," ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"email",value:h,onChange:be=>g(be.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"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("profile.newPasswordLabel")}),s.jsx("input",{type:"password",value:x,onChange:be=>y(be.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"})]}),x&&s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("profile.confirmPasswordLabel")}),s.jsx("input",{type:"password",value:w,onChange:be=>C(be.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"})]}),_&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:_}),s.jsx("button",{onClick:()=>{We()},disabled:T||!m.trim()||!h.trim(),className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:l(T?"common:saving":"profile.saveProfile")})]})},{id:"theme",title:l("theme.title"),subtitle:l("theme.subtitle"),content:s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"grid grid-cols-3 gap-3",children:st.map(be=>s.jsxs("button",{onClick:()=>n(be.value),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-5 transition-all ${t===be.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[s.jsx("span",{className:"text-2xl",children:be.icon}),s.jsx("span",{className:"text-sm font-medium text-fg-primary",children:be.label}),s.jsx("span",{className:"text-[11px] text-fg-tertiary leading-tight text-center",children:be.desc})]},be.value))}),s.jsxs("label",{className:"flex items-center gap-2.5 p-3 bg-surface-elevated/30 rounded-lg cursor-pointer group",children:[s.jsx("input",{type:"checkbox",checked:$e,onChange:be=>Oe(be.target.checked),className:"accent-brand-500 shrink-0"}),s.jsx("span",{className:"text-[11px] text-fg-tertiary",children:l("done.telemetry")})]})]})}],At=r?mt.filter(be=>be.id!==rh):mt,gt=At.findIndex(be=>be.id===L4),jt=At.findIndex(be=>be.id===rh),Jt=()=>{c===gt&>>=0&&!X||c===gt&&X==="organization"&&!F||c===jt&&jt>=0&&!O||(c<At.length-1?d(c+1):(fetch("/api/settings/telemetry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:$e})}).catch(()=>{}),e()))},Rt=At[c];return s.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4",children:s.jsx("div",{className:"w-full max-w-lg",children:s.jsxs("div",{className:"bg-surface-elevated rounded-2xl p-8",children:[s.jsx("div",{className:"flex gap-1.5 mb-8",children:At.map((be,Me)=>s.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${Me<=c?"bg-brand-500":"bg-surface-elevated"}`},Me))}),s.jsx("h2",{className:"text-2xl font-bold text-fg-primary",children:Rt.title}),s.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:Rt.subtitle}),Rt.content,s.jsxs("div",{className:"flex justify-between mt-8",children:[c>0?s.jsx("button",{onClick:()=>d(c-1),className:"px-4 py-2 text-sm text-fg-secondary hover:text-fg-primary transition-colors",children:l("common:back")}):s.jsx("span",{}),s.jsx("button",{onClick:Jt,disabled:jt>=0&&c===jt&&!O||gt>=0&&c===gt&&(!X||X==="organization"&&!F),className:`px-6 py-2.5 text-white text-sm rounded-xl transition-colors ${jt>=0&&c===jt&&!O||gt>=0&&c===gt&&(!X||X==="organization"&&!F)?"bg-brand-600/40 cursor-not-allowed":"bg-brand-600 hover:bg-brand-500"}`,children:c===At.length-1?l("getStarted"):l("common:next")})]})]})})})}const I4="markus:legal-consent",MW="https://markus.global";function RW({onLogin:e,hasOwner:t}){const{t:n,i18n:r}=dt("auth"),[o,l]=k.useState(null),[c,d]=k.useState(""),[m,p]=k.useState(!1),[h,g]=k.useState(""),[x,y]=k.useState(""),[w,C]=k.useState(!1),[T,S]=k.useState(!1),_=K=>{const ae=(r.language||"").toLowerCase().startsWith("zh")?"?lang=zh":"";return`${MW}${K}${ae}`},j=()=>{try{localStorage.setItem(I4,JSON.stringify({acceptedAt:new Date().toISOString(),terms:!0,privacy:!0}))}catch{}},O=()=>T?(j(),!0):(C(!1),requestAnimationFrame(()=>C(!0)),!1),P=async()=>{const K=yn(),ae=sa();if(!K||!ae){d(n("login.hubUnavailable"));return}const W=await Ce.auth.hubLogin(K,ae);if(window.markusDesktop?.clearPendingDeepLinkAuth?.(),W.cloudAiReady===!1)try{sessionStorage.setItem("markus:cloud-ai-warning",W.cloudAiError?n("login.cloudAiNotReady",{error:W.cloudAiError}):n("login.cloudAiNotReadyGeneric"))}catch{}e(W.user,W.needsOnboarding??!1,{fromHub:!0})},D=async(K,ae=!1)=>{if(!(!ae&&!O())){d(""),l(K??"hub");try{if(ae&&yn()&&sa()){await P();return}await na(K),await P()}catch(W){const F=W instanceof Error?W.message:"";if(!F.includes("cancelled")){if(!ae&&yn())return D(K,!0);d(F||n("login.hubUnavailable"))}}finally{l(null)}}},$=()=>{AD(),l(null),d("")};k.useEffect(()=>{const K=window.markusDesktop;if(!K?.peekPendingDeepLinkAuth&&!K?.consumePendingDeepLinkAuth)return;let ae=!1;return(async()=>{const W=K.peekPendingDeepLinkAuth?await K.peekPendingDeepLinkAuth():null;if(ae||!W)return;let F=!1;try{F=!!localStorage.getItem(I4)}catch{}if(!T&&!F){d(n("login.consentRequired"));return}F&&!T&&S(!0),j();const Z=K.consumePendingDeepLinkAuth?await K.consumePendingDeepLinkAuth():W;if(!(ae||!Z)){d(""),l("hub");try{if(!await TD(Z)||!yn()||!sa()){d(n("login.hubUnavailable"));return}await P()}catch{d(n("login.hubUnavailable"))}finally{ae||l(null)}}})().catch(()=>{}),()=>{ae=!0}},[T]);const X=async K=>{if(K.preventDefault(),!(!h.trim()||!x)&&O()){d(""),l("local");try{const{user:ae,needsOnboarding:W}=await Ce.auth.login(h.trim(),x);e(ae,W??!1)}catch{d(n("login.invalidCredentials"))}finally{l(null)}}},ee=n(t?"login.welcomeBack":"login.getStarted"),H="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 s.jsxs("div",{className:"min-h-dvh bg-surface-primary flex flex-col items-center justify-center p-4 relative overflow-hidden",children:[s.jsxs("div",{className:"pointer-events-none absolute inset-0 overflow-hidden",children:[s.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]"}),s.jsx("div",{className:"absolute top-1/4 -left-40 h-[26rem] w-[26rem] rounded-full bg-brand-400/10 blur-[100px]"}),s.jsx("div",{className:"absolute -bottom-40 -right-32 h-[34rem] w-[34rem] rounded-full bg-brand-600/10 blur-[110px]"})]}),s.jsxs("div",{className:"w-full max-w-[26rem] relative z-10 flex-1 flex flex-col justify-center",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.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"}),s.jsx("div",{className:"text-[1.75rem] leading-none font-extrabold tracking-tight text-fg-primary mb-2",children:"Markus"}),s.jsx("div",{className:"text-sm text-fg-tertiary",children:ee})]}),s.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?s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-base font-semibold text-fg-primary",children:n("login.localTitle")}),s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:n("login.localAccountHint")})]}),s.jsxs("form",{onSubmit:X,className:"space-y-3",children:[s.jsx("input",{type:"email",value:h,onChange:K=>g(K.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}),s.jsx("input",{type:"password",value:x,onChange:K=>y(K.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&&s.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&&s.jsx("p",{className:"text-[11px] text-fg-tertiary",children:n("login.defaultCredentials")}),s.jsx("button",{type:"submit",disabled:o==="local"||!h||!x,className:"w-full h-11 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-semibold rounded-xl transition-all shadow-md shadow-brand-900/30 hover:shadow-lg active:scale-[0.99]",children:n(o==="local"?"login.signingIn":"login.signIn")})]}),s.jsx("div",{className:"text-center",children:s.jsx("button",{onClick:()=>{p(!1),d("")},className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors",children:n("login.backToHub")})})]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("button",{onClick:()=>D("google"),disabled:!!o,className:H,children:[s.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[s.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"}),s.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"}),s.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"}),s.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(o==="google"?"login.connectingHub":"login.withGoogle")]}),s.jsxs("button",{onClick:()=>D("github"),disabled:!!o,className:H,children:[s.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:s.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(o==="github"?"login.connectingHub":"login.withGithub")]}),s.jsxs("button",{onClick:()=>D("email"),disabled:!!o,className:H,children:[s.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:s.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(o==="email"?"login.connectingHub":"login.withEmail")]}),o&&(o==="google"||o==="github"||o==="email"||o==="hub")&&s.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:[s.jsx("p",{children:n("login.browserOpened")}),s.jsx("button",{type:"button",onClick:$,className:"text-brand-500 hover:text-brand-400 underline font-medium",children:n("login.cancelWaiting")})]}),c&&s.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}),s.jsxs("div",{className:"flex items-center gap-3 py-1 text-[11px] text-fg-tertiary",children:[s.jsx("span",{className:"h-px flex-1 bg-border-default"}),n("login.or"),s.jsx("span",{className:"h-px flex-1 bg-border-default"})]}),s.jsx("button",{onClick:()=>{p(!0),d("")},disabled:!!o,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")})]})}),s.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 ${w?"animate-shake text-fg-primary font-medium":"text-fg-tertiary"}`,children:[s.jsx("input",{type:"checkbox",checked:T,onChange:K=>{S(K.target.checked),K.target.checked&&C(!1)},className:"mt-0.5 h-3.5 w-3.5 shrink-0 accent-brand-600 cursor-pointer"}),s.jsxs("span",{className:"text-center",children:[n("login.consentPrefix")," ",s.jsx("a",{href:_("/terms"),target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-400 underline",children:n("login.termsLink")})," ",n("login.consentAnd")," ",s.jsx("a",{href:_("/privacy"),target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-400 underline",children:n("login.privacyLink")})]})]})]}),s.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:[s.jsx("a",{href:"https://markus.global",target:"_blank",rel:"noopener noreferrer",className:"hover:text-fg-secondary transition-colors",children:"markus.global"}),s.jsx("a",{href:"mailto:business@markus.global",className:"hover:text-fg-secondary transition-colors",children:n("login.contactSales")})]})]})}function OW({token:e,onComplete:t}){const{t:n}=dt("auth"),[r,o]=k.useState(null),[l,c]=k.useState(""),[d,m]=k.useState(""),[p,h]=k.useState(""),[g,x]=k.useState(!1),[y,w]=k.useState(!1),[C,T]=k.useState(!1);k.useEffect(()=>{Ce.auth.inviteInfo(e).then(_=>o(_)).catch(()=>T(!0))},[e]);const S=async _=>{if(_.preventDefault(),h(""),l.length<6){h(n("invite.passwordMinLength"));return}if(l!==d){h(n("invite.passwordsDoNotMatch"));return}x(!0);try{await Ce.auth.setup(e,l),w(!0),setTimeout(()=>{window.location.hash="",t()},2e3)}catch{h(n("invite.error"))}finally{x(!1)}};return s.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),s.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),s.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),s.jsx("div",{className:"text-sm text-fg-tertiary",children:n("invite.subtitle")})]}),s.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?s.jsxs("div",{className:"text-center space-y-3",children:[s.jsx("div",{className:"text-red-500 text-3xl",children:"⚠"}),s.jsx("p",{className:"text-sm text-fg-secondary",children:n("invite.invalidLink")}),s.jsx("button",{onClick:()=>{window.location.hash="",t()},className:"text-sm text-brand-500 hover:text-brand-400",children:n("login.signIn")})]}):y?s.jsxs("div",{className:"text-center space-y-3",children:[s.jsx("div",{className:"text-green-500 text-3xl",children:"✓"}),s.jsx("p",{className:"text-sm text-fg-secondary",children:n("invite.setupComplete")})]}):r?s.jsxs("form",{onSubmit:S,className:"space-y-5",children:[s.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n("invite.greeting",{name:r.name})}),s.jsx("p",{className:"text-xs text-fg-tertiary text-center",children:r.email}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("invite.setPassword")}),s.jsx("input",{type:"password",value:l,onChange:_=>c(_.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})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("invite.confirmPassword")}),s.jsx("input",{type:"password",value:d,onChange:_=>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})]}),p&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:p}),s.jsx("button",{type:"submit",disabled:g||!l||!d,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-all shadow-md shadow-brand-900/40 hover:shadow-lg hover:shadow-brand-900/50",children:n(g?"invite.settingUp":"invite.setupAccount")})]}):s.jsx("div",{className:"text-center text-fg-tertiary text-sm animate-pulse py-4",children:"Loading…"})})]})]})}function DW({onComplete:e,isFirstTime:t}){const{t:n}=dt("auth"),[r,o]=k.useState(""),[l,c]=k.useState(""),[d,m]=k.useState(""),[p,h]=k.useState(""),[g,x]=k.useState(!1),y=async w=>{if(w.preventDefault(),h(""),l.length<6){h(n("changePassword.passwordMinLength"));return}if(l!==d){h(n("changePassword.passwordsDoNotMatch"));return}x(!0);try{await Ce.auth.changePassword(r,l),e()}catch{h(n("changePassword.failedToChange"))}finally{x(!1)}};return s.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),s.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),s.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),s.jsx("div",{className:"text-sm text-fg-tertiary",children:n("login.subtitle")})]}),s.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:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n(t?"changePassword.setYourPassword":"changePassword.changePassword")}),t&&s.jsx("p",{className:"text-xs text-amber-600/80 text-center mt-2",children:n("changePassword.defaultPasswordWarning")})]}),!t&&s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.currentPassword")}),s.jsx("input",{type:"password",value:r,onChange:w=>o(w.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"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.newPassword")}),s.jsx("input",{type:"password",value:l,onChange:w=>c(w.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})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.confirmNewPassword")}),s.jsx("input",{type:"password",value:d,onChange:w=>m(w.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})]}),p&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:p}),s.jsx("button",{type:"submit",disabled:g||!l||!d,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-colors",children:n(g?"changePassword.saving":t?"changePassword.setPasswordAndContinue":"changePassword.changePassword")})]})]})]})}function LW({side:e,defaultWidth:t,minWidth:n,maxWidth:r,collapsedWidth:o=0,storageKey:l}){const[c,d]=k.useState(()=>{try{const C=localStorage.getItem(`${l}_w`);if(C)return Math.max(n,Math.min(r,parseInt(C,10)))}catch{}return t}),[m,p]=k.useState(()=>{try{return localStorage.getItem(`${l}_c`)==="1"}catch{return!1}}),h=k.useRef(!1),g=k.useRef(n),x=k.useRef(r);g.current=n,x.current=r,k.useEffect(()=>{try{localStorage.setItem(`${l}_w`,String(c))}catch{}},[c,l]),k.useEffect(()=>{try{localStorage.setItem(`${l}_c`,m?"1":"0")}catch{}},[m,l]),k.useEffect(()=>{d(C=>Math.max(n,Math.min(r,C)))},[n,r]);const y=k.useCallback(C=>{C.preventDefault(),h.current=!0;const T=C.clientX,S=c,_=O=>{if(!h.current)return;const P=e==="left"?O.clientX-T:T-O.clientX;d(Math.max(g.current,Math.min(x.current,S+P)))},j=()=>{h.current=!1,document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",j),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",_),document.addEventListener("mouseup",j),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[c,e]),w=k.useCallback(()=>p(C=>!C),[]);return{width:m?o:c,rawWidth:c,collapsed:m,toggle:w,setCollapsed:p,setWidth:d,onResizeStart:y}}const _Y=[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"cyberpunk",label:"Cyberpunk"},{value:"mono",label:"Mono"}],Xh="markus-theme";function P4(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 IW(){try{const e=localStorage.getItem(Xh);if(e==="midnight")return localStorage.setItem(Xh,"dark"),"dark";if(e==="light"||e==="dark"||e==="system"||e==="cyberpunk"||e==="mono")return e}catch{}return"system"}function PW(){const[e,t]=k.useState(IW),n=k.useCallback(r=>{t(r);try{localStorage.setItem(Xh,r)}catch{}P4(r)},[]);return k.useEffect(()=>{P4(e)},[e]),{mode:e,setMode:n}}const $d={agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]},zW={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},BW=["agents","tasks","requirements","projects","deliverables","workflows"];let z4="",B4="all",U4=$d,$4=!1;function UW({onClose:e,currentPage:t}){const{t:n}=dt(["common","home","work"]);zo(!0);const[r,o]=k.useState(z4),[l,c]=k.useState(B4),[d,m]=k.useState(U4),[p,h]=k.useState(!1),[g,x]=k.useState($4),[y,w]=k.useState(-1);k.useEffect(()=>{z4=r},[r]),k.useEffect(()=>{B4=l},[l]),k.useEffect(()=>{U4=d},[d]),k.useEffect(()=>{$4=g},[g]);const C=k.useRef(null),T=k.useRef(void 0),S=k.useRef(null),_=k.useRef(null);k.useEffect(()=>{setTimeout(()=>{C.current?.focus(),C.current?.select()},100)},[]);const j=k.useCallback(async W=>{if(!W.trim()){m($d),x(!1),w(-1);return}h(!0),x(!0),w(-1);const F=W.toLowerCase();try{const[Z,U,Q,ne,ke,B]=await Promise.allSettled([Ce.agents.list(),Ce.tasks.list({search:W,pageSize:20}),Ce.requirements.list(),Ce.projects.list(),Ce.deliverables.search({q:W,limit:20}),Ce.teams.list()]),q=Z.status==="fulfilled"?Z.value.agents.filter(We=>We.name?.toLowerCase().includes(F)||We.role?.toLowerCase().includes(F)):[],le=U.status==="fulfilled"?U.value.tasks:[],I=Q.status==="fulfilled"?Q.value.requirements.filter(We=>We.title?.toLowerCase().includes(F)||We.description?.toLowerCase().includes(F)):[],Ae=ne.status==="fulfilled"?ne.value.projects.filter(We=>We.name?.toLowerCase().includes(F)||We.description?.toLowerCase().includes(F)):[],$e=ke.status==="fulfilled"?ke.value.results:[],Oe=[];if(B.status==="fulfilled"){const We=await Promise.allSettled(B.value.teams.map(st=>Ce.workflows.list(st.id)));for(const st of We)if(st.status==="fulfilled")for(const mt of st.value.workflows)(mt.name.toLowerCase().includes(F)||(mt.displayName||"").toLowerCase().includes(F)||mt.description?.toLowerCase().includes(F))&&Oe.push(mt)}m({agents:q,tasks:le,requirements:I,projects:Ae,deliverables:$e,workflows:Oe})}catch{m($d)}finally{h(!1)}},[]),O=W=>{o(W),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>j(W),400)},P=k.useCallback((W,F)=>{e(),at.navigate(W,F)},[e]),D=[{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:"工作流"})}],$=k.useMemo(()=>zW[t||""]||BW,[t]),X=k.useMemo(()=>{const W=[],F=l==="all"?8:void 0,Z=U=>{if(l!=="all"&&l!==U)return;const Q=d[U].length;if(U==="workflows"){const ne=F?d.workflows.slice(0,F):d.workflows;for(const ke of ne)W.push({id:ke.name,type:"workflow",page:me.WORK,params:{boardType:"workflows"}})}else{const ne=d[U],ke=F?ne.slice(0,F):ne;for(const B of ke)switch(U){case"agents":W.push({id:B.id,type:"agent",page:me.TEAM,params:{agentId:B.id}});break;case"tasks":W.push({id:B.id,type:"task",page:me.WORK,params:{openTask:B.id}});break;case"requirements":W.push({id:B.id,type:"requirement",page:me.WORK,params:{openRequirement:B.id}});break;case"projects":W.push({id:B.id,type:"project",page:me.WORK,params:{projectId:B.id}});break;case"deliverables":W.push({id:B.id,type:"deliverable",page:me.DELIVERABLES,params:{openDeliverable:B.id}});break}}F&&Q>F&&W.push({id:`more_${U}`,type:"showMore",page:"",expandCategory:U,totalCount:Q})};for(const U of $)Z(U);return W},[d,l,$]),ee=k.useCallback(W=>{if(W.type==="showMore"&&W.expandCategory){c(W.expandCategory),w(-1);return}P(W.page,W.params)},[P]);k.useEffect(()=>{const W=_.current;if(!W||y<0)return;const F=W.querySelector(`[data-idx="${y}"]`);F&&F.scrollIntoView({block:"nearest"})},[y]);const H=k.useCallback(W=>{if(W.key==="Escape"){e();return}if(W.key==="Tab"){W.preventDefault();const U=D.map(ke=>ke.id),Q=U.indexOf(l),ne=W.shiftKey?Q<=0?U.length-1:Q-1:Q>=U.length-1?0:Q+1;c(U[ne]),w(-1);return}const F=W.ctrlKey&&W.key==="n"||W.key==="ArrowDown",Z=W.ctrlKey&&W.key==="p"||W.key==="ArrowUp";if(F||Z){W.preventDefault(),w(U=>{const Q=X.length-1;return Q<0?-1:F?U>=Q?0:U+1:U<=0?Q:U-1});return}W.key==="Enter"&&(W.preventDefault(),y>=0&&y<X.length&&ee(X[y]))},[e,X,y,ee,D,l]);k.useEffect(()=>(document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)),[H]);const K=X.length>0;let ae=0;return s.jsx("div",{ref:S,className:"fixed inset-0 bg-black/50 flex items-start justify-center z-50 pt-[8vh]",onClick:W=>{W.target===S.current&&e()},children:s.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:[s.jsxs("div",{className:"shrink-0 px-5 pt-4 pb-3 border-b border-border-default space-y-3",children:[s.jsxs("div",{className:"relative",children:[s.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:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),s.jsx("input",{ref:C,value:r,onChange:W=>O(W.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"}),r&&s.jsx("button",{onClick:()=>{o(""),m($d),x(!1),w(-1),C.current?.focus()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-fg-tertiary hover:text-fg-secondary",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),s.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:D.map(W=>s.jsx("button",{onClick:()=>{c(W.id),w(-1)},className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${l===W.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:W.label},W.id))})]}),s.jsxs("div",{ref:_,className:"flex-1 overflow-y-auto px-5 py-3",children:[p&&s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:n("common:loading")})}),!p&&g&&!K&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[s.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:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),s.jsx("p",{className:"text-sm text-fg-tertiary",children:n("common:noResults",{defaultValue:"没有找到相关结果"})})]}),!p&&K&&s.jsx("div",{className:"space-y-4",children:$.map(W=>{if(l!=="all"&&l!==W)return null;const F=l==="all"?8:void 0,Z=U=>{const Q=ae++,ne=U==="agents"?d.agents.length:U==="tasks"?d.tasks.length:U==="requirements"?d.requirements.length:U==="projects"?d.projects.length:U==="workflows"?d.workflows.length:d.deliverables.length;return s.jsxs("button",{"data-idx":Q,onClick:()=>{c(U),w(-1)},className:`mt-1 w-full text-xs py-1.5 rounded-lg transition-colors ${Q===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:"查看全部"})," (",ne,")"]})};return W==="agents"&&d.agents.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:agents",{defaultValue:"智能体"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.agents.slice(0,F):d.agents).map(U=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(me.TEAM,{agentId:U.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx(Us,{name:U.name||"Agent",avatarUrl:U.avatarUrl,size:28}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:U.name}),s.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:U.role||U.status})]}),s.jsx($W,{status:U.status})]},U.id)})}),F&&d.agents.length>F&&Z("agents")]},"agents"):W==="tasks"&&d.tasks.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:tasks",{defaultValue:"任务"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.tasks.slice(0,F):d.tasks).map(U=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(me.WORK,{openTask:U.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx(HW,{status:U.status}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:U.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[U.status," · ",U.priority||""]})]})]},U.id)})}),F&&d.tasks.length>F&&Z("tasks")]},"tasks"):W==="requirements"&&d.requirements.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:requirements",{defaultValue:"需求"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.requirements.slice(0,F):d.requirements).map(U=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(me.WORK,{openRequirement:U.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${U.status==="approved"?"text-green-500 bg-green-500/15":U.status==="pending"?"text-amber-500 bg-amber-500/15":U.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),s.jsx("polyline",{points:"14 2 14 8 20 8"}),s.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),s.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:U.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[U.status," · ",U.priority||""]})]})]},U.id)})}),F&&d.requirements.length>F&&Z("requirements")]},"requirements"):W==="projects"&&d.projects.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:projects",{defaultValue:"项目"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.projects.slice(0,F):d.projects).map(U=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(me.WORK,{projectId:U.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:s.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"})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:U.name}),U.description&&s.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:U.description})]})]},U.id)})}),F&&d.projects.length>F&&Z("projects")]},"projects"):W==="deliverables"&&d.deliverables.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:deliverables",{defaultValue:"交付物"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.deliverables.slice(0,F):d.deliverables).map(U=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(me.DELIVERABLES,{openDeliverable:U.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-purple-500/15 flex items-center justify-center shrink-0",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-purple-500",children:[s.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),s.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:U.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[U.type," · ",U.status]})]})]},U.id)})}),F&&d.deliverables.length>F&&Z("deliverables")]},"deliverables"):W==="workflows"&&d.workflows.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:workflows",{defaultValue:"工作流"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.workflows.slice(0,F):d.workflows).map(U=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(me.WORK,{boardType:"workflows"}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-teal-500/15 flex items-center justify-center shrink-0",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-teal-500",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.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"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:U.displayName||U.name}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[U.stepCount," steps · v",U.version]})]})]},U.name)})}),F&&d.workflows.length>F&&Z("workflows")]},"workflows"):null})}),!p&&!g&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[s.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:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),s.jsx("p",{className:"text-sm text-fg-tertiary",children:n("common:searchHint",{defaultValue:"输入关键词搜索"})})]})]}),s.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:[s.jsxs("span",{children:[s.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:"唤起/关闭"})]}),s.jsxs("span",{children:[s.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:"切换分类"})]}),s.jsxs("span",{children:[s.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:"导航"})]}),s.jsxs("span",{children:[s.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:"打开"})]}),s.jsxs("span",{children:[s.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 $W({status:e}){const t=e==="active"||e==="idle"?"bg-green-500":e==="working"||e==="busy"?"bg-blue-500":"bg-gray-400";return s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${t}`})}function HW({status:e}){const t=e==="completed"?"text-green-500 bg-green-500/15":e==="in_progress"?"text-blue-500 bg-blue-500/15":e==="pending"?"text-amber-500 bg-amber-500/15":"text-fg-tertiary bg-surface-elevated";return s.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${t}`,children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M9 11l3 3L22 4"}),s.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})})}function FW({authUser:e,onClose:t,onSaved:n,onUserUpdated:r}){const{t:o}=dt("common");zo(!0);const[l,c]=k.useState(e.name||""),[d,m]=k.useState(e.email||""),[p,h]=k.useState(!1),[g,x]=k.useState(""),[y,w]=k.useState(()=>h5(e.avatarUrl,sa()?.avatarUrl)),C=async T=>{if(T.preventDefault(),!l.trim()){x(o("profile.nameRequired"));return}if(d&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d.trim())){x(o("profile.invalidEmail"));return}h(!0),x("");try{const{user:S}=await Ce.auth.updateProfile(l.trim(),d.trim());n({...S,avatarUrl:y??S.avatarUrl})}catch{x(o("profile.failedToSave"))}finally{h(!1)}};return s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10000]",onClick:t,children:s.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:[s.jsx("h3",{className:"text-base font-semibold mb-5",children:o("profile.editProfile")}),s.jsx("div",{className:"flex justify-center mb-5",children:s.jsx(b5,{currentUrl:y,name:l,size:72,targetType:"user",targetId:e.id,onUploaded:T=>{w(T),r?.({...e,avatarUrl:T})}})}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:o("profile.name")}),s.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:o("profile.email")}),s.jsx("input",{value:d,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"})]}),g&&s.jsx("div",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:g})]}),s.jsxs("div",{className:"flex justify-end gap-3 mt-5",children:[s.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:o("cancel")}),s.jsx("button",{type:"submit",disabled:p,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white rounded-lg",children:o(p?"saving":"save")})]})]})})}const H4=k.lazy(()=>qr(()=>import("./Team-DHmWU23x.js"),__vite__mapDeps([2,3,4])).then(e=>({default:e.TeamPage}))),F4=k.lazy(()=>qr(()=>import("./Settings-C86a_mG8.js"),[]).then(e=>({default:e.Settings}))),qW=k.lazy(()=>qr(()=>import("./Store-Ca8mvyTT.js"),[]).then(e=>({default:e.StorePage}))),GW=k.lazy(()=>qr(()=>Promise.resolve().then(()=>lW),void 0).then(e=>({default:e.AgentBuilder}))),q4=k.lazy(()=>qr(()=>import("./Work-zJLJ6A3I.js"),__vite__mapDeps([5,4,1,6,3,7])).then(e=>({default:e.WorkPage}))),G4=k.lazy(()=>qr(()=>import("./Deliverables-DKy2_HPY.js"),__vite__mapDeps([8,4])).then(e=>({default:e.DeliverablesPage}))),VW=k.lazy(()=>qr(()=>import("./Notifications-1YKMlJ91.js"),[]).then(e=>({default:e.NotificationsPage}))),KW=k.lazy(()=>qr(()=>import("./Search-D5P2V5tM.js"),[]).then(e=>({default:e.SearchPage}))),WW={visibility:"hidden",position:"absolute",inset:0,pointerEvents:"none",zIndex:-1};function YW(e){try{const t=navigator.language,n=Intl.DateTimeFormat().resolvedOptions().timeZone,r=e.preferences??{};if(r.locale===t&&r.timezone===n)return;Ce.auth.updatePreferences({locale:t,timezone:n}).catch(()=>{})}catch{}}function XW(){return s.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm animate-pulse",children:"Loading..."})}const QW=k.memo(function({id:t,activePage:n,children:r}){const o=t===n;return s.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",style:o?void 0:WW,children:s.jsx(k.Suspense,{fallback:s.jsx(XW,{}),children:r})})},(e,t)=>{const n=e.id===e.activePage,r=t.id===t.activePage;return n!==r?!1:r?e.children===t.children:!0}),Ed={};function W3(e){return typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches?o5[e]??e:e}function V4(){return W3(uc())}function ZW(){const{t:e}=dt("common"),[t,n]=k.useState(V4),[r,o]=k.useState(()=>!localStorage.getItem("markus_onboarded")),[l,c]=k.useState(!0),d=Bo(),m=PW(),p=LW({side:"left",defaultWidth:160,minWidth:140,maxWidth:400,collapsedWidth:64,storageKey:"markus_sidebar"}),[h,g]=k.useState(()=>new Set([V4()])),[x,y]=k.useState("loading"),[w,C]=k.useState(!1),[T,S]=k.useState(null),[_,j]=k.useState({hasOwner:!1,hasMultipleUsers:!1}),[O,P]=k.useState(!1),[D,$]=k.useState(!1),[X,ee]=k.useState(null),[H,K]=k.useState(!1),[ae,W]=k.useState(null),[F,Z]=k.useState(()=>{const be=localStorage.getItem("markus_update_dismissed");return be||null}),[U,Q]=k.useState(!1),ne=Ec(),ke=ne?.leftCollapsed??!1,B=ne?.toggleLeftCollapsed,q=ne?.toggleRightPanel,le=ne?.openRightPanel,I=ne?.closeRightPanelTab,Ae=ne?.updateRightPanelBrowserTab,$e=k.useRef(ne?.rightPanelTabs);$e.current=ne?.rightPanelTabs,k.useEffect(()=>{const be=window.markusDesktop?.browser?.onPageEvent;if(!(!be||!le))return be(Me=>{if(Me.type==="closed"){const qe=$e.current?.find(ot=>ot.payload.kind==="url"&&ot.payload.browserId===Me.browserId);qe&&I&&I(qe.id);return}if(Me.type==="navigated"){Me.browserId&&Ae&&Ae(Me.browserId,{url:Me.url,title:Me.title||Me.url});return}if(Me.type==="opened"||Me.type==="selected"){if(!Me.url&&!Me.browserId||Me.browserId.startsWith("eb_")||TG(Me.browserId))return;le({kind:"url",url:Me.url||"about:blank",title:Me.title||Me.url||"Browser",browserId:Me.browserId,pageId:Me.pageId})}})},[le,I,Ae]);const Oe=ne?.rightPanelOpen??!1;k.useLayoutEffect(()=>{const be=t===me.TEAM&&Oe;rp(be)},[t,Oe]),k.useEffect(()=>{window.markusDesktop?.browser?.hideAll?.()},[]);const We=k.useRef(!1);k.useEffect(()=>{if(!We.current){We.current=!0;return}p.setCollapsed(ke)},[ke,p.setCollapsed]),k.useEffect(()=>{if(d)return;const be=navigator.platform.toUpperCase().includes("MAC"),Me=ot=>{be&&ot.metaKey&&!ot.ctrlKey&&ot.key==="p"?(ot.preventDefault(),Q(ft=>!ft)):!be&&ot.ctrlKey&&!ot.metaKey&&ot.key==="p"&&(ot.preventDefault(),Q(ft=>!ft))},qe=()=>Q(!0);return document.addEventListener("keydown",Me),window.addEventListener("markus:open-search",qe),()=>{document.removeEventListener("keydown",Me),window.removeEventListener("markus:open-search",qe)}},[d]),k.useEffect(()=>{if(d||!B||!q)return;const be=navigator.platform.toUpperCase().includes("MAC"),Me=qe=>{if(!(be?qe.metaKey&&!qe.ctrlKey:qe.ctrlKey&&!qe.metaKey)||qe.altKey||qe.shiftKey)return;const ft=qe.key.toLowerCase();ft==="b"?(qe.preventDefault(),B()):ft==="l"&&(qe.preventDefault(),q())};return document.addEventListener("keydown",Me),()=>document.removeEventListener("keydown",Me)},[d,B,q]);const st=k.useCallback((be,Me)=>{let qe=cc(be);d?qe=o5[qe]??qe:qe===me.NOTIFICATIONS&&(qe=me.HOME),qe!==me.TEAM&&rp(!1);const ot=uc(),ft=window.location.hash.slice(1);if(ft!==lh(ot)?Ed[ot]=ft:delete Ed[ot],qe===me.SETTINGS&&Me?.tab){const Be=`settings/${Me.tab}`;Ed[qe]=Be,history.pushState(null,"","#"+Be),window.dispatchEvent(new HashChangeEvent("hashchange")),n(qe),g(Xe=>Xe.has(qe)?Xe:new Set([...Xe,qe]));return}const se=qe!==me.WORK?Ed[qe]:void 0;se&&se!==lh(qe)?(history.pushState(null,"",Ni(qe)),history.pushState(null,"","#"+se)):history.pushState(null,"",Ni(qe)),window.dispatchEvent(new HashChangeEvent("hashchange")),n(qe),g(Be=>Be.has(qe)?Be:new Set([...Be,qe]))},[d]);k.useEffect(()=>{at.setHandler((be,Me)=>st(be,Me))},[st]),k.useEffect(()=>{const be=()=>C(!0);return window.addEventListener("markus:open-edit-profile",be),()=>window.removeEventListener("markus:open-edit-profile",be)},[]),k.useEffect(()=>{if(!window.markusDesktop)return;!d&&t!==me.SETTINGS&&!p.collapsed?window.markusDesktop.setTrafficLightPosition(16,16):window.markusDesktop.setTrafficLightPosition(6,16)},[p.collapsed,t,d]),k.useEffect(()=>{window.markusDesktop&&window.markusDesktop.onNotificationClick(be=>{if(be.openNotifications&&window.dispatchEvent(new CustomEvent("markus:open-notifications")),be.page){const Me=cc(be.page);be.params&&Object.entries(be.params).forEach(([qe,ot])=>localStorage.setItem(`markus_nav_${qe}`,ot)),st(Me),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:Me,params:be.params}}))}})},[st]);const mt=k.useCallback(()=>{fetch("/api/settings/llm").then(be=>be.ok?be.json():null).then(be=>{if(be?.providers){const Me=Object.values(be.providers).some(qe=>qe.configured);ee(Me)}}).catch(()=>{})},[]),At=k.useCallback((be,Me)=>{if(!be)return;const ot=Me&&{agent:"agents",team:"teams",skill:"skills"}[Me]||"agents";localStorage.setItem("markus_nav_installItem",be),localStorage.setItem("markus_nav_storeTab",ot);const ft=new URLSearchParams(window.location.search);ft.get("install")||(ft.set("install",be),Me&&ft.set("type",Me));const se=ft.toString();window.history.replaceState(null,"",`${window.location.pathname}?${se}${Ni(me.STORE)}`);const Be=()=>at.navigate(me.STORE,{storeTab:ot,installItem:be});Be(),setTimeout(Be,500),setTimeout(Be,1500)},[]);k.useEffect(()=>{const be=new URLSearchParams(window.location.search),Me=be.get("install");Me&&At(Me,be.get("type"));const qe=window.markusDesktop;qe?.onDeepLinkInstall?.(({id:se,type:Be})=>At(se,Be)),qe?.consumePendingDeepLinkInstall?.().then(se=>{se?.id&&At(se.id,se.type)}),Ce.auth.me().then(({user:se})=>{y(se),S(!0),YW(se),va.connect(se.id),mt(),Ce.health().then(Xe=>{Xe.updateAvailable&&Xe.latestVersion&&W({latestVersion:Xe.latestVersion,currentVersion:Xe.version})}).catch(()=>{});const Be=()=>{hi(Tr.builderArtifacts,()=>Ce.builder.artifacts.list()),hi(Tr.builderAgents,()=>Ce.agents.list()),hi(Tr.builderHubMyItems,()=>it.myItems()),hi(Tr.builderInstalled,()=>Ce.builder.artifacts.installed()),hi(Tr.hubAgents,()=>it.search({type:"agent",limit:50})),hi(Tr.hubTeams,()=>it.search({type:"team",limit:50})),hi(Tr.hubSkills,()=>it.search({type:"skill",limit:50}))};typeof requestIdleCallback=="function"?requestIdleCallback(Be,{timeout:5e3}):setTimeout(Be,3e3)}).catch(()=>{y(null),Ce.auth.status().then(({initialized:se,hasOwner:Be,hasMultipleUsers:Xe})=>{S(se),j({hasOwner:Be,hasMultipleUsers:Xe})}).catch(()=>S(!0))}),va.connect();const ot=va.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),ft=()=>{const se=W3(uc());se!==me.TEAM&&rp(!1),n(se),g(Be=>Be.has(se)?Be:new Set([...Be,se]))};return window.addEventListener("hashchange",ft),window.addEventListener("popstate",ft),()=>{ot(),va.disconnect(),window.removeEventListener("hashchange",ft),window.removeEventListener("popstate",ft)}},[]);const gt=x!=="loading"&&x!==null?x:void 0,jt=k.useMemo(()=>d?{[me.HOME]:s.jsx(ev,{authUser:gt}),[me.TEAM]:s.jsx(H4,{authUser:gt}),[me.BUILDER]:s.jsx(_W,{authUser:gt}),[me.SETTINGS]:s.jsx(F4,{theme:m.mode,onThemeChange:m.setMode,authUser:gt,onLogout:()=>{Ce.auth.logout().catch(()=>{}),_o(),y(null)},onUserUpdated:be=>y(be)}),[me.WORK]:s.jsx(q4,{authUser:gt}),[me.DELIVERABLES]:s.jsx(G4,{authUser:gt}),[me.NOTIFICATIONS]:s.jsx(VW,{authUser:gt}),[me.SEARCH]:s.jsx(KW,{})}:{[me.HOME]:s.jsx(ev,{authUser:gt}),[me.TEAM]:s.jsx(H4,{authUser:gt}),[me.SETTINGS]:s.jsx(F4,{theme:m.mode,onThemeChange:m.setMode,authUser:gt,onLogout:()=>{Ce.auth.logout().catch(()=>{}),_o(),y(null)},onUserUpdated:be=>y(be)}),[me.STORE]:s.jsx(qW,{authUser:gt}),[me.BUILDER]:s.jsx(GW,{authUser:gt}),[me.WORK]:s.jsx(q4,{authUser:gt}),[me.DELIVERABLES]:s.jsx(G4,{authUser:gt})},[gt?.id,gt?.role,m.mode,d]);if(x==="loading"||x===null&&T===null)return s.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center",children:s.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:e("loading")})});const Rt=(typeof window<"u"?window.location.hash:"").match(/^#invite\?token=([a-f0-9]+)/);return Rt?s.jsx(OW,{token:Rt[1],onComplete:()=>{window.location.hash="",localStorage.removeItem("markus_onboarded"),o(!0),P(!0),y("loading"),Ce.auth.me().then(be=>y(be.user)).catch(()=>y(null))}}):x===null?s.jsx(RW,{hasOwner:_.hasOwner,hasMultipleUsers:_.hasMultipleUsers,onLogin:(be,Me,qe)=>{y(be),va.connect(be.id),Me?(localStorage.removeItem("markus_onboarded"),o(!0),qe?.fromHub&&P(!0)):localStorage.getItem("markus_onboarded")||(localStorage.setItem("markus_onboarded","1"),o(!1))}}):D?s.jsx(DW,{onComplete:()=>$(!1),isFirstTime:!0}):r?s.jsx(jW,{theme:m.mode,onThemeChange:m.setMode,skipProfile:O,onProfileUpdated:be=>{const Me={id:be.id,name:be.name,email:be.email,role:be.role,orgId:be.orgId??"default",avatarUrl:be.avatarUrl};y(Me)},onComplete:()=>{localStorage.setItem("markus_onboarded","1"),o(!1),P(!1),Ce.auth.me().then(be=>y(be.user)).catch(()=>{}),mt(),st(me.HOME)}}):s.jsxs("div",{className:`flex h-dvh bg-surface-primary text-fg-primary overflow-x-hidden ${d?"flex-col":""}`,children:[!d&&t!==me.SETTINGS&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"relative z-40 shrink-0",style:{width:p.width},children:s.jsx(LK,{currentPage:t,onNavigate:be=>{st(be),c(!1)},authUser:x,collapsed:p.collapsed,onToggleCollapse:p.toggle,onLogout:()=>{Ce.auth.logout().catch(()=>{}),_o(),y(null)}})}),s.jsx("div",{className:`${p.collapsed?"w-0":"w-1.5 cursor-col-resize"} shrink-0 group relative z-10 flex items-center justify-center`,onMouseDown:p.collapsed?void 0:p.onResizeStart,children:!p.collapsed&&s.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"})})]}),s.jsxs("div",{className:`flex-1 overflow-hidden flex flex-col min-w-0 ${d&&t!==me.SETTINGS&&t!==me.SEARCH?"pb-14":""}`,children:[X===!1&&!H&&t!==me.SETTINGS&&s.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:[s.jsx("span",{className:d?"text-xs":"",children:e("llmBanner.message")}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.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")}),s.jsx("button",{onClick:()=>K(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:e("dismiss")})]})]}),ae&&F!==ae.latestVersion&&s.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:[s.jsx("span",{className:d?"text-xs":"",children:e("update.available",{latest:ae.latestVersion,current:ae.currentVersion})}),s.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[s.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")}),s.jsx("button",{onClick:()=>{Z(ae.latestVersion),localStorage.setItem("markus_update_dismissed",ae.latestVersion)},className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]}),s.jsx("main",{className:"flex-1 overflow-hidden flex flex-col relative",children:Object.keys(jt).map(be=>h.has(be)?s.jsx(QW,{id:be,activePage:t,children:jt[be]},be):null)})]}),d&&t!==me.SETTINGS&&t!==me.SEARCH&&s.jsx(UK,{currentPage:t,onNavigate:st,userId:gt?.id}),d&&s.jsx(OD,{authUser:gt,onNavigate:st}),!d&&U&&s.jsx(UW,{onClose:()=>Q(!1),currentPage:t}),w&>&&s.jsx(FW,{authUser:gt,onClose:()=>C(!1),onUserUpdated:be=>y(be),onSaved:be=>{C(!1),y(be)}})]})}s7.createRoot(document.getElementById("root")).render(s.jsx(k.StrictMode,{children:s.jsx(EG,{children:s.jsx(ZW,{})})}));export{vK as $,Us as A,RD as B,LW as C,cc as D,Ig as E,wc as F,zo as G,Q7 as H,SW as I,dr as J,tY as K,nY as L,x5 as M,RK as N,Ai as O,me as P,Xd as Q,TY as R,wW as S,dW as T,xK as U,NV as V,Q2 as W,CV as X,aY as Y,cY as Z,qr as _,Bo as a,rY as a0,Ci as a1,Vo as a2,Ec as a3,hY as a4,BK as a5,EY as a6,yY as a7,oY as a8,pY as a9,T3 as aA,Ya as aa,wY as ab,MV as ac,vY as ad,kY as ae,jK as af,AK as ag,SY as ah,v0 as ai,J7 as aj,JW as ak,Ni as al,vD as am,E3 as an,lY as ao,i4 as ap,g4 as aq,uK as ar,cK as as,pc as at,_Y as au,eY as av,sa as aw,yn as ax,na as ay,iY as az,TW as b,pW as c,xW as d,Sa as e,Ce as f,mY as g,it as h,ki as i,s as j,TK as k,NY as l,bY as m,at as n,xY as o,gY as p,AY as q,k as r,zg as s,Er as t,dt as u,CY as v,va as w,fY as x,uY as y,dY as z};
|