@markus-global/cli 0.9.0-rc.11 → 0.9.0-rc.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web-ui/assets/{CommentInput-BJ0iV2VC.js → CommentInput-Dpsb9e7X.js} +1 -1
- package/dist/web-ui/assets/{ContentRenderer-CWE0DlFU.js → ContentRenderer-C6rYWd6u.js} +2 -2
- package/dist/web-ui/assets/{Deliverables-BbXx2sVi.js → Deliverables-BV8FX7c8.js} +1 -1
- package/dist/web-ui/assets/{Notifications-DZ1RS03a.js → Notifications-DlJwYRwG.js} +1 -1
- package/dist/web-ui/assets/{Search-BpFJHR4B.js → Search-RM_DN8KT.js} +1 -1
- package/dist/web-ui/assets/{Settings-2wot9SJH.js → Settings-BfybLlOW.js} +1 -1
- package/dist/web-ui/assets/{Store-CIMb8oMO.js → Store-DJ8GwAx1.js} +1 -1
- package/dist/web-ui/assets/{Team-C1ifTSrO.js → Team-Dtnoxd6f.js} +4 -4
- package/dist/web-ui/assets/{Work-Cz9u7f2u.js → Work-DT-c37Wd.js} +1 -1
- package/dist/web-ui/assets/{arc-D2HIMLkq.js → arc-DSN_N-45.js} +1 -1
- package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-GB2CVk5R.js → architectureDiagram-3BPJPVTR-CaY9-3bg.js} +1 -1
- package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-DsHsvlK3.js → blockDiagram-GPEHLZMM-9U3QgGvS.js} +1 -1
- package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-BuS3ELfJ.js → c4Diagram-AAUBKEIU-BLso-JKj.js} +1 -1
- package/dist/web-ui/assets/channel-BpDK8SBQ.js +1 -0
- package/dist/web-ui/assets/{chunk-2J33WTMH-Dz154Pcq.js → chunk-2J33WTMH-Bxclin5c.js} +1 -1
- package/dist/web-ui/assets/{chunk-4BX2VUAB-B2ZLJWZW.js → chunk-4BX2VUAB-Ds2KYOA0.js} +1 -1
- package/dist/web-ui/assets/{chunk-55IACEB6-CXBt_s9n.js → chunk-55IACEB6-BgrRkrbw.js} +1 -1
- package/dist/web-ui/assets/{chunk-727SXJPM-BILy-_U3.js → chunk-727SXJPM-BzCDu5oV.js} +1 -1
- package/dist/web-ui/assets/{chunk-AQP2D5EJ-Cpp8xNWU.js → chunk-AQP2D5EJ-tBSc6TTE.js} +1 -1
- package/dist/web-ui/assets/{chunk-FMBD7UC4-ePSFL10p.js → chunk-FMBD7UC4-CYqAHdLU.js} +1 -1
- package/dist/web-ui/assets/{chunk-ND2GUHAM-DrFBaK_z.js → chunk-ND2GUHAM-BXiWwTBI.js} +1 -1
- package/dist/web-ui/assets/{chunk-QZHKN3VN-DwGDJiLN.js → chunk-QZHKN3VN-D97Bi4tT.js} +1 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-B-Ngehiz.js +1 -0
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-B-Ngehiz.js +1 -0
- package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-DxoL8DMp.js → cose-bilkent-S5V4N54A-bWe6154z.js} +1 -1
- package/dist/web-ui/assets/{dagre-BM42HDAG-BkfQy3Qa.js → dagre-BM42HDAG-DppvmpvW.js} +1 -1
- package/dist/web-ui/assets/{diagram-2AECGRRQ-uZhwYPlV.js → diagram-2AECGRRQ-C_QpyOpT.js} +1 -1
- package/dist/web-ui/assets/{diagram-5GNKFQAL-DPsfZH96.js → diagram-5GNKFQAL-B73gAOin.js} +1 -1
- package/dist/web-ui/assets/{diagram-KO2AKTUF-CUuPoMt5.js → diagram-KO2AKTUF-Pn2QKPwH.js} +1 -1
- package/dist/web-ui/assets/{diagram-LMA3HP47-CiuPSMaS.js → diagram-LMA3HP47-CP0t8kVb.js} +1 -1
- package/dist/web-ui/assets/{diagram-OG6HWLK6-CQArY3tF.js → diagram-OG6HWLK6-AQJQ7NSt.js} +1 -1
- package/dist/web-ui/assets/{erDiagram-TEJ5UH35-CKvcXuJz.js → erDiagram-TEJ5UH35-CEOrZ_g2.js} +1 -1
- package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-DAcfB7AU.js → flowDiagram-I6XJVG4X-DhF3VXFx.js} +1 -1
- package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-J-L3VCf4.js → ganttDiagram-6RSMTGT7-BFV-Dh9O.js} +1 -1
- package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-pyEYcojc.js → gitGraphDiagram-PVQCEYII-Xt-e7Pz5.js} +1 -1
- package/dist/web-ui/assets/{index-CChHEeHa.js → index-DI3gkA7T.js} +4 -4
- package/dist/web-ui/assets/{infoDiagram-5YYISTIA-COjyD8xj.js → infoDiagram-5YYISTIA-Jy4iziRD.js} +1 -1
- package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-Ctksl7ZV.js → ishikawaDiagram-YF4QCWOH-BqdgVOjp.js} +1 -1
- package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-BrsNX6mO.js → journeyDiagram-JHISSGLW-Yvg6pnyI.js} +1 -1
- package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-DbU3SCoX.js → kanban-definition-UN3LZRKU-5lW8AQOU.js} +1 -1
- package/dist/web-ui/assets/{mermaid.core-C_SBxufd.js → mermaid.core-COSp53vV.js} +5 -5
- package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-BvaURRU3.js → mindmap-definition-RKZ34NQL-CkH3jmpi.js} +1 -1
- package/dist/web-ui/assets/{pieDiagram-4H26LBE5-CL6YgP22.js → pieDiagram-4H26LBE5-Dx9b1sk0.js} +1 -1
- package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-j74lLM06.js → quadrantDiagram-W4KKPZXB-8TN2WCCw.js} +1 -1
- package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-BtJlEtHE.js → requirementDiagram-4Y6WPE33-cRa__q_z.js} +1 -1
- package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-D5YKyfuZ.js → sankeyDiagram-5OEKKPKP-_f1_FCIB.js} +1 -1
- package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-P6IeqUAM.js → sequenceDiagram-3UESZ5HK-Cc0dpVu2.js} +1 -1
- package/dist/web-ui/assets/{stateDiagram-AJRCARHV-B-Gz2fU7.js → stateDiagram-AJRCARHV-DEh-A8sf.js} +1 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-CTNZBZCx.js +1 -0
- package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-BHo0NfbD.js → timeline-definition-PNZ67QCA-C6Kzg6Ma.js} +1 -1
- package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-1wWDDBwR.js → vennDiagram-CIIHVFJN-RtpiASPt.js} +1 -1
- package/dist/web-ui/assets/{wardley-L42UT6IY-lPXncQ-4.js → wardley-L42UT6IY-CvAgpHf9.js} +1 -1
- package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-CA3zyxw5.js → wardleyDiagram-YWT4CUSO-BSVYM6qN.js} +1 -1
- package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-Cs0dSnLE.js → xychartDiagram-2RQKCTM6-Cb6pej-j.js} +1 -1
- package/dist/web-ui/index.html +1 -1
- package/package.json +1 -1
- package/dist/web-ui/assets/channel-BtMNeDlh.js +0 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-Cuk60v8D.js +0 -1
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-Cuk60v8D.js +0 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-CpXFl_Sw.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-COSp53vV.js","assets/transform-CpIVI4vC.js","assets/Team-Dtnoxd6f.js","assets/CommentInput-Dpsb9e7X.js","assets/ContentRenderer-C6rYWd6u.js","assets/Work-DT-c37Wd.js","assets/value-DIujSiJ7.js","assets/Work-BZV40eAE.css","assets/Deliverables-BV8FX7c8.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(G){return G===null||typeof G!="object"?null:(G=x&&G[x]||G["@@iterator"],typeof G=="function"?G:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,T={};function S(G,le,I){this.props=G,this.context=le,this.refs=T,this.updater=I||w}S.prototype.isReactComponent={},S.prototype.setState=function(G,le){if(typeof G!="object"&&typeof G!="function"&&G!=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,G,le,"setState")},S.prototype.forceUpdate=function(G){this.updater.enqueueForceUpdate(this,G,"forceUpdate")};function _(){}_.prototype=S.prototype;function j(G,le,I){this.props=G,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(G,le,I){var Ae=I.ref;return{$$typeof:e,type:G,key:le,ref:Ae!==void 0?Ae:null,props:I}}function H(G,le){return ee(G.type,le,G.props)}function K(G){return typeof G=="object"&&G!==null&&G.$$typeof===e}function ae(G){var le={"=":"=0",":":"=2"};return"$"+G.replace(/[=:]/g,function(I){return le[I]})}var W=/\/+/g;function F(G,le){return typeof G=="object"&&G!==null&&G.key!=null?ae(""+G.key):le.toString(36)}function Z(G){switch(G.status){case"fulfilled":return G.value;case"rejected":throw G.reason;default:switch(typeof G.status=="string"?G.then(D,D):(G.status="pending",G.then(function(le){G.status==="pending"&&(G.status="fulfilled",G.value=le)},function(le){G.status==="pending"&&(G.status="rejected",G.reason=le)})),G.status){case"fulfilled":return G.value;case"rejected":throw G.reason}}throw G}function B(G,le,I,Ae,$e){var Oe=typeof G;(Oe==="undefined"||Oe==="boolean")&&(G=null);var We=!1;if(G===null)We=!0;else switch(Oe){case"bigint":case"string":case"number":We=!0;break;case"object":switch(G.$$typeof){case e:case t:We=!0;break;case h:return We=G._init,B(We(G._payload),le,I,Ae,$e)}}if(We)return $e=$e(G),We=Ae===""?"."+F(G,0):Ae,P($e)?(I="",We!=null&&(I=We.replace(W,"$&/")+"/"),B($e,le,I,"",function(At){return At})):$e!=null&&(K($e)&&($e=H($e,I+($e.key==null||G&&G.key===$e.key?"":(""+$e.key).replace(W,"$&/")+"/")+We)),le.push($e)),1;We=0;var st=Ae===""?".":Ae+":";if(P(G))for(var mt=0;mt<G.length;mt++)Ae=G[mt],Oe=st+F(Ae,mt),We+=B(Ae,le,I,Oe,$e);else if(mt=y(G),typeof mt=="function")for(G=mt.call(G),mt=0;!(Ae=G.next()).done;)Ae=Ae.value,Oe=st+F(Ae,mt++),We+=B(Ae,le,I,Oe,$e);else if(Oe==="object"){if(typeof G.then=="function")return B(Z(G),le,I,Ae,$e);throw le=String(G),Error("Objects are not valid as a React child (found: "+(le==="[object Object]"?"object with keys {"+Object.keys(G).join(", ")+"}":le)+"). If you meant to render a collection of children, use an array instead.")}return We}function Q(G,le,I){if(G==null)return G;var Ae=[],$e=0;return B(G,Ae,"","",function(Oe){return le.call(I,Oe,$e++)}),Ae}function ne(G){if(G._status===-1){var le=G._result;le=le(),le.then(function(I){(G._status===0||G._status===-1)&&(G._status=1,G._result=I)},function(I){(G._status===0||G._status===-1)&&(G._status=2,G._result=I)}),G._status===-1&&(G._status=0,G._result=le)}if(G._status===1)return G._result.default;throw G._result}var ke=typeof reportError=="function"?reportError:function(G){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var le=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof G=="object"&&G!==null&&typeof G.message=="string"?String(G.message):String(G),error:G});if(!window.dispatchEvent(le))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",G);return}console.error(G)},U={map:Q,forEach:function(G,le,I){Q(G,function(){le.apply(this,arguments)},I)},count:function(G){var le=0;return Q(G,function(){le++}),le},toArray:function(G){return Q(G,function(le){return le})||[]},only:function(G){if(!K(G))throw Error("React.Children.only expected to receive a single React element child.");return G}};return Ot.Activity=g,Ot.Children=U,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(G){return $.H.useMemoCache(G)}},Ot.cache=function(G){return function(){return G.apply(null,arguments)}},Ot.cacheSignal=function(){return null},Ot.cloneElement=function(G,le,I){if(G==null)throw Error("The argument must be a React element, but you passed "+G+".");var Ae=C({},G.props),$e=G.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(G.type,$e,Ae)},Ot.createContext=function(G){return G={$$typeof:c,_currentValue:G,_currentValue2:G,_threadCount:0,Provider:null,Consumer:null},G.Provider=G,G.Consumer={$$typeof:l,_context:G},G},Ot.createElement=function(G,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(G&&G.defaultProps)for(Ae in We=G.defaultProps,We)$e[Ae]===void 0&&($e[Ae]=We[Ae]);return ee(G,Oe,$e)},Ot.createRef=function(){return{current:null}},Ot.forwardRef=function(G){return{$$typeof:d,render:G}},Ot.isValidElement=K,Ot.lazy=function(G){return{$$typeof:h,_payload:{_status:-1,_result:G},_init:ne}},Ot.memo=function(G,le){return{$$typeof:p,type:G,compare:le===void 0?null:le}},Ot.startTransition=function(G){var le=$.T,I={};$.T=I;try{var Ae=G(),$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(G){return $.H.use(G)},Ot.useActionState=function(G,le,I){return $.H.useActionState(G,le,I)},Ot.useCallback=function(G,le){return $.H.useCallback(G,le)},Ot.useContext=function(G){return $.H.useContext(G)},Ot.useDebugValue=function(){},Ot.useDeferredValue=function(G,le){return $.H.useDeferredValue(G,le)},Ot.useEffect=function(G,le){return $.H.useEffect(G,le)},Ot.useEffectEvent=function(G){return $.H.useEffectEvent(G)},Ot.useId=function(){return $.H.useId()},Ot.useImperativeHandle=function(G,le,I){return $.H.useImperativeHandle(G,le,I)},Ot.useInsertionEffect=function(G,le){return $.H.useInsertionEffect(G,le)},Ot.useLayoutEffect=function(G,le){return $.H.useLayoutEffect(G,le)},Ot.useMemo=function(G,le){return $.H.useMemo(G,le)},Ot.useOptimistic=function(G,le){return $.H.useOptimistic(G,le)},Ot.useReducer=function(G,le,I){return $.H.useReducer(G,le,I)},Ot.useRef=function(G){return $.H.useRef(G)},Ot.useState=function(G){return $.H.useState(G)},Ot.useSyncExternalStore=function(G,le,I){return $.H.useSyncExternalStore(G,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 KW=wc(k);var Kf={exports:{}},Hl={},Wf={exports:{}},Yf={};var wy;function e7(){return wy||(wy=1,(function(e){function t(B,Q){var ne=B.length;B.push(Q);e:for(;0<ne;){var ke=ne-1>>>1,U=B[ke];if(0<o(U,Q))B[ke]=Q,B[ne]=U,ne=ke;else break e}}function n(B){return B.length===0?null:B[0]}function r(B){if(B.length===0)return null;var Q=B[0],ne=B.pop();if(ne!==Q){B[0]=ne;e:for(var ke=0,U=B.length,G=U>>>1;ke<G;){var le=2*(ke+1)-1,I=B[le],Ae=le+1,$e=B[Ae];if(0>o(I,ne))Ae<U&&0>o($e,I)?(B[ke]=$e,B[Ae]=ne,ke=Ae):(B[ke]=I,B[le]=ne,ke=le);else if(Ae<U&&0>o($e,ne))B[ke]=$e,B[Ae]=ne,ke=Ae;else break e}}return Q}function o(B,Q){var ne=B.sortIndex-Q.sortIndex;return ne!==0?ne:B.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(B){for(var Q=n(p);Q!==null;){if(Q.callback===null)r(p);else if(Q.startTime<=B)r(p),Q.sortIndex=Q.expirationTime,t(m,Q);else break;Q=n(p)}}function P(B){if(C=!1,O(B),!w)if(n(m)!==null)w=!0,D||(D=!0,ae());else{var Q=n(p);Q!==null&&Z(P,Q.startTime-B)}}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 B=e.unstable_now();ee=B;var Q=!0;try{e:{w=!1,C&&(C=!1,_($),$=-1),y=!0;var ne=x;try{t:{for(O(B),g=n(m);g!==null&&!(g.expirationTime>B&&H());){var ke=g.callback;if(typeof ke=="function"){g.callback=null,x=g.priorityLevel;var U=ke(g.expirationTime<=B);if(B=e.unstable_now(),typeof U=="function"){g.callback=U,O(B),Q=!0;break t}g===n(m)&&r(m),O(B)}else r(m);g=n(m)}if(g!==null)Q=!0;else{var G=n(p);G!==null&&Z(P,G.startTime-B),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(B,Q){$=S(function(){B(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(B){B.callback=null},e.unstable_forceFrameRate=function(B){0>B||125<B?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):X=0<B?Math.floor(1e3/B):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_next=function(B){switch(x){case 1:case 2:case 3:var Q=3;break;default:Q=x}var ne=x;x=Q;try{return B()}finally{x=ne}},e.unstable_requestPaint=function(){T=!0},e.unstable_runWithPriority=function(B,Q){switch(B){case 1:case 2:case 3:case 4:case 5:break;default:B=3}var ne=x;x=B;try{return Q()}finally{x=ne}},e.unstable_scheduleCallback=function(B,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,B){case 1:var U=-1;break;case 2:U=250;break;case 5:U=1073741823;break;case 4:U=1e4;break;default:U=5e3}return U=ne+U,B={id:h++,callback:Q,priorityLevel:B,startTime:ne,expirationTime:U,sortIndex:-1},ne>ke?(B.sortIndex=ne,t(p,B),n(m)===null&&B===n(p)&&(C?(_($),$=-1):C=!0,Z(P,ne-ke))):(B.sortIndex=U,t(m,B),w||y||(w=!0,D||(D=!0,ae()))),B},e.unstable_shouldYield=H,e.unstable_wrapCallback=function(B){var Q=x;return function(){var ne=x;x=Q;try{return B.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,B=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=[],U=-1;function G(a){return{current:a}}function le(a){0>U||(a.current=ke[U],ke[U]=null,U--)}function I(a,i){U++,ke[U]=a.current,a.current=i}var Ae=G(null),$e=G(null),Oe=G(null),We=G(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(`
|
|
@@ -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 bq=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_-]*/}}),xq=["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"],yq=["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"],vq=[...xq,...yq],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(),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(),kq=["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(),Sq=Vk.concat(Kk).sort().reverse();function Nq(e){const t=bq(e),n=Sq,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:wq.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("+kq.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("+vq.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 Cq(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 Tq(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 Aq(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 Eq(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 _q(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 jq(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(B=>{Z.push(B),B.toLowerCase()===B?Z.push(B.toUpperCase()):Z.push(B.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 Mq(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 Rq(e){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}function Oq(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 Dq(e){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function Lq(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 Iq(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 Pq(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 zq=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_-]*/}}),Bq=["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"],Uq=["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"],$q=[...Bq,...Uq],Hq=["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(),Fq=["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(),qq=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),Gq=["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 Vq(e){const t=zq(e),n=qq,r=Fq,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("+$q.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("+Gq.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:Hq.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 Kq(e){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function Wq(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 Yq(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"("+(Yq(e).capture?"":"?:")+e.map(r=>Wk(r)).join("|")+")"}const Lg=e=>dn(/\b/,e,/\w$/.test(e)?/\b/:/\B/),Xq=["Protocol","Type"].map(Lg),P2=["init","self"].map(Lg),Qq=["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"],Zq=["assignment","associativity","higherThan","left","lowerThan","none","right"],Jq=["#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,"*"),eG=["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"],tG=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function nG(e){const t={match:/\s+/,relevance:0},n=e.COMMENT("/\\*","\\*/",{contains:["self"]}),r=[e.C_LINE_COMMENT_MODE,n],o={match:[/\./,cr(...Xq,...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(Qq).map(Lg),m={variants:[{className:"keyword",match:cr(...d,...P2)}]},p={$pattern:cr(/\b\w+/,/#\w+/),keyword:c.concat(Jq),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+/},B={className:"variable",match:`\\$${l0}+`},Q=[F,Z,B],ne={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:tG,contains:[...T,j,ee]}]}},ke={scope:"keyword",match:dn(/@/,cr(...eG),Wl(cr(/\(/,/\s+/)))},U={scope:"meta",match:dn(/@/,ba)},G=[ne,ke,U],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,...G,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,...G,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,...G,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:[...Zq,...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,...G,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 rG(e){const t=e.regex,n=(ne,{after:ke})=>{const U="</"+ne[0].slice(1);return ne.input.indexOf(U,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 U=ne[0].length+ne.index,G=ne.input[U];if(G==="<"||G===","){ke.ignoreMatch();return}G===">"&&(n(ne,{after:U})||ke.ignoreMatch());let le;const I=ne.input.substring(U);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]},B="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",Q={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(B)],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:B,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 aG(e){const t=e.regex,n=rG(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 sG(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 iG(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 oG(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 lG(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 cG={arduino:qF,bash:GF,c:VF,cpp:KF,csharp:WF,css:rq,diff:aq,go:sq,graphql:iq,ini:oq,java:lq,javascript:fq,json:pq,kotlin:gq,less:Nq,lua:Cq,makefile:Tq,markdown:Aq,objectivec:Eq,perl:_q,php:jq,"php-template":Mq,plaintext:Rq,python:Oq,"python-repl":Dq,r:Lq,ruby:Iq,rust:Pq,scss:Vq,shell:Kq,sql:Wq,swift:nG,typescript:aG,vbnet:sG,wasm:iG,xml:oG,yaml:lG};var Fp,U2;function uG(){if(U2)return Fp;U2=1;function e(q){return q instanceof Map?q.clear=q.delete=q.set=function(){throw new Error("map is read-only")}:q instanceof Set&&(q.add=q.clear=q.delete=function(){throw new Error("set is read-only")}),Object.freeze(q),Object.getOwnPropertyNames(q).forEach(ie=>{const Ne=q[ie],Le=typeof Ne;(Le==="object"||Le==="function")&&!Object.isFrozen(Ne)&&e(Ne)}),q}class t{constructor(ie){ie.data===void 0&&(ie.data={}),this.data=ie.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(q){return q.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function r(q,...ie){const Ne=Object.create(null);for(const Le in q)Ne[Le]=q[Le];return ie.forEach(function(Le){for(const Je in Le)Ne[Je]=Le[Je]}),Ne}const o="</span>",l=q=>!!q.scope,c=(q,{prefix:ie})=>{if(q.startsWith("language:"))return q.replace("language:","language-");if(q.includes(".")){const Ne=q.split(".");return[`${ie}${Ne.shift()}`,...Ne.map((Le,Je)=>`${Le}${"_".repeat(Je+1)}`)].join(" ")}return`${ie}${q}`};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=(q={})=>{const ie={children:[]};return Object.assign(ie,q),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(q){return q?typeof q=="string"?q:q.source:null}function x(q){return C("(?=",q,")")}function y(q){return C("(?:",q,")*")}function w(q){return C("(?:",q,")?")}function C(...q){return q.map(Ne=>g(Ne)).join("")}function T(q){const ie=q[q.length-1];return typeof ie=="object"&&ie.constructor===Object?(q.splice(q.length-1,1),ie):{}}function S(...q){return"("+(T(q).capture?"":"?:")+q.map(Le=>g(Le)).join("|")+")"}function _(q){return new RegExp(q.toString()+"|").exec("").length-1}function j(q,ie){const Ne=q&&q.exec(ie);return Ne&&Ne.index===0}const O=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function P(q,{joinWith:ie}){let Ne=0;return q.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=(q={})=>{const ie=/^#![ ]*\//;return q.binary&&(q.begin=C(ie,/.*\b/,q.binary,/\b.*/)),r({scope:"meta",begin:ie,end:/$/,relevance:0,"on:begin":(Ne,Le)=>{Ne.index!==0&&Le.ignoreMatch()}},q)},F={begin:"\\\\[\\s\\S]",relevance:0},Z={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[F]},B={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(q,ie,Ne={}){const Le=r({scope:"comment",begin:q,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("//","$"),U=ne("/\\*","\\*/"),G=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:U,C_LINE_COMMENT_MODE:ke,C_NUMBER_MODE:I,C_NUMBER_RE:H,END_SAME_AS_BEGIN:function(q){return Object.assign(q,{"on:begin":(ie,Ne)=>{Ne.data._beginMatch=ie[1]},"on:end":(ie,Ne)=>{Ne.data._beginMatch!==ie[1]&&Ne.ignoreMatch()}})},HASH_COMMENT_MODE:G,IDENT_RE:$,MATCH_NOTHING_RE:D,METHOD_GUARD:st,NUMBER_MODE:le,NUMBER_RE:ee,PHRASAL_WORDS_MODE:Q,QUOTE_STRING_MODE:B,REGEXP_MODE:$e,RE_STARTERS_RE:ae,SHEBANG:W,TITLE_MODE:Oe,UNDERSCORE_IDENT_RE:X,UNDERSCORE_TITLE_MODE:We});function gt(q,ie){q.input[q.index-1]==="."&&ie.ignoreMatch()}function jt(q,ie){q.className!==void 0&&(q.scope=q.className,delete q.className)}function Jt(q,ie){ie&&q.beginKeywords&&(q.begin="\\b("+q.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",q.__beforeBegin=gt,q.keywords=q.keywords||q.beginKeywords,delete q.beginKeywords,q.relevance===void 0&&(q.relevance=0))}function Rt(q,ie){Array.isArray(q.illegal)&&(q.illegal=S(...q.illegal))}function be(q,ie){if(q.match){if(q.begin||q.end)throw new Error("begin & end are not supported with match");q.begin=q.match,delete q.match}}function Me(q,ie){q.relevance===void 0&&(q.relevance=1)}const qe=(q,ie)=>{if(!q.beforeMatch)return;if(q.starts)throw new Error("beforeMatch cannot be used with starts");const Ne=Object.assign({},q);Object.keys(q).forEach(Le=>{delete q[Le]}),q.keywords=Ne.keywords,q.begin=C(Ne.beforeMatch,x(Ne.begin)),q.starts={relevance:0,contains:[Object.assign(Ne,{endsParent:!0})]},q.relevance=0,delete Ne.beforeMatch},ot=["of","and","for","in","not","or","if","then","parent","list","value"],ft="keyword";function se(q,ie,Ne=ft){const Le=Object.create(null);return typeof q=="string"?Je(Ne,q.split(" ")):Array.isArray(q)?Je(Ne,q):Object.keys(q).forEach(function(vt){Object.assign(Le,se(q[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(q,ie){return ie?Number(ie):Xe(q)?0:1}function Xe(q){return ot.includes(q.toLowerCase())}const Ge={},et=q=>{console.error(q)},yt=(q,...ie)=>{console.log(`WARN: ${q}`,...ie)},he=(q,ie)=>{Ge[`${q}/${ie}`]||(console.log(`Deprecated as of ${q}. ${ie}`),Ge[`${q}/${ie}`]=!0)},V=new Error;function ye(q,ie,{key:Ne}){let Le=0;const Je=q[Ne],vt={},Ie={};for(let tt=1;tt<=ie.length;tt++)Ie[tt+Le]=Je[tt],vt[tt+Le]=!0,Le+=_(ie[tt-1]);q[Ne]=Ie,q[Ne]._emit=vt,q[Ne]._multi=!0}function Qe(q){if(Array.isArray(q.begin)){if(q.skip||q.excludeBegin||q.returnBegin)throw et("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),V;if(typeof q.beginScope!="object"||q.beginScope===null)throw et("beginScope must be object"),V;ye(q,q.begin,{key:"beginScope"}),q.begin=P(q.begin,{joinWith:""})}}function pe(q){if(Array.isArray(q.end)){if(q.skip||q.excludeEnd||q.returnEnd)throw et("skip, excludeEnd, returnEnd not compatible with endScope: {}"),V;if(typeof q.endScope!="object"||q.endScope===null)throw et("endScope must be object"),V;ye(q,q.end,{key:"endScope"}),q.end=P(q.end,{joinWith:""})}}function ve(q){q.scope&&typeof q.scope=="object"&&q.scope!==null&&(q.beginScope=q.scope,delete q.scope)}function Ye(q){ve(q),typeof q.beginScope=="string"&&(q.beginScope={_wrap:q.beginScope}),typeof q.endScope=="string"&&(q.endScope={_wrap:q.endScope}),Qe(q),pe(q)}function nt(q){function ie(Ie,tt){return new RegExp(g(Ie),"m"+(q.case_insensitive?"i":"")+(q.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)),q.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,q.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(q.compilerExtensions||(q.compilerExtensions=[]),q.contains&&q.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return q.classNameAliases=r(q.classNameAliases||{}),vt(q)}function xt(q){return q?q.endsWithParent||xt(q.starts):!1}function Dt(q){return q.variants&&!q.cachedVariants&&(q.cachedVariants=q.variants.map(function(ie){return r(q,{variants:null},ie)})),q.cachedVariants?q.cachedVariants:xt(q)?r(q,{starts:q.starts?r(q.starts):null}):Object.isFrozen(q)?r(q):q}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(q){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(q)}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,q),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(q,{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}),q.debugMode=function(){Je=!1},q.safeMode=function(){Je=!0},q.versionString=ct,q.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(q,At),q},Ve=Pe({});return Ve.newInstance=()=>Pe({}),Fp=Ve,Ve.HighlightJS=Ve,Ve.default=Ve,Fp}var dG=uG();const mG=wc(dG),$2={},fG="hljs-";function pG(e){const t=mG.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:fG;if(!t.getLanguage(m))throw new Error("Unknown language: `"+m+"` is not registered");t.configure({__emitter:hG,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 hG{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 gG={};function s3(e){const t=e||gG,n=t.aliases,r=t.detect||!1,o=t.languages||cG,l=t.plainText,c=t.prefix,d=t.subset;let m="hljs";const p=pG(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=bG(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 bG(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 xG=10,Bh=new Map;function yG(e,t=3e3){Bh.set(e,Date.now()+t)}function vG(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 wG(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 kG({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 B=null;o(Q=>{const ne=Q.find(G=>H2(G.payload)===F);if(ne)return B=ne.id,g.current=Q,Q;let U=[{id:Z,title:wG(W),payload:W},...Q];for(;U.length>xG;){let G=-1;for(let le=U.length-1;le>=0;le--)if(!U[le].pinned){G=le;break}if(G<0)break;U=U.filter((le,I)=>I!==G)}return B=Z,g.current=U,U}),B&&(c(B),x.current=B),n(!0)},[]),S=W=>{W?.kind==="url"&&W.browserId&&(yG(W.browserId),window.markusDesktop?.browser?.destroy(W.browserId))},_=k.useCallback(W=>{let F,Z,B=!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 U=ne.filter(I=>I.id!==W);g.current=U,B=U.length===0;const le=(ne.some(I=>I.id===Q)?Q:ne[0]?.id??null)===W;return Z=void 0,(le||U.length===0)&&(Z=U[Math.min(ke,U.length-1)]?.id??null),U}),B&&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 B=!1;const Q=Z.map(ne=>{if(ne.payload.kind!=="url"||ne.payload.browserId!==W)return ne;B=!0;const ke=F.url??ne.payload.url,U=F.title||ne.payload.title||ke;return{...ne,title:U,payload:{...ne.payload,url:ke,title:U}}});return B&&(g.current=Q),B?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,B=!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){B=!0;const U=g.current;return Z=x.current&&U.some(le=>le.id===x.current)?x.current:U[0].id,U}B=!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]}),B&&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 SG=k.lazy(()=>qr(()=>import("./ContentRenderer-CWE0DlFU.js"),[]).then(e=>({default:e.ContentRenderer})));let wo=[],F2=60;function NG(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 CG(){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),CG()}function V2(e){const t=Pd.get(e);if(t)for(const n of t)n()}function TG(){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 AG(e){Bs.has(e)||u0.has(e)||(u0.add(e),zd&&clearTimeout(zd),zd=setTimeout(TG,30))}function EG(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 _G(e){const t=k.useCallback(o=>EG(e,o),[e]),n=k.useCallback(()=>Bs.get(e),[e]),r=k.useSyncExternalStore(t,n,n);return k.useEffect(()=>{AG(e)},[e]),r}const jG=/^(?:\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|~\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|[A-Za-z]:(?:\\|\/)[\w.\-@+ ]+(?:(?:\\|\/)[\w.\-@+ ]*)*|\.\.?\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*)$/;function MG(e){return e.length<2||e.length>500?!1:jG.test(e)}function RG({filePath:e,onClose:t}){const n=NG(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(SG,{content:d,format:p==="text"?"text":p,className:"text-sm"})})]})]})}),document.body)}function OG({path:e}){const t=_G(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(RG,{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 DG(){return qp||(qp=qr(()=>import("./mermaid.core-C_SBxufd.js").then(e=>e.b9),__vite__mapDeps([0,1])).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:"loose",fontFamily:"inherit"}),e))),qp}function LG(){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 IG(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 PG(){return LG()}function zG(){return k.useSyncExternalStore(IG,PG)}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=zG();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 DG();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 BG="/assets/viz-global-C_AyN6D9.js";let hd=!1,Gp=null;function UG(){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=BG,r.onload=()=>{hd=!0,e()},r.onerror=()=>t(new Error("Failed to load viz-global.js")),document.head.appendChild(r)})}function $G(){return Gp||(Gp=UG().then(()=>qr(()=>import("./plantuml-DezRDxd4.js"),[]))),Gp}let K2=Promise.resolve();function HG(e,t){const n=K2.then(()=>new Promise((r,o)=>{$G().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 FG(){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 qG(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 GG(){return k.useSyncExternalStore(qG,()=>FG())}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=GG();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),HG(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 VG(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 KG(e,t,n,r){const o=VG(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 WG(e){let t=e.replace(/\\\[([\s\S]*?)\\\]/g,(n,r)=>`$$${r}$$`);return t=t.replace(/\\\((.+?)\\\)/g,(n,r)=>`$${r}$`),t}const gd="#mention:";function YG(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:",XG=new RegExp("(?<!\\[)(?<!\\()(?<!:)(?<!\\/)(?<!\\\\)\\b(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}\\b(?!\\]\\(#entity:)","gi"),QG=/`\[([^\]]+)\]\(#entity:((?:tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)`/gi;function ZG(e,t){const n=e.slice(0,t),r=n.lastIndexOf("](");return r===-1?!1:n.indexOf(")",r+2)===-1}function JG(e){return e.replace(QG,(t,n,r)=>`[${n}](${c3}${r})`)}function eV(e){return e.replace(XG,(t,n,r)=>ZG(e,r)?t:`[${t}](${c3}${t})`)}function tV(e){const t=e.trim();return t.startsWith("@startuml")&&t.endsWith("@enduml")}const nV=/^(graph\s|flowchart\s|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt|pie|gitGraph|mindmap|timeline|journey)/m;function rV(e){return nV.test(e.trim())}const aV={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 sV(e){return aV[e.toLowerCase()]??e.charAt(0).toUpperCase()+e.slice(1)}function iV(e){const t=e.match(/language-(\S+)/);return t?t[1]:null}const oV=[o3,l3];function lV(e){for(const t of k.Children.toArray(e))if(k.isValidElement(t)&&typeof t.props?.className=="string"){const n=t.props.className;return iV(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 cV({children:e}){const{t}=dt("common"),n=lV(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)&&oV.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:sV(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}\//,uV=/\.[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 dV(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&&uV.test(r)&&!r.includes("://")?{kind:"file",path:bd(r,t),fragment:o}:{kind:"passthrough"}}function mV(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 fV(){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 pV(e){localStorage.setItem(b3,JSON.stringify(e))}function hV(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 gV({onClose:e}){const{t}=dt("common"),[n,r]=k.useState(x3);k.useEffect(()=>{pV(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 bV=k.lazy(()=>qr(()=>Promise.resolve().then(()=>T3),void 0).then(e=>({default:e.MarkdownMessage}))),xV={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 yV({item:e,onClose:t,onOpenInPage:n}){const{t:r}=dt(["agent","common"]),o=xV[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(bV,{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 vV={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"},wV=/^(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}$/i;function d0(e){return wV.test(e.trim())}function kV(e){const t=e.split("_")[0]?.toLowerCase();return t?vV[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 SV(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??kV(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=SV(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 NV({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(yV,{item:r.deliverable,onClose:()=>l(!1),onOpenInPage:h=>{l(!1),at.navigate(me.DELIVERABLES,{openDeliverable:h})}})]})}class CV extends k.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t){this.state.error&&this.props.resetKeys&&!TV(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 TV(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 AV=/^(deliverable|task|requirement|project|agent|team|workflow):/i;function Z2(e){return AV.test(e)||p3(e)?e:sw(e)}const J2=[Mw,cF,Ok],e4=[fV,[HF,{strict:"ignore"}],[s3,{detect:!0,ignoreMissing:!0}]],$h="text-brand-500 hover:text-brand-500 underline break-all cursor-pointer",EV=/<think>([\s\S]*?)(<\/think>|$)/g;function _V(e){const t=[];let n=e.replace(EV,(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:",jV=/^\[([^\]]+)\]\(#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 MV(e){return e.type==="text"&&(e.value??"").trim()===""}function RV(e){if(!e?.children)return null;const t=e.children.filter(r=>!MV(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 OV={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")||tV(r))return s.jsx(Uh,{code:r,language:"plantuml",children:s.jsx(l3,{code:r})});if(t?.includes("language-mermaid")||!t&&rV(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(jV);return o?s.jsx(sc,{id:o[2],label:o[1]}):MG(n)?s.jsx(OG,{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(cV,{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})},DV=/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i;function LV(e){const t=Pg(e);return p3(e)&&DV.test(t.split("?")[0]??t)}function IV(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 PV(e){return`/api/files/image?path=${encodeURIComponent(e)}`}const ko=new Map;function zV({src:e,alt:t,onPreview:n,basePath:r}){const o=k.useMemo(()=>LV(e)?PV(IV(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 BV(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 UV(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 $V({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 BV(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=UV(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 HV(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 FV({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=HV();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=hV(_),O=await KG(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(gV,{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}=_V(t),m=k.useRef(null),[p,h]=k.useState(null),g=Ec(),x=k.useCallback(T=>{let S=Yl(T,WG);return S=Yl(S,dV),S=Yl(S,JG),S=Yl(S,eV),S=Yl(S,_=>YG(_,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"){mV(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(()=>({...OV,img:({src:T,alt:S})=>s.jsx(zV,{src:T??"",alt:S,onPreview:h,basePath:l},T??""),p:({children:T,node:S})=>{const _=RV(S);return _?s.jsx(NV,{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(FV,{content:t,contentRef:m}),s.jsx("div",{ref:m,children:s.jsx(CV,{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(q)}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,q),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(q,{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}),q.debugMode=function(){Je=!1},q.safeMode=function(){Je=!0},q.versionString=ct,q.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(q,At),q},Ve=Pe({});return Ve.newInstance=()=>Pe({}),Fp=Ve,Ve.HighlightJS=Ve,Ve.default=Ve,Fp}var dG=uG();const mG=wc(dG),$2={},fG="hljs-";function pG(e){const t=mG.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:fG;if(!t.getLanguage(m))throw new Error("Unknown language: `"+m+"` is not registered");t.configure({__emitter:hG,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 hG{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 gG={};function s3(e){const t=e||gG,n=t.aliases,r=t.detect||!1,o=t.languages||cG,l=t.plainText,c=t.prefix,d=t.subset;let m="hljs";const p=pG(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=bG(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 bG(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 xG=10,Bh=new Map;function yG(e,t=3e3){Bh.set(e,Date.now()+t)}function vG(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 wG(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 kG({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 B=null;o(Q=>{const ne=Q.find(G=>H2(G.payload)===F);if(ne)return B=ne.id,g.current=Q,Q;let U=[{id:Z,title:wG(W),payload:W},...Q];for(;U.length>xG;){let G=-1;for(let le=U.length-1;le>=0;le--)if(!U[le].pinned){G=le;break}if(G<0)break;U=U.filter((le,I)=>I!==G)}return B=Z,g.current=U,U}),B&&(c(B),x.current=B),n(!0)},[]),S=W=>{W?.kind==="url"&&W.browserId&&(yG(W.browserId),window.markusDesktop?.browser?.destroy(W.browserId))},_=k.useCallback(W=>{let F,Z,B=!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 U=ne.filter(I=>I.id!==W);g.current=U,B=U.length===0;const le=(ne.some(I=>I.id===Q)?Q:ne[0]?.id??null)===W;return Z=void 0,(le||U.length===0)&&(Z=U[Math.min(ke,U.length-1)]?.id??null),U}),B&&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 B=!1;const Q=Z.map(ne=>{if(ne.payload.kind!=="url"||ne.payload.browserId!==W)return ne;B=!0;const ke=F.url??ne.payload.url,U=F.title||ne.payload.title||ke;return{...ne,title:U,payload:{...ne.payload,url:ke,title:U}}});return B&&(g.current=Q),B?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,B=!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){B=!0;const U=g.current;return Z=x.current&&U.some(le=>le.id===x.current)?x.current:U[0].id,U}B=!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]}),B&&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 SG=k.lazy(()=>qr(()=>import("./ContentRenderer-C6rYWd6u.js"),[]).then(e=>({default:e.ContentRenderer})));let wo=[],F2=60;function NG(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 CG(){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),CG()}function V2(e){const t=Pd.get(e);if(t)for(const n of t)n()}function TG(){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 AG(e){Bs.has(e)||u0.has(e)||(u0.add(e),zd&&clearTimeout(zd),zd=setTimeout(TG,30))}function EG(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 _G(e){const t=k.useCallback(o=>EG(e,o),[e]),n=k.useCallback(()=>Bs.get(e),[e]),r=k.useSyncExternalStore(t,n,n);return k.useEffect(()=>{AG(e)},[e]),r}const jG=/^(?:\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|~\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|[A-Za-z]:(?:\\|\/)[\w.\-@+ ]+(?:(?:\\|\/)[\w.\-@+ ]*)*|\.\.?\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*)$/;function MG(e){return e.length<2||e.length>500?!1:jG.test(e)}function RG({filePath:e,onClose:t}){const n=NG(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(SG,{content:d,format:p==="text"?"text":p,className:"text-sm"})})]})]})}),document.body)}function OG({path:e}){const t=_G(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(RG,{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 DG(){return qp||(qp=qr(()=>import("./mermaid.core-COSp53vV.js").then(e=>e.b9),__vite__mapDeps([0,1])).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:"loose",fontFamily:"inherit"}),e))),qp}function LG(){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 IG(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 PG(){return LG()}function zG(){return k.useSyncExternalStore(IG,PG)}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=zG();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 DG();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 BG="/assets/viz-global-C_AyN6D9.js";let hd=!1,Gp=null;function UG(){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=BG,r.onload=()=>{hd=!0,e()},r.onerror=()=>t(new Error("Failed to load viz-global.js")),document.head.appendChild(r)})}function $G(){return Gp||(Gp=UG().then(()=>qr(()=>import("./plantuml-DezRDxd4.js"),[]))),Gp}let K2=Promise.resolve();function HG(e,t){const n=K2.then(()=>new Promise((r,o)=>{$G().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 FG(){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 qG(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 GG(){return k.useSyncExternalStore(qG,()=>FG())}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=GG();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),HG(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 VG(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 KG(e,t,n,r){const o=VG(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 WG(e){let t=e.replace(/\\\[([\s\S]*?)\\\]/g,(n,r)=>`$$${r}$$`);return t=t.replace(/\\\((.+?)\\\)/g,(n,r)=>`$${r}$`),t}const gd="#mention:";function YG(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:",XG=new RegExp("(?<!\\[)(?<!\\()(?<!:)(?<!\\/)(?<!\\\\)\\b(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}\\b(?!\\]\\(#entity:)","gi"),QG=/`\[([^\]]+)\]\(#entity:((?:tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)`/gi;function ZG(e,t){const n=e.slice(0,t),r=n.lastIndexOf("](");return r===-1?!1:n.indexOf(")",r+2)===-1}function JG(e){return e.replace(QG,(t,n,r)=>`[${n}](${c3}${r})`)}function eV(e){return e.replace(XG,(t,n,r)=>ZG(e,r)?t:`[${t}](${c3}${t})`)}function tV(e){const t=e.trim();return t.startsWith("@startuml")&&t.endsWith("@enduml")}const nV=/^(graph\s|flowchart\s|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt|pie|gitGraph|mindmap|timeline|journey)/m;function rV(e){return nV.test(e.trim())}const aV={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 sV(e){return aV[e.toLowerCase()]??e.charAt(0).toUpperCase()+e.slice(1)}function iV(e){const t=e.match(/language-(\S+)/);return t?t[1]:null}const oV=[o3,l3];function lV(e){for(const t of k.Children.toArray(e))if(k.isValidElement(t)&&typeof t.props?.className=="string"){const n=t.props.className;return iV(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 cV({children:e}){const{t}=dt("common"),n=lV(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)&&oV.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:sV(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}\//,uV=/\.[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 dV(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&&uV.test(r)&&!r.includes("://")?{kind:"file",path:bd(r,t),fragment:o}:{kind:"passthrough"}}function mV(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 fV(){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 pV(e){localStorage.setItem(b3,JSON.stringify(e))}function hV(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 gV({onClose:e}){const{t}=dt("common"),[n,r]=k.useState(x3);k.useEffect(()=>{pV(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 bV=k.lazy(()=>qr(()=>Promise.resolve().then(()=>T3),void 0).then(e=>({default:e.MarkdownMessage}))),xV={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 yV({item:e,onClose:t,onOpenInPage:n}){const{t:r}=dt(["agent","common"]),o=xV[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(bV,{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 vV={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"},wV=/^(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}$/i;function d0(e){return wV.test(e.trim())}function kV(e){const t=e.split("_")[0]?.toLowerCase();return t?vV[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 SV(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??kV(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=SV(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 NV({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(yV,{item:r.deliverable,onClose:()=>l(!1),onOpenInPage:h=>{l(!1),at.navigate(me.DELIVERABLES,{openDeliverable:h})}})]})}class CV extends k.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t){this.state.error&&this.props.resetKeys&&!TV(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 TV(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 AV=/^(deliverable|task|requirement|project|agent|team|workflow):/i;function Z2(e){return AV.test(e)||p3(e)?e:sw(e)}const J2=[Mw,cF,Ok],e4=[fV,[HF,{strict:"ignore"}],[s3,{detect:!0,ignoreMissing:!0}]],$h="text-brand-500 hover:text-brand-500 underline break-all cursor-pointer",EV=/<think>([\s\S]*?)(<\/think>|$)/g;function _V(e){const t=[];let n=e.replace(EV,(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:",jV=/^\[([^\]]+)\]\(#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 MV(e){return e.type==="text"&&(e.value??"").trim()===""}function RV(e){if(!e?.children)return null;const t=e.children.filter(r=>!MV(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 OV={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")||tV(r))return s.jsx(Uh,{code:r,language:"plantuml",children:s.jsx(l3,{code:r})});if(t?.includes("language-mermaid")||!t&&rV(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(jV);return o?s.jsx(sc,{id:o[2],label:o[1]}):MG(n)?s.jsx(OG,{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(cV,{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})},DV=/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i;function LV(e){const t=Pg(e);return p3(e)&&DV.test(t.split("?")[0]??t)}function IV(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 PV(e){return`/api/files/image?path=${encodeURIComponent(e)}`}const ko=new Map;function zV({src:e,alt:t,onPreview:n,basePath:r}){const o=k.useMemo(()=>LV(e)?PV(IV(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 BV(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 UV(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 $V({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 BV(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=UV(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 HV(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 FV({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=HV();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=hV(_),O=await KG(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(gV,{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}=_V(t),m=k.useRef(null),[p,h]=k.useState(null),g=Ec(),x=k.useCallback(T=>{let S=Yl(T,WG);return S=Yl(S,dV),S=Yl(S,JG),S=Yl(S,eV),S=Yl(S,_=>YG(_,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"){mV(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(()=>({...OV,img:({src:T,alt:S})=>s.jsx(zV,{src:T??"",alt:S,onPreview:h,basePath:l},T??""),p:({children:T,node:S})=>{const _=RV(S);return _?s.jsx(NV,{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(FV,{content:t,contentRef:m}),s.jsx("div",{ref:m,children:s.jsx(CV,{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($V,{src:p,onClose:()=>h(null)})]})},(e,t)=>e.content===t.content&&e.className===t.className&&e.basePath===t.basePath&&e.onMentionClick===t.onMentionClick&&qV(e.knownNames,t.knownNames));function qV(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 tY(){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 GV(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 VV(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 nY(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=GV(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 KV(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 WV(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 YV(){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 XV({activities:e,isActive:t,persistent:n}){const{t:r}=dt("common"),o=WV(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(YV,{})]});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 QV={"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"],ZV=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 JV(e){return QV[e]??{label:e.replace(/-/g," ").replace(/\b\w/g,t=>t.toUpperCase()),icon:"⚙",badgeClass:"bg-surface-elevated text-fg-tertiary"}}function eK(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 tK(e){if(e==="completed"||ZV.has(e))return Ro.length;const t=Ro.indexOf(e);return t>=0?t:0}function nK({session:e,className:t}){const n=JV(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(()=>eK(e,l),[e,l]),g=tK(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 rK({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 aK({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 lY(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 cY(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 uY(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 dY(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?"":`${t.getFullYear()}-${t.getMonth()+1}-${t.getDate()}`}function mY(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 fY(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 pY({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 hY({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 gY({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 wK(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 bY(){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 kK(){try{localStorage.setItem(P3,"1")}catch{}}function xY(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(wK(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 yY({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=hK(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 vY({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 wY=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(pK,{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(XV,{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 SK(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 NK({approval:e,submitting:t,readOnly:n,onClose:r,onSubmit:o}){const{t:l}=dt(["team","common"]);zo(!0);const c=k.useMemo(()=>SK(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 CK(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 TK({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),B=k.useRef(!1),[Q,ne]=k.useState(!0),[ke,U]=k.useState(!1),G=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),!B.current){const de=oe.approvals.filter(Pe=>Pe.status==="pending").length;Z.current=de,B.current=!0}}catch{}},[t]),We=k.useCallback(async()=>{if(!(ke||!Q)){U(!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{}U(!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(q=>!q.read&&(_e&&q.metadata?.taskId===_e||de&&q.metadata?.requirementId===de));if(Ve.length===0)return Pe;for(const q of Ve)Ce.notifications.markRead(q.id).catch(()=>{});return H(q=>Math.max(0,q-Ve.length)),Pe.map(q=>Ve.some(ie=>ie.id===q.id)?{...q,read:!0}:q)})},[]),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=CK(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,q)=>new Date(q.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),q=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(),q()}},[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,q=R.top;Ve+de>oe-8&&(Ve=Math.max(8,oe-de-8)),q+Pe>_e-8&&(q=Math.max(8,_e-Pe-8)),F({top:q,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={},q=new URLSearchParams(Pe.path.split("?")[1]||"");for(const[ie,Ne]of q.entries())Ve[ie]=Ne;at.navigate(me.TEAM,Ve);return}if(Pe.path.startsWith("/work")){const Ve={},q=new URLSearchParams(Pe.path.split("?")[1]||"");for(const[ie,Ne]of q.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 q=Ve?.details?.taskId??oe.taskId,ie=Ve?.details?.requirementId??oe.requirementId,Ne=Ve?.details?.agentId??Ve?.agentId;q?at.navigate(me.WORK,{openTask:q}):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 q=y.filter(ie=>ie.id!==R.id&&!ie.read&&(Pe&&ie.metadata?.taskId===Pe||Ve&&ie.metadata?.requirementId===Ve));for(const ie of q)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 q=Ve.details?.taskId,ie=Ve.details?.requirementId,Ne=y.filter(Le=>!Le.read&&(Le.type==="approval_request"&&Le.metadata?.approvalId===R||q&&Le.metadata?.taskId===q||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(NK,{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:G,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,q=($[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",q||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,q||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,q||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,q||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&&kK()},[]),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 q=Ve.changedTouches[0].clientX-de,ie=Ve.changedTouches[0].clientY-Pe;Math.abs(q)>60&&Math.abs(q)>Math.abs(ie)*1.5&&(q<0&&oe<R.length-1&&x(R[oe+1]),q>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 q=de.details?.subType,ie=q==="task"||q==="requirement"||q==="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 AK({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,B=_.current?.offsetHeight??220;let Q=W.right+8;Q+Xp>F-8&&(Q=Math.max(8,W.left-Xp-8));let ne=W.top-B-8;ne<8&&(ne=Math.min(W.bottom+8,Z-B-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 B=Z.target;S.current?.contains(B)||_.current?.contains(B)||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.0-rc.11"]}),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 EK({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 _K({currentPage:e,onNavigate:t,authUser:n,collapsed:r,onToggleCollapse:o,onLogout:l}){const{t:c}=dt(["nav","common"]);return s.jsxs("aside",{className:"h-dvh bg-surface-secondary flex flex-col shrink-0 overflow-hidden",children:[s.jsx("div",{className:`flex items-center ${r?"px-2 py-3.5 justify-center":"px-4 h-14 justify-between"}`,children:s.jsxs("button",{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:uD.map((d,m)=>{const p=dD.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(TK,{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(EK,{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(AK,{authUser:n,onLogout:l,onEditProfile:()=>{window.dispatchEvent(new Event("markus:open-edit-profile"))},showSettingsLink:!1,collapsed:r,showVersion:!r})})]})}const jK=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 MK(){ic||(Kh(),ic=setInterval(Kh,jK),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 RK(){ic&&(clearInterval(ic),ic=null),Ud&&(Ud(),Ud=null)}function OK(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++,MK();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,RK())}},[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 kY(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 DK({currentPage:e,onNavigate:t,userId:n}){const{t:r}=dt("nav"),[o,l]=k.useState(0),{counts:c}=OK({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:mD.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 LK={agent:258,team:205,skill:32,connector:162};function Bg(e,t){const n=LK[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 IK(e){return!e||$3(e)?!1:[...e].length<=4&&new RegExp("\\p{Extended_Pictographic}","u").test(e)}function PK(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"}},zK=["development","devops","management","productivity","browser","custom","general"],BK=[{label:"Tech",emojis:["✦","◈","⬡","⚡","🤖","🧠","💡","🎯","🔧","📦","🚀","💻","🛠️","⭐","🔥","💎","⚙️","🧩","🔌","💾","🖥️","📡","🔬","🧪","🏗️","📱","🎮","🕹️","📟","💽","🖨️","⌨️"]},{label:"People",emojis:["👤","👥","🧑💻","👨💼","👩🔬","🧙","🦸","🤝","💪","🎓","👷","🕵️","🧑🎨","🧑🏫","👨🚀","🥷","🧑🏭","🧑⚕️","🧑🔧","🧑🍳","👨🎤","🦹","🧝","🧞","🧑✈️","💂","🤴","👸","🧛","🧟","🧜","🧚"]},{label:"Objects",emojis:["📝","📊","🗂️","📁","🔍","🔑","🌐","💬","🔒","🎨","📐","🗃️","📋","✏️","🖊️","📌","📎","🧲","🪝","🧰","🪜","🧬","🔭","💊","🩺","📕","📗","📘","📙","📓","🗒️","📰"]},{label:"Symbols",emojis:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","♠️","♥️","♦️","♣️","🎵","🎶","💯","✅","❌","⭕","🔴","🟠","🟡","🟢","🔵","🟣","⚫","⚪","🟤","🔶","🔷","▶️","⏸️","⏹️"]},{label:"Nature",emojis:["🌟","🌈","🌊","🌿","🍀","🔮","💫","✨","🌙","☀️","🦋","🐉","🦊","🐺","🦅","🐙","🦁","🐯","🦄","🐲","🌸","🌺","🍄","🌵","🎄","🌴","🍁","🌻","🐝","🦎","🐍","🦈"]},{label:"Activity",emojis:["🎯","🏆","🥇","🎖️","🏅","🎪","🎭","🎬","🎤","🎧","🎼","🎹","🥁","🎸","🎺","🎻","⚽","🏀","🎾","🏐","🎲","🧸","🪁","🎰","🎳","🏹","🥊","🤺","⛷️","🏄","🚴","🧗"]}],UK={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 $K({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 HK({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 CK(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 TK({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),B=k.useRef(!1),[Q,ne]=k.useState(!0),[ke,U]=k.useState(!1),G=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),!B.current){const de=oe.approvals.filter(Pe=>Pe.status==="pending").length;Z.current=de,B.current=!0}}catch{}},[t]),We=k.useCallback(async()=>{if(!(ke||!Q)){U(!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{}U(!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(q=>!q.read&&(_e&&q.metadata?.taskId===_e||de&&q.metadata?.requirementId===de));if(Ve.length===0)return Pe;for(const q of Ve)Ce.notifications.markRead(q.id).catch(()=>{});return H(q=>Math.max(0,q-Ve.length)),Pe.map(q=>Ve.some(ie=>ie.id===q.id)?{...q,read:!0}:q)})},[]),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=CK(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,q)=>new Date(q.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),q=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(),q()}},[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,q=R.top;Ve+de>oe-8&&(Ve=Math.max(8,oe-de-8)),q+Pe>_e-8&&(q=Math.max(8,_e-Pe-8)),F({top:q,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={},q=new URLSearchParams(Pe.path.split("?")[1]||"");for(const[ie,Ne]of q.entries())Ve[ie]=Ne;at.navigate(me.TEAM,Ve);return}if(Pe.path.startsWith("/work")){const Ve={},q=new URLSearchParams(Pe.path.split("?")[1]||"");for(const[ie,Ne]of q.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 q=Ve?.details?.taskId??oe.taskId,ie=Ve?.details?.requirementId??oe.requirementId,Ne=Ve?.details?.agentId??Ve?.agentId;q?at.navigate(me.WORK,{openTask:q}):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 q=y.filter(ie=>ie.id!==R.id&&!ie.read&&(Pe&&ie.metadata?.taskId===Pe||Ve&&ie.metadata?.requirementId===Ve));for(const ie of q)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 q=Ve.details?.taskId,ie=Ve.details?.requirementId,Ne=y.filter(Le=>!Le.read&&(Le.type==="approval_request"&&Le.metadata?.approvalId===R||q&&Le.metadata?.taskId===q||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(NK,{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:G,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,q=($[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",q||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,q||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,q||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,q||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&&kK()},[]),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 q=Ve.changedTouches[0].clientX-de,ie=Ve.changedTouches[0].clientY-Pe;Math.abs(q)>60&&Math.abs(q)>Math.abs(ie)*1.5&&(q<0&&oe<R.length-1&&x(R[oe+1]),q>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 q=de.details?.subType,ie=q==="task"||q==="requirement"||q==="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 AK({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,B=_.current?.offsetHeight??220;let Q=W.right+8;Q+Xp>F-8&&(Q=Math.max(8,W.left-Xp-8));let ne=W.top-B-8;ne<8&&(ne=Math.min(W.bottom+8,Z-B-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 B=Z.target;S.current?.contains(B)||_.current?.contains(B)||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.0-rc.13"]}),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 EK({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 _K({currentPage:e,onNavigate:t,authUser:n,collapsed:r,onToggleCollapse:o,onLogout:l}){const{t:c}=dt(["nav","common"]);return s.jsxs("aside",{className:"h-dvh bg-surface-secondary flex flex-col shrink-0 overflow-hidden",children:[s.jsx("div",{className:`flex items-center ${r?"px-2 py-3.5 justify-center":"px-4 h-14 justify-between"}`,children:s.jsxs("button",{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:uD.map((d,m)=>{const p=dD.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(TK,{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(EK,{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(AK,{authUser:n,onLogout:l,onEditProfile:()=>{window.dispatchEvent(new Event("markus:open-edit-profile"))},showSettingsLink:!1,collapsed:r,showVersion:!r})})]})}const jK=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 MK(){ic||(Kh(),ic=setInterval(Kh,jK),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 RK(){ic&&(clearInterval(ic),ic=null),Ud&&(Ud(),Ud=null)}function OK(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++,MK();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,RK())}},[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 kY(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 DK({currentPage:e,onNavigate:t,userId:n}){const{t:r}=dt("nav"),[o,l]=k.useState(0),{counts:c}=OK({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:mD.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 LK={agent:258,team:205,skill:32,connector:162};function Bg(e,t){const n=LK[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 IK(e){return!e||$3(e)?!1:[...e].length<=4&&new RegExp("\\p{Extended_Pictographic}","u").test(e)}function PK(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"}},zK=["development","devops","management","productivity","browser","custom","general"],BK=[{label:"Tech",emojis:["✦","◈","⬡","⚡","🤖","🧠","💡","🎯","🔧","📦","🚀","💻","🛠️","⭐","🔥","💎","⚙️","🧩","🔌","💾","🖥️","📡","🔬","🧪","🏗️","📱","🎮","🕹️","📟","💽","🖨️","⌨️"]},{label:"People",emojis:["👤","👥","🧑💻","👨💼","👩🔬","🧙","🦸","🤝","💪","🎓","👷","🕵️","🧑🎨","🧑🏫","👨🚀","🥷","🧑🏭","🧑⚕️","🧑🔧","🧑🍳","👨🎤","🦹","🧝","🧞","🧑✈️","💂","🤴","👸","🧛","🧟","🧜","🧚"]},{label:"Objects",emojis:["📝","📊","🗂️","📁","🔍","🔑","🌐","💬","🔒","🎨","📐","🗃️","📋","✏️","🖊️","📌","📎","🧲","🪝","🧰","🪜","🧬","🔭","💊","🩺","📕","📗","📘","📙","📓","🗒️","📰"]},{label:"Symbols",emojis:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","♠️","♥️","♦️","♣️","🎵","🎶","💯","✅","❌","⭕","🔴","🟠","🟡","🟢","🔵","🟣","⚫","⚪","🟤","🔶","🔷","▶️","⏸️","⏹️"]},{label:"Nature",emojis:["🌟","🌈","🌊","🌿","🍀","🔮","💫","✨","🌙","☀️","🦋","🐉","🦊","🐺","🦅","🐙","🦁","🐯","🦄","🐲","🌸","🌺","🍄","🌵","🎄","🌴","🍁","🌻","🐝","🦎","🐍","🦈"]},{label:"Activity",emojis:["🎯","🏆","🥇","🎖️","🏅","🎪","🎭","🎬","🎤","🎧","🎼","🎹","🥁","🎸","🎺","🎻","⚽","🏀","🎾","🏐","🎲","🧸","🪁","🎰","🎳","🏹","🥊","🤺","⛷️","🏄","🚴","🧗"]}],UK={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 $K({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 HK({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 FK(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(()=>FK(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 qK({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 GK({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),[B,Q]=k.useState(!1),[ne,ke]=k.useState(!1),[U,G]=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 q=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});q.id&&($({shared:!0,id:q.id,slug:q.slug??nt,version:_e,visibility:q.visibility??pe?.visibility??"public",moderationStatus:q.moderationStatus,pendingReview:q.pendingReview}),K(!1),(q.visibility??pe?.visibility??"public")!=="org"&&(q.moderationStatus==="pending"||q.pendingReview)?G({title:m("common:share"),message:ve.converted?m("share.convertedAndSubmitted",{previous:t,slug:nt}):q.updated?m("share.updateSubmitted"):m("share.submittedForReview"),variant:"primary"}):ve.converted&&G({title:m("common:share"),message:m("share.convertedSlug",{previous:t,slug:nt}),variant:"primary"}))}catch(ve){console.error("Share to Hub failed:",ve),G({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:BK.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($K,{value:st,options:zK,onChange:pe=>ft("category",pe),className:"text-xs px-2 py-0.5 rounded bg-surface-elevated text-fg-tertiary",readOnly:o}),s.jsx(HK,{tags:At,onChange:pe=>ft("tags",pe),readOnly:o})]})]})]}),s.jsx("div",{className:"mb-8",children:s.jsx(qK,{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(GK,{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=UK[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(KK,{onClose:()=>Z(!1),onConfirm:(pe,ve)=>{Z(!1),Be({donationsEnabled:!1,priceCents:pe==="paid"?ve:void 0})},isUpdate:D.shared}),!o&&B&&s.jsx(VK,{onClose:()=>Q(!1),onConfirm:(pe,ve,Ye,nt)=>{Q(!1),Be({visibility:pe,orgId:ve,priceCents:Ye,donationsEnabled:nt})}}),U&&s.jsx(dr,{alertOnly:!0,variant:U.variant??"primary",title:U.title,message:U.message,onConfirm:()=>G(null),onCancel:()=>G(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 VK({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 KK({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 WK({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}`}):IK(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&&KV(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:PK(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 YK({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,B=(T??0)>0,Q=!!b0(c||void 0,d),ne=Bg(W,Z),ke=p??m?.displayName??m?.username??"",[U,G]=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:$}):B?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:U??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&&G(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(YK,{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:B?"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(WK,{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 XK(e){const t=e.indexOf(".markus/builder-artifacts/");return t>=0?"~/"+e.slice(t):e}const QK=[{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 ZK(){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 JK(){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=ZK(),[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(JK),[X,ee]=k.useState(null),[H,K]=k.useState(null),[ae,W]=k.useState(null),[F,Z]=k.useState(null),[B,Q]=k.useState(null),[ne,ke]=k.useState("creations"),[U,G]=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(),q=new File([Ve],de,{type:Ve.type}),ie=await it.uploadImage(q);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"||U.length>0||it.myOrgs().then(se=>{G(se.memberships),se.memberships.length>0&&!le&&I(se.memberships[0].id)}).catch(()=>{})},[ne,U.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:QK.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"&&U.length>0&&s.jsx("div",{className:"flex gap-2 mb-3 overflow-x-auto pb-1",children:U.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"&&(U.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:XK(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(tW,{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})}})})}),B&&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(eW,{onCancel:()=>Q(null),onConfirm:(se,Be,Xe,Ge)=>{const et=B;Q(null),Rt(et,{visibility:se,orgId:Be,priceCents:Xe,donationsEnabled:Ge})}})})})]})})}function eW({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 tW({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 nW=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 rW(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 aW={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function sW({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,B]=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=!!B.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}),B=new URLSearchParams;c&&B.set("q",c);const Q=fetch("/api/templates?"+B.toString()).then(G=>G.json()).catch(()=>({templates:[]})),[ne,ke]=await Promise.all([Z.catch(()=>({items:[],total:0})),Q,ae(),it.isAuthenticated()?it.purchases.mine().then(G=>$(new Set(G.purchases.map(le=>le.itemId)))).catch(()=>{}):Promise.resolve()]),U=await V3(ne?.items??[],t);g(U.items),p(Array.isArray(ke.templates)?ke.templates:[]),U.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,B,Q)=>{try{const ne=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:Z,name:B,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}},B=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 ${aW[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:B}),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",{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,B)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},B))}):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(iW,{item:Z,localInfo:O.get(_c(Z)),purchased:Kd(Z,D),onStatusChange:ae,highlight:Z.id===t,onHighlightDone:n,onViewDetail:B=>ee({type:"agent",name:B})},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 iW({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&&rW(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 oW(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 lW({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:{}}))]),B=new Map;for(const Q of F.artifacts){if(Q.type!=="team")continue;const ne=!!Z.installed[`team/${Q.name}`];B.set(Q.name,{installed:ne,localVersion:Q.meta.version||void 0,localUpdatedAt:Q.updatedAt})}D(B)}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,B]=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(B?.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 B=(await Ce.teams.create(F.name,F.description)).team.id;let Q,ne=0;const ke=[];for(const G of F.members){const le=G.count??1;for(let I=0;I<le;I++){const Ae=G.name??`${F.name} Agent ${I+1}`,$e=le>1?`${Ae} ${I+1}`:Ae,Oe=G.roleName??G.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:B,agentRole:G.role??"worker",skills:G.skills??[]})});if(We.ok){ne++;const st=await We.json();G.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(B,{managerId:Q,managerType:"agent"}).catch(()=>{});const U=ke.length>0?` (${ke.length} failed: ${ke[0]})`:"";O({ok:ne>0,message:`Team "${Jp(F,o)}" deployed with ${ne} agent(s)${U}`})}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??[]}))}},B=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(U=>s.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-surface-elevated text-fg-muted rounded border border-border-default",children:U},U)),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:B,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",{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(cW,{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 cW({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&&oW(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 uW={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 dW({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(dW,{item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o})})})}function mW({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),[B,Q]=k.useState([]),[ne,ke]=k.useState(!1),[U,G]=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);G(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=U.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 ${uW[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",{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?B.filter(ve=>eh(ve,o).toLowerCase().includes(V)||th(ve,o).toLowerCase().includes(V)):B,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 fW=["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 pW({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 hW({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:fW.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(pW,{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(gW,{})]}),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 gW(){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 bW(){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",{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 xW=50,yW=30;function vW(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<xW||Math.atan2(x,g)*(180/Math.PI)>yW)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 wW=["builder","discover","agents","teams","skills","installed"],kW={agent:"agents",team:"teams",skill:"skills",connector:"skills"};function Yh(e){return!!e&&wW.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 SW({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=vW(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(kW[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(hW,{onOpenType:p}),o==="agents"&&s.jsx(sW,{authUser:e,highlightItemId:c,onHighlightDone:()=>d(null)}),o==="teams"&&s.jsx(lW,{highlightItemId:c,onHighlightDone:()=>d(null)}),o==="skills"&&s.jsx(mW,{highlightItemId:c,onHighlightDone:()=>d(null)}),o==="installed"&&s.jsx(bW,{})]})]})}const L4="usageType",rh="profile";function NW({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),[B,Q]=k.useState(""),[ne,ke]=k.useState([]),[U,G]=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()=>{G(be.orgId);try{await Ce.hubOrgs.acceptInvitation(be.orgId),I(be.orgId),Z(!0)}catch{}finally{G(null)}},disabled:U===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"):U===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"})]}),B&&s.jsx("p",{className:"text-xs text-red-500",children:B}),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",CW="https://markus.global";function TW({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`${CW}${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)}}},$=()=>{wD(),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 vD(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 AW({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 EW({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 _W({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 SY=[{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 jW(){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 MW(){const[e,t]=k.useState(jW),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:[]},RW={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},OW=["agents","tasks","requirements","projects","deliverables","workflows"];let z4="",B4="all",U4=$d,$4=!1;function DW({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,B,Q,ne,ke,U]=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()]),G=Z.status==="fulfilled"?Z.value.agents.filter(We=>We.name?.toLowerCase().includes(F)||We.role?.toLowerCase().includes(F)):[],le=B.status==="fulfilled"?B.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(U.status==="fulfilled"){const We=await Promise.allSettled(U.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:G,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(()=>RW[t||""]||OW,[t]),X=k.useMemo(()=>{const W=[],F=l==="all"?8:void 0,Z=B=>{if(l!=="all"&&l!==B)return;const Q=d[B].length;if(B==="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[B],ke=F?ne.slice(0,F):ne;for(const U of ke)switch(B){case"agents":W.push({id:U.id,type:"agent",page:me.TEAM,params:{agentId:U.id}});break;case"tasks":W.push({id:U.id,type:"task",page:me.WORK,params:{openTask:U.id}});break;case"requirements":W.push({id:U.id,type:"requirement",page:me.WORK,params:{openRequirement:U.id}});break;case"projects":W.push({id:U.id,type:"project",page:me.WORK,params:{projectId:U.id}});break;case"deliverables":W.push({id:U.id,type:"deliverable",page:me.DELIVERABLES,params:{openDeliverable:U.id}});break}}F&&Q>F&&W.push({id:`more_${B}`,type:"showMore",page:"",expandCategory:B,totalCount:Q})};for(const B of $)Z(B);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 B=D.map(ke=>ke.id),Q=B.indexOf(l),ne=W.shiftKey?Q<=0?B.length-1:Q-1:Q>=B.length-1?0:Q+1;c(B[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(B=>{const Q=X.length-1;return Q<0?-1:F?B>=Q?0:B+1:B<=0?Q:B-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=B=>{const Q=ae++,ne=B==="agents"?d.agents.length:B==="tasks"?d.tasks.length:B==="requirements"?d.requirements.length:B==="projects"?d.projects.length:B==="workflows"?d.workflows.length:d.deliverables.length;return s.jsxs("button",{"data-idx":Q,onClick:()=>{c(B),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(B=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(me.TEAM,{agentId:B.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:B.name||"Agent",avatarUrl:B.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:B.name}),s.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:B.role||B.status})]}),s.jsx(LW,{status:B.status})]},B.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(B=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(me.WORK,{openTask:B.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(IW,{status:B.status}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:B.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[B.status," · ",B.priority||""]})]})]},B.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(B=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(me.WORK,{openRequirement:B.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 ${B.status==="approved"?"text-green-500 bg-green-500/15":B.status==="pending"?"text-amber-500 bg-amber-500/15":B.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:B.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[B.status," · ",B.priority||""]})]})]},B.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(B=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(me.WORK,{projectId:B.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:B.name}),B.description&&s.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:B.description})]})]},B.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(B=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(me.DELIVERABLES,{openDeliverable:B.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:B.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[B.type," · ",B.status]})]})]},B.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(B=>{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:B.displayName||B.name}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[B.stepCount," steps · v",B.version]})]})]},B.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 LW({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 IW({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 PW({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-C1ifTSrO.js"),__vite__mapDeps([2,3,4])).then(e=>({default:e.TeamPage}))),F4=k.lazy(()=>qr(()=>import("./Settings-2wot9SJH.js"),[]).then(e=>({default:e.Settings}))),zW=k.lazy(()=>qr(()=>import("./Store-CIMb8oMO.js"),[]).then(e=>({default:e.StorePage}))),BW=k.lazy(()=>qr(()=>Promise.resolve().then(()=>nW),void 0).then(e=>({default:e.AgentBuilder}))),q4=k.lazy(()=>qr(()=>import("./Work-Cz9u7f2u.js"),__vite__mapDeps([5,4,1,6,3,7])).then(e=>({default:e.WorkPage}))),G4=k.lazy(()=>qr(()=>import("./Deliverables-BbXx2sVi.js"),__vite__mapDeps([8,4])).then(e=>({default:e.DeliverablesPage}))),UW=k.lazy(()=>qr(()=>import("./Notifications-DZ1RS03a.js"),[]).then(e=>({default:e.NotificationsPage}))),$W=k.lazy(()=>qr(()=>import("./Search-BpFJHR4B.js"),[]).then(e=>({default:e.SearchPage}))),HW={visibility:"hidden",position:"absolute",inset:0,pointerEvents:"none",zIndex:-1};function FW(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 qW(){return s.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm animate-pulse",children:"Loading..."})}const GW=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:HW,children:s.jsx(k.Suspense,{fallback:s.jsx(qW,{}),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 VW(){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=MW(),p=_W({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}),[B,Q]=k.useState(!1),ne=Ec(),ke=ne?.leftCollapsed??!1,U=ne?.toggleLeftCollapsed,G=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_")||vG(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||!U||!G)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(),U()):ft==="l"&&(qe.preventDefault(),G())};return document.addEventListener("keydown",Me),()=>document.removeEventListener("keydown",Me)},[d,U,G]);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),FW(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(SW,{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(UW,{authUser:gt}),[me.SEARCH]:s.jsx($W,{})}:{[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(zW,{authUser:gt}),[me.BUILDER]:s.jsx(BW,{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(AW,{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(TW,{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(EW,{onComplete:()=>$(!1),isFirstTime:!0}):r?s.jsx(NW,{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(_K,{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(GW,{id:be,activePage:t,children:jt[be]},be):null)})]}),d&&t!==me.SETTINGS&&t!==me.SEARCH&&s.jsx(DK,{currentPage:t,onNavigate:st,userId:gt?.id}),d&&s.jsx(AD,{authUser:gt,onNavigate:st}),!d&&B&&s.jsx(DW,{onClose:()=>Q(!1),currentPage:t}),w&>&&s.jsx(PW,{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(kG,{children:s.jsx(VW,{})})}));export{QW as $,Us as A,TD as B,_W as C,cc as D,Ig as E,wc as F,zo as G,Q7 as H,bW as I,dr as J,YW as K,XW as L,x5 as M,TK as N,Xd as O,me as P,mK as Q,vY as R,hW as S,sW as T,xV as U,Q2 as V,yV as W,ZW as X,rY as Y,pK as Z,qr as _,Bo as a,Ci as a0,Vo as a1,Ec as a2,cY as a3,OK as a4,kY as a5,fY as a6,tY as a7,lY as a8,Ya as a9,hY as aa,CV as ab,pY as ac,gY as ad,NK as ae,wK as af,bY as ag,v0 as ah,J7 as ai,KW as aj,Ni as ak,pD as al,E3 as am,nY as an,i4 as ao,g4 as ap,aK as aq,rK as ar,pc as as,SY as at,WW as au,sa as av,yn as aw,na as ax,eY as ay,T3 as az,vW as b,lW as c,mW as d,Sa as e,Ce as f,iY as g,it as h,ki as i,s as j,vK as k,xY as l,dY as m,at as n,mY as o,uY as p,wY as q,k as r,zg as s,Er as t,dt as u,yY as v,va as w,oY as x,aY as y,sY 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 FK(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(()=>FK(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 qK({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 GK({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),[B,Q]=k.useState(!1),[ne,ke]=k.useState(!1),[U,G]=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 q=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});q.id&&($({shared:!0,id:q.id,slug:q.slug??nt,version:_e,visibility:q.visibility??pe?.visibility??"public",moderationStatus:q.moderationStatus,pendingReview:q.pendingReview}),K(!1),(q.visibility??pe?.visibility??"public")!=="org"&&(q.moderationStatus==="pending"||q.pendingReview)?G({title:m("common:share"),message:ve.converted?m("share.convertedAndSubmitted",{previous:t,slug:nt}):q.updated?m("share.updateSubmitted"):m("share.submittedForReview"),variant:"primary"}):ve.converted&&G({title:m("common:share"),message:m("share.convertedSlug",{previous:t,slug:nt}),variant:"primary"}))}catch(ve){console.error("Share to Hub failed:",ve),G({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:BK.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($K,{value:st,options:zK,onChange:pe=>ft("category",pe),className:"text-xs px-2 py-0.5 rounded bg-surface-elevated text-fg-tertiary",readOnly:o}),s.jsx(HK,{tags:At,onChange:pe=>ft("tags",pe),readOnly:o})]})]})]}),s.jsx("div",{className:"mb-8",children:s.jsx(qK,{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(GK,{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=UK[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(KK,{onClose:()=>Z(!1),onConfirm:(pe,ve)=>{Z(!1),Be({donationsEnabled:!1,priceCents:pe==="paid"?ve:void 0})},isUpdate:D.shared}),!o&&B&&s.jsx(VK,{onClose:()=>Q(!1),onConfirm:(pe,ve,Ye,nt)=>{Q(!1),Be({visibility:pe,orgId:ve,priceCents:Ye,donationsEnabled:nt})}}),U&&s.jsx(dr,{alertOnly:!0,variant:U.variant??"primary",title:U.title,message:U.message,onConfirm:()=>G(null),onCancel:()=>G(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 VK({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 KK({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 WK({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}`}):IK(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&&KV(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:PK(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 YK({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,B=(T??0)>0,Q=!!b0(c||void 0,d),ne=Bg(W,Z),ke=p??m?.displayName??m?.username??"",[U,G]=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:$}):B?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:U??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&&G(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(YK,{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:B?"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(WK,{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 XK(e){const t=e.indexOf(".markus/builder-artifacts/");return t>=0?"~/"+e.slice(t):e}const QK=[{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 ZK(){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 JK(){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=ZK(),[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(JK),[X,ee]=k.useState(null),[H,K]=k.useState(null),[ae,W]=k.useState(null),[F,Z]=k.useState(null),[B,Q]=k.useState(null),[ne,ke]=k.useState("creations"),[U,G]=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(),q=new File([Ve],de,{type:Ve.type}),ie=await it.uploadImage(q);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"||U.length>0||it.myOrgs().then(se=>{G(se.memberships),se.memberships.length>0&&!le&&I(se.memberships[0].id)}).catch(()=>{})},[ne,U.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:QK.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"&&U.length>0&&s.jsx("div",{className:"flex gap-2 mb-3 overflow-x-auto pb-1",children:U.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"&&(U.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:XK(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(tW,{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})}})})}),B&&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(eW,{onCancel:()=>Q(null),onConfirm:(se,Be,Xe,Ge)=>{const et=B;Q(null),Rt(et,{visibility:se,orgId:Be,priceCents:Xe,donationsEnabled:Ge})}})})})]})})}function eW({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 tW({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 nW=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 rW(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 aW={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function sW({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,B]=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=!!B.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}),B=new URLSearchParams;c&&B.set("q",c);const Q=fetch("/api/templates?"+B.toString()).then(G=>G.json()).catch(()=>({templates:[]})),[ne,ke]=await Promise.all([Z.catch(()=>({items:[],total:0})),Q,ae(),it.isAuthenticated()?it.purchases.mine().then(G=>$(new Set(G.purchases.map(le=>le.itemId)))).catch(()=>{}):Promise.resolve()]),U=await V3(ne?.items??[],t);g(U.items),p(Array.isArray(ke.templates)?ke.templates:[]),U.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,B,Q)=>{try{const ne=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:Z,name:B,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}},B=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 ${aW[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:B}),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",{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,B)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},B))}):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(iW,{item:Z,localInfo:O.get(_c(Z)),purchased:Kd(Z,D),onStatusChange:ae,highlight:Z.id===t,onHighlightDone:n,onViewDetail:B=>ee({type:"agent",name:B})},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 iW({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&&rW(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 oW(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 lW({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:{}}))]),B=new Map;for(const Q of F.artifacts){if(Q.type!=="team")continue;const ne=!!Z.installed[`team/${Q.name}`];B.set(Q.name,{installed:ne,localVersion:Q.meta.version||void 0,localUpdatedAt:Q.updatedAt})}D(B)}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,B]=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(B?.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 B=(await Ce.teams.create(F.name,F.description)).team.id;let Q,ne=0;const ke=[];for(const G of F.members){const le=G.count??1;for(let I=0;I<le;I++){const Ae=G.name??`${F.name} Agent ${I+1}`,$e=le>1?`${Ae} ${I+1}`:Ae,Oe=G.roleName??G.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:B,agentRole:G.role??"worker",skills:G.skills??[]})});if(We.ok){ne++;const st=await We.json();G.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(B,{managerId:Q,managerType:"agent"}).catch(()=>{});const U=ke.length>0?` (${ke.length} failed: ${ke[0]})`:"";O({ok:ne>0,message:`Team "${Jp(F,o)}" deployed with ${ne} agent(s)${U}`})}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??[]}))}},B=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(U=>s.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-surface-elevated text-fg-muted rounded border border-border-default",children:U},U)),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:B,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",{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(cW,{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 cW({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&&oW(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 uW={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 dW({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(dW,{item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o})})})}function mW({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),[B,Q]=k.useState([]),[ne,ke]=k.useState(!1),[U,G]=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);G(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=U.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 ${uW[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",{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?B.filter(ve=>eh(ve,o).toLowerCase().includes(V)||th(ve,o).toLowerCase().includes(V)):B,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 fW=["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 pW({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 hW({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:fW.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(pW,{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(gW,{})]}),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 gW(){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 bW(){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",{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 xW=50,yW=30;function vW(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<xW||Math.atan2(x,g)*(180/Math.PI)>yW)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 wW=["builder","discover","agents","teams","skills","installed"],kW={agent:"agents",team:"teams",skill:"skills",connector:"skills"};function Yh(e){return!!e&&wW.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 SW({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=vW(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(kW[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(hW,{onOpenType:p}),o==="agents"&&s.jsx(sW,{authUser:e,highlightItemId:c,onHighlightDone:()=>d(null)}),o==="teams"&&s.jsx(lW,{highlightItemId:c,onHighlightDone:()=>d(null)}),o==="skills"&&s.jsx(mW,{highlightItemId:c,onHighlightDone:()=>d(null)}),o==="installed"&&s.jsx(bW,{})]})]})}const L4="usageType",rh="profile";function NW({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),[B,Q]=k.useState(""),[ne,ke]=k.useState([]),[U,G]=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()=>{G(be.orgId);try{await Ce.hubOrgs.acceptInvitation(be.orgId),I(be.orgId),Z(!0)}catch{}finally{G(null)}},disabled:U===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"):U===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"})]}),B&&s.jsx("p",{className:"text-xs text-red-500",children:B}),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",CW="https://markus.global";function TW({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`${CW}${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)}}},$=()=>{wD(),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 vD(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 AW({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 EW({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 _W({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 SY=[{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 jW(){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 MW(){const[e,t]=k.useState(jW),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:[]},RW={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},OW=["agents","tasks","requirements","projects","deliverables","workflows"];let z4="",B4="all",U4=$d,$4=!1;function DW({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,B,Q,ne,ke,U]=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()]),G=Z.status==="fulfilled"?Z.value.agents.filter(We=>We.name?.toLowerCase().includes(F)||We.role?.toLowerCase().includes(F)):[],le=B.status==="fulfilled"?B.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(U.status==="fulfilled"){const We=await Promise.allSettled(U.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:G,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(()=>RW[t||""]||OW,[t]),X=k.useMemo(()=>{const W=[],F=l==="all"?8:void 0,Z=B=>{if(l!=="all"&&l!==B)return;const Q=d[B].length;if(B==="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[B],ke=F?ne.slice(0,F):ne;for(const U of ke)switch(B){case"agents":W.push({id:U.id,type:"agent",page:me.TEAM,params:{agentId:U.id}});break;case"tasks":W.push({id:U.id,type:"task",page:me.WORK,params:{openTask:U.id}});break;case"requirements":W.push({id:U.id,type:"requirement",page:me.WORK,params:{openRequirement:U.id}});break;case"projects":W.push({id:U.id,type:"project",page:me.WORK,params:{projectId:U.id}});break;case"deliverables":W.push({id:U.id,type:"deliverable",page:me.DELIVERABLES,params:{openDeliverable:U.id}});break}}F&&Q>F&&W.push({id:`more_${B}`,type:"showMore",page:"",expandCategory:B,totalCount:Q})};for(const B of $)Z(B);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 B=D.map(ke=>ke.id),Q=B.indexOf(l),ne=W.shiftKey?Q<=0?B.length-1:Q-1:Q>=B.length-1?0:Q+1;c(B[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(B=>{const Q=X.length-1;return Q<0?-1:F?B>=Q?0:B+1:B<=0?Q:B-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=B=>{const Q=ae++,ne=B==="agents"?d.agents.length:B==="tasks"?d.tasks.length:B==="requirements"?d.requirements.length:B==="projects"?d.projects.length:B==="workflows"?d.workflows.length:d.deliverables.length;return s.jsxs("button",{"data-idx":Q,onClick:()=>{c(B),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(B=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(me.TEAM,{agentId:B.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:B.name||"Agent",avatarUrl:B.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:B.name}),s.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:B.role||B.status})]}),s.jsx(LW,{status:B.status})]},B.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(B=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(me.WORK,{openTask:B.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(IW,{status:B.status}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:B.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[B.status," · ",B.priority||""]})]})]},B.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(B=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(me.WORK,{openRequirement:B.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 ${B.status==="approved"?"text-green-500 bg-green-500/15":B.status==="pending"?"text-amber-500 bg-amber-500/15":B.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:B.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[B.status," · ",B.priority||""]})]})]},B.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(B=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(me.WORK,{projectId:B.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:B.name}),B.description&&s.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:B.description})]})]},B.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(B=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(me.DELIVERABLES,{openDeliverable:B.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:B.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[B.type," · ",B.status]})]})]},B.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(B=>{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:B.displayName||B.name}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[B.stepCount," steps · v",B.version]})]})]},B.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 LW({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 IW({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 PW({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-Dtnoxd6f.js"),__vite__mapDeps([2,3,4])).then(e=>({default:e.TeamPage}))),F4=k.lazy(()=>qr(()=>import("./Settings-BfybLlOW.js"),[]).then(e=>({default:e.Settings}))),zW=k.lazy(()=>qr(()=>import("./Store-DJ8GwAx1.js"),[]).then(e=>({default:e.StorePage}))),BW=k.lazy(()=>qr(()=>Promise.resolve().then(()=>nW),void 0).then(e=>({default:e.AgentBuilder}))),q4=k.lazy(()=>qr(()=>import("./Work-DT-c37Wd.js"),__vite__mapDeps([5,4,1,6,3,7])).then(e=>({default:e.WorkPage}))),G4=k.lazy(()=>qr(()=>import("./Deliverables-BV8FX7c8.js"),__vite__mapDeps([8,4])).then(e=>({default:e.DeliverablesPage}))),UW=k.lazy(()=>qr(()=>import("./Notifications-DlJwYRwG.js"),[]).then(e=>({default:e.NotificationsPage}))),$W=k.lazy(()=>qr(()=>import("./Search-RM_DN8KT.js"),[]).then(e=>({default:e.SearchPage}))),HW={visibility:"hidden",position:"absolute",inset:0,pointerEvents:"none",zIndex:-1};function FW(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 qW(){return s.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm animate-pulse",children:"Loading..."})}const GW=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:HW,children:s.jsx(k.Suspense,{fallback:s.jsx(qW,{}),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 VW(){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=MW(),p=_W({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}),[B,Q]=k.useState(!1),ne=Ec(),ke=ne?.leftCollapsed??!1,U=ne?.toggleLeftCollapsed,G=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_")||vG(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||!U||!G)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(),U()):ft==="l"&&(qe.preventDefault(),G())};return document.addEventListener("keydown",Me),()=>document.removeEventListener("keydown",Me)},[d,U,G]);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),FW(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(SW,{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(UW,{authUser:gt}),[me.SEARCH]:s.jsx($W,{})}:{[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(zW,{authUser:gt}),[me.BUILDER]:s.jsx(BW,{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(AW,{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(TW,{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(EW,{onComplete:()=>$(!1),isFirstTime:!0}):r?s.jsx(NW,{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(_K,{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(GW,{id:be,activePage:t,children:jt[be]},be):null)})]}),d&&t!==me.SETTINGS&&t!==me.SEARCH&&s.jsx(DK,{currentPage:t,onNavigate:st,userId:gt?.id}),d&&s.jsx(AD,{authUser:gt,onNavigate:st}),!d&&B&&s.jsx(DW,{onClose:()=>Q(!1),currentPage:t}),w&>&&s.jsx(PW,{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(kG,{children:s.jsx(VW,{})})}));export{QW as $,Us as A,TD as B,_W as C,cc as D,Ig as E,wc as F,zo as G,Q7 as H,bW as I,dr as J,YW as K,XW as L,x5 as M,TK as N,Xd as O,me as P,mK as Q,vY as R,hW as S,sW as T,xV as U,Q2 as V,yV as W,ZW as X,rY as Y,pK as Z,qr as _,Bo as a,Ci as a0,Vo as a1,Ec as a2,cY as a3,OK as a4,kY as a5,fY as a6,tY as a7,lY as a8,Ya as a9,hY as aa,CV as ab,pY as ac,gY as ad,NK as ae,wK as af,bY as ag,v0 as ah,J7 as ai,KW as aj,Ni as ak,pD as al,E3 as am,nY as an,i4 as ao,g4 as ap,aK as aq,rK as ar,pc as as,SY as at,WW as au,sa as av,yn as aw,na as ax,eY as ay,T3 as az,vW as b,lW as c,mW as d,Sa as e,Ce as f,iY as g,it as h,ki as i,s as j,vK as k,xY as l,dY as m,at as n,mY as o,uY as p,wY as q,k as r,zg as s,Er as t,dt as u,yY as v,va as w,oY as x,aY as y,sY as z};
|