@mycelish/cli 0.2.1 → 0.2.3
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/core/auto-adapter.test.js +8 -10
- package/dist/core/auto-adapter.test.js.map +1 -1
- package/dist/core/marketplace-sources.d.ts.map +1 -1
- package/dist/core/marketplace-sources.js +3 -1
- package/dist/core/marketplace-sources.js.map +1 -1
- package/dist/core/migrator/scanners.d.ts.map +1 -1
- package/dist/core/migrator/scanners.js +103 -28
- package/dist/core/migrator/scanners.js.map +1 -1
- package/dist/core/migrator.test.js +15 -10
- package/dist/core/migrator.test.js.map +1 -1
- package/dist/core/tool-adapter.d.ts.map +1 -1
- package/dist/core/tool-adapter.js +17 -18
- package/dist/core/tool-adapter.js.map +1 -1
- package/dist/dashboard/assets/{index-BjDoq18L.js → index-C9q5nAP3.js} +2 -2
- package/dist/dashboard/index.html +1 -1
- package/dist/routes/state.d.ts.map +1 -1
- package/dist/routes/state.js +4 -1
- package/dist/routes/state.js.map +1 -1
- package/package.json +2 -2
|
@@ -106,7 +106,7 @@ Error generating stack: `+l.message+`
|
|
|
106
106
|
|
|
107
107
|
`)}S.write("payload.value = newResult;"),S.write("return payload;");const H=S.compile();return(E,M)=>H(v,E,M)};let c;const u=Pc,d=!N1.jitless,m=d&&fT.value,y=o.catchall;let g;e._zod.parse=(v,S)=>{g??(g=i.value);const w=v.value;return u(w)?d&&m&&S?.async===!1&&S.jitless!==!0?(c||(c=s(o.shape)),v=c(v,S),y?U1([],w,v,S,g,e):v):a(v,S):(v.issues.push({expected:"object",code:"invalid_type",input:w,inst:e}),v)}});function zv(e,o,a,i){for(const c of e)if(c.issues.length===0)return o.value=c.value,o;const s=e.filter(c=>!Yr(c));return s.length===1?(o.value=s[0].value,s[0]):(o.issues.push({code:"invalid_union",input:o.value,inst:a,errors:e.map(c=>c.issues.map(u=>ea(u,i,Wo())))}),o)}const XA=fe("$ZodUnion",(e,o)=>{ut.init(e,o),Ie(e._zod,"optin",()=>o.options.some(s=>s._zod.optin==="optional")?"optional":void 0),Ie(e._zod,"optout",()=>o.options.some(s=>s._zod.optout==="optional")?"optional":void 0),Ie(e._zod,"values",()=>{if(o.options.every(s=>s._zod.values))return new Set(o.options.flatMap(s=>Array.from(s._zod.values)))}),Ie(e._zod,"pattern",()=>{if(o.options.every(s=>s._zod.pattern)){const s=o.options.map(c=>c._zod.pattern);return new RegExp(`^(${s.map(c=>sm(c.source)).join("|")})$`)}});const a=o.options.length===1,i=o.options[0]._zod.run;e._zod.parse=(s,c)=>{if(a)return i(s,c);let u=!1;const d=[];for(const p of o.options){const m=p._zod.run({value:s.value,issues:[]},c);if(m instanceof Promise)d.push(m),u=!0;else{if(m.issues.length===0)return m;d.push(m)}}return u?Promise.all(d).then(p=>zv(p,s,e,c)):zv(d,s,e,c)}}),PA=fe("$ZodIntersection",(e,o)=>{ut.init(e,o),e._zod.parse=(a,i)=>{const s=a.value,c=o.left._zod.run({value:s,issues:[]},i),u=o.right._zod.run({value:s,issues:[]},i);return c instanceof Promise||u instanceof Promise?Promise.all([c,u]).then(([p,m])=>Tv(a,p,m)):Tv(a,c,u)}});function Oh(e,o){if(e===o)return{valid:!0,data:e};if(e instanceof Date&&o instanceof Date&&+e==+o)return{valid:!0,data:e};if(oi(e)&&oi(o)){const a=Object.keys(o),i=Object.keys(e).filter(c=>a.indexOf(c)!==-1),s={...e,...o};for(const c of i){const u=Oh(e[c],o[c]);if(!u.valid)return{valid:!1,mergeErrorPath:[c,...u.mergeErrorPath]};s[c]=u.data}return{valid:!0,data:s}}if(Array.isArray(e)&&Array.isArray(o)){if(e.length!==o.length)return{valid:!1,mergeErrorPath:[]};const a=[];for(let i=0;i<e.length;i++){const s=e[i],c=o[i],u=Oh(s,c);if(!u.valid)return{valid:!1,mergeErrorPath:[i,...u.mergeErrorPath]};a.push(u.data)}return{valid:!0,data:a}}return{valid:!1,mergeErrorPath:[]}}function Tv(e,o,a){const i=new Map;let s;for(const d of o.issues)if(d.code==="unrecognized_keys"){s??(s=d);for(const p of d.keys)i.has(p)||i.set(p,{}),i.get(p).l=!0}else e.issues.push(d);for(const d of a.issues)if(d.code==="unrecognized_keys")for(const p of d.keys)i.has(p)||i.set(p,{}),i.get(p).r=!0;else e.issues.push(d);const c=[...i].filter(([,d])=>d.l&&d.r).map(([d])=>d);if(c.length&&s&&e.issues.push({...s,keys:c}),Yr(e))return e;const u=Oh(o.value,a.value);if(!u.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(u.mergeErrorPath)}`);return e.value=u.data,e}const QA=fe("$ZodRecord",(e,o)=>{ut.init(e,o),e._zod.parse=(a,i)=>{const s=a.value;if(!oi(s))return a.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),a;const c=[],u=o.keyType._zod.values;if(u){a.value={};const d=new Set;for(const m of u)if(typeof m=="string"||typeof m=="number"||typeof m=="symbol"){d.add(typeof m=="number"?m.toString():m);const y=o.valueType._zod.run({value:s[m],issues:[]},i);y instanceof Promise?c.push(y.then(g=>{g.issues.length&&a.issues.push(...qr(m,g.issues)),a.value[m]=g.value})):(y.issues.length&&a.issues.push(...qr(m,y.issues)),a.value[m]=y.value)}let p;for(const m in s)d.has(m)||(p=p??[],p.push(m));p&&p.length>0&&a.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:p})}else{a.value={};for(const d of Reflect.ownKeys(s)){if(d==="__proto__")continue;let p=o.keyType._zod.run({value:d,issues:[]},i);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof d=="string"&&eA.test(d)&&p.issues.length){const g=o.keyType._zod.run({value:Number(d),issues:[]},i);if(g instanceof Promise)throw new Error("Async schemas not supported in object keys currently");g.issues.length===0&&(p=g)}if(p.issues.length){o.mode==="loose"?a.value[d]=s[d]:a.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map(g=>ea(g,i,Wo())),input:d,path:[d],inst:e});continue}const y=o.valueType._zod.run({value:s[d],issues:[]},i);y instanceof Promise?c.push(y.then(g=>{g.issues.length&&a.issues.push(...qr(d,g.issues)),a.value[p.value]=g.value})):(y.issues.length&&a.issues.push(...qr(d,y.issues)),a.value[p.value]=y.value)}}return c.length?Promise.all(c).then(()=>a):a}}),KA=fe("$ZodEnum",(e,o)=>{ut.init(e,o);const a=z1(o.entries),i=new Set(a);e._zod.values=i,e._zod.pattern=new RegExp(`^(${a.filter(s=>dT.has(typeof s)).map(s=>typeof s=="string"?hu(s):s.toString()).join("|")})$`),e._zod.parse=(s,c)=>{const u=s.value;return i.has(u)||s.issues.push({code:"invalid_value",values:a,input:u,inst:e}),s}}),JA=fe("$ZodTransform",(e,o)=>{ut.init(e,o),e._zod.parse=(a,i)=>{if(i.direction==="backward")throw new C1(e.constructor.name);const s=o.transform(a.value,a);if(i.async)return(s instanceof Promise?s:Promise.resolve(s)).then(u=>(a.value=u,a));if(s instanceof Promise)throw new Xr;return a.value=s,a}});function Av(e,o){return e.issues.length&&o===void 0?{issues:[],value:void 0}:e}const Z1=fe("$ZodOptional",(e,o)=>{ut.init(e,o),e._zod.optin="optional",e._zod.optout="optional",Ie(e._zod,"values",()=>o.innerType._zod.values?new Set([...o.innerType._zod.values,void 0]):void 0),Ie(e._zod,"pattern",()=>{const a=o.innerType._zod.pattern;return a?new RegExp(`^(${sm(a.source)})?$`):void 0}),e._zod.parse=(a,i)=>{if(o.innerType._zod.optin==="optional"){const s=o.innerType._zod.run(a,i);return s instanceof Promise?s.then(c=>Av(c,a.value)):Av(s,a.value)}return a.value===void 0?a:o.innerType._zod.run(a,i)}}),FA=fe("$ZodExactOptional",(e,o)=>{Z1.init(e,o),Ie(e._zod,"values",()=>o.innerType._zod.values),Ie(e._zod,"pattern",()=>o.innerType._zod.pattern),e._zod.parse=(a,i)=>o.innerType._zod.run(a,i)}),WA=fe("$ZodNullable",(e,o)=>{ut.init(e,o),Ie(e._zod,"optin",()=>o.innerType._zod.optin),Ie(e._zod,"optout",()=>o.innerType._zod.optout),Ie(e._zod,"pattern",()=>{const a=o.innerType._zod.pattern;return a?new RegExp(`^(${sm(a.source)}|null)$`):void 0}),Ie(e._zod,"values",()=>o.innerType._zod.values?new Set([...o.innerType._zod.values,null]):void 0),e._zod.parse=(a,i)=>a.value===null?a:o.innerType._zod.run(a,i)}),eM=fe("$ZodDefault",(e,o)=>{ut.init(e,o),e._zod.optin="optional",Ie(e._zod,"values",()=>o.innerType._zod.values),e._zod.parse=(a,i)=>{if(i.direction==="backward")return o.innerType._zod.run(a,i);if(a.value===void 0)return a.value=o.defaultValue,a;const s=o.innerType._zod.run(a,i);return s instanceof Promise?s.then(c=>Mv(c,o)):Mv(s,o)}});function Mv(e,o){return e.value===void 0&&(e.value=o.defaultValue),e}const tM=fe("$ZodPrefault",(e,o)=>{ut.init(e,o),e._zod.optin="optional",Ie(e._zod,"values",()=>o.innerType._zod.values),e._zod.parse=(a,i)=>(i.direction==="backward"||a.value===void 0&&(a.value=o.defaultValue),o.innerType._zod.run(a,i))}),nM=fe("$ZodNonOptional",(e,o)=>{ut.init(e,o),Ie(e._zod,"values",()=>{const a=o.innerType._zod.values;return a?new Set([...a].filter(i=>i!==void 0)):void 0}),e._zod.parse=(a,i)=>{const s=o.innerType._zod.run(a,i);return s instanceof Promise?s.then(c=>kv(c,e)):kv(s,e)}});function kv(e,o){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:o}),e}const oM=fe("$ZodCatch",(e,o)=>{ut.init(e,o),Ie(e._zod,"optin",()=>o.innerType._zod.optin),Ie(e._zod,"optout",()=>o.innerType._zod.optout),Ie(e._zod,"values",()=>o.innerType._zod.values),e._zod.parse=(a,i)=>{if(i.direction==="backward")return o.innerType._zod.run(a,i);const s=o.innerType._zod.run(a,i);return s instanceof Promise?s.then(c=>(a.value=c.value,c.issues.length&&(a.value=o.catchValue({...a,error:{issues:c.issues.map(u=>ea(u,i,Wo()))},input:a.value}),a.issues=[]),a)):(a.value=s.value,s.issues.length&&(a.value=o.catchValue({...a,error:{issues:s.issues.map(c=>ea(c,i,Wo()))},input:a.value}),a.issues=[]),a)}}),aM=fe("$ZodPipe",(e,o)=>{ut.init(e,o),Ie(e._zod,"values",()=>o.in._zod.values),Ie(e._zod,"optin",()=>o.in._zod.optin),Ie(e._zod,"optout",()=>o.out._zod.optout),Ie(e._zod,"propValues",()=>o.in._zod.propValues),e._zod.parse=(a,i)=>{if(i.direction==="backward"){const c=o.out._zod.run(a,i);return c instanceof Promise?c.then(u=>vc(u,o.in,i)):vc(c,o.in,i)}const s=o.in._zod.run(a,i);return s instanceof Promise?s.then(c=>vc(c,o.out,i)):vc(s,o.out,i)}});function vc(e,o,a){return e.issues.length?(e.aborted=!0,e):o._zod.run({value:e.value,issues:e.issues},a)}const rM=fe("$ZodReadonly",(e,o)=>{ut.init(e,o),Ie(e._zod,"propValues",()=>o.innerType._zod.propValues),Ie(e._zod,"values",()=>o.innerType._zod.values),Ie(e._zod,"optin",()=>o.innerType?._zod?.optin),Ie(e._zod,"optout",()=>o.innerType?._zod?.optout),e._zod.parse=(a,i)=>{if(i.direction==="backward")return o.innerType._zod.run(a,i);const s=o.innerType._zod.run(a,i);return s instanceof Promise?s.then(Ov):Ov(s)}});function Ov(e){return e.value=Object.freeze(e.value),e}const iM=fe("$ZodCustom",(e,o)=>{Zn.init(e,o),ut.init(e,o),e._zod.parse=(a,i)=>a,e._zod.check=a=>{const i=a.value,s=o.fn(i);if(s instanceof Promise)return s.then(c=>Dv(c,a,i,e));Dv(s,a,i,e)}});function Dv(e,o,a,i){if(!e){const s={code:"custom",input:a,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(s.params=i._zod.def.params),o.issues.push(Cl(s))}}var jv;class lM{constructor(){this._map=new WeakMap,this._idmap=new Map}add(o,...a){const i=a[0];return this._map.set(o,i),i&&typeof i=="object"&&"id"in i&&this._idmap.set(i.id,o),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(o){const a=this._map.get(o);return a&&typeof a=="object"&&"id"in a&&this._idmap.delete(a.id),this._map.delete(o),this}get(o){const a=o._zod.parent;if(a){const i={...this.get(a)??{}};delete i.id;const s={...i,...this._map.get(o)};return Object.keys(s).length?s:void 0}return this._map.get(o)}has(o){return this._map.has(o)}}function sM(){return new lM}(jv=globalThis).__zod_globalRegistry??(jv.__zod_globalRegistry=sM());const ul=globalThis.__zod_globalRegistry;function cM(e,o){return new e({type:"string",...Ce(o)})}function uM(e,o){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Ce(o)})}function Rv(e,o){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Ce(o)})}function fM(e,o){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Ce(o)})}function dM(e,o){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Ce(o)})}function hM(e,o){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Ce(o)})}function mM(e,o){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Ce(o)})}function pM(e,o){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Ce(o)})}function gM(e,o){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Ce(o)})}function yM(e,o){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Ce(o)})}function vM(e,o){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Ce(o)})}function bM(e,o){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Ce(o)})}function xM(e,o){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Ce(o)})}function SM(e,o){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Ce(o)})}function wM(e,o){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Ce(o)})}function _M(e,o){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Ce(o)})}function EM(e,o){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Ce(o)})}function CM(e,o){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Ce(o)})}function NM(e,o){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Ce(o)})}function zM(e,o){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Ce(o)})}function TM(e,o){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Ce(o)})}function AM(e,o){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Ce(o)})}function MM(e,o){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Ce(o)})}function kM(e,o){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Ce(o)})}function OM(e,o){return new e({type:"string",format:"date",check:"string_format",...Ce(o)})}function DM(e,o){return new e({type:"string",format:"time",check:"string_format",precision:null,...Ce(o)})}function jM(e,o){return new e({type:"string",format:"duration",check:"string_format",...Ce(o)})}function RM(e,o){return new e({type:"boolean",...Ce(o)})}function LM(e){return new e({type:"unknown"})}function HM(e,o){return new e({type:"never",...Ce(o)})}function B1(e,o){return new aA({check:"max_length",...Ce(o),maximum:e})}function Kc(e,o){return new rA({check:"min_length",...Ce(o),minimum:e})}function $1(e,o){return new iA({check:"length_equals",...Ce(o),length:e})}function UM(e,o){return new lA({check:"string_format",format:"regex",...Ce(o),pattern:e})}function ZM(e){return new sA({check:"string_format",format:"lowercase",...Ce(e)})}function BM(e){return new cA({check:"string_format",format:"uppercase",...Ce(e)})}function $M(e,o){return new uA({check:"string_format",format:"includes",...Ce(o),includes:e})}function VM(e,o){return new fA({check:"string_format",format:"starts_with",...Ce(o),prefix:e})}function YM(e,o){return new dA({check:"string_format",format:"ends_with",...Ce(o),suffix:e})}function li(e){return new hA({check:"overwrite",tx:e})}function qM(e){return li(o=>o.normalize(e))}function GM(){return li(e=>e.trim())}function IM(){return li(e=>e.toLowerCase())}function XM(){return li(e=>e.toUpperCase())}function PM(){return li(e=>uT(e))}function QM(e,o,a){return new e({type:"array",element:o,...Ce(a)})}function KM(e,o,a){return new e({type:"custom",check:"custom",fn:o,...Ce(a)})}function JM(e){const o=FM(a=>(a.addIssue=i=>{if(typeof i=="string")a.issues.push(Cl(i,a.value,o._zod.def));else{const s=i;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=a.value),s.inst??(s.inst=o),s.continue??(s.continue=!o._zod.def.abort),a.issues.push(Cl(s))}},e(a.value,a)));return o}function FM(e,o){const a=new Zn({check:"custom",...Ce(o)});return a._zod.check=e,a}function V1(e){let o=e?.target??"draft-2020-12";return o==="draft-4"&&(o="draft-04"),o==="draft-7"&&(o="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??ul,target:o,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function bt(e,o,a={path:[],schemaPath:[]}){var i;const s=e._zod.def,c=o.seen.get(e);if(c)return c.count++,a.schemaPath.includes(e)&&(c.cycle=a.path),c.schema;const u={schema:{},count:1,cycle:void 0,path:a.path};o.seen.set(e,u);const d=e._zod.toJSONSchema?.();if(d)u.schema=d;else{const y={...a,schemaPath:[...a.schemaPath,e],path:a.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(o,u.schema,y);else{const v=u.schema,S=o.processors[s.type];if(!S)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${s.type}`);S(e,o,v,y)}const g=e._zod.parent;g&&(u.ref||(u.ref=g),bt(g,o,y),o.seen.get(g).isParent=!0)}const p=o.metadataRegistry.get(e);return p&&Object.assign(u.schema,p),o.io==="input"&&Lt(e)&&(delete u.schema.examples,delete u.schema.default),o.io==="input"&&u.schema._prefault&&((i=u.schema).default??(i.default=u.schema._prefault)),delete u.schema._prefault,o.seen.get(e).schema}function Y1(e,o){const a=e.seen.get(o);if(!a)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=new Map;for(const u of e.seen.entries()){const d=e.metadataRegistry.get(u[0])?.id;if(d){const p=i.get(d);if(p&&p!==u[0])throw new Error(`Duplicate schema id "${d}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(d,u[0])}}const s=u=>{const d=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const g=e.external.registry.get(u[0])?.id,v=e.external.uri??(w=>w);if(g)return{ref:v(g)};const S=u[1].defId??u[1].schema.id??`schema${e.counter++}`;return u[1].defId=S,{defId:S,ref:`${v("__shared")}#/${d}/${S}`}}if(u[1]===a)return{ref:"#"};const m=`#/${d}/`,y=u[1].schema.id??`__schema${e.counter++}`;return{defId:y,ref:m+y}},c=u=>{if(u[1].schema.$ref)return;const d=u[1],{ref:p,defId:m}=s(u);d.def={...d.schema},m&&(d.defId=m);const y=d.schema;for(const g in y)delete y[g];y.$ref=p};if(e.cycles==="throw")for(const u of e.seen.entries()){const d=u[1];if(d.cycle)throw new Error(`Cycle detected: #/${d.cycle?.join("/")}/<root>
|
|
108
108
|
|
|
109
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const u of e.seen.entries()){const d=u[1];if(o===u[0]){c(u);continue}if(e.external){const m=e.external.registry.get(u[0])?.id;if(o!==u[0]&&m){c(u);continue}}if(e.metadataRegistry.get(u[0])?.id){c(u);continue}if(d.cycle){c(u);continue}if(d.count>1&&e.reused==="ref"){c(u);continue}}}function q1(e,o){const a=e.seen.get(o);if(!a)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=u=>{const d=e.seen.get(u);if(d.ref===null)return;const p=d.def??d.schema,m={...p},y=d.ref;if(d.ref=null,y){i(y);const v=e.seen.get(y),S=v.schema;if(S.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(S)):Object.assign(p,S),Object.assign(p,m),u._zod.parent===y)for(const _ in p)_==="$ref"||_==="allOf"||_ in m||delete p[_];if(S.$ref&&v.def)for(const _ in p)_==="$ref"||_==="allOf"||_ in v.def&&JSON.stringify(p[_])===JSON.stringify(v.def[_])&&delete p[_]}const g=u._zod.parent;if(g&&g!==y){i(g);const v=e.seen.get(g);if(v?.schema.$ref&&(p.$ref=v.schema.$ref,v.def))for(const S in p)S==="$ref"||S==="allOf"||S in v.def&&JSON.stringify(p[S])===JSON.stringify(v.def[S])&&delete p[S]}e.override({zodSchema:u,jsonSchema:p,path:d.path??[]})};for(const u of[...e.seen.entries()].reverse())i(u[0]);const s={};if(e.target==="draft-2020-12"?s.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?s.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?s.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const u=e.external.registry.get(o)?.id;if(!u)throw new Error("Schema is missing an `id` property");s.$id=e.external.uri(u)}Object.assign(s,a.def??a.schema);const c=e.external?.defs??{};for(const u of e.seen.entries()){const d=u[1];d.def&&d.defId&&(c[d.defId]=d.def)}e.external||Object.keys(c).length>0&&(e.target==="draft-2020-12"?s.$defs=c:s.definitions=c);try{const u=JSON.parse(JSON.stringify(s));return Object.defineProperty(u,"~standard",{value:{...o["~standard"],jsonSchema:{input:Jc(o,"input",e.processors),output:Jc(o,"output",e.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function Lt(e,o){const a=o??{seen:new Set};if(a.seen.has(e))return!1;a.seen.add(e);const i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return Lt(i.element,a);if(i.type==="set")return Lt(i.valueType,a);if(i.type==="lazy")return Lt(i.getter(),a);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault")return Lt(i.innerType,a);if(i.type==="intersection")return Lt(i.left,a)||Lt(i.right,a);if(i.type==="record"||i.type==="map")return Lt(i.keyType,a)||Lt(i.valueType,a);if(i.type==="pipe")return Lt(i.in,a)||Lt(i.out,a);if(i.type==="object"){for(const s in i.shape)if(Lt(i.shape[s],a))return!0;return!1}if(i.type==="union"){for(const s of i.options)if(Lt(s,a))return!0;return!1}if(i.type==="tuple"){for(const s of i.items)if(Lt(s,a))return!0;return!!(i.rest&&Lt(i.rest,a))}return!1}const WM=(e,o={})=>a=>{const i=V1({...a,processors:o});return bt(e,i),Y1(i,e),q1(i,e)},Jc=(e,o,a={})=>i=>{const{libraryOptions:s,target:c}=i??{},u=V1({...s??{},target:c,io:o,processors:a});return bt(e,u),Y1(u,e),q1(u,e)},ek={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},tk=(e,o,a,i)=>{const s=a;s.type="string";const{minimum:c,maximum:u,format:d,patterns:p,contentEncoding:m}=e._zod.bag;if(typeof c=="number"&&(s.minLength=c),typeof u=="number"&&(s.maxLength=u),d&&(s.format=ek[d]??d,s.format===""&&delete s.format,d==="time"&&delete s.format),m&&(s.contentEncoding=m),p&&p.size>0){const y=[...p];y.length===1?s.pattern=y[0].source:y.length>1&&(s.allOf=[...y.map(g=>({...o.target==="draft-07"||o.target==="draft-04"||o.target==="openapi-3.0"?{type:"string"}:{},pattern:g.source}))])}},nk=(e,o,a,i)=>{a.type="boolean"},ok=(e,o,a,i)=>{a.not={}},ak=(e,o,a,i)=>{},rk=(e,o,a,i)=>{const s=e._zod.def,c=z1(s.entries);c.every(u=>typeof u=="number")&&(a.type="number"),c.every(u=>typeof u=="string")&&(a.type="string"),a.enum=c},ik=(e,o,a,i)=>{if(o.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},lk=(e,o,a,i)=>{if(o.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},sk=(e,o,a,i)=>{const s=a,c=e._zod.def,{minimum:u,maximum:d}=e._zod.bag;typeof u=="number"&&(s.minItems=u),typeof d=="number"&&(s.maxItems=d),s.type="array",s.items=bt(c.element,o,{...i,path:[...i.path,"items"]})},ck=(e,o,a,i)=>{const s=a,c=e._zod.def;s.type="object",s.properties={};const u=c.shape;for(const m in u)s.properties[m]=bt(u[m],o,{...i,path:[...i.path,"properties",m]});const d=new Set(Object.keys(u)),p=new Set([...d].filter(m=>{const y=c.shape[m]._zod;return o.io==="input"?y.optin===void 0:y.optout===void 0}));p.size>0&&(s.required=Array.from(p)),c.catchall?._zod.def.type==="never"?s.additionalProperties=!1:c.catchall?c.catchall&&(s.additionalProperties=bt(c.catchall,o,{...i,path:[...i.path,"additionalProperties"]})):o.io==="output"&&(s.additionalProperties=!1)},uk=(e,o,a,i)=>{const s=e._zod.def,c=s.inclusive===!1,u=s.options.map((d,p)=>bt(d,o,{...i,path:[...i.path,c?"oneOf":"anyOf",p]}));c?a.oneOf=u:a.anyOf=u},fk=(e,o,a,i)=>{const s=e._zod.def,c=bt(s.left,o,{...i,path:[...i.path,"allOf",0]}),u=bt(s.right,o,{...i,path:[...i.path,"allOf",1]}),d=m=>"allOf"in m&&Object.keys(m).length===1,p=[...d(c)?c.allOf:[c],...d(u)?u.allOf:[u]];a.allOf=p},dk=(e,o,a,i)=>{const s=a,c=e._zod.def;s.type="object";const u=c.keyType,p=u._zod.bag?.patterns;if(c.mode==="loose"&&p&&p.size>0){const y=bt(c.valueType,o,{...i,path:[...i.path,"patternProperties","*"]});s.patternProperties={};for(const g of p)s.patternProperties[g.source]=y}else(o.target==="draft-07"||o.target==="draft-2020-12")&&(s.propertyNames=bt(c.keyType,o,{...i,path:[...i.path,"propertyNames"]})),s.additionalProperties=bt(c.valueType,o,{...i,path:[...i.path,"additionalProperties"]});const m=u._zod.values;if(m){const y=[...m].filter(g=>typeof g=="string"||typeof g=="number");y.length>0&&(s.required=y)}},hk=(e,o,a,i)=>{const s=e._zod.def,c=bt(s.innerType,o,i),u=o.seen.get(e);o.target==="openapi-3.0"?(u.ref=s.innerType,a.nullable=!0):a.anyOf=[c,{type:"null"}]},mk=(e,o,a,i)=>{const s=e._zod.def;bt(s.innerType,o,i);const c=o.seen.get(e);c.ref=s.innerType},pk=(e,o,a,i)=>{const s=e._zod.def;bt(s.innerType,o,i);const c=o.seen.get(e);c.ref=s.innerType,a.default=JSON.parse(JSON.stringify(s.defaultValue))},gk=(e,o,a,i)=>{const s=e._zod.def;bt(s.innerType,o,i);const c=o.seen.get(e);c.ref=s.innerType,o.io==="input"&&(a._prefault=JSON.parse(JSON.stringify(s.defaultValue)))},yk=(e,o,a,i)=>{const s=e._zod.def;bt(s.innerType,o,i);const c=o.seen.get(e);c.ref=s.innerType;let u;try{u=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}a.default=u},vk=(e,o,a,i)=>{const s=e._zod.def,c=o.io==="input"?s.in._zod.def.type==="transform"?s.out:s.in:s.out;bt(c,o,i);const u=o.seen.get(e);u.ref=c},bk=(e,o,a,i)=>{const s=e._zod.def;bt(s.innerType,o,i);const c=o.seen.get(e);c.ref=s.innerType,a.readOnly=!0},G1=(e,o,a,i)=>{const s=e._zod.def;bt(s.innerType,o,i);const c=o.seen.get(e);c.ref=s.innerType},xk=fe("ZodISODateTime",(e,o)=>{zA.init(e,o),ot.init(e,o)});function Sk(e){return kM(xk,e)}const wk=fe("ZodISODate",(e,o)=>{TA.init(e,o),ot.init(e,o)});function _k(e){return OM(wk,e)}const Ek=fe("ZodISOTime",(e,o)=>{AA.init(e,o),ot.init(e,o)});function Ck(e){return DM(Ek,e)}const Nk=fe("ZodISODuration",(e,o)=>{MA.init(e,o),ot.init(e,o)});function zk(e){return jM(Nk,e)}const Tk=(e,o)=>{k1.init(e,o),e.name="ZodError",Object.defineProperties(e,{format:{value:a=>wT(e,a)},flatten:{value:a=>ST(e,a)},addIssue:{value:a=>{e.issues.push(a),e.message=JSON.stringify(e.issues,kh,2)}},addIssues:{value:a=>{e.issues.push(...a),e.message=JSON.stringify(e.issues,kh,2)}},isEmpty:{get(){return e.issues.length===0}}})},gn=fe("ZodError",Tk,{Parent:Error}),Ak=um(gn),Mk=fm(gn),kk=mu(gn),Ok=pu(gn),Dk=CT(gn),jk=NT(gn),Rk=zT(gn),Lk=TT(gn),Hk=AT(gn),Uk=MT(gn),Zk=kT(gn),Bk=OT(gn),ft=fe("ZodType",(e,o)=>(ut.init(e,o),Object.assign(e["~standard"],{jsonSchema:{input:Jc(e,"input"),output:Jc(e,"output")}}),e.toJSONSchema=WM(e,{}),e.def=o,e.type=o.type,Object.defineProperty(e,"_def",{value:o}),e.check=(...a)=>e.clone(aa(o,{checks:[...o.checks??[],...a.map(i=>typeof i=="function"?{_zod:{check:i,def:{check:"custom"},onattach:[]}}:i)]}),{parent:!0}),e.with=e.check,e.clone=(a,i)=>ra(e,a,i),e.brand=()=>e,e.register=((a,i)=>(a.add(e,i),e)),e.parse=(a,i)=>Ak(e,a,i,{callee:e.parse}),e.safeParse=(a,i)=>kk(e,a,i),e.parseAsync=async(a,i)=>Mk(e,a,i,{callee:e.parseAsync}),e.safeParseAsync=async(a,i)=>Ok(e,a,i),e.spa=e.safeParseAsync,e.encode=(a,i)=>Dk(e,a,i),e.decode=(a,i)=>jk(e,a,i),e.encodeAsync=async(a,i)=>Rk(e,a,i),e.decodeAsync=async(a,i)=>Lk(e,a,i),e.safeEncode=(a,i)=>Hk(e,a,i),e.safeDecode=(a,i)=>Uk(e,a,i),e.safeEncodeAsync=async(a,i)=>Zk(e,a,i),e.safeDecodeAsync=async(a,i)=>Bk(e,a,i),e.refine=(a,i)=>e.check(OO(a,i)),e.superRefine=a=>e.check(DO(a)),e.overwrite=a=>e.check(li(a)),e.optional=()=>Uv(e),e.exactOptional=()=>bO(e),e.nullable=()=>Zv(e),e.nullish=()=>Uv(Zv(e)),e.nonoptional=a=>CO(e,a),e.array=()=>ho(e),e.or=a=>dO([e,a]),e.and=a=>mO(e,a),e.transform=a=>Bv(e,yO(a)),e.default=a=>wO(e,a),e.prefault=a=>EO(e,a),e.catch=a=>zO(e,a),e.pipe=a=>Bv(e,a),e.readonly=()=>MO(e),e.describe=a=>{const i=e.clone();return ul.add(i,{description:a}),i},Object.defineProperty(e,"description",{get(){return ul.get(e)?.description},configurable:!0}),e.meta=(...a)=>{if(a.length===0)return ul.get(e);const i=e.clone();return ul.add(i,a[0]),i},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=a=>a(e),e)),I1=fe("_ZodString",(e,o)=>{dm.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(i,s,c)=>tk(e,i,s);const a=e._zod.bag;e.format=a.format??null,e.minLength=a.minimum??null,e.maxLength=a.maximum??null,e.regex=(...i)=>e.check(UM(...i)),e.includes=(...i)=>e.check($M(...i)),e.startsWith=(...i)=>e.check(VM(...i)),e.endsWith=(...i)=>e.check(YM(...i)),e.min=(...i)=>e.check(Kc(...i)),e.max=(...i)=>e.check(B1(...i)),e.length=(...i)=>e.check($1(...i)),e.nonempty=(...i)=>e.check(Kc(1,...i)),e.lowercase=i=>e.check(ZM(i)),e.uppercase=i=>e.check(BM(i)),e.trim=()=>e.check(GM()),e.normalize=(...i)=>e.check(qM(...i)),e.toLowerCase=()=>e.check(IM()),e.toUpperCase=()=>e.check(XM()),e.slugify=()=>e.check(PM())}),$k=fe("ZodString",(e,o)=>{dm.init(e,o),I1.init(e,o),e.email=a=>e.check(uM(Vk,a)),e.url=a=>e.check(pM(Yk,a)),e.jwt=a=>e.check(MM(aO,a)),e.emoji=a=>e.check(gM(qk,a)),e.guid=a=>e.check(Rv(Lv,a)),e.uuid=a=>e.check(fM(bc,a)),e.uuidv4=a=>e.check(dM(bc,a)),e.uuidv6=a=>e.check(hM(bc,a)),e.uuidv7=a=>e.check(mM(bc,a)),e.nanoid=a=>e.check(yM(Gk,a)),e.guid=a=>e.check(Rv(Lv,a)),e.cuid=a=>e.check(vM(Ik,a)),e.cuid2=a=>e.check(bM(Xk,a)),e.ulid=a=>e.check(xM(Pk,a)),e.base64=a=>e.check(zM(tO,a)),e.base64url=a=>e.check(TM(nO,a)),e.xid=a=>e.check(SM(Qk,a)),e.ksuid=a=>e.check(wM(Kk,a)),e.ipv4=a=>e.check(_M(Jk,a)),e.ipv6=a=>e.check(EM(Fk,a)),e.cidrv4=a=>e.check(CM(Wk,a)),e.cidrv6=a=>e.check(NM(eO,a)),e.e164=a=>e.check(AM(oO,a)),e.datetime=a=>e.check(Sk(a)),e.date=a=>e.check(_k(a)),e.time=a=>e.check(Ck(a)),e.duration=a=>e.check(zk(a))});function Ht(e){return cM($k,e)}const ot=fe("ZodStringFormat",(e,o)=>{nt.init(e,o),I1.init(e,o)}),Vk=fe("ZodEmail",(e,o)=>{vA.init(e,o),ot.init(e,o)}),Lv=fe("ZodGUID",(e,o)=>{gA.init(e,o),ot.init(e,o)}),bc=fe("ZodUUID",(e,o)=>{yA.init(e,o),ot.init(e,o)}),Yk=fe("ZodURL",(e,o)=>{bA.init(e,o),ot.init(e,o)}),qk=fe("ZodEmoji",(e,o)=>{xA.init(e,o),ot.init(e,o)}),Gk=fe("ZodNanoID",(e,o)=>{SA.init(e,o),ot.init(e,o)}),Ik=fe("ZodCUID",(e,o)=>{wA.init(e,o),ot.init(e,o)}),Xk=fe("ZodCUID2",(e,o)=>{_A.init(e,o),ot.init(e,o)}),Pk=fe("ZodULID",(e,o)=>{EA.init(e,o),ot.init(e,o)}),Qk=fe("ZodXID",(e,o)=>{CA.init(e,o),ot.init(e,o)}),Kk=fe("ZodKSUID",(e,o)=>{NA.init(e,o),ot.init(e,o)}),Jk=fe("ZodIPv4",(e,o)=>{kA.init(e,o),ot.init(e,o)}),Fk=fe("ZodIPv6",(e,o)=>{OA.init(e,o),ot.init(e,o)}),Wk=fe("ZodCIDRv4",(e,o)=>{DA.init(e,o),ot.init(e,o)}),eO=fe("ZodCIDRv6",(e,o)=>{jA.init(e,o),ot.init(e,o)}),tO=fe("ZodBase64",(e,o)=>{RA.init(e,o),ot.init(e,o)}),nO=fe("ZodBase64URL",(e,o)=>{HA.init(e,o),ot.init(e,o)}),oO=fe("ZodE164",(e,o)=>{UA.init(e,o),ot.init(e,o)}),aO=fe("ZodJWT",(e,o)=>{BA.init(e,o),ot.init(e,o)}),rO=fe("ZodBoolean",(e,o)=>{$A.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>nk(e,a,i)});function hm(e){return RM(rO,e)}const iO=fe("ZodUnknown",(e,o)=>{VA.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>ak()});function Hv(){return LM(iO)}const lO=fe("ZodNever",(e,o)=>{YA.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>ok(e,a,i)});function sO(e){return HM(lO,e)}const cO=fe("ZodArray",(e,o)=>{qA.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>sk(e,a,i,s),e.element=o.element,e.min=(a,i)=>e.check(Kc(a,i)),e.nonempty=a=>e.check(Kc(1,a)),e.max=(a,i)=>e.check(B1(a,i)),e.length=(a,i)=>e.check($1(a,i)),e.unwrap=()=>e.element});function ho(e,o){return QM(cO,e,o)}const uO=fe("ZodObject",(e,o)=>{IA.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>ck(e,a,i,s),Ie(e,"shape",()=>o.shape),e.keyof=()=>mm(Object.keys(e._zod.def.shape)),e.catchall=a=>e.clone({...e._zod.def,catchall:a}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Hv()}),e.loose=()=>e.clone({...e._zod.def,catchall:Hv()}),e.strict=()=>e.clone({...e._zod.def,catchall:sO()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=a=>gT(e,a),e.safeExtend=a=>yT(e,a),e.merge=a=>vT(e,a),e.pick=a=>mT(e,a),e.omit=a=>pT(e,a),e.partial=(...a)=>bT(X1,e,a[0]),e.required=(...a)=>xT(P1,e,a[0])});function ta(e,o){const a={type:"object",shape:e??{},...Ce(o)};return new uO(a)}const fO=fe("ZodUnion",(e,o)=>{XA.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>uk(e,a,i,s),e.options=o.options});function dO(e,o){return new fO({type:"union",options:e,...Ce(o)})}const hO=fe("ZodIntersection",(e,o)=>{PA.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>fk(e,a,i,s)});function mO(e,o){return new hO({type:"intersection",left:e,right:o})}const pO=fe("ZodRecord",(e,o)=>{QA.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>dk(e,a,i,s),e.keyType=o.keyType,e.valueType=o.valueType});function ai(e,o,a){return new pO({type:"record",keyType:e,valueType:o,...Ce(a)})}const Dh=fe("ZodEnum",(e,o)=>{KA.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(i,s,c)=>rk(e,i,s),e.enum=o.entries,e.options=Object.values(o.entries);const a=new Set(Object.keys(o.entries));e.extract=(i,s)=>{const c={};for(const u of i)if(a.has(u))c[u]=o.entries[u];else throw new Error(`Key ${u} not found in enum`);return new Dh({...o,checks:[],...Ce(s),entries:c})},e.exclude=(i,s)=>{const c={...o.entries};for(const u of i)if(a.has(u))delete c[u];else throw new Error(`Key ${u} not found in enum`);return new Dh({...o,checks:[],...Ce(s),entries:c})}});function mm(e,o){const a=Array.isArray(e)?Object.fromEntries(e.map(i=>[i,i])):e;return new Dh({type:"enum",entries:a,...Ce(o)})}const gO=fe("ZodTransform",(e,o)=>{JA.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>lk(e,a),e._zod.parse=(a,i)=>{if(i.direction==="backward")throw new C1(e.constructor.name);a.addIssue=c=>{if(typeof c=="string")a.issues.push(Cl(c,a.value,o));else{const u=c;u.fatal&&(u.continue=!1),u.code??(u.code="custom"),u.input??(u.input=a.value),u.inst??(u.inst=e),a.issues.push(Cl(u))}};const s=o.transform(a.value,a);return s instanceof Promise?s.then(c=>(a.value=c,a)):(a.value=s,a)}});function yO(e){return new gO({type:"transform",transform:e})}const X1=fe("ZodOptional",(e,o)=>{Z1.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>G1(e,a,i,s),e.unwrap=()=>e._zod.def.innerType});function Uv(e){return new X1({type:"optional",innerType:e})}const vO=fe("ZodExactOptional",(e,o)=>{FA.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>G1(e,a,i,s),e.unwrap=()=>e._zod.def.innerType});function bO(e){return new vO({type:"optional",innerType:e})}const xO=fe("ZodNullable",(e,o)=>{WA.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>hk(e,a,i,s),e.unwrap=()=>e._zod.def.innerType});function Zv(e){return new xO({type:"nullable",innerType:e})}const SO=fe("ZodDefault",(e,o)=>{eM.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>pk(e,a,i,s),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function wO(e,o){return new SO({type:"default",innerType:e,get defaultValue(){return typeof o=="function"?o():A1(o)}})}const _O=fe("ZodPrefault",(e,o)=>{tM.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>gk(e,a,i,s),e.unwrap=()=>e._zod.def.innerType});function EO(e,o){return new _O({type:"prefault",innerType:e,get defaultValue(){return typeof o=="function"?o():A1(o)}})}const P1=fe("ZodNonOptional",(e,o)=>{nM.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>mk(e,a,i,s),e.unwrap=()=>e._zod.def.innerType});function CO(e,o){return new P1({type:"nonoptional",innerType:e,...Ce(o)})}const NO=fe("ZodCatch",(e,o)=>{oM.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>yk(e,a,i,s),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function zO(e,o){return new NO({type:"catch",innerType:e,catchValue:typeof o=="function"?o:()=>o})}const TO=fe("ZodPipe",(e,o)=>{aM.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>vk(e,a,i,s),e.in=o.in,e.out=o.out});function Bv(e,o){return new TO({type:"pipe",in:e,out:o})}const AO=fe("ZodReadonly",(e,o)=>{rM.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>bk(e,a,i,s),e.unwrap=()=>e._zod.def.innerType});function MO(e){return new AO({type:"readonly",innerType:e})}const kO=fe("ZodCustom",(e,o)=>{iM.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>ik(e,a)});function OO(e,o={}){return KM(kO,e,o)}function DO(e){return JM(e)}const $v={id:"claude-code",display:{name:"Claude Code",icon:"claude",color:"#D97706"},cli:{command:"claude",mcp:{add:["mcp","add-json"],remove:["mcp","remove"]}},paths:{mcp:"~/.claude.json",projectMcp:".claude/mcp.json",skills:"~/.claude/skills",projectSkills:".claude/skills/",globalMemory:"~/.claude/CLAUDE.md",projectMemory:"CLAUDE.md",agents:"~/.claude/agents/",projectAgents:".claude/agents/",rules:null,hooks:"~/.claude/settings.json",commands:null,backupDirs:["~/.claude","~/"]},mcp:{format:"json",key:"mcpServers",entryShape:"standard"},scopes:["shared","coding"],capabilities:["mcp","skills","memory","agents","hooks"],enabled:!0,memoryMaxLines:200},Vv={id:"codex",display:{name:"Codex CLI",icon:"openai",color:"#10A37F"},cli:{command:"codex",mcp:{add:["mcp","add"],remove:["mcp","remove"]}},paths:{mcp:"~/.codex/config.toml",projectMcp:null,skills:"~/.codex/skills",projectSkills:null,globalMemory:"~/.codex/AGENTS.md",projectMemory:"AGENTS.md",agents:null,projectAgents:null,rules:".codex/rules/",hooks:"~/.codex/config.toml",commands:null,backupDirs:["~/.codex"]},mcp:{format:"toml",key:"mcp.servers",entryShape:"standard"},scopes:["shared","coding"],capabilities:["mcp","skills","memory","rules","hooks"],enabled:!0,memoryMaxLines:null},Yv={id:"gemini-cli",display:{name:"Gemini CLI",icon:"gemini",color:"#4285F4"},cli:{command:"gemini",mcp:{add:["mcp","add"],remove:["mcp","remove"],enable:["mcp","enable"],disable:["mcp","disable"]}},paths:{mcp:"~/.gemini/settings.json",projectMcp:null,skills:"~/.gemini/extensions",projectSkills:null,globalMemory:"~/.gemini/GEMINI.md",projectMemory:"GEMINI.md",agents:null,projectAgents:null,rules:null,hooks:"~/.gemini/settings.json",commands:null,backupDirs:["~/.gemini"]},mcp:{format:"json",key:"mcpServers",entryShape:"standard"},scopes:["shared","coding"],capabilities:["mcp","skills","memory","hooks"],enabled:!0,memoryMaxLines:null},qv={id:"opencode",display:{name:"OpenCode",icon:"opencode",color:"#6366F1"},cli:null,paths:{mcp:"~/.config/opencode/opencode.json",projectMcp:null,skills:"~/.config/opencode/plugin",projectSkills:null,globalMemory:"~/.opencode/context.md",projectMemory:null,agents:"~/.config/opencode/agents/",projectAgents:".opencode/agents/",rules:null,hooks:"~/.config/opencode/settings.json",commands:"~/.config/opencode/commands/",backupDirs:["~/.config/opencode"]},mcp:{format:"json",key:"mcp",entryShape:"opencode"},scopes:["shared","coding"],capabilities:["mcp","skills","memory","agents","hooks","commands"],enabled:!0,memoryMaxLines:null},Gv={id:"openclaw",display:{name:"OpenClaw",icon:"openclaw",color:"#EC4899"},cli:null,paths:{mcp:"~/.openclaw/openclaw.json",projectMcp:null,skills:"~/.openclaw/skills",projectSkills:null,globalMemory:"~/.openclaw/MEMORY.md",projectMemory:null,agents:null,projectAgents:null,rules:null,hooks:"~/.openclaw/hooks/",commands:null,backupDirs:["~/.openclaw"]},mcp:{format:"json",key:"plugins.entries",entryShape:"openclaw"},scopes:["shared","personal"],capabilities:["mcp","skills","memory","hooks"],enabled:!0,memoryMaxLines:null},Iv={id:"aider",display:{name:"Aider",icon:"aider",color:"#22C55E"},cli:null,paths:{mcp:"~/.aider/mcp-servers.json",projectMcp:null,skills:"~/.aider/plugins",projectSkills:null,globalMemory:"~/.aider/MEMORY.md",projectMemory:null,agents:null,projectAgents:null,rules:"CONVENTIONS.md",hooks:null,commands:null,backupDirs:["~/.aider"]},mcp:{format:"json",key:"mcpServers",entryShape:"standard"},scopes:["shared","coding"],capabilities:["mcp","skills","memory","rules"],enabled:!0,memoryMaxLines:null},Xv={id:"cursor",display:{name:"Cursor",icon:"cursor",color:"#00D4AA"},cli:{command:"cursor"},paths:{mcp:"~/.cursor/mcp.json",projectMcp:".cursor/mcp.json",skills:null,projectSkills:null,globalMemory:null,projectMemory:".cursorrules",agents:null,projectAgents:".cursor/agents/",rules:".cursor/rules/",hooks:".cursor/hooks.json",commands:".cursor/commands/",backupDirs:["~/.cursor"]},mcp:{format:"json",key:"mcpServers",entryShape:"standard"},scopes:["shared","coding"],capabilities:["mcp","memory","rules","agents","hooks","commands"],enabled:!0,memoryMaxLines:null},Pv={id:"vscode",display:{name:"VS Code",icon:"vscode",color:"#007ACC"},cli:{command:"code"},paths:{mcp:{darwin:"~/Library/Application Support/Code/User/mcp.json",linux:"~/.config/Code/User/mcp.json",win32:"%APPDATA%/Code/User/mcp.json"},projectMcp:".vscode/mcp.json",skills:null,projectSkills:".github/skills/",globalMemory:null,projectMemory:".github/copilot-instructions.md",agents:null,projectAgents:".github/agents/",rules:".github/instructions/",hooks:null,commands:null,backupDirs:[]},mcp:{format:"jsonc",key:"servers",entryShape:"vscode"},scopes:["shared","coding"],capabilities:["mcp","skills","memory","agents","rules"],enabled:!0,memoryMaxLines:null},Qv={id:"antigravity",display:{name:"Antigravity",icon:"antigravity",color:"#FF6B35"},cli:{command:"agy"},paths:{mcp:"~/.gemini/antigravity/mcp_config.json",projectMcp:null,skills:"~/.gemini/antigravity/skills/",projectSkills:".agent/skills/",globalMemory:"~/.gemini/antigravity/rules.md",projectMemory:".antigravity/rules.md",agents:null,projectAgents:".agent/",rules:null,hooks:null,commands:null,backupDirs:["~/.gemini/antigravity"]},mcp:{format:"json",key:"mcpServers",entryShape:"standard"},scopes:["shared","coding"],capabilities:["mcp","skills","memory","agents"],enabled:!0,memoryMaxLines:null},pm={[$v.id]:$v,[Vv.id]:Vv,[Yv.id]:Yv,[qv.id]:qv,[Gv.id]:Gv,[Iv.id]:Iv,[Xv.id]:Xv,[Pv.id]:Pv,[Qv.id]:Qv},jO=Object.keys(pm),RO=jO,Va=mm(RO),Q1=ta({command:Ht(),args:ho(Ht()).optional(),env:ai(Ht(),Ht()).optional(),enabled:hm().optional().default(!0),tools:ho(Va).optional(),excludeTools:ho(Va).optional()});ta({mcps:ai(Ht(),Q1)});const LO=ta({name:Ht(),description:Ht().optional(),version:Ht().optional(),author:Ht().optional(),tools:ho(Va).optional(),excludeTools:ho(Va).optional(),enabled:hm().optional().default(!0)}),HO=mm(["shared","coding","personal"]),UO=ta({syncTo:ho(Va),excludeFrom:ho(Va).optional(),path:Ht(),files:ho(Ht())}),K1=ta({scopes:ai(HO,UO)});ta({version:Ht(),tools:ai(Va,ta({enabled:hm()})),memory:K1});ta({hostname:Ht(),mcps:ai(Ht(),Q1.partial()).optional(),skills:ai(Ht(),LO.partial()).optional(),memory:K1.partial().optional()});function ZO({svg:e,size:o=16}){const a=e.replace(/<svg\b/,`<svg width="${o}" height="${o}"`);return x.jsx("span",{dangerouslySetInnerHTML:{__html:a},style:{display:"inline-flex",lineHeight:0}})}const BO={claude:tT,openai:nT,gemini:oT,opencode:aT,openclaw:rT,aider:iT,cursor:lT,vscode:sT,antigravity:cT},$O=Object.fromEntries(Object.values(pm).map(e=>[e.display.name,x.jsx(ZO,{svg:BO[e.display.icon]??""})]));function gm({status:e}){const o={synced:"bg-green-500 shadow-green-500/50",pending:"bg-yellow-500 shadow-yellow-500/50",error:"bg-red-500 shadow-red-500/50",disabled:"bg-gray-500",not_installed:"bg-gray-700 border border-gray-500"};return x.jsx("span",{"data-testid":`node-status-${e}`,className:Le("inline-block w-2.5 h-2.5 rounded-full shadow-sm",o[e])})}function VO({data:e,sourcePosition:o,targetPosition:a}){const i=e.installed!==!1;return x.jsxs("div",{className:Le("px-4 py-3 rounded-lg border-2 bg-card shadow-lg min-w-[130px] transition-colors",i?"border-primary/60 hover:border-primary":"border-gray-600 opacity-50"),children:[x.jsx(pn,{type:"target",position:a??he.Top,className:"!bg-primary !w-3 !h-3"}),x.jsxs("div",{className:"flex items-center gap-2",children:[$O[e.name]??null,x.jsx(gm,{status:i?e.status:"not_installed"}),x.jsx("span",{className:Le("font-medium text-sm",!i&&"text-gray-500"),children:e.name})]}),!i&&x.jsx("div",{className:"text-[10px] text-gray-500 mt-1",children:"Not installed"}),x.jsx(pn,{type:"source",position:o??he.Bottom,className:"!bg-primary !w-3 !h-3"})]})}const YO=N.memo(VO);function qO({data:e,sourcePosition:o,targetPosition:a}){const i=e.enabled!==!1,s={skill:{border:"border-blue-500/60",bg:"bg-[#0c1529]"},mcp:{border:"border-purple-500/60",bg:"bg-[#150c29]"},memory:{border:"border-amber-500/60",bg:"bg-[#1a1408]"}},c=s[e.type]||s.skill;return x.jsxs("div",{className:Le("px-3 py-2 rounded-md border shadow-md min-w-[110px] transition-colors hover:border-white/40",c.border,c.bg,!i&&"opacity-50"),children:[x.jsx(pn,{type:"target",position:a??he.Top,className:"!bg-muted !w-2 !h-2"}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx(gm,{status:i?e.status:"disabled"}),x.jsx("span",{className:"text-sm font-medium truncate max-w-[100px]",children:e.name}),x.jsx("button",{role:"switch","aria-checked":i,"aria-label":`Toggle ${e.name}`,onClick:u=>{u.stopPropagation(),e.onToggle?.(e.type,e.name,!i)},className:Le("ml-auto relative inline-flex h-4 w-7 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors",i?"bg-primary":"bg-muted"),children:x.jsx("span",{className:Le("pointer-events-none inline-block h-3 w-3 rounded-full bg-white shadow-sm transition-transform",i?"translate-x-3":"translate-x-0")})})]}),x.jsx("div",{className:"text-[10px] text-muted-foreground mt-0.5 uppercase tracking-wider",children:e.type}),x.jsx(pn,{type:"source",position:o??he.Bottom,className:"!bg-muted !w-2 !h-2"})]})}const GO=N.memo(qO);const J1=(...e)=>e.filter((o,a,i)=>!!o&&o.trim()!==""&&i.indexOf(o)===a).join(" ").trim();const IO=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const XO=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(o,a,i)=>i?i.toUpperCase():a.toLowerCase());const Kv=e=>{const o=XO(e);return o.charAt(0).toUpperCase()+o.slice(1)};var PO={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const QO=e=>{for(const o in e)if(o.startsWith("aria-")||o==="role"||o==="title")return!0;return!1};const KO=N.forwardRef(({color:e="currentColor",size:o=24,strokeWidth:a=2,absoluteStrokeWidth:i,className:s="",children:c,iconNode:u,...d},p)=>N.createElement("svg",{ref:p,...PO,width:o,height:o,stroke:e,strokeWidth:i?Number(a)*24/Number(o):a,className:J1("lucide",s),...!c&&!QO(d)&&{"aria-hidden":"true"},...d},[...u.map(([m,y])=>N.createElement(m,y)),...Array.isArray(c)?c:[c]]));const Ll=(e,o)=>{const a=N.forwardRef(({className:i,...s},c)=>N.createElement(KO,{ref:c,iconNode:o,className:J1(`lucide-${IO(Kv(e))}`,`lucide-${e}`,i),...s}));return a.displayName=Kv(e),a};const JO=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],F1=Ll("bot",JO);const FO=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],W1=Ll("library",FO);const WO=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],eS=Ll("sparkles",WO);const e6=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],tS=Ll("terminal",e6);const t6=[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]],nS=Ll("webhook",t6);function n6({data:e,sourcePosition:o,targetPosition:a}){const i=e.enabled!==!1;return x.jsxs("div",{className:Le("px-3 py-2 rounded-md border shadow-md min-w-[110px] transition-colors hover:border-white/40 cursor-pointer","border-teal-500/60","bg-[#081a1a]",!i&&"opacity-50"),onClick:()=>e.onClick?.(e.name),children:[x.jsx(pn,{type:"target",position:a??he.Top,className:"!bg-muted !w-2 !h-2"}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx(gm,{status:i?"synced":"disabled"}),x.jsx("span",{className:"text-sm font-medium truncate max-w-[120px]",children:e.name}),x.jsx("button",{role:"switch","aria-checked":i,"aria-label":`Toggle ${e.name}`,onClick:s=>{s.stopPropagation(),e.onToggle?.(e.name,!i)},className:Le("ml-auto relative inline-flex h-4 w-7 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors",i?"bg-primary":"bg-muted"),children:x.jsx("span",{className:Le("pointer-events-none inline-block h-3 w-3 rounded-full bg-white shadow-sm transition-transform",i?"translate-x-3":"translate-x-0")})})]}),x.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 text-[10px] text-muted-foreground",children:[e.skillCount>0&&x.jsxs("span",{className:"flex items-center gap-0.5",title:"Skills",children:[x.jsx(eS,{size:10,className:"text-purple-400"}),e.skillCount]}),e.agentCount>0&&x.jsxs("span",{className:"flex items-center gap-0.5",title:"Agents",children:[x.jsx(F1,{size:10,className:"text-emerald-400"}),e.agentCount]}),e.commandCount>0&&x.jsxs("span",{className:"flex items-center gap-0.5",title:"Commands",children:[x.jsx(tS,{size:10,className:"text-blue-400"}),e.commandCount]}),e.hookCount>0&&x.jsxs("span",{className:"flex items-center gap-0.5",title:"Hooks",children:[x.jsx(nS,{size:10,className:"text-amber-400"}),e.hookCount]}),e.libCount>0&&x.jsxs("span",{className:"flex items-center gap-0.5",title:"Libraries",children:[x.jsx(W1,{size:10,className:"text-pink-400"}),e.libCount]})]}),x.jsx(pn,{type:"source",position:o??he.Bottom,className:"!bg-muted !w-2 !h-2"})]})}const o6=N.memo(n6);function a6({data:e,sourcePosition:o,targetPosition:a}){return x.jsxs("div",{className:"px-4 py-3 rounded-lg border-2 border-dashed border-muted-foreground/40 bg-card/50 shadow-md min-w-[130px] cursor-pointer hover:border-primary/60 hover:bg-card transition-colors",onClick:()=>e.onClick?.(),children:[x.jsx(pn,{type:"target",position:a??he.Top,className:"!bg-muted !w-3 !h-3"}),x.jsxs("div",{className:"flex items-center gap-2 justify-center",children:[x.jsx("span",{className:"text-lg text-muted-foreground",children:"+"}),x.jsx("span",{className:"font-medium text-sm text-muted-foreground",children:"Add Tool"})]}),x.jsx(pn,{type:"source",position:o??he.Bottom,className:"!bg-muted !w-3 !h-3"})]})}const r6=N.memo(a6),Ya={tool:{width:160,height:60},addTool:{width:160,height:60},resource:{width:170,height:58},plugin:{width:180,height:68}},na={width:160,height:55},jn={skill:"#3b82f6",mcp:"#a855f7",memory:"#f59e0b",plugin:"#14b8a6",custom:"#6b7280",disabled:"#ef4444"},il={synced:"#22c55e",pending:"#eab308",error:"#ef4444",not_installed:"#374151",fallback:"#6b7280"},ml={strokeWidth:1.5,disabledDashArray:"5,5",disabledOpacity:.4},Ma={strokeDasharray:"6,4",opacity:.55,fontSize:13,labelBgOpacity:.9,labelBgRadius:8,labelPadding:[5,5]},mn={horizontalSpacing:180,addToolSpacing:160,layers:{top:0,middle:200,bottom:400}},Jv={color:"#333",gap:20},Fv="smoothstep",jh="DOWN",Hr={layout:"mycelium:graph:layout",edgeType:"mycelium:graph:edgeType",radialMode:"mycelium:graph:radialMode"},Rh="sectors";function xc(e,o){const a=new Map;for(const g of e)g.installed&&a.set(g.toolId,{id:g.toolId,name:g.toolName,installed:!0});const i=Array.from(a.values()).map(g=>({id:g.id,name:g.name,status:o.tools[g.id]!==!1?"synced":"disabled",installed:!0})),s=new Map,c=[];for(const g of e)for(const v of g.skills)if(v.marketplace&&v.pluginName){const S=`${v.marketplace}/${v.pluginName}`,w=s.get(S);w?w.skills.includes(v.name)||w.skills.push(v.name):s.set(S,{marketplace:v.marketplace,skills:[v.name],enabled:o.skills[v.name]!==!1})}else c.push({name:v.name,status:"pending",enabled:o.skills[v.name]!==!1,connectedTools:[g.toolId]});const u=Array.from(s.entries()).map(([g,v])=>({name:g.split("/")[1]||g,marketplace:v.marketplace,componentCount:v.skills.length,enabled:v.skills.some(w=>o.skills[w]!==!1),skills:v.skills})),d=new Set,p=[];for(const g of e)for(const v of g.mcps)d.has(v.name)||(d.add(v.name),p.push({name:v.name,status:"pending",enabled:o.mcps[v.name]!==!1,connectedTools:[g.toolId]}));const m=new Set,y=[];for(const g of e)for(const v of g.memory)m.has(v.name)||(m.add(v.name),y.push({name:v.name,scope:"shared",status:"pending"}));return{tools:i,skills:c,mcps:p,memory:y,plugins:u}}const i6=Object.values(pm).map(e=>({id:e.id,name:e.display.name,status:"synced",installed:!0}));function Sc(e,o){return{stroke:e,strokeWidth:ml.strokeWidth,...o?{}:{strokeDasharray:ml.disabledDashArray,opacity:ml.disabledOpacity}}}function l6(e,o,a,i){const s=[],c=[],u=e?.tools||i6,d=a?u:u.filter(m=>m.installed!==!1);d.forEach((m,y)=>{s.push({id:`tool-${m.id}`,type:"tool",position:{x:y*mn.horizontalSpacing,y:mn.layers.middle},data:{name:m.name,status:m.status,installed:m.installed,__elkLayer:"NONE"}})});const p=new Set;return e?.plugins?.forEach(m=>{m.skills.forEach(y=>p.add(y))}),e?.plugins?.forEach((m,y)=>{const g=`plugin-${m.name}`;s.push({id:g,type:"plugin",position:{x:y*mn.horizontalSpacing,y:mn.layers.top},data:{__elkLayer:"FIRST",name:m.name,marketplace:m.marketplace,componentCount:m.componentCount,skillCount:m.skills?.length??0,agentCount:m.agents?.length??0,commandCount:m.commands?.length??0,hookCount:m.hooks?.length??0,libCount:m.libs?.length??0,enabled:m.enabled,onToggle:(v,S)=>i.onPluginToggle?.(v,S),onClick:v=>i.onPluginClick?.(v)}}),d.filter(v=>v.installed).forEach(v=>{c.push({id:`${g}-to-tool-${v.id}`,source:g,target:`tool-${v.id}`,animated:m.enabled,style:Sc(jn.plugin,m.enabled)})})}),e?.skills.forEach((m,y)=>{if(p.has(m.name))return;const g=`skill-${m.name}`;s.push({id:g,type:"resource",position:{x:y*mn.horizontalSpacing,y:mn.layers.top},data:{name:m.name,type:"skill",status:m.status,enabled:m.enabled,onToggle:i.handleToggle,__elkLayer:"FIRST"}});const v=m.enabled!==!1;(m.connectedTools||d.filter(w=>w.installed).map(w=>w.id)).forEach(w=>{d.some(_=>_.id===w)&&c.push({id:`${g}-to-${w}`,source:g,target:`tool-${w}`,animated:v&&m.status==="synced",style:Sc(jn.skill,v)})})}),e?.mcps.forEach((m,y)=>{const g=`mcp-${m.name}`;s.push({id:g,type:"resource",position:{x:y*mn.horizontalSpacing,y:mn.layers.bottom},data:{name:m.name,type:"mcp",status:m.status,enabled:m.enabled,onToggle:i.handleToggle}});const v=m.enabled!==!1;(m.connectedTools||d.filter(w=>w.installed).map(w=>w.id)).forEach(w=>{d.some(_=>_.id===w)&&c.push({id:`tool-${w}-to-${g}`,source:`tool-${w}`,target:g,animated:v&&m.status==="synced",style:Sc(jn.mcp,v)})})}),e?.memory.forEach((m,y)=>{const g=`memory-${m.name}`;s.push({id:g,type:"resource",position:{x:y*mn.horizontalSpacing,y:mn.layers.bottom},data:{name:m.name,type:"memory",status:m.status,onToggle:i.handleToggle,__elkLayer:"LAST"}});let v;m.scope==="personal"?v=["openclaw"]:m.scope==="coding"?v=d.filter(S=>S.id!=="openclaw"&&S.installed).map(S=>S.id):v=d.filter(S=>S.installed).map(S=>S.id),v.forEach(S=>{d.some(w=>w.id===S)&&c.push({id:`tool-${S}-to-${g}`,source:`tool-${S}`,target:g,animated:m.status==="synced",style:Sc(jn.memory,!0)})})}),o==="migrate"&&s.push({id:"add-tool",type:"addTool",position:{x:d.length*mn.addToolSpacing,y:mn.layers.top},data:{onClick:i.onAddTool}}),{initialNodes:s,initialEdges:c}}function Lh(e){return e.type==="tool"||e.type==="addTool"?"tool":e.type==="plugin"?"plugin":e.data?.type==="skill"?"skill":e.data?.type==="mcp"?"mcp":e.data?.type==="memory"?"memory":"other"}const s6=["plugin","skill","tool","mcp","memory"];function yu(e){const o=new Map;for(const a of s6)o.set(a,[]);for(const a of e){const i=Lh(a);o.has(i)||o.set(i,[]),o.get(i).push(a)}return o}function c6(e,o,a){const i=a==="RIGHT",s=yu(e),c=30,u=120,d=[],p=[[...s.get("plugin")??[],...s.get("skill")??[]],s.get("tool")??[],s.get("mcp")??[],s.get("memory")??[]].filter(w=>w.length>0),m=w=>{const _=w.measured;return _?.width&&_?.height?{width:_.width,height:_.height}:Ya[w.type||""]||na},y=p.map(w=>w.reduce((_,T)=>{const z=m(T);return _+(i?z.height:z.width)},0)),g=p.map((w,_)=>y[_]+(w.length-1)*c),v=Math.max(...g);let S=0;for(let w=0;w<p.length;w++){const _=p[w],T=g[w],z=(v-T)/2;let H=0,E=z;for(const M of _){const R=m(M),D=i?R.width:R.height,O=i?R.height:R.width;H=Math.max(H,D),d.push({...M,zIndex:10,position:i?{x:S,y:E}:{x:E,y:S},sourcePosition:i?he.Right:he.Bottom,targetPosition:i?he.Left:he.Top}),E+=O+c}S+=H+u}return{nodes:d,edges:o}}function oS(e){const o=new Map;return e.forEach((a,i)=>{o.set(a.id,i/e.length*2*Math.PI-Math.PI/2)}),o}function aS(e,o){const a=new Map;for(const i of e){if(o.has(i.source)){const s=a.get(i.target)??[];s.push(i.source),a.set(i.target,s)}if(o.has(i.target)){const s=a.get(i.source)??[];s.push(i.target),a.set(i.source,s)}}return a}function Fc(e,o,a){const i=o.get(e.id)??[];if(i.length===0)return Math.PI;const s=i.map(d=>a.get(d)??0),c=s.reduce((d,p)=>d+Math.sin(p),0),u=s.reduce((d,p)=>d+Math.cos(p),0);return Math.atan2(c/s.length,u/s.length)}function Wc(e,o,a,i,s){const c=Ya[e.type||""]?.width??na.width,u=Ya[e.type||""]?.height??na.height;return{...e,zIndex:10,position:{x:o+i*Math.cos(s)-c/2,y:a+i*Math.sin(s)-u/2},sourcePosition:he.Bottom,targetPosition:he.Top}}function u6(e,o,a=40,i=30,s=50){const c=s/100,u=[];let d=o;for(const p of e){if(p.length===0){u.push(d);continue}const m=Math.max(...p.map(w=>Ya[w.type||""]?.width??na.width)),y=Math.max(...p.map(w=>Ya[w.type||""]?.height??na.height)),g=p.length*(m+i)/(2*Math.PI)*c,v=d+Math.max(m,y)*c+a,S=Math.max(g,v);u.push(S),d=S}return u}function f6(e,o,a=60,i=150,s=50){const c=yu(e),u=c.get("tool")??[],d=u.length<=1?0:i,p=oS(u),m=aS(o,p),y=[[...c.get("plugin")??[],...c.get("skill")??[]],c.get("mcp")??[],c.get("memory")??[]],g=u6(y,d,a,a/2,s),v=Math.max(d,...g),S=v+200,w=v+200,_=[];for(const T of u)_.push(Wc(T,S,w,d,p.get(T.id)));for(let T=0;T<y.length;T++){if(y[T].length===0)continue;const z=[...y[T]].sort((H,E)=>Fc(H,m,p)-Fc(E,m,p));z.forEach((H,E)=>{_.push(Wc(H,S,w,g[T],E/z.length*2*Math.PI-Math.PI/2))})}return{nodes:_,edges:o}}function d6(e,o,a=60,i=150,s=50){const c=yu(e),u=c.get("tool")??[],d=oS(u),p=aS(o,d),m=u.length<=1?0:i,y=[{cat:["plugin"],centerAngle:-Math.PI*3/4,label:"Plugins (top-left)"},{cat:["memory"],centerAngle:-Math.PI/4,label:"Memory (top-right)"},{cat:["skill"],centerAngle:Math.PI*3/4,label:"Skills (bottom-left)"},{cat:["mcp"],centerAngle:Math.PI/4,label:"MCPs (bottom-right)"}],g=Math.PI/2,v=g*.42,S=[];for(const I of y){const W=[];for(const L of I.cat)W.push(...c.get(L)??[]);S.push(W)}const w=6,_=40,T=na.width,z=Math.max(...S.map(I=>I.length),1),H=Math.min(w,z),E=s/100,M=H*(T+_)/g*E,R=Math.max(m+a,M),D=a+40,O=Math.max(...S.map(I=>Math.ceil(I.length/w)),1),Z=R+O*D+100,$=Z+200,oe=Z+200,q=[];for(const I of u)q.push(Wc(I,$,oe,m,d.get(I.id)));for(let I=0;I<y.length;I++){const W=y[I],L=S[I];if(L.length===0)continue;const Y=[...L].sort((U,j)=>Fc(U,p,d)-Fc(j,p,d)),A=Math.ceil(Y.length/w);for(let U=0;U<A;U++){const j=Y.slice(U*w,(U+1)*w),Q=R+U*D;j.forEach((re,k)=>{const V=j.length<=1?0:(k/(j.length-1)-.5)*2*v;q.push(Wc(re,$,oe,Q,W.centerAngle+V))})}}return{nodes:q,edges:o}}function h6(e,o,a=60,i=150,s=50){const d=(yu(e).get("tool")??[]).length<=1?0:i,p=a*(1+s/50),m={tool:d,plugin:d+p,skill:d+p,mcp:d+p*2,memory:d+p*3},y=d+p*3+200,g=y+200,v=y+200,S=[...e],w=new Map,_=[],T=new Map,z=new Map;for(const R of S){const D=Lh(R),O=m[D]??d+300,Z=T.get(O)??0;T.set(O,Z+1)}for(const[R]of T)z.set(R,0);for(const R of S){const D=Lh(R),O=m[D]??d+300,Z=T.get(O)??1,$=z.get(O)??0;z.set(O,$+1);const oe=$/Z*2*Math.PI-Math.PI/2;w.set(R.id,_.length),_.push({node:R,x:g+O*Math.cos(oe),y:v+O*Math.sin(oe),vx:0,vy:0,targetR:O,fixed:D==="tool"})}const H=80,E=.3;for(let R=0;R<H;R++){const D=1-R/H;for(const O of o){const Z=w.get(O.source),$=w.get(O.target);if(Z===void 0||$===void 0)continue;const oe=_[Z],q=_[$],I=q.x-oe.x,W=q.y-oe.y,L=Math.sqrt(I*I+W*W)||1,Y=Math.abs(oe.targetR-q.targetR)*.8+100,A=(L-Y)/L*.02*D;oe.fixed||(oe.vx+=I*A,oe.vy+=W*A),q.fixed||(q.vx-=I*A,q.vy-=W*A)}for(let O=0;O<_.length;O++)if(!_[O].fixed)for(let Z=O+1;Z<_.length;Z++){const $=_[Z].x-_[O].x,oe=_[Z].y-_[O].y,q=Math.sqrt($*$+oe*oe)||1,I=200;if(q<I){const W=(I-q)/q*.25*D;_[O].fixed||(_[O].vx-=$*W,_[O].vy-=oe*W),_[Z].fixed||(_[Z].vx+=$*W,_[Z].vy+=oe*W)}}for(const O of _){if(O.fixed)continue;O.x+=O.vx*E,O.y+=O.vy*E,O.vx*=.7,O.vy*=.7;const Z=O.x-g,$=O.y-v,oe=Math.sqrt(Z*Z+$*$)||1,q=Math.atan2($,Z),I=oe+(O.targetR-oe)*.3;O.x=g+I*Math.cos(q),O.y=v+I*Math.sin(q)}}return{nodes:_.map(R=>{const D=Ya[R.node.type||""]?.width??na.width,O=Ya[R.node.type||""]?.height??na.height;return{...R.node,zIndex:10,position:{x:R.x-D/2,y:R.y-O/2},sourcePosition:he.Bottom,targetPosition:he.Top}}),edges:o}}function m6(e,o,a="hybrid",i=60,s=150,c=50){switch(a){case"sectors":return d6(e,o,i,s,c);case"force":return h6(e,o,i,s,c);default:return f6(e,o,i,s,c)}}async function wc(e,o,a=jh,i=Rh,s=60,c=150,u=50){return a==="RADIAL"?m6(e,o,i,s,c,u):c6(e,o,a)}const p6={tool:YO,resource:GO,plugin:o6,addTool:r6};function rS({data:e,mode:o="dashboard",onNodeClick:a,onToggle:i,onPluginToggle:s,onPluginClick:c,onMcpClick:u,onSkillClick:d,onAddTool:p,onEdgeToggle:m,disabledEdges:y,showUninstalledTools:g=!1}){const[v,S,w]=_4([]),[_,T,z]=E4([]),H=N.useRef(null),[E,M]=N.useState(()=>{try{return localStorage.getItem(Hr.layout)||jh}catch{return jh}}),[R,D]=N.useState(()=>{try{return localStorage.getItem(Hr.edgeType)||Fv}catch{return Fv}}),[O,Z]=N.useState(()=>{try{return localStorage.getItem(Hr.radialMode)||Rh}catch{return Rh}}),[$,oe]=N.useState(60),[q,I]=N.useState(150),[W,L]=N.useState(50),Y=N.useMemo(()=>{try{return new URLSearchParams(window.location.search).has("debug")}catch{return!1}},[]),A=N.useCallback(me=>{M(me);try{localStorage.setItem(Hr.layout,me)}catch{}},[]),U=N.useCallback(me=>{D(me);try{localStorage.setItem(Hr.edgeType,me)}catch{}},[]),j=N.useCallback(me=>{Z(me);try{localStorage.setItem(Hr.radialMode,me)}catch{}},[]),[Q,re]=N.useState(new Set),k=y??Q,V=N.useRef(i);V.current=i;const F=N.useRef(s);F.current=s;const ee=N.useRef(c);ee.current=c;const P=N.useRef(p);P.current=p;const se=N.useCallback((me,ze,it)=>{V.current?.({type:me,name:ze,enabled:it})},[]),ne=N.useMemo(()=>({handleToggle:se,onToggle:me=>V.current?.(me),onPluginToggle:(me,ze)=>F.current?.(me,ze),onPluginClick:me=>ee.current?.(me),onAddTool:()=>P.current?.()}),[se]),{initialNodes:le,initialEdges:de}=N.useMemo(()=>l6(e,o,g,ne),[e,o,g,ne]),Ee=N.useMemo(()=>_.map(me=>k.has(me.id)?{...me,animated:!1,interactionWidth:30,style:{stroke:jn.disabled,strokeWidth:ml.strokeWidth,strokeDasharray:Ma.strokeDasharray,opacity:Ma.opacity},label:"✕",labelStyle:{fill:jn.disabled,fontSize:Ma.fontSize,fontWeight:700,cursor:"pointer"},labelBgStyle:{fill:"#1a1a1a",fillOpacity:Ma.labelBgOpacity,rx:Ma.labelBgRadius,ry:Ma.labelBgRadius},labelBgPadding:Ma.labelPadding}:{...me,type:R,interactionWidth:30}),[_,k,R]),we=N.useRef(!1),ve=N.useRef(!1);N.useEffect(()=>{le.length>0&&(ve.current=!1,wc(le,de,E,O,$,q,W).then(({nodes:me,edges:ze})=>{S(me),T(ze),we.current||(we.current=!0,setTimeout(()=>H.current?.(),50))}))},[le,de,E,O,$,q,W,S,T]);const _e=N4();N.useEffect(()=>{_e&&v.length>0&&!ve.current&&(ve.current=!0,wc(v,_,E,O,$,q,W).then(({nodes:me,edges:ze})=>{S(me),T(ze)}))},[_e]);const Me=N.useCallback(me=>{A(me),wc(v,_,me,O,$,q,W).then(({nodes:ze,edges:it})=>{S(ze),T(it),setTimeout(()=>H.current?.(),50)})},[v,_,O,$,q,W,S,T,A]),Ye=N.useCallback(me=>{j(me),wc(v,_,"RADIAL",me,$,q,W).then(({nodes:ze,edges:it})=>{S(ze),T(it),setTimeout(()=>H.current?.(),50)})},[v,_,$,q,W,S,T,j]),$e=N.useCallback(()=>{},[]),dt=N.useCallback(me=>{T(ze=>Mx({...me,animated:!0,style:{stroke:jn.custom,strokeWidth:ml.strokeWidth}},ze))},[T]),Qt=N.useCallback((me,ze)=>{const it=k.has(ze.id);m?m(ze.id,it):re(Bn=>{const lt=new Set(Bn);return it?lt.delete(ze.id):lt.add(ze.id),lt})},[k,m]),Ot=N.useCallback((me,ze)=>{if(a?.(ze),ze.type==="plugin")ee.current?.(ze.data.name);else if(ze.type==="resource"){const it=ze.data;it.type==="mcp"?u?.(it.name):it.type==="skill"&&d?.(it.name)}},[a,u,d]);return x.jsx("div",{"data-testid":"react-flow-graph",className:"w-full h-full",children:x.jsxs(w4,{nodes:v,edges:Ee,onNodesChange:w,onEdgesChange:z,nodeTypes:p6,onNodeClick:Ot,onNodeDragStop:$e,onEdgeClick:Qt,onConnect:dt,onInit:me=>{H.current=()=>me.fitView({padding:.2,duration:300})},fitView:!0,minZoom:.3,maxZoom:2,defaultViewport:{x:0,y:0,zoom:.8},children:[x.jsxs(Rl,{position:"top-right",className:"flex gap-2",children:[x.jsx("button",{onClick:()=>Me("DOWN"),className:Le("px-3 py-1.5 rounded text-xs font-medium transition-colors",E==="DOWN"?"bg-primary text-primary-foreground":"bg-secondary text-secondary-foreground hover:bg-secondary/80"),children:"Vertical"}),x.jsx("button",{onClick:()=>Me("RIGHT"),className:Le("px-3 py-1.5 rounded text-xs font-medium transition-colors",E==="RIGHT"?"bg-primary text-primary-foreground":"bg-secondary text-secondary-foreground hover:bg-secondary/80"),children:"Horizontal"}),x.jsx("button",{onClick:()=>Me("RADIAL"),className:Le("px-3 py-1.5 rounded text-xs font-medium transition-colors",E==="RADIAL"?"bg-primary text-primary-foreground":"bg-secondary text-secondary-foreground hover:bg-secondary/80"),children:"Radial"}),E==="RADIAL"&&Y&&x.jsxs(x.Fragment,{children:[x.jsx("span",{className:"mx-1 text-muted-foreground/40",children:"|"}),["hybrid","sectors","force"].map(me=>x.jsx("button",{onClick:()=>Ye(me),className:Le("px-2 py-1.5 rounded text-[10px] font-medium transition-colors capitalize",O===me?"bg-emerald-600 text-white":"bg-secondary text-secondary-foreground hover:bg-secondary/80"),children:me},me)),x.jsx("span",{className:"mx-1 text-muted-foreground/40",children:"|"}),x.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",title:"Density: 0=tight, 100=spacious",children:["Density",x.jsx("input",{type:"range",min:0,max:100,step:5,value:W,onChange:me=>L(Number(me.target.value)),className:"w-20 h-1 accent-orange-500"}),x.jsx("span",{className:"w-6 text-right font-mono",children:W})]}),x.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",title:"Center ring size",children:["Center",x.jsx("input",{type:"range",min:0,max:500,step:5,value:q,onChange:me=>I(Number(me.target.value)),className:"w-20 h-1 accent-cyan-500"}),x.jsx("span",{className:"w-6 text-right font-mono",children:q})]}),x.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",title:"Gap between rings",children:["Gap",x.jsx("input",{type:"range",min:0,max:500,step:5,value:$,onChange:me=>oe(Number(me.target.value)),className:"w-20 h-1 accent-emerald-500"}),x.jsx("span",{className:"w-6 text-right font-mono",children:$})]})]}),x.jsx("span",{className:"mx-1 text-muted-foreground/40",children:"|"}),["smoothstep","default","straight","step"].map(me=>x.jsx("button",{onClick:()=>U(me),className:Le("px-2 py-1.5 rounded text-[10px] font-medium transition-colors capitalize",R===me?"bg-purple-600 text-white":"bg-secondary text-secondary-foreground hover:bg-secondary/80"),children:me==="default"?"bezier":me},me))]}),x.jsx(k4,{color:Jv.color,gap:Jv.gap}),x.jsx(U4,{className:"!bg-card !border-border [&>button]:!bg-card [&>button]:!border-border"}),x.jsx(J4,{className:"!bg-card/80 !border-border",maskColor:"rgba(0,0,0,0.8)",nodeColor:me=>{const ze=me.data;return ze?.status==="synced"?il.synced:ze?.status==="pending"?il.pending:ze?.status==="error"?il.error:ze?.status==="not_installed"?il.not_installed:ze?.type==="skill"?jn.skill:ze?.type==="mcp"?jn.mcp:ze?.type==="memory"?jn.memory:il.fallback}})]})})}let iS=!1;try{iS=globalThis.localStorage?.getItem("mycelium:debug:panel")==="1"}catch{}const ih=(...e)=>{iS&&console.log("[panel]",...e)},g6={skill:{label:"Skills",color:"text-purple-400",icon:x.jsx(eS,{size:14,className:"text-purple-400"})},agent:{label:"Agents",color:"text-emerald-400",icon:x.jsx(F1,{size:14,className:"text-emerald-400"})},command:{label:"Commands",color:"text-blue-400",icon:x.jsx(tS,{size:14,className:"text-blue-400"})},hook:{label:"Hooks",color:"text-amber-400",icon:x.jsx(nS,{size:14,className:"text-amber-400"})},lib:{label:"Libraries",color:"text-pink-400",icon:x.jsx(W1,{size:14,className:"text-pink-400"})}};function y6(e){if(!e)return{};const o=new Set(e.disabledItems??[]),a={},i=[...e.skills,...e.agents,...e.commands,...e.hooks??[],...e.libs??[]];for(const s of i)a[s]=!o.has(s);return a}function lS({plugin:e,onClose:o,onTogglePlugin:a,onToggleItem:i,onRemoveItem:s}){const c=N.useMemo(()=>y6(e),[e]),[u,d]=N.useState(null),p=u??c,[m,y]=N.useState(!1),[g,v]=N.useState("closed"),S=N.useRef(null),w=N.useRef(null);N.useEffect(()=>{ih("useEffect",{animState:g,plugin:e?.name??null}),e?(S.current=e,w.current!==e.name&&(d(null),w.current=e.name),v(D=>D==="closed"?"opening":D)):(g==="open"||g==="opening")&&v("closing")},[e]);const _=N.useCallback(D=>{D.target===D.currentTarget&&(ih("animEnd",{animState:g,anim:D.animationName}),g==="opening"?v("open"):g==="closing"&&(v("closed"),S.current=null))},[g]),T=N.useCallback(()=>{ih("handleClose",{animState:g}),v("closing"),o()},[o,g]);if(g==="closed")return null;const z=S.current;if(!z)return null;const H=g==="opening"||g==="open",E=D=>{const O={};for(const Z of Object.keys(p))O[Z]=D;d(O),a(z.name,D)},M=[{type:"skill",items:z.skills},{type:"agent",items:z.agents},{type:"command",items:z.commands},{type:"hook",items:z.hooks??[]},{type:"lib",items:z.libs??[]}].filter(D=>D.items.length>0),R=M.reduce((D,O)=>D+O.items.length,0);return x.jsxs(x.Fragment,{children:[x.jsx("div",{className:Le("fixed inset-0 z-40 bg-black/50",H?"animate-fade-in":"animate-fade-out"),onClick:T}),x.jsxs("div",{role:"dialog","aria-label":z.name,className:Le("fixed right-0 top-0 z-50 h-full w-96 overflow-y-auto border-l bg-card text-card-foreground shadow-xl",H?"animate-slide-in-right":"animate-slide-out-right"),onAnimationEnd:_,children:[x.jsxs("div",{className:"flex items-start justify-between border-b p-4",children:[x.jsxs("div",{children:[x.jsx("h2",{className:"text-lg font-bold",children:z.name}),x.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[z.version&&x.jsxs("span",{className:"text-sm text-muted-foreground",children:["v",z.version]}),x.jsx("span",{className:"rounded-full bg-teal-500/10 px-2 py-0.5 text-xs text-teal-400 border border-teal-500/30",children:z.marketplace})]}),z.author&&x.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["by ",z.author]}),x.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:[R," components"]})]}),x.jsx("button",{onClick:T,className:"rounded-md p-1 text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":"Close",children:x.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[x.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),x.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),x.jsx("div",{className:"border-b p-4",children:x.jsx("p",{className:"text-sm text-muted-foreground",children:z.description})}),x.jsxs("div",{className:"flex gap-2 border-b p-4",children:[x.jsx("button",{onClick:()=>E(!0),className:Le("flex-1 rounded-md px-3 py-1.5 text-sm font-medium transition-colors",Object.values(p).some(D=>!D)?"bg-primary text-primary-foreground":"border bg-background text-foreground hover:bg-muted"),children:"Enable All"}),x.jsx("button",{onClick:()=>E(!1),className:Le("flex-1 rounded-md px-3 py-1.5 text-sm font-medium transition-colors",Object.values(p).some(Boolean)?"bg-destructive text-destructive-foreground":"border bg-background text-foreground hover:bg-muted"),children:"Disable All"})]}),M.map(({type:D,items:O})=>{const Z=g6[D]??{label:D,color:"text-muted-foreground",icon:"?"};return x.jsxs("div",{className:"border-b p-4",children:[x.jsxs("h3",{className:"mb-2 flex items-center gap-2 text-sm font-medium",children:[Z.icon,x.jsx("span",{className:Le("font-bold",Z.color),children:Z.label}),x.jsx("span",{className:"rounded-full bg-muted px-1.5 py-0 text-[10px] text-muted-foreground",children:O.length})]}),x.jsx("div",{className:"space-y-2",children:O.map($=>x.jsxs("div",{className:"flex items-center justify-between rounded-md border px-3 py-2",children:[x.jsx("span",{className:"text-sm",children:$}),x.jsx("button",{onClick:()=>{const oe=!p[$];d(q=>({...q??c,[$]:oe})),i?.(z.name,$,oe)},className:Le("relative inline-flex h-5 w-9 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors",p[$]?"bg-primary":"bg-muted"),role:"switch","aria-checked":p[$],"aria-label":`Toggle ${$}`,children:x.jsx("span",{className:Le("pointer-events-none inline-block h-4 w-4 rounded-full bg-white shadow-sm transition-transform",p[$]?"translate-x-4":"translate-x-0")})})]},$))})]},D)}),s&&x.jsxs("div",{className:"p-4",children:[x.jsx("h3",{className:"mb-2 text-sm font-medium text-destructive",children:"Danger Zone"}),x.jsxs("button",{onClick:()=>y(!0),className:"w-full rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm font-medium text-destructive hover:bg-destructive/20",children:["Remove ",z.marketplace==="system"?"MCP":z.marketplace==="standalone"?"Skill":"Plugin"]}),x.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["This removes it from ~/.mycelium. Run ",x.jsx("code",{className:"bg-muted px-1 rounded",children:"mycelium sync"})," to propagate to all tools."]})]})]}),m&&x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"fixed inset-0 z-[60] bg-black/60",onClick:()=>y(!1)}),x.jsxs("div",{className:"fixed left-1/2 top-1/2 z-[70] w-80 -translate-x-1/2 -translate-y-1/2 rounded-lg border bg-card p-6 shadow-2xl",children:[x.jsxs("h3",{className:"text-lg font-bold text-destructive",children:["Remove ",z.name,"?"]}),x.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["This will remove all components (",R," total) from ~/.mycelium. Run ",x.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"mycelium sync"})," after to propagate."]}),x.jsxs("div",{className:"mt-4 flex gap-2",children:[x.jsx("button",{onClick:()=>{const D=z.marketplace==="system"?"mcp":z.marketplace==="standalone"?"skill":"plugin";s?.(D,z.name),y(!1),o()},className:"flex-1 rounded-md bg-destructive px-3 py-2 text-sm font-medium text-destructive-foreground hover:bg-destructive/90",children:"Yes, remove"}),x.jsx("button",{onClick:()=>y(!1),className:"flex-1 rounded-md border px-3 py-2 text-sm font-medium hover:bg-muted",children:"Cancel"})]})]})]})]})}async function ll(){return(await fetch("/api/state")).json()}async function v6(e){await fetch("/api/toggle",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function b6(){return(await fetch("/api/migrate/scan")).json()}async function x6(e){return(await fetch("/api/migrate/apply",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json()}async function S6(e,o){const a=new URLSearchParams({q:e});return o&&a.set("source",o),(await fetch(`/api/marketplace/search?${a}`)).json()}async function w6(e,o){return(await fetch("/api/marketplace/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,source:o})})).json()}async function _6(){return(await fetch("/api/marketplace/registry")).json()}async function E6(e,o){await fetch("/api/marketplace/registry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,...o})})}async function C6(e){await fetch(`/api/marketplace/registry/${encodeURIComponent(e)}`,{method:"DELETE"})}async function N6(e){return(await fetch("/api/plugins")).json()}async function z6(e,o){return(await fetch("/api/plugins/toggle",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,enabled:o})})).json()}async function T6(e,o,a,i){return(await fetch(`/api/plugins/${encodeURIComponent(e)}/items/${encodeURIComponent(o)}/toggle`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:a,...i})})).json()}async function Wv(){return(await fetch("/api/marketplace/popular")).json()}async function A6(e){return(await fetch(`/api/remove/skill/${encodeURIComponent(e)}`,{method:"DELETE"})).json()}async function M6(e){return(await fetch(`/api/remove/mcp/${encodeURIComponent(e)}`,{method:"DELETE"})).json()}async function k6(e){return(await fetch(`/api/remove/plugin/${encodeURIComponent(e)}`,{method:"DELETE"})).json()}async function O6(e,o){return(await fetch("/api/marketplace/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,source:o})})).json()}function D6({onClose:e}){const[o,a]=N.useState("scan"),[i,s]=N.useState(!1),[c,u]=N.useState([]),[d,p]=N.useState(null),[m,y]=N.useState(0),[g,v]=N.useState({skills:{},mcps:{},memory:{},tools:{}}),[S,w]=N.useState(null);async function _(){s(!0),p(null);try{const $=await b6();u($);const oe={},q={},I={},W={};for(const L of $){L.installed&&(W[L.toolId]=!0);for(const Y of L.skills)oe[Y.name]=!0;for(const Y of L.mcps)q[Y.name]=!0;for(const Y of L.memory)I[Y.name]=!0}v({skills:oe,mcps:q,memory:I,tools:W}),a("review")}catch($){p($.message??"Scan failed")}finally{s(!1)}}async function T(){p(null),a("apply");try{const $=xc(c,g),oe=Object.entries(g.skills).filter(([,Y])=>Y).map(([Y])=>Y),q=Object.entries(g.mcps).filter(([,Y])=>Y).map(([Y])=>Y),I=Object.entries(g.memory).filter(([,Y])=>Y).map(([Y])=>Y),W={skills:$.plugins.flatMap(Y=>Y.skills.filter(A=>oe.includes(A)).map(A=>({name:A,source:"scan"}))),mcps:$.mcps.filter(Y=>q.includes(Y.name)).map(Y=>({name:Y.name,source:"scan",config:{command:"",args:[]}})),memory:$.memory.filter(Y=>I.includes(Y.name)).map(Y=>({name:Y.name,source:"scan",content:""})),conflicts:[]},L=await x6(W);y(L.skillsImported+L.mcpsImported+L.memoryImported),a("done")}catch($){p($.message??"Migration failed"),a("review")}}const z=N.useCallback($=>{v(oe=>{const q=$.type==="skill"?"skills":$.type==="mcp"?"mcps":$.type==="memory"?"memory":null;return q?{...oe,[q]:{...oe[q],[$.name]:$.enabled}}:oe})},[]),H=N.useCallback($=>{const q=xc(c,g).plugins.find(I=>I.name===$);q&&w({name:q.name,marketplace:q.marketplace,version:"scanned",description:`${q.componentCount} components from ${q.marketplace}`,enabled:q.enabled,skills:q.skills,agents:[],commands:[],hooks:[],libs:[]})},[c,g]),E=N.useCallback(($,oe)=>{const I=xc(c,g).plugins.find(W=>W.name===$);I&&v(W=>{const L={...W.skills};for(const Y of I.skills)L[Y]=oe;return{...W,skills:L}}),w(W=>W?{...W,enabled:oe}:null)},[c,g]),M=N.useCallback(()=>{console.log("Add tool destination")},[]),R=c.length>0?xc(c,g):void 0,D=Object.values(g.skills).filter(Boolean).length+Object.values(g.mcps).filter(Boolean).length+Object.values(g.memory).filter(Boolean).length,O={scan:"Scan",review:"Review",apply:"Apply",done:"Done"},Z=["scan","review","apply","done"];return x.jsxs("div",{className:"space-y-6",children:[x.jsx("div",{className:"flex items-center justify-center gap-2",children:Z.map(($,oe)=>x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("div",{className:Le("flex h-8 w-8 items-center justify-center rounded-full text-sm font-medium",$===o?"bg-primary text-primary-foreground":Z.indexOf(o)>oe?"bg-primary/20 text-primary":"bg-muted text-muted-foreground"),children:oe+1}),x.jsx("span",{className:"text-sm",children:O[$]}),oe<Z.length-1&&x.jsx("div",{className:"h-px w-8 bg-border"})]},$))}),d&&x.jsx("div",{className:"rounded-lg border border-red-500/50 bg-red-500/10 p-3 text-sm text-red-500",children:d}),o==="scan"&&x.jsxs("div",{className:"rounded-lg border bg-card p-6 text-card-foreground shadow-sm",children:[x.jsx("h2",{className:"text-lg font-semibold",children:"Scan for Tools"}),x.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Detect installed AI tools and their configurations to migrate into Mycelium."}),x.jsx("button",{onClick:_,disabled:i,className:"mt-4 rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:i?"Scanning...":"Start Scan"})]}),o==="review"&&R&&x.jsxs("div",{className:"space-y-4",children:[x.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-card p-4 text-card-foreground shadow-sm",children:[x.jsxs("div",{className:"flex gap-6 text-sm",children:[x.jsxs("span",{children:[x.jsx("strong",{children:R.plugins.length})," plugins"]}),x.jsxs("span",{children:[x.jsx("strong",{children:Object.values(g.skills).filter(Boolean).length})," skills"]}),x.jsxs("span",{children:[x.jsx("strong",{children:Object.values(g.mcps).filter(Boolean).length})," MCPs"]}),x.jsxs("span",{children:[x.jsx("strong",{children:Object.values(g.memory).filter(Boolean).length})," memory"]}),x.jsxs("span",{className:"text-muted-foreground",children:["→ ",x.jsx("strong",{children:R.tools.length})," destinations"]})]}),x.jsxs("div",{className:"flex gap-2",children:[x.jsx("button",{onClick:()=>a("scan"),className:"rounded-md border px-4 py-2 text-sm hover:bg-muted",children:"Rescan"}),x.jsxs("button",{onClick:T,disabled:D===0,className:"rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:["Apply (",D," items)"]})]})]}),x.jsx("div",{className:"h-[500px] rounded-lg border bg-card/50",children:x.jsx(rm,{children:x.jsx(rS,{mode:"migrate",data:R,showUninstalledTools:!1,onToggle:z,onPluginClick:H,onAddTool:M})})}),x.jsx("p",{className:"text-center text-sm text-muted-foreground",children:"Click plugin nodes to select individual skills. Toggle nodes to include/exclude from migration."})]}),o==="apply"&&x.jsxs("div",{className:"rounded-lg border bg-card p-6 text-card-foreground shadow-sm",children:[x.jsx("h2",{className:"text-lg font-semibold",children:"Applying Migration"}),x.jsxs("div",{className:"mt-4 flex items-center gap-3",children:[x.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-primary border-t-transparent"}),x.jsx("span",{className:"text-sm text-muted-foreground",children:"Migrating configurations..."})]})]}),o==="done"&&x.jsxs("div",{className:"rounded-lg border bg-card p-6 text-card-foreground shadow-sm",children:[x.jsx("h2",{className:"text-lg font-semibold",children:"Migration Complete"}),x.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["Successfully migrated ",m," items into Mycelium."]}),x.jsxs("div",{className:"mt-4 flex gap-2",children:[x.jsx("button",{onClick:()=>{a("scan"),u([])},className:"rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90",children:"Scan Again"}),e&&x.jsx("button",{onClick:e,className:"rounded-md border px-4 py-2 text-sm hover:bg-muted",children:"Close"})]})]}),x.jsx(lS,{plugin:S,onClose:()=>w(null),onTogglePlugin:E})]})}const j6={skill:{label:"Skill",color:"text-purple-400",bgColor:"bg-purple-500/10",borderColor:"border-purple-500/30",fileExt:".md"},mcp:{label:"MCP",color:"text-blue-400",bgColor:"bg-blue-500/10",borderColor:"border-blue-500/30",fileExt:".yaml"},plugin:{label:"Plugin",color:"text-amber-400",bgColor:"bg-amber-500/10",borderColor:"border-amber-500/30",fileExt:".json"},agent:{label:"Agent",color:"text-emerald-400",bgColor:"bg-emerald-500/10",borderColor:"border-emerald-500/30",fileExt:".md"},template:{label:"Template",color:"text-pink-400",bgColor:"bg-pink-500/10",borderColor:"border-pink-500/30",fileExt:".yaml"}},R6={label:"Item",color:"text-gray-400",bgColor:"bg-gray-500/10",borderColor:"border-gray-500/30",fileExt:".md"},L6={skill:"⚙",mcp:"⚡",plugin:"⬢",agent:"▶",template:"▦"};function H6(e){return j6[e]||R6}function eb(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function U6({item:e,installing:o,updating:a,expanded:i,onInstall:s,onUpdate:c,onToggleExpand:u}){const d=`${e.source}-${e.name}`,p=o===d,m=a===d,y=e.installed&&e.latestVersion&&e.installedVersion&&e.latestVersion!==e.installedVersion,g=H6(e.type),v=L6[e.type]||"●";return x.jsxs("div",{className:Le("group rounded-xl border bg-card text-sm shadow-sm transition-all cursor-pointer","hover:shadow-md hover:border-primary/40",g.borderColor,i&&"ring-2 ring-primary/30 shadow-md",e.installed&&"border-green-500/40"),onClick:()=>u(d),children:[x.jsx("div",{className:"px-4 pt-4 pb-2",children:x.jsxs("div",{className:"flex items-start justify-between gap-2",children:[x.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[x.jsx("div",{className:Le("flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-base",g.bgColor,g.color),children:v}),x.jsxs("div",{className:"min-w-0",children:[x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("span",{className:"font-semibold text-foreground truncate",children:e.name}),e.installed&&x.jsx("span",{className:"shrink-0 rounded-full bg-green-500/15 px-1.5 py-0.5 text-[10px] font-medium text-green-400",children:"Installed"}),y&&x.jsx("span",{className:"shrink-0 rounded-full bg-yellow-500/15 px-1.5 py-0.5 text-[10px] font-medium text-yellow-400",children:"Update"})]}),e.author&&x.jsx("span",{className:"text-xs text-muted-foreground",children:e.author})]})]}),x.jsx("span",{className:Le("shrink-0 rounded-md px-2 py-0.5 text-[10px] font-bold uppercase tracking-wider",g.bgColor,g.color),children:g.label})]})}),x.jsx("div",{className:"px-4 pb-3",children:x.jsx("p",{className:Le("text-xs text-muted-foreground leading-relaxed",!i&&"line-clamp-2"),children:e.description})}),x.jsxs("div",{className:"flex items-center gap-3 px-4 pb-3 text-xs text-muted-foreground",children:[e.stars!=null&&x.jsxs("span",{className:"flex items-center gap-1",children:[x.jsx("span",{className:"text-yellow-400",children:"★"}),eb(e.stars)]}),e.downloads!=null&&x.jsxs("span",{className:"flex items-center gap-1",children:[x.jsx("span",{className:"text-muted-foreground/60",children:"↓"}),eb(e.downloads)]}),e.latestVersion&&x.jsxs("span",{className:"font-mono",children:["v",e.latestVersion]}),x.jsx("span",{className:Le("ml-auto rounded-full px-2 py-0.5 text-[10px]",g.bgColor,g.color),children:e.source})]}),i&&x.jsxs("div",{className:"border-t border-border/50 px-4 py-3 space-y-3",children:[e.category&&x.jsx("div",{className:"flex flex-wrap gap-1.5",children:x.jsx("span",{className:"rounded-full bg-primary/15 px-2 py-0.5 text-[10px] text-primary font-medium",children:e.category})}),(e.installedVersion||e.latestVersion)&&x.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[e.installedVersion&&x.jsxs("span",{children:["Installed: ",x.jsxs("span",{className:"font-mono",children:["v",e.installedVersion]})]}),e.latestVersion&&x.jsxs("span",{children:["Latest: ",x.jsxs("span",{className:"font-mono",children:["v",e.latestVersion]})]})]}),e.updatedAt&&x.jsxs("div",{className:"text-xs text-muted-foreground",children:["Updated: ",e.updatedAt]}),x.jsxs("div",{className:"flex items-center justify-end gap-2 pt-1",children:[y&&x.jsx("button",{onClick:S=>{S.stopPropagation(),c(e)},disabled:m,className:"rounded-md px-3 py-1.5 text-xs font-medium bg-yellow-500/15 text-yellow-400 hover:bg-yellow-500/25 disabled:opacity-50 transition-colors",children:m?"Updating...":"Update"}),x.jsx("button",{onClick:S=>{S.stopPropagation(),s(e)},disabled:e.installed||p,className:Le("rounded-md px-4 py-1.5 text-xs font-medium transition-colors",e.installed?"border border-green-500/30 text-green-400 bg-green-500/10":"bg-primary text-primary-foreground hover:bg-primary/90","disabled:opacity-50"),children:e.installed?"Installed":p?"Installing...":"Install"})]})]}),!i&&x.jsxs("div",{className:"flex items-center justify-end px-4 pb-3",children:[y&&x.jsx("button",{onClick:S=>{S.stopPropagation(),c(e)},disabled:m,className:"mr-2 rounded-md px-2.5 py-1 text-[11px] font-medium text-yellow-400 hover:bg-yellow-500/15 disabled:opacity-50 transition-colors",children:m?"...":"Update"}),x.jsx("button",{onClick:S=>{S.stopPropagation(),s(e)},disabled:e.installed||p,className:Le("rounded-md px-3 py-1 text-[11px] font-medium transition-colors",e.installed?"text-green-400 bg-green-500/10":"bg-primary/80 text-primary-foreground hover:bg-primary","disabled:opacity-50"),children:e.installed?"Installed":p?"...":"Install"})]})]})}function Fo(e,o,{checkForDefaultPrevented:a=!0}={}){return function(s){if(e?.(s),a===!1||!s.defaultPrevented)return o?.(s)}}function tb(e,o){if(typeof e=="function")return e(o);e!=null&&(e.current=o)}function sS(...e){return o=>{let a=!1;const i=e.map(s=>{const c=tb(s,o);return!a&&typeof c=="function"&&(a=!0),c});if(a)return()=>{for(let s=0;s<i.length;s++){const c=i[s];typeof c=="function"?c():tb(e[s],null)}}}}function Ia(...e){return N.useCallback(sS(...e),e)}function Z6(e,o){const a=N.createContext(o),i=c=>{const{children:u,...d}=c,p=N.useMemo(()=>d,Object.values(d));return x.jsx(a.Provider,{value:p,children:u})};i.displayName=e+"Provider";function s(c){const u=N.useContext(a);if(u)return u;if(o!==void 0)return o;throw new Error(`\`${c}\` must be used within \`${e}\``)}return[i,s]}function B6(e,o=[]){let a=[];function i(c,u){const d=N.createContext(u),p=a.length;a=[...a,u];const m=g=>{const{scope:v,children:S,...w}=g,_=v?.[e]?.[p]||d,T=N.useMemo(()=>w,Object.values(w));return x.jsx(_.Provider,{value:T,children:S})};m.displayName=c+"Provider";function y(g,v){const S=v?.[e]?.[p]||d,w=N.useContext(S);if(w)return w;if(u!==void 0)return u;throw new Error(`\`${g}\` must be used within \`${c}\``)}return[m,y]}const s=()=>{const c=a.map(u=>N.createContext(u));return function(d){const p=d?.[e]||c;return N.useMemo(()=>({[`__scope${e}`]:{...d,[e]:p}}),[d,p])}};return s.scopeName=e,[i,$6(s,...o)]}function $6(...e){const o=e[0];if(e.length===1)return o;const a=()=>{const i=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(c){const u=i.reduce((d,{useScope:p,scopeName:m})=>{const g=p(c)[`__scope${m}`];return{...d,...g}},{});return N.useMemo(()=>({[`__scope${o.scopeName}`]:u}),[u])}};return a.scopeName=o.scopeName,a}var Nl=globalThis?.document?N.useLayoutEffect:()=>{},V6=_b[" useId ".trim().toString()]||(()=>{}),Y6=0;function lh(e){const[o,a]=N.useState(V6());return Nl(()=>{a(i=>i??String(Y6++))},[e]),e||(o?`radix-${o}`:"")}var q6=_b[" useInsertionEffect ".trim().toString()]||Nl;function G6({prop:e,defaultProp:o,onChange:a=()=>{},caller:i}){const[s,c,u]=I6({defaultProp:o,onChange:a}),d=e!==void 0,p=d?e:s;{const y=N.useRef(e!==void 0);N.useEffect(()=>{const g=y.current;g!==d&&console.warn(`${i} is changing from ${g?"controlled":"uncontrolled"} to ${d?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),y.current=d},[d,i])}const m=N.useCallback(y=>{if(d){const g=X6(y)?y(e):y;g!==e&&u.current?.(g)}else c(y)},[d,e,c,u]);return[p,m]}function I6({defaultProp:e,onChange:o}){const[a,i]=N.useState(e),s=N.useRef(a),c=N.useRef(o);return q6(()=>{c.current=o},[o]),N.useEffect(()=>{s.current!==a&&(c.current?.(a),s.current=a)},[a,s]),[a,i,c]}function X6(e){return typeof e=="function"}function cS(e){const o=P6(e),a=N.forwardRef((i,s)=>{const{children:c,...u}=i,d=N.Children.toArray(c),p=d.find(K6);if(p){const m=p.props.children,y=d.map(g=>g===p?N.Children.count(m)>1?N.Children.only(null):N.isValidElement(m)?m.props.children:null:g);return x.jsx(o,{...u,ref:s,children:N.isValidElement(m)?N.cloneElement(m,void 0,y):null})}return x.jsx(o,{...u,ref:s,children:c})});return a.displayName=`${e}.Slot`,a}function P6(e){const o=N.forwardRef((a,i)=>{const{children:s,...c}=a;if(N.isValidElement(s)){const u=F6(s),d=J6(c,s.props);return s.type!==N.Fragment&&(d.ref=i?sS(i,u):u),N.cloneElement(s,d)}return N.Children.count(s)>1?N.Children.only(null):null});return o.displayName=`${e}.SlotClone`,o}var Q6=Symbol("radix.slottable");function K6(e){return N.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Q6}function J6(e,o){const a={...o};for(const i in o){const s=e[i],c=o[i];/^on[A-Z]/.test(i)?s&&c?a[i]=(...d)=>{const p=c(...d);return s(...d),p}:s&&(a[i]=s):i==="style"?a[i]={...s,...c}:i==="className"&&(a[i]=[s,c].filter(Boolean).join(" "))}return{...e,...a}}function F6(e){let o=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,a=o&&"isReactWarning"in o&&o.isReactWarning;return a?e.ref:(o=Object.getOwnPropertyDescriptor(e,"ref")?.get,a=o&&"isReactWarning"in o&&o.isReactWarning,a?e.props.ref:e.props.ref||e.ref)}var W6=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],go=W6.reduce((e,o)=>{const a=cS(`Primitive.${o}`),i=N.forwardRef((s,c)=>{const{asChild:u,...d}=s,p=u?a:o;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),x.jsx(p,{...d,ref:c})});return i.displayName=`Primitive.${o}`,{...e,[o]:i}},{});function eD(e,o){e&&qx.flushSync(()=>e.dispatchEvent(o))}function zl(e){const o=N.useRef(e);return N.useEffect(()=>{o.current=e}),N.useMemo(()=>(...a)=>o.current?.(...a),[])}function tD(e,o=globalThis?.document){const a=zl(e);N.useEffect(()=>{const i=s=>{s.key==="Escape"&&a(s)};return o.addEventListener("keydown",i,{capture:!0}),()=>o.removeEventListener("keydown",i,{capture:!0})},[a,o])}var nD="DismissableLayer",Hh="dismissableLayer.update",oD="dismissableLayer.pointerDownOutside",aD="dismissableLayer.focusOutside",nb,uS=N.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),fS=N.forwardRef((e,o)=>{const{disableOutsidePointerEvents:a=!1,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:c,onInteractOutside:u,onDismiss:d,...p}=e,m=N.useContext(uS),[y,g]=N.useState(null),v=y?.ownerDocument??globalThis?.document,[,S]=N.useState({}),w=Ia(o,O=>g(O)),_=Array.from(m.layers),[T]=[...m.layersWithOutsidePointerEventsDisabled].slice(-1),z=_.indexOf(T),H=y?_.indexOf(y):-1,E=m.layersWithOutsidePointerEventsDisabled.size>0,M=H>=z,R=lD(O=>{const Z=O.target,$=[...m.branches].some(oe=>oe.contains(Z));!M||$||(s?.(O),u?.(O),O.defaultPrevented||d?.())},v),D=sD(O=>{const Z=O.target;[...m.branches].some(oe=>oe.contains(Z))||(c?.(O),u?.(O),O.defaultPrevented||d?.())},v);return tD(O=>{H===m.layers.size-1&&(i?.(O),!O.defaultPrevented&&d&&(O.preventDefault(),d()))},v),N.useEffect(()=>{if(y)return a&&(m.layersWithOutsidePointerEventsDisabled.size===0&&(nb=v.body.style.pointerEvents,v.body.style.pointerEvents="none"),m.layersWithOutsidePointerEventsDisabled.add(y)),m.layers.add(y),ob(),()=>{a&&m.layersWithOutsidePointerEventsDisabled.size===1&&(v.body.style.pointerEvents=nb)}},[y,v,a,m]),N.useEffect(()=>()=>{y&&(m.layers.delete(y),m.layersWithOutsidePointerEventsDisabled.delete(y),ob())},[y,m]),N.useEffect(()=>{const O=()=>S({});return document.addEventListener(Hh,O),()=>document.removeEventListener(Hh,O)},[]),x.jsx(go.div,{...p,ref:w,style:{pointerEvents:E?M?"auto":"none":void 0,...e.style},onFocusCapture:Fo(e.onFocusCapture,D.onFocusCapture),onBlurCapture:Fo(e.onBlurCapture,D.onBlurCapture),onPointerDownCapture:Fo(e.onPointerDownCapture,R.onPointerDownCapture)})});fS.displayName=nD;var rD="DismissableLayerBranch",iD=N.forwardRef((e,o)=>{const a=N.useContext(uS),i=N.useRef(null),s=Ia(o,i);return N.useEffect(()=>{const c=i.current;if(c)return a.branches.add(c),()=>{a.branches.delete(c)}},[a.branches]),x.jsx(go.div,{...e,ref:s})});iD.displayName=rD;function lD(e,o=globalThis?.document){const a=zl(e),i=N.useRef(!1),s=N.useRef(()=>{});return N.useEffect(()=>{const c=d=>{if(d.target&&!i.current){let p=function(){dS(oD,a,m,{discrete:!0})};const m={originalEvent:d};d.pointerType==="touch"?(o.removeEventListener("click",s.current),s.current=p,o.addEventListener("click",s.current,{once:!0})):p()}else o.removeEventListener("click",s.current);i.current=!1},u=window.setTimeout(()=>{o.addEventListener("pointerdown",c)},0);return()=>{window.clearTimeout(u),o.removeEventListener("pointerdown",c),o.removeEventListener("click",s.current)}},[o,a]),{onPointerDownCapture:()=>i.current=!0}}function sD(e,o=globalThis?.document){const a=zl(e),i=N.useRef(!1);return N.useEffect(()=>{const s=c=>{c.target&&!i.current&&dS(aD,a,{originalEvent:c},{discrete:!1})};return o.addEventListener("focusin",s),()=>o.removeEventListener("focusin",s)},[o,a]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}function ob(){const e=new CustomEvent(Hh);document.dispatchEvent(e)}function dS(e,o,a,{discrete:i}){const s=a.originalEvent.target,c=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:a});o&&s.addEventListener(e,o,{once:!0}),i?eD(s,c):s.dispatchEvent(c)}var sh="focusScope.autoFocusOnMount",ch="focusScope.autoFocusOnUnmount",ab={bubbles:!1,cancelable:!0},cD="FocusScope",hS=N.forwardRef((e,o)=>{const{loop:a=!1,trapped:i=!1,onMountAutoFocus:s,onUnmountAutoFocus:c,...u}=e,[d,p]=N.useState(null),m=zl(s),y=zl(c),g=N.useRef(null),v=Ia(o,_=>p(_)),S=N.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;N.useEffect(()=>{if(i){let _=function(E){if(S.paused||!d)return;const M=E.target;d.contains(M)?g.current=M:Qo(g.current,{select:!0})},T=function(E){if(S.paused||!d)return;const M=E.relatedTarget;M!==null&&(d.contains(M)||Qo(g.current,{select:!0}))},z=function(E){if(document.activeElement===document.body)for(const R of E)R.removedNodes.length>0&&Qo(d)};document.addEventListener("focusin",_),document.addEventListener("focusout",T);const H=new MutationObserver(z);return d&&H.observe(d,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",_),document.removeEventListener("focusout",T),H.disconnect()}}},[i,d,S.paused]),N.useEffect(()=>{if(d){ib.add(S);const _=document.activeElement;if(!d.contains(_)){const z=new CustomEvent(sh,ab);d.addEventListener(sh,m),d.dispatchEvent(z),z.defaultPrevented||(uD(pD(mS(d)),{select:!0}),document.activeElement===_&&Qo(d))}return()=>{d.removeEventListener(sh,m),setTimeout(()=>{const z=new CustomEvent(ch,ab);d.addEventListener(ch,y),d.dispatchEvent(z),z.defaultPrevented||Qo(_??document.body,{select:!0}),d.removeEventListener(ch,y),ib.remove(S)},0)}}},[d,m,y,S]);const w=N.useCallback(_=>{if(!a&&!i||S.paused)return;const T=_.key==="Tab"&&!_.altKey&&!_.ctrlKey&&!_.metaKey,z=document.activeElement;if(T&&z){const H=_.currentTarget,[E,M]=fD(H);E&&M?!_.shiftKey&&z===M?(_.preventDefault(),a&&Qo(E,{select:!0})):_.shiftKey&&z===E&&(_.preventDefault(),a&&Qo(M,{select:!0})):z===H&&_.preventDefault()}},[a,i,S.paused]);return x.jsx(go.div,{tabIndex:-1,...u,ref:v,onKeyDown:w})});hS.displayName=cD;function uD(e,{select:o=!1}={}){const a=document.activeElement;for(const i of e)if(Qo(i,{select:o}),document.activeElement!==a)return}function fD(e){const o=mS(e),a=rb(o,e),i=rb(o.reverse(),e);return[a,i]}function mS(e){const o=[],a=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:i=>{const s=i.tagName==="INPUT"&&i.type==="hidden";return i.disabled||i.hidden||s?NodeFilter.FILTER_SKIP:i.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;a.nextNode();)o.push(a.currentNode);return o}function rb(e,o){for(const a of e)if(!dD(a,{upTo:o}))return a}function dD(e,{upTo:o}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(o!==void 0&&e===o)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function hD(e){return e instanceof HTMLInputElement&&"select"in e}function Qo(e,{select:o=!1}={}){if(e&&e.focus){const a=document.activeElement;e.focus({preventScroll:!0}),e!==a&&hD(e)&&o&&e.select()}}var ib=mD();function mD(){let e=[];return{add(o){const a=e[0];o!==a&&a?.pause(),e=lb(e,o),e.unshift(o)},remove(o){e=lb(e,o),e[0]?.resume()}}}function lb(e,o){const a=[...e],i=a.indexOf(o);return i!==-1&&a.splice(i,1),a}function pD(e){return e.filter(o=>o.tagName!=="A")}var gD="Portal",pS=N.forwardRef((e,o)=>{const{container:a,...i}=e,[s,c]=N.useState(!1);Nl(()=>c(!0),[]);const u=a||s&&globalThis?.document?.body;return u?Lz.createPortal(x.jsx(go.div,{...i,ref:o}),u):null});pS.displayName=gD;function yD(e,o){return N.useReducer((a,i)=>o[a][i]??a,e)}var vu=e=>{const{present:o,children:a}=e,i=vD(o),s=typeof a=="function"?a({present:i.isPresent}):N.Children.only(a),c=Ia(i.ref,bD(s));return typeof a=="function"||i.isPresent?N.cloneElement(s,{ref:c}):null};vu.displayName="Presence";function vD(e){const[o,a]=N.useState(),i=N.useRef(null),s=N.useRef(e),c=N.useRef("none"),u=e?"mounted":"unmounted",[d,p]=yD(u,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return N.useEffect(()=>{const m=_c(i.current);c.current=d==="mounted"?m:"none"},[d]),Nl(()=>{const m=i.current,y=s.current;if(y!==e){const v=c.current,S=_c(m);e?p("MOUNT"):S==="none"||m?.display==="none"?p("UNMOUNT"):p(y&&v!==S?"ANIMATION_OUT":"UNMOUNT"),s.current=e}},[e,p]),Nl(()=>{if(o){let m;const y=o.ownerDocument.defaultView??window,g=S=>{const _=_c(i.current).includes(CSS.escape(S.animationName));if(S.target===o&&_&&(p("ANIMATION_END"),!s.current)){const T=o.style.animationFillMode;o.style.animationFillMode="forwards",m=y.setTimeout(()=>{o.style.animationFillMode==="forwards"&&(o.style.animationFillMode=T)})}},v=S=>{S.target===o&&(c.current=_c(i.current))};return o.addEventListener("animationstart",v),o.addEventListener("animationcancel",g),o.addEventListener("animationend",g),()=>{y.clearTimeout(m),o.removeEventListener("animationstart",v),o.removeEventListener("animationcancel",g),o.removeEventListener("animationend",g)}}else p("ANIMATION_END")},[o,p]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:N.useCallback(m=>{i.current=m?getComputedStyle(m):null,a(m)},[])}}function _c(e){return e?.animationName||"none"}function bD(e){let o=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,a=o&&"isReactWarning"in o&&o.isReactWarning;return a?e.ref:(o=Object.getOwnPropertyDescriptor(e,"ref")?.get,a=o&&"isReactWarning"in o&&o.isReactWarning,a?e.props.ref:e.props.ref||e.ref)}var uh=0;function xD(){N.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??sb()),document.body.insertAdjacentElement("beforeend",e[1]??sb()),uh++,()=>{uh===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(o=>o.remove()),uh--}},[])}function sb(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Rn=function(){return Rn=Object.assign||function(o){for(var a,i=1,s=arguments.length;i<s;i++){a=arguments[i];for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(o[c]=a[c])}return o},Rn.apply(this,arguments)};function gS(e,o){var a={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&o.indexOf(i)<0&&(a[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(e);s<i.length;s++)o.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(e,i[s])&&(a[i[s]]=e[i[s]]);return a}function SD(e,o,a){if(a||arguments.length===2)for(var i=0,s=o.length,c;i<s;i++)(c||!(i in o))&&(c||(c=Array.prototype.slice.call(o,0,i)),c[i]=o[i]);return e.concat(c||Array.prototype.slice.call(o))}var jc="right-scroll-bar-position",Rc="width-before-scroll-bar",wD="with-scroll-bars-hidden",_D="--removed-body-scroll-bar-size";function fh(e,o){return typeof e=="function"?e(o):e&&(e.current=o),e}function ED(e,o){var a=N.useState(function(){return{value:e,callback:o,facade:{get current(){return a.value},set current(i){var s=a.value;s!==i&&(a.value=i,a.callback(i,s))}}}})[0];return a.callback=o,a.facade}var CD=typeof window<"u"?N.useLayoutEffect:N.useEffect,cb=new WeakMap;function ND(e,o){var a=ED(null,function(i){return e.forEach(function(s){return fh(s,i)})});return CD(function(){var i=cb.get(a);if(i){var s=new Set(i),c=new Set(e),u=a.current;s.forEach(function(d){c.has(d)||fh(d,null)}),c.forEach(function(d){s.has(d)||fh(d,u)})}cb.set(a,e)},[e]),a}function zD(e){return e}function TD(e,o){o===void 0&&(o=zD);var a=[],i=!1,s={read:function(){if(i)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return a.length?a[a.length-1]:e},useMedium:function(c){var u=o(c,i);return a.push(u),function(){a=a.filter(function(d){return d!==u})}},assignSyncMedium:function(c){for(i=!0;a.length;){var u=a;a=[],u.forEach(c)}a={push:function(d){return c(d)},filter:function(){return a}}},assignMedium:function(c){i=!0;var u=[];if(a.length){var d=a;a=[],d.forEach(c),u=a}var p=function(){var y=u;u=[],y.forEach(c)},m=function(){return Promise.resolve().then(p)};m(),a={push:function(y){u.push(y),m()},filter:function(y){return u=u.filter(y),a}}}};return s}function AD(e){e===void 0&&(e={});var o=TD(null);return o.options=Rn({async:!0,ssr:!1},e),o}var yS=function(e){var o=e.sideCar,a=gS(e,["sideCar"]);if(!o)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var i=o.read();if(!i)throw new Error("Sidecar medium not found");return N.createElement(i,Rn({},a))};yS.isSideCarExport=!0;function MD(e,o){return e.useMedium(o),yS}var vS=AD(),dh=function(){},bu=N.forwardRef(function(e,o){var a=N.useRef(null),i=N.useState({onScrollCapture:dh,onWheelCapture:dh,onTouchMoveCapture:dh}),s=i[0],c=i[1],u=e.forwardProps,d=e.children,p=e.className,m=e.removeScrollBar,y=e.enabled,g=e.shards,v=e.sideCar,S=e.noRelative,w=e.noIsolation,_=e.inert,T=e.allowPinchZoom,z=e.as,H=z===void 0?"div":z,E=e.gapMode,M=gS(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),R=v,D=ND([a,o]),O=Rn(Rn({},M),s);return N.createElement(N.Fragment,null,y&&N.createElement(R,{sideCar:vS,removeScrollBar:m,shards:g,noRelative:S,noIsolation:w,inert:_,setCallbacks:c,allowPinchZoom:!!T,lockRef:a,gapMode:E}),u?N.cloneElement(N.Children.only(d),Rn(Rn({},O),{ref:D})):N.createElement(H,Rn({},O,{className:p,ref:D}),d))});bu.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};bu.classNames={fullWidth:Rc,zeroRight:jc};var kD=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function OD(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var o=kD();return o&&e.setAttribute("nonce",o),e}function DD(e,o){e.styleSheet?e.styleSheet.cssText=o:e.appendChild(document.createTextNode(o))}function jD(e){var o=document.head||document.getElementsByTagName("head")[0];o.appendChild(e)}var RD=function(){var e=0,o=null;return{add:function(a){e==0&&(o=OD())&&(DD(o,a),jD(o)),e++},remove:function(){e--,!e&&o&&(o.parentNode&&o.parentNode.removeChild(o),o=null)}}},LD=function(){var e=RD();return function(o,a){N.useEffect(function(){return e.add(o),function(){e.remove()}},[o&&a])}},bS=function(){var e=LD(),o=function(a){var i=a.styles,s=a.dynamic;return e(i,s),null};return o},HD={left:0,top:0,right:0,gap:0},hh=function(e){return parseInt(e||"",10)||0},UD=function(e){var o=window.getComputedStyle(document.body),a=o[e==="padding"?"paddingLeft":"marginLeft"],i=o[e==="padding"?"paddingTop":"marginTop"],s=o[e==="padding"?"paddingRight":"marginRight"];return[hh(a),hh(i),hh(s)]},ZD=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return HD;var o=UD(e),a=document.documentElement.clientWidth,i=window.innerWidth;return{left:o[0],top:o[1],right:o[2],gap:Math.max(0,i-a+o[2]-o[0])}},BD=bS(),Pr="data-scroll-locked",$D=function(e,o,a,i){var s=e.left,c=e.top,u=e.right,d=e.gap;return a===void 0&&(a="margin"),`
|
|
109
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const u of e.seen.entries()){const d=u[1];if(o===u[0]){c(u);continue}if(e.external){const m=e.external.registry.get(u[0])?.id;if(o!==u[0]&&m){c(u);continue}}if(e.metadataRegistry.get(u[0])?.id){c(u);continue}if(d.cycle){c(u);continue}if(d.count>1&&e.reused==="ref"){c(u);continue}}}function q1(e,o){const a=e.seen.get(o);if(!a)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=u=>{const d=e.seen.get(u);if(d.ref===null)return;const p=d.def??d.schema,m={...p},y=d.ref;if(d.ref=null,y){i(y);const v=e.seen.get(y),S=v.schema;if(S.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(S)):Object.assign(p,S),Object.assign(p,m),u._zod.parent===y)for(const _ in p)_==="$ref"||_==="allOf"||_ in m||delete p[_];if(S.$ref&&v.def)for(const _ in p)_==="$ref"||_==="allOf"||_ in v.def&&JSON.stringify(p[_])===JSON.stringify(v.def[_])&&delete p[_]}const g=u._zod.parent;if(g&&g!==y){i(g);const v=e.seen.get(g);if(v?.schema.$ref&&(p.$ref=v.schema.$ref,v.def))for(const S in p)S==="$ref"||S==="allOf"||S in v.def&&JSON.stringify(p[S])===JSON.stringify(v.def[S])&&delete p[S]}e.override({zodSchema:u,jsonSchema:p,path:d.path??[]})};for(const u of[...e.seen.entries()].reverse())i(u[0]);const s={};if(e.target==="draft-2020-12"?s.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?s.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?s.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const u=e.external.registry.get(o)?.id;if(!u)throw new Error("Schema is missing an `id` property");s.$id=e.external.uri(u)}Object.assign(s,a.def??a.schema);const c=e.external?.defs??{};for(const u of e.seen.entries()){const d=u[1];d.def&&d.defId&&(c[d.defId]=d.def)}e.external||Object.keys(c).length>0&&(e.target==="draft-2020-12"?s.$defs=c:s.definitions=c);try{const u=JSON.parse(JSON.stringify(s));return Object.defineProperty(u,"~standard",{value:{...o["~standard"],jsonSchema:{input:Jc(o,"input",e.processors),output:Jc(o,"output",e.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function Lt(e,o){const a=o??{seen:new Set};if(a.seen.has(e))return!1;a.seen.add(e);const i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return Lt(i.element,a);if(i.type==="set")return Lt(i.valueType,a);if(i.type==="lazy")return Lt(i.getter(),a);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault")return Lt(i.innerType,a);if(i.type==="intersection")return Lt(i.left,a)||Lt(i.right,a);if(i.type==="record"||i.type==="map")return Lt(i.keyType,a)||Lt(i.valueType,a);if(i.type==="pipe")return Lt(i.in,a)||Lt(i.out,a);if(i.type==="object"){for(const s in i.shape)if(Lt(i.shape[s],a))return!0;return!1}if(i.type==="union"){for(const s of i.options)if(Lt(s,a))return!0;return!1}if(i.type==="tuple"){for(const s of i.items)if(Lt(s,a))return!0;return!!(i.rest&&Lt(i.rest,a))}return!1}const WM=(e,o={})=>a=>{const i=V1({...a,processors:o});return bt(e,i),Y1(i,e),q1(i,e)},Jc=(e,o,a={})=>i=>{const{libraryOptions:s,target:c}=i??{},u=V1({...s??{},target:c,io:o,processors:a});return bt(e,u),Y1(u,e),q1(u,e)},ek={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},tk=(e,o,a,i)=>{const s=a;s.type="string";const{minimum:c,maximum:u,format:d,patterns:p,contentEncoding:m}=e._zod.bag;if(typeof c=="number"&&(s.minLength=c),typeof u=="number"&&(s.maxLength=u),d&&(s.format=ek[d]??d,s.format===""&&delete s.format,d==="time"&&delete s.format),m&&(s.contentEncoding=m),p&&p.size>0){const y=[...p];y.length===1?s.pattern=y[0].source:y.length>1&&(s.allOf=[...y.map(g=>({...o.target==="draft-07"||o.target==="draft-04"||o.target==="openapi-3.0"?{type:"string"}:{},pattern:g.source}))])}},nk=(e,o,a,i)=>{a.type="boolean"},ok=(e,o,a,i)=>{a.not={}},ak=(e,o,a,i)=>{},rk=(e,o,a,i)=>{const s=e._zod.def,c=z1(s.entries);c.every(u=>typeof u=="number")&&(a.type="number"),c.every(u=>typeof u=="string")&&(a.type="string"),a.enum=c},ik=(e,o,a,i)=>{if(o.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},lk=(e,o,a,i)=>{if(o.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},sk=(e,o,a,i)=>{const s=a,c=e._zod.def,{minimum:u,maximum:d}=e._zod.bag;typeof u=="number"&&(s.minItems=u),typeof d=="number"&&(s.maxItems=d),s.type="array",s.items=bt(c.element,o,{...i,path:[...i.path,"items"]})},ck=(e,o,a,i)=>{const s=a,c=e._zod.def;s.type="object",s.properties={};const u=c.shape;for(const m in u)s.properties[m]=bt(u[m],o,{...i,path:[...i.path,"properties",m]});const d=new Set(Object.keys(u)),p=new Set([...d].filter(m=>{const y=c.shape[m]._zod;return o.io==="input"?y.optin===void 0:y.optout===void 0}));p.size>0&&(s.required=Array.from(p)),c.catchall?._zod.def.type==="never"?s.additionalProperties=!1:c.catchall?c.catchall&&(s.additionalProperties=bt(c.catchall,o,{...i,path:[...i.path,"additionalProperties"]})):o.io==="output"&&(s.additionalProperties=!1)},uk=(e,o,a,i)=>{const s=e._zod.def,c=s.inclusive===!1,u=s.options.map((d,p)=>bt(d,o,{...i,path:[...i.path,c?"oneOf":"anyOf",p]}));c?a.oneOf=u:a.anyOf=u},fk=(e,o,a,i)=>{const s=e._zod.def,c=bt(s.left,o,{...i,path:[...i.path,"allOf",0]}),u=bt(s.right,o,{...i,path:[...i.path,"allOf",1]}),d=m=>"allOf"in m&&Object.keys(m).length===1,p=[...d(c)?c.allOf:[c],...d(u)?u.allOf:[u]];a.allOf=p},dk=(e,o,a,i)=>{const s=a,c=e._zod.def;s.type="object";const u=c.keyType,p=u._zod.bag?.patterns;if(c.mode==="loose"&&p&&p.size>0){const y=bt(c.valueType,o,{...i,path:[...i.path,"patternProperties","*"]});s.patternProperties={};for(const g of p)s.patternProperties[g.source]=y}else(o.target==="draft-07"||o.target==="draft-2020-12")&&(s.propertyNames=bt(c.keyType,o,{...i,path:[...i.path,"propertyNames"]})),s.additionalProperties=bt(c.valueType,o,{...i,path:[...i.path,"additionalProperties"]});const m=u._zod.values;if(m){const y=[...m].filter(g=>typeof g=="string"||typeof g=="number");y.length>0&&(s.required=y)}},hk=(e,o,a,i)=>{const s=e._zod.def,c=bt(s.innerType,o,i),u=o.seen.get(e);o.target==="openapi-3.0"?(u.ref=s.innerType,a.nullable=!0):a.anyOf=[c,{type:"null"}]},mk=(e,o,a,i)=>{const s=e._zod.def;bt(s.innerType,o,i);const c=o.seen.get(e);c.ref=s.innerType},pk=(e,o,a,i)=>{const s=e._zod.def;bt(s.innerType,o,i);const c=o.seen.get(e);c.ref=s.innerType,a.default=JSON.parse(JSON.stringify(s.defaultValue))},gk=(e,o,a,i)=>{const s=e._zod.def;bt(s.innerType,o,i);const c=o.seen.get(e);c.ref=s.innerType,o.io==="input"&&(a._prefault=JSON.parse(JSON.stringify(s.defaultValue)))},yk=(e,o,a,i)=>{const s=e._zod.def;bt(s.innerType,o,i);const c=o.seen.get(e);c.ref=s.innerType;let u;try{u=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}a.default=u},vk=(e,o,a,i)=>{const s=e._zod.def,c=o.io==="input"?s.in._zod.def.type==="transform"?s.out:s.in:s.out;bt(c,o,i);const u=o.seen.get(e);u.ref=c},bk=(e,o,a,i)=>{const s=e._zod.def;bt(s.innerType,o,i);const c=o.seen.get(e);c.ref=s.innerType,a.readOnly=!0},G1=(e,o,a,i)=>{const s=e._zod.def;bt(s.innerType,o,i);const c=o.seen.get(e);c.ref=s.innerType},xk=fe("ZodISODateTime",(e,o)=>{zA.init(e,o),ot.init(e,o)});function Sk(e){return kM(xk,e)}const wk=fe("ZodISODate",(e,o)=>{TA.init(e,o),ot.init(e,o)});function _k(e){return OM(wk,e)}const Ek=fe("ZodISOTime",(e,o)=>{AA.init(e,o),ot.init(e,o)});function Ck(e){return DM(Ek,e)}const Nk=fe("ZodISODuration",(e,o)=>{MA.init(e,o),ot.init(e,o)});function zk(e){return jM(Nk,e)}const Tk=(e,o)=>{k1.init(e,o),e.name="ZodError",Object.defineProperties(e,{format:{value:a=>wT(e,a)},flatten:{value:a=>ST(e,a)},addIssue:{value:a=>{e.issues.push(a),e.message=JSON.stringify(e.issues,kh,2)}},addIssues:{value:a=>{e.issues.push(...a),e.message=JSON.stringify(e.issues,kh,2)}},isEmpty:{get(){return e.issues.length===0}}})},gn=fe("ZodError",Tk,{Parent:Error}),Ak=um(gn),Mk=fm(gn),kk=mu(gn),Ok=pu(gn),Dk=CT(gn),jk=NT(gn),Rk=zT(gn),Lk=TT(gn),Hk=AT(gn),Uk=MT(gn),Zk=kT(gn),Bk=OT(gn),ft=fe("ZodType",(e,o)=>(ut.init(e,o),Object.assign(e["~standard"],{jsonSchema:{input:Jc(e,"input"),output:Jc(e,"output")}}),e.toJSONSchema=WM(e,{}),e.def=o,e.type=o.type,Object.defineProperty(e,"_def",{value:o}),e.check=(...a)=>e.clone(aa(o,{checks:[...o.checks??[],...a.map(i=>typeof i=="function"?{_zod:{check:i,def:{check:"custom"},onattach:[]}}:i)]}),{parent:!0}),e.with=e.check,e.clone=(a,i)=>ra(e,a,i),e.brand=()=>e,e.register=((a,i)=>(a.add(e,i),e)),e.parse=(a,i)=>Ak(e,a,i,{callee:e.parse}),e.safeParse=(a,i)=>kk(e,a,i),e.parseAsync=async(a,i)=>Mk(e,a,i,{callee:e.parseAsync}),e.safeParseAsync=async(a,i)=>Ok(e,a,i),e.spa=e.safeParseAsync,e.encode=(a,i)=>Dk(e,a,i),e.decode=(a,i)=>jk(e,a,i),e.encodeAsync=async(a,i)=>Rk(e,a,i),e.decodeAsync=async(a,i)=>Lk(e,a,i),e.safeEncode=(a,i)=>Hk(e,a,i),e.safeDecode=(a,i)=>Uk(e,a,i),e.safeEncodeAsync=async(a,i)=>Zk(e,a,i),e.safeDecodeAsync=async(a,i)=>Bk(e,a,i),e.refine=(a,i)=>e.check(OO(a,i)),e.superRefine=a=>e.check(DO(a)),e.overwrite=a=>e.check(li(a)),e.optional=()=>Uv(e),e.exactOptional=()=>bO(e),e.nullable=()=>Zv(e),e.nullish=()=>Uv(Zv(e)),e.nonoptional=a=>CO(e,a),e.array=()=>ho(e),e.or=a=>dO([e,a]),e.and=a=>mO(e,a),e.transform=a=>Bv(e,yO(a)),e.default=a=>wO(e,a),e.prefault=a=>EO(e,a),e.catch=a=>zO(e,a),e.pipe=a=>Bv(e,a),e.readonly=()=>MO(e),e.describe=a=>{const i=e.clone();return ul.add(i,{description:a}),i},Object.defineProperty(e,"description",{get(){return ul.get(e)?.description},configurable:!0}),e.meta=(...a)=>{if(a.length===0)return ul.get(e);const i=e.clone();return ul.add(i,a[0]),i},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=a=>a(e),e)),I1=fe("_ZodString",(e,o)=>{dm.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(i,s,c)=>tk(e,i,s);const a=e._zod.bag;e.format=a.format??null,e.minLength=a.minimum??null,e.maxLength=a.maximum??null,e.regex=(...i)=>e.check(UM(...i)),e.includes=(...i)=>e.check($M(...i)),e.startsWith=(...i)=>e.check(VM(...i)),e.endsWith=(...i)=>e.check(YM(...i)),e.min=(...i)=>e.check(Kc(...i)),e.max=(...i)=>e.check(B1(...i)),e.length=(...i)=>e.check($1(...i)),e.nonempty=(...i)=>e.check(Kc(1,...i)),e.lowercase=i=>e.check(ZM(i)),e.uppercase=i=>e.check(BM(i)),e.trim=()=>e.check(GM()),e.normalize=(...i)=>e.check(qM(...i)),e.toLowerCase=()=>e.check(IM()),e.toUpperCase=()=>e.check(XM()),e.slugify=()=>e.check(PM())}),$k=fe("ZodString",(e,o)=>{dm.init(e,o),I1.init(e,o),e.email=a=>e.check(uM(Vk,a)),e.url=a=>e.check(pM(Yk,a)),e.jwt=a=>e.check(MM(aO,a)),e.emoji=a=>e.check(gM(qk,a)),e.guid=a=>e.check(Rv(Lv,a)),e.uuid=a=>e.check(fM(bc,a)),e.uuidv4=a=>e.check(dM(bc,a)),e.uuidv6=a=>e.check(hM(bc,a)),e.uuidv7=a=>e.check(mM(bc,a)),e.nanoid=a=>e.check(yM(Gk,a)),e.guid=a=>e.check(Rv(Lv,a)),e.cuid=a=>e.check(vM(Ik,a)),e.cuid2=a=>e.check(bM(Xk,a)),e.ulid=a=>e.check(xM(Pk,a)),e.base64=a=>e.check(zM(tO,a)),e.base64url=a=>e.check(TM(nO,a)),e.xid=a=>e.check(SM(Qk,a)),e.ksuid=a=>e.check(wM(Kk,a)),e.ipv4=a=>e.check(_M(Jk,a)),e.ipv6=a=>e.check(EM(Fk,a)),e.cidrv4=a=>e.check(CM(Wk,a)),e.cidrv6=a=>e.check(NM(eO,a)),e.e164=a=>e.check(AM(oO,a)),e.datetime=a=>e.check(Sk(a)),e.date=a=>e.check(_k(a)),e.time=a=>e.check(Ck(a)),e.duration=a=>e.check(zk(a))});function Ht(e){return cM($k,e)}const ot=fe("ZodStringFormat",(e,o)=>{nt.init(e,o),I1.init(e,o)}),Vk=fe("ZodEmail",(e,o)=>{vA.init(e,o),ot.init(e,o)}),Lv=fe("ZodGUID",(e,o)=>{gA.init(e,o),ot.init(e,o)}),bc=fe("ZodUUID",(e,o)=>{yA.init(e,o),ot.init(e,o)}),Yk=fe("ZodURL",(e,o)=>{bA.init(e,o),ot.init(e,o)}),qk=fe("ZodEmoji",(e,o)=>{xA.init(e,o),ot.init(e,o)}),Gk=fe("ZodNanoID",(e,o)=>{SA.init(e,o),ot.init(e,o)}),Ik=fe("ZodCUID",(e,o)=>{wA.init(e,o),ot.init(e,o)}),Xk=fe("ZodCUID2",(e,o)=>{_A.init(e,o),ot.init(e,o)}),Pk=fe("ZodULID",(e,o)=>{EA.init(e,o),ot.init(e,o)}),Qk=fe("ZodXID",(e,o)=>{CA.init(e,o),ot.init(e,o)}),Kk=fe("ZodKSUID",(e,o)=>{NA.init(e,o),ot.init(e,o)}),Jk=fe("ZodIPv4",(e,o)=>{kA.init(e,o),ot.init(e,o)}),Fk=fe("ZodIPv6",(e,o)=>{OA.init(e,o),ot.init(e,o)}),Wk=fe("ZodCIDRv4",(e,o)=>{DA.init(e,o),ot.init(e,o)}),eO=fe("ZodCIDRv6",(e,o)=>{jA.init(e,o),ot.init(e,o)}),tO=fe("ZodBase64",(e,o)=>{RA.init(e,o),ot.init(e,o)}),nO=fe("ZodBase64URL",(e,o)=>{HA.init(e,o),ot.init(e,o)}),oO=fe("ZodE164",(e,o)=>{UA.init(e,o),ot.init(e,o)}),aO=fe("ZodJWT",(e,o)=>{BA.init(e,o),ot.init(e,o)}),rO=fe("ZodBoolean",(e,o)=>{$A.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>nk(e,a,i)});function hm(e){return RM(rO,e)}const iO=fe("ZodUnknown",(e,o)=>{VA.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>ak()});function Hv(){return LM(iO)}const lO=fe("ZodNever",(e,o)=>{YA.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>ok(e,a,i)});function sO(e){return HM(lO,e)}const cO=fe("ZodArray",(e,o)=>{qA.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>sk(e,a,i,s),e.element=o.element,e.min=(a,i)=>e.check(Kc(a,i)),e.nonempty=a=>e.check(Kc(1,a)),e.max=(a,i)=>e.check(B1(a,i)),e.length=(a,i)=>e.check($1(a,i)),e.unwrap=()=>e.element});function ho(e,o){return QM(cO,e,o)}const uO=fe("ZodObject",(e,o)=>{IA.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>ck(e,a,i,s),Ie(e,"shape",()=>o.shape),e.keyof=()=>mm(Object.keys(e._zod.def.shape)),e.catchall=a=>e.clone({...e._zod.def,catchall:a}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Hv()}),e.loose=()=>e.clone({...e._zod.def,catchall:Hv()}),e.strict=()=>e.clone({...e._zod.def,catchall:sO()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=a=>gT(e,a),e.safeExtend=a=>yT(e,a),e.merge=a=>vT(e,a),e.pick=a=>mT(e,a),e.omit=a=>pT(e,a),e.partial=(...a)=>bT(X1,e,a[0]),e.required=(...a)=>xT(P1,e,a[0])});function ta(e,o){const a={type:"object",shape:e??{},...Ce(o)};return new uO(a)}const fO=fe("ZodUnion",(e,o)=>{XA.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>uk(e,a,i,s),e.options=o.options});function dO(e,o){return new fO({type:"union",options:e,...Ce(o)})}const hO=fe("ZodIntersection",(e,o)=>{PA.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>fk(e,a,i,s)});function mO(e,o){return new hO({type:"intersection",left:e,right:o})}const pO=fe("ZodRecord",(e,o)=>{QA.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>dk(e,a,i,s),e.keyType=o.keyType,e.valueType=o.valueType});function ai(e,o,a){return new pO({type:"record",keyType:e,valueType:o,...Ce(a)})}const Dh=fe("ZodEnum",(e,o)=>{KA.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(i,s,c)=>rk(e,i,s),e.enum=o.entries,e.options=Object.values(o.entries);const a=new Set(Object.keys(o.entries));e.extract=(i,s)=>{const c={};for(const u of i)if(a.has(u))c[u]=o.entries[u];else throw new Error(`Key ${u} not found in enum`);return new Dh({...o,checks:[],...Ce(s),entries:c})},e.exclude=(i,s)=>{const c={...o.entries};for(const u of i)if(a.has(u))delete c[u];else throw new Error(`Key ${u} not found in enum`);return new Dh({...o,checks:[],...Ce(s),entries:c})}});function mm(e,o){const a=Array.isArray(e)?Object.fromEntries(e.map(i=>[i,i])):e;return new Dh({type:"enum",entries:a,...Ce(o)})}const gO=fe("ZodTransform",(e,o)=>{JA.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>lk(e,a),e._zod.parse=(a,i)=>{if(i.direction==="backward")throw new C1(e.constructor.name);a.addIssue=c=>{if(typeof c=="string")a.issues.push(Cl(c,a.value,o));else{const u=c;u.fatal&&(u.continue=!1),u.code??(u.code="custom"),u.input??(u.input=a.value),u.inst??(u.inst=e),a.issues.push(Cl(u))}};const s=o.transform(a.value,a);return s instanceof Promise?s.then(c=>(a.value=c,a)):(a.value=s,a)}});function yO(e){return new gO({type:"transform",transform:e})}const X1=fe("ZodOptional",(e,o)=>{Z1.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>G1(e,a,i,s),e.unwrap=()=>e._zod.def.innerType});function Uv(e){return new X1({type:"optional",innerType:e})}const vO=fe("ZodExactOptional",(e,o)=>{FA.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>G1(e,a,i,s),e.unwrap=()=>e._zod.def.innerType});function bO(e){return new vO({type:"optional",innerType:e})}const xO=fe("ZodNullable",(e,o)=>{WA.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>hk(e,a,i,s),e.unwrap=()=>e._zod.def.innerType});function Zv(e){return new xO({type:"nullable",innerType:e})}const SO=fe("ZodDefault",(e,o)=>{eM.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>pk(e,a,i,s),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function wO(e,o){return new SO({type:"default",innerType:e,get defaultValue(){return typeof o=="function"?o():A1(o)}})}const _O=fe("ZodPrefault",(e,o)=>{tM.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>gk(e,a,i,s),e.unwrap=()=>e._zod.def.innerType});function EO(e,o){return new _O({type:"prefault",innerType:e,get defaultValue(){return typeof o=="function"?o():A1(o)}})}const P1=fe("ZodNonOptional",(e,o)=>{nM.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>mk(e,a,i,s),e.unwrap=()=>e._zod.def.innerType});function CO(e,o){return new P1({type:"nonoptional",innerType:e,...Ce(o)})}const NO=fe("ZodCatch",(e,o)=>{oM.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>yk(e,a,i,s),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function zO(e,o){return new NO({type:"catch",innerType:e,catchValue:typeof o=="function"?o:()=>o})}const TO=fe("ZodPipe",(e,o)=>{aM.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>vk(e,a,i,s),e.in=o.in,e.out=o.out});function Bv(e,o){return new TO({type:"pipe",in:e,out:o})}const AO=fe("ZodReadonly",(e,o)=>{rM.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>bk(e,a,i,s),e.unwrap=()=>e._zod.def.innerType});function MO(e){return new AO({type:"readonly",innerType:e})}const kO=fe("ZodCustom",(e,o)=>{iM.init(e,o),ft.init(e,o),e._zod.processJSONSchema=(a,i,s)=>ik(e,a)});function OO(e,o={}){return KM(kO,e,o)}function DO(e){return JM(e)}const $v={id:"claude-code",display:{name:"Claude Code",icon:"claude",color:"#D97706"},cli:{command:"claude",mcp:{add:["mcp","add-json"],remove:["mcp","remove"]}},paths:{mcp:"~/.claude.json",projectMcp:".claude/mcp.json",skills:"~/.claude/skills",projectSkills:".claude/skills/",globalMemory:"~/.claude/CLAUDE.md",projectMemory:"CLAUDE.md",agents:"~/.claude/agents/",projectAgents:".claude/agents/",rules:null,hooks:"~/.claude/settings.json",commands:null,backupDirs:["~/.claude","~/"]},mcp:{format:"json",key:"mcpServers",entryShape:"standard"},scopes:["shared","coding"],capabilities:["mcp","skills","memory","agents","hooks"],enabled:!0,memoryMaxLines:200},Vv={id:"codex",display:{name:"Codex CLI",icon:"openai",color:"#10A37F"},cli:{command:"codex",mcp:{add:["mcp","add"],remove:["mcp","remove"]}},paths:{mcp:"~/.codex/config.toml",projectMcp:null,skills:"~/.codex/skills",projectSkills:null,globalMemory:"~/.codex/AGENTS.md",projectMemory:"AGENTS.md",agents:null,projectAgents:null,rules:".codex/rules/",hooks:"~/.codex/config.toml",commands:null,backupDirs:["~/.codex"]},mcp:{format:"toml",key:"mcp.servers",entryShape:"standard"},scopes:["shared","coding"],capabilities:["mcp","skills","memory","rules","hooks"],enabled:!0,memoryMaxLines:null},Yv={id:"gemini-cli",display:{name:"Gemini CLI",icon:"gemini",color:"#4285F4"},cli:{command:"gemini",mcp:{add:["mcp","add"],remove:["mcp","remove"],enable:["mcp","enable"],disable:["mcp","disable"]}},paths:{mcp:"~/.gemini/settings.json",projectMcp:null,skills:"~/.gemini/extensions",projectSkills:null,globalMemory:"~/.gemini/GEMINI.md",projectMemory:"GEMINI.md",agents:null,projectAgents:null,rules:null,hooks:"~/.gemini/settings.json",commands:null,backupDirs:["~/.gemini"]},mcp:{format:"json",key:"mcpServers",entryShape:"standard"},scopes:["shared","coding"],capabilities:["mcp","skills","memory","hooks"],enabled:!0,memoryMaxLines:null},qv={id:"opencode",display:{name:"OpenCode",icon:"opencode",color:"#6366F1"},cli:null,paths:{mcp:"~/.config/opencode/opencode.json",projectMcp:null,skills:"~/.config/opencode/plugin",projectSkills:null,globalMemory:"~/.opencode/context.md",projectMemory:null,agents:"~/.config/opencode/agents/",projectAgents:".opencode/agents/",rules:null,hooks:"~/.config/opencode/settings.json",commands:"~/.config/opencode/commands/",backupDirs:["~/.config/opencode"]},mcp:{format:"json",key:"mcp",entryShape:"opencode"},scopes:["shared","coding"],capabilities:["mcp","skills","memory","agents","hooks","commands"],enabled:!0,memoryMaxLines:null},Gv={id:"openclaw",display:{name:"OpenClaw",icon:"openclaw",color:"#EC4899"},cli:null,paths:{mcp:"~/.openclaw/openclaw.json",projectMcp:null,skills:"~/.openclaw/workspace/skills",projectSkills:null,globalMemory:"~/.openclaw/workspace/MEMORY.md",projectMemory:null,agents:"~/.openclaw/workspace/agents",projectAgents:null,rules:null,hooks:"~/.openclaw/hooks/",commands:null,backupDirs:["~/.openclaw"]},mcp:{format:"json",key:"plugins.entries",entryShape:"openclaw"},scopes:["shared","personal"],capabilities:["mcp","skills","memory","hooks","agents"],enabled:!0,memoryMaxLines:null},Iv={id:"aider",display:{name:"Aider",icon:"aider",color:"#22C55E"},cli:null,paths:{mcp:"~/.aider/mcp-servers.json",projectMcp:null,skills:"~/.aider/plugins",projectSkills:null,globalMemory:"~/.aider/MEMORY.md",projectMemory:null,agents:null,projectAgents:null,rules:"CONVENTIONS.md",hooks:null,commands:null,backupDirs:["~/.aider"]},mcp:{format:"json",key:"mcpServers",entryShape:"standard"},scopes:["shared","coding"],capabilities:["mcp","skills","memory","rules"],enabled:!0,memoryMaxLines:null},Xv={id:"cursor",display:{name:"Cursor",icon:"cursor",color:"#00D4AA"},cli:{command:"cursor"},paths:{mcp:"~/.cursor/mcp.json",projectMcp:".cursor/mcp.json",skills:null,projectSkills:null,globalMemory:null,projectMemory:".cursorrules",agents:null,projectAgents:".cursor/agents/",rules:".cursor/rules/",hooks:".cursor/hooks.json",commands:".cursor/commands/",backupDirs:["~/.cursor"]},mcp:{format:"json",key:"mcpServers",entryShape:"standard"},scopes:["shared","coding"],capabilities:["mcp","memory","rules","agents","hooks","commands"],enabled:!0,memoryMaxLines:null},Pv={id:"vscode",display:{name:"VS Code",icon:"vscode",color:"#007ACC"},cli:{command:"code"},paths:{mcp:{darwin:"~/Library/Application Support/Code/User/mcp.json",linux:"~/.config/Code/User/mcp.json",win32:"%APPDATA%/Code/User/mcp.json"},projectMcp:".vscode/mcp.json",skills:null,projectSkills:".github/skills/",globalMemory:null,projectMemory:".github/copilot-instructions.md",agents:null,projectAgents:".github/agents/",rules:".github/instructions/",hooks:null,commands:null,backupDirs:[]},mcp:{format:"jsonc",key:"servers",entryShape:"vscode"},scopes:["shared","coding"],capabilities:["mcp","skills","memory","agents","rules"],enabled:!0,memoryMaxLines:null},Qv={id:"antigravity",display:{name:"Antigravity",icon:"antigravity",color:"#FF6B35"},cli:{command:"agy"},paths:{mcp:"~/.gemini/antigravity/mcp_config.json",projectMcp:null,skills:"~/.gemini/antigravity/skills/",projectSkills:".agent/skills/",globalMemory:"~/.gemini/antigravity/rules.md",projectMemory:".antigravity/rules.md",agents:null,projectAgents:".agent/",rules:null,hooks:null,commands:null,backupDirs:["~/.gemini/antigravity"]},mcp:{format:"json",key:"mcpServers",entryShape:"standard"},scopes:["shared","coding"],capabilities:["mcp","skills","memory","agents"],enabled:!0,memoryMaxLines:null},pm={[$v.id]:$v,[Vv.id]:Vv,[Yv.id]:Yv,[qv.id]:qv,[Gv.id]:Gv,[Iv.id]:Iv,[Xv.id]:Xv,[Pv.id]:Pv,[Qv.id]:Qv},jO=Object.keys(pm),RO=jO,Va=mm(RO),Q1=ta({command:Ht(),args:ho(Ht()).optional(),env:ai(Ht(),Ht()).optional(),enabled:hm().optional().default(!0),tools:ho(Va).optional(),excludeTools:ho(Va).optional()});ta({mcps:ai(Ht(),Q1)});const LO=ta({name:Ht(),description:Ht().optional(),version:Ht().optional(),author:Ht().optional(),tools:ho(Va).optional(),excludeTools:ho(Va).optional(),enabled:hm().optional().default(!0)}),HO=mm(["shared","coding","personal"]),UO=ta({syncTo:ho(Va),excludeFrom:ho(Va).optional(),path:Ht(),files:ho(Ht())}),K1=ta({scopes:ai(HO,UO)});ta({version:Ht(),tools:ai(Va,ta({enabled:hm()})),memory:K1});ta({hostname:Ht(),mcps:ai(Ht(),Q1.partial()).optional(),skills:ai(Ht(),LO.partial()).optional(),memory:K1.partial().optional()});function ZO({svg:e,size:o=16}){const a=e.replace(/<svg\b/,`<svg width="${o}" height="${o}"`);return x.jsx("span",{dangerouslySetInnerHTML:{__html:a},style:{display:"inline-flex",lineHeight:0}})}const BO={claude:tT,openai:nT,gemini:oT,opencode:aT,openclaw:rT,aider:iT,cursor:lT,vscode:sT,antigravity:cT},$O=Object.fromEntries(Object.values(pm).map(e=>[e.display.name,x.jsx(ZO,{svg:BO[e.display.icon]??""})]));function gm({status:e}){const o={synced:"bg-green-500 shadow-green-500/50",pending:"bg-yellow-500 shadow-yellow-500/50",error:"bg-red-500 shadow-red-500/50",disabled:"bg-gray-500",not_installed:"bg-gray-700 border border-gray-500"};return x.jsx("span",{"data-testid":`node-status-${e}`,className:Le("inline-block w-2.5 h-2.5 rounded-full shadow-sm",o[e])})}function VO({data:e,sourcePosition:o,targetPosition:a}){const i=e.installed!==!1;return x.jsxs("div",{className:Le("px-4 py-3 rounded-lg border-2 bg-card shadow-lg min-w-[130px] transition-colors",i?"border-primary/60 hover:border-primary":"border-gray-600 opacity-50"),children:[x.jsx(pn,{type:"target",position:a??he.Top,className:"!bg-primary !w-3 !h-3"}),x.jsxs("div",{className:"flex items-center gap-2",children:[$O[e.name]??null,x.jsx(gm,{status:i?e.status:"not_installed"}),x.jsx("span",{className:Le("font-medium text-sm",!i&&"text-gray-500"),children:e.name})]}),!i&&x.jsx("div",{className:"text-[10px] text-gray-500 mt-1",children:"Not installed"}),x.jsx(pn,{type:"source",position:o??he.Bottom,className:"!bg-primary !w-3 !h-3"})]})}const YO=N.memo(VO);function qO({data:e,sourcePosition:o,targetPosition:a}){const i=e.enabled!==!1,s={skill:{border:"border-blue-500/60",bg:"bg-[#0c1529]"},mcp:{border:"border-purple-500/60",bg:"bg-[#150c29]"},memory:{border:"border-amber-500/60",bg:"bg-[#1a1408]"}},c=s[e.type]||s.skill;return x.jsxs("div",{className:Le("px-3 py-2 rounded-md border shadow-md min-w-[110px] transition-colors hover:border-white/40",c.border,c.bg,!i&&"opacity-50"),children:[x.jsx(pn,{type:"target",position:a??he.Top,className:"!bg-muted !w-2 !h-2"}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx(gm,{status:i?e.status:"disabled"}),x.jsx("span",{className:"text-sm font-medium truncate max-w-[100px]",children:e.name}),x.jsx("button",{role:"switch","aria-checked":i,"aria-label":`Toggle ${e.name}`,onClick:u=>{u.stopPropagation(),e.onToggle?.(e.type,e.name,!i)},className:Le("ml-auto relative inline-flex h-4 w-7 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors",i?"bg-primary":"bg-muted"),children:x.jsx("span",{className:Le("pointer-events-none inline-block h-3 w-3 rounded-full bg-white shadow-sm transition-transform",i?"translate-x-3":"translate-x-0")})})]}),x.jsx("div",{className:"text-[10px] text-muted-foreground mt-0.5 uppercase tracking-wider",children:e.type}),x.jsx(pn,{type:"source",position:o??he.Bottom,className:"!bg-muted !w-2 !h-2"})]})}const GO=N.memo(qO);const J1=(...e)=>e.filter((o,a,i)=>!!o&&o.trim()!==""&&i.indexOf(o)===a).join(" ").trim();const IO=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const XO=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(o,a,i)=>i?i.toUpperCase():a.toLowerCase());const Kv=e=>{const o=XO(e);return o.charAt(0).toUpperCase()+o.slice(1)};var PO={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const QO=e=>{for(const o in e)if(o.startsWith("aria-")||o==="role"||o==="title")return!0;return!1};const KO=N.forwardRef(({color:e="currentColor",size:o=24,strokeWidth:a=2,absoluteStrokeWidth:i,className:s="",children:c,iconNode:u,...d},p)=>N.createElement("svg",{ref:p,...PO,width:o,height:o,stroke:e,strokeWidth:i?Number(a)*24/Number(o):a,className:J1("lucide",s),...!c&&!QO(d)&&{"aria-hidden":"true"},...d},[...u.map(([m,y])=>N.createElement(m,y)),...Array.isArray(c)?c:[c]]));const Ll=(e,o)=>{const a=N.forwardRef(({className:i,...s},c)=>N.createElement(KO,{ref:c,iconNode:o,className:J1(`lucide-${IO(Kv(e))}`,`lucide-${e}`,i),...s}));return a.displayName=Kv(e),a};const JO=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],F1=Ll("bot",JO);const FO=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],W1=Ll("library",FO);const WO=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],eS=Ll("sparkles",WO);const e6=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],tS=Ll("terminal",e6);const t6=[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]],nS=Ll("webhook",t6);function n6({data:e,sourcePosition:o,targetPosition:a}){const i=e.enabled!==!1;return x.jsxs("div",{className:Le("px-3 py-2 rounded-md border shadow-md min-w-[110px] transition-colors hover:border-white/40 cursor-pointer","border-teal-500/60","bg-[#081a1a]",!i&&"opacity-50"),onClick:()=>e.onClick?.(e.name),children:[x.jsx(pn,{type:"target",position:a??he.Top,className:"!bg-muted !w-2 !h-2"}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx(gm,{status:i?"synced":"disabled"}),x.jsx("span",{className:"text-sm font-medium truncate max-w-[120px]",children:e.name}),x.jsx("button",{role:"switch","aria-checked":i,"aria-label":`Toggle ${e.name}`,onClick:s=>{s.stopPropagation(),e.onToggle?.(e.name,!i)},className:Le("ml-auto relative inline-flex h-4 w-7 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors",i?"bg-primary":"bg-muted"),children:x.jsx("span",{className:Le("pointer-events-none inline-block h-3 w-3 rounded-full bg-white shadow-sm transition-transform",i?"translate-x-3":"translate-x-0")})})]}),x.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 text-[10px] text-muted-foreground",children:[e.skillCount>0&&x.jsxs("span",{className:"flex items-center gap-0.5",title:"Skills",children:[x.jsx(eS,{size:10,className:"text-purple-400"}),e.skillCount]}),e.agentCount>0&&x.jsxs("span",{className:"flex items-center gap-0.5",title:"Agents",children:[x.jsx(F1,{size:10,className:"text-emerald-400"}),e.agentCount]}),e.commandCount>0&&x.jsxs("span",{className:"flex items-center gap-0.5",title:"Commands",children:[x.jsx(tS,{size:10,className:"text-blue-400"}),e.commandCount]}),e.hookCount>0&&x.jsxs("span",{className:"flex items-center gap-0.5",title:"Hooks",children:[x.jsx(nS,{size:10,className:"text-amber-400"}),e.hookCount]}),e.libCount>0&&x.jsxs("span",{className:"flex items-center gap-0.5",title:"Libraries",children:[x.jsx(W1,{size:10,className:"text-pink-400"}),e.libCount]})]}),x.jsx(pn,{type:"source",position:o??he.Bottom,className:"!bg-muted !w-2 !h-2"})]})}const o6=N.memo(n6);function a6({data:e,sourcePosition:o,targetPosition:a}){return x.jsxs("div",{className:"px-4 py-3 rounded-lg border-2 border-dashed border-muted-foreground/40 bg-card/50 shadow-md min-w-[130px] cursor-pointer hover:border-primary/60 hover:bg-card transition-colors",onClick:()=>e.onClick?.(),children:[x.jsx(pn,{type:"target",position:a??he.Top,className:"!bg-muted !w-3 !h-3"}),x.jsxs("div",{className:"flex items-center gap-2 justify-center",children:[x.jsx("span",{className:"text-lg text-muted-foreground",children:"+"}),x.jsx("span",{className:"font-medium text-sm text-muted-foreground",children:"Add Tool"})]}),x.jsx(pn,{type:"source",position:o??he.Bottom,className:"!bg-muted !w-3 !h-3"})]})}const r6=N.memo(a6),Ya={tool:{width:160,height:60},addTool:{width:160,height:60},resource:{width:170,height:58},plugin:{width:180,height:68}},na={width:160,height:55},jn={skill:"#3b82f6",mcp:"#a855f7",memory:"#f59e0b",plugin:"#14b8a6",custom:"#6b7280",disabled:"#ef4444"},il={synced:"#22c55e",pending:"#eab308",error:"#ef4444",not_installed:"#374151",fallback:"#6b7280"},ml={strokeWidth:1.5,disabledDashArray:"5,5",disabledOpacity:.4},Ma={strokeDasharray:"6,4",opacity:.55,fontSize:13,labelBgOpacity:.9,labelBgRadius:8,labelPadding:[5,5]},mn={horizontalSpacing:180,addToolSpacing:160,layers:{top:0,middle:200,bottom:400}},Jv={color:"#333",gap:20},Fv="smoothstep",jh="DOWN",Hr={layout:"mycelium:graph:layout",edgeType:"mycelium:graph:edgeType",radialMode:"mycelium:graph:radialMode"},Rh="sectors";function xc(e,o){const a=new Map;for(const g of e)g.installed&&a.set(g.toolId,{id:g.toolId,name:g.toolName,installed:!0});const i=Array.from(a.values()).map(g=>({id:g.id,name:g.name,status:o.tools[g.id]!==!1?"synced":"disabled",installed:!0})),s=new Map,c=[];for(const g of e)for(const v of g.skills)if(v.marketplace&&v.pluginName){const S=`${v.marketplace}/${v.pluginName}`,w=s.get(S);w?w.skills.includes(v.name)||w.skills.push(v.name):s.set(S,{marketplace:v.marketplace,skills:[v.name],enabled:o.skills[v.name]!==!1})}else c.push({name:v.name,status:"pending",enabled:o.skills[v.name]!==!1,connectedTools:[g.toolId]});const u=Array.from(s.entries()).map(([g,v])=>({name:g.split("/")[1]||g,marketplace:v.marketplace,componentCount:v.skills.length,enabled:v.skills.some(w=>o.skills[w]!==!1),skills:v.skills})),d=new Set,p=[];for(const g of e)for(const v of g.mcps)d.has(v.name)||(d.add(v.name),p.push({name:v.name,status:"pending",enabled:o.mcps[v.name]!==!1,connectedTools:[g.toolId]}));const m=new Set,y=[];for(const g of e)for(const v of g.memory)m.has(v.name)||(m.add(v.name),y.push({name:v.name,scope:"shared",status:"pending"}));return{tools:i,skills:c,mcps:p,memory:y,plugins:u}}const i6=Object.values(pm).map(e=>({id:e.id,name:e.display.name,status:"synced",installed:!0}));function Sc(e,o){return{stroke:e,strokeWidth:ml.strokeWidth,...o?{}:{strokeDasharray:ml.disabledDashArray,opacity:ml.disabledOpacity}}}function l6(e,o,a,i){const s=[],c=[],u=e?.tools||i6,d=a?u:u.filter(m=>m.installed!==!1);d.forEach((m,y)=>{s.push({id:`tool-${m.id}`,type:"tool",position:{x:y*mn.horizontalSpacing,y:mn.layers.middle},data:{name:m.name,status:m.status,installed:m.installed,__elkLayer:"NONE"}})});const p=new Set;return e?.plugins?.forEach(m=>{m.skills.forEach(y=>p.add(y))}),e?.plugins?.forEach((m,y)=>{const g=`plugin-${m.name}`;s.push({id:g,type:"plugin",position:{x:y*mn.horizontalSpacing,y:mn.layers.top},data:{__elkLayer:"FIRST",name:m.name,marketplace:m.marketplace,componentCount:m.componentCount,skillCount:m.skills?.length??0,agentCount:m.agents?.length??0,commandCount:m.commands?.length??0,hookCount:m.hooks?.length??0,libCount:m.libs?.length??0,enabled:m.enabled,onToggle:(v,S)=>i.onPluginToggle?.(v,S),onClick:v=>i.onPluginClick?.(v)}}),d.filter(v=>v.installed).forEach(v=>{c.push({id:`${g}-to-tool-${v.id}`,source:g,target:`tool-${v.id}`,animated:m.enabled,style:Sc(jn.plugin,m.enabled)})})}),e?.skills.forEach((m,y)=>{if(p.has(m.name))return;const g=`skill-${m.name}`;s.push({id:g,type:"resource",position:{x:y*mn.horizontalSpacing,y:mn.layers.top},data:{name:m.name,type:"skill",status:m.status,enabled:m.enabled,onToggle:i.handleToggle,__elkLayer:"FIRST"}});const v=m.enabled!==!1;(m.connectedTools||d.filter(w=>w.installed).map(w=>w.id)).forEach(w=>{d.some(_=>_.id===w)&&c.push({id:`${g}-to-${w}`,source:g,target:`tool-${w}`,animated:v&&m.status==="synced",style:Sc(jn.skill,v)})})}),e?.mcps.forEach((m,y)=>{const g=`mcp-${m.name}`;s.push({id:g,type:"resource",position:{x:y*mn.horizontalSpacing,y:mn.layers.bottom},data:{name:m.name,type:"mcp",status:m.status,enabled:m.enabled,onToggle:i.handleToggle}});const v=m.enabled!==!1;(m.connectedTools||d.filter(w=>w.installed).map(w=>w.id)).forEach(w=>{d.some(_=>_.id===w)&&c.push({id:`tool-${w}-to-${g}`,source:`tool-${w}`,target:g,animated:v&&m.status==="synced",style:Sc(jn.mcp,v)})})}),e?.memory.forEach((m,y)=>{const g=`memory-${m.name}`;s.push({id:g,type:"resource",position:{x:y*mn.horizontalSpacing,y:mn.layers.bottom},data:{name:m.name,type:"memory",status:m.status,onToggle:i.handleToggle,__elkLayer:"LAST"}});let v;m.scope==="personal"?v=["openclaw"]:m.scope==="coding"?v=d.filter(S=>S.id!=="openclaw"&&S.installed).map(S=>S.id):v=d.filter(S=>S.installed).map(S=>S.id),v.forEach(S=>{d.some(w=>w.id===S)&&c.push({id:`tool-${S}-to-${g}`,source:`tool-${S}`,target:g,animated:m.status==="synced",style:Sc(jn.memory,!0)})})}),o==="migrate"&&s.push({id:"add-tool",type:"addTool",position:{x:d.length*mn.addToolSpacing,y:mn.layers.top},data:{onClick:i.onAddTool}}),{initialNodes:s,initialEdges:c}}function Lh(e){return e.type==="tool"||e.type==="addTool"?"tool":e.type==="plugin"?"plugin":e.data?.type==="skill"?"skill":e.data?.type==="mcp"?"mcp":e.data?.type==="memory"?"memory":"other"}const s6=["plugin","skill","tool","mcp","memory"];function yu(e){const o=new Map;for(const a of s6)o.set(a,[]);for(const a of e){const i=Lh(a);o.has(i)||o.set(i,[]),o.get(i).push(a)}return o}function c6(e,o,a){const i=a==="RIGHT",s=yu(e),c=30,u=120,d=[],p=[[...s.get("plugin")??[],...s.get("skill")??[]],s.get("tool")??[],s.get("mcp")??[],s.get("memory")??[]].filter(w=>w.length>0),m=w=>{const _=w.measured;return _?.width&&_?.height?{width:_.width,height:_.height}:Ya[w.type||""]||na},y=p.map(w=>w.reduce((_,T)=>{const z=m(T);return _+(i?z.height:z.width)},0)),g=p.map((w,_)=>y[_]+(w.length-1)*c),v=Math.max(...g);let S=0;for(let w=0;w<p.length;w++){const _=p[w],T=g[w],z=(v-T)/2;let H=0,E=z;for(const M of _){const R=m(M),D=i?R.width:R.height,O=i?R.height:R.width;H=Math.max(H,D),d.push({...M,zIndex:10,position:i?{x:S,y:E}:{x:E,y:S},sourcePosition:i?he.Right:he.Bottom,targetPosition:i?he.Left:he.Top}),E+=O+c}S+=H+u}return{nodes:d,edges:o}}function oS(e){const o=new Map;return e.forEach((a,i)=>{o.set(a.id,i/e.length*2*Math.PI-Math.PI/2)}),o}function aS(e,o){const a=new Map;for(const i of e){if(o.has(i.source)){const s=a.get(i.target)??[];s.push(i.source),a.set(i.target,s)}if(o.has(i.target)){const s=a.get(i.source)??[];s.push(i.target),a.set(i.source,s)}}return a}function Fc(e,o,a){const i=o.get(e.id)??[];if(i.length===0)return Math.PI;const s=i.map(d=>a.get(d)??0),c=s.reduce((d,p)=>d+Math.sin(p),0),u=s.reduce((d,p)=>d+Math.cos(p),0);return Math.atan2(c/s.length,u/s.length)}function Wc(e,o,a,i,s){const c=Ya[e.type||""]?.width??na.width,u=Ya[e.type||""]?.height??na.height;return{...e,zIndex:10,position:{x:o+i*Math.cos(s)-c/2,y:a+i*Math.sin(s)-u/2},sourcePosition:he.Bottom,targetPosition:he.Top}}function u6(e,o,a=40,i=30,s=50){const c=s/100,u=[];let d=o;for(const p of e){if(p.length===0){u.push(d);continue}const m=Math.max(...p.map(w=>Ya[w.type||""]?.width??na.width)),y=Math.max(...p.map(w=>Ya[w.type||""]?.height??na.height)),g=p.length*(m+i)/(2*Math.PI)*c,v=d+Math.max(m,y)*c+a,S=Math.max(g,v);u.push(S),d=S}return u}function f6(e,o,a=60,i=150,s=50){const c=yu(e),u=c.get("tool")??[],d=u.length<=1?0:i,p=oS(u),m=aS(o,p),y=[[...c.get("plugin")??[],...c.get("skill")??[]],c.get("mcp")??[],c.get("memory")??[]],g=u6(y,d,a,a/2,s),v=Math.max(d,...g),S=v+200,w=v+200,_=[];for(const T of u)_.push(Wc(T,S,w,d,p.get(T.id)));for(let T=0;T<y.length;T++){if(y[T].length===0)continue;const z=[...y[T]].sort((H,E)=>Fc(H,m,p)-Fc(E,m,p));z.forEach((H,E)=>{_.push(Wc(H,S,w,g[T],E/z.length*2*Math.PI-Math.PI/2))})}return{nodes:_,edges:o}}function d6(e,o,a=60,i=150,s=50){const c=yu(e),u=c.get("tool")??[],d=oS(u),p=aS(o,d),m=u.length<=1?0:i,y=[{cat:["plugin"],centerAngle:-Math.PI*3/4,label:"Plugins (top-left)"},{cat:["memory"],centerAngle:-Math.PI/4,label:"Memory (top-right)"},{cat:["skill"],centerAngle:Math.PI*3/4,label:"Skills (bottom-left)"},{cat:["mcp"],centerAngle:Math.PI/4,label:"MCPs (bottom-right)"}],g=Math.PI/2,v=g*.42,S=[];for(const I of y){const W=[];for(const L of I.cat)W.push(...c.get(L)??[]);S.push(W)}const w=6,_=40,T=na.width,z=Math.max(...S.map(I=>I.length),1),H=Math.min(w,z),E=s/100,M=H*(T+_)/g*E,R=Math.max(m+a,M),D=a+40,O=Math.max(...S.map(I=>Math.ceil(I.length/w)),1),Z=R+O*D+100,$=Z+200,oe=Z+200,q=[];for(const I of u)q.push(Wc(I,$,oe,m,d.get(I.id)));for(let I=0;I<y.length;I++){const W=y[I],L=S[I];if(L.length===0)continue;const Y=[...L].sort((U,j)=>Fc(U,p,d)-Fc(j,p,d)),A=Math.ceil(Y.length/w);for(let U=0;U<A;U++){const j=Y.slice(U*w,(U+1)*w),Q=R+U*D;j.forEach((re,k)=>{const V=j.length<=1?0:(k/(j.length-1)-.5)*2*v;q.push(Wc(re,$,oe,Q,W.centerAngle+V))})}}return{nodes:q,edges:o}}function h6(e,o,a=60,i=150,s=50){const d=(yu(e).get("tool")??[]).length<=1?0:i,p=a*(1+s/50),m={tool:d,plugin:d+p,skill:d+p,mcp:d+p*2,memory:d+p*3},y=d+p*3+200,g=y+200,v=y+200,S=[...e],w=new Map,_=[],T=new Map,z=new Map;for(const R of S){const D=Lh(R),O=m[D]??d+300,Z=T.get(O)??0;T.set(O,Z+1)}for(const[R]of T)z.set(R,0);for(const R of S){const D=Lh(R),O=m[D]??d+300,Z=T.get(O)??1,$=z.get(O)??0;z.set(O,$+1);const oe=$/Z*2*Math.PI-Math.PI/2;w.set(R.id,_.length),_.push({node:R,x:g+O*Math.cos(oe),y:v+O*Math.sin(oe),vx:0,vy:0,targetR:O,fixed:D==="tool"})}const H=80,E=.3;for(let R=0;R<H;R++){const D=1-R/H;for(const O of o){const Z=w.get(O.source),$=w.get(O.target);if(Z===void 0||$===void 0)continue;const oe=_[Z],q=_[$],I=q.x-oe.x,W=q.y-oe.y,L=Math.sqrt(I*I+W*W)||1,Y=Math.abs(oe.targetR-q.targetR)*.8+100,A=(L-Y)/L*.02*D;oe.fixed||(oe.vx+=I*A,oe.vy+=W*A),q.fixed||(q.vx-=I*A,q.vy-=W*A)}for(let O=0;O<_.length;O++)if(!_[O].fixed)for(let Z=O+1;Z<_.length;Z++){const $=_[Z].x-_[O].x,oe=_[Z].y-_[O].y,q=Math.sqrt($*$+oe*oe)||1,I=200;if(q<I){const W=(I-q)/q*.25*D;_[O].fixed||(_[O].vx-=$*W,_[O].vy-=oe*W),_[Z].fixed||(_[Z].vx+=$*W,_[Z].vy+=oe*W)}}for(const O of _){if(O.fixed)continue;O.x+=O.vx*E,O.y+=O.vy*E,O.vx*=.7,O.vy*=.7;const Z=O.x-g,$=O.y-v,oe=Math.sqrt(Z*Z+$*$)||1,q=Math.atan2($,Z),I=oe+(O.targetR-oe)*.3;O.x=g+I*Math.cos(q),O.y=v+I*Math.sin(q)}}return{nodes:_.map(R=>{const D=Ya[R.node.type||""]?.width??na.width,O=Ya[R.node.type||""]?.height??na.height;return{...R.node,zIndex:10,position:{x:R.x-D/2,y:R.y-O/2},sourcePosition:he.Bottom,targetPosition:he.Top}}),edges:o}}function m6(e,o,a="hybrid",i=60,s=150,c=50){switch(a){case"sectors":return d6(e,o,i,s,c);case"force":return h6(e,o,i,s,c);default:return f6(e,o,i,s,c)}}async function wc(e,o,a=jh,i=Rh,s=60,c=150,u=50){return a==="RADIAL"?m6(e,o,i,s,c,u):c6(e,o,a)}const p6={tool:YO,resource:GO,plugin:o6,addTool:r6};function rS({data:e,mode:o="dashboard",onNodeClick:a,onToggle:i,onPluginToggle:s,onPluginClick:c,onMcpClick:u,onSkillClick:d,onAddTool:p,onEdgeToggle:m,disabledEdges:y,showUninstalledTools:g=!1}){const[v,S,w]=_4([]),[_,T,z]=E4([]),H=N.useRef(null),[E,M]=N.useState(()=>{try{return localStorage.getItem(Hr.layout)||jh}catch{return jh}}),[R,D]=N.useState(()=>{try{return localStorage.getItem(Hr.edgeType)||Fv}catch{return Fv}}),[O,Z]=N.useState(()=>{try{return localStorage.getItem(Hr.radialMode)||Rh}catch{return Rh}}),[$,oe]=N.useState(60),[q,I]=N.useState(150),[W,L]=N.useState(50),Y=N.useMemo(()=>{try{return new URLSearchParams(window.location.search).has("debug")}catch{return!1}},[]),A=N.useCallback(me=>{M(me);try{localStorage.setItem(Hr.layout,me)}catch{}},[]),U=N.useCallback(me=>{D(me);try{localStorage.setItem(Hr.edgeType,me)}catch{}},[]),j=N.useCallback(me=>{Z(me);try{localStorage.setItem(Hr.radialMode,me)}catch{}},[]),[Q,re]=N.useState(new Set),k=y??Q,V=N.useRef(i);V.current=i;const F=N.useRef(s);F.current=s;const ee=N.useRef(c);ee.current=c;const P=N.useRef(p);P.current=p;const se=N.useCallback((me,ze,it)=>{V.current?.({type:me,name:ze,enabled:it})},[]),ne=N.useMemo(()=>({handleToggle:se,onToggle:me=>V.current?.(me),onPluginToggle:(me,ze)=>F.current?.(me,ze),onPluginClick:me=>ee.current?.(me),onAddTool:()=>P.current?.()}),[se]),{initialNodes:le,initialEdges:de}=N.useMemo(()=>l6(e,o,g,ne),[e,o,g,ne]),Ee=N.useMemo(()=>_.map(me=>k.has(me.id)?{...me,animated:!1,interactionWidth:30,style:{stroke:jn.disabled,strokeWidth:ml.strokeWidth,strokeDasharray:Ma.strokeDasharray,opacity:Ma.opacity},label:"✕",labelStyle:{fill:jn.disabled,fontSize:Ma.fontSize,fontWeight:700,cursor:"pointer"},labelBgStyle:{fill:"#1a1a1a",fillOpacity:Ma.labelBgOpacity,rx:Ma.labelBgRadius,ry:Ma.labelBgRadius},labelBgPadding:Ma.labelPadding}:{...me,type:R,interactionWidth:30}),[_,k,R]),we=N.useRef(!1),ve=N.useRef(!1);N.useEffect(()=>{le.length>0&&(ve.current=!1,wc(le,de,E,O,$,q,W).then(({nodes:me,edges:ze})=>{S(me),T(ze),we.current||(we.current=!0,setTimeout(()=>H.current?.(),50))}))},[le,de,E,O,$,q,W,S,T]);const _e=N4();N.useEffect(()=>{_e&&v.length>0&&!ve.current&&(ve.current=!0,wc(v,_,E,O,$,q,W).then(({nodes:me,edges:ze})=>{S(me),T(ze)}))},[_e]);const Me=N.useCallback(me=>{A(me),wc(v,_,me,O,$,q,W).then(({nodes:ze,edges:it})=>{S(ze),T(it),setTimeout(()=>H.current?.(),50)})},[v,_,O,$,q,W,S,T,A]),Ye=N.useCallback(me=>{j(me),wc(v,_,"RADIAL",me,$,q,W).then(({nodes:ze,edges:it})=>{S(ze),T(it),setTimeout(()=>H.current?.(),50)})},[v,_,$,q,W,S,T,j]),$e=N.useCallback(()=>{},[]),dt=N.useCallback(me=>{T(ze=>Mx({...me,animated:!0,style:{stroke:jn.custom,strokeWidth:ml.strokeWidth}},ze))},[T]),Qt=N.useCallback((me,ze)=>{const it=k.has(ze.id);m?m(ze.id,it):re(Bn=>{const lt=new Set(Bn);return it?lt.delete(ze.id):lt.add(ze.id),lt})},[k,m]),Ot=N.useCallback((me,ze)=>{if(a?.(ze),ze.type==="plugin")ee.current?.(ze.data.name);else if(ze.type==="resource"){const it=ze.data;it.type==="mcp"?u?.(it.name):it.type==="skill"&&d?.(it.name)}},[a,u,d]);return x.jsx("div",{"data-testid":"react-flow-graph",className:"w-full h-full",children:x.jsxs(w4,{nodes:v,edges:Ee,onNodesChange:w,onEdgesChange:z,nodeTypes:p6,onNodeClick:Ot,onNodeDragStop:$e,onEdgeClick:Qt,onConnect:dt,onInit:me=>{H.current=()=>me.fitView({padding:.2,duration:300})},fitView:!0,minZoom:.3,maxZoom:2,defaultViewport:{x:0,y:0,zoom:.8},children:[x.jsxs(Rl,{position:"top-right",className:"flex gap-2",children:[x.jsx("button",{onClick:()=>Me("DOWN"),className:Le("px-3 py-1.5 rounded text-xs font-medium transition-colors",E==="DOWN"?"bg-primary text-primary-foreground":"bg-secondary text-secondary-foreground hover:bg-secondary/80"),children:"Vertical"}),x.jsx("button",{onClick:()=>Me("RIGHT"),className:Le("px-3 py-1.5 rounded text-xs font-medium transition-colors",E==="RIGHT"?"bg-primary text-primary-foreground":"bg-secondary text-secondary-foreground hover:bg-secondary/80"),children:"Horizontal"}),x.jsx("button",{onClick:()=>Me("RADIAL"),className:Le("px-3 py-1.5 rounded text-xs font-medium transition-colors",E==="RADIAL"?"bg-primary text-primary-foreground":"bg-secondary text-secondary-foreground hover:bg-secondary/80"),children:"Radial"}),E==="RADIAL"&&Y&&x.jsxs(x.Fragment,{children:[x.jsx("span",{className:"mx-1 text-muted-foreground/40",children:"|"}),["hybrid","sectors","force"].map(me=>x.jsx("button",{onClick:()=>Ye(me),className:Le("px-2 py-1.5 rounded text-[10px] font-medium transition-colors capitalize",O===me?"bg-emerald-600 text-white":"bg-secondary text-secondary-foreground hover:bg-secondary/80"),children:me},me)),x.jsx("span",{className:"mx-1 text-muted-foreground/40",children:"|"}),x.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",title:"Density: 0=tight, 100=spacious",children:["Density",x.jsx("input",{type:"range",min:0,max:100,step:5,value:W,onChange:me=>L(Number(me.target.value)),className:"w-20 h-1 accent-orange-500"}),x.jsx("span",{className:"w-6 text-right font-mono",children:W})]}),x.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",title:"Center ring size",children:["Center",x.jsx("input",{type:"range",min:0,max:500,step:5,value:q,onChange:me=>I(Number(me.target.value)),className:"w-20 h-1 accent-cyan-500"}),x.jsx("span",{className:"w-6 text-right font-mono",children:q})]}),x.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",title:"Gap between rings",children:["Gap",x.jsx("input",{type:"range",min:0,max:500,step:5,value:$,onChange:me=>oe(Number(me.target.value)),className:"w-20 h-1 accent-emerald-500"}),x.jsx("span",{className:"w-6 text-right font-mono",children:$})]})]}),x.jsx("span",{className:"mx-1 text-muted-foreground/40",children:"|"}),["smoothstep","default","straight","step"].map(me=>x.jsx("button",{onClick:()=>U(me),className:Le("px-2 py-1.5 rounded text-[10px] font-medium transition-colors capitalize",R===me?"bg-purple-600 text-white":"bg-secondary text-secondary-foreground hover:bg-secondary/80"),children:me==="default"?"bezier":me},me))]}),x.jsx(k4,{color:Jv.color,gap:Jv.gap}),x.jsx(U4,{className:"!bg-card !border-border [&>button]:!bg-card [&>button]:!border-border"}),x.jsx(J4,{className:"!bg-card/80 !border-border",maskColor:"rgba(0,0,0,0.8)",nodeColor:me=>{const ze=me.data;return ze?.status==="synced"?il.synced:ze?.status==="pending"?il.pending:ze?.status==="error"?il.error:ze?.status==="not_installed"?il.not_installed:ze?.type==="skill"?jn.skill:ze?.type==="mcp"?jn.mcp:ze?.type==="memory"?jn.memory:il.fallback}})]})})}let iS=!1;try{iS=globalThis.localStorage?.getItem("mycelium:debug:panel")==="1"}catch{}const ih=(...e)=>{iS&&console.log("[panel]",...e)},g6={skill:{label:"Skills",color:"text-purple-400",icon:x.jsx(eS,{size:14,className:"text-purple-400"})},agent:{label:"Agents",color:"text-emerald-400",icon:x.jsx(F1,{size:14,className:"text-emerald-400"})},command:{label:"Commands",color:"text-blue-400",icon:x.jsx(tS,{size:14,className:"text-blue-400"})},hook:{label:"Hooks",color:"text-amber-400",icon:x.jsx(nS,{size:14,className:"text-amber-400"})},lib:{label:"Libraries",color:"text-pink-400",icon:x.jsx(W1,{size:14,className:"text-pink-400"})}};function y6(e){if(!e)return{};const o=new Set(e.disabledItems??[]),a={},i=[...e.skills,...e.agents,...e.commands,...e.hooks??[],...e.libs??[]];for(const s of i)a[s]=!o.has(s);return a}function lS({plugin:e,onClose:o,onTogglePlugin:a,onToggleItem:i,onRemoveItem:s}){const c=N.useMemo(()=>y6(e),[e]),[u,d]=N.useState(null),p=u??c,[m,y]=N.useState(!1),[g,v]=N.useState("closed"),S=N.useRef(null),w=N.useRef(null);N.useEffect(()=>{ih("useEffect",{animState:g,plugin:e?.name??null}),e?(S.current=e,w.current!==e.name&&(d(null),w.current=e.name),v(D=>D==="closed"?"opening":D)):(g==="open"||g==="opening")&&v("closing")},[e]);const _=N.useCallback(D=>{D.target===D.currentTarget&&(ih("animEnd",{animState:g,anim:D.animationName}),g==="opening"?v("open"):g==="closing"&&(v("closed"),S.current=null))},[g]),T=N.useCallback(()=>{ih("handleClose",{animState:g}),v("closing"),o()},[o,g]);if(g==="closed")return null;const z=S.current;if(!z)return null;const H=g==="opening"||g==="open",E=D=>{const O={};for(const Z of Object.keys(p))O[Z]=D;d(O),a(z.name,D)},M=[{type:"skill",items:z.skills},{type:"agent",items:z.agents},{type:"command",items:z.commands},{type:"hook",items:z.hooks??[]},{type:"lib",items:z.libs??[]}].filter(D=>D.items.length>0),R=M.reduce((D,O)=>D+O.items.length,0);return x.jsxs(x.Fragment,{children:[x.jsx("div",{className:Le("fixed inset-0 z-40 bg-black/50",H?"animate-fade-in":"animate-fade-out"),onClick:T}),x.jsxs("div",{role:"dialog","aria-label":z.name,className:Le("fixed right-0 top-0 z-50 h-full w-96 overflow-y-auto border-l bg-card text-card-foreground shadow-xl",H?"animate-slide-in-right":"animate-slide-out-right"),onAnimationEnd:_,children:[x.jsxs("div",{className:"flex items-start justify-between border-b p-4",children:[x.jsxs("div",{children:[x.jsx("h2",{className:"text-lg font-bold",children:z.name}),x.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[z.version&&x.jsxs("span",{className:"text-sm text-muted-foreground",children:["v",z.version]}),x.jsx("span",{className:"rounded-full bg-teal-500/10 px-2 py-0.5 text-xs text-teal-400 border border-teal-500/30",children:z.marketplace})]}),z.author&&x.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["by ",z.author]}),x.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:[R," components"]})]}),x.jsx("button",{onClick:T,className:"rounded-md p-1 text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":"Close",children:x.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[x.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),x.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),x.jsx("div",{className:"border-b p-4",children:x.jsx("p",{className:"text-sm text-muted-foreground",children:z.description})}),x.jsxs("div",{className:"flex gap-2 border-b p-4",children:[x.jsx("button",{onClick:()=>E(!0),className:Le("flex-1 rounded-md px-3 py-1.5 text-sm font-medium transition-colors",Object.values(p).some(D=>!D)?"bg-primary text-primary-foreground":"border bg-background text-foreground hover:bg-muted"),children:"Enable All"}),x.jsx("button",{onClick:()=>E(!1),className:Le("flex-1 rounded-md px-3 py-1.5 text-sm font-medium transition-colors",Object.values(p).some(Boolean)?"bg-destructive text-destructive-foreground":"border bg-background text-foreground hover:bg-muted"),children:"Disable All"})]}),M.map(({type:D,items:O})=>{const Z=g6[D]??{label:D,color:"text-muted-foreground",icon:"?"};return x.jsxs("div",{className:"border-b p-4",children:[x.jsxs("h3",{className:"mb-2 flex items-center gap-2 text-sm font-medium",children:[Z.icon,x.jsx("span",{className:Le("font-bold",Z.color),children:Z.label}),x.jsx("span",{className:"rounded-full bg-muted px-1.5 py-0 text-[10px] text-muted-foreground",children:O.length})]}),x.jsx("div",{className:"space-y-2",children:O.map($=>x.jsxs("div",{className:"flex items-center justify-between rounded-md border px-3 py-2",children:[x.jsx("span",{className:"text-sm",children:$}),x.jsx("button",{onClick:()=>{const oe=!p[$];d(q=>({...q??c,[$]:oe})),i?.(z.name,$,oe)},className:Le("relative inline-flex h-5 w-9 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors",p[$]?"bg-primary":"bg-muted"),role:"switch","aria-checked":p[$],"aria-label":`Toggle ${$}`,children:x.jsx("span",{className:Le("pointer-events-none inline-block h-4 w-4 rounded-full bg-white shadow-sm transition-transform",p[$]?"translate-x-4":"translate-x-0")})})]},$))})]},D)}),s&&x.jsxs("div",{className:"p-4",children:[x.jsx("h3",{className:"mb-2 text-sm font-medium text-destructive",children:"Danger Zone"}),x.jsxs("button",{onClick:()=>y(!0),className:"w-full rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm font-medium text-destructive hover:bg-destructive/20",children:["Remove ",z.marketplace==="system"?"MCP":z.marketplace==="standalone"?"Skill":"Plugin"]}),x.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["This removes it from ~/.mycelium. Run ",x.jsx("code",{className:"bg-muted px-1 rounded",children:"mycelium sync"})," to propagate to all tools."]})]})]}),m&&x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"fixed inset-0 z-[60] bg-black/60",onClick:()=>y(!1)}),x.jsxs("div",{className:"fixed left-1/2 top-1/2 z-[70] w-80 -translate-x-1/2 -translate-y-1/2 rounded-lg border bg-card p-6 shadow-2xl",children:[x.jsxs("h3",{className:"text-lg font-bold text-destructive",children:["Remove ",z.name,"?"]}),x.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["This will remove all components (",R," total) from ~/.mycelium. Run ",x.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"mycelium sync"})," after to propagate."]}),x.jsxs("div",{className:"mt-4 flex gap-2",children:[x.jsx("button",{onClick:()=>{const D=z.marketplace==="system"?"mcp":z.marketplace==="standalone"?"skill":"plugin";s?.(D,z.name),y(!1),o()},className:"flex-1 rounded-md bg-destructive px-3 py-2 text-sm font-medium text-destructive-foreground hover:bg-destructive/90",children:"Yes, remove"}),x.jsx("button",{onClick:()=>y(!1),className:"flex-1 rounded-md border px-3 py-2 text-sm font-medium hover:bg-muted",children:"Cancel"})]})]})]})]})}async function ll(){return(await fetch("/api/state")).json()}async function v6(e){await fetch("/api/toggle",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function b6(){return(await fetch("/api/migrate/scan")).json()}async function x6(e){return(await fetch("/api/migrate/apply",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json()}async function S6(e,o){const a=new URLSearchParams({q:e});return o&&a.set("source",o),(await fetch(`/api/marketplace/search?${a}`)).json()}async function w6(e,o){return(await fetch("/api/marketplace/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,source:o})})).json()}async function _6(){return(await fetch("/api/marketplace/registry")).json()}async function E6(e,o){await fetch("/api/marketplace/registry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,...o})})}async function C6(e){await fetch(`/api/marketplace/registry/${encodeURIComponent(e)}`,{method:"DELETE"})}async function N6(e){return(await fetch("/api/plugins")).json()}async function z6(e,o){return(await fetch("/api/plugins/toggle",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,enabled:o})})).json()}async function T6(e,o,a,i){return(await fetch(`/api/plugins/${encodeURIComponent(e)}/items/${encodeURIComponent(o)}/toggle`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:a,...i})})).json()}async function Wv(){return(await fetch("/api/marketplace/popular")).json()}async function A6(e){return(await fetch(`/api/remove/skill/${encodeURIComponent(e)}`,{method:"DELETE"})).json()}async function M6(e){return(await fetch(`/api/remove/mcp/${encodeURIComponent(e)}`,{method:"DELETE"})).json()}async function k6(e){return(await fetch(`/api/remove/plugin/${encodeURIComponent(e)}`,{method:"DELETE"})).json()}async function O6(e,o){return(await fetch("/api/marketplace/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,source:o})})).json()}function D6({onClose:e}){const[o,a]=N.useState("scan"),[i,s]=N.useState(!1),[c,u]=N.useState([]),[d,p]=N.useState(null),[m,y]=N.useState(0),[g,v]=N.useState({skills:{},mcps:{},memory:{},tools:{}}),[S,w]=N.useState(null);async function _(){s(!0),p(null);try{const $=await b6();u($);const oe={},q={},I={},W={};for(const L of $){L.installed&&(W[L.toolId]=!0);for(const Y of L.skills)oe[Y.name]=!0;for(const Y of L.mcps)q[Y.name]=!0;for(const Y of L.memory)I[Y.name]=!0}v({skills:oe,mcps:q,memory:I,tools:W}),a("review")}catch($){p($.message??"Scan failed")}finally{s(!1)}}async function T(){p(null),a("apply");try{const $=xc(c,g),oe=Object.entries(g.skills).filter(([,Y])=>Y).map(([Y])=>Y),q=Object.entries(g.mcps).filter(([,Y])=>Y).map(([Y])=>Y),I=Object.entries(g.memory).filter(([,Y])=>Y).map(([Y])=>Y),W={skills:$.plugins.flatMap(Y=>Y.skills.filter(A=>oe.includes(A)).map(A=>({name:A,source:"scan"}))),mcps:$.mcps.filter(Y=>q.includes(Y.name)).map(Y=>({name:Y.name,source:"scan",config:{command:"",args:[]}})),memory:$.memory.filter(Y=>I.includes(Y.name)).map(Y=>({name:Y.name,source:"scan",content:""})),conflicts:[]},L=await x6(W);y(L.skillsImported+L.mcpsImported+L.memoryImported),a("done")}catch($){p($.message??"Migration failed"),a("review")}}const z=N.useCallback($=>{v(oe=>{const q=$.type==="skill"?"skills":$.type==="mcp"?"mcps":$.type==="memory"?"memory":null;return q?{...oe,[q]:{...oe[q],[$.name]:$.enabled}}:oe})},[]),H=N.useCallback($=>{const q=xc(c,g).plugins.find(I=>I.name===$);q&&w({name:q.name,marketplace:q.marketplace,version:"scanned",description:`${q.componentCount} components from ${q.marketplace}`,enabled:q.enabled,skills:q.skills,agents:[],commands:[],hooks:[],libs:[]})},[c,g]),E=N.useCallback(($,oe)=>{const I=xc(c,g).plugins.find(W=>W.name===$);I&&v(W=>{const L={...W.skills};for(const Y of I.skills)L[Y]=oe;return{...W,skills:L}}),w(W=>W?{...W,enabled:oe}:null)},[c,g]),M=N.useCallback(()=>{console.log("Add tool destination")},[]),R=c.length>0?xc(c,g):void 0,D=Object.values(g.skills).filter(Boolean).length+Object.values(g.mcps).filter(Boolean).length+Object.values(g.memory).filter(Boolean).length,O={scan:"Scan",review:"Review",apply:"Apply",done:"Done"},Z=["scan","review","apply","done"];return x.jsxs("div",{className:"space-y-6",children:[x.jsx("div",{className:"flex items-center justify-center gap-2",children:Z.map(($,oe)=>x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("div",{className:Le("flex h-8 w-8 items-center justify-center rounded-full text-sm font-medium",$===o?"bg-primary text-primary-foreground":Z.indexOf(o)>oe?"bg-primary/20 text-primary":"bg-muted text-muted-foreground"),children:oe+1}),x.jsx("span",{className:"text-sm",children:O[$]}),oe<Z.length-1&&x.jsx("div",{className:"h-px w-8 bg-border"})]},$))}),d&&x.jsx("div",{className:"rounded-lg border border-red-500/50 bg-red-500/10 p-3 text-sm text-red-500",children:d}),o==="scan"&&x.jsxs("div",{className:"rounded-lg border bg-card p-6 text-card-foreground shadow-sm",children:[x.jsx("h2",{className:"text-lg font-semibold",children:"Scan for Tools"}),x.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Detect installed AI tools and their configurations to migrate into Mycelium."}),x.jsx("button",{onClick:_,disabled:i,className:"mt-4 rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:i?"Scanning...":"Start Scan"})]}),o==="review"&&R&&x.jsxs("div",{className:"space-y-4",children:[x.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-card p-4 text-card-foreground shadow-sm",children:[x.jsxs("div",{className:"flex gap-6 text-sm",children:[x.jsxs("span",{children:[x.jsx("strong",{children:R.plugins.length})," plugins"]}),x.jsxs("span",{children:[x.jsx("strong",{children:Object.values(g.skills).filter(Boolean).length})," skills"]}),x.jsxs("span",{children:[x.jsx("strong",{children:Object.values(g.mcps).filter(Boolean).length})," MCPs"]}),x.jsxs("span",{children:[x.jsx("strong",{children:Object.values(g.memory).filter(Boolean).length})," memory"]}),x.jsxs("span",{className:"text-muted-foreground",children:["→ ",x.jsx("strong",{children:R.tools.length})," destinations"]})]}),x.jsxs("div",{className:"flex gap-2",children:[x.jsx("button",{onClick:()=>a("scan"),className:"rounded-md border px-4 py-2 text-sm hover:bg-muted",children:"Rescan"}),x.jsxs("button",{onClick:T,disabled:D===0,className:"rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:["Apply (",D," items)"]})]})]}),x.jsx("div",{className:"h-[500px] rounded-lg border bg-card/50",children:x.jsx(rm,{children:x.jsx(rS,{mode:"migrate",data:R,showUninstalledTools:!1,onToggle:z,onPluginClick:H,onAddTool:M})})}),x.jsx("p",{className:"text-center text-sm text-muted-foreground",children:"Click plugin nodes to select individual skills. Toggle nodes to include/exclude from migration."})]}),o==="apply"&&x.jsxs("div",{className:"rounded-lg border bg-card p-6 text-card-foreground shadow-sm",children:[x.jsx("h2",{className:"text-lg font-semibold",children:"Applying Migration"}),x.jsxs("div",{className:"mt-4 flex items-center gap-3",children:[x.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-primary border-t-transparent"}),x.jsx("span",{className:"text-sm text-muted-foreground",children:"Migrating configurations..."})]})]}),o==="done"&&x.jsxs("div",{className:"rounded-lg border bg-card p-6 text-card-foreground shadow-sm",children:[x.jsx("h2",{className:"text-lg font-semibold",children:"Migration Complete"}),x.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["Successfully migrated ",m," items into Mycelium."]}),x.jsxs("div",{className:"mt-4 flex gap-2",children:[x.jsx("button",{onClick:()=>{a("scan"),u([])},className:"rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90",children:"Scan Again"}),e&&x.jsx("button",{onClick:e,className:"rounded-md border px-4 py-2 text-sm hover:bg-muted",children:"Close"})]})]}),x.jsx(lS,{plugin:S,onClose:()=>w(null),onTogglePlugin:E})]})}const j6={skill:{label:"Skill",color:"text-purple-400",bgColor:"bg-purple-500/10",borderColor:"border-purple-500/30",fileExt:".md"},mcp:{label:"MCP",color:"text-blue-400",bgColor:"bg-blue-500/10",borderColor:"border-blue-500/30",fileExt:".yaml"},plugin:{label:"Plugin",color:"text-amber-400",bgColor:"bg-amber-500/10",borderColor:"border-amber-500/30",fileExt:".json"},agent:{label:"Agent",color:"text-emerald-400",bgColor:"bg-emerald-500/10",borderColor:"border-emerald-500/30",fileExt:".md"},template:{label:"Template",color:"text-pink-400",bgColor:"bg-pink-500/10",borderColor:"border-pink-500/30",fileExt:".yaml"}},R6={label:"Item",color:"text-gray-400",bgColor:"bg-gray-500/10",borderColor:"border-gray-500/30",fileExt:".md"},L6={skill:"⚙",mcp:"⚡",plugin:"⬢",agent:"▶",template:"▦"};function H6(e){return j6[e]||R6}function eb(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function U6({item:e,installing:o,updating:a,expanded:i,onInstall:s,onUpdate:c,onToggleExpand:u}){const d=`${e.source}-${e.name}`,p=o===d,m=a===d,y=e.installed&&e.latestVersion&&e.installedVersion&&e.latestVersion!==e.installedVersion,g=H6(e.type),v=L6[e.type]||"●";return x.jsxs("div",{className:Le("group rounded-xl border bg-card text-sm shadow-sm transition-all cursor-pointer","hover:shadow-md hover:border-primary/40",g.borderColor,i&&"ring-2 ring-primary/30 shadow-md",e.installed&&"border-green-500/40"),onClick:()=>u(d),children:[x.jsx("div",{className:"px-4 pt-4 pb-2",children:x.jsxs("div",{className:"flex items-start justify-between gap-2",children:[x.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[x.jsx("div",{className:Le("flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-base",g.bgColor,g.color),children:v}),x.jsxs("div",{className:"min-w-0",children:[x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("span",{className:"font-semibold text-foreground truncate",children:e.name}),e.installed&&x.jsx("span",{className:"shrink-0 rounded-full bg-green-500/15 px-1.5 py-0.5 text-[10px] font-medium text-green-400",children:"Installed"}),y&&x.jsx("span",{className:"shrink-0 rounded-full bg-yellow-500/15 px-1.5 py-0.5 text-[10px] font-medium text-yellow-400",children:"Update"})]}),e.author&&x.jsx("span",{className:"text-xs text-muted-foreground",children:e.author})]})]}),x.jsx("span",{className:Le("shrink-0 rounded-md px-2 py-0.5 text-[10px] font-bold uppercase tracking-wider",g.bgColor,g.color),children:g.label})]})}),x.jsx("div",{className:"px-4 pb-3",children:x.jsx("p",{className:Le("text-xs text-muted-foreground leading-relaxed",!i&&"line-clamp-2"),children:e.description})}),x.jsxs("div",{className:"flex items-center gap-3 px-4 pb-3 text-xs text-muted-foreground",children:[e.stars!=null&&x.jsxs("span",{className:"flex items-center gap-1",children:[x.jsx("span",{className:"text-yellow-400",children:"★"}),eb(e.stars)]}),e.downloads!=null&&x.jsxs("span",{className:"flex items-center gap-1",children:[x.jsx("span",{className:"text-muted-foreground/60",children:"↓"}),eb(e.downloads)]}),e.latestVersion&&x.jsxs("span",{className:"font-mono",children:["v",e.latestVersion]}),x.jsx("span",{className:Le("ml-auto rounded-full px-2 py-0.5 text-[10px]",g.bgColor,g.color),children:e.source})]}),i&&x.jsxs("div",{className:"border-t border-border/50 px-4 py-3 space-y-3",children:[e.category&&x.jsx("div",{className:"flex flex-wrap gap-1.5",children:x.jsx("span",{className:"rounded-full bg-primary/15 px-2 py-0.5 text-[10px] text-primary font-medium",children:e.category})}),(e.installedVersion||e.latestVersion)&&x.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[e.installedVersion&&x.jsxs("span",{children:["Installed: ",x.jsxs("span",{className:"font-mono",children:["v",e.installedVersion]})]}),e.latestVersion&&x.jsxs("span",{children:["Latest: ",x.jsxs("span",{className:"font-mono",children:["v",e.latestVersion]})]})]}),e.updatedAt&&x.jsxs("div",{className:"text-xs text-muted-foreground",children:["Updated: ",e.updatedAt]}),x.jsxs("div",{className:"flex items-center justify-end gap-2 pt-1",children:[y&&x.jsx("button",{onClick:S=>{S.stopPropagation(),c(e)},disabled:m,className:"rounded-md px-3 py-1.5 text-xs font-medium bg-yellow-500/15 text-yellow-400 hover:bg-yellow-500/25 disabled:opacity-50 transition-colors",children:m?"Updating...":"Update"}),x.jsx("button",{onClick:S=>{S.stopPropagation(),s(e)},disabled:e.installed||p,className:Le("rounded-md px-4 py-1.5 text-xs font-medium transition-colors",e.installed?"border border-green-500/30 text-green-400 bg-green-500/10":"bg-primary text-primary-foreground hover:bg-primary/90","disabled:opacity-50"),children:e.installed?"Installed":p?"Installing...":"Install"})]})]}),!i&&x.jsxs("div",{className:"flex items-center justify-end px-4 pb-3",children:[y&&x.jsx("button",{onClick:S=>{S.stopPropagation(),c(e)},disabled:m,className:"mr-2 rounded-md px-2.5 py-1 text-[11px] font-medium text-yellow-400 hover:bg-yellow-500/15 disabled:opacity-50 transition-colors",children:m?"...":"Update"}),x.jsx("button",{onClick:S=>{S.stopPropagation(),s(e)},disabled:e.installed||p,className:Le("rounded-md px-3 py-1 text-[11px] font-medium transition-colors",e.installed?"text-green-400 bg-green-500/10":"bg-primary/80 text-primary-foreground hover:bg-primary","disabled:opacity-50"),children:e.installed?"Installed":p?"...":"Install"})]})]})}function Fo(e,o,{checkForDefaultPrevented:a=!0}={}){return function(s){if(e?.(s),a===!1||!s.defaultPrevented)return o?.(s)}}function tb(e,o){if(typeof e=="function")return e(o);e!=null&&(e.current=o)}function sS(...e){return o=>{let a=!1;const i=e.map(s=>{const c=tb(s,o);return!a&&typeof c=="function"&&(a=!0),c});if(a)return()=>{for(let s=0;s<i.length;s++){const c=i[s];typeof c=="function"?c():tb(e[s],null)}}}}function Ia(...e){return N.useCallback(sS(...e),e)}function Z6(e,o){const a=N.createContext(o),i=c=>{const{children:u,...d}=c,p=N.useMemo(()=>d,Object.values(d));return x.jsx(a.Provider,{value:p,children:u})};i.displayName=e+"Provider";function s(c){const u=N.useContext(a);if(u)return u;if(o!==void 0)return o;throw new Error(`\`${c}\` must be used within \`${e}\``)}return[i,s]}function B6(e,o=[]){let a=[];function i(c,u){const d=N.createContext(u),p=a.length;a=[...a,u];const m=g=>{const{scope:v,children:S,...w}=g,_=v?.[e]?.[p]||d,T=N.useMemo(()=>w,Object.values(w));return x.jsx(_.Provider,{value:T,children:S})};m.displayName=c+"Provider";function y(g,v){const S=v?.[e]?.[p]||d,w=N.useContext(S);if(w)return w;if(u!==void 0)return u;throw new Error(`\`${g}\` must be used within \`${c}\``)}return[m,y]}const s=()=>{const c=a.map(u=>N.createContext(u));return function(d){const p=d?.[e]||c;return N.useMemo(()=>({[`__scope${e}`]:{...d,[e]:p}}),[d,p])}};return s.scopeName=e,[i,$6(s,...o)]}function $6(...e){const o=e[0];if(e.length===1)return o;const a=()=>{const i=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(c){const u=i.reduce((d,{useScope:p,scopeName:m})=>{const g=p(c)[`__scope${m}`];return{...d,...g}},{});return N.useMemo(()=>({[`__scope${o.scopeName}`]:u}),[u])}};return a.scopeName=o.scopeName,a}var Nl=globalThis?.document?N.useLayoutEffect:()=>{},V6=_b[" useId ".trim().toString()]||(()=>{}),Y6=0;function lh(e){const[o,a]=N.useState(V6());return Nl(()=>{a(i=>i??String(Y6++))},[e]),e||(o?`radix-${o}`:"")}var q6=_b[" useInsertionEffect ".trim().toString()]||Nl;function G6({prop:e,defaultProp:o,onChange:a=()=>{},caller:i}){const[s,c,u]=I6({defaultProp:o,onChange:a}),d=e!==void 0,p=d?e:s;{const y=N.useRef(e!==void 0);N.useEffect(()=>{const g=y.current;g!==d&&console.warn(`${i} is changing from ${g?"controlled":"uncontrolled"} to ${d?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),y.current=d},[d,i])}const m=N.useCallback(y=>{if(d){const g=X6(y)?y(e):y;g!==e&&u.current?.(g)}else c(y)},[d,e,c,u]);return[p,m]}function I6({defaultProp:e,onChange:o}){const[a,i]=N.useState(e),s=N.useRef(a),c=N.useRef(o);return q6(()=>{c.current=o},[o]),N.useEffect(()=>{s.current!==a&&(c.current?.(a),s.current=a)},[a,s]),[a,i,c]}function X6(e){return typeof e=="function"}function cS(e){const o=P6(e),a=N.forwardRef((i,s)=>{const{children:c,...u}=i,d=N.Children.toArray(c),p=d.find(K6);if(p){const m=p.props.children,y=d.map(g=>g===p?N.Children.count(m)>1?N.Children.only(null):N.isValidElement(m)?m.props.children:null:g);return x.jsx(o,{...u,ref:s,children:N.isValidElement(m)?N.cloneElement(m,void 0,y):null})}return x.jsx(o,{...u,ref:s,children:c})});return a.displayName=`${e}.Slot`,a}function P6(e){const o=N.forwardRef((a,i)=>{const{children:s,...c}=a;if(N.isValidElement(s)){const u=F6(s),d=J6(c,s.props);return s.type!==N.Fragment&&(d.ref=i?sS(i,u):u),N.cloneElement(s,d)}return N.Children.count(s)>1?N.Children.only(null):null});return o.displayName=`${e}.SlotClone`,o}var Q6=Symbol("radix.slottable");function K6(e){return N.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Q6}function J6(e,o){const a={...o};for(const i in o){const s=e[i],c=o[i];/^on[A-Z]/.test(i)?s&&c?a[i]=(...d)=>{const p=c(...d);return s(...d),p}:s&&(a[i]=s):i==="style"?a[i]={...s,...c}:i==="className"&&(a[i]=[s,c].filter(Boolean).join(" "))}return{...e,...a}}function F6(e){let o=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,a=o&&"isReactWarning"in o&&o.isReactWarning;return a?e.ref:(o=Object.getOwnPropertyDescriptor(e,"ref")?.get,a=o&&"isReactWarning"in o&&o.isReactWarning,a?e.props.ref:e.props.ref||e.ref)}var W6=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],go=W6.reduce((e,o)=>{const a=cS(`Primitive.${o}`),i=N.forwardRef((s,c)=>{const{asChild:u,...d}=s,p=u?a:o;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),x.jsx(p,{...d,ref:c})});return i.displayName=`Primitive.${o}`,{...e,[o]:i}},{});function eD(e,o){e&&qx.flushSync(()=>e.dispatchEvent(o))}function zl(e){const o=N.useRef(e);return N.useEffect(()=>{o.current=e}),N.useMemo(()=>(...a)=>o.current?.(...a),[])}function tD(e,o=globalThis?.document){const a=zl(e);N.useEffect(()=>{const i=s=>{s.key==="Escape"&&a(s)};return o.addEventListener("keydown",i,{capture:!0}),()=>o.removeEventListener("keydown",i,{capture:!0})},[a,o])}var nD="DismissableLayer",Hh="dismissableLayer.update",oD="dismissableLayer.pointerDownOutside",aD="dismissableLayer.focusOutside",nb,uS=N.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),fS=N.forwardRef((e,o)=>{const{disableOutsidePointerEvents:a=!1,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:c,onInteractOutside:u,onDismiss:d,...p}=e,m=N.useContext(uS),[y,g]=N.useState(null),v=y?.ownerDocument??globalThis?.document,[,S]=N.useState({}),w=Ia(o,O=>g(O)),_=Array.from(m.layers),[T]=[...m.layersWithOutsidePointerEventsDisabled].slice(-1),z=_.indexOf(T),H=y?_.indexOf(y):-1,E=m.layersWithOutsidePointerEventsDisabled.size>0,M=H>=z,R=lD(O=>{const Z=O.target,$=[...m.branches].some(oe=>oe.contains(Z));!M||$||(s?.(O),u?.(O),O.defaultPrevented||d?.())},v),D=sD(O=>{const Z=O.target;[...m.branches].some(oe=>oe.contains(Z))||(c?.(O),u?.(O),O.defaultPrevented||d?.())},v);return tD(O=>{H===m.layers.size-1&&(i?.(O),!O.defaultPrevented&&d&&(O.preventDefault(),d()))},v),N.useEffect(()=>{if(y)return a&&(m.layersWithOutsidePointerEventsDisabled.size===0&&(nb=v.body.style.pointerEvents,v.body.style.pointerEvents="none"),m.layersWithOutsidePointerEventsDisabled.add(y)),m.layers.add(y),ob(),()=>{a&&m.layersWithOutsidePointerEventsDisabled.size===1&&(v.body.style.pointerEvents=nb)}},[y,v,a,m]),N.useEffect(()=>()=>{y&&(m.layers.delete(y),m.layersWithOutsidePointerEventsDisabled.delete(y),ob())},[y,m]),N.useEffect(()=>{const O=()=>S({});return document.addEventListener(Hh,O),()=>document.removeEventListener(Hh,O)},[]),x.jsx(go.div,{...p,ref:w,style:{pointerEvents:E?M?"auto":"none":void 0,...e.style},onFocusCapture:Fo(e.onFocusCapture,D.onFocusCapture),onBlurCapture:Fo(e.onBlurCapture,D.onBlurCapture),onPointerDownCapture:Fo(e.onPointerDownCapture,R.onPointerDownCapture)})});fS.displayName=nD;var rD="DismissableLayerBranch",iD=N.forwardRef((e,o)=>{const a=N.useContext(uS),i=N.useRef(null),s=Ia(o,i);return N.useEffect(()=>{const c=i.current;if(c)return a.branches.add(c),()=>{a.branches.delete(c)}},[a.branches]),x.jsx(go.div,{...e,ref:s})});iD.displayName=rD;function lD(e,o=globalThis?.document){const a=zl(e),i=N.useRef(!1),s=N.useRef(()=>{});return N.useEffect(()=>{const c=d=>{if(d.target&&!i.current){let p=function(){dS(oD,a,m,{discrete:!0})};const m={originalEvent:d};d.pointerType==="touch"?(o.removeEventListener("click",s.current),s.current=p,o.addEventListener("click",s.current,{once:!0})):p()}else o.removeEventListener("click",s.current);i.current=!1},u=window.setTimeout(()=>{o.addEventListener("pointerdown",c)},0);return()=>{window.clearTimeout(u),o.removeEventListener("pointerdown",c),o.removeEventListener("click",s.current)}},[o,a]),{onPointerDownCapture:()=>i.current=!0}}function sD(e,o=globalThis?.document){const a=zl(e),i=N.useRef(!1);return N.useEffect(()=>{const s=c=>{c.target&&!i.current&&dS(aD,a,{originalEvent:c},{discrete:!1})};return o.addEventListener("focusin",s),()=>o.removeEventListener("focusin",s)},[o,a]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}function ob(){const e=new CustomEvent(Hh);document.dispatchEvent(e)}function dS(e,o,a,{discrete:i}){const s=a.originalEvent.target,c=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:a});o&&s.addEventListener(e,o,{once:!0}),i?eD(s,c):s.dispatchEvent(c)}var sh="focusScope.autoFocusOnMount",ch="focusScope.autoFocusOnUnmount",ab={bubbles:!1,cancelable:!0},cD="FocusScope",hS=N.forwardRef((e,o)=>{const{loop:a=!1,trapped:i=!1,onMountAutoFocus:s,onUnmountAutoFocus:c,...u}=e,[d,p]=N.useState(null),m=zl(s),y=zl(c),g=N.useRef(null),v=Ia(o,_=>p(_)),S=N.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;N.useEffect(()=>{if(i){let _=function(E){if(S.paused||!d)return;const M=E.target;d.contains(M)?g.current=M:Qo(g.current,{select:!0})},T=function(E){if(S.paused||!d)return;const M=E.relatedTarget;M!==null&&(d.contains(M)||Qo(g.current,{select:!0}))},z=function(E){if(document.activeElement===document.body)for(const R of E)R.removedNodes.length>0&&Qo(d)};document.addEventListener("focusin",_),document.addEventListener("focusout",T);const H=new MutationObserver(z);return d&&H.observe(d,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",_),document.removeEventListener("focusout",T),H.disconnect()}}},[i,d,S.paused]),N.useEffect(()=>{if(d){ib.add(S);const _=document.activeElement;if(!d.contains(_)){const z=new CustomEvent(sh,ab);d.addEventListener(sh,m),d.dispatchEvent(z),z.defaultPrevented||(uD(pD(mS(d)),{select:!0}),document.activeElement===_&&Qo(d))}return()=>{d.removeEventListener(sh,m),setTimeout(()=>{const z=new CustomEvent(ch,ab);d.addEventListener(ch,y),d.dispatchEvent(z),z.defaultPrevented||Qo(_??document.body,{select:!0}),d.removeEventListener(ch,y),ib.remove(S)},0)}}},[d,m,y,S]);const w=N.useCallback(_=>{if(!a&&!i||S.paused)return;const T=_.key==="Tab"&&!_.altKey&&!_.ctrlKey&&!_.metaKey,z=document.activeElement;if(T&&z){const H=_.currentTarget,[E,M]=fD(H);E&&M?!_.shiftKey&&z===M?(_.preventDefault(),a&&Qo(E,{select:!0})):_.shiftKey&&z===E&&(_.preventDefault(),a&&Qo(M,{select:!0})):z===H&&_.preventDefault()}},[a,i,S.paused]);return x.jsx(go.div,{tabIndex:-1,...u,ref:v,onKeyDown:w})});hS.displayName=cD;function uD(e,{select:o=!1}={}){const a=document.activeElement;for(const i of e)if(Qo(i,{select:o}),document.activeElement!==a)return}function fD(e){const o=mS(e),a=rb(o,e),i=rb(o.reverse(),e);return[a,i]}function mS(e){const o=[],a=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:i=>{const s=i.tagName==="INPUT"&&i.type==="hidden";return i.disabled||i.hidden||s?NodeFilter.FILTER_SKIP:i.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;a.nextNode();)o.push(a.currentNode);return o}function rb(e,o){for(const a of e)if(!dD(a,{upTo:o}))return a}function dD(e,{upTo:o}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(o!==void 0&&e===o)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function hD(e){return e instanceof HTMLInputElement&&"select"in e}function Qo(e,{select:o=!1}={}){if(e&&e.focus){const a=document.activeElement;e.focus({preventScroll:!0}),e!==a&&hD(e)&&o&&e.select()}}var ib=mD();function mD(){let e=[];return{add(o){const a=e[0];o!==a&&a?.pause(),e=lb(e,o),e.unshift(o)},remove(o){e=lb(e,o),e[0]?.resume()}}}function lb(e,o){const a=[...e],i=a.indexOf(o);return i!==-1&&a.splice(i,1),a}function pD(e){return e.filter(o=>o.tagName!=="A")}var gD="Portal",pS=N.forwardRef((e,o)=>{const{container:a,...i}=e,[s,c]=N.useState(!1);Nl(()=>c(!0),[]);const u=a||s&&globalThis?.document?.body;return u?Lz.createPortal(x.jsx(go.div,{...i,ref:o}),u):null});pS.displayName=gD;function yD(e,o){return N.useReducer((a,i)=>o[a][i]??a,e)}var vu=e=>{const{present:o,children:a}=e,i=vD(o),s=typeof a=="function"?a({present:i.isPresent}):N.Children.only(a),c=Ia(i.ref,bD(s));return typeof a=="function"||i.isPresent?N.cloneElement(s,{ref:c}):null};vu.displayName="Presence";function vD(e){const[o,a]=N.useState(),i=N.useRef(null),s=N.useRef(e),c=N.useRef("none"),u=e?"mounted":"unmounted",[d,p]=yD(u,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return N.useEffect(()=>{const m=_c(i.current);c.current=d==="mounted"?m:"none"},[d]),Nl(()=>{const m=i.current,y=s.current;if(y!==e){const v=c.current,S=_c(m);e?p("MOUNT"):S==="none"||m?.display==="none"?p("UNMOUNT"):p(y&&v!==S?"ANIMATION_OUT":"UNMOUNT"),s.current=e}},[e,p]),Nl(()=>{if(o){let m;const y=o.ownerDocument.defaultView??window,g=S=>{const _=_c(i.current).includes(CSS.escape(S.animationName));if(S.target===o&&_&&(p("ANIMATION_END"),!s.current)){const T=o.style.animationFillMode;o.style.animationFillMode="forwards",m=y.setTimeout(()=>{o.style.animationFillMode==="forwards"&&(o.style.animationFillMode=T)})}},v=S=>{S.target===o&&(c.current=_c(i.current))};return o.addEventListener("animationstart",v),o.addEventListener("animationcancel",g),o.addEventListener("animationend",g),()=>{y.clearTimeout(m),o.removeEventListener("animationstart",v),o.removeEventListener("animationcancel",g),o.removeEventListener("animationend",g)}}else p("ANIMATION_END")},[o,p]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:N.useCallback(m=>{i.current=m?getComputedStyle(m):null,a(m)},[])}}function _c(e){return e?.animationName||"none"}function bD(e){let o=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,a=o&&"isReactWarning"in o&&o.isReactWarning;return a?e.ref:(o=Object.getOwnPropertyDescriptor(e,"ref")?.get,a=o&&"isReactWarning"in o&&o.isReactWarning,a?e.props.ref:e.props.ref||e.ref)}var uh=0;function xD(){N.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??sb()),document.body.insertAdjacentElement("beforeend",e[1]??sb()),uh++,()=>{uh===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(o=>o.remove()),uh--}},[])}function sb(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Rn=function(){return Rn=Object.assign||function(o){for(var a,i=1,s=arguments.length;i<s;i++){a=arguments[i];for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(o[c]=a[c])}return o},Rn.apply(this,arguments)};function gS(e,o){var a={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&o.indexOf(i)<0&&(a[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(e);s<i.length;s++)o.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(e,i[s])&&(a[i[s]]=e[i[s]]);return a}function SD(e,o,a){if(a||arguments.length===2)for(var i=0,s=o.length,c;i<s;i++)(c||!(i in o))&&(c||(c=Array.prototype.slice.call(o,0,i)),c[i]=o[i]);return e.concat(c||Array.prototype.slice.call(o))}var jc="right-scroll-bar-position",Rc="width-before-scroll-bar",wD="with-scroll-bars-hidden",_D="--removed-body-scroll-bar-size";function fh(e,o){return typeof e=="function"?e(o):e&&(e.current=o),e}function ED(e,o){var a=N.useState(function(){return{value:e,callback:o,facade:{get current(){return a.value},set current(i){var s=a.value;s!==i&&(a.value=i,a.callback(i,s))}}}})[0];return a.callback=o,a.facade}var CD=typeof window<"u"?N.useLayoutEffect:N.useEffect,cb=new WeakMap;function ND(e,o){var a=ED(null,function(i){return e.forEach(function(s){return fh(s,i)})});return CD(function(){var i=cb.get(a);if(i){var s=new Set(i),c=new Set(e),u=a.current;s.forEach(function(d){c.has(d)||fh(d,null)}),c.forEach(function(d){s.has(d)||fh(d,u)})}cb.set(a,e)},[e]),a}function zD(e){return e}function TD(e,o){o===void 0&&(o=zD);var a=[],i=!1,s={read:function(){if(i)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return a.length?a[a.length-1]:e},useMedium:function(c){var u=o(c,i);return a.push(u),function(){a=a.filter(function(d){return d!==u})}},assignSyncMedium:function(c){for(i=!0;a.length;){var u=a;a=[],u.forEach(c)}a={push:function(d){return c(d)},filter:function(){return a}}},assignMedium:function(c){i=!0;var u=[];if(a.length){var d=a;a=[],d.forEach(c),u=a}var p=function(){var y=u;u=[],y.forEach(c)},m=function(){return Promise.resolve().then(p)};m(),a={push:function(y){u.push(y),m()},filter:function(y){return u=u.filter(y),a}}}};return s}function AD(e){e===void 0&&(e={});var o=TD(null);return o.options=Rn({async:!0,ssr:!1},e),o}var yS=function(e){var o=e.sideCar,a=gS(e,["sideCar"]);if(!o)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var i=o.read();if(!i)throw new Error("Sidecar medium not found");return N.createElement(i,Rn({},a))};yS.isSideCarExport=!0;function MD(e,o){return e.useMedium(o),yS}var vS=AD(),dh=function(){},bu=N.forwardRef(function(e,o){var a=N.useRef(null),i=N.useState({onScrollCapture:dh,onWheelCapture:dh,onTouchMoveCapture:dh}),s=i[0],c=i[1],u=e.forwardProps,d=e.children,p=e.className,m=e.removeScrollBar,y=e.enabled,g=e.shards,v=e.sideCar,S=e.noRelative,w=e.noIsolation,_=e.inert,T=e.allowPinchZoom,z=e.as,H=z===void 0?"div":z,E=e.gapMode,M=gS(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),R=v,D=ND([a,o]),O=Rn(Rn({},M),s);return N.createElement(N.Fragment,null,y&&N.createElement(R,{sideCar:vS,removeScrollBar:m,shards:g,noRelative:S,noIsolation:w,inert:_,setCallbacks:c,allowPinchZoom:!!T,lockRef:a,gapMode:E}),u?N.cloneElement(N.Children.only(d),Rn(Rn({},O),{ref:D})):N.createElement(H,Rn({},O,{className:p,ref:D}),d))});bu.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};bu.classNames={fullWidth:Rc,zeroRight:jc};var kD=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function OD(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var o=kD();return o&&e.setAttribute("nonce",o),e}function DD(e,o){e.styleSheet?e.styleSheet.cssText=o:e.appendChild(document.createTextNode(o))}function jD(e){var o=document.head||document.getElementsByTagName("head")[0];o.appendChild(e)}var RD=function(){var e=0,o=null;return{add:function(a){e==0&&(o=OD())&&(DD(o,a),jD(o)),e++},remove:function(){e--,!e&&o&&(o.parentNode&&o.parentNode.removeChild(o),o=null)}}},LD=function(){var e=RD();return function(o,a){N.useEffect(function(){return e.add(o),function(){e.remove()}},[o&&a])}},bS=function(){var e=LD(),o=function(a){var i=a.styles,s=a.dynamic;return e(i,s),null};return o},HD={left:0,top:0,right:0,gap:0},hh=function(e){return parseInt(e||"",10)||0},UD=function(e){var o=window.getComputedStyle(document.body),a=o[e==="padding"?"paddingLeft":"marginLeft"],i=o[e==="padding"?"paddingTop":"marginTop"],s=o[e==="padding"?"paddingRight":"marginRight"];return[hh(a),hh(i),hh(s)]},ZD=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return HD;var o=UD(e),a=document.documentElement.clientWidth,i=window.innerWidth;return{left:o[0],top:o[1],right:o[2],gap:Math.max(0,i-a+o[2]-o[0])}},BD=bS(),Pr="data-scroll-locked",$D=function(e,o,a,i){var s=e.left,c=e.top,u=e.right,d=e.gap;return a===void 0&&(a="margin"),`
|
|
110
110
|
.`.concat(wD,` {
|
|
111
111
|
overflow: hidden `).concat(i,`;
|
|
112
112
|
padding-right: `).concat(d,"px ").concat(i,`;
|
|
@@ -150,4 +150,4 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
150
150
|
|
|
151
151
|
If you want to hide the \`${o.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
152
152
|
|
|
153
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${o.docsSlug}`;return N.useEffect(()=>{e&&(document.getElementById(e)||console.error(a))},[a,e]),null},pj="DialogDescriptionWarning",gj=({contentRef:e,descriptionId:o})=>{const i=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ZS(pj).contentName}}.`;return N.useEffect(()=>{const s=e.current?.getAttribute("aria-describedby");o&&s&&(document.getElementById(o)||console.warn(i))},[i,e,o]),null},mb=NS,pb=AS,gb=MS,yb=kS,vb=DS,bb=RS,xb=HS;const yj=["All","Testing","Git","Debugging","Frontend","Backend","DevOps","AI","Code Review","Documentation"];function vj({onClose:e}){const[o,a]=N.useState(""),[i,s]=N.useState("all"),[c,u]=N.useState("All"),[d,p]=N.useState("popular"),[m,y]=N.useState([]),[g,v]=N.useState(!1),[S,w]=N.useState(!1),[_,T]=N.useState(null),[z,H]=N.useState(null),[E,M]=N.useState(null),[R,D]=N.useState(null),[O,Z]=N.useState([{value:"all",label:"All"}]),[$,oe]=N.useState({}),[q,I]=N.useState(!1),[W,L]=N.useState(""),[Y,A]=N.useState(""),[U,j]=N.useState(null);N.useEffect(()=>{_6().then(P=>{oe(P);const se=Object.keys(P).map(ne=>({value:ne,label:ne}));Z([{value:"all",label:"All"},...se])}).catch(P=>{console.warn("Failed to load marketplace registry:",P)}),v(!0),Wv().then(P=>{const se=P.flatMap(ne=>ne.entries.map(le=>({...le,type:le.type})));y(se)}).catch(P=>{console.warn("Failed to load popular skills:",P)}).finally(()=>v(!1))},[]);const Q=N.useCallback(async P=>{if(P?.preventDefault(),D(null),!o.trim()){v(!0),w(!1),Wv().then(se=>{const ne=se.flatMap(le=>le.entries.map(de=>({...de,type:de.type})));y(ne)}).catch(()=>y([])).finally(()=>v(!1));return}v(!0),w(!0);try{const ne=(await S6(o,i!=="all"?i:void 0)).flatMap(le=>le.entries.map(de=>({...de,type:de.type})));y(ne)}catch{y([])}finally{v(!1)}},[o,i]);async function re(P){const se=`${P.source}-${P.name}`;T(se),D(null);try{const ne=await w6(P.name,P.source);ne.success?y(le=>le.map(de=>de.name===P.name&&de.source===P.source?{...de,installed:!0}:de)):D(`Failed to install ${P.name}: ${ne.error||"Unknown error"}`)}catch(ne){D(`Failed to install ${P.name}: ${ne instanceof Error?ne.message:String(ne)}`)}finally{T(null)}}async function k(P){const se=`${P.source}-${P.name}`;H(se),D(null);try{const ne=await O6(P.name,P.source);ne.success?y(le=>le.map(de=>de.name===P.name&&de.source===P.source?{...de,installedVersion:de.latestVersion}:de)):D(`Failed to update ${P.name}: ${ne.error||"Unknown error"}`)}catch(ne){D(`Failed to update ${P.name}: ${ne instanceof Error?ne.message:String(ne)}`)}finally{H(null)}}async function V(P){await C6(P),oe(se=>{const ne={...se};return delete ne[P],ne}),Z(se=>se.filter(ne=>ne.value!==P)),i===P&&s("all")}async function F(){if(!W.trim()||!Y.trim())return;const P={type:"remote",enabled:!0,url:Y};await E6(W,P),oe(se=>({...se,[W]:P})),Z(se=>[...se,{value:W,label:W}]),L(""),A(""),I(!1)}const ee=N.useMemo(()=>{let P=m;if(c!=="All"){const ne=c.toLowerCase();P=P.filter(le=>le.category?.toLowerCase()===ne||le.name.toLowerCase().includes(ne)||le.description.toLowerCase().includes(ne))}const se=[...P];switch(d){case"popular":se.sort((ne,le)=>(le.downloads??0)-(ne.downloads??0));break;case"stars":se.sort((ne,le)=>(le.stars??0)-(ne.stars??0));break;case"recent":se.sort((ne,le)=>(le.updatedAt??"").localeCompare(ne.updatedAt??""));break;case"az":se.sort((ne,le)=>ne.name.localeCompare(le.name));break}return se},[m,c,d]);return x.jsxs("div",{className:"mx-auto max-w-5xl space-y-6",children:[Object.keys($).length>0&&x.jsxs("div",{className:"rounded-lg border bg-card p-4 text-card-foreground shadow-sm",children:[x.jsx("h3",{className:"mb-3 text-sm font-medium",children:"Configured Marketplaces"}),x.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries($).map(([P,se])=>x.jsxs("button",{onClick:()=>{s(P),o.trim()&&Q()},className:Le("flex items-center gap-2 rounded-full border px-3 py-1.5 text-sm cursor-pointer transition-all hover:border-primary",i===P?"border-primary bg-primary/10 ring-1 ring-primary/30":se.enabled?"border-primary/40 bg-primary/5":"border-muted bg-muted/50 opacity-60"),children:[x.jsx("span",{className:Le("inline-block w-2 h-2 rounded-full",se.enabled?"bg-green-500":"bg-gray-500")}),x.jsx("span",{className:"font-medium",children:P}),x.jsx("span",{className:"text-xs text-muted-foreground",children:se.type}),se.discovered&&x.jsx("span",{className:"text-[10px] text-muted-foreground",children:"(auto)"}),se.url&&x.jsx("a",{href:se.url,target:"_blank",rel:"noopener noreferrer",onClick:ne=>ne.stopPropagation(),className:"ml-1 text-xs text-muted-foreground hover:text-primary",title:se.url,children:"↗"}),!se.default&&se.type==="remote"&&!se.discovered&&x.jsx("span",{onClick:ne=>{ne.stopPropagation(),j(P)},className:"ml-1 inline-flex h-4 w-4 items-center justify-center rounded-full text-xs text-muted-foreground hover:bg-destructive/20 hover:text-destructive cursor-pointer",title:"Remove",children:"x"})]},P))})]}),x.jsx(mb,{open:!!U,onOpenChange:P=>{P||j(null)},children:x.jsxs(pb,{children:[x.jsx(gb,{className:"fixed inset-0 z-40 bg-black/50"}),x.jsxs(yb,{className:"fixed left-1/2 top-1/2 z-50 w-80 -translate-x-1/2 -translate-y-1/2 rounded-lg border bg-card p-6 shadow-xl",children:[x.jsx(vb,{className:"text-lg font-medium",children:"Remove Marketplace"}),x.jsxs(bb,{className:"mt-2 text-sm text-muted-foreground",children:["Remove ",x.jsx("strong",{children:U}),"?"]}),x.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[x.jsx(xb,{asChild:!0,children:x.jsx("button",{className:"rounded-md border px-3 py-1.5 text-sm hover:bg-muted",children:"Cancel"})}),x.jsx("button",{onClick:()=>{V(U),j(null)},className:"rounded-md bg-destructive px-3 py-1.5 text-sm font-medium text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})]})}),x.jsx(mb,{open:q,onOpenChange:I,children:x.jsxs(pb,{children:[x.jsx(gb,{className:"fixed inset-0 z-40 bg-black/50"}),x.jsxs(yb,{className:"fixed left-1/2 top-1/2 z-50 w-96 -translate-x-1/2 -translate-y-1/2 rounded-lg border bg-card p-6 shadow-xl",children:[x.jsx(vb,{className:"mb-4 text-lg font-medium",children:"Add Marketplace"}),x.jsx(bb,{className:"sr-only",children:"Enter the name and URL for a new marketplace source."}),x.jsxs("div",{className:"space-y-3",children:[x.jsx("input",{type:"text",value:W,onChange:P=>L(P.target.value),placeholder:"Marketplace name",className:"w-full rounded-md border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary"}),x.jsx("input",{type:"text",value:Y,onChange:P=>A(P.target.value),placeholder:"URL (required)",className:"w-full rounded-md border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary"}),x.jsxs("div",{className:"flex justify-end gap-2",children:[x.jsx(xb,{asChild:!0,children:x.jsx("button",{className:"rounded-md border px-3 py-1.5 text-sm hover:bg-muted",children:"Cancel"})}),x.jsx("button",{onClick:F,disabled:!W.trim()||!Y.trim(),className:"rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:"Add"})]})]})]})]})}),x.jsxs("div",{className:"space-y-3",children:[x.jsxs("form",{onSubmit:Q,className:"flex gap-2",children:[x.jsx("input",{type:"text",value:o,onChange:P=>a(P.target.value),placeholder:"Search skills and MCPs...",className:"flex-1 rounded-md border bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary"}),x.jsx("select",{value:i,onChange:P=>s(P.target.value),className:"rounded-md border bg-background px-3 py-2 text-sm",children:O.map(P=>x.jsx("option",{value:P.value,children:P.label},P.value))}),x.jsxs("select",{value:d,onChange:P=>p(P.target.value),className:"rounded-md border bg-background px-3 py-2 text-sm",children:[x.jsx("option",{value:"popular",children:"Popular"}),x.jsx("option",{value:"stars",children:"Stars"}),x.jsx("option",{value:"recent",children:"Recent"}),x.jsx("option",{value:"az",children:"A-Z"})]}),x.jsx("button",{type:"submit",disabled:g,className:"rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:g?"...":"Search"}),x.jsx("button",{type:"button",onClick:()=>I(!0),className:"rounded-md border px-3 py-2 text-sm font-medium hover:bg-muted",children:"+ Add"})]}),x.jsx("div",{className:"flex flex-wrap gap-1.5",children:yj.map(P=>x.jsx("button",{onClick:()=>u(P),className:Le("rounded-full px-3 py-1 text-xs font-medium transition-colors",c===P?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:text-foreground"),children:P},P))})]}),R&&x.jsxs("div",{"aria-live":"polite",className:"flex items-center justify-between rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:[x.jsx("span",{children:R}),x.jsx("button",{onClick:()=>D(null),className:"ml-2 text-xs hover:underline",children:"Dismiss"})]}),!S&&!g&&m.length>0&&x.jsx("h2",{className:"text-sm font-medium text-muted-foreground",children:"Popular Skills & MCPs"}),g&&x.jsx("div",{"aria-live":"polite",className:"flex items-center justify-center py-12",children:x.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent",role:"status","aria-label":"Loading"})}),!g&&S&&ee.length===0&&x.jsxs("div",{className:"rounded-lg border bg-card p-6 text-center text-sm text-muted-foreground shadow-sm",children:["No results found",o&&x.jsxs(x.Fragment,{children:[' for "',o,'"']}),"."]}),!g&&ee.length>0&&x.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:ee.map(P=>x.jsx(U6,{item:P,installing:_,updating:z,expanded:E===`${P.source}-${P.name}`,onInstall:re,onUpdate:k,onToggleExpand:M},`${P.source}-${P.name}`))})]})}const Sb=e=>{let o;const a=new Set,i=(m,y)=>{const g=typeof m=="function"?m(o):m;if(!Object.is(g,o)){const v=o;o=y??(typeof g!="object"||g===null)?g:Object.assign({},o,g),a.forEach(S=>S(o,v))}},s=()=>o,d={setState:i,getState:s,getInitialState:()=>p,subscribe:m=>(a.add(m),()=>a.delete(m))},p=o=e(i,s,d);return d},bj=(e=>e?Sb(e):Sb),xj=e=>e;function Sj(e,o=xj){const a=Oa.useSyncExternalStore(e.subscribe,Oa.useCallback(()=>o(e.getState()),[e,o]),Oa.useCallback(()=>o(e.getInitialState()),[e,o]));return Oa.useDebugValue(a),a}const wb=e=>{const o=bj(e),a=i=>Sj(o,i);return Object.assign(a,o),a},wj=(e=>e?wb(e):wb);let BS=!1;try{BS=globalThis.localStorage?.getItem("mycelium:debug:store")==="1"}catch{}const Tc=(...e)=>{BS&&console.log("[store]",...e)};function ph(e){const o=(e.skills??[]).map(c=>({...c,enabled:c.enabled??!0})),a=(e.mcps??[]).map(c=>({...c,enabled:c.enabled??!0})),i=(e.memory??[]).map(c=>({...c,scope:c.scope??"shared"})),s=(e.plugins??[]).map(c=>{const u=c.skills??[],d=c.agents??[],p=c.commands??[],m=c.hooks??[],y=c.libs??[];return{name:c.name,marketplace:c.marketplace??"",componentCount:u.length+d.length+p.length+m.length+y.length,enabled:c.enabled??!0,skills:u,agents:d,commands:p,hooks:m,libs:y,disabledItems:c.disabledItems??[]}});return{tools:e.tools??[],skills:o,mcps:a,memory:i,plugins:s,migrated:e.migrated??!1}}const $S=wj((e,o)=>({graphData:null,loading:!0,error:!1,activeTab:"graph",selectedPlugin:null,apiStatus:"checking",hasPendingChanges:!1,syncBanner:null,checkApiStatus:async()=>{try{await ll(),e({apiStatus:"connected"})}catch{e({apiStatus:"disconnected"})}},fetchState:async()=>{const{apiStatus:a}=o();if(a!=="connected"){e({loading:!1,error:a==="disconnected"});return}const i=!o().graphData;Tc("fetchState",{isInitialLoad:i}),i&&e({loading:!0});try{const s=await ll(),c=ph(s);e({graphData:c,error:!1,loading:!1})}catch{i&&e({error:!0,loading:!1})}},toggleResource:async a=>{if(a.type==="plugin")return o().togglePlugin(a.name,a.enabled);e(i=>i.graphData?a.type==="skill"?{graphData:{...i.graphData,skills:i.graphData.skills.map(s=>s.name===a.name?{...s,enabled:a.enabled}:s)}}:a.type==="mcp"?{graphData:{...i.graphData,mcps:i.graphData.mcps.map(s=>s.name===a.name?{...s,enabled:a.enabled,status:a.enabled?"synced":"disabled"}:s)}}:i:i);try{await v6({type:a.type,name:a.name,toolId:"claude-code",enabled:a.enabled});const i=await ll();e({graphData:ph(i)})}catch{const i=await ll();e({graphData:ph(i)})}},togglePlugin:async(a,i)=>{Tc("togglePlugin",{name:a,enabled:i}),e(s=>{const c=s.graphData?.plugins.find(p=>p.name===a),u=c?[...c.skills,...c.agents??[],...c.commands??[],...c.hooks??[],...c.libs??[]]:[],d=i?[]:u;return{graphData:s.graphData?{...s.graphData,plugins:s.graphData.plugins.map(p=>p.name===a?{...p,enabled:i,disabledItems:d}:p)}:s.graphData,selectedPlugin:s.selectedPlugin?.name===a?{...s.selectedPlugin,enabled:i,disabledItems:d}:s.selectedPlugin,hasPendingChanges:!0}});try{await z6(a,i)}catch(s){console.error("togglePlugin failed:",s)}await o().fetchState()},togglePluginItem:async(a,i,s)=>{Tc("togglePluginItem",{pluginName:a,itemName:i,enabled:s});try{const c=await T6(a,i,s);c.success?(e({hasPendingChanges:!0}),await o().fetchState()):(e({syncBanner:{type:"error",message:`Failed to ${s?"enable":"disable"} ${i}: ${c.error}`}}),setTimeout(()=>e({syncBanner:null}),5e3))}catch(c){console.error("togglePluginItem failed:",c),e({syncBanner:{type:"error",message:`Network error toggling ${i}`}}),setTimeout(()=>e({syncBanner:null}),5e3)}},removeItem:async(a,i)=>{try{a==="skill"?await A6(i):a==="mcp"?await M6(i):a==="plugin"&&await k6(i),e({hasPendingChanges:!0,syncBanner:{type:"pending",message:`Removed ${a}: ${i}. Click Sync to propagate.`}}),setTimeout(()=>{const{syncBanner:s}=o();s?.message.includes(i)&&e({syncBanner:null})},5e3),o().fetchState()}catch(s){console.error("removeItem failed:",s)}},triggerSync:async()=>{e({syncBanner:{type:"pending",message:"Syncing to all tools..."}});try{await fetch("/api/sync",{method:"POST"}),e({syncBanner:{type:"success",message:"Synced to all tools"},hasPendingChanges:!1}),setTimeout(()=>e({syncBanner:null}),3e3)}catch{e({syncBanner:{type:"error",message:"Sync failed — run `mycelium sync` manually"}}),setTimeout(()=>e({syncBanner:null}),5e3)}},setActiveTab:a=>e({activeTab:a}),setSelectedPlugin:a=>e({selectedPlugin:a}),openPluginPanel:a=>{const i=o().graphData?.plugins.find(s=>s.name===a);e(i?{selectedPlugin:{version:"",description:"",installPath:"",agents:[],commands:[],hooks:[],libs:[],...i}}:{selectedPlugin:{name:a,marketplace:"",version:"",description:`Plugin: ${a}`,author:void 0,enabled:!0,skills:[],agents:[],commands:[],hooks:[],libs:[],installPath:""}}),i||N6().then(s=>{if(o().selectedPlugin?.name!==a)return;const c=s.find(u=>u.name===a);c&&(Tc("openPluginPanel: updating from fetch",{pluginName:a}),e({selectedPlugin:c}))}).catch(s=>{console.error("openPluginPanel fetch failed:",s)})},openMcpPanel:a=>{e({selectedPlugin:{name:a,marketplace:"system",version:"",description:`MCP server: ${a}`,author:void 0,enabled:!0,skills:[],agents:[],commands:[],hooks:[],libs:[],installPath:""}})},openSkillPanel:a=>{ll().then(i=>{if(o().selectedPlugin?.name!==a)return;const s=(i.plugins??[]).find(c=>(c.skills??[]).includes(a));s?o().openPluginPanel(s.name):e({selectedPlugin:{name:a,marketplace:"standalone",version:"",description:`Standalone skill: ${a}`,author:void 0,enabled:!0,skills:[a],agents:[],commands:[],hooks:[],libs:[],installPath:""}})}).catch(i=>{console.error("openSkillPanel fetch failed:",i),e({selectedPlugin:{name:a,marketplace:"standalone",version:"",description:`Standalone skill: ${a}`,author:void 0,enabled:!0,skills:[a],agents:[],commands:[],hooks:[],libs:[],installPath:""}})})}})),Ha=[{id:"claude-code",name:"Claude Code"},{id:"codex",name:"Codex CLI"},{id:"gemini",name:"Gemini CLI"},{id:"opencode",name:"OpenCode"},{id:"openclaw",name:"OpenClaw"},{id:"aider",name:"Aider"}],Qr=[{name:"sherpai",marketplace:"sherpai-marketplace",skills:["navigate","health","debug","live-bot","cache-debug","iterate","walkforward"],extras:{agents:["bot-agent","monitor-agent"],hooks:["pre-deploy","post-test"],commands:["run-backtest"]}},{name:"superpowers",marketplace:"superpowers-marketplace",skills:["tdd","debugging","plans","git-worktrees","code-review","parallel-agents","brainstorming","finishing-branch","verification"]},{name:"sherpai-core",marketplace:"sherpai-marketplace",skills:["skill-creator","raycast","prompt-builder"]},{name:"glm-plan-usage",marketplace:"zai-coding-plugins",skills:["usage-query","cost-tracker"]},{name:"docgen",marketplace:"community",skills:["api-docs","readme-gen","changelog","jsdoc-gen"]},{name:"test-runner",marketplace:"community",skills:["vitest-run","jest-run","coverage","e2e-run"]},{name:"infra-tools",marketplace:"internal",skills:["docker-compose","k8s-deploy","terraform-plan"]},{name:"code-quality",marketplace:"community",skills:["eslint-fix","prettier-run","sonar-scan","dead-code"]},{name:"ai-helpers",marketplace:"community",skills:["prompt-optimize","context-compress","token-count"]},{name:"data-tools",marketplace:"internal",skills:["csv-parse","json-transform","sql-gen"]}],ja=["context7","playwright","supabase","github-mcp","linear","slack-mcp","notion-mcp","redis-mcp","postgres-mcp","sentry-mcp","stripe-mcp","vercel-mcp","cloudflare-mcp","openai-mcp","pinecone-mcp","grafana-mcp","whark-trading","massive"],fl=["custom-deploy","lint-fix","db-migrate","api-scaffold","perf-profile","env-sync","secret-rotate","changelog-gen","pr-template","benchmark"],pl=[{name:"Argusito",scope:"shared"},{name:"mycelium",scope:"shared"},{name:"vnido",scope:"shared"},{name:"bytemines-io",scope:"shared"},{name:"trading-bot",scope:"shared"},{name:"personal-notes",scope:"personal"},{name:"coding-standards",scope:"coding"},{name:"architecture-decisions",scope:"shared"},{name:"api-patterns",scope:"coding"},{name:"team-conventions",scope:"shared"},{name:"incident-log",scope:"shared"},{name:"performance-baselines",scope:"coding"},{name:"security-policies",scope:"shared"},{name:"onboarding-guide",scope:"shared"}];function Pt(e,o,a=!0){return{id:e,name:o,status:"synced",installed:a}}function vt(e,o=!0,a){return{name:e,status:o?"synced":"disabled",enabled:o,connectedTools:a}}function At(e,o="shared"){return{name:e,scope:o,status:"synced"}}function It(e,o=!0,a){return{name:e,status:"synced",enabled:o,connectedTools:a}}function oa(e,o,a,i){return{name:e,marketplace:o,componentCount:a.length,enabled:!0,skills:a,agents:i?.agents,commands:i?.commands,hooks:i?.hooks,libs:i?.libs}}const _j={tools:[Pt("claude-code","Claude Code"),Pt("codex","Codex CLI")],plugins:[oa("sherpai","sherpai-marketplace",["navigate","health","debug"],{agents:["bot-agent"],hooks:["pre-deploy"]}),oa("superpowers","superpowers-marketplace",["tdd","debugging","plans","git-worktrees"])],skills:[],mcps:[vt("context7"),vt("playwright"),vt("whark-trading",!1)],memory:[At("Argusito"),At("mycelium"),At("vnido")]},Ej={tools:Ha.slice(0,4).map(e=>Pt(e.id,e.name)),plugins:Qr.slice(0,4).map(e=>oa(e.name,e.marketplace,[...e.skills],"extras"in e?e.extras:void 0)),skills:[It("custom-deploy",!0,["claude-code"]),It("lint-fix",!0,["claude-code","codex"])],mcps:[vt("context7"),vt("playwright"),vt("whark-trading",!1),vt("massive",!1),vt("supabase"),vt("github-mcp"),vt("linear")],memory:[At("Argusito"),At("mycelium"),At("vnido"),At("bytemines-io"),At("personal-notes","personal"),At("coding-standards","coding")]},Cj={tools:Ha.map(e=>Pt(e.id,e.name)),plugins:Qr.slice(0,7).map(e=>oa(e.name,e.marketplace,[...e.skills],"extras"in e?e.extras:void 0)),skills:[It("custom-deploy",!0,["claude-code"]),It("lint-fix",!0,["claude-code","codex"]),It("db-migrate",!0,["claude-code","opencode"]),It("api-scaffold",!0,["claude-code","gemini"]),It("perf-profile",!0,["claude-code"])],mcps:ja.slice(0,12).map((e,o)=>vt(e,o!==2&&o!==3&&o!==11)),memory:pl.slice(0,10).map(e=>At(e.name,e.scope))},Nj={tools:Ha.map(e=>Pt(e.id,e.name)),plugins:Qr.map(e=>oa(e.name,e.marketplace,[...e.skills],"extras"in e?e.extras:void 0)),skills:fl.map((e,o)=>{const a=Ha.map(s=>s.id),i=a.slice(0,Math.max(1,o%a.length+1));return It(e,!0,i)}),mcps:ja.map((e,o)=>vt(e,o%5!==0)),memory:pl.map(e=>At(e.name,e.scope))},zj={tools:[Pt("claude-code","Claude Code")],plugins:[oa("superpowers","superpowers-marketplace",["tdd","debugging"])],skills:[It("lint-fix",!0,["claude-code"])],mcps:[vt("context7",!0,["claude-code"]),vt("playwright",!0,["claude-code"])],memory:[At("project-a")]},Tj={tools:[Pt("claude-code","Claude Code"),Pt("codex","Codex CLI"),Pt("gemini","Gemini CLI")],plugins:[oa("superpowers","superpowers-marketplace",["tdd","debugging"])],skills:[It("claude-only-skill",!0,["claude-code"]),It("codex-only-skill",!0,["codex"]),It("gemini-only-skill",!0,["gemini"]),It("shared-skill",!0,["claude-code","codex","gemini"])],mcps:[vt("claude-mcp",!0,["claude-code"]),vt("codex-mcp",!0,["codex"]),vt("shared-mcp",!0,["claude-code","codex"]),vt("all-mcp",!0,["claude-code","codex","gemini"])],memory:[At("shared-mem"),At("coding-mem","coding"),At("personal-mem","personal")]},Aj={tools:[Pt("claude-code","Claude Code"),Pt("codex","Codex CLI")],plugins:[],skills:[],mcps:ja.map((e,o)=>vt(e,o%3!==0,o%2===0?["claude-code"]:["codex"])),memory:[At("project-a")]},Mj={tools:[Pt("claude-code","Claude Code"),Pt("codex","Codex CLI")],plugins:[],skills:[],mcps:[],memory:[]};function kj(e){let o=e;return()=>(o=o*1664525+1013904223&4294967295,(o>>>0)/4294967295)}function Oj(e){const o=kj(e.seed??Date.now()),a=Math.min(e.tools??2,Ha.length),i=e.mcps??3,s=e.memory??2,c=e.skills??0,u=e.plugins??2,d=e.disabledRatio??.2,p=Ha.slice(0,a).map(y=>y.id),m=y=>{const g=p[y%a],v=Math.max(1,Math.floor(o()*a)+1),S=[g];for(let w=1;w<v&&w<a;w++){const _=p[(y+w)%a];S.includes(_)||S.push(_)}return S};return{tools:Ha.slice(0,a).map(y=>Pt(y.id,y.name)),plugins:Array.from({length:u},(y,g)=>{const v=Qr[g%Qr.length],S=g<Qr.length?v.name:`${v.name}-${g}`,w=v.skills.slice(0,Math.max(1,Math.floor(o()*v.skills.length)+1));return oa(S,v.marketplace,[...w],"extras"in v?v.extras:void 0)}),skills:Array.from({length:c},(y,g)=>{const v=g<fl.length?fl[g]:`${fl[g%fl.length]}-${g}`;return It(v,o()>d,m(g))}),mcps:Array.from({length:i},(y,g)=>{const v=g<ja.length?ja[g]:`${ja[g%ja.length]}-${g}`;return vt(v,o()>d,m(g))}),memory:Array.from({length:s},(y,g)=>{const v=pl[g%pl.length],S=g<pl.length?v.name:`${v.name}-${g}`;return At(S,v.scope)})}}const Dj={small:_j,medium:Ej,large:Cj,xl:Nj,"single-tool":zj,radial:Tj,"heavy-mcp":Aj,empty:Mj};function jj(e){return Dj[e]??null}function Rj(){if(typeof window>"u")return null;const e=new URLSearchParams(window.location.search),o=e.get("debug");return o?o==="custom"?Oj({tools:parseInt(e.get("tools")??"2",10),mcps:parseInt(e.get("mcps")??"3",10),memory:parseInt(e.get("memory")??"2",10),skills:parseInt(e.get("skills")??"0",10),plugins:parseInt(e.get("plugins")??"2",10),disabledRatio:parseFloat(e.get("disabledRatio")??"0.2"),seed:e.has("seed")?parseInt(e.get("seed"),10):void 0}):jj(o):null}function Lj({status:e}){const o={synced:"bg-status-synced",pending:"bg-status-pending",error:"bg-status-error",disabled:"bg-status-disabled",not_installed:"bg-gray-700"};return x.jsx("span",{"data-testid":"status-indicator",className:Le("inline-block w-3 h-3 rounded-full",o[e])})}function Hj(){const{graphData:e,loading:o,error:a,apiStatus:i,fetchState:s,toggleResource:c,togglePlugin:u,setActiveTab:d,openPluginPanel:p,openMcpPanel:m,openSkillPanel:y}=$S();if(N.useEffect(()=>{s()},[i,s]),o)return x.jsx("div",{"data-testid":"graph-container",className:"h-full rounded-lg border bg-card/50 flex items-center justify-center",children:x.jsx("div",{"aria-live":"polite",className:"text-center text-muted-foreground",children:x.jsx("div",{className:"mb-2 text-lg",children:"Loading..."})})});if(a)return x.jsx("div",{"data-testid":"graph-container",className:"h-full rounded-lg border bg-card/50 flex items-center justify-center",children:x.jsxs("div",{"aria-live":"polite",className:"text-center text-muted-foreground",children:[x.jsx("div",{className:"mb-2 text-lg",children:"Cannot connect to API"}),x.jsxs("div",{className:"text-sm",children:["Start the server with ",x.jsx("code",{className:"bg-muted px-1 rounded",children:"mycelium serve"})]})]})});if(e&&!e.migrated&&e.skills.length===0&&e.mcps.length===0)return x.jsx("div",{"data-testid":"graph-container",className:"h-full rounded-lg border bg-card/50 flex items-center justify-center",children:x.jsxs("div",{className:"text-center",children:[x.jsx("div",{className:"mb-2 text-lg text-foreground",children:"No configuration detected"}),x.jsxs("div",{className:"mb-4 text-sm text-muted-foreground",children:["Run ",x.jsx("code",{className:"bg-muted px-1 rounded",children:"mycelium migrate --apply"})," to import your tool configs, then ",x.jsx("code",{className:"bg-muted px-1 rounded",children:"mycelium serve"})," to view them here."]}),x.jsx("button",{onClick:()=>d("migrate"),className:"rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90",children:"Scan Tools"})]})});const v=Rj()??e??{tools:[],skills:[],mcps:[],memory:[],plugins:[]};return x.jsx("div",{"data-testid":"graph-container",className:"h-full rounded-lg border bg-card/50",children:x.jsx(rm,{children:x.jsx(rS,{data:v,showUninstalledTools:!1,onToggle:c,onPluginToggle:u,onPluginClick:p,onMcpClick:m,onSkillClick:y})})})}function Uj(){const{activeTab:e,setActiveTab:o,selectedPlugin:a,setSelectedPlugin:i,apiStatus:s,checkApiStatus:c,hasPendingChanges:u,syncBanner:d,triggerSync:p,togglePlugin:m,togglePluginItem:y,removeItem:g}=$S();return N.useEffect(()=>{c()},[c]),x.jsxs("div",{className:"flex h-screen flex-col bg-background",children:[x.jsxs("header",{className:"relative flex items-center border-b px-4 py-2",children:[x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsxs("h1",{className:"flex items-center gap-2 text-lg font-bold tracking-tight",children:[x.jsx("span",{children:"🍄"}),x.jsx("span",{children:"MYCELIUM"}),x.jsx("span",{className:"ml-1 rounded-full bg-purple-500/20 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wider text-purple-400 border border-purple-500/30",children:"Beta"})]}),x.jsx(Lj,{status:s==="connected"?"synced":s==="checking"?"pending":"error"})]}),x.jsx("nav",{role:"tablist",className:"absolute left-1/2 -translate-x-1/2 flex gap-1 rounded-lg bg-muted p-0.5",children:["graph","migrate","marketplace"].map(v=>x.jsx("button",{role:"tab","aria-selected":e===v,onClick:()=>o(v),className:Le("rounded-md px-3 py-1 text-sm font-medium transition-colors",e===v?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:v.charAt(0).toUpperCase()+v.slice(1)},v))}),x.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[s!=="connected"&&x.jsx("span",{className:"text-xs text-muted-foreground",children:s==="checking"?"Connecting...":"API Offline"}),x.jsx("button",{onClick:p,className:Le("rounded-md px-3 py-1.5 text-sm font-medium transition-colors",u?"bg-yellow-500 text-black hover:bg-yellow-400 animate-pulse":"bg-primary text-primary-foreground hover:bg-primary/90"),children:u?"Sync (pending)":"Sync"})]})]}),d&&x.jsx("div",{"aria-live":"polite",className:Le("px-4 py-1.5 text-sm font-medium",d.type==="success"&&"bg-green-500/10 text-green-400",d.type==="pending"&&"bg-yellow-500/10 text-yellow-400",d.type==="error"&&"bg-red-500/10 text-red-400"),children:d.message}),x.jsxs("div",{className:"flex-1 overflow-hidden p-2",children:[e==="graph"&&x.jsx("section",{className:"h-full",children:x.jsx(Hj,{})}),e==="migrate"&&x.jsx("div",{className:"h-full overflow-y-auto p-4",children:x.jsx(D6,{})}),e==="marketplace"&&x.jsx("div",{className:"h-full overflow-y-auto p-4",children:x.jsx(vj,{})})]}),x.jsx(lS,{plugin:a,onClose:()=>i(null),onTogglePlugin:m,onToggleItem:y,onRemoveItem:g})]})}function Zj(){return x.jsx(Uj,{})}o_.createRoot(document.getElementById("root")).render(x.jsx(Oa.StrictMode,{children:x.jsx(Zj,{})}));
|
|
153
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${o.docsSlug}`;return N.useEffect(()=>{e&&(document.getElementById(e)||console.error(a))},[a,e]),null},pj="DialogDescriptionWarning",gj=({contentRef:e,descriptionId:o})=>{const i=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ZS(pj).contentName}}.`;return N.useEffect(()=>{const s=e.current?.getAttribute("aria-describedby");o&&s&&(document.getElementById(o)||console.warn(i))},[i,e,o]),null},mb=NS,pb=AS,gb=MS,yb=kS,vb=DS,bb=RS,xb=HS;const yj=["All","Testing","Git","Debugging","Frontend","Backend","DevOps","AI","Code Review","Documentation"];function vj({onClose:e}){const[o,a]=N.useState(""),[i,s]=N.useState("all"),[c,u]=N.useState("All"),[d,p]=N.useState("popular"),[m,y]=N.useState([]),[g,v]=N.useState(!1),[S,w]=N.useState(!1),[_,T]=N.useState(null),[z,H]=N.useState(null),[E,M]=N.useState(null),[R,D]=N.useState(null),[O,Z]=N.useState([{value:"all",label:"All"}]),[$,oe]=N.useState({}),[q,I]=N.useState(!1),[W,L]=N.useState(""),[Y,A]=N.useState(""),[U,j]=N.useState(null);N.useEffect(()=>{_6().then(P=>{oe(P);const se=Object.keys(P).map(ne=>({value:ne,label:ne}));Z([{value:"all",label:"All"},...se])}).catch(P=>{console.warn("Failed to load marketplace registry:",P)}),v(!0),Wv().then(P=>{const se=P.flatMap(ne=>ne.entries.map(le=>({...le,type:le.type})));y(se)}).catch(P=>{console.warn("Failed to load popular skills:",P)}).finally(()=>v(!1))},[]);const Q=N.useCallback(async P=>{if(P?.preventDefault(),D(null),!o.trim()){v(!0),w(!1),Wv().then(se=>{const ne=se.flatMap(le=>le.entries.map(de=>({...de,type:de.type})));y(ne)}).catch(()=>y([])).finally(()=>v(!1));return}v(!0),w(!0);try{const ne=(await S6(o,i!=="all"?i:void 0)).flatMap(le=>le.entries.map(de=>({...de,type:de.type})));y(ne)}catch{y([])}finally{v(!1)}},[o,i]);async function re(P){const se=`${P.source}-${P.name}`;T(se),D(null);try{const ne=await w6(P.name,P.source);ne.success?y(le=>le.map(de=>de.name===P.name&&de.source===P.source?{...de,installed:!0}:de)):D(`Failed to install ${P.name}: ${ne.error||"Unknown error"}`)}catch(ne){D(`Failed to install ${P.name}: ${ne instanceof Error?ne.message:String(ne)}`)}finally{T(null)}}async function k(P){const se=`${P.source}-${P.name}`;H(se),D(null);try{const ne=await O6(P.name,P.source);ne.success?y(le=>le.map(de=>de.name===P.name&&de.source===P.source?{...de,installedVersion:de.latestVersion}:de)):D(`Failed to update ${P.name}: ${ne.error||"Unknown error"}`)}catch(ne){D(`Failed to update ${P.name}: ${ne instanceof Error?ne.message:String(ne)}`)}finally{H(null)}}async function V(P){await C6(P),oe(se=>{const ne={...se};return delete ne[P],ne}),Z(se=>se.filter(ne=>ne.value!==P)),i===P&&s("all")}async function F(){if(!W.trim()||!Y.trim())return;const P={type:"remote",enabled:!0,url:Y};await E6(W,P),oe(se=>({...se,[W]:P})),Z(se=>[...se,{value:W,label:W}]),L(""),A(""),I(!1)}const ee=N.useMemo(()=>{let P=m;if(c!=="All"){const ne=c.toLowerCase();P=P.filter(le=>le.category?.toLowerCase()===ne||le.name.toLowerCase().includes(ne)||le.description.toLowerCase().includes(ne))}const se=[...P];switch(d){case"popular":se.sort((ne,le)=>(le.downloads??0)-(ne.downloads??0));break;case"stars":se.sort((ne,le)=>(le.stars??0)-(ne.stars??0));break;case"recent":se.sort((ne,le)=>(le.updatedAt??"").localeCompare(ne.updatedAt??""));break;case"az":se.sort((ne,le)=>ne.name.localeCompare(le.name));break}return se},[m,c,d]);return x.jsxs("div",{className:"mx-auto max-w-5xl space-y-6",children:[Object.keys($).length>0&&x.jsxs("div",{className:"rounded-lg border bg-card p-4 text-card-foreground shadow-sm",children:[x.jsx("h3",{className:"mb-3 text-sm font-medium",children:"Configured Marketplaces"}),x.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries($).map(([P,se])=>x.jsxs("button",{onClick:()=>{s(P),o.trim()&&Q()},className:Le("flex items-center gap-2 rounded-full border px-3 py-1.5 text-sm cursor-pointer transition-all hover:border-primary",i===P?"border-primary bg-primary/10 ring-1 ring-primary/30":se.enabled?"border-primary/40 bg-primary/5":"border-muted bg-muted/50 opacity-60"),children:[x.jsx("span",{className:Le("inline-block w-2 h-2 rounded-full",se.enabled?"bg-green-500":"bg-gray-500")}),x.jsx("span",{className:"font-medium",children:P}),x.jsx("span",{className:"text-xs text-muted-foreground",children:se.type}),se.discovered&&x.jsx("span",{className:"text-[10px] text-muted-foreground",children:"(auto)"}),se.url&&x.jsx("a",{href:se.url,target:"_blank",rel:"noopener noreferrer",onClick:ne=>ne.stopPropagation(),className:"ml-1 text-xs text-muted-foreground hover:text-primary",title:se.url,children:"↗"}),!se.default&&se.type==="remote"&&!se.discovered&&x.jsx("span",{onClick:ne=>{ne.stopPropagation(),j(P)},className:"ml-1 inline-flex h-4 w-4 items-center justify-center rounded-full text-xs text-muted-foreground hover:bg-destructive/20 hover:text-destructive cursor-pointer",title:"Remove",children:"x"})]},P))})]}),x.jsx(mb,{open:!!U,onOpenChange:P=>{P||j(null)},children:x.jsxs(pb,{children:[x.jsx(gb,{className:"fixed inset-0 z-40 bg-black/50"}),x.jsxs(yb,{className:"fixed left-1/2 top-1/2 z-50 w-80 -translate-x-1/2 -translate-y-1/2 rounded-lg border bg-card p-6 shadow-xl",children:[x.jsx(vb,{className:"text-lg font-medium",children:"Remove Marketplace"}),x.jsxs(bb,{className:"mt-2 text-sm text-muted-foreground",children:["Remove ",x.jsx("strong",{children:U}),"?"]}),x.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[x.jsx(xb,{asChild:!0,children:x.jsx("button",{className:"rounded-md border px-3 py-1.5 text-sm hover:bg-muted",children:"Cancel"})}),x.jsx("button",{onClick:()=>{V(U),j(null)},className:"rounded-md bg-destructive px-3 py-1.5 text-sm font-medium text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})]})}),x.jsx(mb,{open:q,onOpenChange:I,children:x.jsxs(pb,{children:[x.jsx(gb,{className:"fixed inset-0 z-40 bg-black/50"}),x.jsxs(yb,{className:"fixed left-1/2 top-1/2 z-50 w-96 -translate-x-1/2 -translate-y-1/2 rounded-lg border bg-card p-6 shadow-xl",children:[x.jsx(vb,{className:"mb-4 text-lg font-medium",children:"Add Marketplace"}),x.jsx(bb,{className:"sr-only",children:"Enter the name and URL for a new marketplace source."}),x.jsxs("div",{className:"space-y-3",children:[x.jsx("input",{type:"text",value:W,onChange:P=>L(P.target.value),placeholder:"Marketplace name",className:"w-full rounded-md border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary"}),x.jsx("input",{type:"text",value:Y,onChange:P=>A(P.target.value),placeholder:"URL (required)",className:"w-full rounded-md border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary"}),x.jsxs("div",{className:"flex justify-end gap-2",children:[x.jsx(xb,{asChild:!0,children:x.jsx("button",{className:"rounded-md border px-3 py-1.5 text-sm hover:bg-muted",children:"Cancel"})}),x.jsx("button",{onClick:F,disabled:!W.trim()||!Y.trim(),className:"rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:"Add"})]})]})]})]})}),x.jsxs("div",{className:"space-y-3",children:[x.jsxs("form",{onSubmit:Q,className:"flex gap-2",children:[x.jsx("input",{type:"text",value:o,onChange:P=>a(P.target.value),placeholder:"Search skills and MCPs...",className:"flex-1 rounded-md border bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary"}),x.jsx("select",{value:i,onChange:P=>s(P.target.value),className:"rounded-md border bg-background px-3 py-2 text-sm",children:O.map(P=>x.jsx("option",{value:P.value,children:P.label},P.value))}),x.jsxs("select",{value:d,onChange:P=>p(P.target.value),className:"rounded-md border bg-background px-3 py-2 text-sm",children:[x.jsx("option",{value:"popular",children:"Popular"}),x.jsx("option",{value:"stars",children:"Stars"}),x.jsx("option",{value:"recent",children:"Recent"}),x.jsx("option",{value:"az",children:"A-Z"})]}),x.jsx("button",{type:"submit",disabled:g,className:"rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:g?"...":"Search"}),x.jsx("button",{type:"button",onClick:()=>I(!0),className:"rounded-md border px-3 py-2 text-sm font-medium hover:bg-muted",children:"+ Add"})]}),x.jsx("div",{className:"flex flex-wrap gap-1.5",children:yj.map(P=>x.jsx("button",{onClick:()=>u(P),className:Le("rounded-full px-3 py-1 text-xs font-medium transition-colors",c===P?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:text-foreground"),children:P},P))})]}),R&&x.jsxs("div",{"aria-live":"polite",className:"flex items-center justify-between rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:[x.jsx("span",{children:R}),x.jsx("button",{onClick:()=>D(null),className:"ml-2 text-xs hover:underline",children:"Dismiss"})]}),!S&&!g&&m.length>0&&x.jsx("h2",{className:"text-sm font-medium text-muted-foreground",children:"Popular Skills & MCPs"}),g&&x.jsx("div",{"aria-live":"polite",className:"flex items-center justify-center py-12",children:x.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent",role:"status","aria-label":"Loading"})}),!g&&S&&ee.length===0&&x.jsxs("div",{className:"rounded-lg border bg-card p-6 text-center text-sm text-muted-foreground shadow-sm",children:["No results found",o&&x.jsxs(x.Fragment,{children:[' for "',o,'"']}),"."]}),!g&&ee.length>0&&x.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:ee.map(P=>x.jsx(U6,{item:P,installing:_,updating:z,expanded:E===`${P.source}-${P.name}`,onInstall:re,onUpdate:k,onToggleExpand:M},`${P.source}-${P.name}`))})]})}const Sb=e=>{let o;const a=new Set,i=(m,y)=>{const g=typeof m=="function"?m(o):m;if(!Object.is(g,o)){const v=o;o=y??(typeof g!="object"||g===null)?g:Object.assign({},o,g),a.forEach(S=>S(o,v))}},s=()=>o,d={setState:i,getState:s,getInitialState:()=>p,subscribe:m=>(a.add(m),()=>a.delete(m))},p=o=e(i,s,d);return d},bj=(e=>e?Sb(e):Sb),xj=e=>e;function Sj(e,o=xj){const a=Oa.useSyncExternalStore(e.subscribe,Oa.useCallback(()=>o(e.getState()),[e,o]),Oa.useCallback(()=>o(e.getInitialState()),[e,o]));return Oa.useDebugValue(a),a}const wb=e=>{const o=bj(e),a=i=>Sj(o,i);return Object.assign(a,o),a},wj=(e=>e?wb(e):wb);let BS=!1;try{BS=globalThis.localStorage?.getItem("mycelium:debug:store")==="1"}catch{}const Tc=(...e)=>{BS&&console.log("[store]",...e)};function ph(e){const o=(e.skills??[]).map(c=>({...c,enabled:c.enabled??!0})),a=(e.mcps??[]).map(c=>({...c,enabled:c.enabled??!0})),i=(e.memory??[]).map(c=>({...c,scope:c.scope??"shared"})),s=(e.plugins??[]).map(c=>{const u=c.skills??[],d=c.agents??[],p=c.commands??[],m=c.hooks??[],y=c.libs??[];return{name:c.name,marketplace:c.marketplace??"",componentCount:u.length+d.length+p.length+m.length+y.length,enabled:c.enabled??!0,skills:u,agents:d,commands:p,hooks:m,libs:y,disabledItems:c.disabledItems??[]}});return{tools:e.tools??[],skills:o,mcps:a,memory:i,plugins:s,migrated:e.migrated??!1}}const $S=wj((e,o)=>({graphData:null,loading:!0,error:!1,activeTab:"graph",selectedPlugin:null,apiStatus:"checking",version:null,hasPendingChanges:!1,syncBanner:null,checkApiStatus:async()=>{try{await ll(),e({apiStatus:"connected"})}catch{e({apiStatus:"disconnected"})}},fetchState:async()=>{const{apiStatus:a}=o();if(a!=="connected"){e({loading:!1,error:a==="disconnected"});return}const i=!o().graphData;Tc("fetchState",{isInitialLoad:i}),i&&e({loading:!0});try{const s=await ll(),c=ph(s);e({graphData:c,error:!1,loading:!1,version:s.version??null})}catch{i&&e({error:!0,loading:!1})}},toggleResource:async a=>{if(a.type==="plugin")return o().togglePlugin(a.name,a.enabled);e(i=>i.graphData?a.type==="skill"?{graphData:{...i.graphData,skills:i.graphData.skills.map(s=>s.name===a.name?{...s,enabled:a.enabled}:s)}}:a.type==="mcp"?{graphData:{...i.graphData,mcps:i.graphData.mcps.map(s=>s.name===a.name?{...s,enabled:a.enabled,status:a.enabled?"synced":"disabled"}:s)}}:i:i);try{await v6({type:a.type,name:a.name,toolId:"claude-code",enabled:a.enabled});const i=await ll();e({graphData:ph(i)})}catch{const i=await ll();e({graphData:ph(i)})}},togglePlugin:async(a,i)=>{Tc("togglePlugin",{name:a,enabled:i}),e(s=>{const c=s.graphData?.plugins.find(p=>p.name===a),u=c?[...c.skills,...c.agents??[],...c.commands??[],...c.hooks??[],...c.libs??[]]:[],d=i?[]:u;return{graphData:s.graphData?{...s.graphData,plugins:s.graphData.plugins.map(p=>p.name===a?{...p,enabled:i,disabledItems:d}:p)}:s.graphData,selectedPlugin:s.selectedPlugin?.name===a?{...s.selectedPlugin,enabled:i,disabledItems:d}:s.selectedPlugin,hasPendingChanges:!0}});try{await z6(a,i)}catch(s){console.error("togglePlugin failed:",s)}await o().fetchState()},togglePluginItem:async(a,i,s)=>{Tc("togglePluginItem",{pluginName:a,itemName:i,enabled:s});try{const c=await T6(a,i,s);c.success?(e({hasPendingChanges:!0}),await o().fetchState()):(e({syncBanner:{type:"error",message:`Failed to ${s?"enable":"disable"} ${i}: ${c.error}`}}),setTimeout(()=>e({syncBanner:null}),5e3))}catch(c){console.error("togglePluginItem failed:",c),e({syncBanner:{type:"error",message:`Network error toggling ${i}`}}),setTimeout(()=>e({syncBanner:null}),5e3)}},removeItem:async(a,i)=>{try{a==="skill"?await A6(i):a==="mcp"?await M6(i):a==="plugin"&&await k6(i),e({hasPendingChanges:!0,syncBanner:{type:"pending",message:`Removed ${a}: ${i}. Click Sync to propagate.`}}),setTimeout(()=>{const{syncBanner:s}=o();s?.message.includes(i)&&e({syncBanner:null})},5e3),o().fetchState()}catch(s){console.error("removeItem failed:",s)}},triggerSync:async()=>{e({syncBanner:{type:"pending",message:"Syncing to all tools..."}});try{await fetch("/api/sync",{method:"POST"}),e({syncBanner:{type:"success",message:"Synced to all tools"},hasPendingChanges:!1}),setTimeout(()=>e({syncBanner:null}),3e3)}catch{e({syncBanner:{type:"error",message:"Sync failed — run `mycelium sync` manually"}}),setTimeout(()=>e({syncBanner:null}),5e3)}},setActiveTab:a=>e({activeTab:a}),setSelectedPlugin:a=>e({selectedPlugin:a}),openPluginPanel:a=>{const i=o().graphData?.plugins.find(s=>s.name===a);e(i?{selectedPlugin:{version:"",description:"",installPath:"",agents:[],commands:[],hooks:[],libs:[],...i}}:{selectedPlugin:{name:a,marketplace:"",version:"",description:`Plugin: ${a}`,author:void 0,enabled:!0,skills:[],agents:[],commands:[],hooks:[],libs:[],installPath:""}}),i||N6().then(s=>{if(o().selectedPlugin?.name!==a)return;const c=s.find(u=>u.name===a);c&&(Tc("openPluginPanel: updating from fetch",{pluginName:a}),e({selectedPlugin:c}))}).catch(s=>{console.error("openPluginPanel fetch failed:",s)})},openMcpPanel:a=>{e({selectedPlugin:{name:a,marketplace:"system",version:"",description:`MCP server: ${a}`,author:void 0,enabled:!0,skills:[],agents:[],commands:[],hooks:[],libs:[],installPath:""}})},openSkillPanel:a=>{ll().then(i=>{if(o().selectedPlugin?.name!==a)return;const s=(i.plugins??[]).find(c=>(c.skills??[]).includes(a));s?o().openPluginPanel(s.name):e({selectedPlugin:{name:a,marketplace:"standalone",version:"",description:`Standalone skill: ${a}`,author:void 0,enabled:!0,skills:[a],agents:[],commands:[],hooks:[],libs:[],installPath:""}})}).catch(i=>{console.error("openSkillPanel fetch failed:",i),e({selectedPlugin:{name:a,marketplace:"standalone",version:"",description:`Standalone skill: ${a}`,author:void 0,enabled:!0,skills:[a],agents:[],commands:[],hooks:[],libs:[],installPath:""}})})}})),Ha=[{id:"claude-code",name:"Claude Code"},{id:"codex",name:"Codex CLI"},{id:"gemini",name:"Gemini CLI"},{id:"opencode",name:"OpenCode"},{id:"openclaw",name:"OpenClaw"},{id:"aider",name:"Aider"}],Qr=[{name:"sherpai",marketplace:"sherpai-marketplace",skills:["navigate","health","debug","live-bot","cache-debug","iterate","walkforward"],extras:{agents:["bot-agent","monitor-agent"],hooks:["pre-deploy","post-test"],commands:["run-backtest"]}},{name:"superpowers",marketplace:"superpowers-marketplace",skills:["tdd","debugging","plans","git-worktrees","code-review","parallel-agents","brainstorming","finishing-branch","verification"]},{name:"sherpai-core",marketplace:"sherpai-marketplace",skills:["skill-creator","raycast","prompt-builder"]},{name:"glm-plan-usage",marketplace:"zai-coding-plugins",skills:["usage-query","cost-tracker"]},{name:"docgen",marketplace:"community",skills:["api-docs","readme-gen","changelog","jsdoc-gen"]},{name:"test-runner",marketplace:"community",skills:["vitest-run","jest-run","coverage","e2e-run"]},{name:"infra-tools",marketplace:"internal",skills:["docker-compose","k8s-deploy","terraform-plan"]},{name:"code-quality",marketplace:"community",skills:["eslint-fix","prettier-run","sonar-scan","dead-code"]},{name:"ai-helpers",marketplace:"community",skills:["prompt-optimize","context-compress","token-count"]},{name:"data-tools",marketplace:"internal",skills:["csv-parse","json-transform","sql-gen"]}],ja=["context7","playwright","supabase","github-mcp","linear","slack-mcp","notion-mcp","redis-mcp","postgres-mcp","sentry-mcp","stripe-mcp","vercel-mcp","cloudflare-mcp","openai-mcp","pinecone-mcp","grafana-mcp","whark-trading","massive"],fl=["custom-deploy","lint-fix","db-migrate","api-scaffold","perf-profile","env-sync","secret-rotate","changelog-gen","pr-template","benchmark"],pl=[{name:"Argusito",scope:"shared"},{name:"mycelium",scope:"shared"},{name:"vnido",scope:"shared"},{name:"bytemines-io",scope:"shared"},{name:"trading-bot",scope:"shared"},{name:"personal-notes",scope:"personal"},{name:"coding-standards",scope:"coding"},{name:"architecture-decisions",scope:"shared"},{name:"api-patterns",scope:"coding"},{name:"team-conventions",scope:"shared"},{name:"incident-log",scope:"shared"},{name:"performance-baselines",scope:"coding"},{name:"security-policies",scope:"shared"},{name:"onboarding-guide",scope:"shared"}];function Pt(e,o,a=!0){return{id:e,name:o,status:"synced",installed:a}}function vt(e,o=!0,a){return{name:e,status:o?"synced":"disabled",enabled:o,connectedTools:a}}function At(e,o="shared"){return{name:e,scope:o,status:"synced"}}function It(e,o=!0,a){return{name:e,status:"synced",enabled:o,connectedTools:a}}function oa(e,o,a,i){return{name:e,marketplace:o,componentCount:a.length,enabled:!0,skills:a,agents:i?.agents,commands:i?.commands,hooks:i?.hooks,libs:i?.libs}}const _j={tools:[Pt("claude-code","Claude Code"),Pt("codex","Codex CLI")],plugins:[oa("sherpai","sherpai-marketplace",["navigate","health","debug"],{agents:["bot-agent"],hooks:["pre-deploy"]}),oa("superpowers","superpowers-marketplace",["tdd","debugging","plans","git-worktrees"])],skills:[],mcps:[vt("context7"),vt("playwright"),vt("whark-trading",!1)],memory:[At("Argusito"),At("mycelium"),At("vnido")]},Ej={tools:Ha.slice(0,4).map(e=>Pt(e.id,e.name)),plugins:Qr.slice(0,4).map(e=>oa(e.name,e.marketplace,[...e.skills],"extras"in e?e.extras:void 0)),skills:[It("custom-deploy",!0,["claude-code"]),It("lint-fix",!0,["claude-code","codex"])],mcps:[vt("context7"),vt("playwright"),vt("whark-trading",!1),vt("massive",!1),vt("supabase"),vt("github-mcp"),vt("linear")],memory:[At("Argusito"),At("mycelium"),At("vnido"),At("bytemines-io"),At("personal-notes","personal"),At("coding-standards","coding")]},Cj={tools:Ha.map(e=>Pt(e.id,e.name)),plugins:Qr.slice(0,7).map(e=>oa(e.name,e.marketplace,[...e.skills],"extras"in e?e.extras:void 0)),skills:[It("custom-deploy",!0,["claude-code"]),It("lint-fix",!0,["claude-code","codex"]),It("db-migrate",!0,["claude-code","opencode"]),It("api-scaffold",!0,["claude-code","gemini"]),It("perf-profile",!0,["claude-code"])],mcps:ja.slice(0,12).map((e,o)=>vt(e,o!==2&&o!==3&&o!==11)),memory:pl.slice(0,10).map(e=>At(e.name,e.scope))},Nj={tools:Ha.map(e=>Pt(e.id,e.name)),plugins:Qr.map(e=>oa(e.name,e.marketplace,[...e.skills],"extras"in e?e.extras:void 0)),skills:fl.map((e,o)=>{const a=Ha.map(s=>s.id),i=a.slice(0,Math.max(1,o%a.length+1));return It(e,!0,i)}),mcps:ja.map((e,o)=>vt(e,o%5!==0)),memory:pl.map(e=>At(e.name,e.scope))},zj={tools:[Pt("claude-code","Claude Code")],plugins:[oa("superpowers","superpowers-marketplace",["tdd","debugging"])],skills:[It("lint-fix",!0,["claude-code"])],mcps:[vt("context7",!0,["claude-code"]),vt("playwright",!0,["claude-code"])],memory:[At("project-a")]},Tj={tools:[Pt("claude-code","Claude Code"),Pt("codex","Codex CLI"),Pt("gemini","Gemini CLI")],plugins:[oa("superpowers","superpowers-marketplace",["tdd","debugging"])],skills:[It("claude-only-skill",!0,["claude-code"]),It("codex-only-skill",!0,["codex"]),It("gemini-only-skill",!0,["gemini"]),It("shared-skill",!0,["claude-code","codex","gemini"])],mcps:[vt("claude-mcp",!0,["claude-code"]),vt("codex-mcp",!0,["codex"]),vt("shared-mcp",!0,["claude-code","codex"]),vt("all-mcp",!0,["claude-code","codex","gemini"])],memory:[At("shared-mem"),At("coding-mem","coding"),At("personal-mem","personal")]},Aj={tools:[Pt("claude-code","Claude Code"),Pt("codex","Codex CLI")],plugins:[],skills:[],mcps:ja.map((e,o)=>vt(e,o%3!==0,o%2===0?["claude-code"]:["codex"])),memory:[At("project-a")]},Mj={tools:[Pt("claude-code","Claude Code"),Pt("codex","Codex CLI")],plugins:[],skills:[],mcps:[],memory:[]};function kj(e){let o=e;return()=>(o=o*1664525+1013904223&4294967295,(o>>>0)/4294967295)}function Oj(e){const o=kj(e.seed??Date.now()),a=Math.min(e.tools??2,Ha.length),i=e.mcps??3,s=e.memory??2,c=e.skills??0,u=e.plugins??2,d=e.disabledRatio??.2,p=Ha.slice(0,a).map(y=>y.id),m=y=>{const g=p[y%a],v=Math.max(1,Math.floor(o()*a)+1),S=[g];for(let w=1;w<v&&w<a;w++){const _=p[(y+w)%a];S.includes(_)||S.push(_)}return S};return{tools:Ha.slice(0,a).map(y=>Pt(y.id,y.name)),plugins:Array.from({length:u},(y,g)=>{const v=Qr[g%Qr.length],S=g<Qr.length?v.name:`${v.name}-${g}`,w=v.skills.slice(0,Math.max(1,Math.floor(o()*v.skills.length)+1));return oa(S,v.marketplace,[...w],"extras"in v?v.extras:void 0)}),skills:Array.from({length:c},(y,g)=>{const v=g<fl.length?fl[g]:`${fl[g%fl.length]}-${g}`;return It(v,o()>d,m(g))}),mcps:Array.from({length:i},(y,g)=>{const v=g<ja.length?ja[g]:`${ja[g%ja.length]}-${g}`;return vt(v,o()>d,m(g))}),memory:Array.from({length:s},(y,g)=>{const v=pl[g%pl.length],S=g<pl.length?v.name:`${v.name}-${g}`;return At(S,v.scope)})}}const Dj={small:_j,medium:Ej,large:Cj,xl:Nj,"single-tool":zj,radial:Tj,"heavy-mcp":Aj,empty:Mj};function jj(e){return Dj[e]??null}function Rj(){if(typeof window>"u")return null;const e=new URLSearchParams(window.location.search),o=e.get("debug");return o?o==="custom"?Oj({tools:parseInt(e.get("tools")??"2",10),mcps:parseInt(e.get("mcps")??"3",10),memory:parseInt(e.get("memory")??"2",10),skills:parseInt(e.get("skills")??"0",10),plugins:parseInt(e.get("plugins")??"2",10),disabledRatio:parseFloat(e.get("disabledRatio")??"0.2"),seed:e.has("seed")?parseInt(e.get("seed"),10):void 0}):jj(o):null}function Lj({status:e}){const o={synced:"bg-status-synced",pending:"bg-status-pending",error:"bg-status-error",disabled:"bg-status-disabled",not_installed:"bg-gray-700"};return x.jsx("span",{"data-testid":"status-indicator",className:Le("inline-block w-3 h-3 rounded-full",o[e])})}function Hj(){const{graphData:e,loading:o,error:a,apiStatus:i,fetchState:s,toggleResource:c,togglePlugin:u,setActiveTab:d,openPluginPanel:p,openMcpPanel:m,openSkillPanel:y}=$S();if(N.useEffect(()=>{s()},[i,s]),o)return x.jsx("div",{"data-testid":"graph-container",className:"h-full rounded-lg border bg-card/50 flex items-center justify-center",children:x.jsx("div",{"aria-live":"polite",className:"text-center text-muted-foreground",children:x.jsx("div",{className:"mb-2 text-lg",children:"Loading..."})})});if(a)return x.jsx("div",{"data-testid":"graph-container",className:"h-full rounded-lg border bg-card/50 flex items-center justify-center",children:x.jsxs("div",{"aria-live":"polite",className:"text-center text-muted-foreground",children:[x.jsx("div",{className:"mb-2 text-lg",children:"Cannot connect to API"}),x.jsxs("div",{className:"text-sm",children:["Start the server with ",x.jsx("code",{className:"bg-muted px-1 rounded",children:"mycelium serve"})]})]})});if(e&&!e.migrated&&e.skills.length===0&&e.mcps.length===0)return x.jsx("div",{"data-testid":"graph-container",className:"h-full rounded-lg border bg-card/50 flex items-center justify-center",children:x.jsxs("div",{className:"text-center",children:[x.jsx("div",{className:"mb-2 text-lg text-foreground",children:"No configuration detected"}),x.jsxs("div",{className:"mb-4 text-sm text-muted-foreground",children:["Run ",x.jsx("code",{className:"bg-muted px-1 rounded",children:"mycelium migrate --apply"})," to import your tool configs, then ",x.jsx("code",{className:"bg-muted px-1 rounded",children:"mycelium serve"})," to view them here."]}),x.jsx("button",{onClick:()=>d("migrate"),className:"rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90",children:"Scan Tools"})]})});const v=Rj()??e??{tools:[],skills:[],mcps:[],memory:[],plugins:[]};return x.jsx("div",{"data-testid":"graph-container",className:"h-full rounded-lg border bg-card/50",children:x.jsx(rm,{children:x.jsx(rS,{data:v,showUninstalledTools:!1,onToggle:c,onPluginToggle:u,onPluginClick:p,onMcpClick:m,onSkillClick:y})})})}function Uj(){const{activeTab:e,setActiveTab:o,selectedPlugin:a,setSelectedPlugin:i,apiStatus:s,checkApiStatus:c,hasPendingChanges:u,syncBanner:d,triggerSync:p,togglePlugin:m,togglePluginItem:y,removeItem:g,version:v}=$S();return N.useEffect(()=>{c()},[c]),x.jsxs("div",{className:"flex h-screen flex-col bg-background",children:[x.jsxs("header",{className:"relative flex items-center border-b px-4 py-2",children:[x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsxs("h1",{className:"flex items-center gap-2 text-lg font-bold tracking-tight",children:[x.jsx("span",{children:"🍄"}),x.jsx("span",{children:"MYCELIUM"}),x.jsx("span",{className:"ml-1 rounded-full bg-purple-500/20 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wider text-purple-400 border border-purple-500/30",children:"Beta"}),v&&x.jsxs("span",{className:"text-[10px] text-muted-foreground font-mono",children:["v",v]})]}),x.jsx(Lj,{status:s==="connected"?"synced":s==="checking"?"pending":"error"})]}),x.jsx("nav",{role:"tablist",className:"absolute left-1/2 -translate-x-1/2 flex gap-1 rounded-lg bg-muted p-0.5",children:["graph","migrate","marketplace"].map(S=>x.jsx("button",{role:"tab","aria-selected":e===S,onClick:()=>o(S),className:Le("rounded-md px-3 py-1 text-sm font-medium transition-colors",e===S?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:S.charAt(0).toUpperCase()+S.slice(1)},S))}),x.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[s!=="connected"&&x.jsx("span",{className:"text-xs text-muted-foreground",children:s==="checking"?"Connecting...":"API Offline"}),x.jsx("button",{onClick:p,className:Le("rounded-md px-3 py-1.5 text-sm font-medium transition-colors",u?"bg-yellow-500 text-black hover:bg-yellow-400 animate-pulse":"bg-primary text-primary-foreground hover:bg-primary/90"),children:u?"Sync (pending)":"Sync"})]})]}),d&&x.jsx("div",{"aria-live":"polite",className:Le("px-4 py-1.5 text-sm font-medium",d.type==="success"&&"bg-green-500/10 text-green-400",d.type==="pending"&&"bg-yellow-500/10 text-yellow-400",d.type==="error"&&"bg-red-500/10 text-red-400"),children:d.message}),x.jsxs("div",{className:"flex-1 overflow-hidden p-2",children:[e==="graph"&&x.jsx("section",{className:"h-full",children:x.jsx(Hj,{})}),e==="migrate"&&x.jsx("div",{className:"h-full overflow-y-auto p-4",children:x.jsx(D6,{})}),e==="marketplace"&&x.jsx("div",{className:"h-full overflow-y-auto p-4",children:x.jsx(vj,{})})]}),x.jsx(lS,{plugin:a,onClose:()=>i(null),onTogglePlugin:m,onToggleItem:y,onRemoveItem:g})]})}function Zj(){return x.jsx(Uj,{})}o_.createRoot(document.getElementById("root")).render(x.jsx(Oa.StrictMode,{children:x.jsx(Zj,{})}));
|