@mcp-use/inspector 0.26.0 → 0.26.1
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/cdn/inspector.js +12 -12
- package/dist/client/index.js +31 -31
- package/dist/web/assets/{browser-CqnU_bMs.js → browser-CUjguYn6.js} +3 -3
- package/dist/web/assets/{chunk-RJUJMGGE-Ckike6v2.js → chunk-6E445R5C-ny1rw8Le.js} +1 -1
- package/dist/web/assets/{chunk-RPN2XO5I-BsQOpC8p.js → chunk-RPN2XO5I-_4a18lz2.js} +1 -1
- package/dist/web/assets/{chunk_array-Drzz3Bxj.js → chunk_array-cMM4je5w.js} +1 -1
- package/dist/web/assets/{client-CnWipjEl.js → client-DEFMLVFC.js} +1 -1
- package/dist/web/assets/{client-2CASVELM-BYYvwD7E.js → client-S6L7XHLF-Dqmt1wRx.js} +3 -3
- package/dist/web/assets/{dist-DXjAPY-W.js → dist-BG8NAFfu.js} +1 -1
- package/dist/web/assets/{dist-CFOVbGE_.js → dist-CKth7ANk.js} +1 -1
- package/dist/web/assets/{dist-jBWD8iGG.js → dist-YxwKnKYL.js} +1 -1
- package/dist/web/assets/{function_calling-BLGGrcJY.js → function_calling-XyGNNvjR.js} +1 -1
- package/dist/web/assets/{index-DnLjyl1f.js → index-zqVFP8t5.js} +10 -10
- package/dist/web/assets/{llms-CUFNg0bG.js → llms-DmE4p8kW.js} +1 -1
- package/dist/web/assets/messages-DmWRSzWI.js +1 -0
- package/dist/web/assets/react-Cg35ZZKt.js +1 -0
- package/dist/web/assets/{rpc-logger-TPNV75J4-DaBpv6Xr.js → rpc-logger-TPNV75J4-BPgEimJH.js} +1 -1
- package/dist/web/assets/{stdio-IOUVQROQ-CeewE_Ia.js → stdio-LLTXMSZH-CQ-zxwTS.js} +1 -1
- package/dist/web/assets/{tools-Bn2uguc_.js → tools-DWDA-ZTt.js} +1 -1
- package/dist/web/index.html +4 -4
- package/package.json +4 -3
- package/dist/web/assets/messages-D9QOZWGX.js +0 -1
- package/dist/web/assets/react-DDmrI2D-.js +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/rpc-logger-TPNV75J4-
|
|
2
|
-
import{a as e,n as t,o as n,r,t as i}from"./chunk-zsgVPwQN.js";import{t as a}from"./chunk-3GQAWCBQ-C-9Cm0Np.js";import{n as o,t as s}from"./chunk-QWQYAQCK-CyFuZlX8.js";import{Et as c,Fn as l,Lt as u,S as d,Xn as f,Yn as p,dt as m,mn as h,rr as g,tr as _,ur as v,xn as y}from"./json-schema-processors-DSIsU0go.js";import{A as b,C as x,D as S,E as C,M as w,O as T,S as E,T as D,b as O,c as k,d as A,f as j,h as M,i as N,j as P,k as F,m as I,p as L,u as ee,v as te,w as R,x as z,y as ne}from"./client-CnWipjEl.js";import{a as re,c as ie,d as ae,l as oe,n as se,o as ce,s as le,t as ue,u as de}from"./chunk-RJUJMGGE-Ckike6v2.js";import{t as B}from"./preload-helper-XLr9-hSf.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var fe;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(fe||={});var pe;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(pe||={});var me=fe.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),V=e=>{switch(typeof e){case`undefined`:return me.undefined;case`string`:return me.string;case`number`:return Number.isNaN(e)?me.nan:me.number;case`boolean`:return me.boolean;case`function`:return me.function;case`bigint`:return me.bigint;case`symbol`:return me.symbol;case`object`:return Array.isArray(e)?me.array:e===null?me.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?me.promise:typeof Map<`u`&&e instanceof Map?me.map:typeof Set<`u`&&e instanceof Set?me.set:typeof Date<`u`&&e instanceof Date?me.date:me.object;default:return me.unknown}},H=fe.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),he=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,fe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t=Object.create(null),n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};he.create=e=>new he(e);var ge=(e,t)=>{let n;switch(e.code){case H.invalid_type:n=e.received===me.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case H.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,fe.jsonStringifyReplacer)}`;break;case H.unrecognized_keys:n=`Unrecognized key(s) in object: ${fe.joinValues(e.keys,`, `)}`;break;case H.invalid_union:n=`Invalid input`;break;case H.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${fe.joinValues(e.options)}`;break;case H.invalid_enum_value:n=`Invalid enum value. Expected ${fe.joinValues(e.options)}, received '${e.received}'`;break;case H.invalid_arguments:n=`Invalid function arguments`;break;case H.invalid_return_type:n=`Invalid function return type`;break;case H.invalid_date:n=`Invalid date`;break;case H.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:fe.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case H.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case H.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case H.custom:n=`Invalid input`;break;case H.invalid_intersection_types:n=`Intersection results could not be merged`;break;case H.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case H.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,fe.assertNever(e)}return{message:n}},_e=ge;function ve(){return _e}var ye=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function U(e,t){let n=ve(),r=ye({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===ge?void 0:ge].filter(e=>!!e)});e.common.issues.push(r)}var be=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return xe;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return xe;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}},xe=Object.freeze({status:`aborted`}),Se=e=>({status:`dirty`,value:e}),Ce=e=>({status:`valid`,value:e}),we=e=>e.status===`aborted`,Te=e=>e.status===`dirty`,Ee=e=>e.status===`valid`,De=e=>typeof Promise<`u`&&e instanceof Promise,Oe;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(Oe||={});var ke=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Ae=(e,t)=>{if(Ee(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){return this._error||=new he(e.common.issues),this._error}}};function je(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var Me=class{get description(){return this._def.description}_getType(e){return V(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:V(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new be,ctx:{common:e.parent.common,data:e.data,parsedType:V(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(De(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:V(e)};return Ae(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:V(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return Ee(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>Ee(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:V(e)},r=this._parse({data:e,path:n.path,parent:n});return Ae(n,await(De(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:H.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new Pt({schema:this,typeName:Gt.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return Ft.create(this,this._def)}nullable(){return It.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ht.create(this)}promise(){return Nt.create(this,this._def)}or(e){return vt.create([this,e],this._def)}and(e){return St.create(this,e,this._def)}transform(e){return new Pt({...je(this._def),schema:this,typeName:Gt.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new Lt({...je(this._def),innerType:this,defaultValue:t,typeName:Gt.ZodDefault})}brand(){return new Bt({typeName:Gt.ZodBranded,type:this,...je(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new Rt({...je(this._def),innerType:this,catchValue:t,typeName:Gt.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Vt.create(this,e)}readonly(){return Ht.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Ne=/^c[^\s-]{8,}$/i,Pe=/^[0-9a-z]+$/,Fe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ie=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Le=/^[a-z0-9_-]{21}$/i,Re=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ze=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Be=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ve=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,He,Ue=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,W=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,We=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Ge=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ke=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,qe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Je=`((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`,Ye=RegExp(`^${Je}$`);function Xe(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function Ze(e){return RegExp(`^${Xe(e)}$`)}function Qe(e){let t=`${Je}T${Xe(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function $e(e,t){return!!((t===`v4`||!t)&&Ue.test(e)||(t===`v6`||!t)&&We.test(e))}function et(e,t){if(!Re.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function tt(e,t){return!!((t===`v4`||!t)&&W.test(e)||(t===`v6`||!t)&&Ge.test(e))}var nt=class e extends Me{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==me.string){let t=this._getOrReturnCtx(e);return U(t,{code:H.invalid_type,expected:me.string,received:t.parsedType}),xe}let t=new be,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),U(n,{code:H.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),U(n,{code:H.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?U(n,{code:H.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&U(n,{code:H.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)Be.test(e.data)||(n=this._getOrReturnCtx(e,n),U(n,{validation:`email`,code:H.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)He||=new RegExp(Ve,`u`),He.test(e.data)||(n=this._getOrReturnCtx(e,n),U(n,{validation:`emoji`,code:H.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)Ie.test(e.data)||(n=this._getOrReturnCtx(e,n),U(n,{validation:`uuid`,code:H.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)Le.test(e.data)||(n=this._getOrReturnCtx(e,n),U(n,{validation:`nanoid`,code:H.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)Ne.test(e.data)||(n=this._getOrReturnCtx(e,n),U(n,{validation:`cuid`,code:H.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)Pe.test(e.data)||(n=this._getOrReturnCtx(e,n),U(n,{validation:`cuid2`,code:H.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)Fe.test(e.data)||(n=this._getOrReturnCtx(e,n),U(n,{validation:`ulid`,code:H.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),U(n,{validation:`url`,code:H.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),U(n,{validation:`regex`,code:H.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),U(n,{code:H.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),U(n,{code:H.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),U(n,{code:H.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?Qe(r).test(e.data)||(n=this._getOrReturnCtx(e,n),U(n,{code:H.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?Ye.test(e.data)||(n=this._getOrReturnCtx(e,n),U(n,{code:H.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?Ze(r).test(e.data)||(n=this._getOrReturnCtx(e,n),U(n,{code:H.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?ze.test(e.data)||(n=this._getOrReturnCtx(e,n),U(n,{validation:`duration`,code:H.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?$e(e.data,r.version)||(n=this._getOrReturnCtx(e,n),U(n,{validation:`ip`,code:H.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?et(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),U(n,{validation:`jwt`,code:H.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?tt(e.data,r.version)||(n=this._getOrReturnCtx(e,n),U(n,{validation:`cidr`,code:H.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?Ke.test(e.data)||(n=this._getOrReturnCtx(e,n),U(n,{validation:`base64`,code:H.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?qe.test(e.data)||(n=this._getOrReturnCtx(e,n),U(n,{validation:`base64url`,code:H.invalid_string,message:r.message}),t.dirty()):fe.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:H.invalid_string,...Oe.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...Oe.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...Oe.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...Oe.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...Oe.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...Oe.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...Oe.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...Oe.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...Oe.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...Oe.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...Oe.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...Oe.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...Oe.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...Oe.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...Oe.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...Oe.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...Oe.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...Oe.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...Oe.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...Oe.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...Oe.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...Oe.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...Oe.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...Oe.errToObj(t)})}nonempty(e){return this.min(1,Oe.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};nt.create=e=>new nt({checks:[],typeName:Gt.ZodString,coerce:e?.coerce??!1,...je(e)});function rt(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var it=class e extends Me{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==me.number){let t=this._getOrReturnCtx(e);return U(t,{code:H.invalid_type,expected:me.number,received:t.parsedType}),xe}let t,n=new be;for(let r of this._def.checks)r.kind===`int`?fe.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),U(t,{code:H.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),U(t,{code:H.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),U(t,{code:H.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?rt(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),U(t,{code:H.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),U(t,{code:H.not_finite,message:r.message}),n.dirty()):fe.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,Oe.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,Oe.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,Oe.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,Oe.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Oe.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:Oe.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:Oe.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:Oe.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:Oe.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:Oe.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:Oe.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:Oe.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:Oe.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:Oe.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&fe.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};it.create=e=>new it({checks:[],typeName:Gt.ZodNumber,coerce:e?.coerce||!1,...je(e)});var at=class e extends Me{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==me.bigint)return this._getInvalidInput(e);let t,n=new be;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),U(t,{code:H.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),U(t,{code:H.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),U(t,{code:H.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):fe.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return U(t,{code:H.invalid_type,expected:me.bigint,received:t.parsedType}),xe}gte(e,t){return this.setLimit(`min`,e,!0,Oe.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,Oe.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,Oe.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,Oe.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Oe.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:Oe.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:Oe.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:Oe.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:Oe.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:Oe.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};at.create=e=>new at({checks:[],typeName:Gt.ZodBigInt,coerce:e?.coerce??!1,...je(e)});var ot=class extends Me{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==me.boolean){let t=this._getOrReturnCtx(e);return U(t,{code:H.invalid_type,expected:me.boolean,received:t.parsedType}),xe}return Ce(e.data)}};ot.create=e=>new ot({typeName:Gt.ZodBoolean,coerce:e?.coerce||!1,...je(e)});var st=class e extends Me{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==me.date){let t=this._getOrReturnCtx(e);return U(t,{code:H.invalid_type,expected:me.date,received:t.parsedType}),xe}if(Number.isNaN(e.data.getTime()))return U(this._getOrReturnCtx(e),{code:H.invalid_date}),xe;let t=new be,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),U(n,{code:H.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),U(n,{code:H.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):fe.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:Oe.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:Oe.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};st.create=e=>new st({checks:[],coerce:e?.coerce||!1,typeName:Gt.ZodDate,...je(e)});var ct=class extends Me{_parse(e){if(this._getType(e)!==me.symbol){let t=this._getOrReturnCtx(e);return U(t,{code:H.invalid_type,expected:me.symbol,received:t.parsedType}),xe}return Ce(e.data)}};ct.create=e=>new ct({typeName:Gt.ZodSymbol,...je(e)});var lt=class extends Me{_parse(e){if(this._getType(e)!==me.undefined){let t=this._getOrReturnCtx(e);return U(t,{code:H.invalid_type,expected:me.undefined,received:t.parsedType}),xe}return Ce(e.data)}};lt.create=e=>new lt({typeName:Gt.ZodUndefined,...je(e)});var ut=class extends Me{_parse(e){if(this._getType(e)!==me.null){let t=this._getOrReturnCtx(e);return U(t,{code:H.invalid_type,expected:me.null,received:t.parsedType}),xe}return Ce(e.data)}};ut.create=e=>new ut({typeName:Gt.ZodNull,...je(e)});var dt=class extends Me{constructor(){super(...arguments),this._any=!0}_parse(e){return Ce(e.data)}};dt.create=e=>new dt({typeName:Gt.ZodAny,...je(e)});var ft=class extends Me{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ce(e.data)}};ft.create=e=>new ft({typeName:Gt.ZodUnknown,...je(e)});var pt=class extends Me{_parse(e){let t=this._getOrReturnCtx(e);return U(t,{code:H.invalid_type,expected:me.never,received:t.parsedType}),xe}};pt.create=e=>new pt({typeName:Gt.ZodNever,...je(e)});var mt=class extends Me{_parse(e){if(this._getType(e)!==me.undefined){let t=this._getOrReturnCtx(e);return U(t,{code:H.invalid_type,expected:me.void,received:t.parsedType}),xe}return Ce(e.data)}};mt.create=e=>new mt({typeName:Gt.ZodVoid,...je(e)});var ht=class e extends Me{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==me.array)return U(t,{code:H.invalid_type,expected:me.array,received:t.parsedType}),xe;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(U(t,{code:e?H.too_big:H.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(U(t,{code:H.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(U(t,{code:H.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new ke(t,e,t.path,n)))).then(e=>be.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new ke(t,e,t.path,n)));return be.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:Oe.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:Oe.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:Oe.toString(n)}})}nonempty(e){return this.min(1,e)}};ht.create=(e,t)=>new ht({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Gt.ZodArray,...je(t)});function gt(e){if(e instanceof _t){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=Ft.create(gt(r))}return new _t({...e._def,shape:()=>t})}else if(e instanceof ht)return new ht({...e._def,type:gt(e.element)});else if(e instanceof Ft)return Ft.create(gt(e.unwrap()));else if(e instanceof It)return It.create(gt(e.unwrap()));else if(e instanceof Ct)return Ct.create(e.items.map(e=>gt(e)));else return e}var _t=class e extends Me{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape();return this._cached={shape:e,keys:fe.objectKeys(e)},this._cached}_parse(e){if(this._getType(e)!==me.object){let t=this._getOrReturnCtx(e);return U(t,{code:H.invalid_type,expected:me.object,received:t.parsedType}),xe}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof pt&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new ke(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof pt){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(U(n,{code:H.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new ke(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>be.mergeObjectSync(t,e)):be.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return Oe.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:Oe.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Gt.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of fe.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of fe.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return gt(this)}partial(t){let n={};for(let e of fe.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of fe.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof Ft;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return At(fe.objectKeys(this.shape))}};_t.create=(e,t)=>new _t({shape:()=>e,unknownKeys:`strip`,catchall:pt.create(),typeName:Gt.ZodObject,...je(t)}),_t.strictCreate=(e,t)=>new _t({shape:()=>e,unknownKeys:`strict`,catchall:pt.create(),typeName:Gt.ZodObject,...je(t)}),_t.lazycreate=(e,t)=>new _t({shape:e,unknownKeys:`strip`,catchall:pt.create(),typeName:Gt.ZodObject,...je(t)});var vt=class extends Me{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new he(e.ctx.common.issues));return U(t,{code:H.invalid_union,unionErrors:n}),xe}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new he(e));return U(t,{code:H.invalid_union,unionErrors:i}),xe}}get options(){return this._def.options}};vt.create=(e,t)=>new vt({options:e,typeName:Gt.ZodUnion,...je(t)});var yt=e=>e instanceof Ot?yt(e.schema):e instanceof Pt?yt(e.innerType()):e instanceof kt?[e.value]:e instanceof jt?e.options:e instanceof Mt?fe.objectValues(e.enum):e instanceof Lt?yt(e._def.innerType):e instanceof lt?[void 0]:e instanceof ut?[null]:e instanceof Ft?[void 0,...yt(e.unwrap())]:e instanceof It?[null,...yt(e.unwrap())]:e instanceof Bt||e instanceof Ht?yt(e.unwrap()):e instanceof Rt?yt(e._def.innerType):[],bt=class e extends Me{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==me.object)return U(t,{code:H.invalid_type,expected:me.object,received:t.parsedType}),xe;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(U(t,{code:H.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),xe)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=yt(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:Gt.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...je(r)})}};function xt(e,t){let n=V(e),r=V(t);if(e===t)return{valid:!0,data:e};if(n===me.object&&r===me.object){let n=fe.objectKeys(t),r=fe.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=xt(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===me.array&&r===me.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=xt(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===me.date&&r===me.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var St=class extends Me{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(we(e)||we(r))return xe;let i=xt(e.value,r.value);return i.valid?((Te(e)||Te(r))&&t.dirty(),{status:t.value,value:i.data}):(U(n,{code:H.invalid_intersection_types}),xe)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};St.create=(e,t,n)=>new St({left:e,right:t,typeName:Gt.ZodIntersection,...je(n)});var Ct=class e extends Me{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==me.array)return U(n,{code:H.invalid_type,expected:me.array,received:n.parsedType}),xe;if(n.data.length<this._def.items.length)return U(n,{code:H.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),xe;!this._def.rest&&n.data.length>this._def.items.length&&(U(n,{code:H.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new ke(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>be.mergeArray(t,e)):be.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Ct.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new Ct({items:e,typeName:Gt.ZodTuple,rest:null,...je(t)})};var wt=class e extends Me{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==me.object)return U(n,{code:H.invalid_type,expected:me.object,received:n.parsedType}),xe;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new ke(n,e,n.path,e)),value:a._parse(new ke(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?be.mergeObjectAsync(t,r):be.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof Me?new e({keyType:t,valueType:n,typeName:Gt.ZodRecord,...je(r)}):new e({keyType:nt.create(),valueType:t,typeName:Gt.ZodRecord,...je(n)})}},Tt=class extends Me{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==me.map)return U(n,{code:H.invalid_type,expected:me.map,received:n.parsedType}),xe;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new ke(n,e,n.path,[a,`key`])),value:i._parse(new ke(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return xe;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return xe;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};Tt.create=(e,t,n)=>new Tt({valueType:t,keyType:e,typeName:Gt.ZodMap,...je(n)});var Et=class e extends Me{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==me.set)return U(n,{code:H.invalid_type,expected:me.set,received:n.parsedType}),xe;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(U(n,{code:H.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(U(n,{code:H.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return xe;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new ke(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:Oe.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:Oe.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Et.create=(e,t)=>new Et({valueType:e,minSize:null,maxSize:null,typeName:Gt.ZodSet,...je(t)});var Dt=class e extends Me{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==me.function)return U(t,{code:H.invalid_type,expected:me.function,received:t.parsedType}),xe;function n(e,n){return ye({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ve(),ge].filter(e=>!!e),issueData:{code:H.invalid_arguments,argumentsError:n}})}function r(e,n){return ye({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ve(),ge].filter(e=>!!e),issueData:{code:H.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof Nt){let e=this;return Ce(async function(...t){let o=new he([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return Ce(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new he([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new he([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Ct.create(t).rest(ft.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||Ct.create([]).rest(ft.create()),returns:n||ft.create(),typeName:Gt.ZodFunction,...je(r)})}},Ot=class extends Me{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Ot.create=(e,t)=>new Ot({getter:e,typeName:Gt.ZodLazy,...je(t)});var kt=class extends Me{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return U(t,{received:t.data,code:H.invalid_literal,expected:this._def.value}),xe}return{status:`valid`,value:e.data}}get value(){return this._def.value}};kt.create=(e,t)=>new kt({value:e,typeName:Gt.ZodLiteral,...je(t)});function At(e,t){return new jt({values:e,typeName:Gt.ZodEnum,...je(t)})}var jt=class e extends Me{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return U(t,{expected:fe.joinValues(n),received:t.parsedType,code:H.invalid_type}),xe}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return U(t,{received:t.data,code:H.invalid_enum_value,options:n}),xe}return Ce(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};jt.create=At;var Mt=class extends Me{_parse(e){let t=fe.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==me.string&&n.parsedType!==me.number){let e=fe.objectValues(t);return U(n,{expected:fe.joinValues(e),received:n.parsedType,code:H.invalid_type}),xe}if(this._cache||=new Set(fe.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=fe.objectValues(t);return U(n,{received:n.data,code:H.invalid_enum_value,options:e}),xe}return Ce(e.data)}get enum(){return this._def.values}};Mt.create=(e,t)=>new Mt({values:e,typeName:Gt.ZodNativeEnum,...je(t)});var Nt=class extends Me{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==me.promise&&t.common.async===!1?(U(t,{code:H.invalid_type,expected:me.promise,received:t.parsedType}),xe):Ce((t.parsedType===me.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Nt.create=(e,t)=>new Nt({type:e,typeName:Gt.ZodPromise,...je(t)});var Pt=class extends Me{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Gt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{U(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return xe;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?xe:r.status===`dirty`||t.value===`dirty`?Se(r.value):r});{if(t.value===`aborted`)return xe;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?xe:r.status===`dirty`||t.value===`dirty`?Se(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?xe:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?xe:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Ee(e))return xe;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>Ee(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):xe);fe.assertNever(r)}};Pt.create=(e,t,n)=>new Pt({schema:e,typeName:Gt.ZodEffects,effect:t,...je(n)}),Pt.createWithPreprocess=(e,t,n)=>new Pt({schema:t,effect:{type:`preprocess`,transform:e},typeName:Gt.ZodEffects,...je(n)});var Ft=class extends Me{_parse(e){return this._getType(e)===me.undefined?Ce(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ft.create=(e,t)=>new Ft({innerType:e,typeName:Gt.ZodOptional,...je(t)});var It=class extends Me{_parse(e){return this._getType(e)===me.null?Ce(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};It.create=(e,t)=>new It({innerType:e,typeName:Gt.ZodNullable,...je(t)});var Lt=class extends Me{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===me.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Lt.create=(e,t)=>new Lt({innerType:e,typeName:Gt.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...je(t)});var Rt=class extends Me{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return De(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new he(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new he(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Rt.create=(e,t)=>new Rt({innerType:e,typeName:Gt.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...je(t)});var zt=class extends Me{_parse(e){if(this._getType(e)!==me.nan){let t=this._getOrReturnCtx(e);return U(t,{code:H.invalid_type,expected:me.nan,received:t.parsedType}),xe}return{status:`valid`,value:e.data}}};zt.create=e=>new zt({typeName:Gt.ZodNaN,...je(e)});var Bt=class extends Me{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},Vt=class e extends Me{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?xe:e.status===`dirty`?(t.dirty(),Se(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?xe:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:Gt.ZodPipeline})}},Ht=class extends Me{_parse(e){let t=this._def.innerType._parse(e),n=e=>(Ee(e)&&(e.value=Object.freeze(e.value)),e);return De(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};Ht.create=(e,t)=>new Ht({innerType:e,typeName:Gt.ZodReadonly,...je(t)});function Ut(e,t){let n=typeof e==`function`?e(t):typeof e==`string`?{message:e}:e;return typeof n==`string`?{message:n}:n}function Wt(e,t={},n){return e?dt.create().superRefine((r,i)=>{let a=e(r);if(a instanceof Promise)return a.then(e=>{if(!e){let e=Ut(t,r),a=e.fatal??n??!0;i.addIssue({code:`custom`,...e,fatal:a})}});if(!a){let e=Ut(t,r),a=e.fatal??n??!0;i.addIssue({code:`custom`,...e,fatal:a})}}):dt.create()}_t.lazycreate;var Gt;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(Gt||={});var Kt=(e,t={message:`Input not instance of ${e.name}`})=>Wt(t=>t instanceof e,t),qt=nt.create,Jt=it.create;zt.create,at.create;var Yt=ot.create;st.create,ct.create,lt.create,ut.create;var Xt=dt.create;ft.create,pt.create,mt.create;var Zt=ht.create,Qt=_t.create;_t.strictCreate;var $t=vt.create;bt.create,St.create,Ct.create;var en=wt.create;Tt.create,Et.create;var tn=Dt.create;Ot.create;var nn=kt.create,rn=jt.create;Mt.create;var an=Nt.create;Pt.create,Ft.create,It.create,Pt.createWithPreprocess,Vt.create;function on(e){let t=Object.keys(e.mcpServers??{});N.getInstance().trackMCPClientInit({codeMode:!1,sandbox:!1,allCallbacks:!1,verify:!1,servers:t,numServers:t.length,isBrowser:!0}).catch(e=>o.debug(`Failed to track BrowserMCPClient init: ${e}`))}a(on,`trackBrowserClientInit`);var sn=class e extends ue{static{a(this,`BrowserMCPClient`)}static getPackageVersion(){return k()}constructor(e){super(e),on(this.config)}static fromDict(t){return new e(t)}createConnectorFromConfig(e){let{url:t,headers:n,fetch:r,authToken:i,authProvider:a,wrapTransport:s,clientOptions:c,disableSseFallback:l,preferSse:u,timeout:d,sseReadTimeout:f,gatewayUrl:p,serverId:m,reconnectionOptions:h}=e;if(!t)throw Error(`Server URL is required`);let g=this.config,_=ce(e,g),v=re(e.clientInfo??this.config.clientInfo),y={headers:n,fetch:r,authToken:i,authProvider:a,wrapTransport:s,clientOptions:c,onSampling:_.onSampling,onElicitation:_.onElicitation,onNotification:_.onNotification,disableSseFallback:l,preferSse:u,timeout:d,sseReadTimeout:f,clientInfo:v,gatewayUrl:p,serverId:m,reconnectionOptions:h};return o.debug(`[BrowserMCPClient] Connector options prepared (clientOptions: ${c?`provided`:`none`})`),new se(t,y)}};function cn(e){let t=a(()=>{throw Error(`Invalid url to pass to open(): ${e}`)},`abort`),n;try{n=new URL(e)}catch{t()}return n.protocol!==`https:`&&n.protocol!==`http:`&&t(),n.hostname!==encodeURIComponent(n.hostname)&&t(),n.username&&=encodeURIComponent(n.username),n.password&&=encodeURIComponent(n.password),n.pathname=n.pathname.slice(0,1)+encodeURIComponent(n.pathname.slice(1)).replace(/%2f/gi,`/`),n.search=n.search.slice(0,1)+Array.from(n.searchParams.entries()).map(ln).join(`&`),n.hash=n.hash.slice(0,1)+encodeURIComponent(n.hash.slice(1)),n.href}a(cn,`sanitizeUrl`);function ln([e,t]){return`${encodeURIComponent(e)}${t.length>0?`=${encodeURIComponent(t)}`:``}`}a(ln,`sanitizeParam`);async function un(e){return typeof e==`string`?e:e instanceof URLSearchParams||e instanceof FormData?Object.fromEntries(e.entries()):e instanceof Blob?await e.text():e}a(un,`serializeBody`);var dn=class{static{a(this,`BrowserOAuthClientProvider`)}serverUrl;storageKeyPrefix;serverUrlHash;clientName;clientUri;logoUri;callbackUrl;preventAutoAuth;useRedirectFlow;oauthProxyUrl;connectionUrl;originalFetch;pendingCodeVerifier=null;_lastOriginalResource=null;_cachedAuthServerUrl=null;_cachedMetadata=null;_refreshPromise=null;onPopupWindow;constructor(e,t={}){this.serverUrl=e,this.storageKeyPrefix=t.storageKeyPrefix||`mcp:auth`,this.serverUrlHash=this.hashString(e),this.clientName=t.clientName||`mcp-use`,this.clientUri=t.clientUri||(typeof window<`u`?window.location.origin:``),this.logoUri=t.logoUri||`https://mcp-use.com/logo.png`,this.callbackUrl=cn(t.callbackUrl||(typeof window<`u`?new URL(`/oauth/callback`,window.location.origin).toString():`/oauth/callback`)),this.preventAutoAuth=t.preventAutoAuth,this.useRedirectFlow=t.useRedirectFlow,this.oauthProxyUrl=t.oauthProxyUrl,this.connectionUrl=t.connectionUrl,this.onPopupWindow=t.onPopupWindow}installFetchInterceptor(){if(!this.oauthProxyUrl){console.warn(`[BrowserOAuthProvider] No OAuth proxy URL configured, skipping fetch interceptor installation`);return}if(!this.originalFetch)this.originalFetch=window.fetch;else{console.warn(`[BrowserOAuthProvider] Fetch interceptor already installed`);return}let e=this.oauthProxyUrl,t=this.connectionUrl,n=this.serverUrl,r=this.originalFetch;console.log(`[BrowserOAuthProvider] Installing fetch interceptor with proxy: ${e}`),window.fetch=async(i,a)=>{let o=typeof i==`string`?i:i instanceof URL?i.toString():i.url;if(!(o.includes(`/.well-known/`)||o.match(/\/(register|token|authorize)$/)))return await r(i,a);try{let t=new URL(o),n=new URL(e);if(t.origin===n.origin&&(t.pathname.startsWith(n.pathname)||o.includes(`/inspector/api/oauth`)))return await r(i,a)}catch{}try{let i=o.includes(`/.well-known/`),s=i?`${e}/metadata?url=${encodeURIComponent(o)}`:`${e}/proxy`;if(console.log(`[OAuth Proxy] Routing ${i?`metadata`:`request`} through: ${s}`),i){let e={...a?.headers?Object.fromEntries(new Headers(a.headers)):{}};t&&(e[`X-Connection-URL`]=t);let i=new URL(s);n&&i.searchParams.set(`mcp_url`,n);let o=await r(i.toString(),{...a,method:`GET`,headers:e});try{if((o.headers.get(`content-type`)||``).includes(`application/json`)){let e=await o.clone().json(),t=e&&typeof e==`object`&&typeof e._original_resource==`string`?e._original_resource:null;t&&(this._lastOriginalResource=t)}}catch{}return o}let c=a?.body?await un(a.body):void 0,l=await(await r(s,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:o,method:a?.method||`POST`,headers:a?.headers?Object.fromEntries(new Headers(a.headers)):{},body:c})})).json();return new Response(JSON.stringify(l.body),{status:l.status,statusText:l.statusText,headers:new Headers(l.headers)})}catch(e){return console.error(`[OAuth Proxy] Request failed, falling back to direct fetch:`,e),await r(i,a)}}}restoreFetch(){this.originalFetch&&=(console.log(`[BrowserOAuthProvider] Restoring original fetch`),window.fetch=this.originalFetch,void 0)}get redirectUrl(){return cn(this.callbackUrl)}get clientMetadata(){return{redirect_uris:[this.redirectUrl],token_endpoint_auth_method:`none`,grant_types:[`authorization_code`,`refresh_token`],response_types:[`code`],client_name:this.clientName,client_uri:this.clientUri,logo_uri:this.logoUri}}async clientInformation(){let e=this.getKey(`client_info`),t=localStorage.getItem(e);if(t)try{let n=JSON.parse(t),r=Array.isArray(n.redirect_uris)?n.redirect_uris:[];if(!(r.length===0||r.includes(this.redirectUrl))){console.info(`[${this.storageKeyPrefix}] Invalidating cached OAuth client info due to redirect URI mismatch.`),localStorage.removeItem(e),localStorage.removeItem(this.getKey(`tokens`)),localStorage.removeItem(this.getKey(`last_auth_url`));return}return n}catch(t){console.warn(`[${this.storageKeyPrefix}] Failed to parse client information:`,t),localStorage.removeItem(e);return}}async saveClientInformation(e){let t=this.getKey(`client_info`);localStorage.setItem(t,JSON.stringify(e))}async tokens(){let e=this.getKey(`tokens`),t=localStorage.getItem(e);if(t)try{let e=JSON.parse(t);if(e.access_token&&e.refresh_token)try{let t=JSON.parse(atob(e.access_token.split(`.`)[1]));if(t.exp&&Date.now()>=(t.exp-30)*1e3){console.log(`[tokens] Access token expiring soon, refreshing...`);let t=await this._dedupedRefresh(e);if(t)return console.log(`[tokens] Refreshed successfully`),t}}catch{}return e}catch(t){console.warn(`[${this.storageKeyPrefix}] Failed to parse tokens:`,t),localStorage.removeItem(e);return}}async saveTokens(e){let t=this.getKey(`tokens`);localStorage.setItem(t,JSON.stringify(e)),localStorage.removeItem(this.getKey(`code_verifier`)),localStorage.removeItem(this.getKey(`last_auth_url`)),this.pendingCodeVerifier=null}async _refresh(e){try{if(!this._cachedAuthServerUrl||!this._cachedMetadata){let e=(await oe(this.serverUrl)).authorization_servers?.[0];if(!e)return null;let t=await ie(e);if(!t)return null;this._cachedAuthServerUrl=e,this._cachedMetadata=t}let t=await this.clientInformation();if(!t)return null;let n=await ae(this._cachedAuthServerUrl,{metadata:this._cachedMetadata,clientInformation:t,refreshToken:e.refresh_token});return await this.saveTokens(n),n}catch{return null}}async _dedupedRefresh(e){if(this._refreshPromise)return this._refreshPromise;this._refreshPromise=this._refresh(e);try{return await this._refreshPromise}finally{this._refreshPromise=null}}async invalidateCredentials(e){switch(e){case`all`:localStorage.removeItem(this.getKey(`tokens`)),localStorage.removeItem(this.getKey(`client_info`)),localStorage.removeItem(this.getKey(`code_verifier`)),localStorage.removeItem(this.getKey(`last_auth_url`)),this.pendingCodeVerifier=null;break;case`client`:localStorage.removeItem(this.getKey(`client_info`));break;case`tokens`:localStorage.removeItem(this.getKey(`tokens`));break;case`verifier`:localStorage.removeItem(this.getKey(`code_verifier`)),this.pendingCodeVerifier=null;break;default:break}}async saveCodeVerifier(e){let t=this.getKey(`code_verifier`);localStorage.setItem(t,e),this.pendingCodeVerifier=e}async codeVerifier(){let e=this.getKey(`code_verifier`),t=localStorage.getItem(e);if(!t)throw Error(`[${this.storageKeyPrefix}] Code verifier not found in storage for key ${e}. Auth flow likely corrupted or timed out.`);return t}async prepareAuthorizationUrl(e){let t=e.searchParams.get(`resource`),n=!!(t&&(t.includes(`/inspector/api/proxy`)||t.includes(`/api/proxy`)||t.includes(`localhost:3000`))),r=!!(t&&this.connectionUrl&&t===this.connectionUrl),i=!!(t&&(this._lastOriginalResource||this.serverUrl)&&(r||n)),a=this._lastOriginalResource||this.serverUrl;i&&a&&e.searchParams.set(`resource`,a);let o=globalThis.crypto.randomUUID(),s=`${this.storageKeyPrefix}:state_${o}`,c=this.pendingCodeVerifier||localStorage.getItem(this.getKey(`code_verifier`)),l={serverUrlHash:this.serverUrlHash,expiry:Date.now()+1e3*60*10,codeVerifier:c||void 0,providerOptions:{serverUrl:this.serverUrl,storageKeyPrefix:this.storageKeyPrefix,clientName:this.clientName,clientUri:this.clientUri,callbackUrl:this.callbackUrl,oauthProxyUrl:this.oauthProxyUrl,connectionUrl:this.connectionUrl},flowType:this.useRedirectFlow?`redirect`:`popup`,returnUrl:typeof window<`u`?window.location.href:void 0};console.log(`[OAuth] Storing state key: ${s}`),localStorage.setItem(s,JSON.stringify(l));let u=localStorage.getItem(s);console.log(`[OAuth] State stored successfully: ${!!u}`),e.searchParams.set(`state`,o);let d=cn(e.toString());return localStorage.setItem(this.getKey(`last_auth_url`),d),d}async redirectToAuthorization(e){let t=await this.prepareAuthorizationUrl(e);if(this.preventAutoAuth){console.info(`[${this.storageKeyPrefix}] Auto-auth prevented. Authorization URL stored for manual trigger.`);return}if(this.useRedirectFlow){console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL (full-page redirect).`),window.location.href=t;return}let n=`width=600,height=700,resizable=yes,scrollbars=yes,status=yes`;try{let e=window.open(t,`mcp_auth_${this.serverUrlHash}`,n);this.onPopupWindow&&this.onPopupWindow(t,n,e),!e||e.closed||e.closed===void 0?console.warn(`[${this.storageKeyPrefix}] Popup likely blocked by browser. Manual navigation might be required using the stored URL.`):(e.focus(),console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL in popup.`))}catch(e){console.error(`[${this.storageKeyPrefix}] Error opening popup window:`,e)}}getLastAttemptedAuthUrl(){let e=localStorage.getItem(this.getKey(`last_auth_url`));return e?cn(e):null}clearStorage(){let e=`${this.storageKeyPrefix}_${this.serverUrlHash}_`,t=`${this.storageKeyPrefix}:state_`,n=[],r=0;for(let r=0;r<localStorage.length;r++){let i=localStorage.key(r);if(i){if(i.startsWith(e))n.push(i);else if(i.startsWith(t))try{let e=localStorage.getItem(i);e&&JSON.parse(e).serverUrlHash===this.serverUrlHash&&n.push(i)}catch(e){console.warn(`[${this.storageKeyPrefix}] Error parsing state key ${i} during clearStorage:`,e)}}}return[...new Set(n)].forEach(e=>{localStorage.removeItem(e),r++}),r}hashString(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return Math.abs(t).toString(16)}getKey(e){return`${this.storageKeyPrefix}_${this.serverUrlHash}_${e}`}};async function fn(){let e=new URLSearchParams(window.location.search),t=e.get(`code`),n=e.get(`state`),r=e.get(`error`),i=e.get(`error_description`),a=`[mcp-callback]`;console.log(`${a} Handling callback...`,{code:t,state:n,error:r,errorDescription:i});let o=null,s=null,c=null;try{if(r)throw Error(`OAuth error: ${r} - ${i||`No description provided.`}`);if(!t)throw Error(`Authorization code not found in callback query parameters.`);if(!n)throw Error(`State parameter not found or invalid in callback query parameters.`);console.log(`[mcp-callback] Looking for state: ${n}`),console.log(`[mcp-callback] All localStorage keys:`,Object.keys(localStorage));let e=`mcp:auth:state_${n}`;if(localStorage.getItem(e))c=e,console.log(`[mcp-callback] Found state with default key: ${e}`);else{let e=`:state_${n}`;for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n&&n.endsWith(e)){c=n,console.log(`[mcp-callback] Found state with dynamic key: ${n}`);break}}}if(!c){let e=Object.keys(localStorage).filter(e=>e.includes(`state`));throw console.log(`[mcp-callback] State keys in storage:`,e),Error(`Invalid or expired state parameter "${n}". No matching state found in storage.`)}let l=localStorage.getItem(c);if(!l)throw Error(`Invalid or expired state parameter "${n}". No matching state found in storage.`);try{s=JSON.parse(l)}catch{throw Error(`Failed to parse stored OAuth state.`)}if(!s.expiry||s.expiry<Date.now())throw localStorage.removeItem(c),Error(`OAuth state has expired. Please try initiating authentication again.`);if(!s.providerOptions)throw Error(`Stored state is missing required provider options.`);let{serverUrl:u,...d}=s.providerOptions,f=d.connectionUrl,p=!!(f&&/run\.mcp-use\.com|mcp-use\.run/.test(f)),m=p?f:void 0,h=d.oauthProxyUrl,g=m;if(!h&&g)try{let e=new URL(window.location.href);if(e.pathname.includes(`/oauth/callback`)){let t=e.pathname.replace(/\/oauth\/callback.*$/,``);(!t||t===``)&&(/run\.mcp-use\.com|mcp-use\.run/.test(g)?console.log(`${a} Gateway connection detected; skipping default /inspector OAuth proxy inference`):(t=`/inspector`,console.log(`${a} Callback at root /oauth/callback, using /inspector as base path for OAuth proxy`))),t&&(h=`${e.origin}${t}/api/oauth`),console.log(`${a} Inferred OAuth proxy URL from callback: ${h}`)}}catch(e){console.warn(`${a} Could not infer OAuth proxy URL:`,e)}console.log(`${a} Re-instantiating provider for server: ${u}`),o=new dn(u,{...d,oauthProxyUrl:h,connectionUrl:g});let _=`${d.storageKeyPrefix}_${s.serverUrlHash}_code_verifier`,v=s.codeVerifier||localStorage.getItem(_);if(v)localStorage.setItem(_,v),localStorage.setItem(o.getKey(`code_verifier`),v);else throw Error(`[${d.storageKeyPrefix}] Code verifier missing for OAuth state ${n}. Please restart authentication.`);h&&(console.log(`${a} Installing fetch interceptor for token exchange (proxy: ${h})`),o.installFetchInterceptor()),console.log(`${a} Calling SDK auth() to exchange code...`);let y=p&&g?g:u;console.log(`${a} Using SDK serverUrl: ${y} (connectionUrl: ${g||`none`})`);let b=await le(o,{serverUrl:y,authorizationCode:t});if(b===`AUTHORIZED`)if(console.log(`${a} Authorization successful via SDK auth().`),s.flowType===`redirect`&&s.returnUrl)console.log(`${a} Redirect flow complete. Returning to: ${s.returnUrl}`),localStorage.removeItem(c),window.location.href=s.returnUrl;else if(window.opener&&!window.opener.closed)console.log(`${a} Popup flow complete. Notifying opener...`),window.opener.postMessage({type:`mcp_auth_callback`,success:!0},window.location.origin),localStorage.removeItem(c),window.close();else if(s.returnUrl)console.log(`${a} Popup flow without opener. Returning to: ${s.returnUrl}`),localStorage.removeItem(c),window.location.href=s.returnUrl;else{console.warn(`${a} No opener window or return URL detected. Redirecting to root.`),localStorage.removeItem(c);let e=window.location.pathname.split(`/`).filter(Boolean),t=e.length>0&&e[e.length-1]===`callback`?`/`+e.slice(0,-2).join(`/`):`/`;window.location.href=t||`/`}else throw console.warn(`${a} SDK auth() returned unexpected status: ${b}`),Error(`Unexpected result from authentication library: ${b}`)}catch(e){console.error(`${a} Error during OAuth callback handling:`,e);let t=e instanceof Error?e.message:String(e);window.opener&&!window.opener.closed&&window.opener.postMessage({type:`mcp_auth_callback`,success:!1,error:t},window.location.origin);try{document.body.innerHTML=``;let n=document.createElement(`div`);n.style.fontFamily=`sans-serif`,n.style.padding=`20px`;let r=document.createElement(`h1`);r.textContent=`Authentication Error`,n.appendChild(r);let i=document.createElement(`p`);i.style.color=`red`,i.style.backgroundColor=`#ffebeb`,i.style.border=`1px solid red`,i.style.padding=`10px`,i.style.borderRadius=`4px`,i.textContent=t,n.appendChild(i);let a=document.createElement(`p`);a.textContent=`You can close this window or `;let o=document.createElement(`a`);if(o.href=`#`,o.textContent=`click here to close`,o.onclick=e=>(e.preventDefault(),window.close(),!1),a.appendChild(o),a.appendChild(document.createTextNode(`.`)),n.appendChild(a),e instanceof Error&&e.stack){let t=document.createElement(`pre`);t.style.fontSize=`0.8em`,t.style.color=`#555`,t.style.marginTop=`20px`,t.style.whiteSpace=`pre-wrap`,t.textContent=e.stack,n.appendChild(t)}document.body.appendChild(n)}catch(e){console.error(`${a} Could not display error in callback window:`,e)}c&&localStorage.removeItem(c),o&&localStorage.removeItem(o.getKey(`last_auth_url`))}}a(fn,`onMcpAuthorization`);var pn=s.get(`RpcLogger`),mn=new class{static{a(this,`RpcLogStore`)}logs=[];listeners=new Set;maxLogs=1e3;publish(e){pn.debug(`[RPC Logger] Publishing log:`,e.direction,e.serverId,e.message?.method),this.logs.push(e),this.logs.length>this.maxLogs&&(this.logs=this.logs.slice(-this.maxLogs)),pn.debug(`[RPC Logger] Total logs:`,this.logs.length,`Listeners:`,this.listeners.size),this.listeners.forEach(t=>{try{t(e)}catch(e){pn.error(`[RPC Logger] Listener error:`,e)}})}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}getLogsForServer(e){return this.logs.filter(t=>t.serverId===e)}getAllLogs(){return[...this.logs]}clear(e){e?this.logs=this.logs.filter(t=>t.serverId!==e):this.logs=[]}};function hn(e){return mn.getLogsForServer(e)}a(hn,`getRpcLogs`);function gn(){return mn.getAllLogs()}a(gn,`getAllRpcLogs`);function _n(e){return mn.subscribe(e)}a(_n,`subscribeToRpcLogs`);function vn(e){mn.clear(e)}a(vn,`clearRpcLogs`);function yn(e,t){class n{constructor(e){this.inner=e,this.inner.onmessage=(e,n)=>{mn.publish({serverId:t,direction:`receive`,timestamp:new Date().toISOString(),message:e}),this.onmessage?.(e,n)},this.inner.onclose=()=>{this.onclose?.()},this.inner.onerror=e=>{this.onerror?.(e)}}static{a(this,`LoggingTransport`)}onclose;onerror;onmessage;async start(){typeof this.inner.start==`function`&&await this.inner.start()}async send(e,n){mn.publish({serverId:t,direction:`send`,timestamp:new Date().toISOString(),message:e}),await this.inner.send(e,n)}async close(){await this.inner.close()}get sessionId(){return this.inner.sessionId}setProtocolVersion(e){typeof this.inner.setProtocolVersion==`function`&&this.inner.setProtocolVersion(e)}}return new n(e)}a(yn,`wrapTransportForLogging`);var bn=i((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function N(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,N(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),N(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+j(a,u),c+=N(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+j(a,u++),c+=N(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return N(M(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function P(e,t,n){if(e==null)return e;var r=[],i=0;return N(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function F(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var I=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},L={map:P,forEach:function(e,t,n){P(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return P(e,function(){t++}),t},toArray:function(e){return P(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=L,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:F}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,I)}catch(e){I(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.4`})),xn=i(((e,t)=>{t.exports=bn()})),G=n(xn(),1);async function Sn(e,t=fetch){let n=e.replace(/\/$/,``),r=await t(n.endsWith(`/mcp`)?n:`${n}/mcp`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({jsonrpc:`2.0`,method:`initialize`,id:1,params:{}})});if(r.status!==401)return{};let{resourceMetadataUrl:i,scope:a}=de(r);return{resourceMetadataUrl:i,scope:a}}a(Sn,`probeAuthParams`);function Cn(e,t){if(!e)throw Error(t)}a(Cn,`assert`);function wn(e){return e===`localhost`||e===`127.0.0.1`||e.startsWith(`127.`)||e.startsWith(`192.168.`)||e.startsWith(`10.`)||e.startsWith(`172.`)}a(wn,`isLocalServer`);function Tn(e){let t=e.split(`.`),n=[];for(let e=0;e<t.length-1;e++)n.push(t.slice(e).join(`.`));return n}a(Tn,`getSubdomainLevels`);function En(e){return new Promise((t,n)=>{let r=new FileReader;r.onloadend=()=>{t(r.result)},r.onerror=n,r.readAsDataURL(e)})}a(En,`blobToBase64`);async function Dn(e){console.debug(`[favicon-detector] Starting favicon detection for:`,e);try{let t;if(t=e.startsWith(`http://`)||e.startsWith(`https://`)?new URL(e).hostname:e.includes(`://`)?e.split(`://`)[1].split(`/`)[0]:e.split(`/`)[0],console.debug(`[favicon-detector] Extracted domain:`,t),wn(t))return console.debug(`[favicon-detector] Skipping local server:`,t),null;let n=Tn(t);console.debug(`[favicon-detector] Domains to try:`,n);for(let e of n)try{let t=`https://favicon.tools.mcp-use.com/${e}?response=json`;console.debug(`[favicon-detector] Attempting to fetch favicon metadata for:`,e,`from:`,t);let n=new AbortController,r=setTimeout(()=>n.abort(),2e3);try{let i=await fetch(t,{signal:n.signal});if(clearTimeout(r),!i.ok){console.debug(`[favicon-detector] Fetch failed for`,e,`with status:`,i.status);continue}let a=await i.json();console.debug(`[favicon-detector] Retrieved favicon metadata for:`,e,`source:`,a.source);let o=a.url.replace(/^http:\/\//,`https://`),s=await fetch(o);if(!s.ok){console.debug(`[favicon-detector] Failed to fetch favicon image for`,e,`status:`,s.status);continue}let c=await s.blob(),l=await En(c);if(a.source===`default`){console.debug(`[favicon-detector] Found default favicon for:`,e,`skipping and continuing to search for non-default`);continue}return console.debug(`[favicon-detector] Successfully retrieved non-default favicon for:`,e,`source:`,a.source,`size:`,c.size,`bytes`),l}catch(t){clearTimeout(r),console.debug(`[favicon-detector] Fetch error for`,e,`:`,t instanceof Error?t.message:String(t));continue}}catch(t){console.debug(`[favicon-detector] Error processing domain`,e,`:`,t instanceof Error?t.message:String(t));continue}return console.debug(`[favicon-detector] No non-default favicon found for:`,e,`returning null to show gradient fallback`),null}catch(e){return console.warn(`[favicon-detector] Error detecting favicon:`,e),null}}a(Dn,`detectFavicon`);function On(e,t){let n=t?.headers??t?.customHeaders??{};if(t?.customHeaders&&!t?.headers&&console.warn(`[applyProxyConfig] The "customHeaders" option in proxyConfig is deprecated. Use "headers" instead.`),!t?.proxyAddress)return{url:e,headers:n};let r=new URL(t.proxyAddress),i=new URL(e);return{url:`${r.origin}${r.pathname}${i.pathname}${i.search}`,headers:{"X-Target-URL":e,...n}}}a(On,`applyProxyConfig`);var kn=`inspector-server`;function An(e){return{name:e.name,version:e.version,uri:e.websiteUrl,logo_uri:e.icons?.[0]?.src}}a(An,`deriveOAuthClientConfigFromClientInfo`);function jn(e){let t=(e instanceof Error?e.message:String(e)).toLowerCase();return t.includes(`oauth discovery failed`)||t.includes(`oauth-authorization-server`)||t.includes(`not valid json`)||t.includes(`404`)&&(t.includes(`openid-configuration`)||t.includes(`oauth-protected-resources`)||t.includes(`oauth-authorization-url`)||t.includes(`register`))||t.includes(`invalid oauth error response`)&&t.includes(`not found`)}a(jn,`isOAuthDiscoveryFailure`);function Mn(e){if(!e)return;let t=new URL(e),n=t.pathname.replace(/\/proxy\/?$/,``);return`${t.origin}${n}/oauth`}a(Mn,`deriveOAuthProxyUrl`);function Nn(e){let t=Mn(e.gatewayUrl),n=new dn(e.effectiveOAuthUrl,{storageKeyPrefix:e.storageKeyPrefix,clientName:e.oauthClientConfig.name,clientUri:e.oauthClientConfig.uri,logoUri:e.oauthClientConfig.logo_uri||`https://mcp-use.com/logo.png`,callbackUrl:e.callbackUrl,preventAutoAuth:e.preventAutoAuth,useRedirectFlow:e.useRedirectFlow,oauthProxyUrl:t,connectionUrl:e.gatewayUrl,onPopupWindow:e.onPopupWindow});return t&&e.installFetchInterceptor&&n.installFetchInterceptor(),{provider:n,oauthProxyUrl:t}}a(Nn,`createBrowserOAuthProvider`);function Pn(e){let t=null,n=Date.now(),r=e.healthCheckIntervalMs??1e4,i=e.healthCheckTimeoutMs??3e4,o=a(async()=>{if(!e.isMountedRef.current||e.stateRef.current!==`ready`){t&&=(clearInterval(t),null);return}try{let t=e.gatewayUrl||e.url;if(!t)return;let r=e.getAuthHeaders?await e.getAuthHeaders():{},i=await fetch(t,{method:`HEAD`,headers:{...e.allHeaders,...r},signal:AbortSignal.timeout(5e3)});if(i.ok||i.status<500)n=Date.now();else throw Error(`Server returned ${i.status}`)}catch{let r=Date.now()-n;r>i&&(e.addLog(`warn`,`Connection appears to be broken (no response for ${Math.round(r/1e3)}s), attempting to reconnect...`),t&&=(clearInterval(t),null),e.autoReconnectRef.current&&e.isMountedRef.current&&(e.setState(`discovering`),e.addLog(`info`,`Auto-reconnecting to MCP server...`),setTimeout(()=>{e.isMountedRef.current&&e.stateRef.current===`discovering`&&e.connect()},typeof e.autoReconnectRef.current==`number`?e.autoReconnectRef.current:e.defaultReconnectDelay)))}},`checkConnectionHealth`);return t=setInterval(o,r),()=>{t&&=(clearInterval(t),null)}}a(Pn,`startConnectionHealthMonitoring`);var Fn=3e3,In=5e3;function Ln(e){let{url:t,enabled:n=!0,callbackUrl:r=typeof window<`u`?cn(new URL(`/oauth/callback`,window.location.origin).toString()):`/oauth/callback`,storageKeyPrefix:i=`mcp:auth`,clientConfig:c={},authProvider:l,headers:u,customHeaders:d,proxyConfig:f,autoProxyFallback:p=!0,debug:m=!1,logLevel:h,autoRetry:g=!1,autoReconnect:_=Fn,reconnectionOptions:v,transportType:y=`auto`,preventAutoAuth:b=!0,useRedirectFlow:x=!1,onPopupWindow:S,timeout:C=3e4,sseReadTimeout:w=3e5,wrapTransport:T,fetch:E,clientOptions:D,onNotification:O,onSampling:A,samplingCallback:j,onElicitation:M,elicitationCallback:P}=e,F=(0,G.useMemo)(()=>{let e=`useMcp:${t||`no-url`}`,n=s.get(e);return h?n.level=h:m&&(n.level=`debug`),n},[t,h,m]),I=u??d??{};d&&!u&&F.warn(`[useMcp] The "customHeaders" option is deprecated. Use "headers" instead.`);let L=A??j;j&&!A&&F.warn(`[useMcp] The "samplingCallback" option is deprecated. Use "onSampling" instead.`);let ee=M??P;P&&!M&&o.warn(`[useMcp] The "elicitationCallback" option is deprecated. Use "onElicitation" instead.`);let te=(0,G.useMemo)(()=>({name:`mcp-use`,title:`mcp-use`,version:k(),description:`mcp-use is a complete TypeScript framework for building and using MCP`,icons:[{src:`https://mcp-use.com/logo.png`}],websiteUrl:`https://mcp-use.com`}),[]),R=(0,G.useMemo)(()=>e.clientInfo?{...te,...e.clientInfo}:te,[e.clientInfo,te]),z=(0,G.useMemo)(()=>An(R),[R]),ne=(0,G.useMemo)(()=>c&&Object.keys(c).length>0?(F.warn(`[useMcp] The 'clientConfig' option is deprecated and will be removed in a future version. Use 'clientInfo' instead. The clientConfig will be automatically derived from clientInfo.`),{...z,...c}):z,[c,z]),re=(0,G.useMemo)(()=>p?typeof p==`boolean`?{enabled:p,proxyAddress:`https://inspector.mcp-use.com/inspector/api/proxy`}:{enabled:p.enabled!==!1,proxyAddress:p.proxyAddress||`https://inspector.mcp-use.com/inspector/api/proxy`}:{enabled:!1,proxyAddress:void 0},[p]),ie=(0,G.useMemo)(()=>_===!1?{enabled:!1,initialDelay:0,healthCheckInterval:!1,healthCheckTimeout:3e4}:_===!0?{enabled:!0,initialDelay:Fn,healthCheckInterval:1e4,healthCheckTimeout:3e4}:typeof _==`number`?{enabled:!0,initialDelay:_,healthCheckInterval:1e4,healthCheckTimeout:3e4}:{enabled:_.enabled!==!1,initialDelay:_.initialDelay??Fn,healthCheckInterval:_.healthCheckInterval??1e4,healthCheckTimeout:_.healthCheckTimeout??3e4},[_]),ae=(0,G.useRef)(!1),[oe,se]=(0,G.useState)(f);(0,G.useEffect)(()=>{se(f)},[f]);let{gatewayUrl:ce,proxyHeaders:ue}=(0,G.useMemo)(()=>{let e=On(t||``,f);return{gatewayUrl:f?.proxyAddress,proxyHeaders:e.headers}},[t,f]),de=(0,G.useMemo)(()=>t||``,[t]),B=(0,G.useMemo)(()=>({...ue,...I}),[ue,I]),[fe,pe]=(0,G.useState)(`discovering`),[me,V]=(0,G.useState)([]),[H,he]=(0,G.useState)([]),[ge,_e]=(0,G.useState)([]),[ve,ye]=(0,G.useState)([]),[U,be]=(0,G.useState)(e._initialServerInfo?.name?e._initialServerInfo:void 0),[xe,Se]=(0,G.useState)(),[Ce,we]=(0,G.useState)(void 0),[Te,Ee]=(0,G.useState)([]),[De,Oe]=(0,G.useState)(void 0),[ke,Ae]=(0,G.useState)(void 0),je=(0,G.useRef)(null),Me=(0,G.useRef)(l??null),Ne=(0,G.useRef)(null),Pe=(0,G.useRef)(!1),Fe=(0,G.useRef)(!0),Ie=(0,G.useRef)(0),Le=(0,G.useRef)(null),Re=(0,G.useRef)(!1),ze=(0,G.useRef)(fe),Be=(0,G.useRef)(_),Ve=(0,G.useRef)(null),He=(0,G.useRef)(null),Ue=(0,G.useRef)(null);(0,G.useEffect)(()=>{ze.current=fe,Be.current=_},[fe,_]),(0,G.useEffect)(()=>{Me.current=l??null},[l]);let W=(0,G.useCallback)((e,t,...n)=>{let r=n.length>0?`${t} ${n.map(e=>JSON.stringify(e)).join(` `)}`:t,i=`[useMcp] ${r}`;switch(e){case`error`:F.error(i);break;case`warn`:F.warn(i);break;case`info`:F.info(i);break;case`debug`:F.debug(i);break;default:F.info(i)}Fe.current&&Ee(t=>[...t.slice(-100),{level:e,message:r,timestamp:Date.now()}])},[F]),We=(0,G.useCallback)(async(e=!1)=>{if(e||W(`info`,`Disconnecting...`),Pe.current=!1,Le.current&&clearTimeout(Le.current),Le.current=null,je.current)try{let e=kn,t=je.current.getSession(e);t&&t._healthCheckCleanup&&(t._healthCheckCleanup(),t._healthCheckCleanup=null),t&&await je.current.closeSession(e)}catch(t){e||W(`warn`,`Error closing session:`,t)}je.current=null,Fe.current&&!e&&(pe(`discovering`),V([]),he([]),_e([]),ye([]),we(void 0),Oe(void 0))},[W]),Ge=(0,G.useCallback)((e,n)=>{W(`error`,e,n??``);let r=n&&`code`in n?n.code:void 0,i=re.enabled&&!oe?.proxyAddress,a=e.includes(`CORS`)||e.includes(`blocked by CORS policy`)||e.includes(`Failed to fetch`),o=r===400;if(i&&(a||o||typeof r==`number`&&r>=404&&r<500)&&!(r===401||r===403))return W(`info`,`Direct connection failed with ${a?`CORS error`:o?`HTTP 400 (Bad Request)`:`HTTP 4xx error`}. Trying with proxy...`),je.current=null,l||(Me.current=null),W(`debug`,`Cleared client and auth provider for proxy fallback`),se({proxyAddress:re.proxyAddress}),Fe.current&&pe(`discovering`),setTimeout(()=>{Fe.current&&He.current?.()},1e3),!0;if(Fe.current){W(`info`,`Setting state to FAILED:`,e),pe(`failed`),we(e);let t=Me.current?.getLastAttemptedAuthUrl?.();t&&(Oe(t),W(`info`,`Manual authentication URL may be available.`,t))}return Pe.current=!1,t&&N.getInstance().trackUseMcpConnection({url:t,transportType:y,success:!1,errorType:n?.name||`UnknownError`,hasOAuth:!!Me.current,hasSampling:!!L,hasElicitation:!!ee}).catch(()=>{}),!1},[W,t,y,L,ee,re,oe,l]),Ke=(0,G.useCallback)(async()=>{if(!n||!t){W(`debug`,n?`No server URL provided, skipping connection.`:`Connection disabled via enabled flag.`);return}if(Pe.current){W(`debug`,`Connection attempt already in progress.`);return}if(!Fe.current){W(`debug`,`Connect called after unmount, aborting.`);return}if(Pe.current=!0,Ie.current+=1,we(void 0),Oe(void 0),Ve.current=null,pe(`discovering`),W(`info`,`Connecting attempt #${Ie.current} to ${t}...`),!Me.current){let{provider:e,oauthProxyUrl:t}=Nn({effectiveOAuthUrl:de,storageKeyPrefix:i,oauthClientConfig:ne,callbackUrl:r,preventAutoAuth:b,useRedirectFlow:x,gatewayUrl:ce,onPopupWindow:S,installFetchInterceptor:!0});Me.current=e,t&&W(`debug`,`OAuth proxy URL derived from gateway: ${t}`),W(`debug`,`BrowserOAuthClientProvider initialized with URL: ${de}, proxy: ${t?`enabled`:`disabled`}, gateway: ${ce?`enabled`:`disabled`}`)}je.current?W(`debug`,`BrowserMCPClient already exists, reusing.`):(je.current=new sn,W(`debug`,`BrowserMCPClient initialized in connect.`));let e=a(async n=>{if(!Fe.current)return W(`debug`,`Connection attempt aborted - component unmounted`),`failed`;W(`info`,`Attempting connection with transport: ${n}`),W(`debug`,`Client ref status at start of tryConnectWithTransport: ${je.current?`initialized`:`NULL`}`);try{let e=kn,r={url:t,transport:n===`sse`?`http`:n,timeout:C,sseReadTimeout:w,disableSseFallback:y===`http`,preferSse:n===`sse`,clientInfo:R,...E&&{fetch:E},...D&&{clientOptions:D},...v?{reconnectionOptions:v}:_===!1?{reconnectionOptions:{maxRetries:0}}:{}};if(ce&&(r.gatewayUrl=ce,W(`debug`,`Using proxy gateway: ${ce} for target: ${t}`)),B&&Object.keys(B).length>0&&(r.headers=B),!je.current){if(!Fe.current)return W(`debug`,`Connection aborted - component unmounted, client cleaned up`),`failed`;let e=Error(`Client not initialized - this is a bug in the connection flow`);throw W(`error`,`Client ref is null in tryConnectWithTransport but component is still mounted`),e}je.current.addServer(e,{...r,authProvider:Me.current,onSampling:L,onElicitation:ee,wrapTransport:T?n=>(W(`debug`,`Applying transport wrapper for server:`,e,`url:`,t),T(n,t)):void 0});let i=await je.current.createSession(e,!1);if(!Fe.current)return W(`debug`,`Connection aborted after session creation - component unmounted`),`failed`;if(i.on(`notification`,e=>{W(`debug`,`Notification received:`,e.method,e),O?.(e),e.method===`notifications/tools/list_changed`?(W(`info`,`Tools list changed, auto-refreshing...`),et().catch(e=>{W(`warn`,`Auto-refresh tools failed:`,e)})):e.method===`notifications/resources/list_changed`?(W(`info`,`Resources list changed, auto-refreshing...`),tt().catch(e=>W(`warn`,`Auto-refresh resources failed:`,e))):e.method===`notifications/prompts/list_changed`&&(W(`info`,`Prompts list changed, auto-refreshing...`),nt().catch(e=>W(`warn`,`Auto-refresh prompts failed:`,e)))}),await i.initialize(),!Fe.current)return W(`debug`,`Connection completed but component unmounted, aborting`),`failed`;if(W(`info`,`✅ Successfully connected to MCP server`),W(`info`,`Server info:`,i.connector.serverInfo),W(`info`,`Server capabilities:`,i.connector.serverCapabilities),!Fe.current)return W(`debug`,`Skipping state update - component unmounted`),`failed`;pe(`ready`),Ve.current=n,ie.enabled&&ie.healthCheckInterval!==!1&&(i._healthCheckCleanup=Pn({gatewayUrl:ce,url:t,allHeaders:B,getAuthHeaders:a(async()=>{try{let e=await Me.current?.tokens?.();if(e?.access_token){let t=e.token_type||`bearer`;return{Authorization:`${t.charAt(0).toUpperCase()+t.slice(1)} ${e.access_token}`}}}catch{}return{}},`getAuthHeaders`),isMountedRef:Fe,stateRef:ze,autoReconnectRef:Be,setState:pe,addLog:W,connect:Ke,defaultReconnectDelay:ie.initialDelay,healthCheckIntervalMs:ie.healthCheckInterval,healthCheckTimeoutMs:ie.healthCheckTimeout})),N.getInstance().trackUseMcpConnection({url:t,transportType:n,success:!0,hasOAuth:!!Me.current,hasSampling:!!L,hasElicitation:!!ee}).catch(()=>{}),V(i.connector.tools||[]);let o=await i.connector.listAllResources();if(!Fe.current)return W(`debug`,`Connection aborted after listing resources - component unmounted`),`failed`;he(o.resources||[]);let s=await i.connector.listPrompts();if(!Fe.current)return W(`debug`,`Connection aborted after listing prompts - component unmounted`),`failed`;if(ye(s.prompts||[]),i.connector.serverCapabilities?.resourceTemplates){let e=await i.connector.listResourceTemplates();if(!Fe.current)return W(`debug`,`Connection aborted after listing resource templates - component unmounted`),`failed`;_e(e.resourceTemplates||[])}else _e([]);let c=i.connector.serverInfo,l=i.connector.serverCapabilities;if(c){if(W(`debug`,`Server info:`,c),!Fe.current)return W(`debug`,`Skipping state update - component unmounted`),`failed`;be(c),Ne.current=(async()=>{try{let e=c.icons;if(e&&Array.isArray(e)&&e.length>0){let t=e[0].src||e[0].url;if(t){W(`info`,`Server provided icon:`,t);let e=await(await fetch(t)).blob(),n=await new Promise((t,n)=>{let r=new FileReader;r.onloadend=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)});return Fe.current&&(be(e=>e?{...e,icon:n}:void 0),W(`debug`,`Server icon converted to base64`)),n}}if(t){let e=await Dn(t);if(!Fe.current)return W(`debug`,`Connection aborted after favicon detection - component unmounted`),null;if(e)return be(t=>t?{...t,icon:e}:void 0),W(`debug`,`Favicon detected and added to serverInfo`),e}return null}catch(e){return W(`debug`,`Icon loading failed (non-critical):`,e),null}})()}if(l){if(W(`debug`,`Server capabilities:`,l),!Fe.current)return W(`debug`,`Skipping state update - component unmounted`),`failed`;Se(l)}if(Me.current){let e=await Me.current.tokens?.();if(!Fe.current)return W(`debug`,`Connection aborted after token fetch for auth tokens - component unmounted`),`failed`;if(e?.access_token){let t=e.expires_in?Date.now()+e.expires_in*1e3:void 0;if(!Fe.current)return W(`debug`,`Skipping state update - component unmounted`),`failed`;Ae({access_token:e.access_token,token_type:e.token_type||`Bearer`,expires_at:t,refresh_token:e.refresh_token,scope:e.scope})}}return`success`}catch(r){let i=r,a=i?.message||String(r),o=jn(r),s=i.code===401||a.includes(`401`)||a.includes(`Unauthorized`);if(o&&I&&Object.keys(I).length>0)return Ge(`Authentication failed (HTTP 401). Server does not support OAuth. Check your Authorization header value is correct.`),`failed`;if(o&&(!I||Object.keys(I).length===0))return Ge(`Authentication required (HTTP 401). Server does not support OAuth. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY).`),`failed`;if(s){if(o)return Ge(`Authentication required (HTTP 401). Server does not support OAuth. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY).`),`failed`;if(Me.current)if(W(`info`,`Authentication required. OAuth provider available.`),b){if(W(`info`,`Waiting for user to initiate authentication flow...`),Fe.current){pe(`pending_auth`);let e=Me.current?.getLastAttemptedAuthUrl?.();e&&(Oe(e),W(`info`,`Retrieved stored auth URL for manual authentication`))}return Pe.current=!1,`auth_redirect`}else{W(`info`,`Triggering automatic OAuth authentication flow...`);try{let{resourceMetadataUrl:r,scope:i}=await Sn(t);if(await le(Me.current,{serverUrl:t,...r&&{resourceMetadataUrl:r},...i&&{scope:i}})===`REDIRECT`){let e=await Me.current.getAuthorizationCode?.();if(!e)throw Error(`Authorization code not captured by headless provider`);await le(Me.current,{serverUrl:t,...r&&{resourceMetadataUrl:r},...i&&{scope:i},authorizationCode:e})}return W(`info`,`OAuth flow completed, reconnecting...`),await e(n)}catch(e){return Ge(`Automatic OAuth authentication failed: ${e instanceof Error?e.message:String(e)}`,e instanceof Error?e:Error(String(e))),`failed`}}return I&&Object.keys(I).length>0?(Ge(`Authentication failed: Server returned 401 Unauthorized. Check your Authorization header value is correct.`),`failed`):(Ge(`Authentication required: Server returned 401 Unauthorized. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY).`),`failed`)}return Ge(a,i instanceof Error?i:Error(String(i)))?`auth_redirect`:`failed`}},`tryConnectWithTransport`),o=`failed`;if(y===`sse`)W(`debug`,`Using SSE-only transport mode`),o=await e(`sse`);else if(y===`http`)W(`debug`,`Using HTTP-only transport mode`),o=await e(`http`);else{W(`debug`,`Using auto transport mode (HTTP with SSE fallback)`);let t=await e(`http`);t===`fallback`&&Fe.current&&ze.current!==`authenticating`?(W(`info`,`HTTP failed, attempting SSE fallback...`),o=await e(`sse`)):o=t}(o===`success`||o===`failed`||o===`auth_redirect`)&&(Pe.current=!1),W(`debug`,`Connection sequence finished with status: ${o}`)},[W,Ge,We,t,i,r,ne.name,ne.version,ne.uri,ne.logo_uri,I,y,b,x,S,n,C,w,R,ce,B,de]);(0,G.useEffect)(()=>{He.current=Ke,Ue.current=Ge},[Ke,Ge]);let qe=(0,G.useCallback)(async(e,t,n)=>{if(ze.current!==`ready`||!je.current)throw Error(`MCP client is not ready (current state: ${fe}). Cannot call tool "${e}".`);W(`info`,`Calling tool: ${e}`,t);let r=Date.now();try{let i=kn,a=je.current.getSession(i);if(!a)throw Error(`No active session found`);let o=await a.connector.callTool(e,t||{},n);return W(`info`,`Tool "${e}" call successful:`,o),N.getInstance().trackUseMcpToolCall({toolName:e,success:!0,executionTimeMs:Date.now()-r}).catch(()=>{}),o}catch(t){throw W(`error`,`Tool "${e}" call failed:`,t),N.getInstance().trackUseMcpToolCall({toolName:e,success:!1,errorType:t instanceof Error?t.name:`UnknownError`,executionTimeMs:Date.now()-r}).catch(()=>{}),t}},[fe]),Je=(0,G.useCallback)(()=>{ze.current===`failed`?(W(`info`,`Retry requested...`),He.current?.()):W(`warn`,`Retry called but state is not 'failed' (state: ${ze.current}). Ignoring.`)},[W]),Ye=(0,G.useCallback)(async()=>{W(`info`,`Manual authentication requested...`);let e=ze.current;if(e===`failed`)W(`info`,`Attempting to reconnect and authenticate via retry...`),Je();else if(e===`pending_auth`){W(`info`,`Proceeding with authentication from pending state...`);try{if(Cn(Me.current,`Auth Provider not available for manual auth`),Cn(t,`Server URL is required for authentication`),l){W(`info`,`Using provided authProvider for manual authentication`);let e=new URL(t).origin;await le(Me.current,{serverUrl:e}),He.current?.();return}W(`info`,`Cleared ${Me.current.clearStorage?.()??0} OAuth storage item(s) for fresh authentication`),pe(`authenticating`);let{provider:e,oauthProxyUrl:n}=Nn({effectiveOAuthUrl:de,storageKeyPrefix:i,oauthClientConfig:ne,callbackUrl:r,preventAutoAuth:!1,useRedirectFlow:x,gatewayUrl:ce,onPopupWindow:S,installFetchInterceptor:!ce});n&&!ce?W(`info`,`Installed OAuth fetch interceptor for manual auth`):n&&ce&&W(`info`,`Using MCP gateway proxy for OAuth (no fetch interceptor needed)`),Me.current=e,W(`info`,`Triggering fresh OAuth authorization...`);let a=new URL(t).origin;try{await le(e,{serverUrl:a}),W(`info`,`OAuth flow completed (tokens obtained)`)}catch(e){W(`info`,`OAuth flow initiated (popup/redirect):`,e instanceof Error?e.message:`Redirecting...`)}let o=e.getLastAttemptedAuthUrl?.();o&&(Oe(o),W(`info`,`Updated auth URL for fallback:`,o))}catch(e){if(!Fe.current)return;pe(`pending_auth`),W(`error`,`Manual authentication failed: ${e instanceof Error?e.message:String(e)}`)}}else if(e===`authenticating`){W(`warn`,`Already attempting authentication. Check for blocked popups or wait for timeout.`);let e=Me.current?.getLastAttemptedAuthUrl?.();e&&!De&&(Oe(e),W(`info`,`Manual authentication URL retrieved:`,e))}else W(`info`,`Client not in a state requiring manual authentication trigger (state: ${e}). If needed, try disconnecting and reconnecting.`)},[W,Je,De,t,x,S,i,ne.name,ne.uri,ne.logo_uri,r,R,l]),Xe=(0,G.useCallback)(()=>{Me.current?.clearStorage?(W(`info`,`Cleared ${Me.current.clearStorage()} item(s) from localStorage for ${t}.`),Oe(void 0),We()):W(`warn`,`Auth provider not initialized, cannot clear storage.`)},[t,W,We]),Ze=(0,G.useCallback)(async()=>{if(ze.current!==`ready`||!je.current)throw Error(`MCP client is not ready (current state: ${fe}). Cannot list resources.`);W(`info`,`Listing resources`);try{let e=kn,t=je.current.getSession(e);if(!t)throw Error(`No active session found`);he((await t.connector.listAllResources()).resources||[]),W(`info`,`Resources listed successfully`)}catch(e){throw W(`error`,`List resources failed:`,e),e}},[fe]),Qe=(0,G.useCallback)(async e=>{if(ze.current!==`ready`||!je.current)throw Error(`MCP client is not ready (current state: ${fe}). Cannot read resource.`);W(`info`,`Reading resource: ${e}`);try{let t=kn,n=je.current.getSession(t);if(!n)throw Error(`No active session found`);let r=await n.connector.readResource(e);return W(`info`,`Resource read successful:`,r),N.getInstance().trackUseMcpResourceRead({resourceUri:e,success:!0}).catch(()=>{}),r}catch(t){throw W(`error`,`Resource read failed:`,t),N.getInstance().trackUseMcpResourceRead({resourceUri:e,success:!1,errorType:t instanceof Error?t.name:`UnknownError`}).catch(()=>{}),t}},[fe]),$e=(0,G.useCallback)(async()=>{if(ze.current!==`ready`||!je.current)throw Error(`MCP client is not ready (current state: ${fe}). Cannot list prompts.`);W(`info`,`Listing prompts`);try{let e=kn,t=je.current.getSession(e);if(!t)throw Error(`No active session found`);ye((await t.connector.listPrompts()).prompts||[]),W(`info`,`Prompts listed successfully`)}catch(e){throw W(`error`,`List prompts failed:`,e),e}},[fe]),et=(0,G.useCallback)(async()=>{if(ze.current!==`ready`||!je.current){W(`debug`,`Cannot refresh tools - client not ready. State:`,ze.current);return}W(`debug`,`Refreshing tools list`);try{let e=kn,t=je.current.getSession(e);if(!t){W(`warn`,`No active session found for tools refresh`);return}W(`debug`,`Calling listTools...`);let n=await t.connector.listTools();W(`debug`,`listTools returned:`,n?.length,`tools`),V(n||[]),W(`info`,`Tools list refreshed successfully`)}catch(e){W(`error`,`Failed to refresh tools:`,e)}},[W]),tt=(0,G.useCallback)(async()=>{if(ze.current!==`ready`||!je.current){W(`debug`,`Cannot refresh resources - client not ready`);return}W(`debug`,`Refreshing resources list`);try{let e=kn,t=je.current.getSession(e);if(!t){W(`warn`,`No active session found for resources refresh`);return}he((await t.connector.listAllResources()).resources||[]),W(`info`,`Resources list refreshed successfully`)}catch(e){W(`warn`,`Failed to refresh resources:`,e)}},[W]),nt=(0,G.useCallback)(async()=>{if(ze.current!==`ready`||!je.current){W(`debug`,`Cannot refresh prompts - client not ready`);return}W(`debug`,`Refreshing prompts list`);try{let e=kn,t=je.current.getSession(e);if(!t){W(`warn`,`No active session found for prompts refresh`);return}ye((await t.connector.listPrompts()).prompts||[]),W(`info`,`Prompts list refreshed successfully`)}catch(e){W(`warn`,`Failed to refresh prompts:`,e)}},[W]),rt=(0,G.useCallback)(async()=>{if(ze.current!==`ready`||!je.current){W(`debug`,`Cannot refresh resource templates - client not ready`);return}W(`debug`,`Refreshing resource templates list`);try{let e=kn,t=je.current.getSession(e);if(!t)throw Error(`No active session found`);let n=await t.connector.listResourceTemplates();Fe.current&&(_e(n.resourceTemplates||[]),W(`info`,`Resource templates refreshed: ${n.resourceTemplates?.length||0} templates`))}catch(e){throw W(`error`,`Failed to refresh resource templates:`,e),e}},[W]),it=(0,G.useCallback)(async()=>{W(`info`,`Refreshing all lists (tools, resources, resource templates, prompts)`),await Promise.all([et(),tt(),rt(),nt()])},[et,tt,rt,nt,W]),at=(0,G.useCallback)(async(e,t)=>{if(ze.current!==`ready`||!je.current)throw Error(`MCP client is not ready (current state: ${fe}). Cannot get prompt.`);W(`info`,`Getting prompt: ${e}`,t);try{let n=kn,r=je.current.getSession(n);if(!r)throw Error(`No active session found`);let i=await r.connector.getPrompt(e,t||{});return W(`info`,`Prompt "${e}" retrieved successfully:`,i),i}catch(t){throw W(`error`,`Prompt "${e}" retrieval failed:`,t),t}},[fe,W]),ot=(0,G.useCallback)(async e=>{if(ze.current!==`ready`||!je.current)throw Error(`MCP client is not ready (current state: ${fe}). Cannot request completion.`);W(`info`,`Requesting completions for ${e.ref.type===`ref/prompt`?`prompt`:`resource template`} "${e.ref.type===`ref/prompt`?e.ref.name:e.ref.uri}"`);try{let t=kn,n=je.current.getSession(t);if(!n)throw Error(`No active session found`);let r=await n.complete(e);return W(`info`,`Received ${r.completion.values.length} completion suggestions`),r}catch(e){throw W(`error`,`Completion request failed:`,e),e}},[fe,W]);(0,G.useEffect)(()=>{let e=a(e=>{e.origin===window.location.origin&&e.data?.type===`mcp_auth_callback`&&(W(`info`,`Received auth callback message.`,e.data),Le.current&&clearTimeout(Le.current),Le.current=null,e.data.success?(W(`info`,`Authentication successful via popup. Reconnecting client...`),Pe.current&&W(`debug`,`Connection attempt already in progress, resetting flag to allow reconnection.`),Pe.current=!1,setTimeout(()=>{Fe.current&&(W(`debug`,`Initiating reconnection after successful auth callback.`),He.current?.())},100)):Ue.current?.(`Authentication failed in callback: ${e.data.error||`Unknown reason.`}`))},`messageHandler`);return window.addEventListener(`message`,e),W(`debug`,`Auth callback message listener added.`),()=>{window.removeEventListener(`message`,e),W(`debug`,`Auth callback message listener removed.`),Le.current&&clearTimeout(Le.current)}},[W]),(0,G.useEffect)(()=>{ae.current=!1,se(f)},[t,f]),(0,G.useEffect)(()=>{if(Fe.current=!0,!n||!t)return W(`debug`,n?`No server URL provided, skipping connection.`:`Connection disabled via enabled flag.`),pe(`discovering`),()=>{Fe.current=!1};if(W(`debug`,`useMcp mounted, initiating connection.`),Ie.current=0,l)Me.current=l,W(`debug`,`Using externally provided authProvider`);else if(!Me.current||Me.current.serverUrl!==de){let{provider:e,oauthProxyUrl:t}=Nn({effectiveOAuthUrl:de,storageKeyPrefix:i,oauthClientConfig:ne,callbackUrl:r,preventAutoAuth:b,useRedirectFlow:x,gatewayUrl:ce,onPopupWindow:S,installFetchInterceptor:!0});Me.current=e,t&&W(`debug`,`OAuth proxy URL derived from gateway: ${t}`),W(`debug`,`BrowserOAuthClientProvider initialized/updated with URL: ${de}, proxy: ${t?`enabled`:`disabled`}, gateway: ${ce?`enabled`:`disabled`}`)}return Ke(),()=>{if(Fe.current=!1,W(`debug`,`useMcp unmounting, disconnecting.`),(ze.current===`authenticating`||ze.current===`pending_auth`)&&Me.current)try{let e=Me.current.clearStorage?.()??0;e>0&&W(`debug`,`Cleared ${e} OAuth state item(s) during unmount to prevent corruption`)}catch(e){W(`debug`,`Error clearing OAuth state during unmount:`,e)}We(!0)}},[t,n,i,r,ne.name,ne.version,ne.uri,ne.logo_uri,x,R,de,f,l]);let st=(0,G.useRef)(Je),ct=(0,G.useRef)(W);(0,G.useEffect)(()=>{st.current=Je,ct.current=W},[Je,W]),(0,G.useEffect)(()=>{let e=null;if(fe===`failed`&&g&&Ie.current>0){if(!Re.current){Re.current=!0;let t=typeof g==`number`?g:In;ct.current(`info`,`Connection failed, auto-retrying in ${t}ms...`),e=setTimeout(()=>{Re.current=!1,Fe.current&&ze.current===`failed`&&st.current()},t)}}else fe!==`failed`&&(Re.current=!1);return()=>{e&&(clearTimeout(e),Re.current=!1)}},[fe,g]);let lt=(0,G.useCallback)(async()=>ze.current===`ready`?U?.icon?U.icon:Ne.current?(W(`debug`,`Waiting for icon to finish loading...`),await Ne.current):(W(`debug`,`No icon available and no loading in progress`),null):(W(`warn`,`Cannot ensure icon loaded - not connected`),null),[U,W]);return{state:fe,name:U?.name||t||``,tools:me,resources:H,resourceTemplates:ge,prompts:ve,serverInfo:U,capabilities:xe,error:Ce,log:Te,authUrl:De,authTokens:ke,client:je.current,callTool:qe,readResource:Qe,listResources:Ze,listPrompts:$e,getPrompt:at,complete:ot,refreshTools:et,refreshResources:tt,refreshResourceTemplates:rt,refreshPrompts:nt,refreshAll:it,retry:Je,disconnect:We,authenticate:Ye,clearStorage:Xe,ensureIconLoaded:lt}}a(Ln,`useMcp`);var Rn=`__model_context`,zn=new Map;function Bn(e){zn.set(e.id,e),Un()}a(Bn,`setNode`);function Vn(e){zn.delete(e),Un()}a(Vn,`removeNode`);var Hn=!1;function Un(){Hn||(Hn=!0,queueMicrotask(Wn))}a(Un,`scheduleFlush`);function Wn(){Hn=!1,Jn(Gn())}a(Wn,`flush`);function Gn(){let e=new Map;for(let t of zn.values()){let n=t.parentId??null;e.has(n)||e.set(n,[]),e.get(n).push(t)}for(let t of e.values())t.sort((e,t)=>e.id.localeCompare(t.id));let t=[];function n(r,i){let a=e.get(r);if(a)for(let e of a)e.content.trim()&&t.push(`${` `.repeat(i)}- ${e.content.trim()}`),n(e.id,i+1)}return a(n,`traverseTree`),n(null,0),t.join(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/rpc-logger-TPNV75J4-BPgEimJH.js","assets/chunk-QWQYAQCK-CyFuZlX8.js","assets/chunk-3GQAWCBQ-C-9Cm0Np.js","assets/chunk-zsgVPwQN.js","assets/core-B6Kp8rMh.js","assets/core-DktjxGrT.js","assets/1c-xAwF9KHw.js","assets/abnf-57JF8nOy.js","assets/accesslog-C2D2ESC1.js","assets/actionscript-BA90Z6ek.js","assets/ada-BOZemNeY.js","assets/angelscript-BPuRd7Au.js","assets/apache-CRejwSR0.js","assets/applescript-DRWfnP7q.js","assets/arcade-c4fxT6cy.js","assets/arduino-D-GQgoAg.js","assets/armasm-DW6aLB45.js","assets/asciidoc-l4rRUjBn.js","assets/aspectj-CBoSaF_P.js","assets/autohotkey-oklQZH_e.js","assets/autoit-CCOhikpq.js","assets/avrasm-DQyyIbM0.js","assets/awk-Bpx3OGwB.js","assets/axapta-ConOtNUD.js","assets/bash-CG9dvFVQ.js","assets/basic-D55fg9VU.js","assets/bnf-BRHfvdnF.js","assets/brainfuck-CvIc7KgZ.js","assets/c-like-BiZIVjlk.js","assets/c-BYqCyjPu.js","assets/cal-BI45EWE9.js","assets/capnproto-CT4_QH7U.js","assets/ceylon-DEhPqbQs.js","assets/clean-Dj90Ldo4.js","assets/clojure-repl-CoLrBnNB.js","assets/clojure-nGPdvoWZ.js","assets/cmake-Cau5qcoL.js","assets/coffeescript-CRI19SN5.js","assets/coq-cKQTGfiT.js","assets/cos-BvDn-C7W.js","assets/cpp-Cm8w5GBK.js","assets/crmsh-BphFuWfQ.js","assets/crystal-CjeRzStm.js","assets/csharp-BjNNmcwi.js","assets/csp-BDakTyDq.js","assets/css-BS5Bw9la.js","assets/d-iafwvjhA.js","assets/dart-CJj6VfDK.js","assets/delphi-CiYfdpeB.js","assets/diff-C0_uVc7j.js","assets/django-D2hgH-Q1.js","assets/dns-Cl4dGnK7.js","assets/dockerfile-meWkyaPv.js","assets/dos-AwMP_0oM.js","assets/dsconfig-CnDR2ZdU.js","assets/dts-BzC-HwM_.js","assets/dust-C7Vcl3-X.js","assets/ebnf-CL9qQEga.js","assets/elixir-CfaDenjY.js","assets/elm-Cy8gaJOl.js","assets/erb-C-4IIk8K.js","assets/erlang-repl-BejU3MB_.js","assets/erlang-B1M6fLuV.js","assets/excel-BkfhIrhj.js","assets/fix-BVmdZVAA.js","assets/flix-D0avEvQY.js","assets/fortran-DakqiesO.js","assets/fsharp-DA54xfXW.js","assets/gams-CXTQKphs.js","assets/gauss-CG12HF6_.js","assets/gcode-BCEABt45.js","assets/gherkin-ZM-mRt_J.js","assets/glsl-CsBoWmwk.js","assets/gml-BpvmFz5F.js","assets/go-oa77k3Q1.js","assets/golo-DnSZZkzZ.js","assets/gradle-xhSl5jRG.js","assets/groovy-BUGEyqOY.js","assets/haml-Q5moYl6B.js","assets/handlebars-B8gHazwq.js","assets/haskell-C_nTNVTF.js","assets/haxe-DEa-mhEM.js","assets/hsp-DAtUNrWr.js","assets/htmlbars-IZ5H55KS.js","assets/http-BlfIsTrN.js","assets/hy-BKHwYI3U.js","assets/inform7-DBoQipSc.js","assets/ini-rm_5Fj36.js","assets/irpf90-R1rxRBNO.js","assets/isbl-WbUbjWRI.js","assets/java-flBTnDBg.js","assets/javascript-Bi9wT7IL.js","assets/jboss-cli-BVqHepEU.js","assets/json-BvAVz8jQ.js","assets/julia-repl-Cpt_AFpB.js","assets/julia-B3zW89kP.js","assets/kotlin-CMZ_9XJI.js","assets/lasso-DVqtNSau.js","assets/latex-CFJv-UA6.js","assets/ldif-BS-KKOy0.js","assets/leaf--Z87tMVa.js","assets/less-CXBPSZIU.js","assets/lisp-cVmS95gk.js","assets/livecodeserver-BOOiQrUz.js","assets/livescript-CVxJe7N1.js","assets/llvm-DQeHJJ2W.js","assets/lsl-Bfxi34aD.js","assets/lua-DXxL7Qnq.js","assets/makefile-B5Fr6EdB.js","assets/markdown-DTODmQHl.js","assets/mathematica-XsKNpYVI.js","assets/matlab-BQHIwHUE.js","assets/maxima-4gc2wOHL.js","assets/mel-tWDc8R_0.js","assets/mercury-CMAR8Kmo.js","assets/mipsasm-CuThUvs6.js","assets/mizar-DJiOXbyw.js","assets/mojolicious-BHZ1FyrY.js","assets/monkey-Ckr0R6Af.js","assets/moonscript-rPHoYTbB.js","assets/n1ql-CVbFFpfR.js","assets/nginx-piKHOi7C.js","assets/nim-D2ljN6dK.js","assets/nix-BE-MXto5.js","assets/node-repl-DywEPp9w.js","assets/nsis-DQnnPyE6.js","assets/objectivec-DVFSpwpL.js","assets/ocaml-B9_ypEp1.js","assets/openscad-Cquxty4i.js","assets/oxygene-BtOMSMR6.js","assets/parser3-CWVyPD7l.js","assets/perl-DQMBOVA5.js","assets/pf-DhGORkJd.js","assets/pgsql-awwi5nDK.js","assets/php-template-Dsp4D0jE.js","assets/php-_c_VoeVa.js","assets/plaintext-7v3vLFp3.js","assets/pony-BVahP-cB.js","assets/powershell-DDAkbMgT.js","assets/processing-CCja83Ot.js","assets/profile-BjuA8z3S.js","assets/prolog-jJiPeztA.js","assets/properties-DK40DOVd.js","assets/protobuf-DJs85Lp7.js","assets/puppet-BPdGz-Jp.js","assets/purebasic-C8c2xseX.js","assets/python-repl-CLJQcHH8.js","assets/python-B-gHuzXK.js","assets/q-VmMkCWpr.js","assets/qml-BkIM5RCI.js","assets/r-CHi-Wrw8.js","assets/reasonml-B05iQ6f2.js","assets/rib-DzxrqgFS.js","assets/roboconf-DVxtd4X5.js","assets/routeros-C7PRtmmR.js","assets/rsl-CcIHTLD_.js","assets/ruby-BGhMoiTk.js","assets/ruleslanguage-2nOGmUbL.js","assets/rust-Bn5K3sZf.js","assets/sas-BOCzodK2.js","assets/scala-BRv9Y1Gl.js","assets/scheme-DgxU7T27.js","assets/scilab-CDpHNnol.js","assets/scss-_DXiA8XH.js","assets/shell-JZbpHYqw.js","assets/smali-D-pxIQI6.js","assets/smalltalk-BgHXrgWH.js","assets/sml-XMsOdlaX.js","assets/sqf-BAJmpDEs.js","assets/sql-qDDDtU5U.js","assets/sql_more-OsRq2zw0.js","assets/stan-btJKTWsQ.js","assets/stata-Bk4QaRj1.js","assets/step21-JBksYMyW.js","assets/stylus-B2-KoW99.js","assets/subunit-Dms0B4fv.js","assets/swift-BDkC6DWd.js","assets/taggerscript-BQuVNykw.js","assets/tap-Bwup7RHy.js","assets/tcl-CbpGYImD.js","assets/thrift-B_z8wKcZ.js","assets/tp-BJLBEN3J.js","assets/twig-nUEnJWT1.js","assets/typescript-CrQbuH5h.js","assets/vala-2XexN6SZ.js","assets/vbnet-BAt8krwo.js","assets/vbscript-html-yaZI43iV.js","assets/vbscript--ebsjfOw.js","assets/verilog-emU2h0-4.js","assets/vhdl-CPuOZFR2.js","assets/vim-ZfleAGCY.js","assets/x86asm-BHTiWqya.js","assets/xl-MlLWG0U8.js","assets/xml-CJKMw8W2.js","assets/xquery-B4Yi49S8.js","assets/yaml-5C-oV2Cp.js","assets/zephir-Dig9AotJ.js","assets/dist-BG8NAFfu.js","assets/function_calling-XyGNNvjR.js","assets/chunk_array-cMM4je5w.js","assets/llms-DmE4p8kW.js","assets/tools-DWDA-ZTt.js","assets/json-schema-processors-DSIsU0go.js","assets/schemas-79owEkeD.js","assets/dist-YxwKnKYL.js","assets/dist-CKth7ANk.js","assets/browser-CUjguYn6.js","assets/preload-helper-XLr9-hSf.js","assets/client-DEFMLVFC.js","assets/chunk-6E445R5C-ny1rw8Le.js","assets/chunk-RPN2XO5I-_4a18lz2.js","assets/chunk-UJPHRNQP-C81GjauI.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e,n as t,o as n,r,t as i}from"./chunk-zsgVPwQN.js";import{t as a}from"./chunk-3GQAWCBQ-C-9Cm0Np.js";import{n as o,t as s}from"./chunk-QWQYAQCK-CyFuZlX8.js";import{Et as c,Fn as l,Lt as u,S as d,Xn as f,Yn as p,dt as m,mn as h,rr as g,tr as _,ur as v,xn as y}from"./json-schema-processors-DSIsU0go.js";import{A as b,C as x,D as S,E as C,M as w,O as T,S as E,T as D,b as O,c as k,d as A,f as j,h as M,i as N,j as P,k as F,m as I,p as L,u as ee,v as te,w as R,x as z,y as ne}from"./client-DEFMLVFC.js";import{a as re,c as ie,d as ae,l as oe,n as se,o as ce,s as le,t as ue,u as de}from"./chunk-6E445R5C-ny1rw8Le.js";import{t as B}from"./preload-helper-XLr9-hSf.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var fe;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(fe||={});var pe;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(pe||={});var me=fe.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),V=e=>{switch(typeof e){case`undefined`:return me.undefined;case`string`:return me.string;case`number`:return Number.isNaN(e)?me.nan:me.number;case`boolean`:return me.boolean;case`function`:return me.function;case`bigint`:return me.bigint;case`symbol`:return me.symbol;case`object`:return Array.isArray(e)?me.array:e===null?me.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?me.promise:typeof Map<`u`&&e instanceof Map?me.map:typeof Set<`u`&&e instanceof Set?me.set:typeof Date<`u`&&e instanceof Date?me.date:me.object;default:return me.unknown}},H=fe.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),he=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,fe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t=Object.create(null),n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};he.create=e=>new he(e);var ge=(e,t)=>{let n;switch(e.code){case H.invalid_type:n=e.received===me.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case H.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,fe.jsonStringifyReplacer)}`;break;case H.unrecognized_keys:n=`Unrecognized key(s) in object: ${fe.joinValues(e.keys,`, `)}`;break;case H.invalid_union:n=`Invalid input`;break;case H.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${fe.joinValues(e.options)}`;break;case H.invalid_enum_value:n=`Invalid enum value. Expected ${fe.joinValues(e.options)}, received '${e.received}'`;break;case H.invalid_arguments:n=`Invalid function arguments`;break;case H.invalid_return_type:n=`Invalid function return type`;break;case H.invalid_date:n=`Invalid date`;break;case H.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:fe.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case H.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case H.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case H.custom:n=`Invalid input`;break;case H.invalid_intersection_types:n=`Intersection results could not be merged`;break;case H.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case H.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,fe.assertNever(e)}return{message:n}},_e=ge;function ve(){return _e}var ye=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function U(e,t){let n=ve(),r=ye({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===ge?void 0:ge].filter(e=>!!e)});e.common.issues.push(r)}var be=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return xe;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return xe;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}},xe=Object.freeze({status:`aborted`}),Se=e=>({status:`dirty`,value:e}),Ce=e=>({status:`valid`,value:e}),we=e=>e.status===`aborted`,Te=e=>e.status===`dirty`,Ee=e=>e.status===`valid`,De=e=>typeof Promise<`u`&&e instanceof Promise,Oe;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(Oe||={});var ke=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Ae=(e,t)=>{if(Ee(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){return this._error||=new he(e.common.issues),this._error}}};function je(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var Me=class{get description(){return this._def.description}_getType(e){return V(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:V(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new be,ctx:{common:e.parent.common,data:e.data,parsedType:V(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(De(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:V(e)};return Ae(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:V(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return Ee(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>Ee(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:V(e)},r=this._parse({data:e,path:n.path,parent:n});return Ae(n,await(De(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:H.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new Pt({schema:this,typeName:Gt.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return Ft.create(this,this._def)}nullable(){return It.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ht.create(this)}promise(){return Nt.create(this,this._def)}or(e){return vt.create([this,e],this._def)}and(e){return St.create(this,e,this._def)}transform(e){return new Pt({...je(this._def),schema:this,typeName:Gt.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new Lt({...je(this._def),innerType:this,defaultValue:t,typeName:Gt.ZodDefault})}brand(){return new Bt({typeName:Gt.ZodBranded,type:this,...je(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new Rt({...je(this._def),innerType:this,catchValue:t,typeName:Gt.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Vt.create(this,e)}readonly(){return Ht.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Ne=/^c[^\s-]{8,}$/i,Pe=/^[0-9a-z]+$/,Fe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ie=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Le=/^[a-z0-9_-]{21}$/i,Re=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ze=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Be=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ve=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,He,Ue=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,W=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,We=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Ge=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ke=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,qe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Je=`((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`,Ye=RegExp(`^${Je}$`);function Xe(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function Ze(e){return RegExp(`^${Xe(e)}$`)}function Qe(e){let t=`${Je}T${Xe(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function $e(e,t){return!!((t===`v4`||!t)&&Ue.test(e)||(t===`v6`||!t)&&We.test(e))}function et(e,t){if(!Re.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function tt(e,t){return!!((t===`v4`||!t)&&W.test(e)||(t===`v6`||!t)&&Ge.test(e))}var nt=class e extends Me{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==me.string){let t=this._getOrReturnCtx(e);return U(t,{code:H.invalid_type,expected:me.string,received:t.parsedType}),xe}let t=new be,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),U(n,{code:H.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),U(n,{code:H.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?U(n,{code:H.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&U(n,{code:H.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)Be.test(e.data)||(n=this._getOrReturnCtx(e,n),U(n,{validation:`email`,code:H.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)He||=new RegExp(Ve,`u`),He.test(e.data)||(n=this._getOrReturnCtx(e,n),U(n,{validation:`emoji`,code:H.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)Ie.test(e.data)||(n=this._getOrReturnCtx(e,n),U(n,{validation:`uuid`,code:H.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)Le.test(e.data)||(n=this._getOrReturnCtx(e,n),U(n,{validation:`nanoid`,code:H.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)Ne.test(e.data)||(n=this._getOrReturnCtx(e,n),U(n,{validation:`cuid`,code:H.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)Pe.test(e.data)||(n=this._getOrReturnCtx(e,n),U(n,{validation:`cuid2`,code:H.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)Fe.test(e.data)||(n=this._getOrReturnCtx(e,n),U(n,{validation:`ulid`,code:H.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),U(n,{validation:`url`,code:H.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),U(n,{validation:`regex`,code:H.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),U(n,{code:H.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),U(n,{code:H.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),U(n,{code:H.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?Qe(r).test(e.data)||(n=this._getOrReturnCtx(e,n),U(n,{code:H.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?Ye.test(e.data)||(n=this._getOrReturnCtx(e,n),U(n,{code:H.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?Ze(r).test(e.data)||(n=this._getOrReturnCtx(e,n),U(n,{code:H.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?ze.test(e.data)||(n=this._getOrReturnCtx(e,n),U(n,{validation:`duration`,code:H.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?$e(e.data,r.version)||(n=this._getOrReturnCtx(e,n),U(n,{validation:`ip`,code:H.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?et(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),U(n,{validation:`jwt`,code:H.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?tt(e.data,r.version)||(n=this._getOrReturnCtx(e,n),U(n,{validation:`cidr`,code:H.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?Ke.test(e.data)||(n=this._getOrReturnCtx(e,n),U(n,{validation:`base64`,code:H.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?qe.test(e.data)||(n=this._getOrReturnCtx(e,n),U(n,{validation:`base64url`,code:H.invalid_string,message:r.message}),t.dirty()):fe.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:H.invalid_string,...Oe.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...Oe.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...Oe.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...Oe.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...Oe.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...Oe.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...Oe.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...Oe.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...Oe.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...Oe.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...Oe.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...Oe.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...Oe.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...Oe.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...Oe.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...Oe.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...Oe.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...Oe.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...Oe.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...Oe.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...Oe.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...Oe.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...Oe.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...Oe.errToObj(t)})}nonempty(e){return this.min(1,Oe.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};nt.create=e=>new nt({checks:[],typeName:Gt.ZodString,coerce:e?.coerce??!1,...je(e)});function rt(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var it=class e extends Me{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==me.number){let t=this._getOrReturnCtx(e);return U(t,{code:H.invalid_type,expected:me.number,received:t.parsedType}),xe}let t,n=new be;for(let r of this._def.checks)r.kind===`int`?fe.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),U(t,{code:H.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),U(t,{code:H.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),U(t,{code:H.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?rt(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),U(t,{code:H.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),U(t,{code:H.not_finite,message:r.message}),n.dirty()):fe.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,Oe.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,Oe.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,Oe.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,Oe.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Oe.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:Oe.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:Oe.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:Oe.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:Oe.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:Oe.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:Oe.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:Oe.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:Oe.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:Oe.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&fe.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};it.create=e=>new it({checks:[],typeName:Gt.ZodNumber,coerce:e?.coerce||!1,...je(e)});var at=class e extends Me{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==me.bigint)return this._getInvalidInput(e);let t,n=new be;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),U(t,{code:H.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),U(t,{code:H.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),U(t,{code:H.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):fe.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return U(t,{code:H.invalid_type,expected:me.bigint,received:t.parsedType}),xe}gte(e,t){return this.setLimit(`min`,e,!0,Oe.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,Oe.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,Oe.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,Oe.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Oe.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:Oe.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:Oe.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:Oe.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:Oe.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:Oe.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};at.create=e=>new at({checks:[],typeName:Gt.ZodBigInt,coerce:e?.coerce??!1,...je(e)});var ot=class extends Me{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==me.boolean){let t=this._getOrReturnCtx(e);return U(t,{code:H.invalid_type,expected:me.boolean,received:t.parsedType}),xe}return Ce(e.data)}};ot.create=e=>new ot({typeName:Gt.ZodBoolean,coerce:e?.coerce||!1,...je(e)});var st=class e extends Me{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==me.date){let t=this._getOrReturnCtx(e);return U(t,{code:H.invalid_type,expected:me.date,received:t.parsedType}),xe}if(Number.isNaN(e.data.getTime()))return U(this._getOrReturnCtx(e),{code:H.invalid_date}),xe;let t=new be,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),U(n,{code:H.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),U(n,{code:H.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):fe.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:Oe.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:Oe.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};st.create=e=>new st({checks:[],coerce:e?.coerce||!1,typeName:Gt.ZodDate,...je(e)});var ct=class extends Me{_parse(e){if(this._getType(e)!==me.symbol){let t=this._getOrReturnCtx(e);return U(t,{code:H.invalid_type,expected:me.symbol,received:t.parsedType}),xe}return Ce(e.data)}};ct.create=e=>new ct({typeName:Gt.ZodSymbol,...je(e)});var lt=class extends Me{_parse(e){if(this._getType(e)!==me.undefined){let t=this._getOrReturnCtx(e);return U(t,{code:H.invalid_type,expected:me.undefined,received:t.parsedType}),xe}return Ce(e.data)}};lt.create=e=>new lt({typeName:Gt.ZodUndefined,...je(e)});var ut=class extends Me{_parse(e){if(this._getType(e)!==me.null){let t=this._getOrReturnCtx(e);return U(t,{code:H.invalid_type,expected:me.null,received:t.parsedType}),xe}return Ce(e.data)}};ut.create=e=>new ut({typeName:Gt.ZodNull,...je(e)});var dt=class extends Me{constructor(){super(...arguments),this._any=!0}_parse(e){return Ce(e.data)}};dt.create=e=>new dt({typeName:Gt.ZodAny,...je(e)});var ft=class extends Me{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ce(e.data)}};ft.create=e=>new ft({typeName:Gt.ZodUnknown,...je(e)});var pt=class extends Me{_parse(e){let t=this._getOrReturnCtx(e);return U(t,{code:H.invalid_type,expected:me.never,received:t.parsedType}),xe}};pt.create=e=>new pt({typeName:Gt.ZodNever,...je(e)});var mt=class extends Me{_parse(e){if(this._getType(e)!==me.undefined){let t=this._getOrReturnCtx(e);return U(t,{code:H.invalid_type,expected:me.void,received:t.parsedType}),xe}return Ce(e.data)}};mt.create=e=>new mt({typeName:Gt.ZodVoid,...je(e)});var ht=class e extends Me{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==me.array)return U(t,{code:H.invalid_type,expected:me.array,received:t.parsedType}),xe;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(U(t,{code:e?H.too_big:H.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(U(t,{code:H.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(U(t,{code:H.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new ke(t,e,t.path,n)))).then(e=>be.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new ke(t,e,t.path,n)));return be.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:Oe.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:Oe.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:Oe.toString(n)}})}nonempty(e){return this.min(1,e)}};ht.create=(e,t)=>new ht({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Gt.ZodArray,...je(t)});function gt(e){if(e instanceof _t){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=Ft.create(gt(r))}return new _t({...e._def,shape:()=>t})}else if(e instanceof ht)return new ht({...e._def,type:gt(e.element)});else if(e instanceof Ft)return Ft.create(gt(e.unwrap()));else if(e instanceof It)return It.create(gt(e.unwrap()));else if(e instanceof Ct)return Ct.create(e.items.map(e=>gt(e)));else return e}var _t=class e extends Me{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape();return this._cached={shape:e,keys:fe.objectKeys(e)},this._cached}_parse(e){if(this._getType(e)!==me.object){let t=this._getOrReturnCtx(e);return U(t,{code:H.invalid_type,expected:me.object,received:t.parsedType}),xe}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof pt&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new ke(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof pt){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(U(n,{code:H.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new ke(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>be.mergeObjectSync(t,e)):be.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return Oe.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:Oe.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Gt.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of fe.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of fe.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return gt(this)}partial(t){let n={};for(let e of fe.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of fe.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof Ft;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return At(fe.objectKeys(this.shape))}};_t.create=(e,t)=>new _t({shape:()=>e,unknownKeys:`strip`,catchall:pt.create(),typeName:Gt.ZodObject,...je(t)}),_t.strictCreate=(e,t)=>new _t({shape:()=>e,unknownKeys:`strict`,catchall:pt.create(),typeName:Gt.ZodObject,...je(t)}),_t.lazycreate=(e,t)=>new _t({shape:e,unknownKeys:`strip`,catchall:pt.create(),typeName:Gt.ZodObject,...je(t)});var vt=class extends Me{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new he(e.ctx.common.issues));return U(t,{code:H.invalid_union,unionErrors:n}),xe}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new he(e));return U(t,{code:H.invalid_union,unionErrors:i}),xe}}get options(){return this._def.options}};vt.create=(e,t)=>new vt({options:e,typeName:Gt.ZodUnion,...je(t)});var yt=e=>e instanceof Ot?yt(e.schema):e instanceof Pt?yt(e.innerType()):e instanceof kt?[e.value]:e instanceof jt?e.options:e instanceof Mt?fe.objectValues(e.enum):e instanceof Lt?yt(e._def.innerType):e instanceof lt?[void 0]:e instanceof ut?[null]:e instanceof Ft?[void 0,...yt(e.unwrap())]:e instanceof It?[null,...yt(e.unwrap())]:e instanceof Bt||e instanceof Ht?yt(e.unwrap()):e instanceof Rt?yt(e._def.innerType):[],bt=class e extends Me{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==me.object)return U(t,{code:H.invalid_type,expected:me.object,received:t.parsedType}),xe;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(U(t,{code:H.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),xe)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=yt(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:Gt.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...je(r)})}};function xt(e,t){let n=V(e),r=V(t);if(e===t)return{valid:!0,data:e};if(n===me.object&&r===me.object){let n=fe.objectKeys(t),r=fe.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=xt(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===me.array&&r===me.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=xt(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===me.date&&r===me.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var St=class extends Me{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(we(e)||we(r))return xe;let i=xt(e.value,r.value);return i.valid?((Te(e)||Te(r))&&t.dirty(),{status:t.value,value:i.data}):(U(n,{code:H.invalid_intersection_types}),xe)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};St.create=(e,t,n)=>new St({left:e,right:t,typeName:Gt.ZodIntersection,...je(n)});var Ct=class e extends Me{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==me.array)return U(n,{code:H.invalid_type,expected:me.array,received:n.parsedType}),xe;if(n.data.length<this._def.items.length)return U(n,{code:H.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),xe;!this._def.rest&&n.data.length>this._def.items.length&&(U(n,{code:H.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new ke(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>be.mergeArray(t,e)):be.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Ct.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new Ct({items:e,typeName:Gt.ZodTuple,rest:null,...je(t)})};var wt=class e extends Me{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==me.object)return U(n,{code:H.invalid_type,expected:me.object,received:n.parsedType}),xe;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new ke(n,e,n.path,e)),value:a._parse(new ke(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?be.mergeObjectAsync(t,r):be.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof Me?new e({keyType:t,valueType:n,typeName:Gt.ZodRecord,...je(r)}):new e({keyType:nt.create(),valueType:t,typeName:Gt.ZodRecord,...je(n)})}},Tt=class extends Me{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==me.map)return U(n,{code:H.invalid_type,expected:me.map,received:n.parsedType}),xe;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new ke(n,e,n.path,[a,`key`])),value:i._parse(new ke(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return xe;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return xe;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};Tt.create=(e,t,n)=>new Tt({valueType:t,keyType:e,typeName:Gt.ZodMap,...je(n)});var Et=class e extends Me{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==me.set)return U(n,{code:H.invalid_type,expected:me.set,received:n.parsedType}),xe;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(U(n,{code:H.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(U(n,{code:H.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return xe;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new ke(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:Oe.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:Oe.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Et.create=(e,t)=>new Et({valueType:e,minSize:null,maxSize:null,typeName:Gt.ZodSet,...je(t)});var Dt=class e extends Me{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==me.function)return U(t,{code:H.invalid_type,expected:me.function,received:t.parsedType}),xe;function n(e,n){return ye({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ve(),ge].filter(e=>!!e),issueData:{code:H.invalid_arguments,argumentsError:n}})}function r(e,n){return ye({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ve(),ge].filter(e=>!!e),issueData:{code:H.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof Nt){let e=this;return Ce(async function(...t){let o=new he([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return Ce(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new he([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new he([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Ct.create(t).rest(ft.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||Ct.create([]).rest(ft.create()),returns:n||ft.create(),typeName:Gt.ZodFunction,...je(r)})}},Ot=class extends Me{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Ot.create=(e,t)=>new Ot({getter:e,typeName:Gt.ZodLazy,...je(t)});var kt=class extends Me{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return U(t,{received:t.data,code:H.invalid_literal,expected:this._def.value}),xe}return{status:`valid`,value:e.data}}get value(){return this._def.value}};kt.create=(e,t)=>new kt({value:e,typeName:Gt.ZodLiteral,...je(t)});function At(e,t){return new jt({values:e,typeName:Gt.ZodEnum,...je(t)})}var jt=class e extends Me{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return U(t,{expected:fe.joinValues(n),received:t.parsedType,code:H.invalid_type}),xe}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return U(t,{received:t.data,code:H.invalid_enum_value,options:n}),xe}return Ce(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};jt.create=At;var Mt=class extends Me{_parse(e){let t=fe.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==me.string&&n.parsedType!==me.number){let e=fe.objectValues(t);return U(n,{expected:fe.joinValues(e),received:n.parsedType,code:H.invalid_type}),xe}if(this._cache||=new Set(fe.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=fe.objectValues(t);return U(n,{received:n.data,code:H.invalid_enum_value,options:e}),xe}return Ce(e.data)}get enum(){return this._def.values}};Mt.create=(e,t)=>new Mt({values:e,typeName:Gt.ZodNativeEnum,...je(t)});var Nt=class extends Me{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==me.promise&&t.common.async===!1?(U(t,{code:H.invalid_type,expected:me.promise,received:t.parsedType}),xe):Ce((t.parsedType===me.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Nt.create=(e,t)=>new Nt({type:e,typeName:Gt.ZodPromise,...je(t)});var Pt=class extends Me{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Gt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{U(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return xe;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?xe:r.status===`dirty`||t.value===`dirty`?Se(r.value):r});{if(t.value===`aborted`)return xe;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?xe:r.status===`dirty`||t.value===`dirty`?Se(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?xe:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?xe:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Ee(e))return xe;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>Ee(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):xe);fe.assertNever(r)}};Pt.create=(e,t,n)=>new Pt({schema:e,typeName:Gt.ZodEffects,effect:t,...je(n)}),Pt.createWithPreprocess=(e,t,n)=>new Pt({schema:t,effect:{type:`preprocess`,transform:e},typeName:Gt.ZodEffects,...je(n)});var Ft=class extends Me{_parse(e){return this._getType(e)===me.undefined?Ce(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ft.create=(e,t)=>new Ft({innerType:e,typeName:Gt.ZodOptional,...je(t)});var It=class extends Me{_parse(e){return this._getType(e)===me.null?Ce(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};It.create=(e,t)=>new It({innerType:e,typeName:Gt.ZodNullable,...je(t)});var Lt=class extends Me{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===me.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Lt.create=(e,t)=>new Lt({innerType:e,typeName:Gt.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...je(t)});var Rt=class extends Me{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return De(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new he(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new he(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Rt.create=(e,t)=>new Rt({innerType:e,typeName:Gt.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...je(t)});var zt=class extends Me{_parse(e){if(this._getType(e)!==me.nan){let t=this._getOrReturnCtx(e);return U(t,{code:H.invalid_type,expected:me.nan,received:t.parsedType}),xe}return{status:`valid`,value:e.data}}};zt.create=e=>new zt({typeName:Gt.ZodNaN,...je(e)});var Bt=class extends Me{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},Vt=class e extends Me{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?xe:e.status===`dirty`?(t.dirty(),Se(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?xe:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:Gt.ZodPipeline})}},Ht=class extends Me{_parse(e){let t=this._def.innerType._parse(e),n=e=>(Ee(e)&&(e.value=Object.freeze(e.value)),e);return De(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};Ht.create=(e,t)=>new Ht({innerType:e,typeName:Gt.ZodReadonly,...je(t)});function Ut(e,t){let n=typeof e==`function`?e(t):typeof e==`string`?{message:e}:e;return typeof n==`string`?{message:n}:n}function Wt(e,t={},n){return e?dt.create().superRefine((r,i)=>{let a=e(r);if(a instanceof Promise)return a.then(e=>{if(!e){let e=Ut(t,r),a=e.fatal??n??!0;i.addIssue({code:`custom`,...e,fatal:a})}});if(!a){let e=Ut(t,r),a=e.fatal??n??!0;i.addIssue({code:`custom`,...e,fatal:a})}}):dt.create()}_t.lazycreate;var Gt;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(Gt||={});var Kt=(e,t={message:`Input not instance of ${e.name}`})=>Wt(t=>t instanceof e,t),qt=nt.create,Jt=it.create;zt.create,at.create;var Yt=ot.create;st.create,ct.create,lt.create,ut.create;var Xt=dt.create;ft.create,pt.create,mt.create;var Zt=ht.create,Qt=_t.create;_t.strictCreate;var $t=vt.create;bt.create,St.create,Ct.create;var en=wt.create;Tt.create,Et.create;var tn=Dt.create;Ot.create;var nn=kt.create,rn=jt.create;Mt.create;var an=Nt.create;Pt.create,Ft.create,It.create,Pt.createWithPreprocess,Vt.create;function on(e){let t=Object.keys(e.mcpServers??{});N.getInstance().trackMCPClientInit({codeMode:!1,sandbox:!1,allCallbacks:!1,verify:!1,servers:t,numServers:t.length,isBrowser:!0}).catch(e=>o.debug(`Failed to track BrowserMCPClient init: ${e}`))}a(on,`trackBrowserClientInit`);var sn=class e extends ue{static{a(this,`BrowserMCPClient`)}static getPackageVersion(){return k()}constructor(e){super(e),on(this.config)}static fromDict(t){return new e(t)}createConnectorFromConfig(e){let{url:t,headers:n,fetch:r,authToken:i,authProvider:a,wrapTransport:s,clientOptions:c,disableSseFallback:l,preferSse:u,timeout:d,sseReadTimeout:f,gatewayUrl:p,serverId:m,reconnectionOptions:h}=e;if(!t)throw Error(`Server URL is required`);let g=this.config,_=ce(e,g),v=re(e.clientInfo??this.config.clientInfo),y={headers:n,fetch:r,authToken:i,authProvider:a,wrapTransport:s,clientOptions:c,onSampling:_.onSampling,onElicitation:_.onElicitation,onNotification:_.onNotification,disableSseFallback:l,preferSse:u,timeout:d,sseReadTimeout:f,clientInfo:v,gatewayUrl:p,serverId:m,reconnectionOptions:h};return o.debug(`[BrowserMCPClient] Connector options prepared (clientOptions: ${c?`provided`:`none`})`),new se(t,y)}};function cn(e){let t=a(()=>{throw Error(`Invalid url to pass to open(): ${e}`)},`abort`),n;try{n=new URL(e)}catch{t()}return n.protocol!==`https:`&&n.protocol!==`http:`&&t(),n.hostname!==encodeURIComponent(n.hostname)&&t(),n.username&&=encodeURIComponent(n.username),n.password&&=encodeURIComponent(n.password),n.pathname=n.pathname.slice(0,1)+encodeURIComponent(n.pathname.slice(1)).replace(/%2f/gi,`/`),n.search=n.search.slice(0,1)+Array.from(n.searchParams.entries()).map(ln).join(`&`),n.hash=n.hash.slice(0,1)+encodeURIComponent(n.hash.slice(1)),n.href}a(cn,`sanitizeUrl`);function ln([e,t]){return`${encodeURIComponent(e)}${t.length>0?`=${encodeURIComponent(t)}`:``}`}a(ln,`sanitizeParam`);async function un(e){return typeof e==`string`?e:e instanceof URLSearchParams||e instanceof FormData?Object.fromEntries(e.entries()):e instanceof Blob?await e.text():e}a(un,`serializeBody`);var dn=class{static{a(this,`BrowserOAuthClientProvider`)}serverUrl;storageKeyPrefix;serverUrlHash;clientName;clientUri;logoUri;callbackUrl;preventAutoAuth;useRedirectFlow;oauthProxyUrl;connectionUrl;originalFetch;pendingCodeVerifier=null;_lastOriginalResource=null;_cachedAuthServerUrl=null;_cachedMetadata=null;_refreshPromise=null;onPopupWindow;constructor(e,t={}){this.serverUrl=e,this.storageKeyPrefix=t.storageKeyPrefix||`mcp:auth`,this.serverUrlHash=this.hashString(e),this.clientName=t.clientName||`mcp-use`,this.clientUri=t.clientUri||(typeof window<`u`?window.location.origin:``),this.logoUri=t.logoUri||`https://mcp-use.com/logo.png`,this.callbackUrl=cn(t.callbackUrl||(typeof window<`u`?new URL(`/oauth/callback`,window.location.origin).toString():`/oauth/callback`)),this.preventAutoAuth=t.preventAutoAuth,this.useRedirectFlow=t.useRedirectFlow,this.oauthProxyUrl=t.oauthProxyUrl,this.connectionUrl=t.connectionUrl,this.onPopupWindow=t.onPopupWindow}installFetchInterceptor(){if(!this.oauthProxyUrl){console.warn(`[BrowserOAuthProvider] No OAuth proxy URL configured, skipping fetch interceptor installation`);return}if(!this.originalFetch)this.originalFetch=window.fetch;else{console.warn(`[BrowserOAuthProvider] Fetch interceptor already installed`);return}let e=this.oauthProxyUrl,t=this.connectionUrl,n=this.serverUrl,r=this.originalFetch;console.log(`[BrowserOAuthProvider] Installing fetch interceptor with proxy: ${e}`),window.fetch=async(i,a)=>{let o=typeof i==`string`?i:i instanceof URL?i.toString():i.url;if(!(o.includes(`/.well-known/`)||o.match(/\/(register|token|authorize)$/)))return await r(i,a);try{let t=new URL(o),n=new URL(e);if(t.origin===n.origin&&(t.pathname.startsWith(n.pathname)||o.includes(`/inspector/api/oauth`)))return await r(i,a)}catch{}try{let i=o.includes(`/.well-known/`),s=i?`${e}/metadata?url=${encodeURIComponent(o)}`:`${e}/proxy`;if(console.log(`[OAuth Proxy] Routing ${i?`metadata`:`request`} through: ${s}`),i){let e={...a?.headers?Object.fromEntries(new Headers(a.headers)):{}};t&&(e[`X-Connection-URL`]=t);let i=new URL(s);n&&i.searchParams.set(`mcp_url`,n);let o=await r(i.toString(),{...a,method:`GET`,headers:e});try{if((o.headers.get(`content-type`)||``).includes(`application/json`)){let e=await o.clone().json(),t=e&&typeof e==`object`&&typeof e._original_resource==`string`?e._original_resource:null;t&&(this._lastOriginalResource=t)}}catch{}return o}let c=a?.body?await un(a.body):void 0,l=await(await r(s,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:o,method:a?.method||`POST`,headers:a?.headers?Object.fromEntries(new Headers(a.headers)):{},body:c})})).json();return new Response(JSON.stringify(l.body),{status:l.status,statusText:l.statusText,headers:new Headers(l.headers)})}catch(e){return console.error(`[OAuth Proxy] Request failed, falling back to direct fetch:`,e),await r(i,a)}}}restoreFetch(){this.originalFetch&&=(console.log(`[BrowserOAuthProvider] Restoring original fetch`),window.fetch=this.originalFetch,void 0)}get redirectUrl(){return cn(this.callbackUrl)}get clientMetadata(){return{redirect_uris:[this.redirectUrl],token_endpoint_auth_method:`none`,grant_types:[`authorization_code`,`refresh_token`],response_types:[`code`],client_name:this.clientName,client_uri:this.clientUri,logo_uri:this.logoUri}}async clientInformation(){let e=this.getKey(`client_info`),t=localStorage.getItem(e);if(t)try{let n=JSON.parse(t),r=Array.isArray(n.redirect_uris)?n.redirect_uris:[];if(!(r.length===0||r.includes(this.redirectUrl))){console.info(`[${this.storageKeyPrefix}] Invalidating cached OAuth client info due to redirect URI mismatch.`),localStorage.removeItem(e),localStorage.removeItem(this.getKey(`tokens`)),localStorage.removeItem(this.getKey(`last_auth_url`));return}return n}catch(t){console.warn(`[${this.storageKeyPrefix}] Failed to parse client information:`,t),localStorage.removeItem(e);return}}async saveClientInformation(e){let t=this.getKey(`client_info`);localStorage.setItem(t,JSON.stringify(e))}async tokens(){let e=this.getKey(`tokens`),t=localStorage.getItem(e);if(t)try{let e=JSON.parse(t);if(e.access_token&&e.refresh_token)try{let t=JSON.parse(atob(e.access_token.split(`.`)[1]));if(t.exp&&Date.now()>=(t.exp-30)*1e3){console.log(`[tokens] Access token expiring soon, refreshing...`);let t=await this._dedupedRefresh(e);if(t)return console.log(`[tokens] Refreshed successfully`),t}}catch{}return e}catch(t){console.warn(`[${this.storageKeyPrefix}] Failed to parse tokens:`,t),localStorage.removeItem(e);return}}async saveTokens(e){let t=this.getKey(`tokens`);localStorage.setItem(t,JSON.stringify(e)),localStorage.removeItem(this.getKey(`code_verifier`)),localStorage.removeItem(this.getKey(`last_auth_url`)),this.pendingCodeVerifier=null}async _refresh(e){try{if(!this._cachedAuthServerUrl||!this._cachedMetadata){let e=(await oe(this.serverUrl)).authorization_servers?.[0];if(!e)return null;let t=await ie(e);if(!t)return null;this._cachedAuthServerUrl=e,this._cachedMetadata=t}let t=await this.clientInformation();if(!t)return null;let n=await ae(this._cachedAuthServerUrl,{metadata:this._cachedMetadata,clientInformation:t,refreshToken:e.refresh_token});return await this.saveTokens(n),n}catch{return null}}async _dedupedRefresh(e){if(this._refreshPromise)return this._refreshPromise;this._refreshPromise=this._refresh(e);try{return await this._refreshPromise}finally{this._refreshPromise=null}}async invalidateCredentials(e){switch(e){case`all`:localStorage.removeItem(this.getKey(`tokens`)),localStorage.removeItem(this.getKey(`client_info`)),localStorage.removeItem(this.getKey(`code_verifier`)),localStorage.removeItem(this.getKey(`last_auth_url`)),this.pendingCodeVerifier=null;break;case`client`:localStorage.removeItem(this.getKey(`client_info`));break;case`tokens`:localStorage.removeItem(this.getKey(`tokens`));break;case`verifier`:localStorage.removeItem(this.getKey(`code_verifier`)),this.pendingCodeVerifier=null;break;default:break}}async saveCodeVerifier(e){let t=this.getKey(`code_verifier`);localStorage.setItem(t,e),this.pendingCodeVerifier=e}async codeVerifier(){let e=this.getKey(`code_verifier`),t=localStorage.getItem(e);if(!t)throw Error(`[${this.storageKeyPrefix}] Code verifier not found in storage for key ${e}. Auth flow likely corrupted or timed out.`);return t}async prepareAuthorizationUrl(e){let t=e.searchParams.get(`resource`),n=!!(t&&(t.includes(`/inspector/api/proxy`)||t.includes(`/api/proxy`)||t.includes(`localhost:3000`))),r=!!(t&&this.connectionUrl&&t===this.connectionUrl),i=!!(t&&(this._lastOriginalResource||this.serverUrl)&&(r||n)),a=this._lastOriginalResource||this.serverUrl;i&&a&&e.searchParams.set(`resource`,a);let o=globalThis.crypto.randomUUID(),s=`${this.storageKeyPrefix}:state_${o}`,c=this.pendingCodeVerifier||localStorage.getItem(this.getKey(`code_verifier`)),l={serverUrlHash:this.serverUrlHash,expiry:Date.now()+1e3*60*10,codeVerifier:c||void 0,providerOptions:{serverUrl:this.serverUrl,storageKeyPrefix:this.storageKeyPrefix,clientName:this.clientName,clientUri:this.clientUri,callbackUrl:this.callbackUrl,oauthProxyUrl:this.oauthProxyUrl,connectionUrl:this.connectionUrl},flowType:this.useRedirectFlow?`redirect`:`popup`,returnUrl:typeof window<`u`?window.location.href:void 0};console.log(`[OAuth] Storing state key: ${s}`),localStorage.setItem(s,JSON.stringify(l));let u=localStorage.getItem(s);console.log(`[OAuth] State stored successfully: ${!!u}`),e.searchParams.set(`state`,o);let d=cn(e.toString());return localStorage.setItem(this.getKey(`last_auth_url`),d),d}async redirectToAuthorization(e){let t=await this.prepareAuthorizationUrl(e);if(this.preventAutoAuth){console.info(`[${this.storageKeyPrefix}] Auto-auth prevented. Authorization URL stored for manual trigger.`);return}if(this.useRedirectFlow){console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL (full-page redirect).`),window.location.href=t;return}let n=`width=600,height=700,resizable=yes,scrollbars=yes,status=yes`;try{let e=window.open(t,`mcp_auth_${this.serverUrlHash}`,n);this.onPopupWindow&&this.onPopupWindow(t,n,e),!e||e.closed||e.closed===void 0?console.warn(`[${this.storageKeyPrefix}] Popup likely blocked by browser. Manual navigation might be required using the stored URL.`):(e.focus(),console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL in popup.`))}catch(e){console.error(`[${this.storageKeyPrefix}] Error opening popup window:`,e)}}getLastAttemptedAuthUrl(){let e=localStorage.getItem(this.getKey(`last_auth_url`));return e?cn(e):null}clearStorage(){let e=`${this.storageKeyPrefix}_${this.serverUrlHash}_`,t=`${this.storageKeyPrefix}:state_`,n=[],r=0;for(let r=0;r<localStorage.length;r++){let i=localStorage.key(r);if(i){if(i.startsWith(e))n.push(i);else if(i.startsWith(t))try{let e=localStorage.getItem(i);e&&JSON.parse(e).serverUrlHash===this.serverUrlHash&&n.push(i)}catch(e){console.warn(`[${this.storageKeyPrefix}] Error parsing state key ${i} during clearStorage:`,e)}}}return[...new Set(n)].forEach(e=>{localStorage.removeItem(e),r++}),r}hashString(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return Math.abs(t).toString(16)}getKey(e){return`${this.storageKeyPrefix}_${this.serverUrlHash}_${e}`}};async function fn(){let e=new URLSearchParams(window.location.search),t=e.get(`code`),n=e.get(`state`),r=e.get(`error`),i=e.get(`error_description`),a=`[mcp-callback]`;console.log(`${a} Handling callback...`,{code:t,state:n,error:r,errorDescription:i});let o=null,s=null,c=null;try{if(r)throw Error(`OAuth error: ${r} - ${i||`No description provided.`}`);if(!t)throw Error(`Authorization code not found in callback query parameters.`);if(!n)throw Error(`State parameter not found or invalid in callback query parameters.`);console.log(`[mcp-callback] Looking for state: ${n}`),console.log(`[mcp-callback] All localStorage keys:`,Object.keys(localStorage));let e=`mcp:auth:state_${n}`;if(localStorage.getItem(e))c=e,console.log(`[mcp-callback] Found state with default key: ${e}`);else{let e=`:state_${n}`;for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n&&n.endsWith(e)){c=n,console.log(`[mcp-callback] Found state with dynamic key: ${n}`);break}}}if(!c){let e=Object.keys(localStorage).filter(e=>e.includes(`state`));throw console.log(`[mcp-callback] State keys in storage:`,e),Error(`Invalid or expired state parameter "${n}". No matching state found in storage.`)}let l=localStorage.getItem(c);if(!l)throw Error(`Invalid or expired state parameter "${n}". No matching state found in storage.`);try{s=JSON.parse(l)}catch{throw Error(`Failed to parse stored OAuth state.`)}if(!s.expiry||s.expiry<Date.now())throw localStorage.removeItem(c),Error(`OAuth state has expired. Please try initiating authentication again.`);if(!s.providerOptions)throw Error(`Stored state is missing required provider options.`);let{serverUrl:u,...d}=s.providerOptions,f=d.connectionUrl,p=!!(f&&/run\.mcp-use\.com|mcp-use\.run/.test(f)),m=p?f:void 0,h=d.oauthProxyUrl,g=m;if(!h&&g)try{let e=new URL(window.location.href);if(e.pathname.includes(`/oauth/callback`)){let t=e.pathname.replace(/\/oauth\/callback.*$/,``);(!t||t===``)&&(/run\.mcp-use\.com|mcp-use\.run/.test(g)?console.log(`${a} Gateway connection detected; skipping default /inspector OAuth proxy inference`):(t=`/inspector`,console.log(`${a} Callback at root /oauth/callback, using /inspector as base path for OAuth proxy`))),t&&(h=`${e.origin}${t}/api/oauth`),console.log(`${a} Inferred OAuth proxy URL from callback: ${h}`)}}catch(e){console.warn(`${a} Could not infer OAuth proxy URL:`,e)}console.log(`${a} Re-instantiating provider for server: ${u}`),o=new dn(u,{...d,oauthProxyUrl:h,connectionUrl:g});let _=`${d.storageKeyPrefix}_${s.serverUrlHash}_code_verifier`,v=s.codeVerifier||localStorage.getItem(_);if(v)localStorage.setItem(_,v),localStorage.setItem(o.getKey(`code_verifier`),v);else throw Error(`[${d.storageKeyPrefix}] Code verifier missing for OAuth state ${n}. Please restart authentication.`);h&&(console.log(`${a} Installing fetch interceptor for token exchange (proxy: ${h})`),o.installFetchInterceptor()),console.log(`${a} Calling SDK auth() to exchange code...`);let y=p&&g?g:u;console.log(`${a} Using SDK serverUrl: ${y} (connectionUrl: ${g||`none`})`);let b=await le(o,{serverUrl:y,authorizationCode:t});if(b===`AUTHORIZED`)if(console.log(`${a} Authorization successful via SDK auth().`),s.flowType===`redirect`&&s.returnUrl)console.log(`${a} Redirect flow complete. Returning to: ${s.returnUrl}`),localStorage.removeItem(c),window.location.href=s.returnUrl;else if(window.opener&&!window.opener.closed)console.log(`${a} Popup flow complete. Notifying opener...`),window.opener.postMessage({type:`mcp_auth_callback`,success:!0},window.location.origin),localStorage.removeItem(c),window.close();else if(s.returnUrl)console.log(`${a} Popup flow without opener. Returning to: ${s.returnUrl}`),localStorage.removeItem(c),window.location.href=s.returnUrl;else{console.warn(`${a} No opener window or return URL detected. Redirecting to root.`),localStorage.removeItem(c);let e=window.location.pathname.split(`/`).filter(Boolean),t=e.length>0&&e[e.length-1]===`callback`?`/`+e.slice(0,-2).join(`/`):`/`;window.location.href=t||`/`}else throw console.warn(`${a} SDK auth() returned unexpected status: ${b}`),Error(`Unexpected result from authentication library: ${b}`)}catch(e){console.error(`${a} Error during OAuth callback handling:`,e);let t=e instanceof Error?e.message:String(e);window.opener&&!window.opener.closed&&window.opener.postMessage({type:`mcp_auth_callback`,success:!1,error:t},window.location.origin);try{document.body.innerHTML=``;let n=document.createElement(`div`);n.style.fontFamily=`sans-serif`,n.style.padding=`20px`;let r=document.createElement(`h1`);r.textContent=`Authentication Error`,n.appendChild(r);let i=document.createElement(`p`);i.style.color=`red`,i.style.backgroundColor=`#ffebeb`,i.style.border=`1px solid red`,i.style.padding=`10px`,i.style.borderRadius=`4px`,i.textContent=t,n.appendChild(i);let a=document.createElement(`p`);a.textContent=`You can close this window or `;let o=document.createElement(`a`);if(o.href=`#`,o.textContent=`click here to close`,o.onclick=e=>(e.preventDefault(),window.close(),!1),a.appendChild(o),a.appendChild(document.createTextNode(`.`)),n.appendChild(a),e instanceof Error&&e.stack){let t=document.createElement(`pre`);t.style.fontSize=`0.8em`,t.style.color=`#555`,t.style.marginTop=`20px`,t.style.whiteSpace=`pre-wrap`,t.textContent=e.stack,n.appendChild(t)}document.body.appendChild(n)}catch(e){console.error(`${a} Could not display error in callback window:`,e)}c&&localStorage.removeItem(c),o&&localStorage.removeItem(o.getKey(`last_auth_url`))}}a(fn,`onMcpAuthorization`);var pn=s.get(`RpcLogger`),mn=new class{static{a(this,`RpcLogStore`)}logs=[];listeners=new Set;maxLogs=1e3;publish(e){pn.debug(`[RPC Logger] Publishing log:`,e.direction,e.serverId,e.message?.method),this.logs.push(e),this.logs.length>this.maxLogs&&(this.logs=this.logs.slice(-this.maxLogs)),pn.debug(`[RPC Logger] Total logs:`,this.logs.length,`Listeners:`,this.listeners.size),this.listeners.forEach(t=>{try{t(e)}catch(e){pn.error(`[RPC Logger] Listener error:`,e)}})}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}getLogsForServer(e){return this.logs.filter(t=>t.serverId===e)}getAllLogs(){return[...this.logs]}clear(e){e?this.logs=this.logs.filter(t=>t.serverId!==e):this.logs=[]}};function hn(e){return mn.getLogsForServer(e)}a(hn,`getRpcLogs`);function gn(){return mn.getAllLogs()}a(gn,`getAllRpcLogs`);function _n(e){return mn.subscribe(e)}a(_n,`subscribeToRpcLogs`);function vn(e){mn.clear(e)}a(vn,`clearRpcLogs`);function yn(e,t){class n{constructor(e){this.inner=e,this.inner.onmessage=(e,n)=>{mn.publish({serverId:t,direction:`receive`,timestamp:new Date().toISOString(),message:e}),this.onmessage?.(e,n)},this.inner.onclose=()=>{this.onclose?.()},this.inner.onerror=e=>{this.onerror?.(e)}}static{a(this,`LoggingTransport`)}onclose;onerror;onmessage;async start(){typeof this.inner.start==`function`&&await this.inner.start()}async send(e,n){mn.publish({serverId:t,direction:`send`,timestamp:new Date().toISOString(),message:e}),await this.inner.send(e,n)}async close(){await this.inner.close()}get sessionId(){return this.inner.sessionId}setProtocolVersion(e){typeof this.inner.setProtocolVersion==`function`&&this.inner.setProtocolVersion(e)}}return new n(e)}a(yn,`wrapTransportForLogging`);var bn=i((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function N(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,N(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),N(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+j(a,u),c+=N(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+j(a,u++),c+=N(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return N(M(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function P(e,t,n){if(e==null)return e;var r=[],i=0;return N(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function F(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var I=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},L={map:P,forEach:function(e,t,n){P(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return P(e,function(){t++}),t},toArray:function(e){return P(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=L,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:F}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,I)}catch(e){I(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.4`})),xn=i(((e,t)=>{t.exports=bn()})),G=n(xn(),1);async function Sn(e,t=fetch){let n=e.replace(/\/$/,``),r=await t(n.endsWith(`/mcp`)?n:`${n}/mcp`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({jsonrpc:`2.0`,method:`initialize`,id:1,params:{}})});if(r.status!==401)return{};let{resourceMetadataUrl:i,scope:a}=de(r);return{resourceMetadataUrl:i,scope:a}}a(Sn,`probeAuthParams`);function Cn(e,t){if(!e)throw Error(t)}a(Cn,`assert`);function wn(e){return e===`localhost`||e===`127.0.0.1`||e.startsWith(`127.`)||e.startsWith(`192.168.`)||e.startsWith(`10.`)||e.startsWith(`172.`)}a(wn,`isLocalServer`);function Tn(e){let t=e.split(`.`),n=[];for(let e=0;e<t.length-1;e++)n.push(t.slice(e).join(`.`));return n}a(Tn,`getSubdomainLevels`);function En(e){return new Promise((t,n)=>{let r=new FileReader;r.onloadend=()=>{t(r.result)},r.onerror=n,r.readAsDataURL(e)})}a(En,`blobToBase64`);async function Dn(e){console.debug(`[favicon-detector] Starting favicon detection for:`,e);try{let t;if(t=e.startsWith(`http://`)||e.startsWith(`https://`)?new URL(e).hostname:e.includes(`://`)?e.split(`://`)[1].split(`/`)[0]:e.split(`/`)[0],console.debug(`[favicon-detector] Extracted domain:`,t),wn(t))return console.debug(`[favicon-detector] Skipping local server:`,t),null;let n=Tn(t);console.debug(`[favicon-detector] Domains to try:`,n);for(let e of n)try{let t=`https://favicon.tools.mcp-use.com/${e}?response=json`;console.debug(`[favicon-detector] Attempting to fetch favicon metadata for:`,e,`from:`,t);let n=new AbortController,r=setTimeout(()=>n.abort(),2e3);try{let i=await fetch(t,{signal:n.signal});if(clearTimeout(r),!i.ok){console.debug(`[favicon-detector] Fetch failed for`,e,`with status:`,i.status);continue}let a=await i.json();console.debug(`[favicon-detector] Retrieved favicon metadata for:`,e,`source:`,a.source);let o=a.url.replace(/^http:\/\//,`https://`),s=await fetch(o);if(!s.ok){console.debug(`[favicon-detector] Failed to fetch favicon image for`,e,`status:`,s.status);continue}let c=await s.blob(),l=await En(c);if(a.source===`default`){console.debug(`[favicon-detector] Found default favicon for:`,e,`skipping and continuing to search for non-default`);continue}return console.debug(`[favicon-detector] Successfully retrieved non-default favicon for:`,e,`source:`,a.source,`size:`,c.size,`bytes`),l}catch(t){clearTimeout(r),console.debug(`[favicon-detector] Fetch error for`,e,`:`,t instanceof Error?t.message:String(t));continue}}catch(t){console.debug(`[favicon-detector] Error processing domain`,e,`:`,t instanceof Error?t.message:String(t));continue}return console.debug(`[favicon-detector] No non-default favicon found for:`,e,`returning null to show gradient fallback`),null}catch(e){return console.warn(`[favicon-detector] Error detecting favicon:`,e),null}}a(Dn,`detectFavicon`);function On(e,t){let n=t?.headers??t?.customHeaders??{};if(t?.customHeaders&&!t?.headers&&console.warn(`[applyProxyConfig] The "customHeaders" option in proxyConfig is deprecated. Use "headers" instead.`),!t?.proxyAddress)return{url:e,headers:n};let r=new URL(t.proxyAddress),i=new URL(e);return{url:`${r.origin}${r.pathname}${i.pathname}${i.search}`,headers:{"X-Target-URL":e,...n}}}a(On,`applyProxyConfig`);var kn=`inspector-server`;function An(e){return{name:e.name,version:e.version,uri:e.websiteUrl,logo_uri:e.icons?.[0]?.src}}a(An,`deriveOAuthClientConfigFromClientInfo`);function jn(e){let t=(e instanceof Error?e.message:String(e)).toLowerCase();return t.includes(`oauth discovery failed`)||t.includes(`oauth-authorization-server`)||t.includes(`not valid json`)||t.includes(`404`)&&(t.includes(`openid-configuration`)||t.includes(`oauth-protected-resources`)||t.includes(`oauth-authorization-url`)||t.includes(`register`))||t.includes(`invalid oauth error response`)&&t.includes(`not found`)}a(jn,`isOAuthDiscoveryFailure`);function Mn(e){if(!e)return;let t=new URL(e),n=t.pathname.replace(/\/proxy\/?$/,``);return`${t.origin}${n}/oauth`}a(Mn,`deriveOAuthProxyUrl`);function Nn(e){let t=Mn(e.gatewayUrl),n=new dn(e.effectiveOAuthUrl,{storageKeyPrefix:e.storageKeyPrefix,clientName:e.oauthClientConfig.name,clientUri:e.oauthClientConfig.uri,logoUri:e.oauthClientConfig.logo_uri||`https://mcp-use.com/logo.png`,callbackUrl:e.callbackUrl,preventAutoAuth:e.preventAutoAuth,useRedirectFlow:e.useRedirectFlow,oauthProxyUrl:t,connectionUrl:e.gatewayUrl,onPopupWindow:e.onPopupWindow});return t&&e.installFetchInterceptor&&n.installFetchInterceptor(),{provider:n,oauthProxyUrl:t}}a(Nn,`createBrowserOAuthProvider`);function Pn(e){let t=null,n=Date.now(),r=e.healthCheckIntervalMs??1e4,i=e.healthCheckTimeoutMs??3e4,o=a(async()=>{if(!e.isMountedRef.current||e.stateRef.current!==`ready`){t&&=(clearInterval(t),null);return}try{let t=e.gatewayUrl||e.url;if(!t)return;let r=e.getAuthHeaders?await e.getAuthHeaders():{},i=await fetch(t,{method:`HEAD`,headers:{...e.allHeaders,...r},signal:AbortSignal.timeout(5e3)});if(i.ok||i.status<500)n=Date.now();else throw Error(`Server returned ${i.status}`)}catch{let r=Date.now()-n;r>i&&(e.addLog(`warn`,`Connection appears to be broken (no response for ${Math.round(r/1e3)}s), attempting to reconnect...`),t&&=(clearInterval(t),null),e.autoReconnectRef.current&&e.isMountedRef.current&&(e.setState(`discovering`),e.addLog(`info`,`Auto-reconnecting to MCP server...`),setTimeout(()=>{e.isMountedRef.current&&e.stateRef.current===`discovering`&&e.connect()},typeof e.autoReconnectRef.current==`number`?e.autoReconnectRef.current:e.defaultReconnectDelay)))}},`checkConnectionHealth`);return t=setInterval(o,r),()=>{t&&=(clearInterval(t),null)}}a(Pn,`startConnectionHealthMonitoring`);var Fn=3e3,In=5e3;function Ln(e){let{url:t,enabled:n=!0,callbackUrl:r=typeof window<`u`?cn(new URL(`/oauth/callback`,window.location.origin).toString()):`/oauth/callback`,storageKeyPrefix:i=`mcp:auth`,clientConfig:c={},authProvider:l,headers:u,customHeaders:d,proxyConfig:f,autoProxyFallback:p=!0,debug:m=!1,logLevel:h,autoRetry:g=!1,autoReconnect:_=Fn,reconnectionOptions:v,transportType:y=`auto`,preventAutoAuth:b=!0,useRedirectFlow:x=!1,onPopupWindow:S,timeout:C=3e4,sseReadTimeout:w=3e5,wrapTransport:T,fetch:E,clientOptions:D,onNotification:O,onSampling:A,samplingCallback:j,onElicitation:M,elicitationCallback:P}=e,F=(0,G.useMemo)(()=>{let e=`useMcp:${t||`no-url`}`,n=s.get(e);return h?n.level=h:m&&(n.level=`debug`),n},[t,h,m]),I=u??d??{};d&&!u&&F.warn(`[useMcp] The "customHeaders" option is deprecated. Use "headers" instead.`);let L=A??j;j&&!A&&F.warn(`[useMcp] The "samplingCallback" option is deprecated. Use "onSampling" instead.`);let ee=M??P;P&&!M&&o.warn(`[useMcp] The "elicitationCallback" option is deprecated. Use "onElicitation" instead.`);let te=(0,G.useMemo)(()=>({name:`mcp-use`,title:`mcp-use`,version:k(),description:`mcp-use is a complete TypeScript framework for building and using MCP`,icons:[{src:`https://mcp-use.com/logo.png`}],websiteUrl:`https://mcp-use.com`}),[]),R=(0,G.useMemo)(()=>e.clientInfo?{...te,...e.clientInfo}:te,[e.clientInfo,te]),z=(0,G.useMemo)(()=>An(R),[R]),ne=(0,G.useMemo)(()=>c&&Object.keys(c).length>0?(F.warn(`[useMcp] The 'clientConfig' option is deprecated and will be removed in a future version. Use 'clientInfo' instead. The clientConfig will be automatically derived from clientInfo.`),{...z,...c}):z,[c,z]),re=(0,G.useMemo)(()=>p?typeof p==`boolean`?{enabled:p,proxyAddress:`https://inspector.mcp-use.com/inspector/api/proxy`}:{enabled:p.enabled!==!1,proxyAddress:p.proxyAddress||`https://inspector.mcp-use.com/inspector/api/proxy`}:{enabled:!1,proxyAddress:void 0},[p]),ie=(0,G.useMemo)(()=>_===!1?{enabled:!1,initialDelay:0,healthCheckInterval:!1,healthCheckTimeout:3e4}:_===!0?{enabled:!0,initialDelay:Fn,healthCheckInterval:1e4,healthCheckTimeout:3e4}:typeof _==`number`?{enabled:!0,initialDelay:_,healthCheckInterval:1e4,healthCheckTimeout:3e4}:{enabled:_.enabled!==!1,initialDelay:_.initialDelay??Fn,healthCheckInterval:_.healthCheckInterval??1e4,healthCheckTimeout:_.healthCheckTimeout??3e4},[_]),ae=(0,G.useRef)(!1),[oe,se]=(0,G.useState)(f);(0,G.useEffect)(()=>{se(f)},[f]);let{gatewayUrl:ce,proxyHeaders:ue}=(0,G.useMemo)(()=>{let e=On(t||``,f);return{gatewayUrl:f?.proxyAddress,proxyHeaders:e.headers}},[t,f]),de=(0,G.useMemo)(()=>t||``,[t]),B=(0,G.useMemo)(()=>({...ue,...I}),[ue,I]),[fe,pe]=(0,G.useState)(`discovering`),[me,V]=(0,G.useState)([]),[H,he]=(0,G.useState)([]),[ge,_e]=(0,G.useState)([]),[ve,ye]=(0,G.useState)([]),[U,be]=(0,G.useState)(e._initialServerInfo?.name?e._initialServerInfo:void 0),[xe,Se]=(0,G.useState)(),[Ce,we]=(0,G.useState)(void 0),[Te,Ee]=(0,G.useState)([]),[De,Oe]=(0,G.useState)(void 0),[ke,Ae]=(0,G.useState)(void 0),je=(0,G.useRef)(null),Me=(0,G.useRef)(l??null),Ne=(0,G.useRef)(null),Pe=(0,G.useRef)(!1),Fe=(0,G.useRef)(!0),Ie=(0,G.useRef)(0),Le=(0,G.useRef)(null),Re=(0,G.useRef)(!1),ze=(0,G.useRef)(fe),Be=(0,G.useRef)(_),Ve=(0,G.useRef)(null),He=(0,G.useRef)(null),Ue=(0,G.useRef)(null);(0,G.useEffect)(()=>{ze.current=fe,Be.current=_},[fe,_]),(0,G.useEffect)(()=>{Me.current=l??null},[l]);let W=(0,G.useCallback)((e,t,...n)=>{let r=n.length>0?`${t} ${n.map(e=>JSON.stringify(e)).join(` `)}`:t,i=`[useMcp] ${r}`;switch(e){case`error`:F.error(i);break;case`warn`:F.warn(i);break;case`info`:F.info(i);break;case`debug`:F.debug(i);break;default:F.info(i)}Fe.current&&Ee(t=>[...t.slice(-100),{level:e,message:r,timestamp:Date.now()}])},[F]),We=(0,G.useCallback)(async(e=!1)=>{if(e||W(`info`,`Disconnecting...`),Pe.current=!1,Le.current&&clearTimeout(Le.current),Le.current=null,je.current)try{let e=kn,t=je.current.getSession(e);t&&t._healthCheckCleanup&&(t._healthCheckCleanup(),t._healthCheckCleanup=null),t&&await je.current.closeSession(e)}catch(t){e||W(`warn`,`Error closing session:`,t)}je.current=null,Fe.current&&!e&&(pe(`discovering`),V([]),he([]),_e([]),ye([]),we(void 0),Oe(void 0))},[W]),Ge=(0,G.useCallback)((e,n)=>{W(`error`,e,n??``);let r=n&&`code`in n?n.code:void 0,i=re.enabled&&!oe?.proxyAddress,a=e.includes(`CORS`)||e.includes(`blocked by CORS policy`)||e.includes(`Failed to fetch`),o=r===400;if(i&&(a||o||typeof r==`number`&&r>=404&&r<500)&&!(r===401||r===403))return W(`info`,`Direct connection failed with ${a?`CORS error`:o?`HTTP 400 (Bad Request)`:`HTTP 4xx error`}. Trying with proxy...`),je.current=null,l||(Me.current=null),W(`debug`,`Cleared client and auth provider for proxy fallback`),se({proxyAddress:re.proxyAddress}),Fe.current&&pe(`discovering`),setTimeout(()=>{Fe.current&&He.current?.()},1e3),!0;if(Fe.current){W(`info`,`Setting state to FAILED:`,e),pe(`failed`),we(e);let t=Me.current?.getLastAttemptedAuthUrl?.();t&&(Oe(t),W(`info`,`Manual authentication URL may be available.`,t))}return Pe.current=!1,t&&N.getInstance().trackUseMcpConnection({url:t,transportType:y,success:!1,errorType:n?.name||`UnknownError`,hasOAuth:!!Me.current,hasSampling:!!L,hasElicitation:!!ee}).catch(()=>{}),!1},[W,t,y,L,ee,re,oe,l]),Ke=(0,G.useCallback)(async()=>{if(!n||!t){W(`debug`,n?`No server URL provided, skipping connection.`:`Connection disabled via enabled flag.`);return}if(Pe.current){W(`debug`,`Connection attempt already in progress.`);return}if(!Fe.current){W(`debug`,`Connect called after unmount, aborting.`);return}if(Pe.current=!0,Ie.current+=1,we(void 0),Oe(void 0),Ve.current=null,pe(`discovering`),W(`info`,`Connecting attempt #${Ie.current} to ${t}...`),!Me.current){let{provider:e,oauthProxyUrl:t}=Nn({effectiveOAuthUrl:de,storageKeyPrefix:i,oauthClientConfig:ne,callbackUrl:r,preventAutoAuth:b,useRedirectFlow:x,gatewayUrl:ce,onPopupWindow:S,installFetchInterceptor:!0});Me.current=e,t&&W(`debug`,`OAuth proxy URL derived from gateway: ${t}`),W(`debug`,`BrowserOAuthClientProvider initialized with URL: ${de}, proxy: ${t?`enabled`:`disabled`}, gateway: ${ce?`enabled`:`disabled`}`)}je.current?W(`debug`,`BrowserMCPClient already exists, reusing.`):(je.current=new sn,W(`debug`,`BrowserMCPClient initialized in connect.`));let e=a(async n=>{if(!Fe.current)return W(`debug`,`Connection attempt aborted - component unmounted`),`failed`;W(`info`,`Attempting connection with transport: ${n}`),W(`debug`,`Client ref status at start of tryConnectWithTransport: ${je.current?`initialized`:`NULL`}`);try{let e=kn,r={url:t,transport:n===`sse`?`http`:n,timeout:C,sseReadTimeout:w,disableSseFallback:y===`http`,preferSse:n===`sse`,clientInfo:R,...E&&{fetch:E},...D&&{clientOptions:D},...v?{reconnectionOptions:v}:_===!1?{reconnectionOptions:{maxRetries:0}}:{}};if(ce&&(r.gatewayUrl=ce,W(`debug`,`Using proxy gateway: ${ce} for target: ${t}`)),B&&Object.keys(B).length>0&&(r.headers=B),!je.current){if(!Fe.current)return W(`debug`,`Connection aborted - component unmounted, client cleaned up`),`failed`;let e=Error(`Client not initialized - this is a bug in the connection flow`);throw W(`error`,`Client ref is null in tryConnectWithTransport but component is still mounted`),e}je.current.addServer(e,{...r,authProvider:Me.current,onSampling:L,onElicitation:ee,wrapTransport:T?n=>(W(`debug`,`Applying transport wrapper for server:`,e,`url:`,t),T(n,t)):void 0});let i=await je.current.createSession(e,!1);if(!Fe.current)return W(`debug`,`Connection aborted after session creation - component unmounted`),`failed`;if(i.on(`notification`,e=>{W(`debug`,`Notification received:`,e.method,e),O?.(e),e.method===`notifications/tools/list_changed`?(W(`info`,`Tools list changed, auto-refreshing...`),et().catch(e=>{W(`warn`,`Auto-refresh tools failed:`,e)})):e.method===`notifications/resources/list_changed`?(W(`info`,`Resources list changed, auto-refreshing...`),tt().catch(e=>W(`warn`,`Auto-refresh resources failed:`,e))):e.method===`notifications/prompts/list_changed`&&(W(`info`,`Prompts list changed, auto-refreshing...`),nt().catch(e=>W(`warn`,`Auto-refresh prompts failed:`,e)))}),await i.initialize(),!Fe.current)return W(`debug`,`Connection completed but component unmounted, aborting`),`failed`;if(W(`info`,`✅ Successfully connected to MCP server`),W(`info`,`Server info:`,i.connector.serverInfo),W(`info`,`Server capabilities:`,i.connector.serverCapabilities),!Fe.current)return W(`debug`,`Skipping state update - component unmounted`),`failed`;pe(`ready`),Ve.current=n,ie.enabled&&ie.healthCheckInterval!==!1&&(i._healthCheckCleanup=Pn({gatewayUrl:ce,url:t,allHeaders:B,getAuthHeaders:a(async()=>{try{let e=await Me.current?.tokens?.();if(e?.access_token){let t=e.token_type||`bearer`;return{Authorization:`${t.charAt(0).toUpperCase()+t.slice(1)} ${e.access_token}`}}}catch{}return{}},`getAuthHeaders`),isMountedRef:Fe,stateRef:ze,autoReconnectRef:Be,setState:pe,addLog:W,connect:Ke,defaultReconnectDelay:ie.initialDelay,healthCheckIntervalMs:ie.healthCheckInterval,healthCheckTimeoutMs:ie.healthCheckTimeout})),N.getInstance().trackUseMcpConnection({url:t,transportType:n,success:!0,hasOAuth:!!Me.current,hasSampling:!!L,hasElicitation:!!ee}).catch(()=>{}),V(i.connector.tools||[]);let o=await i.connector.listAllResources();if(!Fe.current)return W(`debug`,`Connection aborted after listing resources - component unmounted`),`failed`;he(o.resources||[]);let s=await i.connector.listPrompts();if(!Fe.current)return W(`debug`,`Connection aborted after listing prompts - component unmounted`),`failed`;if(ye(s.prompts||[]),i.connector.serverCapabilities?.resourceTemplates){let e=await i.connector.listResourceTemplates();if(!Fe.current)return W(`debug`,`Connection aborted after listing resource templates - component unmounted`),`failed`;_e(e.resourceTemplates||[])}else _e([]);let c=i.connector.serverInfo,l=i.connector.serverCapabilities;if(c){if(W(`debug`,`Server info:`,c),!Fe.current)return W(`debug`,`Skipping state update - component unmounted`),`failed`;be(c),Ne.current=(async()=>{try{let e=c.icons;if(e&&Array.isArray(e)&&e.length>0){let t=e[0].src||e[0].url;if(t){W(`info`,`Server provided icon:`,t);let e=await(await fetch(t)).blob(),n=await new Promise((t,n)=>{let r=new FileReader;r.onloadend=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)});return Fe.current&&(be(e=>e?{...e,icon:n}:void 0),W(`debug`,`Server icon converted to base64`)),n}}if(t){let e=await Dn(t);if(!Fe.current)return W(`debug`,`Connection aborted after favicon detection - component unmounted`),null;if(e)return be(t=>t?{...t,icon:e}:void 0),W(`debug`,`Favicon detected and added to serverInfo`),e}return null}catch(e){return W(`debug`,`Icon loading failed (non-critical):`,e),null}})()}if(l){if(W(`debug`,`Server capabilities:`,l),!Fe.current)return W(`debug`,`Skipping state update - component unmounted`),`failed`;Se(l)}if(Me.current){let e=await Me.current.tokens?.();if(!Fe.current)return W(`debug`,`Connection aborted after token fetch for auth tokens - component unmounted`),`failed`;if(e?.access_token){let t=e.expires_in?Date.now()+e.expires_in*1e3:void 0;if(!Fe.current)return W(`debug`,`Skipping state update - component unmounted`),`failed`;Ae({access_token:e.access_token,token_type:e.token_type||`Bearer`,expires_at:t,refresh_token:e.refresh_token,scope:e.scope})}}return`success`}catch(r){let i=r,a=i?.message||String(r),o=jn(r),s=i.code===401||a.includes(`401`)||a.includes(`Unauthorized`);if(o&&I&&Object.keys(I).length>0)return Ge(`Authentication failed (HTTP 401). Server does not support OAuth. Check your Authorization header value is correct.`),`failed`;if(o&&(!I||Object.keys(I).length===0))return Ge(`Authentication required (HTTP 401). Server does not support OAuth. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY).`),`failed`;if(s){if(o)return Ge(`Authentication required (HTTP 401). Server does not support OAuth. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY).`),`failed`;if(Me.current)if(W(`info`,`Authentication required. OAuth provider available.`),b){if(W(`info`,`Waiting for user to initiate authentication flow...`),Fe.current){pe(`pending_auth`);let e=Me.current?.getLastAttemptedAuthUrl?.();e&&(Oe(e),W(`info`,`Retrieved stored auth URL for manual authentication`))}return Pe.current=!1,`auth_redirect`}else{W(`info`,`Triggering automatic OAuth authentication flow...`);try{let{resourceMetadataUrl:r,scope:i}=await Sn(t);if(await le(Me.current,{serverUrl:t,...r&&{resourceMetadataUrl:r},...i&&{scope:i}})===`REDIRECT`){let e=await Me.current.getAuthorizationCode?.();if(!e)throw Error(`Authorization code not captured by headless provider`);await le(Me.current,{serverUrl:t,...r&&{resourceMetadataUrl:r},...i&&{scope:i},authorizationCode:e})}return W(`info`,`OAuth flow completed, reconnecting...`),await e(n)}catch(e){return Ge(`Automatic OAuth authentication failed: ${e instanceof Error?e.message:String(e)}`,e instanceof Error?e:Error(String(e))),`failed`}}return I&&Object.keys(I).length>0?(Ge(`Authentication failed: Server returned 401 Unauthorized. Check your Authorization header value is correct.`),`failed`):(Ge(`Authentication required: Server returned 401 Unauthorized. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY).`),`failed`)}return Ge(a,i instanceof Error?i:Error(String(i)))?`auth_redirect`:`failed`}},`tryConnectWithTransport`),o=`failed`;if(y===`sse`)W(`debug`,`Using SSE-only transport mode`),o=await e(`sse`);else if(y===`http`)W(`debug`,`Using HTTP-only transport mode`),o=await e(`http`);else{W(`debug`,`Using auto transport mode (HTTP with SSE fallback)`);let t=await e(`http`);t===`fallback`&&Fe.current&&ze.current!==`authenticating`?(W(`info`,`HTTP failed, attempting SSE fallback...`),o=await e(`sse`)):o=t}(o===`success`||o===`failed`||o===`auth_redirect`)&&(Pe.current=!1),W(`debug`,`Connection sequence finished with status: ${o}`)},[W,Ge,We,t,i,r,ne.name,ne.version,ne.uri,ne.logo_uri,I,y,b,x,S,n,C,w,R,ce,B,de]);(0,G.useEffect)(()=>{He.current=Ke,Ue.current=Ge},[Ke,Ge]);let qe=(0,G.useCallback)(async(e,t,n)=>{if(ze.current!==`ready`||!je.current)throw Error(`MCP client is not ready (current state: ${fe}). Cannot call tool "${e}".`);W(`info`,`Calling tool: ${e}`,t);let r=Date.now();try{let i=kn,a=je.current.getSession(i);if(!a)throw Error(`No active session found`);let o=await a.connector.callTool(e,t||{},n);return W(`info`,`Tool "${e}" call successful:`,o),N.getInstance().trackUseMcpToolCall({toolName:e,success:!0,executionTimeMs:Date.now()-r}).catch(()=>{}),o}catch(t){throw W(`error`,`Tool "${e}" call failed:`,t),N.getInstance().trackUseMcpToolCall({toolName:e,success:!1,errorType:t instanceof Error?t.name:`UnknownError`,executionTimeMs:Date.now()-r}).catch(()=>{}),t}},[fe]),Je=(0,G.useCallback)(()=>{ze.current===`failed`?(W(`info`,`Retry requested...`),He.current?.()):W(`warn`,`Retry called but state is not 'failed' (state: ${ze.current}). Ignoring.`)},[W]),Ye=(0,G.useCallback)(async()=>{W(`info`,`Manual authentication requested...`);let e=ze.current;if(e===`failed`)W(`info`,`Attempting to reconnect and authenticate via retry...`),Je();else if(e===`pending_auth`){W(`info`,`Proceeding with authentication from pending state...`);try{if(Cn(Me.current,`Auth Provider not available for manual auth`),Cn(t,`Server URL is required for authentication`),l){W(`info`,`Using provided authProvider for manual authentication`);let e=new URL(t).origin;await le(Me.current,{serverUrl:e}),He.current?.();return}W(`info`,`Cleared ${Me.current.clearStorage?.()??0} OAuth storage item(s) for fresh authentication`),pe(`authenticating`);let{provider:e,oauthProxyUrl:n}=Nn({effectiveOAuthUrl:de,storageKeyPrefix:i,oauthClientConfig:ne,callbackUrl:r,preventAutoAuth:!1,useRedirectFlow:x,gatewayUrl:ce,onPopupWindow:S,installFetchInterceptor:!ce});n&&!ce?W(`info`,`Installed OAuth fetch interceptor for manual auth`):n&&ce&&W(`info`,`Using MCP gateway proxy for OAuth (no fetch interceptor needed)`),Me.current=e,W(`info`,`Triggering fresh OAuth authorization...`);let a=new URL(t).origin;try{await le(e,{serverUrl:a}),W(`info`,`OAuth flow completed (tokens obtained)`)}catch(e){W(`info`,`OAuth flow initiated (popup/redirect):`,e instanceof Error?e.message:`Redirecting...`)}let o=e.getLastAttemptedAuthUrl?.();o&&(Oe(o),W(`info`,`Updated auth URL for fallback:`,o))}catch(e){if(!Fe.current)return;pe(`pending_auth`),W(`error`,`Manual authentication failed: ${e instanceof Error?e.message:String(e)}`)}}else if(e===`authenticating`){W(`warn`,`Already attempting authentication. Check for blocked popups or wait for timeout.`);let e=Me.current?.getLastAttemptedAuthUrl?.();e&&!De&&(Oe(e),W(`info`,`Manual authentication URL retrieved:`,e))}else W(`info`,`Client not in a state requiring manual authentication trigger (state: ${e}). If needed, try disconnecting and reconnecting.`)},[W,Je,De,t,x,S,i,ne.name,ne.uri,ne.logo_uri,r,R,l]),Xe=(0,G.useCallback)(()=>{Me.current?.clearStorage?(W(`info`,`Cleared ${Me.current.clearStorage()} item(s) from localStorage for ${t}.`),Oe(void 0),We()):W(`warn`,`Auth provider not initialized, cannot clear storage.`)},[t,W,We]),Ze=(0,G.useCallback)(async()=>{if(ze.current!==`ready`||!je.current)throw Error(`MCP client is not ready (current state: ${fe}). Cannot list resources.`);W(`info`,`Listing resources`);try{let e=kn,t=je.current.getSession(e);if(!t)throw Error(`No active session found`);he((await t.connector.listAllResources()).resources||[]),W(`info`,`Resources listed successfully`)}catch(e){throw W(`error`,`List resources failed:`,e),e}},[fe]),Qe=(0,G.useCallback)(async e=>{if(ze.current!==`ready`||!je.current)throw Error(`MCP client is not ready (current state: ${fe}). Cannot read resource.`);W(`info`,`Reading resource: ${e}`);try{let t=kn,n=je.current.getSession(t);if(!n)throw Error(`No active session found`);let r=await n.connector.readResource(e);return W(`info`,`Resource read successful:`,r),N.getInstance().trackUseMcpResourceRead({resourceUri:e,success:!0}).catch(()=>{}),r}catch(t){throw W(`error`,`Resource read failed:`,t),N.getInstance().trackUseMcpResourceRead({resourceUri:e,success:!1,errorType:t instanceof Error?t.name:`UnknownError`}).catch(()=>{}),t}},[fe]),$e=(0,G.useCallback)(async()=>{if(ze.current!==`ready`||!je.current)throw Error(`MCP client is not ready (current state: ${fe}). Cannot list prompts.`);W(`info`,`Listing prompts`);try{let e=kn,t=je.current.getSession(e);if(!t)throw Error(`No active session found`);ye((await t.connector.listPrompts()).prompts||[]),W(`info`,`Prompts listed successfully`)}catch(e){throw W(`error`,`List prompts failed:`,e),e}},[fe]),et=(0,G.useCallback)(async()=>{if(ze.current!==`ready`||!je.current){W(`debug`,`Cannot refresh tools - client not ready. State:`,ze.current);return}W(`debug`,`Refreshing tools list`);try{let e=kn,t=je.current.getSession(e);if(!t){W(`warn`,`No active session found for tools refresh`);return}W(`debug`,`Calling listTools...`);let n=await t.connector.listTools();W(`debug`,`listTools returned:`,n?.length,`tools`),V(n||[]),W(`info`,`Tools list refreshed successfully`)}catch(e){W(`error`,`Failed to refresh tools:`,e)}},[W]),tt=(0,G.useCallback)(async()=>{if(ze.current!==`ready`||!je.current){W(`debug`,`Cannot refresh resources - client not ready`);return}W(`debug`,`Refreshing resources list`);try{let e=kn,t=je.current.getSession(e);if(!t){W(`warn`,`No active session found for resources refresh`);return}he((await t.connector.listAllResources()).resources||[]),W(`info`,`Resources list refreshed successfully`)}catch(e){W(`warn`,`Failed to refresh resources:`,e)}},[W]),nt=(0,G.useCallback)(async()=>{if(ze.current!==`ready`||!je.current){W(`debug`,`Cannot refresh prompts - client not ready`);return}W(`debug`,`Refreshing prompts list`);try{let e=kn,t=je.current.getSession(e);if(!t){W(`warn`,`No active session found for prompts refresh`);return}ye((await t.connector.listPrompts()).prompts||[]),W(`info`,`Prompts list refreshed successfully`)}catch(e){W(`warn`,`Failed to refresh prompts:`,e)}},[W]),rt=(0,G.useCallback)(async()=>{if(ze.current!==`ready`||!je.current){W(`debug`,`Cannot refresh resource templates - client not ready`);return}W(`debug`,`Refreshing resource templates list`);try{let e=kn,t=je.current.getSession(e);if(!t)throw Error(`No active session found`);let n=await t.connector.listResourceTemplates();Fe.current&&(_e(n.resourceTemplates||[]),W(`info`,`Resource templates refreshed: ${n.resourceTemplates?.length||0} templates`))}catch(e){throw W(`error`,`Failed to refresh resource templates:`,e),e}},[W]),it=(0,G.useCallback)(async()=>{W(`info`,`Refreshing all lists (tools, resources, resource templates, prompts)`),await Promise.all([et(),tt(),rt(),nt()])},[et,tt,rt,nt,W]),at=(0,G.useCallback)(async(e,t)=>{if(ze.current!==`ready`||!je.current)throw Error(`MCP client is not ready (current state: ${fe}). Cannot get prompt.`);W(`info`,`Getting prompt: ${e}`,t);try{let n=kn,r=je.current.getSession(n);if(!r)throw Error(`No active session found`);let i=await r.connector.getPrompt(e,t||{});return W(`info`,`Prompt "${e}" retrieved successfully:`,i),i}catch(t){throw W(`error`,`Prompt "${e}" retrieval failed:`,t),t}},[fe,W]),ot=(0,G.useCallback)(async e=>{if(ze.current!==`ready`||!je.current)throw Error(`MCP client is not ready (current state: ${fe}). Cannot request completion.`);W(`info`,`Requesting completions for ${e.ref.type===`ref/prompt`?`prompt`:`resource template`} "${e.ref.type===`ref/prompt`?e.ref.name:e.ref.uri}"`);try{let t=kn,n=je.current.getSession(t);if(!n)throw Error(`No active session found`);let r=await n.complete(e);return W(`info`,`Received ${r.completion.values.length} completion suggestions`),r}catch(e){throw W(`error`,`Completion request failed:`,e),e}},[fe,W]);(0,G.useEffect)(()=>{let e=a(e=>{e.origin===window.location.origin&&e.data?.type===`mcp_auth_callback`&&(W(`info`,`Received auth callback message.`,e.data),Le.current&&clearTimeout(Le.current),Le.current=null,e.data.success?(W(`info`,`Authentication successful via popup. Reconnecting client...`),Pe.current&&W(`debug`,`Connection attempt already in progress, resetting flag to allow reconnection.`),Pe.current=!1,setTimeout(()=>{Fe.current&&(W(`debug`,`Initiating reconnection after successful auth callback.`),He.current?.())},100)):Ue.current?.(`Authentication failed in callback: ${e.data.error||`Unknown reason.`}`))},`messageHandler`);return window.addEventListener(`message`,e),W(`debug`,`Auth callback message listener added.`),()=>{window.removeEventListener(`message`,e),W(`debug`,`Auth callback message listener removed.`),Le.current&&clearTimeout(Le.current)}},[W]),(0,G.useEffect)(()=>{ae.current=!1,se(f)},[t,f]),(0,G.useEffect)(()=>{if(Fe.current=!0,!n||!t)return W(`debug`,n?`No server URL provided, skipping connection.`:`Connection disabled via enabled flag.`),pe(`discovering`),()=>{Fe.current=!1};if(W(`debug`,`useMcp mounted, initiating connection.`),Ie.current=0,l)Me.current=l,W(`debug`,`Using externally provided authProvider`);else if(!Me.current||Me.current.serverUrl!==de){let{provider:e,oauthProxyUrl:t}=Nn({effectiveOAuthUrl:de,storageKeyPrefix:i,oauthClientConfig:ne,callbackUrl:r,preventAutoAuth:b,useRedirectFlow:x,gatewayUrl:ce,onPopupWindow:S,installFetchInterceptor:!0});Me.current=e,t&&W(`debug`,`OAuth proxy URL derived from gateway: ${t}`),W(`debug`,`BrowserOAuthClientProvider initialized/updated with URL: ${de}, proxy: ${t?`enabled`:`disabled`}, gateway: ${ce?`enabled`:`disabled`}`)}return Ke(),()=>{if(Fe.current=!1,W(`debug`,`useMcp unmounting, disconnecting.`),(ze.current===`authenticating`||ze.current===`pending_auth`)&&Me.current)try{let e=Me.current.clearStorage?.()??0;e>0&&W(`debug`,`Cleared ${e} OAuth state item(s) during unmount to prevent corruption`)}catch(e){W(`debug`,`Error clearing OAuth state during unmount:`,e)}We(!0)}},[t,n,i,r,ne.name,ne.version,ne.uri,ne.logo_uri,x,R,de,f,l]);let st=(0,G.useRef)(Je),ct=(0,G.useRef)(W);(0,G.useEffect)(()=>{st.current=Je,ct.current=W},[Je,W]),(0,G.useEffect)(()=>{let e=null;if(fe===`failed`&&g&&Ie.current>0){if(!Re.current){Re.current=!0;let t=typeof g==`number`?g:In;ct.current(`info`,`Connection failed, auto-retrying in ${t}ms...`),e=setTimeout(()=>{Re.current=!1,Fe.current&&ze.current===`failed`&&st.current()},t)}}else fe!==`failed`&&(Re.current=!1);return()=>{e&&(clearTimeout(e),Re.current=!1)}},[fe,g]);let lt=(0,G.useCallback)(async()=>ze.current===`ready`?U?.icon?U.icon:Ne.current?(W(`debug`,`Waiting for icon to finish loading...`),await Ne.current):(W(`debug`,`No icon available and no loading in progress`),null):(W(`warn`,`Cannot ensure icon loaded - not connected`),null),[U,W]);return{state:fe,name:U?.name||t||``,tools:me,resources:H,resourceTemplates:ge,prompts:ve,serverInfo:U,capabilities:xe,error:Ce,log:Te,authUrl:De,authTokens:ke,client:je.current,callTool:qe,readResource:Qe,listResources:Ze,listPrompts:$e,getPrompt:at,complete:ot,refreshTools:et,refreshResources:tt,refreshResourceTemplates:rt,refreshPrompts:nt,refreshAll:it,retry:Je,disconnect:We,authenticate:Ye,clearStorage:Xe,ensureIconLoaded:lt}}a(Ln,`useMcp`);var Rn=`__model_context`,zn=new Map;function Bn(e){zn.set(e.id,e),Un()}a(Bn,`setNode`);function Vn(e){zn.delete(e),Un()}a(Vn,`removeNode`);var Hn=!1;function Un(){Hn||(Hn=!0,queueMicrotask(Wn))}a(Un,`scheduleFlush`);function Wn(){Hn=!1,Jn(Gn())}a(Wn,`flush`);function Gn(){let e=new Map;for(let t of zn.values()){let n=t.parentId??null;e.has(n)||e.set(n,[]),e.get(n).push(t)}for(let t of e.values())t.sort((e,t)=>e.id.localeCompare(t.id));let t=[];function n(r,i){let a=e.get(r);if(a)for(let e of a)e.content.trim()&&t.push(`${` `.repeat(i)}- ${e.content.trim()}`),n(e.id,i+1)}return a(n,`traverseTree`),n(null,0),t.join(`
|
|
3
3
|
`)}a(Gn,`buildDescriptionString`);var Kn=null;function qn(e){return Kn=e,e(Gn()),()=>{Kn===e&&(Kn=null)}}a(qn,`registerModelContextFlush`);function Jn(e){Kn?.(e)}a(Jn,`notifyHost`);var Yn=(0,G.createContext)(null);function Xn({content:e,children:t}){let n=(0,G.useContext)(Yn),r=(0,G.useId)();return(0,G.useEffect)(()=>(e.trim()&&Bn({id:r,parentId:n,content:e}),()=>{Vn(r)}),[r,n,e]),t==null?null:G.createElement(Yn.Provider,{value:r},t)}a(Xn,`ModelContext`);var Zn=s.get(`ErrorBoundary`),Qn=class extends G.Component{static{a(this,`ErrorBoundary`)}constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){Zn.error(`Widget Error:`,e,t),this.props.onError?.(e,t)}render(){return this.state.hasError&&this.state.error?this.props.fallback===void 0?G.createElement(`div`,{className:`p-4 border border-red-500 bg-red-50 text-red-900 rounded-md dark:bg-red-900/20 dark:text-red-100`},G.createElement(`h3`,{className:`font-bold mb-2`},`Widget Error`),G.createElement(`pre`,{className:`text-sm whitespace-pre-wrap`},this.state.error.message)):typeof this.props.fallback==`function`?this.props.fallback(this.state.error):this.props.fallback:this.props.children}};function $n(e,t){return{jsonrpc:`2.0`,method:e,...t&&{params:t}}}a($n,`createNotification`);function er(e,t,n){return{jsonrpc:`2.0`,id:e,method:t,...n&&{params:n}}}a(er,`createRequest`);var tr={POLL_INTERVAL:100,MAX_TIMEOUT:5e3,MAX_HEIGHT:600,LOCALE:`en`},nr={REQUEST_TIMEOUT:3e4,APP_NAME:`mcp-use-widget`,APP_VERSION:`1.0.0`,PROTOCOL_VERSION:`2025-06-18`},rr=class{static{a(this,`McpAppsBridge`)}connected=!1;connectPromise=null;requestId=1;pendingRequests=new Map;listeners=new Set;toolInput=null;partialToolInput=null;toolOutput=null;toolResponseMetadata=null;hostContext=null;hostInfo=null;hostCapabilities=null;initialized=!1;toolInputHandlers=new Set;toolInputPartialHandlers=new Set;toolResultHandlers=new Set;hostContextHandlers=new Set;constructor(){if(typeof window>`u`)return;let e=a(e=>{let t=e.data;if(!(!t||t.jsonrpc!==`2.0`)){if(`result`in t||`error`in t){let e=t;if(e.id!==null&&e.id!==void 0){let t=this.pendingRequests.get(e.id);t&&(this.pendingRequests.delete(e.id),`error`in e&&e.error?t.reject(Error(e.error.message)):t.resolve(e.result))}return}`method`in t&&!(`id`in t)&&this.handleNotification(t)}},`handleMessage`);window.addEventListener(`message`,e),this.listeners.add(e),this.interceptConsole()}interceptConsole(){if(typeof window>`u`||typeof console>`u`)return;let e={log:console.log.bind(console),warn:console.warn.bind(console),error:console.error.bind(console),info:console.info.bind(console),debug:console.debug.bind(console)},t={log:`info`,warn:`warning`,error:`error`,info:`info`,debug:`debug`},n=a((e,t=new WeakSet)=>{if(typeof e!=`object`||!e)return e;if(t.has(e))return`[Circular]`;if(e instanceof Response)return{__type:`Response`,status:e.status,statusText:e.statusText,ok:e.ok,url:e.url,headers:Object.fromEntries(e.headers.entries())};if(e instanceof Request)return{__type:`Request`,method:e.method,url:e.url,headers:Object.fromEntries(e.headers.entries())};if(e instanceof Error)return{__type:`Error`,name:e.name,message:e.message,stack:e.stack};if(e instanceof Event)return{__type:`Event`,type:e.type,target:e.target?.constructor?.name};if(typeof HTMLElement<`u`&&e instanceof HTMLElement)return{__type:`HTMLElement`,tagName:e.tagName,id:e.id,className:e.className};if(typeof e==`function`)return`[Function: ${e.name||`anonymous`}]`;if(Array.isArray(e))return t.add(e),e.map(e=>n(e,t));try{t.add(e);let r={};for(let i in e)if(Object.prototype.hasOwnProperty.call(e,i))try{r[i]=n(e[i],t)}catch{r[i]=`[Unserializable]`}return r}catch{return`[Object]`}},`serializeForPostMessage`),r=a((r,i)=>{try{let e=i.map(e=>n(e));this.sendNotification(`notifications/message`,{level:t[r]||`info`,logger:`console`,data:e.length===1?e[0]:e})}catch(t){e.warn(`[MCP Apps Bridge] Failed to forward console message:`,t)}},`sendLog`);console.log=(...t)=>{r(`log`,t),e.log(...t)},console.warn=(...t)=>{r(`warn`,t),e.warn(...t)},console.error=(...t)=>{r(`error`,t),e.error(...t)},console.info=(...t)=>{r(`info`,t),e.info(...t)},console.debug=(...t)=>{r(`debug`,t),e.debug(...t)}}handleNotification(e){switch(console.log(`[MCP Apps Bridge] Received notification:`,e.method,e.params),e.method){case`ui/notifications/tool-input`:{let t=e.params;console.log(`[MCP Apps Bridge] Tool input received:`,t.arguments),this.toolInput=t.arguments,this.toolInputHandlers.forEach(e=>e(t.arguments));break}case`ui/notifications/tool-input-partial`:{let t=e.params;console.log(`[MCP Apps Bridge] Partial tool input received:`,t.arguments),this.partialToolInput=t.arguments,this.toolInputPartialHandlers.forEach(e=>e(t.arguments));break}case`ui/notifications/tool-result`:{let t=e.params,n=t.structuredContent||this.parseTextContent(t),r=t._meta||null;this.toolOutput=n,this.toolResponseMetadata=r,this.partialToolInput=null,this.toolResultHandlers.forEach(e=>e(n));break}case`ui/notifications/host-context-changed`:{let t=e.params;console.log(`[MCP Apps Bridge] Host context changed:`,t),this.hostContext={...this.hostContext,...t},console.log(`[MCP Apps Bridge] Merged hostContext:`,this.hostContext),console.log(`[MCP Apps Bridge] Calling handlers:`,this.hostContextHandlers.size),this.hostContextHandlers.forEach(e=>e(this.hostContext));break}case`ui/notifications/initialized`:this.initialized=!0;break;default:break}}parseTextContent(e){if(e.content&&Array.isArray(e.content)){for(let t of e.content)if(t.type===`text`&&t.text)try{let e=JSON.parse(t.text);if(e&&typeof e==`object`&&!Array.isArray(e))return e}catch{}}return{}}sendRequest(e,t){if(typeof window>`u`||!window.parent)return Promise.reject(Error(`Not in iframe context`));let n=this.requestId++,r=er(n,e,t);return new Promise((t,i)=>{this.pendingRequests.set(n,{resolve:t,reject:i}),window.parent.postMessage(r,`*`),setTimeout(()=>{this.pendingRequests.has(n)&&(this.pendingRequests.delete(n),i(Error(`Request timeout: ${e}`)))},nr.REQUEST_TIMEOUT)})}sendNotification(e,t){if(typeof window>`u`||!window.parent)return;let n=$n(e,t);window.parent.postMessage(n,`*`)}async connect(){if(!this.connected){if(typeof window>`u`||window===window.parent){console.log(`[MCP Apps Bridge] Not in iframe, skipping connection`);return}return this.connectPromise||(this.connectPromise=this.doConnect(),this.connectPromise.catch(()=>{this.connectPromise=null})),this.connectPromise}}async doConnect(){console.log(`[MCP Apps Bridge] Connecting to MCP Apps host...`);try{let e=await this.sendRequest(`ui/initialize`,{appCapabilities:{},appInfo:{name:nr.APP_NAME,version:nr.APP_VERSION},protocolVersion:nr.PROTOCOL_VERSION});console.log(`[MCP Apps Bridge] Initialize result:`,e),e.hostContext&&(this.hostContext=e.hostContext,console.log(`[MCP Apps Bridge] Host context:`,this.hostContext)),e.hostInfo&&(this.hostInfo=e.hostInfo),e.hostCapabilities&&(this.hostCapabilities=e.hostCapabilities),this.sendNotification(`ui/notifications/initialized`,{}),this.connected=!0,console.log(`[MCP Apps Bridge] Successfully connected`)}catch(e){throw console.error(`[MCP Apps Bridge] Failed to connect:`,e),e}}isConnected(){return this.connected}getToolInput(){return this.toolInput}getPartialToolInput(){return this.partialToolInput}getToolOutput(){return this.toolOutput}getToolResponseMetadata(){return this.toolResponseMetadata}getHostContext(){return this.hostContext}getHostInfo(){return this.hostInfo}getHostCapabilities(){return this.hostCapabilities}onToolInput(e){return this.toolInputHandlers.add(e),()=>this.toolInputHandlers.delete(e)}onToolInputPartial(e){return this.toolInputPartialHandlers.add(e),()=>this.toolInputPartialHandlers.delete(e)}onToolResult(e){return this.toolResultHandlers.add(e),()=>this.toolResultHandlers.delete(e)}onHostContextChange(e){return this.hostContextHandlers.add(e),()=>this.hostContextHandlers.delete(e)}async callTool(e,t){return this.sendRequest(`tools/call`,{name:e,arguments:t})}async sendMessage(e){let t=Array.isArray(e)?e:[e];await this.sendRequest(`ui/message`,{role:`user`,content:t})}async openLink(e){await this.sendRequest(`ui/open-link`,{url:e})}async requestDisplayMode(e){return await this.sendRequest(`ui/request-display-mode`,{mode:e})}async updateModelContext(e){await this.sendRequest(`ui/update-model-context`,e)}sendSizeChanged(e){this.sendNotification(`ui/notifications/size-changed`,e)}disconnect(){this.listeners.forEach(e=>{typeof window<`u`&&window.removeEventListener(`message`,e)}),this.listeners.clear(),this.pendingRequests.clear(),this.toolInputHandlers.clear(),this.toolInputPartialHandlers.clear(),this.toolResultHandlers.clear(),this.hostContextHandlers.clear(),this.connected=!1,this.connectPromise=null}},ir=null;function ar(){return ir||=new rr,ir}a(ar,`getMcpAppsBridge`);function or(e){if(e&&typeof e==`object`&&`result`in e)return e;let t=e?.content||[],n=e?.structuredContent||{},r=t.filter(e=>e.type===`text`&&e.text).map(e=>e.text).join(`
|
|
4
4
|
`);return{content:t,structuredContent:n,isError:e?.isError??!1,result:r,_meta:e?._meta}}a(or,`normalizeCallToolResponse`);var sr=`openai:set_globals`;function cr(e){return(0,G.useSyncExternalStore)(t=>{let n=typeof window<`u`&&window.openai?window.openai[e]:void 0,r=a(r=>{let i=r.detail.globals[e];i!==void 0&&i!==n&&(n=i,t())},`handleSetGlobal`);return typeof window<`u`&&window.addEventListener(sr,r),()=>{typeof window<`u`&&window.removeEventListener(sr,r)}},()=>typeof window<`u`&&window.openai?window.openai[e]:void 0)}a(cr,`useOpenAiGlobal`);function lr(e){let[t,n]=(0,G.useState)(()=>typeof window<`u`&&!!window.openai),[r,i]=(0,G.useState)(!1),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(null),[u,d]=(0,G.useState)(null),[f,p]=(0,G.useState)(null),[m,h]=(0,G.useState)(null),[g,_]=(0,G.useState)(null),[v,y]=(0,G.useState)(null);(0,G.useEffect)(()=>{if(typeof window<`u`&&window.openai){n(!0);return}let e=setInterval(()=>{typeof window<`u`&&window.openai&&(n(!0),clearInterval(e))},100),t=a(()=>{typeof window<`u`&&window.openai&&(n(!0),clearInterval(e))},`handleSetGlobals`);typeof window<`u`&&window.addEventListener(sr,t);let r=setTimeout(()=>{clearInterval(e),typeof window<`u`&&window.removeEventListener(sr,t)},5e3);return()=>{clearInterval(e),clearTimeout(r),typeof window<`u`&&window.removeEventListener(sr,t)}},[]),(0,G.useEffect)(()=>{if(typeof window>`u`||window.openai||window===window.parent)return;let e=ar();e.connect().then(()=>{i(!0);let t=e.getToolInput(),n=e.getToolOutput(),r=e.getToolResponseMetadata(),a=e.getHostContext(),o=e.getPartialToolInput();t&&s(t),n&&l(n),r&&d(r),o&&p(o),a&&h(a);let c=e.getHostInfo(),u=e.getHostCapabilities();c&&_(c),u&&y(u)}).catch(e=>{console.warn(`[useWidget] Failed to connect to MCP Apps host:`,e)});let t=e.onToolInput(e=>{s(e)}),n=e.onToolInputPartial(e=>{p(e)}),r=e.onToolResult(t=>{l(t),d(e.getToolResponseMetadata()),p(null)}),a=e.onHostContextChange(e=>{console.log(`[useWidget] Host context change received:`,e),h(e)});return()=>{t(),n(),r(),a()}},[]);let b=(0,G.useMemo)(()=>t?`openai`:r?`mcp-apps`:`mcp-ui`,[t,r]),x=typeof window<`u`?window.location.search:``,S=(0,G.useMemo)(()=>{let e=new URLSearchParams(x);return e.has(`mcpUseParams`)?JSON.parse(e.get(`mcpUseParams`)):{toolInput:{},toolOutput:{},toolId:``}},[x]),C=cr(`toolInput`),w=cr(`toolOutput`),T=cr(`toolResponseMetadata`),E=cr(`widgetState`),D=cr(`theme`),O=cr(`displayMode`),k=cr(`safeArea`),A=cr(`maxHeight`),j=cr(`userAgent`),M=cr(`locale`),N=(0,G.useMemo)(()=>b===`openai`?C:b===`mcp-apps`?o:S.toolInput,[b,C,o,S.toolInput]),P=(0,G.useMemo)(()=>{if(b===`openai`){let e=w;return e&&e.structuredContent&&typeof e.structuredContent==`object`?e.structuredContent:w}return b===`mcp-apps`?c:S.toolOutput},[b,w,c,S.toolOutput]),F=(0,G.useMemo)(()=>{let t=N||{},n=e||{},r;if(b===`openai`&&w){let e=w;r=e.structuredContent&&typeof e.structuredContent==`object`?e.structuredContent:e}else b===`mcp-apps`&&c?r=c:b===`mcp-ui`&&S.toolOutput&&(r=S.toolOutput);return{...n,...t,...r||{}}},[b,N,w,c,S.toolOutput,e]),I=(0,G.useMemo)(()=>{if(b===`openai`)return D;if(b===`mcp-apps`&&m)return m.theme},[b,D,m]),L=(0,G.useMemo)(()=>{if(b===`openai`)return O;if(b===`mcp-apps`&&m)return m.displayMode},[b,O,m]),ee=(0,G.useMemo)(()=>{if(b===`openai`)return k;if(b===`mcp-apps`&&m?.safeAreaInsets)return{insets:m.safeAreaInsets}},[b,k,m]),te=(0,G.useMemo)(()=>{if(b===`openai`)return A;if(b===`mcp-apps`&&m?.containerDimensions)return m.containerDimensions.maxHeight},[b,A,m]),R=(0,G.useMemo)(()=>{if(b!==`openai`&&b===`mcp-apps`&&m?.containerDimensions)return m.containerDimensions.maxWidth},[b,m]),z=(0,G.useMemo)(()=>{if(b===`openai`)return j;if(b===`mcp-apps`&&m)return{device:{type:m.platform===`mobile`?`mobile`:`desktop`},capabilities:{hover:m.deviceCapabilities?.hover??!1,touch:m.deviceCapabilities?.touch??!1}}},[b,j,m]),ne=(0,G.useMemo)(()=>{if(b===`openai`)return M;if(b===`mcp-apps`&&m)return m.locale},[b,M,m]),re=(0,G.useMemo)(()=>{if(b===`openai`)return typeof window<`u`?Intl.DateTimeFormat().resolvedOptions().timeZone:void 0;if(b===`mcp-apps`&&m)return m.timeZone},[b,m]),ie=(0,G.useMemo)(()=>typeof window<`u`&&window.__mcpPublicUrl?window.__mcpPublicUrl.replace(/\/mcp-use\/public$/,``):``,[]),[ae,oe]=(0,G.useState)(null);(0,G.useEffect)(()=>{E!==void 0&&oe(E)},[E]);let se=(0,G.useRef)(b);se.current=b;let ce=(0,G.useRef)(ae);ce.current=ae,(0,G.useEffect)(()=>qn(e=>{let t=se.current;if(t===`mcp-apps`){let t=ar();t.isConnected()&&t.updateModelContext({structuredContent:{[Rn]:e},content:[{type:`text`,text:e}]}).catch(e=>{console.warn(`[ModelContext] Failed to update model context:`,e)});return}if(t===`openai`&&window.openai?.setWidgetState){let t=window.openai.widgetState??ce.current??{};window.openai.setWidgetState({...t,[Rn]:e}).catch(e=>{console.warn(`[ModelContext] Failed to set widget state:`,e)})}}),[]);let le=(0,G.useCallback)(async(e,t)=>{if(b===`mcp-apps`)return or(await ar().callTool(e,t));if(!window.openai?.callTool)throw Error(`window.openai.callTool is not available`);return or(await window.openai.callTool(e,t))},[b]),ue=(0,G.useCallback)(async e=>{let t=typeof e==`string`?[{type:`text`,text:e}]:e;if(b===`mcp-apps`){await ar().sendMessage(t);return}if(!window.openai?.sendFollowUpMessage)throw Error(`window.openai.sendFollowUpMessage is not available`);let n=typeof e==`string`?e:t.filter(e=>e.type===`text`&&`text`in e).map(e=>e.text).join(`
|
|
5
|
-
`);return window.openai.sendFollowUpMessage({prompt:n})},[b]),de=(0,G.useCallback)(e=>{if(b===`mcp-apps`){ar().openLink(e).catch(e=>{console.error(`Failed to open link:`,e)});return}if(!window.openai?.openExternal)throw Error(`window.openai.openExternal is not available`);window.openai.openExternal({href:e})},[b]),B=(0,G.useCallback)(async e=>{if(b===`mcp-apps`)return await ar().requestDisplayMode(e);if(!window.openai?.requestDisplayMode)throw Error(`window.openai.requestDisplayMode is not available`);return window.openai.requestDisplayMode({mode:e})},[b]),fe=(0,G.useCallback)(async e=>{if(b===`mcp-apps`){let t=typeof e==`function`?e(ae):e;oe(t);let n=ar(),r=t;n.updateModelContext({structuredContent:r,content:[{type:`text`,text:JSON.stringify(Object.fromEntries(Object.entries(r).filter(([e])=>e!==Rn)))}]}).catch(e=>{console.warn(`[useWidget] Failed to update model context:`,e)});return}if(!window.openai?.setWidgetState)throw Error(`window.openai.setWidgetState is not available`);let t=typeof e==`function`?e(E===void 0?ae:E):e,n=(window.openai.widgetState??{})[Rn];return oe(t),window.openai.setWidgetState(n===void 0?t:{...t,[Rn]:n})},[b,E,ae]),pe=(0,G.useMemo)(()=>b===`openai`?w===null&&T===null:b===`mcp-apps`?c===null:b===`mcp-ui`?typeof window<`u`&&window!==window.parent&&!S.toolId?!0:P==null:!1,[b,w,T,c,P,S.toolId]),me=(0,G.useMemo)(()=>b===`mcp-apps`&&f?f:null,[b,f]),V=(0,G.useMemo)(()=>b===`mcp-apps`?f!==null:!1,[b,f]);return{props:F,toolInput:N||{},output:P??null,metadata:b===`mcp-apps`?u??null:T??null,state:ae?Object.fromEntries(Object.entries(ae).filter(([e])=>e!==Rn)):null,setState:fe,theme:I||`light`,displayMode:L||`inline`,safeArea:ee||{insets:{top:0,bottom:0,left:0,right:0}},maxHeight:te||600,maxWidth:R,userAgent:z||{device:{type:`desktop`},capabilities:{hover:!0,touch:!1}},locale:ne||tr.LOCALE,timeZone:re||(typeof window<`u`?Intl.DateTimeFormat().resolvedOptions().timeZone:`UTC`),mcp_url:ie,callTool:le,sendFollowUpMessage:ue,openExternal:de,requestDisplayMode:B,isAvailable:t||r,isPending:pe,partialToolInput:me,isStreaming:V,hostInfo:g??void 0,hostCapabilities:v??void 0}}a(lr,`useWidget`);function ur(e){let{props:t}=lr(e);return t}a(ur,`useWidgetProps`);function dr(){let{theme:e}=lr();return e}a(dr,`useWidgetTheme`);function fr(e){let{state:t,setState:n}=lr();return(0,G.useEffect)(()=>{t===null&&e!==void 0&&window.openai?.setWidgetState&&n(e)},[]),[t,n]}a(fr,`useWidgetState`);var pr=a(({children:e})=>{let{theme:t,isAvailable:n}=lr(),[r,i]=(0,G.useState)(()=>typeof window>`u`?`light`:window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`);(0,G.useEffect)(()=>{if(typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=a(e=>{i(e.matches?`dark`:`light`)},`handleChange`);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let o=n?t:r;return(0,G.useLayoutEffect)(()=>{if(typeof document>`u`)return;let e=document.documentElement;e.classList.remove(`light`,`dark`),e.classList.add(o===`dark`?`dark`:`light`),e.setAttribute(`data-theme`,o===`dark`?`dark`:`light`),e.style.colorScheme=o===`dark`?`dark`:`light`},[o]),G.createElement(G.Fragment,null,e)},`ThemeProvider`);function mr({children:e,className:t=``,position:n=`top-right`,attachTo:r,showLabels:i=!0,debugger:o=!1,viewControls:s=!1}){let{props:c,output:l,metadata:u,state:d,theme:f,displayMode:p,safeArea:m,maxHeight:h,userAgent:g,locale:_,isAvailable:v,callTool:y,sendFollowUpMessage:b,openExternal:x,requestDisplayMode:S,setState:C}=lr(),[w,T]=(0,G.useState)(!1),[E,D]=(0,G.useState)(!1),O=(0,G.useRef)(null),k=(0,G.useRef)(null),[A,j]=(0,G.useState)([]),[M,N]=(0,G.useState)(``),[P,F]=(0,G.useState)(`get-my-city`),[I,L]=(0,G.useState)(`{}`),[ee,te]=(0,G.useState)(`Test follow-up message`),[R,z]=(0,G.useState)(`https://mcp-use.com/docs`),ne=p===`fullscreen`&&v,re=p===`pip`&&v,ie=typeof window<`u`&&window.location.pathname.includes(`/inspector/api/`);(0,G.useEffect)(()=>{let e=setTimeout(()=>{if(typeof window<`u`&&window.openai)try{j(Object.keys(window.openai))}catch{j([])}else j([])},100);return()=>{clearTimeout(e)}},[]);let ae=f===`dark`,oe=a(()=>{let e=[`absolute`,`z-[1000]`,`flex`,`gap-2`,`transition-opacity`,`duration-200`,`ease-in-out`,w?`opacity-100`:`opacity-0`,w?`pointer-events-auto`:`pointer-events-none`];switch(n){case`top-left`:return[...e,`top-4`,`left-4`];case`top-center`:return[...e,`top-4`,`left-1/2`,`-translate-x-1/2`];case`top-right`:return[...e,`top-4`,`right-4`];case`center-left`:return[...e,`top-1/2`,`left-4`,`-translate-y-1/2`];case`center-right`:return[...e,`top-1/2`,`right-4`,`-translate-y-1/2`];case`bottom-left`:return[...e,`bottom-4`,`left-4`];case`bottom-center`:return[...e,`bottom-4`,`left-1/2`,`-translate-x-1/2`];case`bottom-right`:return[...e,`bottom-4`,`right-4`];default:return[...e,`top-4`,`right-4`]}},`getPositionClasses`),se=a(()=>{let e=m?.insets?.top?Math.max(16,m.insets.top+8):16,t=m?.insets?.right?Math.max(16,m.insets.right+8):16,r=m?.insets?.bottom?Math.max(16,m.insets.bottom+8):16,i=m?.insets?.left?Math.max(16,m.insets.left+8):16,a={};switch(n){case`top-left`:a.top=`${e}px`,a.left=`${i}px`;break;case`top-center`:a.top=`${e}px`;break;case`top-right`:a.top=`${e}px`,a.right=`${t}px`;break;case`center-left`:a.left=`${i}px`;break;case`center-right`:a.right=`${t}px`;break;case`bottom-left`:a.bottom=`${r}px`,a.left=`${i}px`;break;case`bottom-center`:a.bottom=`${r}px`;break;case`bottom-right`:a.bottom=`${r}px`,a.right=`${t}px`;break;default:a.top=`${e}px`,a.right=`${t}px`;break}return a},`getPositionOffsetStyles`);(0,G.useEffect)(()=>{if(!r)return;let e=a(()=>T(!0),`handleMouseEnter`),t=a(()=>T(!1),`handleMouseLeave`);return r.addEventListener(`mouseenter`,e),r.addEventListener(`mouseleave`,t),()=>{r.removeEventListener(`mouseenter`,e),r.removeEventListener(`mouseleave`,t)}},[r]),(0,G.useEffect)(()=>{if(!E)return;let e=a(e=>{k.current&&!k.current.contains(e.target)&&D(!1)},`handleClickOutside`);return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[E]),(0,G.useEffect)(()=>(E?document.body.style.overflow=`hidden`:document.body.style.overflow=``,()=>{document.body.style.overflow=``}),[E]);let ce=a(()=>{D(!E)},`handleToggleOverlay`),le=a(async()=>{try{N(`Calling tool...`);let e=await y(P,I.trim()?JSON.parse(I):{});N(`Success: ${JSON.stringify(e,null,2)}`)}catch(e){N(`Error: ${e.message}`)}},`handleCallTool`),ue=a(async()=>{try{N(`Sending follow-up message...`),await b(ee),N(`Follow-up message sent successfully`)}catch(e){N(`Error: ${e.message}`)}},`handleSendFollowUpMessage`),de=a(()=>{try{x(R),N(`Opened external link: ${R}`)}catch(e){N(`Error: ${e.message}`)}},`handleOpenExternal`),B=a(async e=>{try{N(`Requesting display mode: ${e}...`),N(`Display mode granted: ${(await S(e)).mode}`)}catch(e){N(`Error: ${e.message}`)}},`handleRequestDisplayMode`),fe=a(async()=>{try{let e=d?{...d,debugTimestamp:new Date().toISOString()}:{debugTimestamp:new Date().toISOString()};N(`Setting state...`),await C(e),N(`State updated: ${JSON.stringify(e,null,2)}`)}catch(e){N(`Error: ${e.message}`)}},`handleSetState`),pe=a(async()=>{try{await S(`fullscreen`)}catch(e){console.error(`Failed to go fullscreen:`,e)}},`handleFullscreen`),me=a(async()=>{try{await S(`pip`)}catch(e){console.error(`Failed to go pip:`,e)}},`handlePip`),V=a(()=>{let e=[`absolute`,`px-2`,`py-1`,`bg-black/90`,`text-white`,`rounded`,`text-xs`,`whitespace-nowrap`,`pointer-events-none`,`transition-opacity`,`duration-200`,`ease-in-out`];switch(n){case`top-right`:return[...e,`top-full`,`right-0`,`mt-2`];case`top-left`:return[...e,`top-full`,`left-0`,`mt-2`];case`top-center`:return[...e,`top-full`,`left-1/2`,`-translate-x-1/2`,`mt-2`];case`bottom-right`:return[...e,`bottom-full`,`right-0`,`mb-2`];case`bottom-left`:return[...e,`bottom-full`,`left-0`,`mb-2`];case`bottom-center`:return[...e,`bottom-full`,`left-1/2`,`-translate-x-1/2`,`mb-2`];case`center-left`:return[...e,`left-full`,`top-1/2`,`-translate-y-1/2`,`ml-2`];case`center-right`:return[...e,`right-full`,`top-1/2`,`-translate-y-1/2`,`mr-2`];default:return[...e,`top-full`,`right-0`,`mt-2`]}},`getTooltipClasses`),H=a(({onClick:e,label:t,children:n})=>{let[r,a]=(0,G.useState)(!1),o=V();return G.createElement(`button`,{className:`p-2 ${ae?`bg-white/10 hover:bg-white/20`:`bg-black/70 hover:bg-black/90`} text-white border-none rounded-lg cursor-pointer flex items-center justify-center w-8 h-8 transition-colors duration-200 backdrop-blur-md ${ae?`shadow-[0_2px_8px_rgba(0,0,0,0.3)]`:`shadow-[0_2px_8px_rgba(0,0,0,0.2)]`} relative`,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),onClick:e,"aria-label":t},G.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`block`},n),i&&G.createElement(`span`,{className:`${o.join(` `)} ${r?`opacity-100`:`opacity-0`}`},t))},`IconButton`),he=a(e=>{if(e===null)return`null`;if(e===void 0)return`undefined`;if(typeof e==`object`)try{return JSON.stringify(e,null,2)}catch{return String(e)}return String(e)},`formatValue`),ge=a(e=>e?`${e.device?.type||`unknown`}`:`N/A`,`formatUserAgent`),_e=a(e=>{if(!e?.insets)return`N/A`;let{top:t,bottom:n,left:r,right:i}=e.insets;return`T:${t} B:${n} L:${r} R:${i}`},`formatSafeArea`);return G.createElement(G.Fragment,null,G.createElement(`div`,{ref:O,className:`${t} relative h-fit`,onMouseEnter:()=>!r&&T(!0),onMouseLeave:()=>!r&&T(!1)},G.createElement(`div`,{className:oe().join(` `),style:se()},!ie&&G.createElement(G.Fragment,null,!ne&&!re&&G.createElement(G.Fragment,null,(s===!0||s===`fullscreen`)&&G.createElement(H,{onClick:pe,label:`Fullscreen`},G.createElement(`path`,{d:`M15 3h6v6`}),G.createElement(`path`,{d:`m21 3-7 7`}),G.createElement(`path`,{d:`m3 21 7-7`}),G.createElement(`path`,{d:`M9 21H3v-6`})),(s===!0||s===`pip`)&&G.createElement(H,{onClick:me,label:`Picture in Picture`},G.createElement(`path`,{d:`M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4`}),G.createElement(`rect`,{width:`10`,height:`7`,x:`12`,y:`13`,rx:`2`}))),o&&G.createElement(H,{onClick:ce,label:`Debug Info`},G.createElement(`path`,{d:`M12 20v-9`}),G.createElement(`path`,{d:`M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z`}),G.createElement(`path`,{d:`M14.12 3.88 16 2`}),G.createElement(`path`,{d:`M21 21a4 4 0 0 0-3.81-4`}),G.createElement(`path`,{d:`M21 5a4 4 0 0 1-3.55 3.97`}),G.createElement(`path`,{d:`M22 13h-4`}),G.createElement(`path`,{d:`M3 21a4 4 0 0 1 3.81-4`}),G.createElement(`path`,{d:`M3 5a4 4 0 0 0 3.55 3.97`}),G.createElement(`path`,{d:`M6 13H2`}),G.createElement(`path`,{d:`m8 2 1.88 1.88`}),G.createElement(`path`,{d:`M9 7.13V6a3 3 0 1 1 6 0v1.13`})))),e),E&&o&&G.createElement(`div`,{ref:k,className:`fixed inset-0 bg-black text-white font-mono text-xs z-[10000] overflow-auto p-4`,onClick:e=>{e.target===k.current&&D(!1)}},G.createElement(`button`,{onClick:()=>D(!1),className:`absolute top-4 right-4 bg-white/10 text-white border-none rounded w-8 h-8 cursor-pointer flex items-center justify-center text-lg leading-none`,"aria-label":`Close`},`×`),G.createElement(`div`,{className:`max-w-[1200px] mx-auto pt-10`},G.createElement(`h1`,{className:`text-lg font-bold mb-4 border-b border-gray-700 pb-2`},`Debug Info`),G.createElement(`table`,{className:`w-full border-collapse border-spacing-0`},G.createElement(`tbody`,null,G.createElement(`tr`,{className:`border-b border-gray-700`},G.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Props`),G.createElement(`td`,{className:`p-2 whitespace-pre-wrap break-all`},he(c))),G.createElement(`tr`,{className:`border-b border-gray-700`},G.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Output`),G.createElement(`td`,{className:`p-2 whitespace-pre-wrap break-all`},he(l))),G.createElement(`tr`,{className:`border-b border-gray-700`},G.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Metadata`),G.createElement(`td`,{className:`p-2 whitespace-pre-wrap break-all`},he(u))),G.createElement(`tr`,{className:`border-b border-gray-700`},G.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`State`),G.createElement(`td`,{className:`p-2 whitespace-pre-wrap break-all`},he(d))),G.createElement(`tr`,{className:`border-b border-gray-700`},G.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Theme`),G.createElement(`td`,{className:`p-2`},f)),G.createElement(`tr`,{className:`border-b border-gray-700`},G.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Display Mode`),G.createElement(`td`,{className:`p-2`},p)),G.createElement(`tr`,{className:`border-b border-gray-700`},G.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Locale`),G.createElement(`td`,{className:`p-2`},_)),G.createElement(`tr`,{className:`border-b border-gray-700`},G.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Max Height`),G.createElement(`td`,{className:`p-2`},h,`px`)),G.createElement(`tr`,{className:`border-b border-gray-700`},G.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`User Agent`),G.createElement(`td`,{className:`p-2`},ge(g))),G.createElement(`tr`,{className:`border-b border-gray-700`},G.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Safe Area`),G.createElement(`td`,{className:`p-2`},_e(m))),G.createElement(`tr`,{className:`border-b border-gray-700`},G.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`API Available`),G.createElement(`td`,{className:`p-2`},v?`Yes`:`No`)),G.createElement(`tr`,{className:`border-b border-gray-700`},G.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`window.openai Keys`),G.createElement(`td`,{className:`p-2`},A.length>0?A.join(`, `):`N/A`)))),G.createElement(`h2`,{className:`text-base font-bold mt-8 mb-4 border-b border-gray-700 pb-2`},`Actions`),G.createElement(`div`,{className:`flex flex-col gap-3`},G.createElement(`div`,{className:`flex gap-2 items-center`},G.createElement(`input`,{type:`text`,value:P,onChange:e=>F(e.target.value),placeholder:`Tool name`,className:`py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs w-[150px]`}),G.createElement(`input`,{type:`text`,value:I,onChange:e=>L(e.target.value),placeholder:`{"key": "value"}`,className:`py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1`}),G.createElement(`button`,{onClick:le,className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs`},`Call Tool`)),G.createElement(`div`,{className:`flex gap-2 items-center`},G.createElement(`input`,{type:`text`,value:ee,onChange:e=>te(e.target.value),placeholder:`Follow-up message`,className:`py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1`}),G.createElement(`button`,{onClick:ue,className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs`},`Send Follow-Up`)),G.createElement(`div`,{className:`flex gap-2 items-center`},G.createElement(`input`,{type:`text`,value:R,onChange:e=>z(e.target.value),placeholder:`External URL`,className:`py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1`}),G.createElement(`button`,{onClick:de,className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs`},`Open Link`)),G.createElement(`div`,{className:`flex gap-2 items-center`},G.createElement(`span`,{className:`w-[150px] text-xs`},`Display Mode:`),G.createElement(`button`,{onClick:()=>B(`inline`),className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1`},`Inline`),G.createElement(`button`,{onClick:()=>B(`pip`),className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1`},`PiP`),G.createElement(`button`,{onClick:()=>B(`fullscreen`),className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1`},`Fullscreen`)),G.createElement(`div`,{className:`flex gap-2 items-center`},G.createElement(`button`,{onClick:fe,className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs`},`Set State (Add Timestamp)`)),M&&G.createElement(`div`,{className:`mt-2 p-2 bg-[#1a1a1a] border border-gray-700 rounded whitespace-pre-wrap break-all text-[11px] max-h-[200px] overflow-auto`},G.createElement(`div`,{className:`font-bold mb-1 text-gray-400`},`Result:`),M,G.createElement(`button`,{onClick:()=>N(``),className:`mt-2 py-1 px-2 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-[11px]`},`Clear`))))))}a(mr,`WidgetControls`);var hr=150,gr=5;function _r({children:e,debugger:t=!1,viewControls:n=!1,autoSize:r=!0}){let[i,a]=(0,G.useState)(null),o=(0,G.useRef)(0),s=(0,G.useRef)(null),c=(0,G.useRef)(!1),l=(0,G.useCallback)(e=>{if(!(typeof window>`u`)){if(c.current=!0,window.openai?.notifyIntrinsicHeight){window.openai.notifyIntrinsicHeight(e).then(()=>{c.current=!1}).catch(e=>{c.current=!1,console.error(`[McpUseProvider] Failed to notify intrinsic height (ChatGPT):`,e)});return}try{ar().sendSizeChanged({height:e}),console.log(`[McpUseProvider] Sent size-changed notification:`,e),c.current=!1}catch(e){c.current=!1,console.error(`[McpUseProvider] Failed to notify size change (MCP Apps):`,e)}}},[]),u=(0,G.useCallback)(e=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{Math.abs(e-o.current)>=gr&&e>0&&(o.current=e,l(e))},hr)},[l]);(0,G.useEffect)(()=>{if(!r){console.log(`[McpUseProvider] autoSize is disabled`);return}if(!i){console.log(`[McpUseProvider] No container element found for autoSize`);return}if(typeof ResizeObserver>`u`){console.log(`[McpUseProvider] ResizeObserver not available`);return}console.log(`[McpUseProvider] Setting up ResizeObserver for autoSize`);let e=new ResizeObserver(e=>{if(c.current){console.log(`[McpUseProvider] Skipping resize - notification in progress`);return}for(let t of e){let e=t.contentRect.height,n=t.target.scrollHeight,r=Math.max(e,n);console.log(`[McpUseProvider] ResizeObserver fired:`,{height:e,scrollHeight:n,intrinsicHeight:r}),u(r)}});e.observe(i);let t=Math.max(i.offsetHeight,i.scrollHeight);return console.log(`[McpUseProvider] Initial height measurement:`,t),t>0&&u(t),()=>{console.log(`[McpUseProvider] Cleaning up ResizeObserver`),e.disconnect(),s.current&&=(clearTimeout(s.current),null),c.current=!1}},[r,i,u]);let d=e;return d=G.createElement(Qn,null,d),(t||n)&&(d=G.createElement(mr,{debugger:t,viewControls:n},d)),d=G.createElement(pr,null,d),r&&(d=G.createElement(`div`,{ref:a,style:{width:`100%`,minHeight:0}},d)),G.createElement(G.StrictMode,null,d)}a(_r,`McpUseProvider`);function vr(){let e=(0,G.useMemo)(()=>typeof window>`u`?!1:typeof window.openai?.uploadFile==`function`&&typeof window.openai?.getFileDownloadUrl==`function`,[]);return{isSupported:e,upload:(0,G.useMemo)(()=>async(t,n={})=>{if(!e)throw Error("[useFiles] File upload is not supported in this host. Check `isSupported` before calling `upload`. File operations are only available in the ChatGPT Apps SDK environment.");let r=await window.openai.uploadFile(t),{modelVisible:i=!0}=n;if(i&&window.openai?.setWidgetState){let e=window.openai.widgetState??{},t=[...e.imageIds??[],r.fileId];window.openai.setWidgetState({...e,imageIds:t}).catch(e=>{console.warn(`[useFiles] Failed to track imageId:`,e)})}return r},[e]),getDownloadUrl:(0,G.useMemo)(()=>async t=>{if(!e)throw Error("[useFiles] File download is not supported in this host. Check `isSupported` before calling `getDownloadUrl`. File operations are only available in the ChatGPT Apps SDK environment.");return window.openai.getFileDownloadUrl(t)},[e])}}a(vr,`useFiles`);function yr(e){let[{status:t,data:n,error:r},i]=(0,G.useState)({status:`idle`,data:void 0,error:void 0}),o=(0,G.useRef)(0),s=a(async t=>{let n=++o.current;i({status:`pending`,data:void 0,error:void 0});try{let r;if(typeof window<`u`)if(window.openai?.callTool)r=await window.openai.callTool(e,t);else if(window!==window.parent)r=await ar().callTool(e,t);else throw Error(`No tool calling interface available`);else throw Error(`useCallTool can only be used in browser environment`);let a=or(r);return n===o.current&&i({status:`success`,data:a,error:void 0}),a}catch(e){throw n===o.current&&i({status:`error`,data:void 0,error:e}),e}},`execute`),c=(0,G.useCallback)((e=>s(e===void 0?null:e)),[e]),l=(0,G.useCallback)(((e,t)=>{let n;e&&typeof e==`object`&&(`onSuccess`in e||`onError`in e||`onSettled`in e)?(n=null,t=e):n=e===void 0?null:e,s(n).then(e=>{t?.onSuccess?.(e,n),t?.onSettled?.(e,void 0,n)}).catch(e=>{t?.onError?.(e,n),t?.onSettled?.(void 0,e,n)})}),[e]);return{status:t,data:n,error:r,isIdle:t===`idle`,isPending:t===`pending`,isSuccess:t===`success`,isError:t===`error`,callTool:l,callToolAsync:c}}a(yr,`useCallTool`);function br(){return{useCallTool:a(e=>yr(e),`useCallTool`),useToolInfo:a(()=>lr(),`useToolInfo`)}}a(br,`generateHelpers`);var xr=s.get(`McpClientProvider`),Sr=(0,G.createContext)(null),Cr=500;function wr({id:e,options:t,defaultProxyConfig:n,defaultAutoProxyFallback:r,clientInfo:i,cachedMetadata:a,onUpdate:o,rpcWrapTransport:s,onGlobalSamplingRequest:c,onGlobalElicitationRequest:l}){let{name:u,onSamplingRequest:d,onElicitationRequest:f,onNotificationReceived:p,wrapTransport:m}=t,h=(0,G.useMemo)(()=>{let{name:e,onSamplingRequest:o,onElicitationRequest:s,onNotificationReceived:c,wrapTransport:l,...u}=t;return{...u,proxyConfig:u.proxyConfig||n,autoProxyFallback:u.autoProxyFallback===void 0?r:u.autoProxyFallback,clientInfo:u.clientInfo?i?{...i,...u.clientInfo}:u.clientInfo:i,_initialServerInfo:a}},[t,n,r,i,a]),g=(0,G.useMemo)(()=>{if(!(!s&&!m))return t=>{let n=t;return s&&(n=s(n,e)),m&&(n=m(n,e)),n}},[s,m,e]),[_,v]=(0,G.useState)([]),[y,b]=(0,G.useState)([]),x=(0,G.useRef)(0),[S,C]=(0,G.useState)([]),w=(0,G.useRef)(0),T=(0,G.useCallback)(e=>{v(t=>t.map(t=>t.id===e?{...t,read:!0}:t))},[]),E=(0,G.useCallback)(()=>{v(e=>e.map(e=>({...e,read:!0})))},[]),D=(0,G.useCallback)(()=>{v([])},[]),O=(0,G.useCallback)(e=>{let t={id:globalThis.crypto?.randomUUID?.()||`${Date.now()}-${Math.random()}`,method:e.method,params:e.params,timestamp:Date.now(),read:!1};v(e=>{let n=[t,...e];return n.length>Cr?n.slice(0,Cr):n}),p?.(t)},[p]),k=(0,G.useCallback)((e,t)=>{b(n=>{let r=n.find(t=>t.id===e);return r?(r.resolve(t),n.filter(t=>t.id!==e)):n})},[]),A=(0,G.useCallback)((e,t)=>{b(n=>{let r=n.find(t=>t.id===e);return r?(r.reject(Error(t||`User rejected sampling request`)),n.filter(t=>t.id!==e)):n})},[]),j=(0,G.useCallback)(async t=>new Promise((n,r)=>{let i={id:`sampling-${x.current++}`,request:{method:`sampling/createMessage`,params:t},timestamp:Date.now(),serverName:u||e},a={...i,resolve:n,reject:r};b(e=>[...e,a]),d?.(i),c?.(i,e,u||e,k,A)}),[e,u,d,c,k,A]),M=(0,G.useCallback)((e,t)=>{C(n=>{let r=n.find(t=>t.id===e);return r?(r.resolve(t),n.filter(t=>t.id!==e)):n})},[]),N=(0,G.useCallback)((e,t)=>{C(n=>{let r=n.find(t=>t.id===e);return r?(r.reject(Error(t||`User rejected elicitation request`)),n.filter(t=>t.id!==e)):n})},[]),P=(0,G.useCallback)(async t=>new Promise((n,r)=>{let i={id:`elicitation-${w.current++}`,request:t,timestamp:Date.now(),serverName:u||e},a={...i,resolve:n,reject:r};C(e=>[...e,a]),f?.(i),l?.(i,e,u||e,M,N)}),[e,u,f,l,M,N]),F=Ln({...h,onNotification:O,onSampling:j,onElicitation:P,wrapTransport:g}),I=(0,G.useMemo)(()=>y.map(e=>({id:e.id,request:e.request,timestamp:e.timestamp,serverName:e.serverName})),[y]),L=(0,G.useMemo)(()=>S.map(e=>({id:e.id,request:e.request,timestamp:e.timestamp,serverName:e.serverName})),[S]),ee=(0,G.useMemo)(()=>_.filter(e=>!e.read).length,[_]),te=(0,G.useMemo)(()=>JSON.stringify(F.tools.map(e=>({name:e.name,description:e.description,inputSchema:e.inputSchema,_meta:e._meta})).sort((e,t)=>e.name.localeCompare(t.name))),[F.tools,e]),R=(0,G.useMemo)(()=>JSON.stringify(F.resources.map(e=>({uri:e.uri,name:e.name,description:e.description,mimeType:e.mimeType})).sort((e,t)=>e.uri.localeCompare(t.uri))),[F.resources]),z=(0,G.useMemo)(()=>JSON.stringify(F.prompts.map(e=>({name:e.name,description:e.description,arguments:e.arguments})).sort((e,t)=>e.name.localeCompare(t.name))),[F.prompts]),ne=(0,G.useRef)(o),re=(0,G.useRef)(null),ie=(0,G.useRef)({tools:``,resources:``,prompts:``});return(0,G.useEffect)(()=>{ne.current=o},[o]),(0,G.useEffect)(()=>{let n={...F,id:e,url:t.url||``,name:u||e,notifications:_,unreadNotificationCount:ee,markNotificationRead:T,markAllNotificationsRead:E,clearNotifications:D,pendingSamplingRequests:I,approveSampling:k,rejectSampling:A,pendingElicitationRequests:L,approveElicitation:M,rejectElicitation:N},r=re.current,i=ie.current,a=i.tools!==te,o=i.resources!==R,s=i.prompts!==z;!r||r.state!==n.state||r.error!==n.error||r.authUrl!==n.authUrl||a||o||s||r.serverInfo!==n.serverInfo||r.capabilities!==n.capabilities||r.notifications.length!==n.notifications.length||r.unreadNotificationCount!==n.unreadNotificationCount||r.pendingSamplingRequests.length!==n.pendingSamplingRequests.length||r.pendingElicitationRequests.length!==n.pendingElicitationRequests.length||!r.client?(re.current=n,ie.current={tools:te,resources:R,prompts:z},ne.current(n)):xr.debug(`[McpServerWrapper ${e}] No meaningful changes detected, skipping onUpdate`)},[e,u,t.url,F.state,F.error,F.authUrl,te,R,z,F.serverInfo,F.capabilities,_.length,ee,I.length,L.length,T,E,D,k,A,M,N]),null}a(wr,`McpServerWrapper`);function Tr({children:e,mcpServers:t,defaultProxyConfig:n,defaultAutoProxyFallback:r=!0,clientInfo:i,storageProvider:o,enableRpcLogging:s=!1,onServerAdded:c,onServerRemoved:l,onServerStateChange:u,onSamplingRequest:d,onElicitationRequest:f}){let[p,m]=(0,G.useState)([]),[h,g]=(0,G.useState)([]),[_,v]=(0,G.useState)(!1),y=(0,G.useRef)({}),[b,x]=(0,G.useState)(void 0),[S,C]=(0,G.useState)(!1);(0,G.useEffect)(()=>{if(!s||typeof window>`u`){x(void 0),C(!0);return}B(()=>import(`./rpc-logger-TPNV75J4-DaBpv6Xr.js`).then(e=>{xr.debug(`[McpClientProvider] RPC logger loaded`),x(()=>e.wrapTransportForLogging),C(!0)}),__vite__mapDeps([0,1,2,3])).catch(e=>{xr.error(`[McpClientProvider] Failed to load RPC logger:`,e),x(void 0),C(!0)})},[s]),(0,G.useEffect)(()=>{if(!S){xr.debug(`[McpClientProvider] Waiting for RPC logging to be ready before loading servers`);return}a(async()=>{if(xr.debug(`[McpClientProvider] Loading servers, storageProvider:`,!!o,`mcpServers:`,t),!o){if(t){let e=Object.entries(t).map(([e,t])=>({id:e,options:t}));xr.debug(`[McpClientProvider] Loaded from mcpServers prop:`,e.length),m(e)}v(!0);return}try{let e=await Promise.resolve(o.getServers());if(xr.debug(`[McpClientProvider] Loaded from storage:`,Object.keys(e).length),o.getServerMetadata)try{let t=Object.keys(e).map(async e=>[e,await Promise.resolve(o.getServerMetadata(e))]),n=await Promise.all(t);y.current=Object.fromEntries(n.filter(e=>e[1]!==void 0)),xr.debug(`[McpClientProvider] Loaded cached metadata for`,Object.keys(y.current).length,`servers`)}catch(e){xr.warn(`[McpClientProvider] Failed to load cached metadata:`,e)}let n={...e,...t},r=Object.entries(n).map(([e,t])=>({id:e,options:t}));xr.debug(`[McpClientProvider] Total servers after merge:`,r.length),m(r),v(!0)}catch(e){xr.error(`[McpClientProvider] Failed to load from storage:`,e),t&&m(Object.entries(t).map(([e,t])=>({id:e,options:t}))),v(!0)}},`loadServers`)()},[o,t,S]),(0,G.useEffect)(()=>{!o||!_||a(async()=>{try{let e=p.reduce((e,t)=>(e[t.id]=t.options,e),{});await Promise.resolve(o.setServers(e))}catch(e){xr.error(`[McpClientProvider] Failed to save to storage:`,e)}},`saveServers`)()},[p,o,_]);let w=(0,G.useCallback)(e=>{xr.debug(`[McpClientProvider] handleServerUpdate called for server ${e.id}`,{toolCount:e.tools.length,state:e.state});let t=[];g(n=>{let r=n.findIndex(t=>t.id===e.id);if(r===-1)return xr.debug(`[McpClientProvider] Adding new server ${e.id} to state`),t.push(()=>c?.(e.id,e)),[...n,e];let i=n[r],a=i.state!==e.state,s=i.serverInfo!==e.serverInfo;if(xr.debug(`[McpClientProvider] Comparing server ${e.id}:`,{toolsChanged:i.tools!==e.tools,currentToolCount:i.tools.length,updatedToolCount:e.tools.length,stateChanged:a}),i.state===e.state&&i.tools===e.tools&&i.resources===e.resources&&i.prompts===e.prompts&&i.error===e.error&&i.serverInfo===e.serverInfo&&i.client===e.client&&i.notifications===e.notifications&&i.unreadNotificationCount===e.unreadNotificationCount&&i.pendingSamplingRequests.length===e.pendingSamplingRequests.length&&i.pendingElicitationRequests.length===e.pendingElicitationRequests.length)return xr.debug(`[McpClientProvider] No changes detected for server ${e.id}, skipping update`),n;if(xr.debug(`[McpClientProvider] Updating server ${e.id} in state`),a&&t.push(()=>u?.(e.id,e.state)),s&&e.serverInfo&&o?.setServerMetadata){let t={name:e.serverInfo.name,version:e.serverInfo.version,title:e.serverInfo.title,websiteUrl:e.serverInfo.websiteUrl,icons:e.serverInfo.icons,icon:e.serverInfo.icon};y.current[e.id]=t,Promise.resolve(o.setServerMetadata(e.id,t)).catch(e=>{xr.error(`[McpClientProvider] Failed to save server metadata:`,e)})}let l=[...n];return l[r]=e,l}),t.length>0&&queueMicrotask(()=>{t.forEach(e=>e())})},[c,u,o]),T=(0,G.useCallback)((e,t)=>{m(n=>n.find(t=>t.id===e)?n:(xr.debug(`[McpClientProvider] Adding new server to configs:`,e),[...n,{id:e,options:t}]))},[]),E=(0,G.useCallback)(e=>{g(t=>{let n=t.find(t=>t.id===e);return n?.disconnect&&n.disconnect(),n?.clearStorage&&n.clearStorage(),t.filter(t=>t.id!==e)}),m(t=>t.filter(t=>t.id!==e)),l?.(e)},[l]),D=(0,G.useCallback)(async(e,t)=>new Promise(n=>{let r=p.find(t=>t.id===e);if(!r){xr.warn(`[McpClientProvider] Cannot update server "${e}" - not found`),n();return}let i={...r.options,...t,_updateVersion:(r.options._updateVersion||0)+1};g(t=>{let n=t.find(t=>t.id===e);return n?.disconnect&&n.disconnect(),n?.clearStorage&&n.clearStorage(),t.filter(t=>t.id!==e)}),m(t=>{let r=t.map(t=>t.id===e?{id:e,options:i}:t);return setTimeout(()=>n(),0),r})}),[p]),O=(0,G.useCallback)(e=>h.find(t=>t.id===e),[h]),k=(0,G.useMemo)(()=>({servers:h,addServer:T,removeServer:E,updateServer:D,getServer:O,storageLoaded:_}),[h,T,E,D,O,_]),{capabilities:A,...j}=i||{},M=(0,G.useMemo)(()=>Object.keys(j).length?j:void 0,[i]),N=(0,G.useMemo)(()=>p.map(e=>({id:e.id,options:A?{...e.options,clientOptions:{...e.options.clientOptions,capabilities:{...A,...e.options.clientOptions?.capabilities}}}:e.options})),[p,A]);return G.createElement(Sr.Provider,{value:k},e,N.map(e=>G.createElement(wr,{key:`${e.id}-v${e.options._updateVersion||0}`,id:e.id,options:e.options,defaultProxyConfig:n,defaultAutoProxyFallback:r,clientInfo:M,cachedMetadata:y.current[e.id],onUpdate:w,rpcWrapTransport:b,onGlobalSamplingRequest:d,onGlobalElicitationRequest:f})))}a(Tr,`McpClientProvider`);function Er(){let e=(0,G.useContext)(Sr);if(!e)throw Error(`useMcpClient must be used within a McpClientProvider`);return e}a(Er,`useMcpClient`);function Dr(e){let{getServer:t}=Er();return t(e)}a(Dr,`useMcpServer`);var Or=class{constructor(e=`mcp-client-servers`){this.storageKey=e,this.metadataKey=`${e}-metadata`}static{a(this,`LocalStorageProvider`)}metadataKey;getServers(){try{let e=localStorage.getItem(this.storageKey);return e?JSON.parse(e):{}}catch(e){return console.error(`[LocalStorageProvider] Failed to load servers:`,e),{}}}setServers(e){try{localStorage.setItem(this.storageKey,JSON.stringify(e))}catch(e){console.error(`[LocalStorageProvider] Failed to save servers:`,e)}}setServer(e,t){let n=this.getServers();n[e]=t,this.setServers(n)}removeServer(e){let t=this.getServers();delete t[e],this.setServers(t),this.removeServerMetadata(e)}clear(){try{localStorage.removeItem(this.storageKey),localStorage.removeItem(this.metadataKey)}catch(e){console.error(`[LocalStorageProvider] Failed to clear:`,e)}}getAllMetadata(){try{let e=localStorage.getItem(this.metadataKey);return e?JSON.parse(e):{}}catch(e){return console.error(`[LocalStorageProvider] Failed to load metadata:`,e),{}}}setAllMetadata(e){try{localStorage.setItem(this.metadataKey,JSON.stringify(e))}catch(e){console.error(`[LocalStorageProvider] Failed to save metadata:`,e)}}getServerMetadata(e){return this.getAllMetadata()[e]}setServerMetadata(e,t){let n=this.getAllMetadata();n[e]={...t,cachedAt:Date.now()},this.setAllMetadata(n)}removeServerMetadata(e){let t=this.getAllMetadata();delete t[e],this.setAllMetadata(t)}};(class{static{a(this,`MemoryStorageProvider`)}storage={};metadata={};getServers(){return{...this.storage}}setServers(e){this.storage={...e}}setServer(e,t){this.storage[e]=t}removeServer(e){delete this.storage[e],this.removeServerMetadata(e)}clear(){this.storage={},this.metadata={}}getServerMetadata(e){return this.metadata[e]}setServerMetadata(e,t){this.metadata[e]={...t,cachedAt:Date.now()}}removeServerMetadata(e){delete this.metadata[e]}});var kr=i((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),eee=i(((e,t)=>{t.exports=kr()})),Ar=i((e=>{var t=xn();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.4`})),jr=i(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Ar()})),Mr=i((e=>{var t=eee(),n=xn(),r=jr();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),m=Symbol.for(`react.transitional.element`),h=Symbol.for(`react.portal`),g=Symbol.for(`react.fragment`),_=Symbol.for(`react.strict_mode`),v=Symbol.for(`react.profiler`),y=Symbol.for(`react.consumer`),b=Symbol.for(`react.context`),x=Symbol.for(`react.forward_ref`),S=Symbol.for(`react.suspense`),C=Symbol.for(`react.suspense_list`),w=Symbol.for(`react.memo`),T=Symbol.for(`react.lazy`),E=Symbol.for(`react.activity`),D=Symbol.for(`react.memo_cache_sentinel`),O=Symbol.iterator;function k(e){return typeof e!=`object`||!e?null:(e=O&&e[O]||e[`@@iterator`],typeof e==`function`?e:null)}var A=Symbol.for(`react.client.reference`);function j(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===A?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case g:return`Fragment`;case v:return`Profiler`;case _:return`StrictMode`;case S:return`Suspense`;case C:return`SuspenseList`;case E:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case h:return`Portal`;case b:return e.displayName||`Context`;case y:return(e._context.displayName||`Context`)+`.Consumer`;case x:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case w:return t=e.displayName||null,t===null?j(e.type)||`Memo`:t;case T:t=e._payload,e=e._init;try{return j(e(t))}catch{}}return null}var M=Array.isArray,N=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F={pending:!1,data:null,method:null,action:null},I=[],L=-1;function ee(e){return{current:e}}function te(e){0>L||(e.current=I[L],I[L]=null,L--)}function R(e,t){L++,I[L]=e.current,e.current=t}var z=ee(null),ne=ee(null),re=ee(null),ie=ee(null);function ae(e,t){switch(R(re,t),R(ne,e),R(z,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Gd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Gd(t),e=Kd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}te(z),R(z,e)}function oe(){te(z),te(ne),te(re)}function se(e){e.memoizedState!==null&&R(ie,e);var t=z.current,n=Kd(t,e.type);t!==n&&(R(ne,e),R(z,n))}function ce(e){ne.current===e&&(te(z),te(ne)),ie.current===e&&(te(ie),np._currentValue=F)}var le,ue;function de(e){if(le===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);le=t&&t[1]||``,ue=-1<e.stack.indexOf(`
|
|
5
|
+
`);return window.openai.sendFollowUpMessage({prompt:n})},[b]),de=(0,G.useCallback)(e=>{if(b===`mcp-apps`){ar().openLink(e).catch(e=>{console.error(`Failed to open link:`,e)});return}if(!window.openai?.openExternal)throw Error(`window.openai.openExternal is not available`);window.openai.openExternal({href:e})},[b]),B=(0,G.useCallback)(async e=>{if(b===`mcp-apps`)return await ar().requestDisplayMode(e);if(!window.openai?.requestDisplayMode)throw Error(`window.openai.requestDisplayMode is not available`);return window.openai.requestDisplayMode({mode:e})},[b]),fe=(0,G.useCallback)(async e=>{if(b===`mcp-apps`){let t=typeof e==`function`?e(ae):e;oe(t);let n=ar(),r=t;n.updateModelContext({structuredContent:r,content:[{type:`text`,text:JSON.stringify(Object.fromEntries(Object.entries(r).filter(([e])=>e!==Rn)))}]}).catch(e=>{console.warn(`[useWidget] Failed to update model context:`,e)});return}if(!window.openai?.setWidgetState)throw Error(`window.openai.setWidgetState is not available`);let t=typeof e==`function`?e(E===void 0?ae:E):e,n=(window.openai.widgetState??{})[Rn];return oe(t),window.openai.setWidgetState(n===void 0?t:{...t,[Rn]:n})},[b,E,ae]),pe=(0,G.useMemo)(()=>b===`openai`?w===null&&T===null:b===`mcp-apps`?c===null:b===`mcp-ui`?typeof window<`u`&&window!==window.parent&&!S.toolId?!0:P==null:!1,[b,w,T,c,P,S.toolId]),me=(0,G.useMemo)(()=>b===`mcp-apps`&&f?f:null,[b,f]),V=(0,G.useMemo)(()=>b===`mcp-apps`?f!==null:!1,[b,f]);return{props:F,toolInput:N||{},output:P??null,metadata:b===`mcp-apps`?u??null:T??null,state:ae?Object.fromEntries(Object.entries(ae).filter(([e])=>e!==Rn)):null,setState:fe,theme:I||`light`,displayMode:L||`inline`,safeArea:ee||{insets:{top:0,bottom:0,left:0,right:0}},maxHeight:te||600,maxWidth:R,userAgent:z||{device:{type:`desktop`},capabilities:{hover:!0,touch:!1}},locale:ne||tr.LOCALE,timeZone:re||(typeof window<`u`?Intl.DateTimeFormat().resolvedOptions().timeZone:`UTC`),mcp_url:ie,callTool:le,sendFollowUpMessage:ue,openExternal:de,requestDisplayMode:B,isAvailable:t||r,isPending:pe,partialToolInput:me,isStreaming:V,hostInfo:g??void 0,hostCapabilities:v??void 0}}a(lr,`useWidget`);function ur(e){let{props:t}=lr(e);return t}a(ur,`useWidgetProps`);function dr(){let{theme:e}=lr();return e}a(dr,`useWidgetTheme`);function fr(e){let{state:t,setState:n}=lr();return(0,G.useEffect)(()=>{t===null&&e!==void 0&&window.openai?.setWidgetState&&n(e)},[]),[t,n]}a(fr,`useWidgetState`);var pr=a(({children:e})=>{let{theme:t,isAvailable:n}=lr(),[r,i]=(0,G.useState)(()=>typeof window>`u`?`light`:window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`);(0,G.useEffect)(()=>{if(typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=a(e=>{i(e.matches?`dark`:`light`)},`handleChange`);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let o=n?t:r;return(0,G.useLayoutEffect)(()=>{if(typeof document>`u`)return;let e=document.documentElement;e.classList.remove(`light`,`dark`),e.classList.add(o===`dark`?`dark`:`light`),e.setAttribute(`data-theme`,o===`dark`?`dark`:`light`),e.style.colorScheme=o===`dark`?`dark`:`light`},[o]),G.createElement(G.Fragment,null,e)},`ThemeProvider`);function mr({children:e,className:t=``,position:n=`top-right`,attachTo:r,showLabels:i=!0,debugger:o=!1,viewControls:s=!1}){let{props:c,output:l,metadata:u,state:d,theme:f,displayMode:p,safeArea:m,maxHeight:h,userAgent:g,locale:_,isAvailable:v,callTool:y,sendFollowUpMessage:b,openExternal:x,requestDisplayMode:S,setState:C}=lr(),[w,T]=(0,G.useState)(!1),[E,D]=(0,G.useState)(!1),O=(0,G.useRef)(null),k=(0,G.useRef)(null),[A,j]=(0,G.useState)([]),[M,N]=(0,G.useState)(``),[P,F]=(0,G.useState)(`get-my-city`),[I,L]=(0,G.useState)(`{}`),[ee,te]=(0,G.useState)(`Test follow-up message`),[R,z]=(0,G.useState)(`https://mcp-use.com/docs`),ne=p===`fullscreen`&&v,re=p===`pip`&&v,ie=typeof window<`u`&&window.location.pathname.includes(`/inspector/api/`);(0,G.useEffect)(()=>{let e=setTimeout(()=>{if(typeof window<`u`&&window.openai)try{j(Object.keys(window.openai))}catch{j([])}else j([])},100);return()=>{clearTimeout(e)}},[]);let ae=f===`dark`,oe=a(()=>{let e=[`absolute`,`z-[1000]`,`flex`,`gap-2`,`transition-opacity`,`duration-200`,`ease-in-out`,w?`opacity-100`:`opacity-0`,w?`pointer-events-auto`:`pointer-events-none`];switch(n){case`top-left`:return[...e,`top-4`,`left-4`];case`top-center`:return[...e,`top-4`,`left-1/2`,`-translate-x-1/2`];case`top-right`:return[...e,`top-4`,`right-4`];case`center-left`:return[...e,`top-1/2`,`left-4`,`-translate-y-1/2`];case`center-right`:return[...e,`top-1/2`,`right-4`,`-translate-y-1/2`];case`bottom-left`:return[...e,`bottom-4`,`left-4`];case`bottom-center`:return[...e,`bottom-4`,`left-1/2`,`-translate-x-1/2`];case`bottom-right`:return[...e,`bottom-4`,`right-4`];default:return[...e,`top-4`,`right-4`]}},`getPositionClasses`),se=a(()=>{let e=m?.insets?.top?Math.max(16,m.insets.top+8):16,t=m?.insets?.right?Math.max(16,m.insets.right+8):16,r=m?.insets?.bottom?Math.max(16,m.insets.bottom+8):16,i=m?.insets?.left?Math.max(16,m.insets.left+8):16,a={};switch(n){case`top-left`:a.top=`${e}px`,a.left=`${i}px`;break;case`top-center`:a.top=`${e}px`;break;case`top-right`:a.top=`${e}px`,a.right=`${t}px`;break;case`center-left`:a.left=`${i}px`;break;case`center-right`:a.right=`${t}px`;break;case`bottom-left`:a.bottom=`${r}px`,a.left=`${i}px`;break;case`bottom-center`:a.bottom=`${r}px`;break;case`bottom-right`:a.bottom=`${r}px`,a.right=`${t}px`;break;default:a.top=`${e}px`,a.right=`${t}px`;break}return a},`getPositionOffsetStyles`);(0,G.useEffect)(()=>{if(!r)return;let e=a(()=>T(!0),`handleMouseEnter`),t=a(()=>T(!1),`handleMouseLeave`);return r.addEventListener(`mouseenter`,e),r.addEventListener(`mouseleave`,t),()=>{r.removeEventListener(`mouseenter`,e),r.removeEventListener(`mouseleave`,t)}},[r]),(0,G.useEffect)(()=>{if(!E)return;let e=a(e=>{k.current&&!k.current.contains(e.target)&&D(!1)},`handleClickOutside`);return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[E]),(0,G.useEffect)(()=>(E?document.body.style.overflow=`hidden`:document.body.style.overflow=``,()=>{document.body.style.overflow=``}),[E]);let ce=a(()=>{D(!E)},`handleToggleOverlay`),le=a(async()=>{try{N(`Calling tool...`);let e=await y(P,I.trim()?JSON.parse(I):{});N(`Success: ${JSON.stringify(e,null,2)}`)}catch(e){N(`Error: ${e.message}`)}},`handleCallTool`),ue=a(async()=>{try{N(`Sending follow-up message...`),await b(ee),N(`Follow-up message sent successfully`)}catch(e){N(`Error: ${e.message}`)}},`handleSendFollowUpMessage`),de=a(()=>{try{x(R),N(`Opened external link: ${R}`)}catch(e){N(`Error: ${e.message}`)}},`handleOpenExternal`),B=a(async e=>{try{N(`Requesting display mode: ${e}...`),N(`Display mode granted: ${(await S(e)).mode}`)}catch(e){N(`Error: ${e.message}`)}},`handleRequestDisplayMode`),fe=a(async()=>{try{let e=d?{...d,debugTimestamp:new Date().toISOString()}:{debugTimestamp:new Date().toISOString()};N(`Setting state...`),await C(e),N(`State updated: ${JSON.stringify(e,null,2)}`)}catch(e){N(`Error: ${e.message}`)}},`handleSetState`),pe=a(async()=>{try{await S(`fullscreen`)}catch(e){console.error(`Failed to go fullscreen:`,e)}},`handleFullscreen`),me=a(async()=>{try{await S(`pip`)}catch(e){console.error(`Failed to go pip:`,e)}},`handlePip`),V=a(()=>{let e=[`absolute`,`px-2`,`py-1`,`bg-black/90`,`text-white`,`rounded`,`text-xs`,`whitespace-nowrap`,`pointer-events-none`,`transition-opacity`,`duration-200`,`ease-in-out`];switch(n){case`top-right`:return[...e,`top-full`,`right-0`,`mt-2`];case`top-left`:return[...e,`top-full`,`left-0`,`mt-2`];case`top-center`:return[...e,`top-full`,`left-1/2`,`-translate-x-1/2`,`mt-2`];case`bottom-right`:return[...e,`bottom-full`,`right-0`,`mb-2`];case`bottom-left`:return[...e,`bottom-full`,`left-0`,`mb-2`];case`bottom-center`:return[...e,`bottom-full`,`left-1/2`,`-translate-x-1/2`,`mb-2`];case`center-left`:return[...e,`left-full`,`top-1/2`,`-translate-y-1/2`,`ml-2`];case`center-right`:return[...e,`right-full`,`top-1/2`,`-translate-y-1/2`,`mr-2`];default:return[...e,`top-full`,`right-0`,`mt-2`]}},`getTooltipClasses`),H=a(({onClick:e,label:t,children:n})=>{let[r,a]=(0,G.useState)(!1),o=V();return G.createElement(`button`,{className:`p-2 ${ae?`bg-white/10 hover:bg-white/20`:`bg-black/70 hover:bg-black/90`} text-white border-none rounded-lg cursor-pointer flex items-center justify-center w-8 h-8 transition-colors duration-200 backdrop-blur-md ${ae?`shadow-[0_2px_8px_rgba(0,0,0,0.3)]`:`shadow-[0_2px_8px_rgba(0,0,0,0.2)]`} relative`,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),onClick:e,"aria-label":t},G.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`block`},n),i&&G.createElement(`span`,{className:`${o.join(` `)} ${r?`opacity-100`:`opacity-0`}`},t))},`IconButton`),he=a(e=>{if(e===null)return`null`;if(e===void 0)return`undefined`;if(typeof e==`object`)try{return JSON.stringify(e,null,2)}catch{return String(e)}return String(e)},`formatValue`),ge=a(e=>e?`${e.device?.type||`unknown`}`:`N/A`,`formatUserAgent`),_e=a(e=>{if(!e?.insets)return`N/A`;let{top:t,bottom:n,left:r,right:i}=e.insets;return`T:${t} B:${n} L:${r} R:${i}`},`formatSafeArea`);return G.createElement(G.Fragment,null,G.createElement(`div`,{ref:O,className:`${t} relative h-fit`,onMouseEnter:()=>!r&&T(!0),onMouseLeave:()=>!r&&T(!1)},G.createElement(`div`,{className:oe().join(` `),style:se()},!ie&&G.createElement(G.Fragment,null,!ne&&!re&&G.createElement(G.Fragment,null,(s===!0||s===`fullscreen`)&&G.createElement(H,{onClick:pe,label:`Fullscreen`},G.createElement(`path`,{d:`M15 3h6v6`}),G.createElement(`path`,{d:`m21 3-7 7`}),G.createElement(`path`,{d:`m3 21 7-7`}),G.createElement(`path`,{d:`M9 21H3v-6`})),(s===!0||s===`pip`)&&G.createElement(H,{onClick:me,label:`Picture in Picture`},G.createElement(`path`,{d:`M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4`}),G.createElement(`rect`,{width:`10`,height:`7`,x:`12`,y:`13`,rx:`2`}))),o&&G.createElement(H,{onClick:ce,label:`Debug Info`},G.createElement(`path`,{d:`M12 20v-9`}),G.createElement(`path`,{d:`M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z`}),G.createElement(`path`,{d:`M14.12 3.88 16 2`}),G.createElement(`path`,{d:`M21 21a4 4 0 0 0-3.81-4`}),G.createElement(`path`,{d:`M21 5a4 4 0 0 1-3.55 3.97`}),G.createElement(`path`,{d:`M22 13h-4`}),G.createElement(`path`,{d:`M3 21a4 4 0 0 1 3.81-4`}),G.createElement(`path`,{d:`M3 5a4 4 0 0 0 3.55 3.97`}),G.createElement(`path`,{d:`M6 13H2`}),G.createElement(`path`,{d:`m8 2 1.88 1.88`}),G.createElement(`path`,{d:`M9 7.13V6a3 3 0 1 1 6 0v1.13`})))),e),E&&o&&G.createElement(`div`,{ref:k,className:`fixed inset-0 bg-black text-white font-mono text-xs z-[10000] overflow-auto p-4`,onClick:e=>{e.target===k.current&&D(!1)}},G.createElement(`button`,{onClick:()=>D(!1),className:`absolute top-4 right-4 bg-white/10 text-white border-none rounded w-8 h-8 cursor-pointer flex items-center justify-center text-lg leading-none`,"aria-label":`Close`},`×`),G.createElement(`div`,{className:`max-w-[1200px] mx-auto pt-10`},G.createElement(`h1`,{className:`text-lg font-bold mb-4 border-b border-gray-700 pb-2`},`Debug Info`),G.createElement(`table`,{className:`w-full border-collapse border-spacing-0`},G.createElement(`tbody`,null,G.createElement(`tr`,{className:`border-b border-gray-700`},G.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Props`),G.createElement(`td`,{className:`p-2 whitespace-pre-wrap break-all`},he(c))),G.createElement(`tr`,{className:`border-b border-gray-700`},G.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Output`),G.createElement(`td`,{className:`p-2 whitespace-pre-wrap break-all`},he(l))),G.createElement(`tr`,{className:`border-b border-gray-700`},G.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Metadata`),G.createElement(`td`,{className:`p-2 whitespace-pre-wrap break-all`},he(u))),G.createElement(`tr`,{className:`border-b border-gray-700`},G.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`State`),G.createElement(`td`,{className:`p-2 whitespace-pre-wrap break-all`},he(d))),G.createElement(`tr`,{className:`border-b border-gray-700`},G.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Theme`),G.createElement(`td`,{className:`p-2`},f)),G.createElement(`tr`,{className:`border-b border-gray-700`},G.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Display Mode`),G.createElement(`td`,{className:`p-2`},p)),G.createElement(`tr`,{className:`border-b border-gray-700`},G.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Locale`),G.createElement(`td`,{className:`p-2`},_)),G.createElement(`tr`,{className:`border-b border-gray-700`},G.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Max Height`),G.createElement(`td`,{className:`p-2`},h,`px`)),G.createElement(`tr`,{className:`border-b border-gray-700`},G.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`User Agent`),G.createElement(`td`,{className:`p-2`},ge(g))),G.createElement(`tr`,{className:`border-b border-gray-700`},G.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Safe Area`),G.createElement(`td`,{className:`p-2`},_e(m))),G.createElement(`tr`,{className:`border-b border-gray-700`},G.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`API Available`),G.createElement(`td`,{className:`p-2`},v?`Yes`:`No`)),G.createElement(`tr`,{className:`border-b border-gray-700`},G.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`window.openai Keys`),G.createElement(`td`,{className:`p-2`},A.length>0?A.join(`, `):`N/A`)))),G.createElement(`h2`,{className:`text-base font-bold mt-8 mb-4 border-b border-gray-700 pb-2`},`Actions`),G.createElement(`div`,{className:`flex flex-col gap-3`},G.createElement(`div`,{className:`flex gap-2 items-center`},G.createElement(`input`,{type:`text`,value:P,onChange:e=>F(e.target.value),placeholder:`Tool name`,className:`py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs w-[150px]`}),G.createElement(`input`,{type:`text`,value:I,onChange:e=>L(e.target.value),placeholder:`{"key": "value"}`,className:`py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1`}),G.createElement(`button`,{onClick:le,className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs`},`Call Tool`)),G.createElement(`div`,{className:`flex gap-2 items-center`},G.createElement(`input`,{type:`text`,value:ee,onChange:e=>te(e.target.value),placeholder:`Follow-up message`,className:`py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1`}),G.createElement(`button`,{onClick:ue,className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs`},`Send Follow-Up`)),G.createElement(`div`,{className:`flex gap-2 items-center`},G.createElement(`input`,{type:`text`,value:R,onChange:e=>z(e.target.value),placeholder:`External URL`,className:`py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1`}),G.createElement(`button`,{onClick:de,className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs`},`Open Link`)),G.createElement(`div`,{className:`flex gap-2 items-center`},G.createElement(`span`,{className:`w-[150px] text-xs`},`Display Mode:`),G.createElement(`button`,{onClick:()=>B(`inline`),className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1`},`Inline`),G.createElement(`button`,{onClick:()=>B(`pip`),className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1`},`PiP`),G.createElement(`button`,{onClick:()=>B(`fullscreen`),className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1`},`Fullscreen`)),G.createElement(`div`,{className:`flex gap-2 items-center`},G.createElement(`button`,{onClick:fe,className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs`},`Set State (Add Timestamp)`)),M&&G.createElement(`div`,{className:`mt-2 p-2 bg-[#1a1a1a] border border-gray-700 rounded whitespace-pre-wrap break-all text-[11px] max-h-[200px] overflow-auto`},G.createElement(`div`,{className:`font-bold mb-1 text-gray-400`},`Result:`),M,G.createElement(`button`,{onClick:()=>N(``),className:`mt-2 py-1 px-2 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-[11px]`},`Clear`))))))}a(mr,`WidgetControls`);var hr=150,gr=5;function _r({children:e,debugger:t=!1,viewControls:n=!1,autoSize:r=!0}){let[i,a]=(0,G.useState)(null),o=(0,G.useRef)(0),s=(0,G.useRef)(null),c=(0,G.useRef)(!1),l=(0,G.useCallback)(e=>{if(!(typeof window>`u`)){if(c.current=!0,window.openai?.notifyIntrinsicHeight){window.openai.notifyIntrinsicHeight(e).then(()=>{c.current=!1}).catch(e=>{c.current=!1,console.error(`[McpUseProvider] Failed to notify intrinsic height (ChatGPT):`,e)});return}try{ar().sendSizeChanged({height:e}),console.log(`[McpUseProvider] Sent size-changed notification:`,e),c.current=!1}catch(e){c.current=!1,console.error(`[McpUseProvider] Failed to notify size change (MCP Apps):`,e)}}},[]),u=(0,G.useCallback)(e=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{Math.abs(e-o.current)>=gr&&e>0&&(o.current=e,l(e))},hr)},[l]);(0,G.useEffect)(()=>{if(!r){console.log(`[McpUseProvider] autoSize is disabled`);return}if(!i){console.log(`[McpUseProvider] No container element found for autoSize`);return}if(typeof ResizeObserver>`u`){console.log(`[McpUseProvider] ResizeObserver not available`);return}console.log(`[McpUseProvider] Setting up ResizeObserver for autoSize`);let e=new ResizeObserver(e=>{if(c.current){console.log(`[McpUseProvider] Skipping resize - notification in progress`);return}for(let t of e){let e=t.contentRect.height,n=t.target.scrollHeight,r=Math.max(e,n);console.log(`[McpUseProvider] ResizeObserver fired:`,{height:e,scrollHeight:n,intrinsicHeight:r}),u(r)}});e.observe(i);let t=Math.max(i.offsetHeight,i.scrollHeight);return console.log(`[McpUseProvider] Initial height measurement:`,t),t>0&&u(t),()=>{console.log(`[McpUseProvider] Cleaning up ResizeObserver`),e.disconnect(),s.current&&=(clearTimeout(s.current),null),c.current=!1}},[r,i,u]);let d=e;return d=G.createElement(Qn,null,d),(t||n)&&(d=G.createElement(mr,{debugger:t,viewControls:n},d)),d=G.createElement(pr,null,d),r&&(d=G.createElement(`div`,{ref:a,style:{width:`100%`,minHeight:0}},d)),G.createElement(G.StrictMode,null,d)}a(_r,`McpUseProvider`);function vr(){let e=(0,G.useMemo)(()=>typeof window>`u`?!1:typeof window.openai?.uploadFile==`function`&&typeof window.openai?.getFileDownloadUrl==`function`,[]);return{isSupported:e,upload:(0,G.useMemo)(()=>async(t,n={})=>{if(!e)throw Error("[useFiles] File upload is not supported in this host. Check `isSupported` before calling `upload`. File operations are only available in the ChatGPT Apps SDK environment.");let r=await window.openai.uploadFile(t),{modelVisible:i=!0}=n;if(i&&window.openai?.setWidgetState){let e=window.openai.widgetState??{},t=[...e.imageIds??[],r.fileId];window.openai.setWidgetState({...e,imageIds:t}).catch(e=>{console.warn(`[useFiles] Failed to track imageId:`,e)})}return r},[e]),getDownloadUrl:(0,G.useMemo)(()=>async t=>{if(!e)throw Error("[useFiles] File download is not supported in this host. Check `isSupported` before calling `getDownloadUrl`. File operations are only available in the ChatGPT Apps SDK environment.");return window.openai.getFileDownloadUrl(t)},[e])}}a(vr,`useFiles`);function yr(e){let[{status:t,data:n,error:r},i]=(0,G.useState)({status:`idle`,data:void 0,error:void 0}),o=(0,G.useRef)(0),s=a(async t=>{let n=++o.current;i({status:`pending`,data:void 0,error:void 0});try{let r;if(typeof window<`u`)if(window.openai?.callTool)r=await window.openai.callTool(e,t);else if(window!==window.parent)r=await ar().callTool(e,t);else throw Error(`No tool calling interface available`);else throw Error(`useCallTool can only be used in browser environment`);let a=or(r);return n===o.current&&i({status:`success`,data:a,error:void 0}),a}catch(e){throw n===o.current&&i({status:`error`,data:void 0,error:e}),e}},`execute`),c=(0,G.useCallback)((e=>s(e===void 0?null:e)),[e]),l=(0,G.useCallback)(((e,t)=>{let n;e&&typeof e==`object`&&(`onSuccess`in e||`onError`in e||`onSettled`in e)?(n=null,t=e):n=e===void 0?null:e,s(n).then(e=>{t?.onSuccess?.(e,n),t?.onSettled?.(e,void 0,n)}).catch(e=>{t?.onError?.(e,n),t?.onSettled?.(void 0,e,n)})}),[e]);return{status:t,data:n,error:r,isIdle:t===`idle`,isPending:t===`pending`,isSuccess:t===`success`,isError:t===`error`,callTool:l,callToolAsync:c}}a(yr,`useCallTool`);function br(){return{useCallTool:a(e=>yr(e),`useCallTool`),useToolInfo:a(()=>lr(),`useToolInfo`)}}a(br,`generateHelpers`);var xr=s.get(`McpClientProvider`),Sr=(0,G.createContext)(null),Cr=500;function wr({id:e,options:t,defaultProxyConfig:n,defaultAutoProxyFallback:r,clientInfo:i,cachedMetadata:a,onUpdate:o,rpcWrapTransport:s,onGlobalSamplingRequest:c,onGlobalElicitationRequest:l}){let{name:u,onSamplingRequest:d,onElicitationRequest:f,onNotificationReceived:p,wrapTransport:m}=t,h=(0,G.useMemo)(()=>{let{name:e,onSamplingRequest:o,onElicitationRequest:s,onNotificationReceived:c,wrapTransport:l,...u}=t;return{...u,proxyConfig:u.proxyConfig||n,autoProxyFallback:u.autoProxyFallback===void 0?r:u.autoProxyFallback,clientInfo:u.clientInfo?i?{...i,...u.clientInfo}:u.clientInfo:i,_initialServerInfo:a}},[t,n,r,i,a]),g=(0,G.useMemo)(()=>{if(!(!s&&!m))return t=>{let n=t;return s&&(n=s(n,e)),m&&(n=m(n,e)),n}},[s,m,e]),[_,v]=(0,G.useState)([]),[y,b]=(0,G.useState)([]),x=(0,G.useRef)(0),[S,C]=(0,G.useState)([]),w=(0,G.useRef)(0),T=(0,G.useCallback)(e=>{v(t=>t.map(t=>t.id===e?{...t,read:!0}:t))},[]),E=(0,G.useCallback)(()=>{v(e=>e.map(e=>({...e,read:!0})))},[]),D=(0,G.useCallback)(()=>{v([])},[]),O=(0,G.useCallback)(e=>{let t={id:globalThis.crypto?.randomUUID?.()||`${Date.now()}-${Math.random()}`,method:e.method,params:e.params,timestamp:Date.now(),read:!1};v(e=>{let n=[t,...e];return n.length>Cr?n.slice(0,Cr):n}),p?.(t)},[p]),k=(0,G.useCallback)((e,t)=>{b(n=>{let r=n.find(t=>t.id===e);return r?(r.resolve(t),n.filter(t=>t.id!==e)):n})},[]),A=(0,G.useCallback)((e,t)=>{b(n=>{let r=n.find(t=>t.id===e);return r?(r.reject(Error(t||`User rejected sampling request`)),n.filter(t=>t.id!==e)):n})},[]),j=(0,G.useCallback)(async t=>new Promise((n,r)=>{let i={id:`sampling-${x.current++}`,request:{method:`sampling/createMessage`,params:t},timestamp:Date.now(),serverName:u||e},a={...i,resolve:n,reject:r};b(e=>[...e,a]),d?.(i),c?.(i,e,u||e,k,A)}),[e,u,d,c,k,A]),M=(0,G.useCallback)((e,t)=>{C(n=>{let r=n.find(t=>t.id===e);return r?(r.resolve(t),n.filter(t=>t.id!==e)):n})},[]),N=(0,G.useCallback)((e,t)=>{C(n=>{let r=n.find(t=>t.id===e);return r?(r.reject(Error(t||`User rejected elicitation request`)),n.filter(t=>t.id!==e)):n})},[]),P=(0,G.useCallback)(async t=>new Promise((n,r)=>{let i={id:`elicitation-${w.current++}`,request:t,timestamp:Date.now(),serverName:u||e},a={...i,resolve:n,reject:r};C(e=>[...e,a]),f?.(i),l?.(i,e,u||e,M,N)}),[e,u,f,l,M,N]),F=Ln({...h,onNotification:O,onSampling:j,onElicitation:P,wrapTransport:g}),I=(0,G.useMemo)(()=>y.map(e=>({id:e.id,request:e.request,timestamp:e.timestamp,serverName:e.serverName})),[y]),L=(0,G.useMemo)(()=>S.map(e=>({id:e.id,request:e.request,timestamp:e.timestamp,serverName:e.serverName})),[S]),ee=(0,G.useMemo)(()=>_.filter(e=>!e.read).length,[_]),te=(0,G.useMemo)(()=>JSON.stringify(F.tools.map(e=>({name:e.name,description:e.description,inputSchema:e.inputSchema,_meta:e._meta})).sort((e,t)=>e.name.localeCompare(t.name))),[F.tools,e]),R=(0,G.useMemo)(()=>JSON.stringify(F.resources.map(e=>({uri:e.uri,name:e.name,description:e.description,mimeType:e.mimeType})).sort((e,t)=>e.uri.localeCompare(t.uri))),[F.resources]),z=(0,G.useMemo)(()=>JSON.stringify(F.prompts.map(e=>({name:e.name,description:e.description,arguments:e.arguments})).sort((e,t)=>e.name.localeCompare(t.name))),[F.prompts]),ne=(0,G.useRef)(o),re=(0,G.useRef)(null),ie=(0,G.useRef)({tools:``,resources:``,prompts:``});return(0,G.useEffect)(()=>{ne.current=o},[o]),(0,G.useEffect)(()=>{let n={...F,id:e,url:t.url||``,name:u||e,notifications:_,unreadNotificationCount:ee,markNotificationRead:T,markAllNotificationsRead:E,clearNotifications:D,pendingSamplingRequests:I,approveSampling:k,rejectSampling:A,pendingElicitationRequests:L,approveElicitation:M,rejectElicitation:N},r=re.current,i=ie.current,a=i.tools!==te,o=i.resources!==R,s=i.prompts!==z;!r||r.state!==n.state||r.error!==n.error||r.authUrl!==n.authUrl||a||o||s||r.serverInfo!==n.serverInfo||r.capabilities!==n.capabilities||r.notifications.length!==n.notifications.length||r.unreadNotificationCount!==n.unreadNotificationCount||r.pendingSamplingRequests.length!==n.pendingSamplingRequests.length||r.pendingElicitationRequests.length!==n.pendingElicitationRequests.length||!r.client?(re.current=n,ie.current={tools:te,resources:R,prompts:z},ne.current(n)):xr.debug(`[McpServerWrapper ${e}] No meaningful changes detected, skipping onUpdate`)},[e,u,t.url,F.state,F.error,F.authUrl,te,R,z,F.serverInfo,F.capabilities,_.length,ee,I.length,L.length,T,E,D,k,A,M,N]),null}a(wr,`McpServerWrapper`);function Tr({children:e,mcpServers:t,defaultProxyConfig:n,defaultAutoProxyFallback:r=!0,clientInfo:i,storageProvider:o,enableRpcLogging:s=!1,onServerAdded:c,onServerRemoved:l,onServerStateChange:u,onSamplingRequest:d,onElicitationRequest:f}){let[p,m]=(0,G.useState)([]),[h,g]=(0,G.useState)([]),[_,v]=(0,G.useState)(!1),y=(0,G.useRef)({}),[b,x]=(0,G.useState)(void 0),[S,C]=(0,G.useState)(!1);(0,G.useEffect)(()=>{if(!s||typeof window>`u`){x(void 0),C(!0);return}B(()=>import(`./rpc-logger-TPNV75J4-BPgEimJH.js`).then(e=>{xr.debug(`[McpClientProvider] RPC logger loaded`),x(()=>e.wrapTransportForLogging),C(!0)}),__vite__mapDeps([0,1,2,3])).catch(e=>{xr.error(`[McpClientProvider] Failed to load RPC logger:`,e),x(void 0),C(!0)})},[s]),(0,G.useEffect)(()=>{if(!S){xr.debug(`[McpClientProvider] Waiting for RPC logging to be ready before loading servers`);return}a(async()=>{if(xr.debug(`[McpClientProvider] Loading servers, storageProvider:`,!!o,`mcpServers:`,t),!o){if(t){let e=Object.entries(t).map(([e,t])=>({id:e,options:t}));xr.debug(`[McpClientProvider] Loaded from mcpServers prop:`,e.length),m(e)}v(!0);return}try{let e=await Promise.resolve(o.getServers());if(xr.debug(`[McpClientProvider] Loaded from storage:`,Object.keys(e).length),o.getServerMetadata)try{let t=Object.keys(e).map(async e=>[e,await Promise.resolve(o.getServerMetadata(e))]),n=await Promise.all(t);y.current=Object.fromEntries(n.filter(e=>e[1]!==void 0)),xr.debug(`[McpClientProvider] Loaded cached metadata for`,Object.keys(y.current).length,`servers`)}catch(e){xr.warn(`[McpClientProvider] Failed to load cached metadata:`,e)}let n={...e,...t},r=Object.entries(n).map(([e,t])=>({id:e,options:t}));xr.debug(`[McpClientProvider] Total servers after merge:`,r.length),m(r),v(!0)}catch(e){xr.error(`[McpClientProvider] Failed to load from storage:`,e),t&&m(Object.entries(t).map(([e,t])=>({id:e,options:t}))),v(!0)}},`loadServers`)()},[o,t,S]),(0,G.useEffect)(()=>{!o||!_||a(async()=>{try{let e=p.reduce((e,t)=>(e[t.id]=t.options,e),{});await Promise.resolve(o.setServers(e))}catch(e){xr.error(`[McpClientProvider] Failed to save to storage:`,e)}},`saveServers`)()},[p,o,_]);let w=(0,G.useCallback)(e=>{xr.debug(`[McpClientProvider] handleServerUpdate called for server ${e.id}`,{toolCount:e.tools.length,state:e.state});let t=[];g(n=>{let r=n.findIndex(t=>t.id===e.id);if(r===-1)return xr.debug(`[McpClientProvider] Adding new server ${e.id} to state`),t.push(()=>c?.(e.id,e)),[...n,e];let i=n[r],a=i.state!==e.state,s=i.serverInfo!==e.serverInfo;if(xr.debug(`[McpClientProvider] Comparing server ${e.id}:`,{toolsChanged:i.tools!==e.tools,currentToolCount:i.tools.length,updatedToolCount:e.tools.length,stateChanged:a}),i.state===e.state&&i.tools===e.tools&&i.resources===e.resources&&i.prompts===e.prompts&&i.error===e.error&&i.serverInfo===e.serverInfo&&i.client===e.client&&i.notifications===e.notifications&&i.unreadNotificationCount===e.unreadNotificationCount&&i.pendingSamplingRequests.length===e.pendingSamplingRequests.length&&i.pendingElicitationRequests.length===e.pendingElicitationRequests.length)return xr.debug(`[McpClientProvider] No changes detected for server ${e.id}, skipping update`),n;if(xr.debug(`[McpClientProvider] Updating server ${e.id} in state`),a&&t.push(()=>u?.(e.id,e.state)),s&&e.serverInfo&&o?.setServerMetadata){let t={name:e.serverInfo.name,version:e.serverInfo.version,title:e.serverInfo.title,websiteUrl:e.serverInfo.websiteUrl,icons:e.serverInfo.icons,icon:e.serverInfo.icon};y.current[e.id]=t,Promise.resolve(o.setServerMetadata(e.id,t)).catch(e=>{xr.error(`[McpClientProvider] Failed to save server metadata:`,e)})}let l=[...n];return l[r]=e,l}),t.length>0&&queueMicrotask(()=>{t.forEach(e=>e())})},[c,u,o]),T=(0,G.useCallback)((e,t)=>{m(n=>n.find(t=>t.id===e)?n:(xr.debug(`[McpClientProvider] Adding new server to configs:`,e),[...n,{id:e,options:t}]))},[]),E=(0,G.useCallback)(e=>{g(t=>{let n=t.find(t=>t.id===e);return n?.disconnect&&n.disconnect(),n?.clearStorage&&n.clearStorage(),t.filter(t=>t.id!==e)}),m(t=>t.filter(t=>t.id!==e)),l?.(e)},[l]),D=(0,G.useCallback)(async(e,t)=>new Promise(n=>{let r=p.find(t=>t.id===e);if(!r){xr.warn(`[McpClientProvider] Cannot update server "${e}" - not found`),n();return}let i={...r.options,...t,_updateVersion:(r.options._updateVersion||0)+1};g(t=>{let n=t.find(t=>t.id===e);return n?.disconnect&&n.disconnect(),n?.clearStorage&&n.clearStorage(),t.filter(t=>t.id!==e)}),m(t=>{let r=t.map(t=>t.id===e?{id:e,options:i}:t);return setTimeout(()=>n(),0),r})}),[p]),O=(0,G.useCallback)(e=>h.find(t=>t.id===e),[h]),k=(0,G.useMemo)(()=>({servers:h,addServer:T,removeServer:E,updateServer:D,getServer:O,storageLoaded:_}),[h,T,E,D,O,_]),{capabilities:A,...j}=i||{},M=(0,G.useMemo)(()=>Object.keys(j).length?j:void 0,[i]),N=(0,G.useMemo)(()=>p.map(e=>({id:e.id,options:A?{...e.options,clientOptions:{...e.options.clientOptions,capabilities:{...A,...e.options.clientOptions?.capabilities}}}:e.options})),[p,A]);return G.createElement(Sr.Provider,{value:k},e,N.map(e=>G.createElement(wr,{key:`${e.id}-v${e.options._updateVersion||0}`,id:e.id,options:e.options,defaultProxyConfig:n,defaultAutoProxyFallback:r,clientInfo:M,cachedMetadata:y.current[e.id],onUpdate:w,rpcWrapTransport:b,onGlobalSamplingRequest:d,onGlobalElicitationRequest:f})))}a(Tr,`McpClientProvider`);function Er(){let e=(0,G.useContext)(Sr);if(!e)throw Error(`useMcpClient must be used within a McpClientProvider`);return e}a(Er,`useMcpClient`);function Dr(e){let{getServer:t}=Er();return t(e)}a(Dr,`useMcpServer`);var Or=class{constructor(e=`mcp-client-servers`){this.storageKey=e,this.metadataKey=`${e}-metadata`}static{a(this,`LocalStorageProvider`)}metadataKey;getServers(){try{let e=localStorage.getItem(this.storageKey);return e?JSON.parse(e):{}}catch(e){return console.error(`[LocalStorageProvider] Failed to load servers:`,e),{}}}setServers(e){try{localStorage.setItem(this.storageKey,JSON.stringify(e))}catch(e){console.error(`[LocalStorageProvider] Failed to save servers:`,e)}}setServer(e,t){let n=this.getServers();n[e]=t,this.setServers(n)}removeServer(e){let t=this.getServers();delete t[e],this.setServers(t),this.removeServerMetadata(e)}clear(){try{localStorage.removeItem(this.storageKey),localStorage.removeItem(this.metadataKey)}catch(e){console.error(`[LocalStorageProvider] Failed to clear:`,e)}}getAllMetadata(){try{let e=localStorage.getItem(this.metadataKey);return e?JSON.parse(e):{}}catch(e){return console.error(`[LocalStorageProvider] Failed to load metadata:`,e),{}}}setAllMetadata(e){try{localStorage.setItem(this.metadataKey,JSON.stringify(e))}catch(e){console.error(`[LocalStorageProvider] Failed to save metadata:`,e)}}getServerMetadata(e){return this.getAllMetadata()[e]}setServerMetadata(e,t){let n=this.getAllMetadata();n[e]={...t,cachedAt:Date.now()},this.setAllMetadata(n)}removeServerMetadata(e){let t=this.getAllMetadata();delete t[e],this.setAllMetadata(t)}};(class{static{a(this,`MemoryStorageProvider`)}storage={};metadata={};getServers(){return{...this.storage}}setServers(e){this.storage={...e}}setServer(e,t){this.storage[e]=t}removeServer(e){delete this.storage[e],this.removeServerMetadata(e)}clear(){this.storage={},this.metadata={}}getServerMetadata(e){return this.metadata[e]}setServerMetadata(e,t){this.metadata[e]={...t,cachedAt:Date.now()}}removeServerMetadata(e){delete this.metadata[e]}});var kr=i((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),eee=i(((e,t)=>{t.exports=kr()})),Ar=i((e=>{var t=xn();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.4`})),jr=i(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Ar()})),Mr=i((e=>{var t=eee(),n=xn(),r=jr();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),m=Symbol.for(`react.transitional.element`),h=Symbol.for(`react.portal`),g=Symbol.for(`react.fragment`),_=Symbol.for(`react.strict_mode`),v=Symbol.for(`react.profiler`),y=Symbol.for(`react.consumer`),b=Symbol.for(`react.context`),x=Symbol.for(`react.forward_ref`),S=Symbol.for(`react.suspense`),C=Symbol.for(`react.suspense_list`),w=Symbol.for(`react.memo`),T=Symbol.for(`react.lazy`),E=Symbol.for(`react.activity`),D=Symbol.for(`react.memo_cache_sentinel`),O=Symbol.iterator;function k(e){return typeof e!=`object`||!e?null:(e=O&&e[O]||e[`@@iterator`],typeof e==`function`?e:null)}var A=Symbol.for(`react.client.reference`);function j(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===A?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case g:return`Fragment`;case v:return`Profiler`;case _:return`StrictMode`;case S:return`Suspense`;case C:return`SuspenseList`;case E:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case h:return`Portal`;case b:return e.displayName||`Context`;case y:return(e._context.displayName||`Context`)+`.Consumer`;case x:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case w:return t=e.displayName||null,t===null?j(e.type)||`Memo`:t;case T:t=e._payload,e=e._init;try{return j(e(t))}catch{}}return null}var M=Array.isArray,N=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F={pending:!1,data:null,method:null,action:null},I=[],L=-1;function ee(e){return{current:e}}function te(e){0>L||(e.current=I[L],I[L]=null,L--)}function R(e,t){L++,I[L]=e.current,e.current=t}var z=ee(null),ne=ee(null),re=ee(null),ie=ee(null);function ae(e,t){switch(R(re,t),R(ne,e),R(z,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Gd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Gd(t),e=Kd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}te(z),R(z,e)}function oe(){te(z),te(ne),te(re)}function se(e){e.memoizedState!==null&&R(ie,e);var t=z.current,n=Kd(t,e.type);t!==n&&(R(ne,e),R(z,n))}function ce(e){ne.current===e&&(te(z),te(ne)),ie.current===e&&(te(ie),np._currentValue=F)}var le,ue;function de(e){if(le===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);le=t&&t[1]||``,ue=-1<e.stack.indexOf(`
|
|
6
6
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
7
7
|
`+le+e+ue}var B=!1;function fe(e,t){if(!e||B)return``;B=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,`props`,{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,`name`,{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
8
8
|
`),l=s.split(`
|
|
@@ -50,7 +50,7 @@ Error generating stack: `+e.message+`
|
|
|
50
50
|
`},Gu=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},Ku=function(){G.useEffect(function(){return document.body.setAttribute(Uu,(Gu()+1).toString()),function(){var e=Gu()-1;e<=0?document.body.removeAttribute(Uu):document.body.setAttribute(Uu,e.toString())}},[])},qu=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;Ku();var a=G.useMemo(function(){return Vu(i)},[i]);return G.createElement(Hu,{styles:Wu(a,!t,i,n?``:`!important`)})},Ju=!1;if(typeof window<`u`)try{var Yu=Object.defineProperty({},`passive`,{get:function(){return Ju=!0,!0}});window.addEventListener(`test`,Yu,Yu),window.removeEventListener(`test`,Yu,Yu)}catch{Ju=!1}var Xu=Ju?{passive:!1}:!1,Zu=function(e){return e.tagName===`TEXTAREA`},Qu=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!Zu(e)&&n[t]===`visible`)},$u=function(e){return Qu(e,`overflowY`)},ed=function(e){return Qu(e,`overflowX`)},td=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),id(e,r)){var i=ad(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},nd=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},rd=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},id=function(e,t){return e===`v`?$u(t):ed(t)},ad=function(e,t){return e===`v`?nd(t):rd(t)},od=function(e,t){return e===`h`&&t===`rtl`?-1:1},sd=function(e,t,n,r,i){var a=od(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=ad(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&id(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},cd=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},ld=function(e){return[e.deltaX,e.deltaY]},ud=function(e){return e&&`current`in e?e.current:e},dd=function(e,t){return e[0]===t[0]&&e[1]===t[1]},fd=function(e){return`
|
|
51
51
|
.block-interactivity-${e} {pointer-events: none;}
|
|
52
52
|
.allow-interactivity-${e} {pointer-events: all;}
|
|
53
|
-
`},pd=0,md=[];function hd(e){var t=G.useRef([]),n=G.useRef([0,0]),r=G.useRef(),i=G.useState(pd++)[0],a=G.useState(Lu)[0],o=G.useRef(e);G.useEffect(function(){o.current=e},[e]),G.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=fu([e.lockRef.current],(e.shards||[]).map(ud),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=G.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=cd(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=td(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=td(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return sd(h,t,e,h===`h`?s:c,!0)},[]),c=G.useCallback(function(e){var n=e;if(!(!md.length||md[md.length-1]!==a)){var r=`deltaY`in n?ld(n):cd(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&dd(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(ud).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=G.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:gd(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=G.useCallback(function(e){n.current=cd(e),r.current=void 0},[]),d=G.useCallback(function(t){l(t.type,ld(t),t.target,s(t,e.lockRef.current))},[]),f=G.useCallback(function(t){l(t.type,cd(t),t.target,s(t,e.lockRef.current))},[]);G.useEffect(function(){return md.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Xu),document.addEventListener(`touchmove`,c,Xu),document.addEventListener(`touchstart`,u,Xu),function(){md=md.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Xu),document.removeEventListener(`touchmove`,c,Xu),document.removeEventListener(`touchstart`,u,Xu)}},[]);var p=e.removeScrollBar,m=e.inert;return G.createElement(G.Fragment,null,m?G.createElement(a,{styles:fd(i)}):null,p?G.createElement(qu,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function gd(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var _d=Eu(Du,hd),vd=G.forwardRef(function(e,t){return G.createElement(ku,uu({},e,{ref:t,sideCar:_d}))});vd.classNames=ku.classNames;var yd=[`Enter`,` `],bd=[`ArrowDown`,`PageUp`,`Home`],xd=[`ArrowUp`,`PageDown`,`End`],Sd=[...bd,...xd],Cd={ltr:[...yd,`ArrowRight`],rtl:[...yd,`ArrowLeft`]},wd={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},Td=`Menu`,[Ed,Dd,Od]=Za(Td),[kd,Ad]=Pa(Td,[Od,sl,Vl]),jd=sl(),Md=Vl(),[Nd,Pd]=kd(Td),[Fd,Id]=kd(Td),Ld=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=jd(t),[c,l]=G.useState(null),u=G.useRef(!1),d=eo(a),f=$a(i);return G.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),(0,K.jsx)(Cl,{...s,children:(0,K.jsx)(Nd,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,K.jsx)(Fd,{scope:t,onClose:G.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};Ld.displayName=Td;var Rd=`MenuAnchor`,zd=G.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=jd(n);return(0,K.jsx)(wl,{...i,...r,ref:t})});zd.displayName=Rd;var Bd=`MenuPortal`,[Vd,Hd]=kd(Bd,{forceMount:void 0}),Ud=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=Pd(Bd,t);return(0,K.jsx)(Vd,{scope:t,forceMount:n,children:(0,K.jsx)(Al,{present:n||a.open,children:(0,K.jsx)(Ol,{asChild:!0,container:i,children:r})})})};Ud.displayName=Bd;var Wd=`MenuContent`,[Gd,Kd]=kd(Wd),qd=G.forwardRef((e,t)=>{let n=Hd(Wd,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Pd(Wd,e.__scopeMenu),o=Id(Wd,e.__scopeMenu);return(0,K.jsx)(Ed.Provider,{scope:e.__scopeMenu,children:(0,K.jsx)(Al,{present:r||a.open,children:(0,K.jsx)(Ed.Slot,{scope:e.__scopeMenu,children:o.modal?(0,K.jsx)(Jd,{...i,ref:t}):(0,K.jsx)(Yd,{...i,ref:t})})})})}),Jd=G.forwardRef((e,t)=>{let n=Pd(Wd,e.__scopeMenu),r=G.useRef(null),i=Br(t,r);return G.useEffect(()=>{let e=r.current;if(e)return lu(e)},[]),(0,K.jsx)(Zd,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Ma(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Yd=G.forwardRef((e,t)=>{let n=Pd(Wd,e.__scopeMenu);return(0,K.jsx)(Zd,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Xd=Ha(`MenuContent.ScrollLock`),Zd=G.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=Pd(Wd,n),_=Id(Wd,n),v=jd(n),y=Md(n),b=Dd(n),[x,S]=G.useState(null),C=G.useRef(null),w=Br(t,C,g.onContentChange),T=G.useRef(0),E=G.useRef(``),D=G.useRef(0),O=G.useRef(null),k=G.useRef(`right`),A=G.useRef(0),j=m?vd:G.Fragment,M=m?{as:Xd,allowPinchZoom:!0}:void 0,N=e=>{let t=E.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=If(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){E.current=t,window.clearTimeout(T.current),t!==``&&(T.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};G.useEffect(()=>()=>window.clearTimeout(T.current),[]),_o();let P=G.useCallback(e=>k.current===O.current?.side&&Rf(e,O.current?.area),[]);return(0,K.jsx)(Gd,{scope:n,searchRef:E,onItemEnter:G.useCallback(e=>{P(e)&&e.preventDefault()},[P]),onItemLeave:G.useCallback(e=>{P(e)||(C.current?.focus(),S(null))},[P]),onTriggerLeave:G.useCallback(e=>{P(e)&&e.preventDefault()},[P]),pointerGraceTimerRef:D,onPointerGraceIntentChange:G.useCallback(e=>{O.current=e},[]),children:(0,K.jsx)(j,{...M,children:(0,K.jsx)(Co,{asChild:!0,trapped:i,onMountAutoFocus:Ma(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,K.jsx)(co,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,K.jsx)($l,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:Ma(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,K.jsx)(Tl,{role:`menu`,"aria-orientation":`vertical`,"data-state":jf(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:w,style:{outline:`none`,...h.style},onKeyDown:Ma(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&N(e.key));let i=C.current;if(e.target!==i||!Sd.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);xd.includes(e.key)&&a.reverse(),Pf(a)}),onBlur:Ma(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(T.current),E.current=``)}),onPointerMove:Ma(e.onPointerMove,zf(e=>{let t=e.target,n=A.current!==e.clientX;e.currentTarget.contains(t)&&n&&(k.current=e.clientX>A.current?`right`:`left`,A.current=e.clientX)}))})})})})})})});qd.displayName=Wd;var Qd=`MenuGroup`,$d=G.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,K.jsx)(Ya.div,{role:`group`,...r,ref:t})});$d.displayName=Qd;var ef=`MenuLabel`,tf=G.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,K.jsx)(Ya.div,{...r,ref:t})});tf.displayName=ef;var nf=`MenuItem`,rf=`menu.itemSelect`,af=G.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=G.useRef(null),o=Id(nf,e.__scopeMenu),s=Kd(nf,e.__scopeMenu),c=Br(t,a),l=G.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(rf,{bubbles:!0,cancelable:!0});e.addEventListener(rf,e=>r?.(e),{once:!0}),Xa(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,K.jsx)(of,{...i,ref:c,disabled:n,onClick:Ma(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:Ma(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:Ma(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||yd.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});af.displayName=nf;var of=G.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=Kd(nf,n),s=Md(n),c=G.useRef(null),l=Br(t,c),[u,d]=G.useState(!1),[f,p]=G.useState(``);return G.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,K.jsx)(Ed.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,K.jsx)(eu,{asChild:!0,...s,focusable:!r,children:(0,K.jsx)(Ya.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:Ma(e.onPointerMove,zf(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ma(e.onPointerLeave,zf(e=>o.onItemLeave(e))),onFocus:Ma(e.onFocus,()=>d(!0)),onBlur:Ma(e.onBlur,()=>d(!1))})})})}),sf=`MenuCheckboxItem`,cf=G.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,K.jsx)(gf,{scope:e.__scopeMenu,checked:n,children:(0,K.jsx)(af,{role:`menuitemcheckbox`,"aria-checked":Mf(n)?`mixed`:n,...i,ref:t,"data-state":Nf(n),onSelect:Ma(i.onSelect,()=>r?.(Mf(n)?!0:!n),{checkForDefaultPrevented:!1})})})});cf.displayName=sf;var lf=`MenuRadioGroup`,[uf,df]=kd(lf,{value:void 0,onValueChange:()=>{}}),ff=G.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=eo(r);return(0,K.jsx)(uf,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,K.jsx)($d,{...i,ref:t})})});ff.displayName=lf;var pf=`MenuRadioItem`,mf=G.forwardRef((e,t)=>{let{value:n,...r}=e,i=df(pf,e.__scopeMenu),a=n===i.value;return(0,K.jsx)(gf,{scope:e.__scopeMenu,checked:a,children:(0,K.jsx)(af,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":Nf(a),onSelect:Ma(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});mf.displayName=pf;var hf=`MenuItemIndicator`,[gf,_f]=kd(hf,{checked:!1}),vf=G.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=_f(hf,n);return(0,K.jsx)(Al,{present:r||Mf(a.checked)||a.checked===!0,children:(0,K.jsx)(Ya.span,{...i,ref:t,"data-state":Nf(a.checked)})})});vf.displayName=hf;var yf=`MenuSeparator`,bf=G.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,K.jsx)(Ya.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});bf.displayName=yf;var xf=`MenuArrow`,Sf=G.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=jd(n);return(0,K.jsx)(El,{...i,...r,ref:t})});Sf.displayName=xf;var Cf=`MenuSub`,[wf,Tf]=kd(Cf),Ef=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=Pd(Cf,t),o=jd(t),[s,c]=G.useState(null),[l,u]=G.useState(null),d=eo(i);return G.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,K.jsx)(Cl,{...o,children:(0,K.jsx)(Nd,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,K.jsx)(wf,{scope:t,contentId:Lo(),triggerId:Lo(),trigger:s,onTriggerChange:c,children:n})})})};Ef.displayName=Cf;var Df=`MenuSubTrigger`,Of=G.forwardRef((e,t)=>{let n=Pd(Df,e.__scopeMenu),r=Id(Df,e.__scopeMenu),i=Tf(Df,e.__scopeMenu),a=Kd(Df,e.__scopeMenu),o=G.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=G.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return G.useEffect(()=>u,[u]),G.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]),(0,K.jsx)(zd,{asChild:!0,...l,children:(0,K.jsx)(of,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":jf(n.open),...e,ref:zr(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Ma(e.onPointerMove,zf(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:Ma(e.onPointerLeave,zf(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:Ma(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||Cd[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});Of.displayName=Df;var kf=`MenuSubContent`,Af=G.forwardRef((e,t)=>{let n=Hd(Wd,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Pd(Wd,e.__scopeMenu),o=Id(Wd,e.__scopeMenu),s=Tf(kf,e.__scopeMenu),c=G.useRef(null),l=Br(t,c);return(0,K.jsx)(Ed.Provider,{scope:e.__scopeMenu,children:(0,K.jsx)(Al,{present:r||a.open,children:(0,K.jsx)(Ed.Slot,{scope:e.__scopeMenu,children:(0,K.jsx)(Zd,{id:s.contentId,"aria-labelledby":s.triggerId,...i,ref:l,align:`start`,side:o.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{o.isUsingKeyboardRef.current&&c.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:Ma(e.onFocusOutside,e=>{e.target!==s.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:Ma(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:Ma(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=wd[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});Af.displayName=kf;function jf(e){return e?`open`:`closed`}function Mf(e){return e===`indeterminate`}function Nf(e){return Mf(e)?`indeterminate`:e?`checked`:`unchecked`}function Pf(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Ff(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function If(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Ff(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function Lf(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function Rf(e,t){return t?Lf({x:e.clientX,y:e.clientY},t):!1}function zf(e){return t=>t.pointerType===`mouse`?e(t):void 0}var Bf=Ld,Vf=zd,Hf=Ud,Uf=qd,Wf=$d,Gf=tf,Kf=af,qf=cf,Jf=ff,Yf=mf,Xf=vf,Zf=bf,Qf=Sf,$f=Of,ep=Af,tp=`DropdownMenu`,[np,rp]=Pa(tp,[Ad]),ip=Ad(),[ap,op]=np(tp),sp=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=ip(t),l=G.useRef(null),[u,d]=Ra({prop:i,defaultProp:a??!1,onChange:o,caller:tp});return(0,K.jsx)(ap,{scope:t,triggerId:Lo(),triggerRef:l,contentId:Lo(),open:u,onOpenChange:d,onOpenToggle:G.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,K.jsx)(Bf,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};sp.displayName=tp;var cp=`DropdownMenuTrigger`,lp=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=op(cp,n),o=ip(n);return(0,K.jsx)(Vf,{asChild:!0,...o,children:(0,K.jsx)(Ya.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:zr(t,a.triggerRef),onPointerDown:Ma(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:Ma(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});lp.displayName=cp;var up=`DropdownMenuPortal`,dp=e=>{let{__scopeDropdownMenu:t,...n}=e,r=ip(t);return(0,K.jsx)(Hf,{...r,...n})};dp.displayName=up;var fp=`DropdownMenuContent`,pp=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=op(fp,n),a=ip(n),o=G.useRef(!1);return(0,K.jsx)(Uf,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:Ma(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:Ma(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});pp.displayName=fp;var mp=`DropdownMenuGroup`,hp=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ip(n);return(0,K.jsx)(Wf,{...i,...r,ref:t})});hp.displayName=mp;var gp=`DropdownMenuLabel`,_p=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ip(n);return(0,K.jsx)(Gf,{...i,...r,ref:t})});_p.displayName=gp;var vp=`DropdownMenuItem`,yp=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ip(n);return(0,K.jsx)(Kf,{...i,...r,ref:t})});yp.displayName=vp;var bp=`DropdownMenuCheckboxItem`,xp=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ip(n);return(0,K.jsx)(qf,{...i,...r,ref:t})});xp.displayName=bp;var Sp=`DropdownMenuRadioGroup`,Cp=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ip(n);return(0,K.jsx)(Jf,{...i,...r,ref:t})});Cp.displayName=Sp;var wp=`DropdownMenuRadioItem`,Tp=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ip(n);return(0,K.jsx)(Yf,{...i,...r,ref:t})});Tp.displayName=wp;var Ep=`DropdownMenuItemIndicator`,Dp=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ip(n);return(0,K.jsx)(Xf,{...i,...r,ref:t})});Dp.displayName=Ep;var Op=`DropdownMenuSeparator`,kp=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ip(n);return(0,K.jsx)(Zf,{...i,...r,ref:t})});kp.displayName=Op;var Ap=`DropdownMenuArrow`,jp=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ip(n);return(0,K.jsx)(Qf,{...i,...r,ref:t})});jp.displayName=Ap;var Mp=`DropdownMenuSubTrigger`,Np=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ip(n);return(0,K.jsx)($f,{...i,...r,ref:t})});Np.displayName=Mp;var Pp=`DropdownMenuSubContent`,Fp=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ip(n);return(0,K.jsx)(ep,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Fp.displayName=Pp;var Ip=sp,Lp=lp,Rp=dp,zp=pp,Bp=_p,Vp=yp,Hp=xp,Up=Cp,Wp=Tp,Gp=kp,Kp=Np,qp=Fp,Jp=Ip,Yp=Lp,tee=Up;function nee({ref:e,className:t,inset:n,children:r,...i}){return(0,K.jsx)(Kp,{ref:e,className:q(`flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent`,n&&`pl-8`,t),...i,children:r})}nee.displayName=Kp.displayName;function ree({ref:e,className:t,...n}){return(0,K.jsx)(qp,{ref:e,className:q(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,t),...n})}ree.displayName=qp.displayName;function Xp({ref:e,className:t,sideOffset:n=4,...r}){return(0,K.jsx)(Rp,{children:(0,K.jsx)(zp,{ref:e,sideOffset:n,className:q(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md`,`data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,t),...r})})}Xp.displayName=zp.displayName;function Zp({ref:e,className:t,inset:n,...r}){return(0,K.jsx)(Vp,{ref:e,className:q(`relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,n&&`pl-8`,t),...r})}Zp.displayName=Vp.displayName;function iee({ref:e,className:t,children:n,checked:r,...i}){return(0,K.jsx)(Hp,{ref:e,className:q(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,t),checked:r,...i,children:n})}iee.displayName=Hp.displayName;function Qp({ref:e,className:t,children:n,...r}){return(0,K.jsx)(Wp,{ref:e,className:q(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,t),...r,children:n})}Qp.displayName=Wp.displayName;function $p({ref:e,className:t,inset:n,...r}){return(0,K.jsx)(Bp,{ref:e,className:q(`px-2 py-1.5 text-sm font-semibold`,n&&`pl-8`,t),...r})}$p.displayName=Bp.displayName;function em({ref:e,className:t,...n}){return(0,K.jsx)(Gp,{ref:e,className:q(`-mx-1 my-1 h-px bg-muted`,t),...n})}em.displayName=Gp.displayName;function tm({className:e,...t}){return(0,K.jsx)(`span`,{className:q(`ml-auto text-xs tracking-widest opacity-60`,e),...t})}tm.displayName=`DropdownMenuShortcut`;function nm({message:e,className:t=``,vertical:n,noBorder:r}){return(0,K.jsx)(`div`,{className:q(`mt-2 rounded-md p-6 ${t}`,!r&&`border`),children:(0,K.jsxs)(`p`,{className:q(`text-sm text-muted-foreground flex items-center gap-4`,n&&`flex-col`),children:[(0,K.jsx)(`svg`,{width:`40`,height:`40`,viewBox:`0 0 273 273`,version:`1.1`,xmlns:`http://www.w3.org/2000/svg`,className:`flex-shrink-0`,children:(0,K.jsx)(`g`,{stroke:`none`,strokeWidth:`1`,fill:`none`,fillRule:`evenodd`,children:(0,K.jsxs)(`g`,{transform:`translate(5.320900, 5.320900)`,fillRule:`nonzero`,className:`stroke-black dark:stroke-white`,strokeWidth:`4`,children:[(0,K.jsx)(`path`,{d:`M49.953025,-2.10854389 C63.26892,-2.21867124 76.6185256,2.70621155 86.9019463,12.6653164 L86.9019463,12.6653164 L87.505627,13.2592944 C97.5154947,23.2654892 102.640454,36.3074513 102.880738,49.4222247 C103.08932,77.4533067 113.877287,105.391753 135.242867,126.757333 C156.613383,148.127849 184.559216,158.914875 212.568138,159.119313 L212.568138,159.119313 L213.212264,159.134159 C225.843948,159.517566 238.363557,164.434972 248.121998,173.886137 L248.121998,173.886137 L248.725621,174.480088 C258.982114,184.732164 264.11035,198.171134 264.11035,211.6101 C264.11035,225.04592 258.984514,238.481745 248.732867,248.732867 C238.592792,258.872942 225.336706,263.997882 212.046872,264.107794 C198.731075,264.21792 185.381569,259.293085 175.098248,249.334078 L175.098248,249.334078 L174.494602,248.740134 C163.75802,238.008189 158.640853,223.784027 159.143413,209.719372 C158.258245,182.640933 147.489786,155.83332 126.828333,135.171867 C106.351297,114.694831 79.8363505,103.934873 53.0237258,102.891841 L53.0237258,102.891841 L52.2811438,102.865674 C38.4791718,103.347421 24.5325234,98.4328111 13.8776628,88.1140866 L13.8776628,88.1140866 L13.2739843,87.5201168 C3.12895117,77.3789607 -1.9984796,64.1195994 -2.10841888,50.8264755 C-2.21854669,37.5105567 2.70635908,24.1609269 12.6655135,13.8774565 L12.6655135,13.8774565 L13.2594878,13.2737797 C23.4005926,3.12880025 36.659927,-1.99860507 49.953025,-2.10854389 Z`}),(0,K.jsx)(`circle`,{cx:`50`,cy:`212.0001`,r:`52.5`}),(0,K.jsx)(`circle`,{cx:`212.0001`,cy:`50`,r:`52.5`})]})})}),e]})})}function rm(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return Math.abs(t)}function im(e,t=0){let n=Math.sin(e+t)*1e4;return n-Math.floor(n)}function am({className:e,color:t,children:n,grayscaled:r=!1,seed:i}){let a=(0,G.useId)(),o=(0,G.useMemo)(()=>rm(i||a),[i,a]),s=(0,G.useMemo)(()=>{if(t){let e=t.split(`(`)[1].split(`)`)[0].trim().split(/\s+/);return Number.parseFloat(e[1]||`0`)}return r?0:.2},[t,r]),c=(0,G.useMemo)(()=>{if(t){let e=t.split(`(`)[1].split(`)`)[0].trim().split(/\s+/);return Number.parseFloat(e[0]||`0.5`)}return r?.3:.4},[t,r]),l=(0,G.useMemo)(()=>{if(t){let e=t.split(`(`)[1].split(`)`)[0].trim().split(/\s+/);return Number.parseFloat(e[2]||`0`)}return Math.floor(im(o,0)*360)},[t,o]),u=(0,G.useMemo)(()=>t||`oklch(${Math.min(c,1)} ${s} ${l})`,[l,s,c]),d=(0,G.useMemo)(()=>`oklch(${Math.min(c*2,1)} ${s} ${l})`,[l,s,c,t]),f=(0,G.useMemo)(()=>Math.floor(im(o,1)*360),[o]),p=(0,G.useMemo)(()=>`1000%`,[]);return(0,K.jsx)(`section`,{className:q(`relative w-full h-full overflow-hidden`,e),style:{background:`${d}`},children:(0,K.jsxs)(`div`,{className:`isolate relative w-full h-full`,children:[(0,K.jsx)(`div`,{className:`noise w-full h-full`,style:{background:`linear-gradient(${f}deg, ${u}, transparent), url(https://grainy-gradients.vercel.app/noise.svg)`,filter:`contrast(120%) brightness(${p})`}}),n&&(0,K.jsx)(`div`,{className:`relative z-10 w-full h-full`,children:n})]})})}var om=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),sm=`VisuallyHidden`,cm=G.forwardRef((e,t)=>(0,K.jsx)(Ya.span,{...e,ref:t,style:{...om,...e.style}}));cm.displayName=sm;var lm=cm,[um,aee]=Pa(`Tooltip`,[sl]),dm=sl(),fm=`TooltipProvider`,pm=700,mm=`tooltip.open`,[hm,gm]=um(fm),_m=e=>{let{__scopeTooltip:t,delayDuration:n=pm,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=G.useRef(!0),s=G.useRef(!1),c=G.useRef(0);return G.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,K.jsx)(hm,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:G.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:G.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:G.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};_m.displayName=fm;var vm=`Tooltip`,[ym,bm]=um(vm),xm=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=gm(vm,e.__scopeTooltip),l=dm(t),[u,d]=G.useState(null),f=Lo(),p=G.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=G.useRef(!1),[_,v]=Ra({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(mm))):c.onClose(),a?.(e)},caller:vm}),y=G.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=G.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=G.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=G.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return G.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,K.jsx)(Cl,{...l,children:(0,K.jsx)(ym,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:G.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:G.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};xm.displayName=vm;var Sm=`TooltipTrigger`,Cm=G.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=bm(Sm,n),a=gm(Sm,n),o=dm(n),s=Br(t,G.useRef(null),i.onTriggerChange),c=G.useRef(!1),l=G.useRef(!1),u=G.useCallback(()=>c.current=!1,[]);return G.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,K.jsx)(wl,{asChild:!0,...o,children:(0,K.jsx)(Ya.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:Ma(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:Ma(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:Ma(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:Ma(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:Ma(e.onBlur,i.onClose),onClick:Ma(e.onClick,i.onClose)})})});Cm.displayName=Sm;var wm=`TooltipPortal`,[Tm,Em]=um(wm,{forceMount:void 0}),Dm=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=bm(wm,t);return(0,K.jsx)(Tm,{scope:t,forceMount:n,children:(0,K.jsx)(Al,{present:n||a.open,children:(0,K.jsx)(Ol,{asChild:!0,container:i,children:r})})})};Dm.displayName=wm;var Om=`TooltipContent`,km=G.forwardRef((e,t)=>{let n=Em(Om,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=bm(Om,e.__scopeTooltip);return(0,K.jsx)(Al,{present:r||o.open,children:o.disableHoverableContent?(0,K.jsx)(Am,{side:i,...a,ref:t}):(0,K.jsx)(oee,{side:i,...a,ref:t})})}),oee=G.forwardRef((e,t)=>{let n=bm(Om,e.__scopeTooltip),r=gm(Om,e.__scopeTooltip),i=G.useRef(null),a=Br(t,i),[o,s]=G.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=G.useCallback(()=>{s(null),d(!1)},[d]),p=G.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=dee(r,uee(r,n.getBoundingClientRect())),a=fee(t.getBoundingClientRect());s(mee([...i,...a])),d(!0)},[d]);return G.useEffect(()=>()=>f(),[f]),G.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),G.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!pee(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,K.jsx)(Am,{...e,ref:a})}),[see,cee]=um(vm,{isInside:!1}),lee=Ga(`TooltipContent`),Am=G.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=bm(Om,n),l=dm(n),{onClose:u}=c;return G.useEffect(()=>(document.addEventListener(mm,u),()=>document.removeEventListener(mm,u)),[u]),G.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,K.jsx)(co,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,K.jsxs)(Tl,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,K.jsx)(lee,{children:r}),(0,K.jsx)(see,{scope:n,isInside:!0,children:(0,K.jsx)(lm,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});km.displayName=Om;var jm=`TooltipArrow`,Mm=G.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=dm(n);return cee(jm,n).isInside?null:(0,K.jsx)(El,{...i,...r,ref:t})});Mm.displayName=jm;function uee(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function dee(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function fee(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function pee(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function mee(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0),hee(t)}function hee(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var gee=_m,_ee=xm,vee=Cm,yee=Dm,bee=km,xee=Mm;function Nm({delayDuration:e=0,...t}){return(0,K.jsx)(gee,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Pm({...e}){return(0,K.jsx)(Nm,{children:(0,K.jsx)(_ee,{"data-slot":`tooltip`,...e})})}function Fm({...e}){return(0,K.jsx)(vee,{"data-slot":`tooltip-trigger`,...e})}function Im({className:e,sideOffset:t=0,children:n,...r}){return(0,K.jsx)(yee,{children:(0,K.jsxs)(bee,{"data-slot":`tooltip-content`,sideOffset:t,className:q(`bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance`,e),...r,children:[n,(0,K.jsx)(xee,{className:`bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`})]})})}var See=class{name=`mcp_inspector_open`;properties;constructor(e){this.properties={server_url:e.serverUrl,connection_count:e.connectionCount}}},Lm=class{name=`mcp_tool_execution`;properties;constructor(e){this.properties={tool_name:e.toolName,server_id:e.serverId,success:e.success,duration:e.duration,error:e.error}}},Rm=class{name=`mcp_resource_read`;properties;constructor(e){this.properties={resource_uri:e.resourceUri,server_id:e.serverId,success:e.success,error:e.error}}},zm=class{name=`mcp_prompt_call`;properties;constructor(e){this.properties={prompt_name:e.promptName,server_id:e.serverId,success:e.success,error:e.error}}},Bm=class{name=`mcp_chat_message`;properties;constructor(e){this.properties={server_id:e.serverId,provider:e.provider,model:e.model,message_count:e.messageCount,tool_calls_count:e.toolCallsCount,success:e.success,execution_mode:e.executionMode,duration:e.duration,error:e.error}}},Cee=class{name=`mcp_server_added`;properties;constructor(e){this.properties={server_id:e.serverId,server_url:e.serverUrl,connection_type:e.connectionType,via_proxy:e.viaProxy}}},wee=class{name=`mcp_command_palette_open`;properties;constructor(e){this.properties={trigger:e.trigger}}},Tee=class{name=`mcp_tool_saved`;properties;constructor(e){this.properties={tool_name:e.toolName,server_id:e.serverId}}};function Vm(){try{return`0.26.0`}catch{return`0.0.0`}}function Hm(){try{return typeof window<`u`&&typeof document<`u`}catch{return!1}}var Um=class{endpoint;timeout;constructor(e,t=3e3){this.endpoint=e,this.timeout=t}async logEvent(e){try{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout),r=await fetch(this.endpoint,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),signal:t.signal});if(clearTimeout(n),!r.ok)throw Error(`HTTP error! status: ${r.status}`)}catch{}}};function Wm(e){return`mcp_inspector_telemetry_${e}`}function Gm(){return typeof localStorage<`u`&&typeof localStorage.getItem==`function`&&typeof localStorage.setItem==`function`}var Km=class e{static instance=null;POSTHOG_PROXY_URL=`/inspector/api/tel/posthog`;SCARF_PROXY_URL=`/inspector/api/tel/scarf`;UNKNOWN_USER_ID=`UNKNOWN_USER_ID`;_currUserId=null;_posthogClient=null;_scarfClient=null;_source=`inspector`;constructor(){let e=Hm(),t=this.isTelemetryDisabled();if(this._source=this.getStoredSource()||`inspector`,t)this._posthogClient=null,this._scarfClient=null;else if(!e)this._posthogClient=null,this._scarfClient=null;else{try{this._posthogClient=new Um(this.POSTHOG_PROXY_URL,3e3)}catch{this._posthogClient=null}try{this._scarfClient=new Um(this.SCARF_PROXY_URL,3e3)}catch{this._scarfClient=null}}}isTelemetryDisabled(){return!!(Gm()&&localStorage.getItem(Wm(`disabled`))===`true`||typeof process<`u`&&{}?.MCP_USE_ANONYMIZED_TELEMETRY===`false`)}getStoredSource(){return Gm()?localStorage.getItem(Wm(`source`)):null}static getInstance(){return e.instance||=new e,e.instance}setSource(e){this._source=e,Gm()&&localStorage.setItem(Wm(`source`),e)}getSource(){return this._source}get userId(){if(this._currUserId)return this._currUserId;if(!Hm())return this._currUserId=this.UNKNOWN_USER_ID,this._currUserId;try{if(!Gm())throw Error(`localStorage is not available or not functional`);let e=localStorage.getItem(Wm(`user_id`));if(e)this._currUserId=e;else{let e=this.generateUserId();localStorage.setItem(Wm(`user_id`),e),this._currUserId=e}this.trackPackageDownload({triggered_by:`user_id_property`}).catch(()=>{})}catch{this._currUserId=this.UNKNOWN_USER_ID}return this._currUserId}generateUserId(){let e=window.crypto;if(e){let t=new Uint8Array(16);e.getRandomValues(t),t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=Array.from(t).map(e=>e.toString(16).padStart(2,`0`)).join(``);return n.slice(0,8)+`-`+n.slice(8,12)+`-`+n.slice(12,16)+`-`+n.slice(16,20)+`-`+n.slice(20,32)}else return`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}async capture(e){if(!(!this._posthogClient&&!this._scarfClient)){if(this._posthogClient)try{let t={event:e.name,user_id:this.userId,properties:{...e.properties,mcp_use_version:Vm(),language:`typescript`,source:this._source,package:`inspector`}};await this._posthogClient.logEvent(t)}catch{}if(this._scarfClient)try{let t={};t.mcp_use_version=Vm(),t.user_id=this.userId,t.event=e.name,t.language=`typescript`,t.source=this._source,t.package=`inspector`,await this._scarfClient.logEvent(t)}catch{}}}async trackPackageDownload(e){if(this._scarfClient&&Hm())try{if(!Gm())throw Error(`localStorage is not available or not functional`);let t=Vm(),n=!1,r=!1,i=localStorage.getItem(Wm(`download_version`));if(i?t>i&&(n=!0,r=!1,localStorage.setItem(Wm(`download_version`),t)):(n=!0,r=!0,localStorage.setItem(Wm(`download_version`),t)),n){let n={...e||{}};n.mcp_use_version=t,n.user_id=this.userId,n.event=`package_download`,n.first_download=r,n.language=`typescript`,n.source=this._source,n.package=`inspector`,await this._scarfClient.logEvent(n)}}catch{}}async trackInspectorOpen(e){let t=new See(e);await this.capture(t)}},Eee=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),Dee=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),qm=e=>{let t=Dee(e);return t.charAt(0).toUpperCase()+t.slice(1)},Jm=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),Oee=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0},kee={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`},Aee=(0,G.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>(0,G.createElement)(`svg`,{ref:c,...kee,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Jm(`lucide`,i),...!a&&!Oee(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,G.createElement)(e,t)),...Array.isArray(a)?a:[a]])),Ym=(e,t)=>{let n=(0,G.forwardRef)(({className:n,...r},i)=>(0,G.createElement)(Aee,{ref:i,iconNode:t,className:Jm(`lucide-${Eee(qm(e))}`,`lucide-${e}`,n),...r}));return n.displayName=qm(e),n},jee=Ym(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),Mee=Ym(`arrow-up-from-line`,[[`path`,{d:`m18 9-6-6-6 6`,key:`kcunyi`}],[`path`,{d:`M12 3v14`,key:`7cf3v8`}],[`path`,{d:`M5 21h14`,key:`11awu3`}]]),Nee=Ym(`arrow-up-right`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),Pee=Ym(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Xm=Ym(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),Zm=Ym(`braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),Fee=Ym(`brush-cleaning`,[[`path`,{d:`m16 22-1-4`,key:`1ow2iv`}],[`path`,{d:`M19 14a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2h-3a1 1 0 0 1-1-1V4a2 2 0 0 0-4 0v5a1 1 0 0 1-1 1H6a2 2 0 0 0-2 2v1a1 1 0 0 0 1 1`,key:`11gii7`}],[`path`,{d:`M19 14H5l-1.973 6.767A1 1 0 0 0 4 22h16a1 1 0 0 0 .973-1.233z`,key:`bju7h4`}],[`path`,{d:`m8 22 1-4`,key:`s3unb`}]]),Qm=Ym(`brush`,[[`path`,{d:`m11 10 3 3`,key:`fzmg1i`}],[`path`,{d:`M6.5 21A3.5 3.5 0 1 0 3 17.5a2.62 2.62 0 0 1-.708 1.792A1 1 0 0 0 3 21z`,key:`p4q2r7`}],[`path`,{d:`M9.969 17.031 21.378 5.624a1 1 0 0 0-3.002-3.002L6.967 14.031`,key:`wy6l02`}]]),$m=Ym(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),eh=Ym(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),th=Ym(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),nh=Ym(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),rh=Ym(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),ih=Ym(`chevrons-left-right-ellipsis`,[[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`m17 7 5 5-5 5`,key:`1xlxn0`}],[`path`,{d:`m7 7-5 5 5 5`,key:`19njba`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}]]),Iee=Ym(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),ah=Ym(`circle-minus`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}]]),oh=Ym(`clock`,[[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),sh=Ym(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),ch=Ym(`cog`,[[`path`,{d:`M11 10.27 7 3.34`,key:`16pf9h`}],[`path`,{d:`m11 13.73-4 6.93`,key:`794ttg`}],[`path`,{d:`M12 22v-2`,key:`1osdcq`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M14 12h8`,key:`4f43i9`}],[`path`,{d:`m17 20.66-1-1.73`,key:`eq3orb`}],[`path`,{d:`m17 3.34-1 1.73`,key:`2wel8s`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`m20.66 17-1.73-1`,key:`sg0v6f`}],[`path`,{d:`m20.66 7-1.73 1`,key:`1ow05n`}],[`path`,{d:`m3.34 17 1.73-1`,key:`nuk764`}],[`path`,{d:`m3.34 7 1.73 1`,key:`1ulond`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`circle`,{cx:`12`,cy:`12`,r:`8`,key:`46899m`}]]),lh=Ym(`command`,[[`path`,{d:`M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3`,key:`11bfej`}]]),uh=Ym(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),dh=Ym(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),fh=Ym(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),ph=Ym(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),mh=Ym(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),hh=Ym(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),gh=Ym(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),_h=Ym(`file-code`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]),vh=Ym(`file-image`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),yh=Ym(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),bh=Ym(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),xh=Ym(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),Sh=Ym(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),Ch=Ym(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),wh=Ym(`hash`,[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]),Th=Ym(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),Eh=Ym(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),Dh=Ym(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),Oh=Ym(`key`,[[`path`,{d:`m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4`,key:`g0fldk`}],[`path`,{d:`m21 2-9.6 9.6`,key:`1j0ho8`}],[`circle`,{cx:`7.5`,cy:`15.5`,r:`5.5`,key:`yqb3hr`}]]),kh=Ym(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Ah=Ym(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),jh=Ym(`maximize`,[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]),Lee=Ym(`message-circle`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}]]),Mh=Ym(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),Nh=Ym(`minimize`,[[`path`,{d:`M8 3v3a2 2 0 0 1-2 2H3`,key:`hohbtr`}],[`path`,{d:`M21 8h-3a2 2 0 0 1-2-2V3`,key:`5jw1f3`}],[`path`,{d:`M3 16h3a2 2 0 0 1 2 2v3`,key:`198tvr`}],[`path`,{d:`M16 21v-3a2 2 0 0 1 2-2h3`,key:`ph8mxp`}]]),Ph=Ym(`monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),Fh=Ym(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),Ree=Ym(`mouse-pointer-2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),zee=Ym(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),Bee=Ym(`picture-in-picture`,[[`path`,{d:`M2 10h6V4`,key:`zwrco`}],[`path`,{d:`m2 4 6 6`,key:`ug085t`}],[`path`,{d:`M21 10V7a2 2 0 0 0-2-2h-7`,key:`git5jr`}],[`path`,{d:`M3 14v2a2 2 0 0 0 2 2h3`,key:`1f7fh3`}],[`rect`,{x:`12`,y:`14`,width:`10`,height:`7`,rx:`1`,key:`1wjs3o`}]]),Ih=Ym(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),Lh=Ym(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Vee=Ym(`pointer`,[[`path`,{d:`M22 14a8 8 0 0 1-8 8`,key:`56vcr3`}],[`path`,{d:`M18 11v-1a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1agjmk`}],[`path`,{d:`M14 10V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1`,key:`wdbh2u`}],[`path`,{d:`M10 9.5V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v10`,key:`1ibuk9`}],[`path`,{d:`M18 11a2 2 0 1 1 4 0v3a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`g6ys72`}]]),Rh=Ym(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),zh=Ym(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),Bh=Ym(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),Vh=Ym(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),Hee=Ym(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),Hh=Ym(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),Uh=Ym(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Wh=Ym(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Gh=Ym(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),Uee=Ym(`shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),Kh=Ym(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),qh=Ym(`sparkles`,[[`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`}]]),Jh=Ym(`square-check-big`,[[`path`,{d:`M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344`,key:`2acyp4`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),Wee=Ym(`square-dashed-mouse-pointer`,[[`path`,{d:`M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z`,key:`xwnzip`}],[`path`,{d:`M5 3a2 2 0 0 0-2 2`,key:`y57alp`}],[`path`,{d:`M19 3a2 2 0 0 1 2 2`,key:`18rm91`}],[`path`,{d:`M5 21a2 2 0 0 1-2-2`,key:`sbafld`}],[`path`,{d:`M9 3h1`,key:`1yesri`}],[`path`,{d:`M9 21h2`,key:`1qve2z`}],[`path`,{d:`M14 3h1`,key:`1ec4yj`}],[`path`,{d:`M3 9v1`,key:`1r0deq`}],[`path`,{d:`M21 9v2`,key:`p14lih`}],[`path`,{d:`M3 14v1`,key:`vnatye`}]]),Gee=Ym(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),Yh=Ym(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Xh=Ym(`sun-dim`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 4h.01`,key:`1ujb9j`}],[`path`,{d:`M20 12h.01`,key:`1ykeid`}],[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M4 12h.01`,key:`158zrr`}],[`path`,{d:`M17.657 6.343h.01`,key:`31pqzk`}],[`path`,{d:`M17.657 17.657h.01`,key:`jehnf4`}],[`path`,{d:`M6.343 17.657h.01`,key:`gdk6ow`}],[`path`,{d:`M6.343 6.343h.01`,key:`1uurf0`}]]),Zh=Ym(`tablet`,[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]),Qh=Ym(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),$h=Ym(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),Kee=Ym(`trash`,[[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),eg=Ym(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),tg=Ym(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),ng=Ym(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]);async function rg(e){if(navigator.clipboard?.writeText)return navigator.clipboard.writeText(e);let t=document.createElement(`textarea`);if(t.value=e,t.style.cssText=`position:fixed;top:-9999px;left:-9999px;opacity:0`,document.body.appendChild(t),t.focus(),t.select(),!document.execCommand(`copy`))throw Error(`execCommand copy failed`);document.body.removeChild(t)}var ig=`popstate`;function qee(e={}){function t(e,t){let{pathname:n,search:r,hash:i}=e.location;return cg(``,{pathname:n,search:r,hash:i},t.state&&t.state.usr||null,t.state&&t.state.key||`default`)}function n(e,t){return typeof t==`string`?t:lg(t)}return Yee(t,n,null,e)}function ag(e,t){if(e===!1||e==null)throw Error(t)}function og(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function Jee(){return Math.random().toString(36).substring(2,10)}function sg(e,t){return{usr:e.state,key:e.key,idx:t}}function cg(e,t,n=null,r){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?ug(t):t,state:n,key:t&&t.key||r||Jee()}}function lg({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function ug(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function Yee(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=cg(h.location,e,t);n&&n(r,e),l=u()+1;let d=sg(r,l),f=h.createHref(r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=cg(h.location,e,t);n&&n(r,e),l=u();let i=sg(r,l),d=h.createHref(r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return Xee(e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(ig,d),c=e,()=>{i.removeEventListener(ig,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function Xee(e,t=!1){let n=`http://localhost`;typeof window<`u`&&(n=window.location.origin===`null`?window.location.href:window.location.origin),ag(n,`No window.location.(origin|href) available to create URL`);let r=typeof e==`string`?e:lg(e);return r=r.replace(/ $/,`%20`),!t&&r.startsWith(`//`)&&(r=n+r),new URL(r,n)}function dg(e,t,n=`/`){return Zee(e,t,n,!1)}function Zee(e,t,n,r){let i=yg((typeof t==`string`?ug(t):t).pathname||`/`,n);if(i==null)return null;let a=fg(e);$ee(a);let o=null;for(let e=0;o==null&&e<a.length;++e){let t=vg(i);o=hg(a[e],t,r)}return o}function Qee(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function fg(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;ag(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=Dg([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(ag(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),fg(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:ote(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of pg(e.path))a(e,t,!0,n)}),t}function pg(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=pg(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function $ee(e){e.sort((e,t)=>e.score===t.score?ste(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var ete=/^:[\w-]+$/,tte=3,nte=2,rte=1,ite=10,ate=-2,mg=e=>e===`*`;function ote(e,t){let n=e.split(`/`),r=n.length;return n.some(mg)&&(r+=ate),t&&(r+=nte),n.filter(e=>!mg(e)).reduce((e,t)=>e+(ete.test(t)?tte:t===``?rte:ite),r)}function ste(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function hg(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u=gg({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=gg({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:Dg([a,u.pathname]),pathnameBase:Og(Dg([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=Dg([a,u.pathnameBase]))}return o}function gg(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=_g(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function _g(e,t=!1,n=!0){og(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n)=>(r.push({paramName:t,isOptional:n!=null}),n?`/?([^\\/]+)?`:`/([^\\/]+)`)).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function vg(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return og(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function yg(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}var bg=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function xg(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?ug(e):e,a;return n?(n=n.replace(/\/\/+/g,`/`),a=n.startsWith(`/`)?Sg(n.substring(1),`/`):Sg(n,t)):a=t,{pathname:a,search:kg(r),hash:Ag(i)}}function Sg(e,t){let n=t.replace(/\/+$/,``).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function Cg(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function wg(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function Tg(e){let t=wg(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function Eg(e,t,n,r=!1){let i;typeof e==`string`?i=ug(e):(i={...e},ag(!i.pathname||!i.pathname.includes(`?`),Cg(`?`,`pathname`,`search`,i)),ag(!i.pathname||!i.pathname.includes(`#`),Cg(`#`,`pathname`,`hash`,i)),ag(!i.search||!i.search.includes(`#`),Cg(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=xg(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var Dg=e=>e.join(`/`).replace(/\/\/+/g,`/`),Og=e=>e.replace(/\/+$/,``).replace(/^\/*/,`/`),kg=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,Ag=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,jg=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Mg(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function Ng(e){return e.map(e=>e.route.path).filter(Boolean).join(`/`).replace(/\/\/*/g,`/`)||`/`}var Pg=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Fg(e,t){let n=e;if(typeof n!=`string`||!bg.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Pg)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=yg(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{og(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var Ig=G.createContext(null);Ig.displayName=`DataRouter`;var Lg=G.createContext(null);Lg.displayName=`DataRouterState`;var Rg=G.createContext(!1),zg=G.createContext({isTransitioning:!1});zg.displayName=`ViewTransition`;var Bg=G.createContext(new Map);Bg.displayName=`Fetchers`;var Vg=G.createContext(null);Vg.displayName=`Await`;var Hg=G.createContext(null);Hg.displayName=`Navigation`;var Ug=G.createContext(null);Ug.displayName=`Location`;var Wg=G.createContext({outlet:null,matches:[],isDataRoute:!1});Wg.displayName=`Route`;var Gg=G.createContext(null);Gg.displayName=`RouteError`;var Kg=`REACT_ROUTER_ERROR`,qg=`REDIRECT`,Jg=`ROUTE_ERROR_RESPONSE`;function Yg(e){if(e.startsWith(`${Kg}:${qg}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function Xg(e){if(e.startsWith(`${Kg}:${Jg}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new jg(t.status,t.statusText,t.data)}catch{}}function Zg(e,{relative:t}={}){ag(Qg(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=G.useContext(Hg),{hash:i,pathname:a,search:o}=i_(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:Dg([n,a])),r.createHref({pathname:s,search:o,hash:i})}function Qg(){return G.useContext(Ug)!=null}function $g(){return ag(Qg(),`useLocation() may be used only in the context of a <Router> component.`),G.useContext(Ug).location}var e_=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function t_(e){G.useContext(Hg).static||G.useLayoutEffect(e)}function n_(){let{isDataRoute:e}=G.useContext(Wg);return e?C_():r_()}function r_(){ag(Qg(),`useNavigate() may be used only in the context of a <Router> component.`);let e=G.useContext(Ig),{basename:t,navigator:n}=G.useContext(Hg),{matches:r}=G.useContext(Wg),{pathname:i}=$g(),a=JSON.stringify(Tg(r)),o=G.useRef(!1);return t_(()=>{o.current=!0}),G.useCallback((r,s={})=>{if(og(o.current,e_),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=Eg(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:Dg([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}G.createContext(null);function i_(e,{relative:t}={}){let{matches:n}=G.useContext(Wg),{pathname:r}=$g(),i=JSON.stringify(Tg(n));return G.useMemo(()=>Eg(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function a_(e,t){return o_(e,t)}function o_(e,t,n,r,i){ag(Qg(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:a}=G.useContext(Hg),{matches:o}=G.useContext(Wg),s=o[o.length-1],c=s?s.params:{},l=s?s.pathname:`/`,u=s?s.pathnameBase:`/`,d=s&&s.route;{let e=d&&d.path||``;T_(l,!d||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
53
|
+
`},pd=0,md=[];function hd(e){var t=G.useRef([]),n=G.useRef([0,0]),r=G.useRef(),i=G.useState(pd++)[0],a=G.useState(Lu)[0],o=G.useRef(e);G.useEffect(function(){o.current=e},[e]),G.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=fu([e.lockRef.current],(e.shards||[]).map(ud),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=G.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=cd(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=td(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=td(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return sd(h,t,e,h===`h`?s:c,!0)},[]),c=G.useCallback(function(e){var n=e;if(!(!md.length||md[md.length-1]!==a)){var r=`deltaY`in n?ld(n):cd(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&dd(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(ud).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=G.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:gd(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=G.useCallback(function(e){n.current=cd(e),r.current=void 0},[]),d=G.useCallback(function(t){l(t.type,ld(t),t.target,s(t,e.lockRef.current))},[]),f=G.useCallback(function(t){l(t.type,cd(t),t.target,s(t,e.lockRef.current))},[]);G.useEffect(function(){return md.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Xu),document.addEventListener(`touchmove`,c,Xu),document.addEventListener(`touchstart`,u,Xu),function(){md=md.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Xu),document.removeEventListener(`touchmove`,c,Xu),document.removeEventListener(`touchstart`,u,Xu)}},[]);var p=e.removeScrollBar,m=e.inert;return G.createElement(G.Fragment,null,m?G.createElement(a,{styles:fd(i)}):null,p?G.createElement(qu,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function gd(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var _d=Eu(Du,hd),vd=G.forwardRef(function(e,t){return G.createElement(ku,uu({},e,{ref:t,sideCar:_d}))});vd.classNames=ku.classNames;var yd=[`Enter`,` `],bd=[`ArrowDown`,`PageUp`,`Home`],xd=[`ArrowUp`,`PageDown`,`End`],Sd=[...bd,...xd],Cd={ltr:[...yd,`ArrowRight`],rtl:[...yd,`ArrowLeft`]},wd={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},Td=`Menu`,[Ed,Dd,Od]=Za(Td),[kd,Ad]=Pa(Td,[Od,sl,Vl]),jd=sl(),Md=Vl(),[Nd,Pd]=kd(Td),[Fd,Id]=kd(Td),Ld=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=jd(t),[c,l]=G.useState(null),u=G.useRef(!1),d=eo(a),f=$a(i);return G.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),(0,K.jsx)(Cl,{...s,children:(0,K.jsx)(Nd,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,K.jsx)(Fd,{scope:t,onClose:G.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};Ld.displayName=Td;var Rd=`MenuAnchor`,zd=G.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=jd(n);return(0,K.jsx)(wl,{...i,...r,ref:t})});zd.displayName=Rd;var Bd=`MenuPortal`,[Vd,Hd]=kd(Bd,{forceMount:void 0}),Ud=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=Pd(Bd,t);return(0,K.jsx)(Vd,{scope:t,forceMount:n,children:(0,K.jsx)(Al,{present:n||a.open,children:(0,K.jsx)(Ol,{asChild:!0,container:i,children:r})})})};Ud.displayName=Bd;var Wd=`MenuContent`,[Gd,Kd]=kd(Wd),qd=G.forwardRef((e,t)=>{let n=Hd(Wd,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Pd(Wd,e.__scopeMenu),o=Id(Wd,e.__scopeMenu);return(0,K.jsx)(Ed.Provider,{scope:e.__scopeMenu,children:(0,K.jsx)(Al,{present:r||a.open,children:(0,K.jsx)(Ed.Slot,{scope:e.__scopeMenu,children:o.modal?(0,K.jsx)(Jd,{...i,ref:t}):(0,K.jsx)(Yd,{...i,ref:t})})})})}),Jd=G.forwardRef((e,t)=>{let n=Pd(Wd,e.__scopeMenu),r=G.useRef(null),i=Br(t,r);return G.useEffect(()=>{let e=r.current;if(e)return lu(e)},[]),(0,K.jsx)(Zd,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Ma(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Yd=G.forwardRef((e,t)=>{let n=Pd(Wd,e.__scopeMenu);return(0,K.jsx)(Zd,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Xd=Ha(`MenuContent.ScrollLock`),Zd=G.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=Pd(Wd,n),_=Id(Wd,n),v=jd(n),y=Md(n),b=Dd(n),[x,S]=G.useState(null),C=G.useRef(null),w=Br(t,C,g.onContentChange),T=G.useRef(0),E=G.useRef(``),D=G.useRef(0),O=G.useRef(null),k=G.useRef(`right`),A=G.useRef(0),j=m?vd:G.Fragment,M=m?{as:Xd,allowPinchZoom:!0}:void 0,N=e=>{let t=E.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=If(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){E.current=t,window.clearTimeout(T.current),t!==``&&(T.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};G.useEffect(()=>()=>window.clearTimeout(T.current),[]),_o();let P=G.useCallback(e=>k.current===O.current?.side&&Rf(e,O.current?.area),[]);return(0,K.jsx)(Gd,{scope:n,searchRef:E,onItemEnter:G.useCallback(e=>{P(e)&&e.preventDefault()},[P]),onItemLeave:G.useCallback(e=>{P(e)||(C.current?.focus(),S(null))},[P]),onTriggerLeave:G.useCallback(e=>{P(e)&&e.preventDefault()},[P]),pointerGraceTimerRef:D,onPointerGraceIntentChange:G.useCallback(e=>{O.current=e},[]),children:(0,K.jsx)(j,{...M,children:(0,K.jsx)(Co,{asChild:!0,trapped:i,onMountAutoFocus:Ma(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,K.jsx)(co,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,K.jsx)($l,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:Ma(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,K.jsx)(Tl,{role:`menu`,"aria-orientation":`vertical`,"data-state":jf(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:w,style:{outline:`none`,...h.style},onKeyDown:Ma(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&N(e.key));let i=C.current;if(e.target!==i||!Sd.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);xd.includes(e.key)&&a.reverse(),Pf(a)}),onBlur:Ma(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(T.current),E.current=``)}),onPointerMove:Ma(e.onPointerMove,zf(e=>{let t=e.target,n=A.current!==e.clientX;e.currentTarget.contains(t)&&n&&(k.current=e.clientX>A.current?`right`:`left`,A.current=e.clientX)}))})})})})})})});qd.displayName=Wd;var Qd=`MenuGroup`,$d=G.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,K.jsx)(Ya.div,{role:`group`,...r,ref:t})});$d.displayName=Qd;var ef=`MenuLabel`,tf=G.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,K.jsx)(Ya.div,{...r,ref:t})});tf.displayName=ef;var nf=`MenuItem`,rf=`menu.itemSelect`,af=G.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=G.useRef(null),o=Id(nf,e.__scopeMenu),s=Kd(nf,e.__scopeMenu),c=Br(t,a),l=G.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(rf,{bubbles:!0,cancelable:!0});e.addEventListener(rf,e=>r?.(e),{once:!0}),Xa(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,K.jsx)(of,{...i,ref:c,disabled:n,onClick:Ma(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:Ma(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:Ma(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||yd.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});af.displayName=nf;var of=G.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=Kd(nf,n),s=Md(n),c=G.useRef(null),l=Br(t,c),[u,d]=G.useState(!1),[f,p]=G.useState(``);return G.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,K.jsx)(Ed.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,K.jsx)(eu,{asChild:!0,...s,focusable:!r,children:(0,K.jsx)(Ya.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:Ma(e.onPointerMove,zf(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ma(e.onPointerLeave,zf(e=>o.onItemLeave(e))),onFocus:Ma(e.onFocus,()=>d(!0)),onBlur:Ma(e.onBlur,()=>d(!1))})})})}),sf=`MenuCheckboxItem`,cf=G.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,K.jsx)(gf,{scope:e.__scopeMenu,checked:n,children:(0,K.jsx)(af,{role:`menuitemcheckbox`,"aria-checked":Mf(n)?`mixed`:n,...i,ref:t,"data-state":Nf(n),onSelect:Ma(i.onSelect,()=>r?.(Mf(n)?!0:!n),{checkForDefaultPrevented:!1})})})});cf.displayName=sf;var lf=`MenuRadioGroup`,[uf,df]=kd(lf,{value:void 0,onValueChange:()=>{}}),ff=G.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=eo(r);return(0,K.jsx)(uf,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,K.jsx)($d,{...i,ref:t})})});ff.displayName=lf;var pf=`MenuRadioItem`,mf=G.forwardRef((e,t)=>{let{value:n,...r}=e,i=df(pf,e.__scopeMenu),a=n===i.value;return(0,K.jsx)(gf,{scope:e.__scopeMenu,checked:a,children:(0,K.jsx)(af,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":Nf(a),onSelect:Ma(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});mf.displayName=pf;var hf=`MenuItemIndicator`,[gf,_f]=kd(hf,{checked:!1}),vf=G.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=_f(hf,n);return(0,K.jsx)(Al,{present:r||Mf(a.checked)||a.checked===!0,children:(0,K.jsx)(Ya.span,{...i,ref:t,"data-state":Nf(a.checked)})})});vf.displayName=hf;var yf=`MenuSeparator`,bf=G.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,K.jsx)(Ya.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});bf.displayName=yf;var xf=`MenuArrow`,Sf=G.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=jd(n);return(0,K.jsx)(El,{...i,...r,ref:t})});Sf.displayName=xf;var Cf=`MenuSub`,[wf,Tf]=kd(Cf),Ef=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=Pd(Cf,t),o=jd(t),[s,c]=G.useState(null),[l,u]=G.useState(null),d=eo(i);return G.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,K.jsx)(Cl,{...o,children:(0,K.jsx)(Nd,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,K.jsx)(wf,{scope:t,contentId:Lo(),triggerId:Lo(),trigger:s,onTriggerChange:c,children:n})})})};Ef.displayName=Cf;var Df=`MenuSubTrigger`,Of=G.forwardRef((e,t)=>{let n=Pd(Df,e.__scopeMenu),r=Id(Df,e.__scopeMenu),i=Tf(Df,e.__scopeMenu),a=Kd(Df,e.__scopeMenu),o=G.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=G.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return G.useEffect(()=>u,[u]),G.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]),(0,K.jsx)(zd,{asChild:!0,...l,children:(0,K.jsx)(of,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":jf(n.open),...e,ref:zr(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Ma(e.onPointerMove,zf(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:Ma(e.onPointerLeave,zf(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:Ma(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||Cd[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});Of.displayName=Df;var kf=`MenuSubContent`,Af=G.forwardRef((e,t)=>{let n=Hd(Wd,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Pd(Wd,e.__scopeMenu),o=Id(Wd,e.__scopeMenu),s=Tf(kf,e.__scopeMenu),c=G.useRef(null),l=Br(t,c);return(0,K.jsx)(Ed.Provider,{scope:e.__scopeMenu,children:(0,K.jsx)(Al,{present:r||a.open,children:(0,K.jsx)(Ed.Slot,{scope:e.__scopeMenu,children:(0,K.jsx)(Zd,{id:s.contentId,"aria-labelledby":s.triggerId,...i,ref:l,align:`start`,side:o.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{o.isUsingKeyboardRef.current&&c.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:Ma(e.onFocusOutside,e=>{e.target!==s.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:Ma(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:Ma(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=wd[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});Af.displayName=kf;function jf(e){return e?`open`:`closed`}function Mf(e){return e===`indeterminate`}function Nf(e){return Mf(e)?`indeterminate`:e?`checked`:`unchecked`}function Pf(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Ff(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function If(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Ff(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function Lf(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function Rf(e,t){return t?Lf({x:e.clientX,y:e.clientY},t):!1}function zf(e){return t=>t.pointerType===`mouse`?e(t):void 0}var Bf=Ld,Vf=zd,Hf=Ud,Uf=qd,Wf=$d,Gf=tf,Kf=af,qf=cf,Jf=ff,Yf=mf,Xf=vf,Zf=bf,Qf=Sf,$f=Of,ep=Af,tp=`DropdownMenu`,[np,rp]=Pa(tp,[Ad]),ip=Ad(),[ap,op]=np(tp),sp=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=ip(t),l=G.useRef(null),[u,d]=Ra({prop:i,defaultProp:a??!1,onChange:o,caller:tp});return(0,K.jsx)(ap,{scope:t,triggerId:Lo(),triggerRef:l,contentId:Lo(),open:u,onOpenChange:d,onOpenToggle:G.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,K.jsx)(Bf,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};sp.displayName=tp;var cp=`DropdownMenuTrigger`,lp=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=op(cp,n),o=ip(n);return(0,K.jsx)(Vf,{asChild:!0,...o,children:(0,K.jsx)(Ya.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:zr(t,a.triggerRef),onPointerDown:Ma(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:Ma(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});lp.displayName=cp;var up=`DropdownMenuPortal`,dp=e=>{let{__scopeDropdownMenu:t,...n}=e,r=ip(t);return(0,K.jsx)(Hf,{...r,...n})};dp.displayName=up;var fp=`DropdownMenuContent`,pp=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=op(fp,n),a=ip(n),o=G.useRef(!1);return(0,K.jsx)(Uf,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:Ma(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:Ma(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});pp.displayName=fp;var mp=`DropdownMenuGroup`,hp=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ip(n);return(0,K.jsx)(Wf,{...i,...r,ref:t})});hp.displayName=mp;var gp=`DropdownMenuLabel`,_p=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ip(n);return(0,K.jsx)(Gf,{...i,...r,ref:t})});_p.displayName=gp;var vp=`DropdownMenuItem`,yp=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ip(n);return(0,K.jsx)(Kf,{...i,...r,ref:t})});yp.displayName=vp;var bp=`DropdownMenuCheckboxItem`,xp=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ip(n);return(0,K.jsx)(qf,{...i,...r,ref:t})});xp.displayName=bp;var Sp=`DropdownMenuRadioGroup`,Cp=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ip(n);return(0,K.jsx)(Jf,{...i,...r,ref:t})});Cp.displayName=Sp;var wp=`DropdownMenuRadioItem`,Tp=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ip(n);return(0,K.jsx)(Yf,{...i,...r,ref:t})});Tp.displayName=wp;var Ep=`DropdownMenuItemIndicator`,Dp=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ip(n);return(0,K.jsx)(Xf,{...i,...r,ref:t})});Dp.displayName=Ep;var Op=`DropdownMenuSeparator`,kp=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ip(n);return(0,K.jsx)(Zf,{...i,...r,ref:t})});kp.displayName=Op;var Ap=`DropdownMenuArrow`,jp=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ip(n);return(0,K.jsx)(Qf,{...i,...r,ref:t})});jp.displayName=Ap;var Mp=`DropdownMenuSubTrigger`,Np=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ip(n);return(0,K.jsx)($f,{...i,...r,ref:t})});Np.displayName=Mp;var Pp=`DropdownMenuSubContent`,Fp=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ip(n);return(0,K.jsx)(ep,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Fp.displayName=Pp;var Ip=sp,Lp=lp,Rp=dp,zp=pp,Bp=_p,Vp=yp,Hp=xp,Up=Cp,Wp=Tp,Gp=kp,Kp=Np,qp=Fp,Jp=Ip,Yp=Lp,tee=Up;function nee({ref:e,className:t,inset:n,children:r,...i}){return(0,K.jsx)(Kp,{ref:e,className:q(`flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent`,n&&`pl-8`,t),...i,children:r})}nee.displayName=Kp.displayName;function ree({ref:e,className:t,...n}){return(0,K.jsx)(qp,{ref:e,className:q(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,t),...n})}ree.displayName=qp.displayName;function Xp({ref:e,className:t,sideOffset:n=4,...r}){return(0,K.jsx)(Rp,{children:(0,K.jsx)(zp,{ref:e,sideOffset:n,className:q(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md`,`data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,t),...r})})}Xp.displayName=zp.displayName;function Zp({ref:e,className:t,inset:n,...r}){return(0,K.jsx)(Vp,{ref:e,className:q(`relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,n&&`pl-8`,t),...r})}Zp.displayName=Vp.displayName;function iee({ref:e,className:t,children:n,checked:r,...i}){return(0,K.jsx)(Hp,{ref:e,className:q(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,t),checked:r,...i,children:n})}iee.displayName=Hp.displayName;function Qp({ref:e,className:t,children:n,...r}){return(0,K.jsx)(Wp,{ref:e,className:q(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,t),...r,children:n})}Qp.displayName=Wp.displayName;function $p({ref:e,className:t,inset:n,...r}){return(0,K.jsx)(Bp,{ref:e,className:q(`px-2 py-1.5 text-sm font-semibold`,n&&`pl-8`,t),...r})}$p.displayName=Bp.displayName;function em({ref:e,className:t,...n}){return(0,K.jsx)(Gp,{ref:e,className:q(`-mx-1 my-1 h-px bg-muted`,t),...n})}em.displayName=Gp.displayName;function tm({className:e,...t}){return(0,K.jsx)(`span`,{className:q(`ml-auto text-xs tracking-widest opacity-60`,e),...t})}tm.displayName=`DropdownMenuShortcut`;function nm({message:e,className:t=``,vertical:n,noBorder:r}){return(0,K.jsx)(`div`,{className:q(`mt-2 rounded-md p-6 ${t}`,!r&&`border`),children:(0,K.jsxs)(`p`,{className:q(`text-sm text-muted-foreground flex items-center gap-4`,n&&`flex-col`),children:[(0,K.jsx)(`svg`,{width:`40`,height:`40`,viewBox:`0 0 273 273`,version:`1.1`,xmlns:`http://www.w3.org/2000/svg`,className:`flex-shrink-0`,children:(0,K.jsx)(`g`,{stroke:`none`,strokeWidth:`1`,fill:`none`,fillRule:`evenodd`,children:(0,K.jsxs)(`g`,{transform:`translate(5.320900, 5.320900)`,fillRule:`nonzero`,className:`stroke-black dark:stroke-white`,strokeWidth:`4`,children:[(0,K.jsx)(`path`,{d:`M49.953025,-2.10854389 C63.26892,-2.21867124 76.6185256,2.70621155 86.9019463,12.6653164 L86.9019463,12.6653164 L87.505627,13.2592944 C97.5154947,23.2654892 102.640454,36.3074513 102.880738,49.4222247 C103.08932,77.4533067 113.877287,105.391753 135.242867,126.757333 C156.613383,148.127849 184.559216,158.914875 212.568138,159.119313 L212.568138,159.119313 L213.212264,159.134159 C225.843948,159.517566 238.363557,164.434972 248.121998,173.886137 L248.121998,173.886137 L248.725621,174.480088 C258.982114,184.732164 264.11035,198.171134 264.11035,211.6101 C264.11035,225.04592 258.984514,238.481745 248.732867,248.732867 C238.592792,258.872942 225.336706,263.997882 212.046872,264.107794 C198.731075,264.21792 185.381569,259.293085 175.098248,249.334078 L175.098248,249.334078 L174.494602,248.740134 C163.75802,238.008189 158.640853,223.784027 159.143413,209.719372 C158.258245,182.640933 147.489786,155.83332 126.828333,135.171867 C106.351297,114.694831 79.8363505,103.934873 53.0237258,102.891841 L53.0237258,102.891841 L52.2811438,102.865674 C38.4791718,103.347421 24.5325234,98.4328111 13.8776628,88.1140866 L13.8776628,88.1140866 L13.2739843,87.5201168 C3.12895117,77.3789607 -1.9984796,64.1195994 -2.10841888,50.8264755 C-2.21854669,37.5105567 2.70635908,24.1609269 12.6655135,13.8774565 L12.6655135,13.8774565 L13.2594878,13.2737797 C23.4005926,3.12880025 36.659927,-1.99860507 49.953025,-2.10854389 Z`}),(0,K.jsx)(`circle`,{cx:`50`,cy:`212.0001`,r:`52.5`}),(0,K.jsx)(`circle`,{cx:`212.0001`,cy:`50`,r:`52.5`})]})})}),e]})})}function rm(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return Math.abs(t)}function im(e,t=0){let n=Math.sin(e+t)*1e4;return n-Math.floor(n)}function am({className:e,color:t,children:n,grayscaled:r=!1,seed:i}){let a=(0,G.useId)(),o=(0,G.useMemo)(()=>rm(i||a),[i,a]),s=(0,G.useMemo)(()=>{if(t){let e=t.split(`(`)[1].split(`)`)[0].trim().split(/\s+/);return Number.parseFloat(e[1]||`0`)}return r?0:.2},[t,r]),c=(0,G.useMemo)(()=>{if(t){let e=t.split(`(`)[1].split(`)`)[0].trim().split(/\s+/);return Number.parseFloat(e[0]||`0.5`)}return r?.3:.4},[t,r]),l=(0,G.useMemo)(()=>{if(t){let e=t.split(`(`)[1].split(`)`)[0].trim().split(/\s+/);return Number.parseFloat(e[2]||`0`)}return Math.floor(im(o,0)*360)},[t,o]),u=(0,G.useMemo)(()=>t||`oklch(${Math.min(c,1)} ${s} ${l})`,[l,s,c]),d=(0,G.useMemo)(()=>`oklch(${Math.min(c*2,1)} ${s} ${l})`,[l,s,c,t]),f=(0,G.useMemo)(()=>Math.floor(im(o,1)*360),[o]),p=(0,G.useMemo)(()=>`1000%`,[]);return(0,K.jsx)(`section`,{className:q(`relative w-full h-full overflow-hidden`,e),style:{background:`${d}`},children:(0,K.jsxs)(`div`,{className:`isolate relative w-full h-full`,children:[(0,K.jsx)(`div`,{className:`noise w-full h-full`,style:{background:`linear-gradient(${f}deg, ${u}, transparent), url(https://grainy-gradients.vercel.app/noise.svg)`,filter:`contrast(120%) brightness(${p})`}}),n&&(0,K.jsx)(`div`,{className:`relative z-10 w-full h-full`,children:n})]})})}var om=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),sm=`VisuallyHidden`,cm=G.forwardRef((e,t)=>(0,K.jsx)(Ya.span,{...e,ref:t,style:{...om,...e.style}}));cm.displayName=sm;var lm=cm,[um,aee]=Pa(`Tooltip`,[sl]),dm=sl(),fm=`TooltipProvider`,pm=700,mm=`tooltip.open`,[hm,gm]=um(fm),_m=e=>{let{__scopeTooltip:t,delayDuration:n=pm,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=G.useRef(!0),s=G.useRef(!1),c=G.useRef(0);return G.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,K.jsx)(hm,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:G.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:G.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:G.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};_m.displayName=fm;var vm=`Tooltip`,[ym,bm]=um(vm),xm=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=gm(vm,e.__scopeTooltip),l=dm(t),[u,d]=G.useState(null),f=Lo(),p=G.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=G.useRef(!1),[_,v]=Ra({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(mm))):c.onClose(),a?.(e)},caller:vm}),y=G.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=G.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=G.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=G.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return G.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,K.jsx)(Cl,{...l,children:(0,K.jsx)(ym,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:G.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:G.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};xm.displayName=vm;var Sm=`TooltipTrigger`,Cm=G.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=bm(Sm,n),a=gm(Sm,n),o=dm(n),s=Br(t,G.useRef(null),i.onTriggerChange),c=G.useRef(!1),l=G.useRef(!1),u=G.useCallback(()=>c.current=!1,[]);return G.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,K.jsx)(wl,{asChild:!0,...o,children:(0,K.jsx)(Ya.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:Ma(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:Ma(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:Ma(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:Ma(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:Ma(e.onBlur,i.onClose),onClick:Ma(e.onClick,i.onClose)})})});Cm.displayName=Sm;var wm=`TooltipPortal`,[Tm,Em]=um(wm,{forceMount:void 0}),Dm=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=bm(wm,t);return(0,K.jsx)(Tm,{scope:t,forceMount:n,children:(0,K.jsx)(Al,{present:n||a.open,children:(0,K.jsx)(Ol,{asChild:!0,container:i,children:r})})})};Dm.displayName=wm;var Om=`TooltipContent`,km=G.forwardRef((e,t)=>{let n=Em(Om,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=bm(Om,e.__scopeTooltip);return(0,K.jsx)(Al,{present:r||o.open,children:o.disableHoverableContent?(0,K.jsx)(Am,{side:i,...a,ref:t}):(0,K.jsx)(oee,{side:i,...a,ref:t})})}),oee=G.forwardRef((e,t)=>{let n=bm(Om,e.__scopeTooltip),r=gm(Om,e.__scopeTooltip),i=G.useRef(null),a=Br(t,i),[o,s]=G.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=G.useCallback(()=>{s(null),d(!1)},[d]),p=G.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=dee(r,uee(r,n.getBoundingClientRect())),a=fee(t.getBoundingClientRect());s(mee([...i,...a])),d(!0)},[d]);return G.useEffect(()=>()=>f(),[f]),G.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),G.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!pee(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,K.jsx)(Am,{...e,ref:a})}),[see,cee]=um(vm,{isInside:!1}),lee=Ga(`TooltipContent`),Am=G.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=bm(Om,n),l=dm(n),{onClose:u}=c;return G.useEffect(()=>(document.addEventListener(mm,u),()=>document.removeEventListener(mm,u)),[u]),G.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,K.jsx)(co,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,K.jsxs)(Tl,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,K.jsx)(lee,{children:r}),(0,K.jsx)(see,{scope:n,isInside:!0,children:(0,K.jsx)(lm,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});km.displayName=Om;var jm=`TooltipArrow`,Mm=G.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=dm(n);return cee(jm,n).isInside?null:(0,K.jsx)(El,{...i,...r,ref:t})});Mm.displayName=jm;function uee(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function dee(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function fee(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function pee(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function mee(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0),hee(t)}function hee(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var gee=_m,_ee=xm,vee=Cm,yee=Dm,bee=km,xee=Mm;function Nm({delayDuration:e=0,...t}){return(0,K.jsx)(gee,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Pm({...e}){return(0,K.jsx)(Nm,{children:(0,K.jsx)(_ee,{"data-slot":`tooltip`,...e})})}function Fm({...e}){return(0,K.jsx)(vee,{"data-slot":`tooltip-trigger`,...e})}function Im({className:e,sideOffset:t=0,children:n,...r}){return(0,K.jsx)(yee,{children:(0,K.jsxs)(bee,{"data-slot":`tooltip-content`,sideOffset:t,className:q(`bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance`,e),...r,children:[n,(0,K.jsx)(xee,{className:`bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`})]})})}var See=class{name=`mcp_inspector_open`;properties;constructor(e){this.properties={server_url:e.serverUrl,connection_count:e.connectionCount}}},Lm=class{name=`mcp_tool_execution`;properties;constructor(e){this.properties={tool_name:e.toolName,server_id:e.serverId,success:e.success,duration:e.duration,error:e.error}}},Rm=class{name=`mcp_resource_read`;properties;constructor(e){this.properties={resource_uri:e.resourceUri,server_id:e.serverId,success:e.success,error:e.error}}},zm=class{name=`mcp_prompt_call`;properties;constructor(e){this.properties={prompt_name:e.promptName,server_id:e.serverId,success:e.success,error:e.error}}},Bm=class{name=`mcp_chat_message`;properties;constructor(e){this.properties={server_id:e.serverId,provider:e.provider,model:e.model,message_count:e.messageCount,tool_calls_count:e.toolCallsCount,success:e.success,execution_mode:e.executionMode,duration:e.duration,error:e.error}}},Cee=class{name=`mcp_server_added`;properties;constructor(e){this.properties={server_id:e.serverId,server_url:e.serverUrl,connection_type:e.connectionType,via_proxy:e.viaProxy}}},wee=class{name=`mcp_command_palette_open`;properties;constructor(e){this.properties={trigger:e.trigger}}},Tee=class{name=`mcp_tool_saved`;properties;constructor(e){this.properties={tool_name:e.toolName,server_id:e.serverId}}};function Vm(){try{return`0.26.1`}catch{return`0.0.0`}}function Hm(){try{return typeof window<`u`&&typeof document<`u`}catch{return!1}}var Um=class{endpoint;timeout;constructor(e,t=3e3){this.endpoint=e,this.timeout=t}async logEvent(e){try{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout),r=await fetch(this.endpoint,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),signal:t.signal});if(clearTimeout(n),!r.ok)throw Error(`HTTP error! status: ${r.status}`)}catch{}}};function Wm(e){return`mcp_inspector_telemetry_${e}`}function Gm(){return typeof localStorage<`u`&&typeof localStorage.getItem==`function`&&typeof localStorage.setItem==`function`}var Km=class e{static instance=null;POSTHOG_PROXY_URL=`/inspector/api/tel/posthog`;SCARF_PROXY_URL=`/inspector/api/tel/scarf`;UNKNOWN_USER_ID=`UNKNOWN_USER_ID`;_currUserId=null;_posthogClient=null;_scarfClient=null;_source=`inspector`;constructor(){let e=Hm(),t=this.isTelemetryDisabled();if(this._source=this.getStoredSource()||`inspector`,t)this._posthogClient=null,this._scarfClient=null;else if(!e)this._posthogClient=null,this._scarfClient=null;else{try{this._posthogClient=new Um(this.POSTHOG_PROXY_URL,3e3)}catch{this._posthogClient=null}try{this._scarfClient=new Um(this.SCARF_PROXY_URL,3e3)}catch{this._scarfClient=null}}}isTelemetryDisabled(){return!!(Gm()&&localStorage.getItem(Wm(`disabled`))===`true`||typeof process<`u`&&{}?.MCP_USE_ANONYMIZED_TELEMETRY===`false`)}getStoredSource(){return Gm()?localStorage.getItem(Wm(`source`)):null}static getInstance(){return e.instance||=new e,e.instance}setSource(e){this._source=e,Gm()&&localStorage.setItem(Wm(`source`),e)}getSource(){return this._source}get userId(){if(this._currUserId)return this._currUserId;if(!Hm())return this._currUserId=this.UNKNOWN_USER_ID,this._currUserId;try{if(!Gm())throw Error(`localStorage is not available or not functional`);let e=localStorage.getItem(Wm(`user_id`));if(e)this._currUserId=e;else{let e=this.generateUserId();localStorage.setItem(Wm(`user_id`),e),this._currUserId=e}this.trackPackageDownload({triggered_by:`user_id_property`}).catch(()=>{})}catch{this._currUserId=this.UNKNOWN_USER_ID}return this._currUserId}generateUserId(){let e=window.crypto;if(e){let t=new Uint8Array(16);e.getRandomValues(t),t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=Array.from(t).map(e=>e.toString(16).padStart(2,`0`)).join(``);return n.slice(0,8)+`-`+n.slice(8,12)+`-`+n.slice(12,16)+`-`+n.slice(16,20)+`-`+n.slice(20,32)}else return`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}async capture(e){if(!(!this._posthogClient&&!this._scarfClient)){if(this._posthogClient)try{let t={event:e.name,user_id:this.userId,properties:{...e.properties,mcp_use_version:Vm(),language:`typescript`,source:this._source,package:`inspector`}};await this._posthogClient.logEvent(t)}catch{}if(this._scarfClient)try{let t={};t.mcp_use_version=Vm(),t.user_id=this.userId,t.event=e.name,t.language=`typescript`,t.source=this._source,t.package=`inspector`,await this._scarfClient.logEvent(t)}catch{}}}async trackPackageDownload(e){if(this._scarfClient&&Hm())try{if(!Gm())throw Error(`localStorage is not available or not functional`);let t=Vm(),n=!1,r=!1,i=localStorage.getItem(Wm(`download_version`));if(i?t>i&&(n=!0,r=!1,localStorage.setItem(Wm(`download_version`),t)):(n=!0,r=!0,localStorage.setItem(Wm(`download_version`),t)),n){let n={...e||{}};n.mcp_use_version=t,n.user_id=this.userId,n.event=`package_download`,n.first_download=r,n.language=`typescript`,n.source=this._source,n.package=`inspector`,await this._scarfClient.logEvent(n)}}catch{}}async trackInspectorOpen(e){let t=new See(e);await this.capture(t)}},Eee=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),Dee=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),qm=e=>{let t=Dee(e);return t.charAt(0).toUpperCase()+t.slice(1)},Jm=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),Oee=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0},kee={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`},Aee=(0,G.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>(0,G.createElement)(`svg`,{ref:c,...kee,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Jm(`lucide`,i),...!a&&!Oee(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,G.createElement)(e,t)),...Array.isArray(a)?a:[a]])),Ym=(e,t)=>{let n=(0,G.forwardRef)(({className:n,...r},i)=>(0,G.createElement)(Aee,{ref:i,iconNode:t,className:Jm(`lucide-${Eee(qm(e))}`,`lucide-${e}`,n),...r}));return n.displayName=qm(e),n},jee=Ym(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),Mee=Ym(`arrow-up-from-line`,[[`path`,{d:`m18 9-6-6-6 6`,key:`kcunyi`}],[`path`,{d:`M12 3v14`,key:`7cf3v8`}],[`path`,{d:`M5 21h14`,key:`11awu3`}]]),Nee=Ym(`arrow-up-right`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),Pee=Ym(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Xm=Ym(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),Zm=Ym(`braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),Fee=Ym(`brush-cleaning`,[[`path`,{d:`m16 22-1-4`,key:`1ow2iv`}],[`path`,{d:`M19 14a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2h-3a1 1 0 0 1-1-1V4a2 2 0 0 0-4 0v5a1 1 0 0 1-1 1H6a2 2 0 0 0-2 2v1a1 1 0 0 0 1 1`,key:`11gii7`}],[`path`,{d:`M19 14H5l-1.973 6.767A1 1 0 0 0 4 22h16a1 1 0 0 0 .973-1.233z`,key:`bju7h4`}],[`path`,{d:`m8 22 1-4`,key:`s3unb`}]]),Qm=Ym(`brush`,[[`path`,{d:`m11 10 3 3`,key:`fzmg1i`}],[`path`,{d:`M6.5 21A3.5 3.5 0 1 0 3 17.5a2.62 2.62 0 0 1-.708 1.792A1 1 0 0 0 3 21z`,key:`p4q2r7`}],[`path`,{d:`M9.969 17.031 21.378 5.624a1 1 0 0 0-3.002-3.002L6.967 14.031`,key:`wy6l02`}]]),$m=Ym(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),eh=Ym(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),th=Ym(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),nh=Ym(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),rh=Ym(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),ih=Ym(`chevrons-left-right-ellipsis`,[[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`m17 7 5 5-5 5`,key:`1xlxn0`}],[`path`,{d:`m7 7-5 5 5 5`,key:`19njba`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}]]),Iee=Ym(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),ah=Ym(`circle-minus`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}]]),oh=Ym(`clock`,[[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),sh=Ym(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),ch=Ym(`cog`,[[`path`,{d:`M11 10.27 7 3.34`,key:`16pf9h`}],[`path`,{d:`m11 13.73-4 6.93`,key:`794ttg`}],[`path`,{d:`M12 22v-2`,key:`1osdcq`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M14 12h8`,key:`4f43i9`}],[`path`,{d:`m17 20.66-1-1.73`,key:`eq3orb`}],[`path`,{d:`m17 3.34-1 1.73`,key:`2wel8s`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`m20.66 17-1.73-1`,key:`sg0v6f`}],[`path`,{d:`m20.66 7-1.73 1`,key:`1ow05n`}],[`path`,{d:`m3.34 17 1.73-1`,key:`nuk764`}],[`path`,{d:`m3.34 7 1.73 1`,key:`1ulond`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`circle`,{cx:`12`,cy:`12`,r:`8`,key:`46899m`}]]),lh=Ym(`command`,[[`path`,{d:`M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3`,key:`11bfej`}]]),uh=Ym(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),dh=Ym(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),fh=Ym(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),ph=Ym(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),mh=Ym(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),hh=Ym(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),gh=Ym(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),_h=Ym(`file-code`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]),vh=Ym(`file-image`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),yh=Ym(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),bh=Ym(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),xh=Ym(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),Sh=Ym(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),Ch=Ym(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),wh=Ym(`hash`,[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]),Th=Ym(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),Eh=Ym(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),Dh=Ym(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),Oh=Ym(`key`,[[`path`,{d:`m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4`,key:`g0fldk`}],[`path`,{d:`m21 2-9.6 9.6`,key:`1j0ho8`}],[`circle`,{cx:`7.5`,cy:`15.5`,r:`5.5`,key:`yqb3hr`}]]),kh=Ym(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Ah=Ym(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),jh=Ym(`maximize`,[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]),Lee=Ym(`message-circle`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}]]),Mh=Ym(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),Nh=Ym(`minimize`,[[`path`,{d:`M8 3v3a2 2 0 0 1-2 2H3`,key:`hohbtr`}],[`path`,{d:`M21 8h-3a2 2 0 0 1-2-2V3`,key:`5jw1f3`}],[`path`,{d:`M3 16h3a2 2 0 0 1 2 2v3`,key:`198tvr`}],[`path`,{d:`M16 21v-3a2 2 0 0 1 2-2h3`,key:`ph8mxp`}]]),Ph=Ym(`monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),Fh=Ym(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),Ree=Ym(`mouse-pointer-2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),zee=Ym(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),Bee=Ym(`picture-in-picture`,[[`path`,{d:`M2 10h6V4`,key:`zwrco`}],[`path`,{d:`m2 4 6 6`,key:`ug085t`}],[`path`,{d:`M21 10V7a2 2 0 0 0-2-2h-7`,key:`git5jr`}],[`path`,{d:`M3 14v2a2 2 0 0 0 2 2h3`,key:`1f7fh3`}],[`rect`,{x:`12`,y:`14`,width:`10`,height:`7`,rx:`1`,key:`1wjs3o`}]]),Ih=Ym(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),Lh=Ym(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Vee=Ym(`pointer`,[[`path`,{d:`M22 14a8 8 0 0 1-8 8`,key:`56vcr3`}],[`path`,{d:`M18 11v-1a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1agjmk`}],[`path`,{d:`M14 10V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1`,key:`wdbh2u`}],[`path`,{d:`M10 9.5V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v10`,key:`1ibuk9`}],[`path`,{d:`M18 11a2 2 0 1 1 4 0v3a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`g6ys72`}]]),Rh=Ym(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),zh=Ym(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),Bh=Ym(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),Vh=Ym(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),Hee=Ym(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),Hh=Ym(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),Uh=Ym(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Wh=Ym(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Gh=Ym(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),Uee=Ym(`shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),Kh=Ym(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),qh=Ym(`sparkles`,[[`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`}]]),Jh=Ym(`square-check-big`,[[`path`,{d:`M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344`,key:`2acyp4`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),Wee=Ym(`square-dashed-mouse-pointer`,[[`path`,{d:`M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z`,key:`xwnzip`}],[`path`,{d:`M5 3a2 2 0 0 0-2 2`,key:`y57alp`}],[`path`,{d:`M19 3a2 2 0 0 1 2 2`,key:`18rm91`}],[`path`,{d:`M5 21a2 2 0 0 1-2-2`,key:`sbafld`}],[`path`,{d:`M9 3h1`,key:`1yesri`}],[`path`,{d:`M9 21h2`,key:`1qve2z`}],[`path`,{d:`M14 3h1`,key:`1ec4yj`}],[`path`,{d:`M3 9v1`,key:`1r0deq`}],[`path`,{d:`M21 9v2`,key:`p14lih`}],[`path`,{d:`M3 14v1`,key:`vnatye`}]]),Gee=Ym(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),Yh=Ym(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Xh=Ym(`sun-dim`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 4h.01`,key:`1ujb9j`}],[`path`,{d:`M20 12h.01`,key:`1ykeid`}],[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M4 12h.01`,key:`158zrr`}],[`path`,{d:`M17.657 6.343h.01`,key:`31pqzk`}],[`path`,{d:`M17.657 17.657h.01`,key:`jehnf4`}],[`path`,{d:`M6.343 17.657h.01`,key:`gdk6ow`}],[`path`,{d:`M6.343 6.343h.01`,key:`1uurf0`}]]),Zh=Ym(`tablet`,[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]),Qh=Ym(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),$h=Ym(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),Kee=Ym(`trash`,[[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),eg=Ym(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),tg=Ym(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),ng=Ym(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]);async function rg(e){if(navigator.clipboard?.writeText)return navigator.clipboard.writeText(e);let t=document.createElement(`textarea`);if(t.value=e,t.style.cssText=`position:fixed;top:-9999px;left:-9999px;opacity:0`,document.body.appendChild(t),t.focus(),t.select(),!document.execCommand(`copy`))throw Error(`execCommand copy failed`);document.body.removeChild(t)}var ig=`popstate`;function qee(e={}){function t(e,t){let{pathname:n,search:r,hash:i}=e.location;return cg(``,{pathname:n,search:r,hash:i},t.state&&t.state.usr||null,t.state&&t.state.key||`default`)}function n(e,t){return typeof t==`string`?t:lg(t)}return Yee(t,n,null,e)}function ag(e,t){if(e===!1||e==null)throw Error(t)}function og(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function Jee(){return Math.random().toString(36).substring(2,10)}function sg(e,t){return{usr:e.state,key:e.key,idx:t}}function cg(e,t,n=null,r){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?ug(t):t,state:n,key:t&&t.key||r||Jee()}}function lg({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function ug(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function Yee(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=cg(h.location,e,t);n&&n(r,e),l=u()+1;let d=sg(r,l),f=h.createHref(r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=cg(h.location,e,t);n&&n(r,e),l=u();let i=sg(r,l),d=h.createHref(r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return Xee(e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(ig,d),c=e,()=>{i.removeEventListener(ig,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function Xee(e,t=!1){let n=`http://localhost`;typeof window<`u`&&(n=window.location.origin===`null`?window.location.href:window.location.origin),ag(n,`No window.location.(origin|href) available to create URL`);let r=typeof e==`string`?e:lg(e);return r=r.replace(/ $/,`%20`),!t&&r.startsWith(`//`)&&(r=n+r),new URL(r,n)}function dg(e,t,n=`/`){return Zee(e,t,n,!1)}function Zee(e,t,n,r){let i=yg((typeof t==`string`?ug(t):t).pathname||`/`,n);if(i==null)return null;let a=fg(e);$ee(a);let o=null;for(let e=0;o==null&&e<a.length;++e){let t=vg(i);o=hg(a[e],t,r)}return o}function Qee(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function fg(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;ag(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=Dg([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(ag(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),fg(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:ote(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of pg(e.path))a(e,t,!0,n)}),t}function pg(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=pg(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function $ee(e){e.sort((e,t)=>e.score===t.score?ste(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var ete=/^:[\w-]+$/,tte=3,nte=2,rte=1,ite=10,ate=-2,mg=e=>e===`*`;function ote(e,t){let n=e.split(`/`),r=n.length;return n.some(mg)&&(r+=ate),t&&(r+=nte),n.filter(e=>!mg(e)).reduce((e,t)=>e+(ete.test(t)?tte:t===``?rte:ite),r)}function ste(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function hg(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u=gg({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=gg({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:Dg([a,u.pathname]),pathnameBase:Og(Dg([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=Dg([a,u.pathnameBase]))}return o}function gg(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=_g(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function _g(e,t=!1,n=!0){og(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n)=>(r.push({paramName:t,isOptional:n!=null}),n?`/?([^\\/]+)?`:`/([^\\/]+)`)).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function vg(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return og(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function yg(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}var bg=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function xg(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?ug(e):e,a;return n?(n=n.replace(/\/\/+/g,`/`),a=n.startsWith(`/`)?Sg(n.substring(1),`/`):Sg(n,t)):a=t,{pathname:a,search:kg(r),hash:Ag(i)}}function Sg(e,t){let n=t.replace(/\/+$/,``).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function Cg(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function wg(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function Tg(e){let t=wg(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function Eg(e,t,n,r=!1){let i;typeof e==`string`?i=ug(e):(i={...e},ag(!i.pathname||!i.pathname.includes(`?`),Cg(`?`,`pathname`,`search`,i)),ag(!i.pathname||!i.pathname.includes(`#`),Cg(`#`,`pathname`,`hash`,i)),ag(!i.search||!i.search.includes(`#`),Cg(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=xg(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var Dg=e=>e.join(`/`).replace(/\/\/+/g,`/`),Og=e=>e.replace(/\/+$/,``).replace(/^\/*/,`/`),kg=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,Ag=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,jg=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Mg(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function Ng(e){return e.map(e=>e.route.path).filter(Boolean).join(`/`).replace(/\/\/*/g,`/`)||`/`}var Pg=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Fg(e,t){let n=e;if(typeof n!=`string`||!bg.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Pg)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=yg(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{og(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var Ig=G.createContext(null);Ig.displayName=`DataRouter`;var Lg=G.createContext(null);Lg.displayName=`DataRouterState`;var Rg=G.createContext(!1),zg=G.createContext({isTransitioning:!1});zg.displayName=`ViewTransition`;var Bg=G.createContext(new Map);Bg.displayName=`Fetchers`;var Vg=G.createContext(null);Vg.displayName=`Await`;var Hg=G.createContext(null);Hg.displayName=`Navigation`;var Ug=G.createContext(null);Ug.displayName=`Location`;var Wg=G.createContext({outlet:null,matches:[],isDataRoute:!1});Wg.displayName=`Route`;var Gg=G.createContext(null);Gg.displayName=`RouteError`;var Kg=`REACT_ROUTER_ERROR`,qg=`REDIRECT`,Jg=`ROUTE_ERROR_RESPONSE`;function Yg(e){if(e.startsWith(`${Kg}:${qg}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function Xg(e){if(e.startsWith(`${Kg}:${Jg}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new jg(t.status,t.statusText,t.data)}catch{}}function Zg(e,{relative:t}={}){ag(Qg(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=G.useContext(Hg),{hash:i,pathname:a,search:o}=i_(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:Dg([n,a])),r.createHref({pathname:s,search:o,hash:i})}function Qg(){return G.useContext(Ug)!=null}function $g(){return ag(Qg(),`useLocation() may be used only in the context of a <Router> component.`),G.useContext(Ug).location}var e_=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function t_(e){G.useContext(Hg).static||G.useLayoutEffect(e)}function n_(){let{isDataRoute:e}=G.useContext(Wg);return e?C_():r_()}function r_(){ag(Qg(),`useNavigate() may be used only in the context of a <Router> component.`);let e=G.useContext(Ig),{basename:t,navigator:n}=G.useContext(Hg),{matches:r}=G.useContext(Wg),{pathname:i}=$g(),a=JSON.stringify(Tg(r)),o=G.useRef(!1);return t_(()=>{o.current=!0}),G.useCallback((r,s={})=>{if(og(o.current,e_),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=Eg(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:Dg([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}G.createContext(null);function i_(e,{relative:t}={}){let{matches:n}=G.useContext(Wg),{pathname:r}=$g(),i=JSON.stringify(Tg(n));return G.useMemo(()=>Eg(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function a_(e,t){return o_(e,t)}function o_(e,t,n,r,i){ag(Qg(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:a}=G.useContext(Hg),{matches:o}=G.useContext(Wg),s=o[o.length-1],c=s?s.params:{},l=s?s.pathname:`/`,u=s?s.pathnameBase:`/`,d=s&&s.route;{let e=d&&d.path||``;T_(l,!d||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
54
54
|
|
|
55
55
|
Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let f=$g(),p;if(t){let e=typeof t==`string`?ug(t):t;ag(u===`/`||e.pathname?.startsWith(u),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${u}" but pathname "${e.pathname}" was given in the \`location\` prop.`),p=e}else p=f;let m=p.pathname||`/`,h=m;if(u!==`/`){let e=u.replace(/^\//,``).split(`/`);h=`/`+m.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let g=dg(e,{pathname:h});og(d||g!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),og(g==null||g[g.length-1].route.element!==void 0||g[g.length-1].route.Component!==void 0||g[g.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let _=p_(g&&g.map(e=>Object.assign({},e,{params:Object.assign({},c,e.params),pathname:Dg([u,a.encodeLocation?a.encodeLocation(e.pathname.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?u:Dg([u,a.encodeLocation?a.encodeLocation(e.pathnameBase.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),o,n,r,i);return t&&_?G.createElement(Ug.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,...p},navigationType:`POP`}},_):_}function s_(){let e=S_(),t=Mg(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r=`rgba(200,200,200, 0.5)`,i={padding:`0.5rem`,backgroundColor:r},a={padding:`2px 4px`,backgroundColor:r},o=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),o=G.createElement(G.Fragment,null,G.createElement(`p`,null,`💿 Hey developer 👋`),G.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,G.createElement(`code`,{style:a},`ErrorBoundary`),` or`,` `,G.createElement(`code`,{style:a},`errorElement`),` prop on your route.`)),G.createElement(G.Fragment,null,G.createElement(`h2`,null,`Unexpected Application Error!`),G.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?G.createElement(`pre`,{style:i},n):null,o)}var c_=G.createElement(s_,null),l_=class extends G.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error(`React Router caught the following error during render`,e)}render(){let e=this.state.error;if(this.context&&typeof e==`object`&&e&&`digest`in e&&typeof e.digest==`string`){let t=Xg(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:G.createElement(Wg.Provider,{value:this.props.routeContext},G.createElement(Gg.Provider,{value:e,children:this.props.component}));return this.context?G.createElement(d_,{error:e},t):t}};l_.contextType=Rg;var u_=new WeakMap;function d_({children:e,error:t}){let{basename:n}=G.useContext(Hg);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=Yg(t.digest);if(e){let r=u_.get(t);if(r)throw r;let i=Fg(e.location,n);if(Pg&&!u_.get(t))if(i.isExternal||e.reloadDocument)window.location.href=i.absoluteURL||i.to;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:e.replace}));throw u_.set(t,n),n}return G.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${i.absoluteURL||i.to}`})}}return e}function f_({routeContext:e,match:t,children:n}){let r=G.useContext(Ig);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),G.createElement(Wg.Provider,{value:e},n)}function p_(e,t=[],n=null,r=null,i=null){if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let a=e,o=n?.errors;if(o!=null){let e=a.findIndex(e=>e.route.id&&o?.[e.route.id]!==void 0);ag(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(`,`)}`),a=a.slice(0,Math.min(a.length,e+1))}let s=!1,c=-1;if(n)for(let e=0;e<a.length;e++){let t=a[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(c=e),t.route.id){let{loaderData:e,errors:r}=n,i=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!r||r[t.route.id]===void 0);if(t.route.lazy||i){s=!0,a=c>=0?a.slice(0,c+1):[a[0]];break}}}let l=n&&r?(e,t)=>{r(e,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:Ng(n.matches),errorInfo:t})}:void 0;return a.reduceRight((e,r,i)=>{let u,d=!1,f=null,p=null;n&&(u=o&&r.route.id?o[r.route.id]:void 0,f=r.route.errorElement||c_,s&&(c<0&&i===0?(T_(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),d=!0,p=null):c===i&&(d=!0,p=r.route.hydrateFallbackElement||null)));let m=t.concat(a.slice(0,i+1)),h=()=>{let t;return t=u?f:d?p:r.route.Component?G.createElement(r.route.Component,null):r.route.element?r.route.element:e,G.createElement(f_,{match:r,routeContext:{outlet:e,matches:m,isDataRoute:n!=null},children:t})};return n&&(r.route.ErrorBoundary||r.route.errorElement||i===0)?G.createElement(l_,{location:n.location,revalidation:n.revalidation,component:f,error:u,children:h(),routeContext:{outlet:null,matches:m,isDataRoute:!0},onError:l}):h()},null)}function m_(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function h_(e){let t=G.useContext(Ig);return ag(t,m_(e)),t}function g_(e){let t=G.useContext(Lg);return ag(t,m_(e)),t}function __(e){let t=G.useContext(Wg);return ag(t,m_(e)),t}function v_(e){let t=__(e),n=t.matches[t.matches.length-1];return ag(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function y_(){return v_(`useRouteId`)}function b_(){return g_(`useNavigation`).navigation}function x_(){let{matches:e,loaderData:t}=g_(`useMatches`);return G.useMemo(()=>e.map(e=>Qee(e,t)),[e,t])}function S_(){let e=G.useContext(Gg),t=g_(`useRouteError`),n=v_(`useRouteError`);return e===void 0?t.errors?.[n]:e}function C_(){let{router:e}=h_(`useNavigate`),t=v_(`useNavigate`),n=G.useRef(!1);return t_(()=>{n.current=!0}),G.useCallback(async(r,i={})=>{og(n.current,e_),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var w_={};function T_(e,t,n){!t&&!w_[e]&&(w_[e]=!0,og(!1,n))}G.useOptimistic,G.memo(E_);function E_({routes:e,future:t,state:n,onError:r}){return o_(e,void 0,n,r,t)}function D_(e){ag(!1,`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`)}function O_({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,unstable_useTransitions:o}){ag(!Qg(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let s=e.replace(/^\/*/,`/`),c=G.useMemo(()=>({basename:s,navigator:i,static:a,unstable_useTransitions:o,future:{}}),[s,i,a,o]);typeof n==`string`&&(n=ug(n));let{pathname:l=`/`,search:u=``,hash:d=``,state:f=null,key:p=`default`}=n,m=G.useMemo(()=>{let e=yg(l,s);return e==null?null:{location:{pathname:e,search:u,hash:d,state:f,key:p},navigationType:r}},[s,l,u,d,f,p,r]);return og(m!=null,`<Router basename="${s}"> is not able to match the URL "${l}${u}${d}" because it does not start with the basename, so the <Router> won't render anything.`),m==null?null:G.createElement(Hg.Provider,{value:c},G.createElement(Ug.Provider,{children:t,value:m}))}function k_({children:e,location:t}){return a_(A_(e),t)}function A_(e,t=[]){let n=[];return G.Children.forEach(e,(e,r)=>{if(!G.isValidElement(e))return;let i=[...t,r];if(e.type===G.Fragment){n.push.apply(n,A_(e.props.children,i));return}ag(e.type===D_,`[${typeof e.type==`string`?e.type:e.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),ag(!e.props.index||!e.props.children,`An index route cannot have child routes.`);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.hasErrorBoundary===!0||e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=A_(e.props.children,i)),n.push(a)}),n}var j_=`get`,M_=`application/x-www-form-urlencoded`;function N_(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function P_(e){return N_(e)&&e.tagName.toLowerCase()===`button`}function F_(e){return N_(e)&&e.tagName.toLowerCase()===`form`}function I_(e){return N_(e)&&e.tagName.toLowerCase()===`input`}function L_(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function R_(e,t){return e.button===0&&(!t||t===`_self`)&&!L_(e)}var z_=null;function B_(){if(z_===null)try{new FormData(document.createElement(`form`),0),z_=!1}catch{z_=!0}return z_}var V_=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function H_(e){return e!=null&&!V_.has(e)?(og(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${M_}"`),null):e}function U_(e,t){let n,r,i,a,o;if(F_(e)){let o=e.getAttribute(`action`);r=o?yg(o,t):null,n=e.getAttribute(`method`)||j_,i=H_(e.getAttribute(`enctype`))||M_,a=new FormData(e)}else if(P_(e)||I_(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a <button> or <input type="submit"> without a <form>`);let s=e.getAttribute(`formaction`)||o.getAttribute(`action`);if(r=s?yg(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||j_,i=H_(e.getAttribute(`formenctype`))||H_(o.getAttribute(`enctype`))||M_,a=new FormData(o,e),!B_()){let{name:t,type:n,value:r}=e;if(n===`image`){let e=t?`${t}.`:``;a.append(`${e}x`,`0`),a.append(`${e}y`,`0`)}else t&&a.append(t,r)}}else if(N_(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=j_,r=null,i=M_,o=e;return a&&i===`text/plain`&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var W_={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},G_=/[&><\u2028\u2029]/g;function K_(e){return e.replace(G_,e=>W_[e])}function q_(e,t){if(e===!1||e==null)throw Error(t)}function J_(e,t,n,r){let i=typeof e==`string`?new URL(e,typeof window>`u`?`server://singlefetch/`:window.location.origin):e;return n?i.pathname.endsWith(`/`)?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname===`/`?i.pathname=`_root.${r}`:t&&yg(i.pathname,t)===`/`?i.pathname=`${t.replace(/\/$/,``)}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,``)}.${r}`,i}async function Y_(e,t){if(e.id in t)return t[e.id];try{let n=await B(()=>import(e.module),[]);return t[e.id]=n,n}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function X_(e){return e!=null&&typeof e.page==`string`}function Z_(e){return e==null?!1:e.href==null?e.rel===`preload`&&typeof e.imageSrcSet==`string`&&typeof e.imageSizes==`string`:typeof e.rel==`string`&&typeof e.href==`string`}async function Q_(e,t,n){return rv((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await Y_(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(Z_).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function $_(e,t,n,r,i,a){let o=(e,t)=>n[t]?e.route.id!==n[t].route.id:!0,s=(e,t)=>n[t].pathname!==e.pathname||n[t].route.path?.endsWith(`*`)&&n[t].params[`*`]!==e.params[`*`];return a===`assets`?t.filter((e,t)=>o(e,t)||s(e,t)):a===`data`?t.filter((t,a)=>{let c=r.routes[t.route.id];if(!c||!c.hasLoader)return!1;if(o(t,a)||s(t,a))return!0;if(t.route.shouldRevalidate){let r=t.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if(typeof r==`boolean`)return r}return!0}):[]}function ev(e,t,{includeHydrateFallback:n}={}){return tv(e.map(e=>{let r=t.routes[e.route.id];if(!r)return[];let i=[r.module];return r.clientActionModule&&(i=i.concat(r.clientActionModule)),r.clientLoaderModule&&(i=i.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(i=i.concat(r.hydrateFallbackModule)),r.imports&&(i=i.concat(r.imports)),i}).flat(1))}function tv(e){return[...new Set(e)]}function nv(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function rv(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!X_(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(nv(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function iv(){let e=G.useContext(Ig);return q_(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function av(){let e=G.useContext(Lg);return q_(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var ov=G.createContext(void 0);ov.displayName=`FrameworkContext`;function sv(){let e=G.useContext(ov);return q_(e,`You must render this element inside a <HydratedRouter> element`),e}function cv(e,t){let n=G.useContext(ov),[r,i]=G.useState(!1),[a,o]=G.useState(!1),{onFocus:s,onBlur:c,onMouseEnter:l,onMouseLeave:u,onTouchStart:d}=t,f=G.useRef(null);G.useEffect(()=>{if(e===`render`&&o(!0),e===`viewport`){let e=new IntersectionObserver(e=>{e.forEach(e=>{o(e.isIntersecting)})},{threshold:.5});return f.current&&e.observe(f.current),()=>{e.disconnect()}}},[e]),G.useEffect(()=>{if(r){let e=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(e)}}},[r]);let p=()=>{i(!0)},m=()=>{i(!1),o(!1)};return n?e===`intent`?[a,f,{onFocus:lv(s,p),onBlur:lv(c,m),onMouseEnter:lv(l,p),onMouseLeave:lv(u,m),onTouchStart:lv(d,p)}]:[a,f,{}]:[!1,f,{}]}function lv(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function uv({page:e,...t}){let{router:n}=iv(),r=G.useMemo(()=>dg(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?G.createElement(cte,{page:e,matches:r,...t}):null}function dv(e){let{manifest:t,routeModules:n}=sv(),[r,i]=G.useState([]);return G.useEffect(()=>{let r=!1;return Q_(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function cte({page:e,matches:t,...n}){let r=$g(),{future:i,manifest:a,routeModules:o}=sv(),{basename:s}=iv(),{loaderData:c,matches:l}=av(),u=G.useMemo(()=>$_(e,t,l,a,r,`data`),[e,t,l,a,r]),d=G.useMemo(()=>$_(e,t,l,a,r,`assets`),[e,t,l,a,r]),f=G.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=new Set,l=!1;if(t.forEach(e=>{let t=a.routes[e.route.id];!t||!t.hasLoader||(!u.some(t=>t.route.id===e.route.id)&&e.route.id in c&&o[e.route.id]?.shouldRevalidate||t.hasClientLoader?l=!0:n.add(e.route.id))}),n.size===0)return[];let d=J_(e,s,i.unstable_trailingSlashAwareDataRequests,`data`);return l&&n.size>0&&d.searchParams.set(`_routes`,t.filter(e=>n.has(e.route.id)).map(e=>e.route.id).join(`,`)),[d.pathname+d.search]},[s,i.unstable_trailingSlashAwareDataRequests,c,r,a,u,t,e,o]),p=G.useMemo(()=>ev(d,a),[d,a]),m=dv(d);return G.createElement(G.Fragment,null,f.map(e=>G.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),p.map(e=>G.createElement(`link`,{key:e,rel:`modulepreload`,href:e,...n})),m.map(({key:e,link:t})=>G.createElement(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function lte(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}var ute=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{ute&&(window.__reactRouterVersion=`7.13.0`)}catch{}function dte({basename:e,children:t,unstable_useTransitions:n,window:r}){let i=G.useRef();i.current??=qee({window:r,v5Compat:!0});let a=i.current,[o,s]=G.useState({action:a.action,location:a.location}),c=G.useCallback(e=>{n===!1?s(e):G.startTransition(()=>s(e))},[n]);return G.useLayoutEffect(()=>a.listen(c),[a,c]),G.createElement(O_,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:a,unstable_useTransitions:n})}function fte({basename:e,children:t,history:n,unstable_useTransitions:r}){let[i,a]=G.useState({action:n.action,location:n.location}),o=G.useCallback(e=>{r===!1?a(e):G.startTransition(()=>a(e))},[r]);return G.useLayoutEffect(()=>n.listen(o),[n,o]),G.createElement(O_,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:n,unstable_useTransitions:r})}fte.displayName=`unstable_HistoryRouter`;var fv=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,pv=G.forwardRef(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:r,reloadDocument:i,replace:a,state:o,target:s,to:c,preventScrollReset:l,viewTransition:u,unstable_defaultShouldRevalidate:d,...f},p){let{basename:m,unstable_useTransitions:h}=G.useContext(Hg),g=typeof c==`string`&&fv.test(c),_=Fg(c,m);c=_.to;let v=Zg(c,{relative:r}),[y,b,x]=cv(n,f),S=_te(c,{replace:a,state:o,target:s,preventScrollReset:l,relative:r,viewTransition:u,unstable_defaultShouldRevalidate:d,unstable_useTransitions:h});function C(t){e&&e(t),t.defaultPrevented||S(t)}let w=G.createElement(`a`,{...f,...x,href:_.absoluteURL||v,onClick:_.isExternal||i?e:C,ref:lte(p,b),target:s,"data-discover":!g&&t===`render`?`true`:void 0});return y&&!g?G.createElement(G.Fragment,null,w,G.createElement(uv,{page:v})):w});pv.displayName=`Link`;var pte=G.forwardRef(function({"aria-current":e=`page`,caseSensitive:t=!1,className:n=``,end:r=!1,style:i,to:a,viewTransition:o,children:s,...c},l){let u=i_(a,{relative:c.relative}),d=$g(),f=G.useContext(Lg),{navigator:p,basename:m}=G.useContext(Hg),h=f!=null&&wte(u)&&o===!0,g=p.encodeLocation?p.encodeLocation(u).pathname:u.pathname,_=d.pathname,v=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;t||(_=_.toLowerCase(),v=v?v.toLowerCase():null,g=g.toLowerCase()),v&&m&&(v=yg(v,m)||v);let y=g!==`/`&&g.endsWith(`/`)?g.length-1:g.length,b=_===g||!r&&_.startsWith(g)&&_.charAt(y)===`/`,x=v!=null&&(v===g||!r&&v.startsWith(g)&&v.charAt(g.length)===`/`),S={isActive:b,isPending:x,isTransitioning:h},C=b?e:void 0,w;w=typeof n==`function`?n(S):[n,b?`active`:null,x?`pending`:null,h?`transitioning`:null].filter(Boolean).join(` `);let T=typeof i==`function`?i(S):i;return G.createElement(pv,{...c,"aria-current":C,className:w,ref:l,style:T,to:a,viewTransition:o},typeof s==`function`?s(S):s)});pte.displayName=`NavLink`;var mte=G.forwardRef(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:a,method:o=j_,action:s,onSubmit:c,relative:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f,...p},m)=>{let{unstable_useTransitions:h}=G.useContext(Hg),g=bte(),_=xte(s,{relative:l}),v=o.toLowerCase()===`get`?`get`:`post`,y=typeof s==`string`&&fv.test(s);return G.createElement(`form`,{ref:m,method:v,action:_,onSubmit:r?c:e=>{if(c&&c(e),e.defaultPrevented)return;e.preventDefault();let r=e.nativeEvent.submitter,s=r?.getAttribute(`formmethod`)||o,p=()=>g(r||e.currentTarget,{fetcherKey:t,method:s,navigate:n,replace:i,state:a,relative:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f});h&&n!==!1?G.startTransition(()=>p()):p()},...p,"data-discover":!y&&e===`render`?`true`:void 0})});mte.displayName=`Form`;function hte({getKey:e,storageKey:t,...n}){let r=G.useContext(ov),{basename:i}=G.useContext(Hg),a=$g(),o=x_();Ste({getKey:e,storageKey:t});let s=G.useMemo(()=>{if(!r||!e)return null;let t=vv(a,o,i,e);return t===a.key?null:t},[]);if(!r||r.isSpaMode)return null;let c=((e,t)=>{if(!window.history.state||!window.history.state.key){let e=Math.random().toString(32).slice(2);window.history.replaceState({key:e},``)}try{let n=JSON.parse(sessionStorage.getItem(e)||`{}`)[t||window.history.state.key];typeof n==`number`&&window.scrollTo(0,n)}catch(t){console.error(t),sessionStorage.removeItem(e)}}).toString();return G.createElement(`script`,{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${c})(${K_(JSON.stringify(t||gv))}, ${K_(JSON.stringify(s))})`}})}hte.displayName=`ScrollRestoration`;function mv(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function hv(e){let t=G.useContext(Ig);return ag(t,mv(e)),t}function gte(e){let t=G.useContext(Lg);return ag(t,mv(e)),t}function _te(e,{target:t,replace:n,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:s,unstable_useTransitions:c}={}){let l=n_(),u=$g(),d=i_(e,{relative:a});return G.useCallback(f=>{if(R_(f,t)){f.preventDefault();let t=n===void 0?lg(u)===lg(d):n,p=()=>l(e,{replace:t,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:s});c?G.startTransition(()=>p()):p()}},[u,l,d,n,r,t,e,i,a,o,s,c])}var vte=0,yte=()=>`__${String(++vte)}__`;function bte(){let{router:e}=hv(`useSubmit`),{basename:t}=G.useContext(Hg),n=y_(),r=e.fetch,i=e.navigate;return G.useCallback(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=U_(e,t);a.navigate===!1?await r(a.fetcherKey||yte(),n,a.action||o,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,flushSync:a.flushSync}):await i(a.action||o,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[r,i,t,n])}function xte(e,{relative:t}={}){let{basename:n}=G.useContext(Hg),r=G.useContext(Wg);ag(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...i_(e||`.`,{relative:t})},o=$g();if(e==null){a.search=o.search;let e=new URLSearchParams(a.search),t=e.getAll(`index`);if(t.some(e=>e===``)){e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();a.search=n?`?${n}`:``}}return(!e||e===`.`)&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,`?index&`):`?index`),n!==`/`&&(a.pathname=a.pathname===`/`?n:Dg([n,a.pathname])),lg(a)}var gv=`react-router-scroll-positions`,_v={};function vv(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:yg(e.pathname,n)||e.pathname},t)),i??=e.key,i}function Ste({getKey:e,storageKey:t}={}){let{router:n}=hv(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=gte(`useScrollRestoration`),{basename:a}=G.useContext(Hg),o=$g(),s=x_(),c=b_();G.useEffect(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),Cte(G.useCallback(()=>{if(c.state===`idle`){let t=vv(o,s,a,e);_v[t]=window.scrollY}try{sessionStorage.setItem(t||gv,JSON.stringify(_v))}catch(e){og(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${e}).`)}window.history.scrollRestoration=`auto`},[c.state,e,a,o,s,t])),typeof document<`u`&&(G.useLayoutEffect(()=>{try{let e=sessionStorage.getItem(t||gv);e&&(_v=JSON.parse(e))}catch{}},[t]),G.useLayoutEffect(()=>{let t=n?.enableScrollRestoration(_v,()=>window.scrollY,e?(t,n)=>vv(t,n,a,e):void 0);return()=>t&&t()},[n,a,e]),G.useLayoutEffect(()=>{if(r!==!1){if(typeof r==`number`){window.scrollTo(0,r);return}try{if(o.hash){let e=document.getElementById(decodeURIComponent(o.hash.slice(1)));if(e){e.scrollIntoView();return}}}catch{og(!1,`"${o.hash.slice(1)}" is not a decodable element ID. The view will not scroll to it.`)}i!==!0&&window.scrollTo(0,0)}},[o,r,i]))}function Cte(e,t){let{capture:n}=t||{};G.useEffect(()=>{let t=n==null?void 0:{capture:n};return window.addEventListener(`pagehide`,e,t),()=>{window.removeEventListener(`pagehide`,e,t)}},[e,n])}function wte(e,{relative:t}={}){let n=G.useContext(zg);ag(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=hv(`useViewTransitionState`),i=i_(e,{relative:t});if(!n.isTransitioning)return!1;let a=yg(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=yg(n.nextLocation.pathname,r)||n.nextLocation.pathname;return gg(i.pathname,o)!=null||gg(i.pathname,a)!=null}function Tte(e){if(!e||typeof document>`u`)return;let t=document.head||document.getElementsByTagName(`head`)[0],n=document.createElement(`style`);n.type=`text/css`,t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}var Ete=e=>{switch(e){case`success`:return kte;case`info`:return jte;case`warning`:return Ate;case`error`:return Mte;default:return null}},Dte=Array(12).fill(0),Ote=({visible:e,className:t})=>G.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},G.createElement(`div`,{className:`sonner-spinner`},Dte.map((e,t)=>G.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),kte=G.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},G.createElement(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,clipRule:`evenodd`})),Ate=G.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`},G.createElement(`path`,{fillRule:`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,clipRule:`evenodd`})),jte=G.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},G.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,clipRule:`evenodd`})),Mte=G.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},G.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,clipRule:`evenodd`})),Nte=G.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`},G.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),G.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),Pte=()=>{let[e,t]=G.useState(document.hidden);return G.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>window.removeEventListener(`visibilitychange`,e)},[]),e},yv=1,bv=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{let{message:t,...n}=e,r=typeof e?.id==`number`||e.id?.length>0?e.id:yv++,i=this.toasts.find(e=>e.id===r),a=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(r)&&this.dismissedToasts.delete(r),i?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:a,title:t}):n):this.addToast({title:t,...n,dismissible:a,id:r}),r},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:`error`}),this.success=(e,t)=>this.create({...t,type:`success`,message:e}),this.info=(e,t)=>this.create({...t,type:`info`,message:e}),this.warning=(e,t)=>this.create({...t,type:`warning`,message:e}),this.loading=(e,t)=>this.create({...t,type:`loading`,message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:t.loading,description:typeof t.description==`function`?void 0:t.description}));let r=Promise.resolve(e instanceof Function?e():e),i=n!==void 0,a,o=r.then(async e=>{if(a=[`resolve`,e],G.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if(Ite(e)&&!e.ok){i=!1;let r=typeof t.error==`function`?await t.error(`HTTP error! status: ${e.status}`):t.error,a=typeof t.description==`function`?await t.description(`HTTP error! status: ${e.status}`):t.description,o=typeof r==`object`&&!G.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(e instanceof Error){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!G.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(t.success!==void 0){i=!1;let r=typeof t.success==`function`?await t.success(e):t.success,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!G.isValidElement(r)?r:{message:r};this.create({id:n,type:`success`,description:a,...o})}}).catch(async e=>{if(a=[`reject`,e],t.error!==void 0){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!G.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),t.finally==null||t.finally.call(t)}),s=()=>new Promise((e,t)=>o.then(()=>a[0]===`reject`?t(a[1]):e(a[1])).catch(t));return typeof n!=`string`&&typeof n!=`number`?{unwrap:s}:Object.assign(n,{unwrap:s})},this.custom=(e,t)=>{let n=t?.id||yv++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Fte=(e,t)=>{let n=t?.id||yv++;return bv.addToast({title:e,...t,id:n}),n},Ite=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,Lte=Fte,xv=Object.assign(Lte,{success:bv.success,info:bv.info,warning:bv.warning,error:bv.error,custom:bv.custom,message:bv.message,promise:bv.promise,dismiss:bv.dismiss,loading:bv.loading},{getHistory:()=>bv.toasts,getToasts:()=>bv.getActiveToasts()});Tte(`[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}`);function Sv(e){return e.label!==void 0}var Rte=3,zte=`24px`,Bte=`16px`,Cv=4e3,Vte=356,Hte=14,Ute=45,Wte=200;function wv(...e){return e.filter(Boolean).join(` `)}function Gte(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var Kte=e=>{let{invert:t,toast:n,unstyled:r,interacting:i,setHeights:a,visibleToasts:o,heights:s,index:c,toasts:l,expanded:u,removeToast:d,defaultRichColors:f,closeButton:p,style:m,cancelButtonStyle:h,actionButtonStyle:g,className:_=``,descriptionClassName:v=``,duration:y,position:b,gap:x,expandByDefault:S,classNames:C,icons:w,closeButtonAriaLabel:T=`Close toast`}=e,[E,D]=G.useState(null),[O,k]=G.useState(null),[A,j]=G.useState(!1),[M,N]=G.useState(!1),[P,F]=G.useState(!1),[I,L]=G.useState(!1),[ee,te]=G.useState(!1),[R,z]=G.useState(0),[ne,re]=G.useState(0),ie=G.useRef(n.duration||y||Cv),ae=G.useRef(null),oe=G.useRef(null),se=c===0,ce=c+1<=o,le=n.type,ue=n.dismissible!==!1,de=n.className||``,B=n.descriptionClassName||``,fe=G.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),pe=G.useMemo(()=>n.closeButton??p,[n.closeButton,p]),me=G.useMemo(()=>n.duration||y||Cv,[n.duration,y]),V=G.useRef(0),H=G.useRef(0),he=G.useRef(0),ge=G.useRef(null),[_e,ve]=b.split(`-`),ye=G.useMemo(()=>s.reduce((e,t,n)=>n>=fe?e:e+t.height,0),[s,fe]),U=Pte(),be=n.invert||t,xe=le===`loading`;H.current=G.useMemo(()=>fe*x+ye,[fe,ye]),G.useEffect(()=>{ie.current=me},[me]),G.useEffect(()=>{j(!0)},[]),G.useEffect(()=>{let e=oe.current;if(e){let t=e.getBoundingClientRect().height;return re(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),G.useLayoutEffect(()=>{if(!A)return;let e=oe.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,re(r),a(e=>e.find(e=>e.toastId===n.id)?e.map(e=>e.toastId===n.id?{...e,height:r}:e):[{toastId:n.id,height:r,position:n.position},...e])},[A,n.title,n.description,a,n.id,n.jsx,n.action,n.cancel]);let Se=G.useCallback(()=>{N(!0),z(H.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},Wte)},[n,d,a,H]);G.useEffect(()=>{if(n.promise&&le===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||U?(()=>{if(he.current<V.current){let e=new Date().getTime()-V.current;ie.current-=e}he.current=new Date().getTime()})():ie.current!==1/0&&(V.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),Se()},ie.current)),()=>clearTimeout(e)},[u,i,n,le,U,Se]),G.useEffect(()=>{n.delete&&(Se(),n.onDismiss==null||n.onDismiss.call(n,n))},[Se,n.delete]);function Ce(){return w?.loading?G.createElement(`div`,{className:wv(C?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":le===`loading`},w.loading):G.createElement(Ote,{className:wv(C?.loader,n?.classNames?.loader),visible:le===`loading`})}let we=n.icon||w?.[le]||Ete(le);return G.createElement(`li`,{tabIndex:0,ref:oe,className:wv(_,de,C?.toast,n?.classNames?.toast,C?.default,C?.[le],n?.classNames?.[le]),"data-sonner-toast":``,"data-rich-colors":n.richColors??f,"data-styled":!(n.jsx||n.unstyled||r),"data-mounted":A,"data-promise":!!n.promise,"data-swiped":ee,"data-removed":M,"data-visible":ce,"data-y-position":_e,"data-x-position":ve,"data-index":c,"data-front":se,"data-swiping":P,"data-dismissible":ue,"data-type":le,"data-invert":be,"data-swipe-out":I,"data-swipe-direction":O,"data-expanded":!!(u||S&&A),"data-testid":n.testId,style:{"--index":c,"--toasts-before":c,"--z-index":l.length-c,"--offset":`${M?R:H.current}px`,"--initial-height":S?`auto`:`${ne}px`,...m,...n.style},onDragEnd:()=>{F(!1),D(null),ge.current=null},onPointerDown:e=>{e.button!==2&&(xe||!ue||(ae.current=new Date,z(H.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(F(!0),ge.current={x:e.clientX,y:e.clientY})))},onPointerUp:()=>{if(I||!ue)return;ge.current=null;let e=Number(oe.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(oe.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),r=new Date().getTime()-ae.current?.getTime(),i=E===`x`?e:t,a=Math.abs(i)/r;if(Math.abs(i)>=Ute||a>.11){z(H.current),n.onDismiss==null||n.onDismiss.call(n,n),k(E===`x`?e>0?`right`:`left`:t>0?`down`:`up`),Se(),L(!0);return}else{var o,s;(o=oe.current)==null||o.style.setProperty(`--swipe-amount-x`,`0px`),(s=oe.current)==null||s.style.setProperty(`--swipe-amount-y`,`0px`)}te(!1),F(!1),D(null)},onPointerMove:t=>{var n,r;if(!ge.current||!ue||window.getSelection()?.toString().length>0)return;let i=t.clientY-ge.current.y,a=t.clientX-ge.current.x,o=e.swipeDirections??Gte(b);!E&&(Math.abs(a)>1||Math.abs(i)>1)&&D(Math.abs(a)>Math.abs(i)?`x`:`y`);let s={x:0,y:0},c=e=>1/(1.5+Math.abs(e)/20);if(E===`y`){if(o.includes(`top`)||o.includes(`bottom`))if(o.includes(`top`)&&i<0||o.includes(`bottom`)&&i>0)s.y=i;else{let e=i*c(i);s.y=Math.abs(e)<Math.abs(i)?e:i}}else if(E===`x`&&(o.includes(`left`)||o.includes(`right`)))if(o.includes(`left`)&&a<0||o.includes(`right`)&&a>0)s.x=a;else{let e=a*c(a);s.x=Math.abs(e)<Math.abs(a)?e:a}(Math.abs(s.x)>0||Math.abs(s.y)>0)&&te(!0),(n=oe.current)==null||n.style.setProperty(`--swipe-amount-x`,`${s.x}px`),(r=oe.current)==null||r.style.setProperty(`--swipe-amount-y`,`${s.y}px`)}},pe&&!n.jsx&&le!==`loading`?G.createElement(`button`,{"aria-label":T,"data-disabled":xe,"data-close-button":!0,onClick:xe||!ue?()=>{}:()=>{Se(),n.onDismiss==null||n.onDismiss.call(n,n)},className:wv(C?.closeButton,n?.classNames?.closeButton)},w?.close??Nte):null,(le||n.icon||n.promise)&&n.icon!==null&&(w?.[le]!==null||n.icon)?G.createElement(`div`,{"data-icon":``,className:wv(C?.icon,n?.classNames?.icon)},n.promise||n.type===`loading`&&!n.icon?n.icon||Ce():null,n.type===`loading`?null:we):null,G.createElement(`div`,{"data-content":``,className:wv(C?.content,n?.classNames?.content)},G.createElement(`div`,{"data-title":``,className:wv(C?.title,n?.classNames?.title)},n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title),n.description?G.createElement(`div`,{"data-description":``,className:wv(v,B,C?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),G.isValidElement(n.cancel)?n.cancel:n.cancel&&Sv(n.cancel)?G.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||h,onClick:e=>{Sv(n.cancel)&&ue&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),Se())},className:wv(C?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,G.isValidElement(n.action)?n.action:n.action&&Sv(n.action)?G.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||g,onClick:e=>{Sv(n.action)&&(n.action.onClick==null||n.action.onClick.call(n.action,e),!e.defaultPrevented&&Se())},className:wv(C?.actionButton,n?.classNames?.actionButton)},n.action.label):null)};function Tv(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}function qte(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?Bte:zte;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}var Jte=G.forwardRef(function(e,t){let{id:n,invert:r,position:i=`bottom-right`,hotkey:a=[`altKey`,`KeyT`],expand:o,closeButton:s,className:c,offset:l,mobileOffset:u,theme:d=`light`,richColors:f,duration:p,style:m,visibleToasts:h=Rte,toastOptions:g,dir:_=Tv(),gap:v=Hte,icons:y,containerAriaLabel:b=`Notifications`}=e,[x,S]=G.useState([]),C=G.useMemo(()=>n?x.filter(e=>e.toasterId===n):x.filter(e=>!e.toasterId),[x,n]),w=G.useMemo(()=>Array.from(new Set([i].concat(C.filter(e=>e.position).map(e=>e.position)))),[C,i]),[T,E]=G.useState([]),[D,O]=G.useState(!1),[k,A]=G.useState(!1),[j,M]=G.useState(d===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:d),N=G.useRef(null),P=a.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),F=G.useRef(null),I=G.useRef(!1),L=G.useCallback(e=>{S(t=>(t.find(t=>t.id===e.id)?.delete||bv.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return G.useEffect(()=>bv.subscribe(e=>{if(e.dismiss){requestAnimationFrame(()=>{S(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))});return}setTimeout(()=>{Va.flushSync(()=>{S(t=>{let n=t.findIndex(t=>t.id===e.id);return n===-1?[e,...t]:[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]})})})}),[x]),G.useEffect(()=>{if(d!==`system`){M(d);return}if(d===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?M(`dark`):M(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{M(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{M(e?`dark`:`light`)}catch(e){console.error(e)}})}},[d]),G.useEffect(()=>{x.length<=1&&O(!1)},[x]),G.useEffect(()=>{let e=e=>{if(a.every(t=>e[t]||e.code===t)){var t;O(!0),(t=N.current)==null||t.focus()}e.code===`Escape`&&(document.activeElement===N.current||N.current?.contains(document.activeElement))&&O(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]),G.useEffect(()=>{if(N.current)return()=>{F.current&&(F.current.focus({preventScroll:!0}),F.current=null,I.current=!1)}},[N.current]),G.createElement(`section`,{ref:t,"aria-label":`${b} ${P}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0},w.map((t,n)=>{let[i,a]=t.split(`-`);return C.length?G.createElement(`ol`,{key:t,dir:_===`auto`?Tv():_,tabIndex:-1,ref:N,className:c,"data-sonner-toaster":!0,"data-sonner-theme":j,"data-y-position":i,"data-x-position":a,style:{"--front-toast-height":`${T[0]?.height||0}px`,"--width":`${Vte}px`,"--gap":`${v}px`,...m,...qte(l,u)},onBlur:e=>{I.current&&!e.currentTarget.contains(e.relatedTarget)&&(I.current=!1,F.current&&=(F.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||I.current||(I.current=!0,F.current=e.relatedTarget)},onMouseEnter:()=>O(!0),onMouseMove:()=>O(!0),onMouseLeave:()=>{k||O(!1)},onDragEnd:()=>O(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||A(!0)},onPointerUp:()=>A(!1)},C.filter(e=>!e.position&&n===0||e.position===t).map((n,i)=>G.createElement(Kte,{key:n.id,icons:y,index:i,toast:n,defaultRichColors:f,duration:g?.duration??p,className:g?.className,descriptionClassName:g?.descriptionClassName,invert:r,visibleToasts:h,closeButton:g?.closeButton??s,interacting:k,position:t,style:g?.style,unstyled:g?.unstyled,classNames:g?.classNames,cancelButtonStyle:g?.cancelButtonStyle,actionButtonStyle:g?.actionButtonStyle,closeButtonAriaLabel:g?.closeButtonAriaLabel,removeToast:L,toasts:C.filter(e=>e.position==n.position),heights:T.filter(e=>e.position==n.position),setHeights:E,expandByDefault:o,gap:v,expanded:D,swipeDirections:e.swipeDirections}))):null}))}),Ev=`Dialog`,[Dv,Ov]=Pa(Ev),[Yte,kv]=Dv(Ev),Av=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=G.useRef(null),c=G.useRef(null),[l,u]=Ra({prop:r,defaultProp:i??!1,onChange:a,caller:Ev});return(0,K.jsx)(Yte,{scope:t,triggerRef:s,contentRef:c,contentId:Lo(),titleId:Lo(),descriptionId:Lo(),open:l,onOpenChange:u,onOpenToggle:G.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})};Av.displayName=Ev;var jv=`DialogTrigger`,Mv=G.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=kv(jv,n),a=Br(t,i.triggerRef);return(0,K.jsx)(Ya.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":qv(i.open),...r,ref:a,onClick:Ma(e.onClick,i.onOpenToggle)})});Mv.displayName=jv;var Nv=`DialogPortal`,[Xte,Pv]=Dv(Nv,{forceMount:void 0}),Fv=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=kv(Nv,t);return(0,K.jsx)(Xte,{scope:t,forceMount:n,children:G.Children.map(r,e=>(0,K.jsx)(Al,{present:n||a.open,children:(0,K.jsx)(Ol,{asChild:!0,container:i,children:e})}))})};Fv.displayName=Nv;var Iv=`DialogOverlay`,Lv=G.forwardRef((e,t)=>{let n=Pv(Iv,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=kv(Iv,e.__scopeDialog);return a.modal?(0,K.jsx)(Al,{present:r||a.open,children:(0,K.jsx)(Qte,{...i,ref:t})}):null});Lv.displayName=Iv;var Zte=Ha(`DialogOverlay.RemoveScroll`),Qte=G.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=kv(Iv,n);return(0,K.jsx)(vd,{as:Zte,allowPinchZoom:!0,shards:[i.contentRef],children:(0,K.jsx)(Ya.div,{"data-state":qv(i.open),...r,ref:t,style:{pointerEvents:`auto`,...r.style}})})}),Rv=`DialogContent`,zv=G.forwardRef((e,t)=>{let n=Pv(Rv,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=kv(Rv,e.__scopeDialog);return(0,K.jsx)(Al,{present:r||a.open,children:a.modal?(0,K.jsx)($te,{...i,ref:t}):(0,K.jsx)(ene,{...i,ref:t})})});zv.displayName=Rv;var $te=G.forwardRef((e,t)=>{let n=kv(Rv,e.__scopeDialog),r=G.useRef(null),i=Br(t,n.contentRef,r);return G.useEffect(()=>{let e=r.current;if(e)return lu(e)},[]),(0,K.jsx)(Bv,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ma(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Ma(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:Ma(e.onFocusOutside,e=>e.preventDefault())})}),ene=G.forwardRef((e,t)=>{let n=kv(Rv,e.__scopeDialog),r=G.useRef(!1),i=G.useRef(!1);return(0,K.jsx)(Bv,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),Bv=G.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=kv(Rv,n),c=G.useRef(null),l=Br(t,c);return _o(),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Co,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,K.jsx)(co,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":qv(s.open),...o,ref:l,onDismiss:()=>s.onOpenChange(!1)})}),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(nne,{titleId:s.titleId}),(0,K.jsx)(ine,{contentRef:c,descriptionId:s.descriptionId})]})]})}),Vv=`DialogTitle`,Hv=G.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=kv(Vv,n);return(0,K.jsx)(Ya.h2,{id:i.titleId,...r,ref:t})});Hv.displayName=Vv;var Uv=`DialogDescription`,Wv=G.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=kv(Uv,n);return(0,K.jsx)(Ya.p,{id:i.descriptionId,...r,ref:t})});Wv.displayName=Uv;var Gv=`DialogClose`,Kv=G.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=kv(Gv,n);return(0,K.jsx)(Ya.button,{type:`button`,...r,ref:t,onClick:Ma(e.onClick,()=>i.onOpenChange(!1))})});Kv.displayName=Gv;function qv(e){return e?`open`:`closed`}var Jv=`DialogTitleWarning`,[tne,Yv]=Na(Jv,{contentName:Rv,titleName:Vv,docsSlug:`dialog`}),nne=({titleId:e})=>{let t=Yv(Jv),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
56
56
|
|
|
@@ -368,7 +368,7 @@ Props Schema:
|
|
|
368
368
|
${r}
|
|
369
369
|
|
|
370
370
|
Generate appropriate default/example values for these props. Return ONLY a JSON object with the exact prop names as keys.
|
|
371
|
-
Example: {"query": "example search term", "results": [{"fruit": "Apple", "color": "red"}]}`,{SystemMessage:s,HumanMessage:c}=await B(async()=>{let{SystemMessage:e,HumanMessage:t}=await import(`./messages-
|
|
371
|
+
Example: {"query": "example search term", "results": [{"fruit": "Apple", "color": "red"}]}`,{SystemMessage:s,HumanMessage:c}=await B(async()=>{let{SystemMessage:e,HumanMessage:t}=await import(`./messages-DmWRSzWI.js`);return{SystemMessage:e,HumanMessage:t}},[]),l=[new s(`You are helping a developer configure props for a UI widget. The widget has a defined schema with specific props. Generate appropriate values for ONLY the props listed in the schema. Return ONLY a JSON object with these exact keys. For array props, each item must match the specified structure.`),new c(a)];if(!t.current||t.current.provider!==e.provider||t.current.model!==e.model||t.current.apiKey!==e.apiKey){let n,r={model:e.model,apiKey:e.apiKey};if(e.temperature!==void 0&&(r.temperature=e.temperature),e.provider===`openai`){let{ChatOpenAI:e}=await B(async()=>{let{ChatOpenAI:e}=await import(`./dist-BG8NAFfu.js`);return{ChatOpenAI:e}},__vite__mapDeps([197,198,3,199,200,201,202,203]));n=new e(r)}else if(e.provider===`anthropic`){let{ChatAnthropic:e}=await B(async()=>{let{ChatAnthropic:e}=await import(`./dist-YxwKnKYL.js`);return{ChatAnthropic:e}},__vite__mapDeps([204,198,3,201,202,203]));n=new e(r)}else if(e.provider===`google`){let{ChatGoogleGenerativeAI:e}=await B(async()=>{let{ChatGoogleGenerativeAI:e}=await import(`./dist-CKth7ANk.js`);return{ChatGoogleGenerativeAI:e}},__vite__mapDeps([205,198,3,199]));n=new e(r)}else throw Error(`Unsupported LLM provider: ${e.provider}`);t.current={instance:n,provider:e.provider,model:e.model,apiKey:e.apiKey}}let u=await t.current.instance.invoke(l),d=v$(u.content||u.text||``);if(d)return Object.entries(d).map(([e,t])=>({key:e,value:typeof t==`object`&&t?JSON.stringify(t):String(t)}));throw Error(`Could not parse props from LLM response`)}let s=!!(r&&Object.keys(r).some(e=>e.startsWith(`openai/`))),c=typeof a==`string`&&(a.toLowerCase().includes(`mcp-ui`)||a.toLowerCase().includes(`html`)||a.toLowerCase().includes(`remote-dom`)),l=`Resource Information:
|
|
372
372
|
- URI: ${n.uri}
|
|
373
373
|
- Name: ${n.name||`N/A`}
|
|
374
374
|
- Type: ${a}
|
|
@@ -376,7 +376,7 @@ Example: {"query": "example search term", "results": [{"fruit": "Apple", "color"
|
|
|
376
376
|
- Is OpenAI Widget: ${s?`Yes`:`No`}
|
|
377
377
|
- Is MCP UI Resource: ${c?`Yes`:`No`}
|
|
378
378
|
|
|
379
|
-
Based on this information, suggest 3-5 common customizable properties like theme, dimensions, colors, titles, or configuration options that would be useful for this type of resource. Keep it simple and practical.`;if(!t.current||t.current.provider!==e.provider||t.current.model!==e.model||t.current.apiKey!==e.apiKey){let n,r={model:e.model,apiKey:e.apiKey};if(e.temperature!==void 0&&(r.temperature=e.temperature),e.provider===`openai`){let{ChatOpenAI:e}=await B(async()=>{let{ChatOpenAI:e}=await import(`./dist-
|
|
379
|
+
Based on this information, suggest 3-5 common customizable properties like theme, dimensions, colors, titles, or configuration options that would be useful for this type of resource. Keep it simple and practical.`;if(!t.current||t.current.provider!==e.provider||t.current.model!==e.model||t.current.apiKey!==e.apiKey){let n,r={model:e.model,apiKey:e.apiKey};if(e.temperature!==void 0&&(r.temperature=e.temperature),e.provider===`openai`){let{ChatOpenAI:e}=await B(async()=>{let{ChatOpenAI:e}=await import(`./dist-BG8NAFfu.js`);return{ChatOpenAI:e}},__vite__mapDeps([197,198,3,199,200,201,202,203]));n=new e(r)}else if(e.provider===`anthropic`){let{ChatAnthropic:e}=await B(async()=>{let{ChatAnthropic:e}=await import(`./dist-YxwKnKYL.js`);return{ChatAnthropic:e}},__vite__mapDeps([204,198,3,201,202,203]));n=new e(r)}else if(e.provider===`google`){let{ChatGoogleGenerativeAI:e}=await B(async()=>{let{ChatGoogleGenerativeAI:e}=await import(`./dist-CKth7ANk.js`);return{ChatGoogleGenerativeAI:e}},__vite__mapDeps([205,198,3,199]));n=new e(r)}else throw Error(`Unsupported LLM provider: ${e.provider}`);t.current={instance:n,provider:e.provider,model:e.model,apiKey:e.apiKey}}let{SystemMessage:u,HumanMessage:d}=await B(async()=>{let{SystemMessage:e,HumanMessage:t}=await import(`./messages-DmWRSzWI.js`);return{SystemMessage:e,HumanMessage:t}},[]),f=[new u(`You are helping a developer configure props for a UI widget/resource.
|
|
380
380
|
Analyze the provided information and suggest appropriate props in key-value format.
|
|
381
381
|
Return ONLY a JSON object with key-value pairs, where both keys and values are strings.
|
|
382
382
|
Example format: {"theme": "dark", "width": "400", "title": "My Widget"}`),new d(l)],p=await t.current.instance.invoke(f),m=p.content||p.text||``;try{let e=v$(m);if(e)return Object.entries(e).map(([e,t])=>({key:e,value:typeof t==`object`&&t?JSON.stringify(t):String(t)}));let t=m.split(`
|
|
@@ -423,9 +423,9 @@ Instead got an unsupported type.`)}var J8=class extends B8{static lc_name(){retu
|
|
|
423
423
|
`)}else r.content&&typeof r.content==`object`&&(r.content.type===`text`&&r.content.text?e=r.content.text:r.content.type===`image`&&r.content.data?i.push({type:`image`,data:r.content.data,mimeType:r.content.mimeType||`image/png`}):e=JSON.stringify(r.content));!e&&i.length===0&&(e=`[no content]`);let a={id:`prompt-${n.promptName}-${n.timestamp}-${t.length}`,role:r.role,content:e||``,timestamp:n.timestamp,attachments:i.length>0?i:void 0};t.push(a)}}return t};function _be({mcpServerUrl:e,llmConfig:t,authConfig:n,isConnected:r,chatApiUrl:i,waitForChatApiUrl:a,widgetModelContexts:o,initialMessages:s}){let[c,l]=(0,G.useState)(s??[]),[u,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)([]),m=(0,G.useRef)(null);return{messages:c,isLoading:u,attachments:f,sendMessage:(0,G.useCallback)(async(s,u,h)=>{let g=[...f,...h??[]];if(!(s.trim()||u.length>0||g.length>0)||!t||!r)return;let _=[...d5(u)];if(s.trim()||g.length>0){let e={id:`user-${Date.now()}`,role:`user`,content:s.trim(),timestamp:Date.now(),attachments:g.length>0?g:void 0};_.push(e)}l(e=>[...e,..._]),d(!0),p([]),m.current=new AbortController;try{let r=n;if(n?.type===`oauth`)try{let t=`mcp:auth_${yL(e)}_tokens`,i=localStorage.getItem(t);if(i){let e=JSON.parse(i);r={...n,oauthTokens:e}}else console.warn(`No OAuth tokens found in localStorage for key:`,t)}catch(e){console.warn(`Failed to retrieve OAuth tokens:`,e)}let s=[];if(o&&o.size>0){let e=[];for(let[,t]of o)t&&(t.content?.length?e.push(t.content.map(e=>e.text).join(`
|
|
424
424
|
`)):t.structuredContent&&e.push(JSON.stringify(t.structuredContent)));e.length>0&&s.push({role:`user`,content:`[Current Widget State]\n${e.join(`
|
|
425
425
|
`)}`})}let u=i??(a?await a():void 0)??`/inspector/api/chat/stream`,d=await fetch(u,{method:`POST`,headers:{"Content-Type":`application/json`},signal:m.current.signal,body:JSON.stringify({mcpServerUrl:e,llmConfig:t,authConfig:r,messages:[...[...c,..._].map(e=>({role:e.role,content:e.content||(e.parts?.filter(e=>e.type===`text`).map(e=>e.text).join(``)??``),attachments:e.attachments})),...s]})});if(!d.ok)throw Error(`HTTP error! status: ${d.status}`);let f=`assistant-${Date.now()}`,p=``,h=[];l(e=>[...e,{id:f,role:`assistant`,content:``,timestamp:Date.now(),parts:[]}]);let g=d.body?.getReader(),v=new TextDecoder;if(!g)throw Error(`No response body`);let y=``;for(;;){if(m.current?.signal.aborted){await g.cancel();break}let{done:e,value:t}=await g.read();if(e)break;y+=v.decode(t,{stream:!0});let n=y.split(`
|
|
426
|
-
`);y=n.pop()||``;for(let e of n)if(e.trim()&&e.startsWith(`data: `))try{let t=JSON.parse(e.slice(6));if(console.log(`[Client received event]`,t.type,t.toolName||t.content?.slice?.(0,30)),t.type===`message`)console.log(`[Message started]`,t.id);else if(t.type===`text`){p+=t.content;let e=h[h.length-1];e&&e.type===`text`?e.text=p:h.push({type:`text`,text:p}),console.log(`[Parts after text]`,h.length,`parts, text length:`,p.length),l(e=>e.map(e=>e.id===f?{...e,parts:[...h]}:e))}else if(t.type===`tool-call`)p&&=``,h.push({type:`tool-invocation`,toolInvocation:{toolName:t.toolName,args:t.args,state:`pending`}}),console.log(`[Parts after tool-call]`,h.length,`parts, tool:`,t.toolName),l(e=>e.map(e=>e.id===f?{...e,parts:[...h]}:e));else if(t.type===`tool-result`){let e=h.find(e=>e.type===`tool-invocation`&&e.toolInvocation?.toolName===t.toolName&&!e.toolInvocation?.result);e&&e.toolInvocation?(e.toolInvocation.result=t.result,e.toolInvocation.state=t.result?.isError?`error`:`result`,console.log(`[Parts after tool-result]`,h.length,`parts, updated:`,t.toolName),l(e=>e.map(e=>e.id===f?{...e,parts:[...h]}:e))):console.warn(`[tool-result] Could not find matching tool part for`,t.toolName)}else if(t.type===`done`)console.log(`[Done] Final parts:`,h.length),l(e=>e.map(e=>e.id===f?{...e,parts:[...h],content:``}:e));else if(t.type===`error`)throw Error(t.message||`Streaming error`)}catch(t){console.error(`Failed to parse streaming event:`,t,e)}}if(m.current?.signal.aborted){for(let e of h)e.type===`tool-invocation`&&e.toolInvocation?.state===`pending`&&(e.toolInvocation.state=`error`,e.toolInvocation.result=`Cancelled by user`);l(e=>e.map(e=>e.id===f?{...e,parts:[...h],content:``}:e))}}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;let t=`Unknown error occurred`;if(e instanceof Error){t=e.message;let n=e;n.status&&(t=`HTTP ${n.status}: ${t}`),(n.code===401||t.includes(`401`)||t.includes(`Unauthorized`))&&(t=`Authentication failed (401). Check your Authorization header in the connection settings.`)}let n={id:`error-${Date.now()}`,role:`assistant`,content:`Error: ${t}`,timestamp:Date.now()};l(e=>[...e,n])}finally{d(!1),m.current=null}},[t,r,e,c,n,f,i,a]),clearMessages:(0,G.useCallback)(()=>{l([])},[]),setMessages:l,stop:(0,G.useCallback)(()=>{m.current&&m.current.abort()},[]),addAttachment:(0,G.useCallback)(async e=>{try{let t=await DL(e);p(e=>{let n=[...e,t];return TL(n)?n:(alert(`Total attachment size exceeds 20MB limit`),e)})}catch(e){e instanceof Error?alert(e.message):alert(`Failed to add attachment`)}},[]),removeAttachment:(0,G.useCallback)(e=>{p(t=>t.filter((t,n)=>n!==e))},[]),clearAttachments:(0,G.useCallback)(()=>{p([])},[])}}function vbe({connection:e,llmConfig:t,isConnected:n,readResource:r,widgetModelContexts:i,disabledTools:a}){let[o,s]=(0,G.useState)([]),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)([]),f=(0,G.useRef)(null),p=(0,G.useRef)(null),m=(0,G.useRef)(null),h=(0,G.useRef)(``);return{messages:o,isLoading:c,attachments:u,sendMessage:(0,G.useCallback)(async(c,g,_)=>{let v=[...u,..._??[]];if(!(c.trim()||g.length>0||v.length>0)||!t||!n)return;let y=d5(g),b={id:`user-${Date.now()}`,role:`user`,content:c.trim(),timestamp:Date.now(),attachments:v.length>0?v:void 0},x=[...y];(c.trim()||v.length>0)&&x.push(b),s(e=>[...e,...x]),l(!0),d([]),f.current=new AbortController;let S=Date.now(),C=0;try{let n=`assistant-${Date.now()}`,l=``,u=[],d=new Map,g=0,_=async()=>{let e=Date.now();e-g>=80&&(g=e,await new Promise(e=>setTimeout(e,0)))};if(s(e=>[...e,{id:n,role:`assistant`,content:``,timestamp:Date.now(),parts:[]}]),!m.current||m.current.provider!==t.provider||m.current.model!==t.model||m.current.apiKey!==t.apiKey){let e;if(t.provider===`openai`){let{ChatOpenAI:n}=await B(async()=>{let{ChatOpenAI:e}=await import(`./dist-
|
|
426
|
+
`);y=n.pop()||``;for(let e of n)if(e.trim()&&e.startsWith(`data: `))try{let t=JSON.parse(e.slice(6));if(console.log(`[Client received event]`,t.type,t.toolName||t.content?.slice?.(0,30)),t.type===`message`)console.log(`[Message started]`,t.id);else if(t.type===`text`){p+=t.content;let e=h[h.length-1];e&&e.type===`text`?e.text=p:h.push({type:`text`,text:p}),console.log(`[Parts after text]`,h.length,`parts, text length:`,p.length),l(e=>e.map(e=>e.id===f?{...e,parts:[...h]}:e))}else if(t.type===`tool-call`)p&&=``,h.push({type:`tool-invocation`,toolInvocation:{toolName:t.toolName,args:t.args,state:`pending`}}),console.log(`[Parts after tool-call]`,h.length,`parts, tool:`,t.toolName),l(e=>e.map(e=>e.id===f?{...e,parts:[...h]}:e));else if(t.type===`tool-result`){let e=h.find(e=>e.type===`tool-invocation`&&e.toolInvocation?.toolName===t.toolName&&!e.toolInvocation?.result);e&&e.toolInvocation?(e.toolInvocation.result=t.result,e.toolInvocation.state=t.result?.isError?`error`:`result`,console.log(`[Parts after tool-result]`,h.length,`parts, updated:`,t.toolName),l(e=>e.map(e=>e.id===f?{...e,parts:[...h]}:e))):console.warn(`[tool-result] Could not find matching tool part for`,t.toolName)}else if(t.type===`done`)console.log(`[Done] Final parts:`,h.length),l(e=>e.map(e=>e.id===f?{...e,parts:[...h],content:``}:e));else if(t.type===`error`)throw Error(t.message||`Streaming error`)}catch(t){console.error(`Failed to parse streaming event:`,t,e)}}if(m.current?.signal.aborted){for(let e of h)e.type===`tool-invocation`&&e.toolInvocation?.state===`pending`&&(e.toolInvocation.state=`error`,e.toolInvocation.result=`Cancelled by user`);l(e=>e.map(e=>e.id===f?{...e,parts:[...h],content:``}:e))}}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;let t=`Unknown error occurred`;if(e instanceof Error){t=e.message;let n=e;n.status&&(t=`HTTP ${n.status}: ${t}`),(n.code===401||t.includes(`401`)||t.includes(`Unauthorized`))&&(t=`Authentication failed (401). Check your Authorization header in the connection settings.`)}let n={id:`error-${Date.now()}`,role:`assistant`,content:`Error: ${t}`,timestamp:Date.now()};l(e=>[...e,n])}finally{d(!1),m.current=null}},[t,r,e,c,n,f,i,a]),clearMessages:(0,G.useCallback)(()=>{l([])},[]),setMessages:l,stop:(0,G.useCallback)(()=>{m.current&&m.current.abort()},[]),addAttachment:(0,G.useCallback)(async e=>{try{let t=await DL(e);p(e=>{let n=[...e,t];return TL(n)?n:(alert(`Total attachment size exceeds 20MB limit`),e)})}catch(e){e instanceof Error?alert(e.message):alert(`Failed to add attachment`)}},[]),removeAttachment:(0,G.useCallback)(e=>{p(t=>t.filter((t,n)=>n!==e))},[]),clearAttachments:(0,G.useCallback)(()=>{p([])},[])}}function vbe({connection:e,llmConfig:t,isConnected:n,readResource:r,widgetModelContexts:i,disabledTools:a}){let[o,s]=(0,G.useState)([]),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)([]),f=(0,G.useRef)(null),p=(0,G.useRef)(null),m=(0,G.useRef)(null),h=(0,G.useRef)(``);return{messages:o,isLoading:c,attachments:u,sendMessage:(0,G.useCallback)(async(c,g,_)=>{let v=[...u,..._??[]];if(!(c.trim()||g.length>0||v.length>0)||!t||!n)return;let y=d5(g),b={id:`user-${Date.now()}`,role:`user`,content:c.trim(),timestamp:Date.now(),attachments:v.length>0?v:void 0},x=[...y];(c.trim()||v.length>0)&&x.push(b),s(e=>[...e,...x]),l(!0),d([]),f.current=new AbortController;let S=Date.now(),C=0;try{let n=`assistant-${Date.now()}`,l=``,u=[],d=new Map,g=0,_=async()=>{let e=Date.now();e-g>=80&&(g=e,await new Promise(e=>setTimeout(e,0)))};if(s(e=>[...e,{id:n,role:`assistant`,content:``,timestamp:Date.now(),parts:[]}]),!m.current||m.current.provider!==t.provider||m.current.model!==t.model||m.current.apiKey!==t.apiKey){let e;if(t.provider===`openai`){let{ChatOpenAI:n}=await B(async()=>{let{ChatOpenAI:e}=await import(`./dist-BG8NAFfu.js`);return{ChatOpenAI:e}},__vite__mapDeps([197,198,3,199,200,201,202,203]));e=new n({model:t.model,apiKey:t.apiKey})}else if(t.provider===`anthropic`){let{ChatAnthropic:n}=await B(async()=>{let{ChatAnthropic:e}=await import(`./dist-YxwKnKYL.js`);return{ChatAnthropic:e}},__vite__mapDeps([204,198,3,201,202,203]));e=new n({model:t.model,apiKey:t.apiKey})}else if(t.provider===`google`){let{ChatGoogleGenerativeAI:n}=await B(async()=>{let{ChatGoogleGenerativeAI:e}=await import(`./dist-CKth7ANk.js`);return{ChatGoogleGenerativeAI:e}},__vite__mapDeps([205,198,3,199]));e=new n({model:t.model,apiKey:t.apiKey})}else throw Error(`Unsupported LLM provider: ${t.provider}`);m.current={instance:e,provider:t.provider,model:t.model,apiKey:t.apiKey}}let v=a?[...a].sort():[],x=v.join(`,`);if(!p.current||p.current.llm!==m.current.instance||h.current!==x){let{MCPAgent:t}=await B(async()=>{let{MCPAgent:e}=await import(`./browser-CUjguYn6.js`);return{MCPAgent:e}},__vite__mapDeps([206,207,198,3,199,200,201,202,208,203,2,1,209,210,211]));p.current=new t({llm:m.current.instance,client:e.client??void 0,memoryEnabled:!1,exposeResourcesAsTools:!1,exposePromptsAsTools:!1,disallowedTools:v.length>0?v:void 0,systemPrompt:`You are a helpful assistant with access to MCP tools. Help users interact with the MCP server.`}),await p.current.initialize(),h.current=x}let w=[];if(i&&i.size>0){let e=[];for(let[,t]of i)t&&(t.content?.length?e.push(t.content.map(e=>e.text).join(`
|
|
427
427
|
`)):t.structuredContent&&e.push(JSON.stringify(t.structuredContent)));e.length>0&&w.push({id:`widget-context-${Date.now()}`,role:`user`,content:`[Current Widget State]\n${e.join(`
|
|
428
|
-
`)}`,timestamp:Date.now()})}let T=(b.attachments?.length??0)>0,E=gbe([...o,...y,...w,...T?[b]:[]]),D=T?``:c;for await(let e of p.current.streamEvents(D,10,!1,E,void 0,f.current?.signal)){if(f.current?.signal.aborted)break;if(e.event===`on_chat_model_stream`){let t=e.data?.chunk;if(t?.text){let e=t.text;if(typeof e==`string`&&e.length>0){l+=e;let t=u[u.length-1];t&&t.type===`text`?t.text=l:u.push({type:`text`,text:l}),s(e=>e.map(e=>e.id===n?{...e,parts:[...u]}:e))}}let r=t?.tool_call_chunks||t?.kwargs?.tool_call_chunks||t?.lc_kwargs?.tool_call_chunks||t?.additional_kwargs?.tool_calls||t?.tool_calls;if(r&&Array.isArray(r)&&r.length>0){l&&=``;for(let e of r){let t=e.index??0,r=e.name||``,i=e.args||``,a=d.get(t);a||(a={name:r||`unknown`,accumulatedJson:``},d.set(t,a)),r&&a.name===`unknown`&&(a.name=r);let o;if(typeof i==`object`&&i)o=i;else if(typeof i==`string`&&i){a.accumulatedJson+=i;try{o=JSON.parse(a.accumulatedJson)}catch{let e=[()=>{let e=a.accumulatedJson;(e.match(/(?<!\\)"/g)||[]).length%2!=0&&(e+=`"`);let t=(e.match(/{/g)||[]).length-(e.match(/}/g)||[]).length,n=(e.match(/\[/g)||[]).length-(e.match(/]/g)||[]).length;for(let t=0;t<n;t++)e+=`]`;for(let n=0;n<t;n++)e+=`}`;return JSON.parse(e)},()=>{let e=a.accumulatedJson;e=e.replace(/,\s*"[^"]*"?\s*:\s*("([^"\\]|\\.)*)?$/,``),e=e.replace(/,\s*"[^"]*$/,``),(e.match(/(?<!\\)"/g)||[]).length%2!=0&&(e+=`"`);let t=(e.match(/{/g)||[]).length-(e.match(/}/g)||[]).length,n=(e.match(/\[/g)||[]).length-(e.match(/]/g)||[]).length;for(let t=0;t<n;t++)e+=`]`;for(let n=0;n<t;n++)e+=`}`;return JSON.parse(e)}];for(let t of e)try{o=t();break}catch{}}}if(o){let e=u.find(e=>e.type===`tool-invocation`&&e.toolInvocation?.state===`streaming`&&e.toolInvocation?.toolName===a.name);if(e&&e.toolInvocation){let t=e.toolInvocation.partialArgs,n=t?Object.keys(t):[],r=Object.keys(o),i=n.reduce((e,n)=>e+String(t[n]??``).length,0),a=r.reduce((e,t)=>e+String(o[t]??``).length,0);(r.length>n.length||a>=i)&&(e.toolInvocation.partialArgs=o)}else u.push({type:`tool-invocation`,toolInvocation:{toolName:a.name,args:{},state:`streaming`,partialArgs:o}});s(e=>e.map(e=>e.id===n?{...e,parts:[...u]}:e)),await _()}}}}else if(e.event===`on_tool_start`){l&&=``;let t={};e.data?.input?t=e.data.input:e.data?.tool_input?t=e.data.tool_input:e.data&&(t=e.data),console.log(`[useChatMessagesClientSide] on_tool_start:`,{toolName:e.name,eventData:e.data,extractedArgs:t}),C++;let r=u.find(t=>t.type===`tool-invocation`&&t.toolInvocation?.state===`streaming`&&t.toolInvocation?.toolName===(e.name||`unknown`));r&&r.toolInvocation?(r.toolInvocation.args=t,r.toolInvocation.state=`pending`):u.push({type:`tool-invocation`,toolInvocation:{toolName:e.name||`unknown`,args:t,state:`pending`}}),d.clear(),s(e=>e.map(e=>e.id===n?{...e,parts:[...u]}:e))}else if(e.event===`on_tool_end`){let t=u.find(t=>t.type===`tool-invocation`&&t.toolInvocation?.toolName===e.name&&!t.toolInvocation?.result);if(console.log(`[useChatMessagesClientSide] on_tool_end event:`,{toolName:e.name,hasToolPart:!!t,output:e.data?.output}),t&&t.toolInvocation){let i=e.data?.output;if(i?.kwargs?.content&&typeof i.kwargs.content==`string`)try{i=JSON.parse(i.kwargs.content)}catch(e){console.warn(`[useChatMessagesClientSide] Failed to parse kwargs.content:`,e),i=i.kwargs.content}else if(i?.content&&typeof i.content==`string`)try{i=JSON.parse(i.content)}catch{i=i.content}t.toolInvocation.result=i,t.toolInvocation.state=i?.isError?`error`:`result`;let a=i?._meta?.[`openai/outputTemplate`];if(console.log(`[useChatMessagesClientSide] Tool result:`,{toolName:e.name,hasMeta:!!i?._meta,hasStructuredContent:!!i?.structuredContent,appsSdkUri:a}),a&&typeof a==`string`&&r){console.log(`[useChatMessagesClientSide] Detected Apps SDK component, fetching resource:`,a);try{let e=await r(a);console.log(`[useChatMessagesClientSide] Resource fetched:`,e);let n=i?.structuredContent||null;if(e?.contents&&Array.isArray(e.contents)){let r=e.contents.map(e=>({type:`resource`,resource:e}));console.log(`[useChatMessagesClientSide] Created MCP resources:`,r);let a={...i,content:[...i.content||[],...r],structuredContent:n};t.toolInvocation.result=a,console.log(`[useChatMessagesClientSide] Updated result with resources`)}else console.warn(`[useChatMessagesClientSide] No contents in resourceData:`,e)}catch(e){console.error(`Failed to fetch Apps SDK resource:`,e)}}s(e=>e.map(e=>e.id===n?{...e,parts:[...u]}:e))}}}if(f.current?.signal.aborted)for(let e of u)e.type===`tool-invocation`&&e.toolInvocation?.state===`pending`&&(e.toolInvocation.state=`error`,e.toolInvocation.result=`Cancelled by user`);s(e=>e.map(e=>e.id===n?{...e,parts:[...u],content:``}:e)),t&&Km.getInstance().capture(new Bm({serverId:e.url,provider:t.provider,model:t.model,messageCount:o.length+1,toolCallsCount:C,success:!0,executionMode:`client-side`,duration:Date.now()-S})).catch(()=>{})}catch(n){if(n instanceof DOMException&&n.name===`AbortError`)return;console.error(`Client-side agent error:`,n);let r=`Unknown error occurred`;if(n instanceof Error){r=n.message;let e=n;e.status&&(r=`HTTP ${e.status}: ${r}`),(e.code===401||r.includes(`401`)||r.includes(`Unauthorized`))&&(r=`Authentication failed (401). Check your Authorization header in the connection settings.`)}t&&Km.getInstance().capture(new Bm({serverId:e.url,provider:t.provider,model:t.model,messageCount:o.length+1,toolCallsCount:C,success:!1,executionMode:`client-side`,duration:Date.now()-S,error:r})).catch(()=>{});let i={id:`error-${Date.now()}`,role:`assistant`,content:`Error: ${r}`,timestamp:Date.now()};s(e=>[...e,i])}finally{l(!1),f.current=null}},[e,t,n,o,r,u,a]),clearMessages:(0,G.useCallback)(()=>{s([]),p.current&&p.current.clearConversationHistory()},[]),setMessages:s,stop:(0,G.useCallback)(()=>{f.current&&f.current.abort()},[]),addAttachment:(0,G.useCallback)(async e=>{try{let t=await DL(e);d(e=>{let n=[...e,t];return TL(n)?n:(alert(`Total attachment size exceeds 20MB limit`),e)})}catch(e){e instanceof Error?alert(e.message):alert(`Failed to add attachment`)}},[]),removeAttachment:(0,G.useCallback)(e=>{d(t=>t.filter((t,n)=>n!==e))},[]),clearAttachments:(0,G.useCallback)(()=>{d([])},[])}}var f5={openai:`gpt-4o`,anthropic:`claude-haiku-4-5-20251001`,google:`gemini-2.5-flash`};function p5({mcpServerUrl:e}){let[t,n]=(0,G.useState)(null),[r,i]=(0,G.useState)(null),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(`openai`),[l,u]=(0,G.useState)(``),[d,f]=(0,G.useState)(f5.openai),p=(0,G.useCallback)(()=>{let e=localStorage.getItem(`mcp-inspector-api-keys`);if(e)try{return JSON.parse(e)}catch(e){return console.error(`Failed to load API keys:`,e),{}}return{}},[]),m=(0,G.useCallback)(e=>{localStorage.setItem(`mcp-inspector-api-keys`,JSON.stringify(e))},[]),[h,g]=(0,G.useState)(`none`),[_,v]=(0,G.useState)(``),[y,b]=(0,G.useState)(``),[x,S]=(0,G.useState)(``);return(0,G.useEffect)(()=>{let e=()=>{let e=localStorage.getItem(`mcp-inspector-llm-config`),t=p();if(e)try{let r=JSON.parse(e);n(r),c(r.provider),u(t[r.provider]||r.apiKey||``),f(r.model)}catch(e){console.error(`Failed to load LLM config:`,e)}};e();let t=()=>{e()},r=t=>{(t.key===`mcp-inspector-llm-config`||t.key===`mcp-inspector-api-keys`)&&e()};return window.addEventListener(`llm-config-updated`,t),window.addEventListener(`storage`,r),()=>{window.removeEventListener(`llm-config-updated`,t),window.removeEventListener(`storage`,r)}},[p]),(0,G.useEffect)(()=>{let t=localStorage.getItem(`mcp-inspector-auth-config`);if(t)try{let e=JSON.parse(t);i(e),g(e.type),e.username&&v(e.username),e.password&&b(e.password),e.token&&S(e.token)}catch(e){console.error(`Failed to load auth config:`,e)}else try{let t=`mcp:auth_${yL(e)}_tokens`;localStorage.getItem(t)&&(i({type:`oauth`}),g(`oauth`))}catch(e){console.error(`Failed to check for OAuth tokens:`,e)}},[e]),(0,G.useEffect)(()=>{f(f5[s]),u(p()[s]||``)},[s,p]),{llmConfig:t,authConfig:r,configDialogOpen:a,setConfigDialogOpen:o,tempProvider:s,setTempProvider:c,tempApiKey:l,setTempApiKey:u,tempModel:d,setTempModel:f,tempAuthType:h,saveLLMConfig:(0,G.useCallback)(()=>{if(!l.trim())return;let e=p();e[s]=l,m(e);let t={provider:s,apiKey:l,model:d},r={type:h,...h===`basic`&&{username:_.trim(),password:y.trim()},...h===`bearer`&&{token:x.trim()}};n(t),i(r),localStorage.setItem(`mcp-inspector-llm-config`,JSON.stringify(t)),localStorage.setItem(`mcp-inspector-auth-config`,JSON.stringify(r)),window.dispatchEvent(new CustomEvent(`llm-config-updated`)),o(!1)},[s,l,d,h,_,y,x,p,m]),clearConfig:(0,G.useCallback)(()=>{n(null),i(null);let e=p();delete e[s],m(e),u(``),v(``),b(``),S(``),g(`none`),localStorage.removeItem(`mcp-inspector-llm-config`),localStorage.removeItem(`mcp-inspector-auth-config`)},[s,p,m])}}var ybe=/(?:^\/$|\s+\/$)/,bbe=[`ArrowDown`,`ArrowUp`,`Escape`,`Enter`];function m5({connection:e,isConnected:t,useClientSide:n=!0,enableKeyboardShortcuts:r=!0,prompts:i,serverId:a,callPrompt:o,readResource:s,chatApiUrl:c,waitForChatApiUrl:l,initialMessages:u,managedLlmConfig:d,clearButtonLabel:f,hideTitle:p,hideModelBadge:m,hideServerUrl:h,clearButtonHideIcon:g,clearButtonHideShortcut:_,clearButtonVariant:v,hideClearButton:y,hideToolSelector:b,chatQuickQuestions:x=[],chatFollowups:S=[]}){let[C,w]=(0,G.useState)(``),[T,E]=(0,G.useState)(!1),[D,O]=(0,G.useState)(-1),[k,A]=(0,G.useState)(x),[j,M]=(0,G.useState)(S),[N,P]=(0,G.useState)(new Set),F=(0,G.useRef)(null),I=(0,G.useRef)(null),L=(0,G.useMemo)(()=>(e.tools??[]).map(e=>({name:e.name,description:e.description})),[e.tools]),{llmConfig:ee,authConfig:te,configDialogOpen:R,setConfigDialogOpen:z,tempProvider:ne,setTempProvider:re,tempApiKey:ie,setTempApiKey:ae,tempModel:oe,setTempModel:se,saveLLMConfig:ce,clearConfig:le}=p5({mcpServerUrl:e.url}),ue=d??ee,de=!!d,{getAllModelContexts:B}=XB(),fe=B(),pe={connection:e,llmConfig:ue,isConnected:t,readResource:s,widgetModelContexts:fe,disabledTools:N},me=_be({mcpServerUrl:e.url,llmConfig:ue,authConfig:te,isConnected:t,chatApiUrl:c,waitForChatApiUrl:l,widgetModelContexts:fe,initialMessages:u}),V=vbe(pe),{messages:H,isLoading:he,attachments:ge,sendMessage:_e,clearMessages:ve,setMessages:ye,stop:U,addAttachment:be,removeAttachment:xe}=n?V:me,{filteredPrompts:Se,setSelectedPrompt:Ce,selectedPrompt:we,setPromptArgs:Te,executePrompt:Ee,results:De,handleDeleteResult:Oe,clearPromptResults:ke}=uI({prompts:i,callPrompt:o,serverId:a}),Ae=(0,G.useCallback)(e=>Array.isArray(e)?e.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean).slice(0,8):[],[]),je=(0,G.useCallback)(e=>typeof e.content==`string`?e.content:Array.isArray(e.content)?e.content.map(e=>typeof e==`string`?e:e.text??``).join(``):``,[]),Me=(0,G.useCallback)(()=>H.map(e=>({id:e.id,role:e.role,content:je(e),timestamp:e.timestamp})),[H,je]),Ne=(0,G.useCallback)((e,t={})=>{typeof window>`u`||window.parent===window||window.parent.postMessage({type:e,serverId:a,...t},`*`)},[a]);(0,G.useEffect)(()=>{Ne(`mcp-inspector:chat:ready`,{capabilities:{send:!0,clear:!0,getState:!0,setQuickQuestions:!0,setFollowups:!0,loadMessages:!0}})},[Ne]),(0,G.useEffect)(()=>{Ne(`mcp-inspector:chat:state_changed`,{isLoading:he,messageCount:H.length,messages:Me(),quickQuestions:k,followups:j})},[j,Me,he,H.length,Ne,k]),(0,G.useEffect)(()=>{let e=e=>{if(!e.data||typeof e.data!=`object`)return;let n=e.data;if(!n.type?.startsWith(`mcp-inspector:chat:`)||n.serverId&&n.serverId!==a)return;let r=n.requestId,i=(e,t={})=>{Ne(`mcp-inspector:chat:command_result`,{requestId:r,ok:e,...t})};if(n.type===`mcp-inspector:chat:send`){let e=(n.message??n.prompt??``).trim();if(!e){i(!1,{error:`Missing message`});return}if(!ue||!t){i(!1,{error:`Chat is not ready to send messages`});return}_e(e,[]).then(()=>{Ne(`mcp-inspector:chat:message_sent`,{requestId:r,message:e,source:`bridge`}),i(!0)}).catch(e=>{i(!1,{error:e instanceof Error?e.message:String(e)})});return}if(n.type===`mcp-inspector:chat:clear`){ve(),Ne(`mcp-inspector:chat:cleared`,{requestId:r}),i(!0);return}if(n.type===`mcp-inspector:chat:get_state`){Ne(`mcp-inspector:chat:state`,{requestId:r,isLoading:he,messageCount:H.length,messages:Me(),quickQuestions:k,followups:j}),i(!0);return}if(n.type===`mcp-inspector:chat:set_quick_questions`){let e=Ae(n.questions);A(e),i(!0,{quickQuestions:e});return}if(n.type===`mcp-inspector:chat:set_followups`){let e=Ae(n.followups);M(e),i(!0,{followups:e});return}if(n.type===`mcp-inspector:chat:load_messages`){let e=n.messages;if(!Array.isArray(e)){i(!1,{error:`messages must be an array`});return}ye(e),i(!0,{count:e.length});return}};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[ve,ye,j,Me,he,H.length,Ne,k,Ae,_e,a,ue,t]),TF(r?{onNewChat:ve}:{});let Pe=(0,G.useCallback)(()=>{O(-1),E(!1),I.current=null},[]),Fe=(0,G.useCallback)(()=>{if(!F.current)return;let e=F.current.selectionStart,t=C.slice(0,e),n=ybe.test(t);E(n),n?(I.current={start:e-1,end:e},O(0)):Pe()},[C,Pe]);(0,G.useEffect)(()=>{ue&&H.length===0&&F.current&&F.current.focus()},[ue,H.length]),(0,G.useEffect)(()=>{!he&&H.length>0&&F.current&&F.current.focus()},[he,H.length]),(0,G.useEffect)(()=>{F.current&&Fe()},[C,Fe]);let Ie=(0,G.useCallback)(()=>{Ce(null),Te({}),Pe()},[Pe]),Le=(0,G.useCallback)(async e=>{if(Ce(e),e.arguments&&e.arguments.length>0){Ce(null),xv.error(`Prompts with arguments are not supported`,{description:`This prompt requires arguments which are not yet supported in chat mode.`});return}try{await Ee(e,{})}catch(e){console.error(`Error executing prompt`,e)}finally{if(F.current&&I.current){let{start:e,end:t}=I.current;w(C.slice(0,e)+C.slice(t)),requestAnimationFrame(()=>{F.current?.focus(),F.current?.setSelectionRange(e,e)})}Ie()}},[Ee,Ie,C]),Re=(0,G.useCallback)(()=>{(C.trim()||De.length>0||ge.length>0)&&(_e(C,De),w(``),ke())},[C,De,_e,ke,ge]),ze=(0,G.useCallback)(e=>{if(e.key===`ArrowDown`)O(e=>Se.length===0?-1:(e+1)%Se.length);else if(e.key===`ArrowUp`)O(e=>Se.length===0?-1:(e-1+Se.length)%Se.length);else if(e.key===`Escape`)e.stopPropagation(),Pe();else if(e.key===`Enter`&&D>=0){let e=Se[D];e&&Le(e)}},[Se,D,Le,Pe]),Be=(0,G.useCallback)(e=>{bbe.includes(e.key)&&T?(e.preventDefault(),ze(e)):e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Re())},[Re,ze,T]),Ve=(0,G.useCallback)(e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&Fe()},[Fe]),He=(0,G.useCallback)(()=>{le(),ve()},[le,ve]),Ue=(0,G.useCallback)(e=>{e.trim()&&(!ue||!t||_e(e,[]).then(()=>{Ne(`mcp-inspector:chat:message_sent`,{message:e,source:`quick_question`})}))},[Ne,_e,ue,t]),W=(0,G.useCallback)(e=>{e.trim()&&(!ue||!t||_e(e,[]).then(()=>{Ne(`mcp-inspector:chat:message_sent`,{message:e,source:`followup`})}))},[Ne,_e,ue,t]);return ue&&H.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col h-full`,children:[!de&&(0,K.jsx)(`div`,{className:`absolute top-4 right-4 z-10`,children:(0,K.jsx)($I,{open:R,onOpenChange:z,tempProvider:ne,tempModel:oe,tempApiKey:ie,onProviderChange:re,onModelChange:se,onApiKeyChange:ae,onSave:ce,onClear:He,showClearButton:!0,buttonLabel:`Change API Key`})}),(0,K.jsx)(PL,{mcpServerUrl:e.url,inputValue:C,isConnected:t,isLoading:he,textareaRef:F,llmConfig:ue,promptsDropdownOpen:T,promptFocusedIndex:D,prompts:Se,selectedPrompt:we,promptResults:De,attachments:ge,tools:b?void 0:L,disabledTools:b?void 0:N,onDisabledToolsChange:b?void 0:P,onDeletePromptResult:Oe,onPromptSelect:Le,onInputChange:w,onKeyDown:Be,onKeyUp:Ve,onClick:Fe,onSubmit:e=>{e.preventDefault(),Re()},onConfigDialogOpenChange:z,onAttachmentAdd:be,onAttachmentRemove:xe,hideModelBadge:m,hideServerUrl:h,quickQuestions:k,onQuickQuestionSelect:Ue})]}):(0,K.jsxs)(`div`,{className:`flex flex-col h-full relative`,children:[(0,K.jsx)(eL,{llmConfig:ue,hasMessages:H.length>0,configDialogOpen:de?!1:R,onConfigDialogOpenChange:de?()=>{}:z,onClearChat:ve,tempProvider:ne,tempModel:oe,tempApiKey:ie,onProviderChange:re,onModelChange:se,onApiKeyChange:ae,onSaveConfig:ce,onClearConfig:He,hideConfigButton:de,clearButtonLabel:f,hideTitle:p,clearButtonHideIcon:g,clearButtonHideShortcut:_,clearButtonVariant:v,hideClearButton:y}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto p-2 sm:p-4 pt-[80px] sm:pt-[100px]`,children:ue?(0,K.jsx)(ime,{messages:H,isLoading:he,serverId:e.url,readResource:s,tools:e.tools,sendMessage:(e,t)=>_e(e,[],t),serverBaseUrl:e.url}):(0,K.jsx)(FL,{onConfigureClick:()=>z(!0)})}),ue&&(0,K.jsx)(ML,{inputValue:C,isConnected:t,isLoading:he,textareaRef:F,promptsDropdownOpen:T,promptFocusedIndex:D,prompts:Se,promptResults:De,selectedPrompt:we,attachments:ge,tools:b?void 0:L,disabledTools:b?void 0:N,onDisabledToolsChange:b?void 0:P,onDeletePromptResult:Oe,onPromptSelect:Le,onInputChange:w,onKeyDown:Be,onKeyUp:Ve,onClick:Fe,onSendMessage:Re,onStopStreaming:U,onAttachmentAdd:be,onAttachmentRemove:xe,followups:j,onFollowupSelect:W})]})}var xbe=r({Group:()=>y7,Panel:()=>S7,Separator:()=>C7,isCoarsePointer:()=>w5,useDefaultLayout:()=>Jbe,useGroupCallbackRef:()=>Xbe,useGroupRef:()=>Zbe,usePanelCallbackRef:()=>exe,usePanelRef:()=>txe});function Sbe(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function Cbe(e,t){let n=getComputedStyle(e.ownerDocument.body);return t*parseFloat(n.fontSize)}function wbe(e){return e/100*window.innerHeight}function Tbe(e){return e/100*window.innerWidth}function Ebe(e){switch(typeof e){case`number`:return[e,`px`];case`string`:{let t=parseFloat(e);return e.endsWith(`%`)?[t,`%`]:e.endsWith(`px`)?[t,`px`]:e.endsWith(`rem`)?[t,`rem`]:e.endsWith(`em`)?[t,`em`]:e.endsWith(`vh`)?[t,`vh`]:e.endsWith(`vw`)?[t,`vw`]:[t,`%`]}}}function h5({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=Ebe(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=Cbe(t,i);break;case`em`:r=Sbe(t,i);break;case`vh`:r=wbe(i);break;case`vw`:r=Tbe(i);break}return r}function g5(e){return parseFloat(e.toFixed(3))}function _5({group:e}){let{orientation:t,panels:n}=e;return n.reduce((e,n)=>(e+=t===`horizontal`?n.element.offsetWidth:n.element.offsetHeight,e),0)}function v5(e){let{panels:t}=e,n=_5({group:e});return n===0?t.map(e=>({collapsedSize:0,collapsible:e.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:e.panelConstraints.disabled,minSize:0,maxSize:100,panelId:e.id})):t.map(e=>{let{element:t,panelConstraints:r}=e,i=0;r.collapsedSize!==void 0&&(i=g5(h5({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=g5(h5({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=g5(h5({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=g5(h5({groupSize:n,panelElement:t,styleProp:r.maxSize})/n*100)),{collapsedSize:i,collapsible:r.collapsible===!0,defaultSize:a,disabled:r.disabled,minSize:o,maxSize:s,panelId:e.id}})}function y5(e,t=`Assertion error`){if(!e)throw Error(t)}function b5(e,t){return Array.from(t).sort(e===`horizontal`?Dbe:Obe)}function Dbe(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function Obe(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function x5(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function S5(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function kbe({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},i,a=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=S5(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return y5(i,`No rect found`),i}var C5;function w5(){return C5===void 0&&(C5=typeof matchMedia==`function`?!!matchMedia(`(pointer:coarse)`).matches:!1),C5}function T5(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=b5(n,Array.from(t.children).filter(x5).map(e=>({element:e}))).map(({element:e})=>e),o=[],s=!1,c=!1,l=-1,u=-1,d=0,f,p=[];{let e=-1;for(let t of a)t.hasAttribute(`data-panel`)&&(e++,t.ariaDisabled===null&&(d++,l===-1&&(l=e),u=e))}if(d>1){let t=-1;for(let d of a)if(d.hasAttribute(`data-panel`)){t++;let i=r.find(e=>e.element===d);if(i){if(f){let r=f.element.getBoundingClientRect(),a=d.getBoundingClientRect(),m;if(c){let e=n===`horizontal`?new DOMRect(r.right,r.top,0,r.height):new DOMRect(r.left,r.bottom,r.width,0),t=n===`horizontal`?new DOMRect(a.left,a.top,0,a.height):new DOMRect(a.left,a.top,a.width,0);switch(p.length){case 0:m=[e,t];break;case 1:{let i=p[0];m=[i,kbe({orientation:n,rects:[r,a],targetRect:i.element.getBoundingClientRect()})===r?t:e];break}default:m=p;break}}else m=p.length?p:[n===`horizontal`?new DOMRect(r.right,a.top,a.left-r.right,a.height):new DOMRect(a.left,r.bottom,a.width,a.top-r.bottom)];for(let n of m){let r=`width`in n?n:n.element.getBoundingClientRect(),a=w5()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(r.width<a){let e=a-r.width;r=new DOMRect(r.x-e/2,r.y,r.width+e,r.height)}if(r.height<a){let e=a-r.height;r=new DOMRect(r.x,r.y-e/2,r.width,r.height+e)}!s&&!(t<=l||t>u)&&o.push({group:e,groupSize:_5({group:e}),panels:[f,i],separator:`width`in n?void 0:n,rect:r}),s=!1}}c=!1,f=i,p=[]}}else if(d.hasAttribute(`data-separator`)){d.ariaDisabled!==null&&(s=!0);let e=i.find(e=>e.element===d);e?p.push(e):(f=void 0,p=[])}else c=!0}return o}var Abe=class{#e={};addListener(e,t){let n=this.#e[e];return n===void 0?this.#e[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#e[e];if(n!==void 0)if(n.length===1)n[0].call(null,t);else{let e=!1,r=null,i=Array.from(n);for(let n=0;n<i.length;n++){let a=i[n];try{a.call(null,t)}catch(t){r===null&&(e=!0,r=t)}}if(e)throw r}}removeAllListeners(){this.#e={}}removeListener(e,t){let n=this.#e[e];if(n!==void 0){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}};function E5(e,t,n=0){return Math.abs(g5(e)-g5(t))<=n}var D5={cursorFlags:0,interactionState:{state:`inactive`},mountedGroups:new Map},O5=new Abe;function k5(){return D5}function A5(e){let t=typeof e==`function`?e(D5):e;if(D5===t)return D5;let n=D5;return D5={...D5,...t},t.cursorFlags!==void 0&&O5.emit(`cursorFlagsChange`,D5.cursorFlags),t.interactionState!==void 0&&O5.emit(`interactionStateChange`,D5.interactionState),t.mountedGroups!==void 0&&(D5.mountedGroups.forEach((e,t)=>{e.derivedPanelConstraints.forEach(r=>{if(r.collapsible){let{layout:i}=n.mountedGroups.get(t)??{};if(i){let n=E5(r.collapsedSize,e.layout[r.panelId]),a=E5(r.collapsedSize,i[r.panelId]);n&&!a&&(t.inMemoryLastExpandedPanelSizes[r.panelId]=i[r.panelId])}}})}),O5.emit(`mountedGroupsChange`,D5.mountedGroups)),D5}function jbe(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=S5(n,a.rect);switch(e){case`horizontal`:t.x<=i.x&&(r=a,i=t);break;case`vertical`:t.y<=i.y&&(r=a,i=t);break}}return r?{distance:i,hitRegion:r}:void 0}function Mbe(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Nbe(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:N5(e),b:N5(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();y5(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:M5(j5(n.a)),b:M5(j5(n.b))};if(i.a===i.b){let e=r.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let n=e[i];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(i.a-i.b)}var Pbe=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Fbe(e){let t=getComputedStyle(P5(e)??e).display;return t===`flex`||t===`inline-flex`}function Ibe(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||Fbe(e))||+t.opacity<1||`transform`in t&&t.transform!==`none`||`webkitTransform`in t&&t.webkitTransform!==`none`||`mixBlendMode`in t&&t.mixBlendMode!==`normal`||`filter`in t&&t.filter!==`none`||`webkitFilter`in t&&t.webkitFilter!==`none`||`isolation`in t&&t.isolation===`isolate`||Pbe.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function j5(e){let t=e.length;for(;t--;){let n=e[t];if(y5(n,`Missing node`),Ibe(n))return n}return null}function M5(e){return e&&Number(getComputedStyle(e).zIndex)||0}function N5(e){let t=[];for(;e;)t.push(e),e=P5(e);return t}function P5(e){let{parentNode:t}=e;return Mbe(t)?t.host:t}function Lbe(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Rbe({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!x5(n)||n.contains(e)||e.contains(n))return!0;if(Nbe(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(Lbe(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function F5(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=T5(r),a=jbe(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&Rbe({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function zbe(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function I5(e,t){return E5(e,t)?0:e>t?1:-1}function L5({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){let{collapsedSize:i=0,collapsible:a,disabled:o,maxSize:s=100,minSize:c=0}=t;if(o&&!e)return n;if(I5(r,c)<0)if(a){let e=(i+c)/2;r=I5(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=g5(r),r}function R5({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(E5(e,0))return t;let o=a===`imperative-api`,s=Object.values(t),c=Object.values(i),l=[...s],[u,d]=r;y5(u!=null,`Invalid first pivot index`),y5(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];y5(r,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(y5(n!=null,`Previous layout not found for panel index ${t}`),E5(n,i)){let t=o-n;I5(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];y5(r,`No panel constraints found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(y5(n!=null,`Previous layout not found for panel index ${t}`),E5(n,o)){let t=n-i;I5(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];y5(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsible:a,collapsedSize:o,minSize:c}=r;if(a&&I5(i,c)<0)if(e>0){let t=c-o,n=t/2;I5(i+e,c)<0&&(e=I5(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;I5(i-e,c)<0&&(e=I5(100+e,n)>0?0:-t)}break}}{let t=e<0?1:-1,r=e<0?d:u,i=0;for(;;){let e=s[r];y5(e!=null,`Previous layout not found for panel index ${r}`);let a=L5({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:e,size:100})-e;if(i+=a,r+=t,r<0||r>=n.length)break}let a=Math.min(Math.abs(e),Math.abs(i));e=e<0?0-a:a}{let t=e<0?u:d;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(f),i=s[t];y5(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=L5({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!E5(i,c)&&(f+=i-c,l[t]=c,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(zbe(c,l))return i;{let t=e<0?d:u,r=s[t];y5(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=L5({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!E5(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];y5(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=L5({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(E5(i,s)||(t-=s-i,l[r]=s),E5(t,0))break;e>0?r--:r++}}}if(!E5(Object.values(l).reduce((e,t)=>t+e,0),100,.1))return i;let p=Object.keys(i);return l.reduce((e,t,n)=>(e[p[n]]=t,e),{})}function z5(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||I5(e[n],t[n])!==0)return!1;return!0}function B5({layout:e,panelConstraints:t}){let n=Object.values(e),r=[...n],i=r.reduce((e,t)=>e+t,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(e=>`${e}%`).join(`, `)}`);if(!E5(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];y5(t!=null,`No layout data found for index ${e}`),r[e]=100/i*t}let a=0;for(let e=0;e<t.length;e++){let i=n[e];y5(i!=null,`No layout data found for index ${e}`);let o=r[e];y5(o!=null,`No layout data found for index ${e}`);let s=L5({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!E5(a,0))for(let e=0;e<t.length;e++){let n=r[e];y5(n!=null,`No layout data found for index ${e}`);let i=n+a,o=L5({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,E5(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function V5({groupId:e,panelId:t}){let n=()=>{let{mountedGroups:t}=k5();for(let[n,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:a,separatorToPanels:o}]of t)if(n.id===e)return{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:n,layout:a,separatorToPanels:o};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedPanelConstraints.find(e=>e.panelId===t);if(e!==void 0)return e;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{let e=n().group.panels.find(e=>e.id===t);if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},a=()=>{let e=n().layout[t];if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},o=e=>{let r=a();if(e===r)return;let{defaultLayoutDeferred:i,derivedPanelConstraints:o,group:s,layout:c,separatorToPanels:l}=n(),u=s.panels.findIndex(e=>e.id===t),d=u===s.panels.length-1,f=B5({layout:R5({delta:d?r-e:e-r,initialLayout:c,panelConstraints:o,pivotIndices:d?[u-1,u]:[u,u+1],prevLayout:c,trigger:`imperative-api`}),panelConstraints:o});z5(c,f)||A5(e=>({mountedGroups:new Map(e.mountedGroups).set(s,{defaultLayoutDeferred:i,derivedPanelConstraints:o,layout:f,separatorToPanels:l})}))};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=i(),s=a();e&&s!==t&&(n.expandToSize=s,o(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:s}=i(),c=a();if(e&&c===t){let e=s.expandToSize??n;e===0&&(e=1),o(e)}},getSize:()=>{let{group:e}=n(),t=a(),{element:r}=i();return{asPercentage:t,inPixels:e.orientation===`horizontal`?r.offsetWidth:r.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=a();return e&&E5(t,n)},resize:e=>{if(a()!==e){let t;switch(typeof e){case`number`:{let{group:r}=n();t=g5(e/_5({group:r})*100);break}case`string`:t=parseFloat(e);break}o(t)}}}}function H5(e){if(e.defaultPrevented)return;let{mountedGroups:t}=k5();F5(e,t).forEach(t=>{if(t.separator){let n=t.panels.find(e=>e.panelConstraints.defaultSize!==void 0);if(n){let r=n.panelConstraints.defaultSize,i=V5({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function U5(e){let{mountedGroups:t}=k5();for(let[n]of t)if(n.separators.some(t=>t.element===e))return n;throw Error(`Could not find parent Group for separator element`)}function W5({groupId:e}){let t=()=>{let{mountedGroups:t}=k5();for(let[n,r]of t)if(n.id===e)return{group:n,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{defaultLayoutDeferred:n,derivedPanelConstraints:r,group:i,layout:a,separatorToPanels:o}=t(),s=B5({layout:e,panelConstraints:r});if(n)return a;if(!z5(a,s)){A5(e=>({mountedGroups:new Map(e.mountedGroups).set(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,layout:s,separatorToPanels:o})}));let e=i.panels.map(({id:e})=>e).join(`,`);i.inMemoryLayouts[e]=s}return s}}}function G5(e){let{mountedGroups:t}=k5(),n=t.get(e);return y5(n,`Mounted Group ${e.id} not found`),n}function K5(e,t){let n=U5(e),r=G5(n),i=n.separators.find(t=>t.element===e);y5(i,`Matching separator not found`);let a=r.separatorToPanels.get(i);y5(a,`Matching panels not found`);let o=a.map(e=>n.panels.indexOf(e)),s=W5({groupId:n.id}).getLayout(),c=B5({layout:R5({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});z5(s,c)||A5(e=>({mountedGroups:new Map(e.mountedGroups).set(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,layout:c,separatorToPanels:r.separatorToPanels})}))}function q5(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=U5(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&K5(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&K5(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&K5(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&K5(t,-5);break;case`End`:e.preventDefault(),K5(t,100);break;case`Enter`:{e.preventDefault();let n=U5(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=G5(n),o=n.separators.find(e=>e.element===t);y5(o,`Matching separator not found`);let s=a.get(o);y5(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.panelId===c.id);if(y5(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];K5(t,(l.collapsedSize===e?n.inMemoryLastExpandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=U5(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);y5(r!==null,`Index not found`),n[e.shiftKey?r>0?r-1:n.length-1:r+1<n.length?r+1:0].focus();break}case`Home`:e.preventDefault(),K5(t,-100);break}}function J5(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let{mountedGroups:t}=k5(),n=F5(e,t),r=new Map,i=!1;n.forEach(e=>{e.separator&&(i||(i=!0,e.separator.element.focus()));let n=t.get(e.group);n&&r.set(e.group,n.layout)}),A5({interactionState:{hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}}),n.length&&e.preventDefault()}var Bbe=e=>e,Y5=()=>{},X5=1,Z5=2,Q5=4,$5=8,e7=3,t7=12,n7;function r7(){return n7===void 0&&(n7=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(n7=!0)),n7}function Vbe({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case`active`:case`hover`:t.forEach(e=>{if(!e.disableCursor)switch(e.orientation){case`horizontal`:r++;break;case`vertical`:i++;break}})}if(!(r===0&&i===0)){switch(n){case`active`:if(e&&r7()){let t=(e&X5)!==0,n=(e&Z5)!==0,r=(e&Q5)!==0,i=(e&$5)!==0;if(t)return r?`se-resize`:i?`ne-resize`:`e-resize`;if(n)return r?`sw-resize`:i?`nw-resize`:`w-resize`;if(r)return`s-resize`;if(i)return`n-resize`}break}return r7()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var i7=new WeakMap;function a7(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=i7.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets.push(n));let{cursorFlags:r,interactionState:i}=k5();switch(i.state){case`active`:case`hover`:{let e=Vbe({cursorFlags:r,groups:i.hitRegions.map(e=>e.group),state:i.state}),a=`*, *:hover {cursor: ${e} !important; }`;if(t===a)return;t=a,e?n.cssRules.length===0?n.insertRule(a):n.replaceSync(a):n.cssRules.length===1&&n.deleteRule(0);break}case`inactive`:t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}i7.set(e,{prevStyle:t,styleSheet:n})}function o7({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:a,prevCursorFlags:o}){let s=0,c=new Map(i);n.forEach(e=>{let{group:n,groupSize:o}=e,{disableCursor:l,orientation:u,panels:d}=n,f=0;f=a?u===`horizontal`?(t.clientX-a.x)/o*100:(t.clientY-a.y)/o*100:u===`horizontal`?t.clientX<0?-100:100:t.clientY<0?-100:100;let p=r.get(n),{defaultLayoutDeferred:m,derivedPanelConstraints:h,layout:g,separatorToPanels:_}=i.get(n)??{defaultLayoutDeferred:!1};if(h&&p&&g&&_){let t=R5({delta:f,initialLayout:p,panelConstraints:h,pivotIndices:e.panels.map(e=>d.indexOf(e)),prevLayout:g,trigger:`mouse-or-touch`});if(z5(t,g)){if(f!==0&&!l)switch(u){case`horizontal`:s|=f<0?X5:Z5;break;case`vertical`:s|=f<0?Q5:$5;break}}else{c.set(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,layout:t,separatorToPanels:_});let n=e.group.panels.map(({id:e})=>e).join(`,`);e.group.inMemoryLayouts[n]=t}}});let l=0;t.movementX===0?l|=o&e7:l|=s&e7,t.movementY===0?l|=o&t7:l|=s&t7,A5({cursorFlags:l,mountedGroups:c}),a7(e)}function s7(e){let{cursorFlags:t,interactionState:n,mountedGroups:r}=k5();switch(n.state){case`active`:o7({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:r,prevCursorFlags:t})}}function c7(e){if(e.defaultPrevented)return;let{cursorFlags:t,interactionState:n,mountedGroups:r}=k5();switch(n.state){case`active`:if(e.buttons===0){A5(e=>e.interactionState.state===`inactive`?e:{cursorFlags:0,interactionState:{state:`inactive`}}),A5(e=>({mountedGroups:new Map(e.mountedGroups)}));return}o7({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:r,pointerDownAtPoint:n.pointerDownAtPoint,prevCursorFlags:t});break;default:{let t=F5(e,r);t.length===0?n.state!==`inactive`&&A5({interactionState:{state:`inactive`}}):A5({interactionState:{hitRegions:t,state:`hover`}}),a7(e.currentTarget);break}}}function l7(e){if(e.relatedTarget instanceof HTMLIFrameElement){let{interactionState:e}=k5();switch(e.state){case`hover`:A5({interactionState:{state:`inactive`}})}}}function u7(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let{interactionState:t}=k5();switch(t.state){case`active`:A5({cursorFlags:0,interactionState:{state:`inactive`}}),t.hitRegions.length>0&&(a7(e.currentTarget),A5(e=>({mountedGroups:new Map(e.mountedGroups)})),e.preventDefault())}}function d7(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=g5(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=g5((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function Hbe(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=_5({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:g5(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function Ube(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function Wbe(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}var f7=new Map;function Gbe(e){let t=!0;y5(e.element.ownerDocument.defaultView,`Cannot register an unmounted Group`);let n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,a=new n(n=>{for(let r of n){let{borderBoxSize:n,target:i}=r;if(i===e.element){if(t){if(_5({group:e})===0)return;A5(t=>{let n=t.mountedGroups.get(e);if(n){let r=v5(e),i=n.defaultLayoutDeferred?d7(r):n.layout,a=B5({layout:i,panelConstraints:r});return!n.defaultLayoutDeferred&&z5(i,a)&&Ube(n.derivedPanelConstraints,r)?t:{mountedGroups:new Map(t.mountedGroups).set(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,layout:a,separatorToPanels:n.separatorToPanels})}}return t})}}else Hbe(e,i,n)}});a.observe(e.element),e.panels.forEach(e=>{y5(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&a.observe(e.element)});let o=_5({group:e}),s=v5(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.defaultLayout;l&&(Wbe(e.panels,l)||(l=void 0));let u=B5({layout:e.inMemoryLayouts[c]??l??d7(s),panelConstraints:s}),d=T5(e),f=e.element.ownerDocument;return A5(t=>{let n=new Map;return f7.set(f,(f7.get(f)??0)+1),d.forEach(e=>{e.separator&&n.set(e.separator,e.panels)}),{mountedGroups:new Map(t.mountedGroups).set(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:s,layout:u,separatorToPanels:n})}}),e.separators.forEach(e=>{y5(!i.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),i.add(e.id),e.element.addEventListener(`keydown`,q5)}),f7.get(f)===1&&(f.addEventListener(`dblclick`,H5,!0),f.addEventListener(`pointerdown`,J5,!0),f.addEventListener(`pointerleave`,s7),f.addEventListener(`pointermove`,c7),f.addEventListener(`pointerout`,l7),f.addEventListener(`pointerup`,u7,!0)),function(){t=!1,f7.set(f,Math.max(0,(f7.get(f)??0)-1)),A5(t=>{let n=new Map(t.mountedGroups);return n.delete(e),{mountedGroups:n}}),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,q5)}),f7.get(f)||(f.removeEventListener(`dblclick`,H5,!0),f.removeEventListener(`pointerdown`,J5,!0),f.removeEventListener(`pointerleave`,s7),f.removeEventListener(`pointermove`,c7),f.removeEventListener(`pointerout`,l7),f.removeEventListener(`pointerup`,u7,!0)),a.disconnect()}}function Kbe(){let[e,t]=(0,G.useState)({});return[e,(0,G.useCallback)(()=>t({}),[])]}function p7(e){let t=(0,G.useId)();return`${e??t}`}var m7=typeof window<`u`?G.useLayoutEffect:G.useEffect;function h7(e){let t=(0,G.useRef)(e);return m7(()=>{t.current=e},[e]),(0,G.useCallback)((...e)=>t.current?.(...e),[t])}function g7(...e){return h7(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function _7(e){let t=(0,G.useRef)({...e});return m7(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var v7=(0,G.createContext)(null);function qbe(e,t){let n=(0,G.useRef)({getLayout:()=>({}),setLayout:Bbe});(0,G.useImperativeHandle)(t,()=>n.current,[]),m7(()=>{Object.assign(n.current,W5({groupId:e}))})}function y7({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:o,id:s,onLayoutChange:c,onLayoutChanged:l,orientation:u=`horizontal`,resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){let m=(0,G.useRef)({onLayoutChange:{},onLayoutChanged:{}}),h=h7(e=>{z5(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=h7(e=>{z5(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e))}),_=p7(s),v=(0,G.useRef)(null),[y,b]=Kbe(),x=(0,G.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=g7(v,a);qbe(_,o);let C=h7((e,t)=>{let{interactionState:r,mountedGroups:i}=k5();for(let n of i.keys())if(n.id===e){let e=i.get(n);if(e){let i=!1;switch(r.state){case`active`:i=r.hitRegions.some(e=>e.group===n);break}return{flexGrow:e.layout[t]??1,pointerEvents:i?`none`:void 0}}}return{flexGrow:n?.[t]??1}}),w=_7({defaultLayout:n,disableCursor:r}),T=(0,G.useMemo)(()=>({get disableCursor(){return!!w.disableCursor},getPanelStyles:C,id:_,orientation:u,registerPanel:e=>{let t=x.current;return t.panels=b5(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=b5(u,[...t.separators,e]),b(),()=>{t.separators=t.separators.filter(t=>t!==e),b()}},togglePanelDisabled:(e,t)=>{let n=x.current.panels.find(t=>t.id===e);n&&(n.panelConstraints.disabled=t);let{mountedGroups:r}=k5();for(let e of r.keys())if(e.id===_){let t=r.get(e);t&&(t.derivedPanelConstraints=v5(e))}},toggleSeparatorDisabled:(e,t)=>{let n=x.current.separators.find(t=>t.id===e);n&&(n.disabled=t)}}),[C,_,b,u,w]),E=(0,G.useRef)(null);return m7(()=>{let e=v.current;if(e===null)return;let t=x.current,n;if(w.defaultLayout!==void 0&&Object.keys(w.defaultLayout).length===t.panels.length){n={};for(let e of t.panels){let t=w.defaultLayout[e.id];t!==void 0&&(n[e.id]=t)}}let r={defaultLayout:n,disableCursor:!!w.disableCursor,disabled:!!i,element:e,id:_,inMemoryLastExpandedPanelSizes:x.current.lastExpandedPanelSizes,inMemoryLayouts:x.current.layouts,orientation:u,panels:t.panels,resizeTargetMinimumSize:t.resizeTargetMinimumSize,separators:t.separators};E.current=r;let a=Gbe(r),o=k5().mountedGroups.get(r);if(o){let{defaultLayoutDeferred:e,derivedPanelConstraints:t,layout:n}=o;!e&&t.length>0&&(h(n),g(n))}let s=O5.addListener(`interactionStateChange`,e=>{e.state}),c=O5.addListener(`mountedGroupsChange`,e=>{let t=e.get(r);if(t){let{defaultLayoutDeferred:e,derivedPanelConstraints:n,layout:r}=t;if(e||n.length===0)return;let{interactionState:i}=k5(),a=i.state!==`active`;h(r),a&&g(r)}});return()=>{E.current=null,a(),s(),c()}},[i,_,g,h,u,y,w]),(0,G.useEffect)(()=>{let e=E.current;e&&(e.defaultLayout=n,e.disableCursor=!!r)}),(0,K.jsx)(v7.Provider,{value:T,children:(0,K.jsx)(`div`,{...p,className:t,"data-group":!0,"data-testid":_,id:_,ref:S,style:{height:`100%`,width:`100%`,overflow:`hidden`,...f,display:`flex`,flexDirection:u===`horizontal`?`row`:`column`,flexWrap:`nowrap`,touchAction:u===`horizontal`?`pan-y`:`pan-x`},children:e})})}y7.displayName=`Group`;function b7(e,t){return`react-resizable-panels:${[e,...t].join(`:`)}`}function Jbe({debounceSaveMs:e=100,panelIds:t,storage:n=localStorage,...r}){let i=t!==void 0,a=`id`in r?r.id:r.groupId,o=b7(a,t??[]),s=(0,G.useSyncExternalStore)(Ybe,()=>n.getItem(o),()=>n.getItem(o)),c=(0,G.useMemo)(()=>s?JSON.parse(s):void 0,[s]),l=(0,G.useRef)(null),u=(0,G.useCallback)(()=>{let e=l.current;e&&(l.current=null,clearTimeout(e))},[]);(0,G.useLayoutEffect)(()=>()=>{u()},[u]);let d=(0,G.useCallback)(e=>{u();let t;t=i?b7(a,Object.keys(e)):b7(a,[]);try{n.setItem(t,JSON.stringify(e))}catch(e){console.error(e)}},[u,i,a,n]);return{defaultLayout:c,onLayoutChange:(0,G.useCallback)(t=>{u(),e===0?d(t):l.current=setTimeout(()=>{d(t)},e)},[u,e,d]),onLayoutChanged:d}}function Ybe(){return function(){}}function Xbe(){return(0,G.useState)(null)}function Zbe(){return(0,G.useRef)(null)}function x7(){let e=(0,G.useContext)(v7);return y5(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function Qbe(e,t){let{id:n}=x7(),r=(0,G.useRef)({collapse:Y5,expand:Y5,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Y5});(0,G.useImperativeHandle)(t,()=>r.current,[]),m7(()=>{Object.assign(r.current,V5({groupId:n,panelId:e}))})}function S7({children:e,className:t,collapsedSize:n=`0%`,collapsible:r=!1,defaultSize:i,disabled:a,elementRef:o,id:s,maxSize:c=`100%`,minSize:l=`0%`,onResize:u,panelRef:d,style:f,...p}){let m=!!s,h=p7(s),g=_7({disabled:a}),_=(0,G.useRef)(null),v=g7(_,o),{getPanelStyles:y,id:b,orientation:x,registerPanel:S,togglePanelDisabled:C}=x7(),w=u!==null,T=h7((e,t,n)=>{u?.(e,s,n)});m7(()=>{let e=_.current;if(e!==null)return S({element:e,id:h,idIsStable:m,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:w?T:void 0,panelConstraints:{collapsedSize:n,collapsible:r,defaultSize:i,disabled:g.disabled,maxSize:c,minSize:l}})},[n,r,i,w,h,m,c,l,T,S,g]),(0,G.useEffect)(()=>{C(h,!!a)},[a,h,C]),Qbe(h,d);let E=(0,G.useSyncExternalStore)(e=>(O5.addListener(`mountedGroupsChange`,e),()=>{O5.removeListener(`mountedGroupsChange`,e)}),()=>JSON.stringify(y(b,h)),()=>JSON.stringify(y(b,h)));return(0,K.jsx)(`div`,{...p,"aria-disabled":a||void 0,"data-panel":!0,"data-testid":h,id:h,ref:v,style:{...$be,display:`flex`,flexBasis:0,flexShrink:1,overflow:`hidden`,...JSON.parse(E)},children:(0,K.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,...f,touchAction:x===`horizontal`?`pan-y`:`pan-x`},children:e})})}S7.displayName=`Panel`;var $be={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function exe(){return(0,G.useState)(null)}function txe(){return(0,G.useRef)(null)}function nxe({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,a,o=e[n],s=t.find(e=>e.panelId===n);if(s){let c=s.maxSize,l=s.collapsible?s.collapsedSize:s.minSize,u=[r,r+1];a=B5({layout:R5({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=B5({layout:R5({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function C7({children:e,className:t,disabled:n,elementRef:r,id:i,style:a,...o}){let s=p7(i),c=_7({disabled:n}),[l,u]=(0,G.useState)({}),[d,f]=(0,G.useState)(`inactive`),p=(0,G.useRef)(null),m=g7(p,r),{disableCursor:h,id:g,orientation:_,registerSeparator:v,toggleSeparatorDisabled:y}=x7(),b=_===`horizontal`?`vertical`:`horizontal`;m7(()=>{let e=p.current;if(e!==null){let t={disabled:c.disabled,element:e,id:s},n=v(t),r=O5.addListener(`interactionStateChange`,e=>{f(e.state!==`inactive`&&e.hitRegions.some(e=>e.separator===t)?e.state:`inactive`)}),i=O5.addListener(`mountedGroupsChange`,e=>{e.forEach(({derivedPanelConstraints:e,layout:n,separatorToPanels:r},i)=>{if(i.id===g){let a=r.get(t);if(a){let t=a[0],r=i.panels.indexOf(t);u(nxe({layout:n,panelConstraints:e,panelId:t.id,panelIndex:r}))}}})});return()=>{r(),i(),n()}}},[g,s,v,c]),(0,G.useEffect)(()=>{y(s,!!n)},[n,s,y]);let x;return n&&!h&&(x=`not-allowed`),(0,K.jsx)(`div`,{...o,"aria-controls":l.valueControls,"aria-disabled":n||void 0,"aria-orientation":b,"aria-valuemax":l.valueMax,"aria-valuemin":l.valueMin,"aria-valuenow":l.valueNow,children:e,className:t,"data-separator":n?`disabled`:d,"data-testid":s,id:s,ref:m,role:`separator`,style:{flexBasis:`auto`,cursor:x,...a,flexGrow:0,flexShrink:0,touchAction:`none`},tabIndex:n?void 0:0})}C7.displayName=`Separator`;var{usePanelRef:w7}=xbe;function T7({className:e,...t}){return(0,K.jsx)(y7,{"data-slot":`resizable-panel-group`,className:q(`flex h-full w-full aria-[orientation=vertical]:flex-col`,e),...t})}function E7({...e}){return(0,K.jsx)(S7,{"data-slot":`resizable-panel`,...e})}function D7({withHandle:e,className:t,...n}){return(0,K.jsx)(C7,{"data-slot":`resizable-handle`,className:q(`relative flex items-center justify-center bg-border`,`focus-visible:ring-ring focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden`,`after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2`,`aria-[orientation=vertical]:h-auto aria-[orientation=vertical]:w-px`,`aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full`,`aria-[orientation=vertical]:after:left-0 aria-[orientation=vertical]:after:h-1 aria-[orientation=vertical]:after:w-full aria-[orientation=vertical]:after:translate-x-0 aria-[orientation=vertical]:after:-translate-y-1/2`,`[&[aria-orientation=horizontal]>div]:rotate-90`,t),...n,children:e&&(0,K.jsx)(`div`,{className:`bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border`,children:(0,K.jsx)(Ch,{className:`size-2.5`})})})}function O7({className:e,...t}){return(0,K.jsx)(`kbd`,{"data-slot":`kbd`,className:q(`bg-muted text-muted-foreground pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none`,`[&_svg:not([class*='size-'])]:size-3`,`[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10`,e),...t})}function rxe({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:r,onSearchExpand:i,onSearchChange:a,onSearchBlur:o,onCancelAll:s,searchInputRef:c}){return(0,K.jsxs)(`div`,{className:`flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2`,children:[(0,K.jsx)(`div`,{className:`flex items-center gap-2 flex-1`,children:e?(0,K.jsx)(uy,{ref:c,placeholder:`Search requests...`,value:t,onChange:e=>a(e.target.value),onBlur:o,className:`h-8 border-gray-300 dark:border-zinc-600`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-medium text-gray-900 dark:text-gray-100`,"data-testid":`elicitation-tab-header`,children:`Elicitation`}),(0,K.jsx)(Aa,{className:`bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent`,variant:`outline`,children:n}),(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:i,className:`h-8 w-8 p-0`,children:(0,K.jsx)(Vh,{className:`h-4 w-4`})})}),(0,K.jsxs)(Im,{side:`bottom`,className:`flex gap-2`,children:[`Search`,(0,K.jsx)(O7,{children:`F`})]})]})]})}),(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:s,disabled:r===0,className:`h-8 w-8 p-0`,children:(0,K.jsx)(tg,{className:`h-4 w-4`})})}),(0,K.jsx)(Im,{side:`bottom`,children:`Cancel all`})]})})]})}function k7({id:e,isSelected:t,isFocused:n,icon:r,title:i,description:a,metadata:o,onClick:s,className:c,"data-testid":l}){return(0,K.jsx)(`button`,{id:e,"data-testid":l,type:`button`,onClick:s,className:q(`w-full text-left cursor-pointer p-2 sm:p-4 border-b dark:border-zinc-700 hover:bg-gray-50 dark:hover:bg-zinc-800/50 transition-colors group`,t&&`bg-zinc-50 dark:bg-zinc-800 border-l-4 border-l-zinc-500`,n&&`ring-2 ring-zinc-500 dark:ring-zinc-400 ring-inset`,c),children:(0,K.jsxs)(`div`,{className:`flex items-start gap-2 sm:gap-3`,children:[r&&(0,K.jsx)(`div`,{className:`flex-shrink-0 mt-1`,children:(0,K.jsx)(`div`,{className:q(`p-2.5 rounded-full transition-colors`,t?`bg-zinc-500 dark:bg-zinc-100/80 text-zinc-100 dark:text-zinc-900`:`bg-gray-100 dark:bg-zinc-700 text-gray-600 dark:text-gray-400 group-hover:bg-gray-200 dark:group-hover:bg-zinc-600`),children:r})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`flex items-center gap-2 mb-1`,children:(0,K.jsx)(`h3`,{className:q(`font-medium truncate font-mono text-sm`),children:i})}),a&&(0,K.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 line-clamp-2`,children:a})]}),o&&(0,K.jsx)(`div`,{className:`flex-shrink-0 flex items-center self-center`,children:o})]})})}function ixe({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:r,formatRelativeTime:i,listRef:a}){return e.length===0?(0,K.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:(0,K.jsx)(nm,{vertical:!0,noBorder:!0,message:`No elicitation requests`})}):(0,K.jsx)(`div`,{ref:a,className:`overflow-y-auto flex-1 overscroll-contain`,children:e.map((e,a)=>{let o=e.request.mode||`form`,s=o===`form`&&`requestedSchema`in e.request&&e.request.requestedSchema;return(0,K.jsx)(k7,{id:`elicitation-request-${e.id}`,"data-testid":`elicitation-request-item-${a}`,isSelected:t?.id===e.id,isFocused:r===a,title:(0,K.jsxs)(`span`,{className:`flex items-center gap-3`,children:[e.serverName,(0,K.jsx)(Aa,{variant:`outline`,className:o===`url`?`bg-blue-500/20 text-blue-600 dark:text-blue-400 border-blue-500/50`:`bg-green-500/20 text-green-600 dark:text-green-400 border-green-500/50`,children:o})]}),description:(()=>{let t=i(e.timestamp),n=[];return s&&n.push(`with schema`),o===`url`&&n.push(`external action`),t+(n.length>0?` | ${n.join(`, `)}`:``)})(),onClick:()=>n(e)},e.id)})})}function A7(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.const==`string`&&(t.title===void 0||typeof t.title==`string`)}function axe(e){let t=Array.isArray(e.oneOf)?e.oneOf.filter(A7):[],n=Array.isArray(e.anyOf)?e.anyOf.filter(A7):[];return t.length>0?t:n}function oxe(e){let t=e.items&&typeof e.items==`object`?e.items:{},n=Array.isArray(t.anyOf)?t.anyOf.filter(A7):[],r=Array.isArray(t.oneOf)?t.oneOf.filter(A7):[];return n.length>0?n:r}function sxe({request:e,onApprove:t,onReject:r,onClose:i,previewMode:a,onTogglePreview:o,isCopied:s,onCopy:c,onDownload:l,onFullscreen:u}){let[d,f]=(0,G.useState)({}),[p,m]=(0,G.useState)(!1),h=e?.request.mode||`form`,g=h===`form`,_=h===`url`;(0,G.useEffect)(()=>{if(e&&g&&`requestedSchema`in e.request){let t=e.request.requestedSchema,n={};if(t?.type===`object`&&t.properties)for(let[e,r]of Object.entries(t.properties)){let t=r;t.default===void 0?t.type===`array`?n[e]=[]:t.type===`boolean`?n[e]=!1:t.type===`number`||t.type===`integer`?n[e]=0:n[e]=``:n[e]=t.default}f(n)}m(!1)},[e?.id,g]);let v=(e,t)=>{f(n=>({...n,[e]:t}))},y=()=>{if(e){if(g){if(`requestedSchema`in e.request){let t=e.request.requestedSchema;if(t?.required){let e=t.required.filter(e=>d[e]===void 0||d[e]===``||d[e]===null);if(e.length>0){xv.error(`Missing required fields`,{description:`Please fill in: ${e.join(`, `)}`});return}}}t(e.id,{action:`accept`,content:d})}else _&&t(e.id,{action:`accept`});i(),B(()=>import(`./react-DDmrI2D-.js`).then(e=>n(e.default,1)).then(e=>{let t=xv(e.createElement(`div`,{className:`space-y-3`},e.createElement(`div`,null,e.createElement(`strong`,null,`Elicitation Response Sent`),e.createElement(`p`,{className:`text-sm text-muted-foreground mt-1`},`The tool will continue executing.`)),e.createElement(`div`,{className:`flex gap-2`},e.createElement(`button`,{"data-testid":`elicitation-view-tool-result`,className:`px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90`,onClick:()=>{let e=new globalThis.CustomEvent(`navigate-to-tool-result`,{detail:{toolName:null}});window.dispatchEvent(e),xv.dismiss(t)}},`View Tool Result`))),{duration:5e3})}),[])}},b=()=>{e&&(t(e.id,{action:`decline`}),i())},x=()=>{e&&(r(e.id,`User cancelled elicitation request`),i())},S=()=>{e&&_&&`url`in e.request&&(window.open(e.request.url,`_blank`),m(!0))},C=(0,G.useMemo)(()=>{if(!e||!g||!(`requestedSchema`in e.request))return null;let t=e.request.requestedSchema;if(!t||t.type!==`object`||!t.properties)return(0,K.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:`No form schema available`});let n=t.properties,r=t.required||[];return(0,K.jsx)(`div`,{className:`space-y-4`,children:Object.entries(n).map(([e,t])=>{let n=t,i=r.includes(e),a=n.type||`string`,o=n.title||e,s=n.description,c=axe(n),l=c.length>0,u=Array.isArray(n.enum),f=a===`array`&&Array.isArray(n.items?.enum),p=oxe(n),m=a===`array`&&p.length>0,h=Array.isArray(d[e])?d[e]:[];return(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(py,{htmlFor:`field-${e}`,children:[o,i&&(0,K.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),s&&(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s}),a===`boolean`?(0,K.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,K.jsx)(_L,{id:`field-${e}`,"data-testid":`elicitation-field-${e}`,checked:d[e]||!1,onCheckedChange:t=>v(e,t)}),(0,K.jsx)(py,{htmlFor:`field-${e}`,className:`text-sm font-normal cursor-pointer`,children:n.title||e})]}):a===`number`||a===`integer`?(0,K.jsx)(uy,{id:`field-${e}`,"data-testid":`elicitation-field-${e}`,type:`number`,value:d[e]||``,onChange:t=>v(e,a===`integer`?parseInt(t.target.value,10):parseFloat(t.target.value)),placeholder:n.default?.toString()||``}):l?(0,K.jsxs)(`select`,{id:`field-${e}`,"data-testid":`elicitation-field-${e}`,value:d[e]||``,onChange:t=>v(e,t.target.value),className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:[(0,K.jsx)(`option`,{value:``,children:`Select...`}),c.map(e=>(0,K.jsx)(`option`,{value:e.const,children:e.title||e.const},e.const))]}):u?(0,K.jsxs)(`select`,{id:`field-${e}`,"data-testid":`elicitation-field-${e}`,value:d[e]||``,onChange:t=>v(e,t.target.value),className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:[(0,K.jsx)(`option`,{value:``,children:`Select...`}),n.enum.map((e,t)=>(0,K.jsx)(`option`,{value:e,children:n.enumNames?.[t]||e},e))]}):f?(0,K.jsx)(`div`,{className:`space-y-2`,"data-testid":`elicitation-field-${e}`,children:n.items.enum.map(t=>{let n=`field-${e}-${t}`;return(0,K.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,K.jsx)(_L,{id:n,checked:h.includes(t),onCheckedChange:n=>{v(e,n?[...h,t]:h.filter(e=>e!==t))}}),(0,K.jsx)(py,{htmlFor:n,className:`text-sm font-normal cursor-pointer`,children:t})]},t)})}):m?(0,K.jsx)(`div`,{className:`space-y-2`,"data-testid":`elicitation-field-${e}`,children:p.map(t=>{let n=`field-${e}-${t.const}`;return(0,K.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,K.jsx)(_L,{id:n,checked:h.includes(t.const),onCheckedChange:n=>{v(e,n?[...h,t.const]:h.filter(e=>e!==t.const))}}),(0,K.jsx)(py,{htmlFor:n,className:`text-sm font-normal cursor-pointer`,children:t.title||t.const})]},t.const)})}):a===`string`&&(n.format===`textarea`||n.maxLength>100)?(0,K.jsx)(tL,{id:`field-${e}`,"data-testid":`elicitation-field-${e}`,value:d[e]||``,onChange:t=>v(e,t.target.value),placeholder:n.default||``,rows:4}):(0,K.jsx)(uy,{id:`field-${e}`,"data-testid":`elicitation-field-${e}`,type:`text`,value:d[e]||``,onChange:t=>v(e,t.target.value),placeholder:n.default||``})]},e)})})},[e,d,g]);return e?(0,K.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b dark:border-zinc-700`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`h3`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:e.serverName}),(0,K.jsx)(Aa,{variant:`outline`,className:_?`bg-blue-500/20 text-blue-600 dark:text-blue-400 border-blue-500/50`:`bg-green-500/20 text-green-600 dark:text-green-400 border-green-500/50`,children:h}),(0,K.jsx)(`span`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:new Date(e.timestamp).toLocaleString()})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:c,className:`h-8 w-8 p-0`,children:s?(0,K.jsx)($m,{className:`h-4 w-4 text-green-600`}):(0,K.jsx)(uh,{className:`h-4 w-4`})})}),(0,K.jsx)(Im,{children:`Copy request`})]}),(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:l,className:`h-8 w-8 p-0`,children:(0,K.jsx)(fh,{className:`h-4 w-4`})})}),(0,K.jsx)(Im,{children:`Download request`})]}),(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:u,className:`h-8 w-8 p-0`,children:(0,K.jsx)(Ah,{className:`h-4 w-4`})})}),(0,K.jsx)(Im,{children:`Fullscreen`})]}),(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:i,className:`h-8 w-8 p-0`,children:(0,K.jsx)(tg,{className:`h-4 w-4`})})]})]}),(0,K.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-6`,children:[(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`Message`}),(0,K.jsx)(`p`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e.request.message})]}),_&&`url`in e.request&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`External Action Required`}),(0,K.jsxs)(`div`,{className:`bg-muted rounded-lg p-4 space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This request requires you to complete an action at an external URL:`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-background rounded border`,children:[(0,K.jsx)(`code`,{className:`flex-1 text-xs font-mono break-all`,children:e.request.url}),(0,K.jsxs)(J,{size:`sm`,variant:`outline`,onClick:S,className:`flex items-center gap-2`,children:[(0,K.jsx)(mh,{className:`h-4 w-4`}),`Open URL`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center space-x-2 pt-2`,children:[(0,K.jsx)(_L,{id:`url-completed`,checked:p,onCheckedChange:e=>m(!!e)}),(0,K.jsx)(py,{htmlFor:`url-completed`,className:`text-sm font-normal cursor-pointer`,children:`I have completed the required action`})]})]})]}),g&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`Form Data`}),C]}),g&&`requestedSchema`in e.request&&e.request.requestedSchema&&(0,K.jsxs)(`details`,{className:`space-y-2`,children:[(0,K.jsx)(`summary`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100 cursor-pointer`,children:`Schema (for reference)`}),(0,K.jsx)(`div`,{className:`bg-muted rounded-lg p-3 max-h-64 overflow-auto`,children:(0,K.jsx)(bO,{data:e.request.requestedSchema})})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 p-4 border-t dark:border-zinc-700`,children:[(0,K.jsx)(J,{onClick:y,className:`flex-1`,"data-testid":`elicitation-accept-button`,children:`Accept`}),(0,K.jsx)(J,{onClick:b,variant:`outline`,className:`flex-1`,"data-testid":`elicitation-decline-button`,children:`Decline`}),(0,K.jsx)(J,{onClick:x,variant:`outline`,className:`flex-1`,"data-testid":`elicitation-cancel-button`,children:`Cancel`})]})]}):(0,K.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:(0,K.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Select an elicitation request to view details`})})}function j7(e){let t=Date.now()-e,n=Math.floor(t/1e3),r=Math.floor(n/60),i=Math.floor(r/60),a=Math.floor(i/24);return n<60?`just now`:r<60?`${r}m ago`:i<24?`${i}h ago`:a<7?`${a}d ago`:new Date(e).toLocaleDateString()}function cxe({pendingRequests:e=[],onApprove:t,onReject:n,serverId:r,isConnected:i}){let{selectedElicitationRequestId:a,setSelectedElicitationRequestId:o}=SF(),[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(``),[d,f]=(0,G.useState)(-1),[p,m]=(0,G.useState)(!0),[h,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(!0),[y,b]=(0,G.useState)(!1),x=(0,G.useRef)(null),S=(0,G.useRef)(null),C=(0,G.useRef)(null),w=(0,G.useRef)(!1);(0,G.useEffect)(()=>{if(console.log(`[ElicitationTab] Auto-selection check:`,{selectedElicitationRequestId:a,pendingRequestsCount:e.length,currentSelectedId:s?.id}),a&&e.length>0){let t=e.find(e=>e.id===a);console.log(`[ElicitationTab] Found request for auto-selection:`,!!t,t?.id),t&&(console.log(`[ElicitationTab] Auto-selecting request:`,t.id),o(null),c(t),setTimeout(()=>{let e=document.getElementById(`elicitation-request-${t.id}`);console.log(`[ElicitationTab] Scrolling to element:`,!!e),e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},100))}},[a,e,o]),(0,G.useEffect)(()=>{let t=t=>{let n=t.detail.requestId;console.log(`[ElicitationTab] Custom navigate event received:`,n);let r=e.find(e=>e.id===n);r&&(console.log(`[ElicitationTab] Selecting request from event:`,n),c(r),setTimeout(()=>{let e=document.getElementById(`elicitation-request-${n}`);e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},200))};return window.addEventListener(`navigate-to-elicitation`,t),()=>window.removeEventListener(`navigate-to-elicitation`,t)},[e]),(0,G.useEffect)(()=>{p&&e.length>0&&x.current&&!w.current&&(x.current.scrollTop=0)},[e.length,p]),(0,G.useEffect)(()=>{let e=x.current;if(!e)return;let t=()=>{e.scrollTop>0&&(w.current=!0,m(!1))};return e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)},[]),(0,G.useEffect)(()=>{e.length===0&&(w.current=!1,m(!0))},[e.length]),(0,G.useEffect)(()=>{h&&C.current&&C.current.focus()},[h]);let T=(0,G.useCallback)(()=>{l.trim()||g(!1)},[l]),E=(0,G.useMemo)(()=>{if(!l.trim())return e;let t=l.toLowerCase();return e.filter(e=>e.serverName.toLowerCase().includes(t)||e.request.message.toLowerCase().includes(t)||JSON.stringify(e.request||{}).toLowerCase().includes(t))},[e,l]);(0,G.useEffect)(()=>{f(-1)},[l]),(0,G.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.contentEditable===`true`||e.metaKey||e.ctrlKey||e.altKey)return;let n=E;if(e.key===`ArrowDown`)e.preventDefault(),f(e=>{let t=e+1;return t>=n.length?0:t});else if(e.key===`ArrowUp`)e.preventDefault(),f(e=>{let t=e-1;return t<0?n.length-1:t});else if(e.key===`Enter`&&d>=0){e.preventDefault();let t=E[d];t&&D(t)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[d,E]),(0,G.useEffect)(()=>{if(d>=0){let e=`elicitation-request-${E[d]?.id}`,t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[d,E]);let D=(0,G.useCallback)(e=>{c(e)},[]),O=(0,G.useCallback)(()=>{window.confirm(`Are you sure you want to cancel all elicitation requests? This cannot be undone.`)&&(e.forEach(e=>{n(e.id,`User cancelled all requests`)}),c(null))},[e,n]),k=(0,G.useCallback)(async()=>{if(s)try{await rg(JSON.stringify({id:s.id,serverName:s.serverName,timestamp:s.timestamp,request:s.request},null,2)),b(!0),setTimeout(()=>b(!1),2e3)}catch(e){console.error(`[ElicitationTab] Failed to copy request:`,e)}},[s]),A=(0,G.useCallback)(()=>{if(s)try{let e=new globalThis.Blob([JSON.stringify({id:s.id,serverName:s.serverName,timestamp:s.timestamp,request:s.request},null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`elicitation-request-${Date.now()}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}catch(e){console.error(`[ElicitationTab] Failed to download request:`,e)}},[s]),j=(0,G.useCallback)(async()=>{if(S.current)try{document.fullscreenElement?await document.exitFullscreen():await S.current.requestFullscreen()}catch(e){console.error(`[ElicitationTab] Failed to toggle fullscreen:`,e)}},[]);return i?(0,K.jsxs)(T7,{orientation:`horizontal`,className:`h-full`,children:[(0,K.jsx)(E7,{defaultSize:40,minSize:30,children:(0,K.jsx)(T7,{orientation:`vertical`,className:`h-full border-r dark:border-zinc-700`,children:(0,K.jsxs)(E7,{defaultSize:75,minSize:30,children:[(0,K.jsx)(rxe,{isSearchExpanded:h,searchQuery:l,filteredRequestsCount:E.length,requestsCount:e.length,onSearchExpand:()=>g(!0),onSearchChange:u,onSearchBlur:T,onCancelAll:O,searchInputRef:C}),(0,K.jsx)(`div`,{className:`flex flex-col h-full`,children:(0,K.jsx)(ixe,{requests:E,selectedRequest:s,onRequestSelect:D,focusedIndex:d,formatRelativeTime:j7,listRef:x})})]})})}),(0,K.jsx)(D7,{}),(0,K.jsx)(E7,{defaultSize:60,minSize:40,children:(0,K.jsx)(`div`,{ref:S,className:`h-full bg-white dark:bg-zinc-900`,children:(0,K.jsx)(sxe,{request:s,onApprove:t,onReject:n,onClose:()=>c(null),previewMode:_,onTogglePreview:()=>v(!_),isCopied:y,onCopy:k,onDownload:A,onFullscreen:j})})})]}):(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,K.jsx)(Jh,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,K.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Not connected to server`})]})}function lxe({isSearchExpanded:e,searchQuery:t,filteredNotificationsCount:n,notificationsCount:r,onSearchExpand:i,onSearchChange:a,onSearchBlur:o,onClearAll:s,searchInputRef:c}){return(0,K.jsxs)(`div`,{className:`flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2`,children:[(0,K.jsx)(`div`,{className:`flex items-center gap-2 flex-1`,children:e?(0,K.jsx)(uy,{ref:c,placeholder:`Search notifications...`,value:t,onChange:e=>a(e.target.value),onBlur:o,className:`h-8 border-gray-300 dark:border-zinc-600`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-medium text-gray-900 dark:text-gray-100`,children:`Notifications`}),(0,K.jsx)(Aa,{className:`bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent`,variant:`outline`,children:n}),(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:i,className:`h-8 w-8 p-0`,children:(0,K.jsx)(Vh,{className:`h-4 w-4`})})}),(0,K.jsxs)(Im,{side:`bottom`,className:`flex gap-2`,children:[`Search`,(0,K.jsx)(O7,{children:`F`})]})]})]})}),(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:s,disabled:r===0,className:`h-8 w-8 p-0`,children:(0,K.jsx)($h,{className:`h-4 w-4`})})}),(0,K.jsx)(Im,{side:`bottom`,children:`Clear all`})]})})]})}function uxe({notifications:e,selectedNotification:t,onNotificationSelect:n,focusedIndex:r,formatRelativeTime:i,listRef:a}){return e.length===0?(0,K.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:(0,K.jsx)(nm,{vertical:!0,noBorder:!0,message:`No notifications yet`})}):(0,K.jsx)(`div`,{ref:a,className:`overflow-y-auto flex-1 overscroll-contain`,children:e.map((e,a)=>(0,K.jsx)(k7,{id:`notification-${e.id}`,isSelected:t?.id===e.id,isFocused:r===a,title:(0,K.jsxs)(`span`,{className:`flex items-center gap-3`,children:[e.method,!e.read&&(0,K.jsx)(`span`,{className:`size-1.5 block rounded-full bg-orange-500`})]}),description:(()=>{let t=i(e.timestamp),n=e.params&&Object.keys(e.params).length>0?Object.keys(e.params).length:0;return t+(n>0?` | ${n} param${n>1?`s`:``}`:``)})(),onClick:()=>n(e)},e.id))})}function dxe({notification:e,previewMode:t,onTogglePreview:n,onCopy:r,onDownload:i,onFullscreen:a,isCopied:o=!1,onClose:s}){return e?(0,K.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,K.jsxs)(`div`,{className:`flex-shrink-0 px-4 py-3 border-b border-gray-200 dark:border-zinc-700 flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(oh,{className:`h-3 w-3 text-gray-400`}),(0,K.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:new Date(e.timestamp).toLocaleTimeString()})]}),(0,K.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e.formatRelativeTime(e.timestamp)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsxs)(J,{variant:`ghost`,size:`sm`,onClick:n,className:t?``:`text-purple-600 dark:text-purple-400`,children:[t?(0,K.jsx)(sh,{className:`h-4 w-4 mr-1`}):(0,K.jsx)(Qm,{className:`h-4 w-4 mr-1`}),t?`JSON`:`Formatted`]}),(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:r,children:o?(0,K.jsx)($m,{className:`h-4 w-4`}):(0,K.jsx)(uh,{className:`h-4 w-4`})}),(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:i,children:(0,K.jsx)(fh,{className:`h-4 w-4`})}),(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:a,children:(0,K.jsx)(jh,{className:`h-4 w-4`})}),s&&(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:s,children:(0,K.jsx)(tg,{className:`h-4 w-4`})})]})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,K.jsx)(`div`,{className:`px-4 pt-4`,children:(0,K.jsx)(bO,{data:{method:e.method,timestamp:e.timestamp,read:e.read,params:e.params},filename:`notification-${e.method.replace(/[^a-zA-Z0-9]/g,`-`)}-${Date.now()}.json`})})})]}):(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,K.jsx)(Xm,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,K.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Select a notification to view details`})]})}function fxe({notifications:e,unreadCount:t,markNotificationRead:n,markAllNotificationsRead:r,clearNotifications:i,serverId:a,isConnected:o}){let[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(``),[d,f]=(0,G.useState)(-1),[p,m]=(0,G.useState)(!0),[h,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(!0),[y,b]=(0,G.useState)(!1),x=(0,G.useRef)(null),S=(0,G.useRef)(null),C=(0,G.useRef)(null),w=(0,G.useRef)(!1);(0,G.useEffect)(()=>{p&&e.length>0&&x.current&&!w.current&&(x.current.scrollTop=0)},[e.length,p]),(0,G.useEffect)(()=>{let e=x.current;if(!e)return;let t=()=>{e.scrollTop>0&&(w.current=!0,m(!1))};return e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)},[]),(0,G.useEffect)(()=>{e.length===0&&(w.current=!1,m(!0))},[e.length]),(0,G.useEffect)(()=>{s&&!s.read&&n(s.id)},[s,n]),(0,G.useEffect)(()=>{h&&C.current&&C.current.focus()},[h]);let T=(0,G.useCallback)(()=>{l.trim()||g(!1)},[l]),E=(0,G.useMemo)(()=>{if(!l.trim())return e;let t=l.toLowerCase();return e.filter(e=>e.method.toLowerCase().includes(t)||JSON.stringify(e.params||{}).toLowerCase().includes(t))},[e,l]);(0,G.useEffect)(()=>{f(-1)},[l]),(0,G.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.contentEditable===`true`||e.metaKey||e.ctrlKey||e.altKey)return;let n=E;if(e.key===`ArrowDown`)e.preventDefault(),f(e=>{let t=e+1;return t>=n.length?0:t});else if(e.key===`ArrowUp`)e.preventDefault(),f(e=>{let t=e-1;return t<0?n.length-1:t});else if(e.key===`Enter`&&d>=0){e.preventDefault();let t=E[d];t&&D(t)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[d,E]),(0,G.useEffect)(()=>{if(d>=0){let e=`notification-${E[d]?.id}`,t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[d,E]);let D=(0,G.useCallback)(e=>{c(e)},[]),O=(0,G.useCallback)(()=>{window.confirm(`Are you sure you want to clear all notifications? This cannot be undone.`)&&(i(),c(null))},[i]),k=(0,G.useCallback)(async()=>{if(s)try{await rg(JSON.stringify({method:s.method,timestamp:s.timestamp,read:s.read,params:s.params},null,2)),b(!0),setTimeout(()=>b(!1),2e3)}catch(e){console.error(`[NotificationsTab] Failed to copy notification:`,e)}},[s]),A=(0,G.useCallback)(()=>{if(s)try{let e=new globalThis.Blob([JSON.stringify({method:s.method,timestamp:s.timestamp,read:s.read,params:s.params},null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`notification-${Date.now()}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}catch(e){console.error(`[NotificationsTab] Failed to download notification:`,e)}},[s]),j=(0,G.useCallback)(async()=>{if(S.current)try{document.fullscreenElement?await document.exitFullscreen():await S.current.requestFullscreen()}catch(e){console.error(`[NotificationsTab] Failed to toggle fullscreen:`,e)}},[]),M=s?{method:s.method,params:s.params,timestamp:s.timestamp,read:s.read,formatRelativeTime:j7}:null;return o?(0,K.jsxs)(T7,{orientation:`horizontal`,className:`h-full`,children:[(0,K.jsx)(E7,{defaultSize:40,minSize:30,children:(0,K.jsx)(T7,{orientation:`vertical`,className:`h-full border-r dark:border-zinc-700`,children:(0,K.jsxs)(E7,{defaultSize:75,minSize:30,children:[(0,K.jsx)(lxe,{isSearchExpanded:h,searchQuery:l,filteredNotificationsCount:E.length,notificationsCount:e.length,onSearchExpand:()=>g(!0),onSearchChange:u,onSearchBlur:T,onClearAll:O,searchInputRef:C}),(0,K.jsx)(`div`,{className:`flex flex-col h-full`,children:(0,K.jsx)(uxe,{notifications:E,selectedNotification:s,onNotificationSelect:D,focusedIndex:d,formatRelativeTime:j7,listRef:x})})]})})}),(0,K.jsx)(D7,{}),(0,K.jsx)(E7,{defaultSize:60,minSize:40,children:(0,K.jsx)(`div`,{ref:S,className:`h-full bg-white dark:bg-zinc-900`,children:(0,K.jsx)(dxe,{notification:M,previewMode:_,onTogglePreview:()=>v(!_),onCopy:k,onDownload:A,onFullscreen:j,onClose:()=>c(null),isCopied:y})})})]}):(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,K.jsx)(Xm,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,K.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Not connected to server`})]})}function M7({activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabTitle:r,secondaryTabTitle:i,primaryCount:a,secondaryCount:o,secondaryIcon:s,primaryIcon:c,searchPlaceholder:l=`Search...`,onSearchExpand:u,onSearchChange:d,onSearchBlur:f,onTabSwitch:p,searchInputRef:m,primaryTabName:h,onRefresh:g,isRefreshing:_=!1}){let v=e===h;return(0,K.jsxs)(`div`,{className:`flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2`,children:[(0,K.jsx)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:t?(0,K.jsx)(uy,{ref:m,placeholder:l,value:n,onChange:e=>d(e.target.value),onBlur:f,className:`h-8 border-gray-300 dark:border-zinc-600`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-medium text-gray-900 dark:text-gray-100`,children:v?r:i}),v&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Aa,{className:`bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent`,variant:`outline`,children:a}),(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:u,className:`h-8 w-8 p-0`,children:(0,K.jsx)(Vh,{className:`h-4 w-4`})})}),(0,K.jsxs)(Im,{side:`bottom`,className:`flex gap-2`,children:[`Search`,(0,K.jsx)(O7,{children:`F`})]})]}),g&&(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:g,disabled:_,className:`h-8 w-8 p-0`,children:(0,K.jsx)(Rh,{className:`h-4 w-4 ${_?`animate-spin`:``}`})})}),(0,K.jsxs)(Im,{side:`bottom`,className:`flex gap-2`,children:[`Refresh list`,(0,K.jsx)(O7,{children:`R`})]})]})]})]})}),(0,K.jsxs)(J,{variant:`ghost`,size:`sm`,onClick:p,className:`gap-2 flex-shrink-0`,children:[v?(0,K.jsx)(s,{}):(0,K.jsx)(c,{}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:v?i:r}),v&&o>0&&(0,K.jsx)(Aa,{className:`bg-purple-500/20 text-purple-600 dark:text-purple-400 border-transparent`,variant:`outline`,children:o})]})]})}function pxe({serverIds:e,onCountChange:t,onClearRef:n,onExportRef:r}={}){let[i,a]=(0,G.useState)([]),o=(0,G.useRef)(null),[s,c]=(0,G.useState)(new Set),[l]=(0,G.useState)(``),u=e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},d=async()=>{a([]),c(new Set),t?.(0),e&&e.length>0?e.forEach(e=>vn(e)):vn()},f=async e=>{try{await rg(JSON.stringify(e,null,2)),xv.success(`Message copied to clipboard`)}catch(e){console.error(`Failed to copy message:`,e),xv.error(`Failed to copy to clipboard`)}},p=async()=>{try{await rg(JSON.stringify(h,null,2)),xv.success(`All messages copied to clipboard (${h.length})`)}catch(e){console.error(`Failed to copy all messages:`,e),xv.error(`Failed to copy to clipboard`)}},m=(0,G.useMemo)(()=>!e||e.length===0?``:[...e].sort().join(`,`),[e]);(0,G.useEffect)(()=>(n&&(n.current=d),()=>{n&&(n.current=null)}),[n,d]),(0,G.useEffect)(()=>(r&&(r.current=p),()=>{r&&(r.current=null)}),[r,p]),(0,G.useEffect)(()=>{t?.(i.length)},[i.length,t]),(0,G.useEffect)(()=>{console.log(`[RPC Logger] Subscribing to RPC logs for servers:`,e);let n=gn(),r=(e&&e.length>0?n.filter(t=>e.includes(t.serverId)):n).map(e=>{let t=e.message,n=typeof t?.method==`string`?t.method:t?.result===void 0?t?.error===void 0?`unknown`:`error`:`result`;return{id:`${e.timestamp}-${Math.random().toString(36).slice(2)}`,serverId:e.serverId,direction:e.direction.toUpperCase(),method:n,timestamp:e.timestamp,payload:e.message}}).reverse();a(r),t?.(r.length);let i=_n(n=>{if(e&&e.length>0&&!e.includes(n.serverId))return;let r=n.message,i=typeof r?.method==`string`?r.method:r?.result===void 0?r?.error===void 0?`unknown`:`error`:`result`,o={id:`${n.timestamp}-${Math.random().toString(36).slice(2)}`,serverId:n.serverId,direction:n.direction.toUpperCase(),method:i,timestamp:n.timestamp,payload:n.message};console.log(`[RPC Logger] New RPC log:`,{method:i,direction:n.direction,serverId:n.serverId}),a(e=>{let n=[o,...e].slice(0,1e3);return t?.(n.length),n})});return()=>{i(),console.log(`[RPC Logger] Unsubscribed from RPC logs`)}},[m,t]);let h=(0,G.useMemo)(()=>{let t=i;if(e&&e.length>0){let n=new Set(e);t=t.filter(e=>n.has(e.serverId))}if(l.trim()){let e=l.toLowerCase();t=t.filter(t=>t.serverId.toLowerCase().includes(e)||t.method.toLowerCase().includes(e)||t.direction.toLowerCase().includes(e)||JSON.stringify(t.payload).toLowerCase().includes(e))}return t=[...t].sort((e,t)=>new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime()),t},[i,l,e]);return(0,K.jsx)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,children:(0,K.jsx)(`div`,{ref:o,className:`flex-1 min-h-0 overflow-y-auto`,children:h.length===0?(0,K.jsxs)(`div`,{className:`text-center py-8`,children:[(0,K.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No messages yet`}),(0,K.jsx)(`div`,{className:`text-[10px] text-muted-foreground mt-1`,children:`JSON-RPC messages will appear here`})]}):h.map(e=>{let t=s.has(e.id);return(0,K.jsxs)(`div`,{className:`group hover:bg-muted/50 transition-all duration-200 overflow-hidden`,"data-testid":`rpc-message-${e.method.replace(/\//g,`-`)}`,children:[(0,K.jsxs)(`div`,{className:`px-3 py-2 flex items-center gap-2 cursor-pointer hover:bg-muted/50 transition-colors`,onClick:()=>u(e.id),children:[(0,K.jsx)(`div`,{className:`flex-shrink-0`,children:t?(0,K.jsx)(eh,{className:`h-3 w-3 text-muted-foreground transition-transform`}):(0,K.jsx)(nh,{className:`h-3 w-3 text-muted-foreground transition-transform`})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:new Date(e.timestamp).toLocaleTimeString()}),(0,K.jsx)(`span`,{className:`flex items-center justify-center px-1 py-0.5 rounded ${e.direction===`RECEIVE`?`bg-blue-500/10 text-blue-600 dark:text-blue-400`:`bg-green-500/10 text-green-600 dark:text-green-400`}`,title:e.direction===`RECEIVE`?`Incoming`:`Outgoing`,children:e.direction===`RECEIVE`?(0,K.jsx)(jee,{className:`h-3 w-3`}):(0,K.jsx)(Mee,{className:`h-3 w-3`})}),(0,K.jsx)(`span`,{className:`text-xs font-mono text-foreground truncate`,children:e.method})]})]}),t&&(0,K.jsx)(`div`,{className:`border-t bg-muted/20`,children:(0,K.jsxs)(`div`,{className:`p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Message Payload`}),(0,K.jsxs)(J,{variant:`ghost`,size:`sm`,onClick:t=>{t.stopPropagation(),f(e.payload)},className:`h-6 px-2`,title:`Copy message to clipboard`,children:[(0,K.jsx)(uh,{className:`h-3 w-3 mr-1`}),(0,K.jsx)(`span`,{className:`text-xs`,children:`Copy`})]})]}),(0,K.jsx)(`div`,{className:`max-h-[40vh] overflow-auto rounded-sm bg-background/60 p-2`,children:(0,K.jsx)(bO,{data:e.payload})})]})})]},e.id)})})})}function N7({serverId:e,className:t}){let[n,r]=(0,G.useState)(0),[i,a]=(0,G.useState)(!0),o=w7(),s=(0,G.useRef)(null),c=(0,G.useRef)(null);return(0,G.useEffect)(()=>{o.current?.collapse()},[]),(0,K.jsxs)(E7,{panelRef:o,defaultSize:46,collapsible:!0,minSize:150,collapsedSize:46,onResize:e=>{i&&e.inPixels>46?a(!1):!i&&e.inPixels<=46&&a(!0)},className:`flex flex-col border-t dark:border-zinc-700 ${t||``}`,children:[(0,K.jsxs)(`div`,{"data-testid":`rpc-panel-toggle`,className:`group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors`,onClick:e=>{e.preventDefault(),e.stopPropagation(),i?(a(!1),setTimeout(()=>{o.current?.expand()},100)):(o.current?.collapse(),setTimeout(()=>{a(!0)},100))},children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium`,children:`RPC Messages`}),n>0&&(0,K.jsx)(Aa,{"data-testid":`rpc-message-count`,variant:`secondary`,className:`bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent`,children:n})]}),n>0&&!i&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:e=>{e.preventDefault(),e.stopPropagation(),c.current?.()},className:`h-6 w-6 p-0`,title:`Copy all messages to clipboard`,children:(0,K.jsx)(uh,{className:`h-3.5 w-3.5`})}),(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:e=>{e.preventDefault(),e.stopPropagation(),s.current?.()},className:`h-6 w-6 p-0`,title:`Clear all messages`,children:(0,K.jsx)($h,{className:`h-3.5 w-3.5`})})]})]}),(0,K.jsx)(eh,{className:`h-4 w-4 text-muted-foreground transition-transform ${i?``:`rotate-180`}`})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-hidden min-h-0 ${i?`hidden`:``}`,children:(0,K.jsx)(pxe,{serverIds:[e],onCountChange:r,onClearRef:s,onExportRef:c})})]})}N7.displayName=`RpcPanel`;function P7({prompts:e,selectedPrompt:t,onPromptSelect:n,focusedIndex:r}){return e.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,K.jsx)(Mh,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,K.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`No prompts available`})]}):(0,K.jsx)(`div`,{className:`overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain`,children:e.map((e,i)=>(0,K.jsx)(k7,{id:`prompt-${e.name}`,"data-testid":`prompt-item-${e.name}`,isSelected:t?.name===e.name,isFocused:r===i,icon:(0,K.jsx)(Mh,{className:`h-4 w-4`}),title:e.name,description:e.description,metadata:e.arguments&&e.arguments.length>0&&(0,K.jsxs)(Aa,{variant:`outline`,className:`text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400`,children:[e.arguments.length,` args`]}),onClick:()=>n(e)},e.name))})}function F7({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredPromptsCount:r,savedPromptsCount:i,onSearchExpand:a,onSearchChange:o,onSearchBlur:s,onTabSwitch:c,searchInputRef:l,onRefresh:u,isRefreshing:d}){return(0,K.jsx)(M7,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:`prompts`,secondaryTabName:`saved`,primaryTabTitle:`Prompts`,secondaryTabTitle:`History`,primaryCount:r,secondaryCount:i,primaryIcon:Mh,secondaryIcon:oh,searchPlaceholder:`Search prompts...`,onSearchExpand:a,onSearchChange:o,onSearchBlur:s,onTabSwitch:c,searchInputRef:l,onRefresh:u,isRefreshing:d})}function I7({savedPrompts:e,selectedPrompt:t,onLoadPrompt:n,onDeletePrompt:r,focusedIndex:i}){return e.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,K.jsx)(oh,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,K.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`No history`}),(0,K.jsx)(`p`,{className:`text-sm text-gray-400 dark:text-gray-500 mt-1`,children:`Prompts you execute will appear here`})]}):(0,K.jsx)(`div`,{className:`overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain`,children:e.map((e,r)=>(0,K.jsx)(k7,{id:`saved-prompt-${e.id}`,isSelected:t?.id===e.id,isFocused:i===r,icon:(0,K.jsx)(oh,{className:`h-4 w-4`}),title:e.name,description:`${e.promptName} - ${new Date(e.savedAt).toLocaleString()}`,onClick:()=>n(e)},e.id))})}function mxe({selectedPrompt:e,promptArgs:t,onArgChange:n}){let r=e?.arguments||[];if(!(r.length>0))return(0,K.jsx)(`div`,{className:`flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm`,children:`No arguments required`});let i=e=>{let r=e.name,i=t[r],a=typeof i==`string`?i:JSON.stringify(i);return e.type===`boolean`?(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(py,{htmlFor:r,className:`text-sm font-medium`,children:[r,e.required&&(0,K.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),(0,K.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,K.jsx)(`input`,{id:r,type:`checkbox`,checked:!!i,onChange:e=>n(r,e.target.checked),className:`rounded`,"aria-label":`Toggle ${r}`}),(0,K.jsx)(`span`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:e.description})]})]},r):e.type===`number`?(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(py,{htmlFor:r,className:`text-sm font-medium`,children:[r,e.required&&(0,K.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),(0,K.jsx)(uy,{id:r,type:`number`,value:Number(i)||0,onChange:e=>n(r,Number(e.target.value)),placeholder:e.description||`Enter ${r}`}),e.description&&(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e.description})]},r):e.type===`array`||e.type===`object`?(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(py,{htmlFor:r,className:`text-sm font-medium`,children:[r,e.required&&(0,K.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),(0,K.jsx)(tL,{id:r,value:a,onChange:e=>{try{n(r,JSON.parse(e.target.value))}catch{n(r,e.target.value)}},placeholder:e.description||`Enter ${r} as JSON`,className:`font-mono text-sm min-h-[100px]`}),e.description&&(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e.description})]},r):(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(py,{htmlFor:r,className:`text-sm font-medium`,children:[r,e.required&&(0,K.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),(0,K.jsx)(uy,{id:r,"data-testid":`prompt-param-${r}`,value:a,onChange:e=>n(r,e.target.value),placeholder:e.description||`Enter ${r}`}),e.description&&(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e.description})]},r)};return(0,K.jsx)(`div`,{className:`space-y-4`,children:r.map(e=>i(e))})}function L7({selectedPrompt:e,promptArgs:t,isExecuting:n,isConnected:r,onArgChange:i,onExecute:a,onSave:o}){return(0,G.useEffect)(()=>{let t=t=>{(t.metaKey||t.ctrlKey)&&t.key===`Enter`&&e&&!n&&r&&(t.preventDefault(),a())};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,n,r,a]),e?(0,K.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,K.jsx)(`div`,{className:`flex-shrink-0 p-3 sm:p-6 pt-3 pb-4 pr-3`,children:(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex flex-row items-center justify-between mb-0 gap-2`,children:[(0,K.jsx)(`h3`,{className:`text-base sm:text-lg font-semibold`,children:e.name}),(0,K.jsxs)(`div`,{className:`flex gap-2 flex-shrink-0`,children:[(0,K.jsx)(J,{onClick:a,disabled:n||!r,size:`sm`,className:`lg:size-default pr-1! gap-0`,"data-testid":`prompt-execute-button`,children:n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(yF,{className:`mr-2`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:`Executing...`})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ih,{className:`h-4 w-4 sm:mr-2`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:`Execute`}),(0,K.jsx)(`span`,{className:`hidden sm:inline text-[12px] border text-zinc-300 p-1 rounded-full border-zinc-300 dark:text-zinc-600 dark:border-zinc-500 ml-2`,children:`⌘↵`})]})}),(0,K.jsxs)(J,{variant:`outline`,onClick:o,disabled:n,size:`sm`,className:`lg:size-default gap-2`,children:[(0,K.jsx)(Bh,{className:`h-4 w-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:`Save`})]})]})]}),e.description&&(0,K.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 leading-relaxed mt-2`,children:e.description})]})}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto px-3 sm:px-6 pb-4 pr-3`,children:(0,K.jsx)(mxe,{selectedPrompt:e,promptArgs:t,onArgChange:i})})]}):(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,K.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400 mb-2`,children:`Select a prompt to get started`}),(0,K.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:`Choose a prompt from the list to view its details and execute it`})]})}function hxe(e){switch(e){case`system`:return`default`;case`user`:return`outline`;case`assistant`:return`secondary`;default:return`outline`}}function gxe(e){return e.charAt(0).toUpperCase()+e.slice(1)}function _xe(e){return typeof e==`string`?e:e.text?e.text:e.type===`resource`&&e.resource?.text?e.resource.text:e.type===`image`?`[Image: ${e.mimeType||`unknown type`}]`:JSON.stringify(e,null,2)}function vxe({message:e,index:t}){let[n,r]=(0,G.useState)(!1),i=async()=>{await rg(_xe(e.content)),r(!0),setTimeout(()=>r(!1),2e3)},a=()=>{let t=e.content;return typeof t==`string`?(0,K.jsx)(VB,{content:t}):t.type===`text`&&t.text?(0,K.jsx)(VB,{content:t.text}):t.type===`image`?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,K.jsxs)(`span`,{className:`font-mono bg-muted px-2 py-1 rounded`,children:[`Image: `,t.mimeType||`unknown type`]}),t.data&&(0,K.jsx)(`img`,{src:`data:${t.mimeType};base64,${t.data}`,alt:`Prompt image`,className:`max-w-full max-h-[300px] object-contain rounded-lg border border-border mt-2`})]}):t.type===`resource`&&t.resource?(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:`Resource:`}),(0,K.jsx)(`code`,{className:`bg-muted px-2 py-0.5 rounded text-xs font-mono`,children:t.resource.uri})]}),t.resource.text&&(0,K.jsx)(`div`,{className:`mt-2`,children:(0,K.jsx)(VB,{content:t.resource.text})})]}):(0,K.jsx)(`pre`,{className:`bg-muted p-3 rounded-lg text-sm overflow-x-auto`,children:(0,K.jsx)(`code`,{children:JSON.stringify(t,null,2)})})};return(0,K.jsxs)(`div`,{className:`border border-border rounded-lg overflow-hidden bg-white dark:bg-zinc-900`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 bg-muted/30 border-b border-border`,children:[(0,K.jsx)(Aa,{variant:hxe(e.role),children:gxe(e.role)}),(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:i,className:`h-6 px-2`,title:`Copy message content`,children:n?(0,K.jsx)($m,{className:`h-3.5 w-3.5`}):(0,K.jsx)(uh,{className:`h-3.5 w-3.5`})})]}),(0,K.jsx)(`div`,{className:`px-4 py-3`,"data-testid":`prompt-message-content-${t}`,children:a()})]})}function yxe(e){let t=Date.now()-e,n=Math.floor(t/1e3),r=Math.floor(n/60),i=Math.floor(r/60),a=Math.floor(i/24);return n<10?`now`:n<60?`${n}s ago`:r<60?`${r}m ago`:i<24?`${i}h ago`:`${a}d ago`}function bxe(e){return`isError`in e&&!e.isError?null:`error`in e&&e.error?String(e.error):`isError`in e&&e.isError?`An error occurred`:null}function R7({results:e,copiedResult:t,previewMode:n=!0,onCopy:r,onDelete:i,onFullscreen:a,onTogglePreview:o,onMaximize:s,isMaximized:c=!1}){let[l,u]=(0,G.useState)(0),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(!0),h=e[0],g=h?e.filter(e=>e.promptName===h.promptName):[],_=g[l]||g[0],v=e.findIndex(e=>e===_);if((0,G.useEffect)(()=>{g.length>0&&l>=g.length&&u(0)},[g.length,l]),(0,G.useEffect)(()=>{let e=()=>{_&&f(yxe(_.timestamp))};e();let t=setInterval(e,1e3);return()=>clearInterval(t)},[_]),e.length===0)return(0,K.jsx)(`div`,{className:`flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700`,children:(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto h-full`,children:(0,K.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,K.jsx)(`div`,{className:`text-center`,children:(0,K.jsx)(nm,{vertical:!0,noBorder:!0,message:`No Results yet`})})})})});let y=_.error||bxe(_.result),b=`messages`in _.result&&Array.isArray(_.result.messages);return(0,K.jsx)(`div`,{className:`flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700`,children:(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto h-full`,children:(0,K.jsxs)(`div`,{className:`space-y-0 flex-1 h-full flex flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-4 pt-2 border-b border-gray-200 dark:border-zinc-600 pb-2`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium hidden sm:block`,children:`Response`}),_.duration!==void 0&&(0,K.jsxs)(`div`,{className:`hidden sm:flex items-center gap-1`,children:[(0,K.jsx)(ng,{className:`h-3 w-3 text-gray-400`}),(0,K.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[_.duration,`ms`]})]}),b&&(0,K.jsx)(`div`,{className:`flex items-center gap-4 sm:ml-4`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`button`,{onClick:()=>m(!0),className:`text-xs font-medium ${p?`text-black dark:text-white`:`text-zinc-500 dark:text-zinc-400`}`,children:`Formatted`}),(0,K.jsx)(`span`,{className:`text-xs text-zinc-400`,children:`|`}),(0,K.jsx)(`button`,{onClick:()=>m(!1),className:`text-xs font-medium ${p?`text-zinc-500 dark:text-zinc-400`:`text-black dark:text-white`}`,children:`Raw`})]})}),(0,K.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[g.length>1&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mr-2`,children:[(0,K.jsx)(Th,{className:`h-3 w-3 text-gray-400`}),(0,K.jsxs)(ab,{value:l.toString(),onValueChange:e=>u(parseInt(e)),children:[(0,K.jsx)(sb,{className:`h-7 w-[120px] text-xs`,children:(0,K.jsx)(ob,{})}),(0,K.jsx)(cb,{children:g.map((e,t)=>(0,K.jsx)(lb,{value:t.toString(),children:t===0?`Latest`:`${t+1} call ago`},t))})]})]}),(0,K.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400 mr-2`,children:d}),(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>r(v,_.result),className:`h-7 w-7 p-0`,title:`Copy result`,children:t===v?(0,K.jsx)($m,{className:`h-4 w-4`}):(0,K.jsx)(uh,{className:`h-4 w-4`})}),i&&(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>i(v),className:`h-7 w-7 p-0`,title:`Delete result`,children:(0,K.jsx)($h,{className:`h-4 w-4`})}),a&&(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>a(v),className:`h-7 w-7 p-0 sm:hidden`,title:`Fullscreen`,children:(0,K.jsx)(jh,{className:`h-4 w-4`})}),s&&(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:s,className:`h-7 w-7 p-0 hidden sm:flex`,title:c?`Restore`:`Maximize`,children:c?(0,K.jsx)(Nh,{className:`h-4 w-4`}):(0,K.jsx)(jh,{className:`h-4 w-4`})})]})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:y?(0,K.jsxs)(`div`,{className:`bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3`,children:[(0,K.jsx)(`p`,{className:`text-red-800 dark:text-red-300 font-medium`,children:`Error:`}),(0,K.jsx)(`p`,{className:`text-red-700 dark:text-red-400 text-sm`,children:y})]}):p&&b?(0,K.jsx)(`div`,{className:`space-y-3`,children:(`messages`in _.result?_.result.messages:[]).map((e,t)=>(0,K.jsx)(vxe,{message:e,index:t},t))}):(0,K.jsx)(bO,{data:_.result,filename:`prompt-result-${_.promptName}-${Date.now()}.json`})})]})})})}var z7=`mcp-inspector-saved-prompts`;function B7({ref:e,prompts:t,callPrompt:n,serverId:r,isConnected:i,refreshPrompts:a}){let[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(null),{selectedPromptName:u,setSelectedPromptName:d}=SF(),[f,p]=(0,G.useState)(null),[m,h]=(0,G.useState)(`prompts`),[g,_]=(0,G.useState)([]),[v,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(``),[S,C]=(0,G.useState)(!1),[w,T]=(0,G.useState)(-1),E=(0,G.useRef)(null),[D,O]=(0,G.useState)(!1),[k,A]=(0,G.useState)(`list`),[j,M]=(0,G.useState)(!1),{filteredPrompts:N,selectedPrompt:P,setSelectedPrompt:F,results:I,handleDeleteResult:L,promptArgs:ee,setPromptArgs:te,isExecuting:R,handlePromptSelect:z,handleArgChange:ne,executeSelectedPrompt:re,searchQuery:ie,setSearchQuery:ae}=uI({prompts:t,callPrompt:n,serverId:r}),oe=w7(),se=w7();(0,G.useEffect)(()=>{let e=()=>{O(window.innerWidth<1024)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,G.useEffect)(()=>{A(P?`detail`:`list`)},[P]),(0,G.useEffect)(()=>{D&&I.length>0&&!R&&A(`response`)},[I,R,D]),(0,G.useImperativeHandle)(e,()=>({focusSearch:()=>{C(!0),setTimeout(()=>{E.current&&E.current.focus()},0)},blurSearch:()=>{ae(``),C(!1),E.current&&E.current.blur()}})),(0,G.useEffect)(()=>{try{let e=localStorage.getItem(z7);e&&_(JSON.parse(e))}catch(e){console.error(`[PromptsTab] Failed to load saved prompts:`,e)}},[]);let ce=(0,G.useCallback)(e=>{try{localStorage.setItem(z7,JSON.stringify(e))}catch(e){console.error(`[PromptsTab] Failed to save prompts:`,e)}},[]);(0,G.useEffect)(()=>{S&&E.current&&E.current.focus()},[S]);let le=(0,G.useCallback)(()=>{ie.trim()||C(!1)},[ie]),ue=(0,G.useCallback)(async()=>{if(a){s(!0);try{await a()}finally{s(!1)}}},[a]),de=(0,G.useCallback)(e=>{let n=t.find(t=>t.name===e.promptName);n&&(F(n),te(e.args),l(e))},[t,F,te]);(0,G.useEffect)(()=>{T(-1)},[ie,m]),(0,G.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.contentEditable===`true`||e.metaKey||e.ctrlKey||e.altKey)return;let n=m===`prompts`?N:g;if(e.key===`ArrowDown`)e.preventDefault(),T(e=>{let t=e+1;return t>=n.length?0:t});else if(e.key===`ArrowUp`)e.preventDefault(),T(e=>{let t=e-1;return t<0?n.length-1:t});else if(e.key===`Enter`&&w>=0)if(e.preventDefault(),m===`prompts`){let e=N[w];e&&z(e)}else{let e=g[w];e&&de(e)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[w,N,g,m,z,de]),(0,G.useEffect)(()=>{if(w>=0){let e=m===`prompts`?`prompt-${N[w]?.name}`:`saved-prompt-${g[w]?.id}`,t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[w,N,g,m]),(0,G.useEffect)(()=>{if(console.warn(`[PromptsTab] Auto-selection effect triggered:`,{selectedPromptName:u,promptsCount:t.length,currentSelectedPrompt:P?.name}),u&&t.length>0){let e=t.find(e=>e.name===u);if(console.warn(`[PromptsTab] Prompt lookup result:`,{selectedPromptName:u,promptFound:!!e,promptName:e?.name,shouldSelect:e&&P?.name!==e.name}),e&&P?.name!==e.name){console.warn(`[PromptsTab] Selecting prompt:`,e.name),d(null);let t=setTimeout(()=>{z(e);let t=document.getElementById(`prompt-${e.name}`);t&&(console.warn(`[PromptsTab] Scrolling to prompt element`),t.scrollIntoView({behavior:`smooth`,block:`nearest`}))},100);return()=>clearTimeout(t)}}},[u,t,P,z,d]);let B=(0,G.useCallback)(async(e,t)=>{try{await rg(JSON.stringify(t,null,2)),p(e),setTimeout(()=>p(null),2e3)}catch(e){console.error(`[PromptsTab] Failed to copy result:`,e)}},[]),fe=(0,G.useCallback)(e=>{if(D)A(`response`);else{let t=I[e];if(t){let e=window.open(``,`_blank`,`width=800,height=600`);if(e){let n=t.result;e.document.write(`
|
|
428
|
+
`)}`,timestamp:Date.now()})}let T=(b.attachments?.length??0)>0,E=gbe([...o,...y,...w,...T?[b]:[]]),D=T?``:c;for await(let e of p.current.streamEvents(D,10,!1,E,void 0,f.current?.signal)){if(f.current?.signal.aborted)break;if(e.event===`on_chat_model_stream`){let t=e.data?.chunk;if(t?.text){let e=t.text;if(typeof e==`string`&&e.length>0){l+=e;let t=u[u.length-1];t&&t.type===`text`?t.text=l:u.push({type:`text`,text:l}),s(e=>e.map(e=>e.id===n?{...e,parts:[...u]}:e))}}let r=t?.tool_call_chunks||t?.kwargs?.tool_call_chunks||t?.lc_kwargs?.tool_call_chunks||t?.additional_kwargs?.tool_calls||t?.tool_calls;if(r&&Array.isArray(r)&&r.length>0){l&&=``;for(let e of r){let t=e.index??0,r=e.name||``,i=e.args||``,a=d.get(t);a||(a={name:r||`unknown`,accumulatedJson:``},d.set(t,a)),r&&a.name===`unknown`&&(a.name=r);let o;if(typeof i==`object`&&i)o=i;else if(typeof i==`string`&&i){a.accumulatedJson+=i;try{o=JSON.parse(a.accumulatedJson)}catch{let e=[()=>{let e=a.accumulatedJson;(e.match(/(?<!\\)"/g)||[]).length%2!=0&&(e+=`"`);let t=(e.match(/{/g)||[]).length-(e.match(/}/g)||[]).length,n=(e.match(/\[/g)||[]).length-(e.match(/]/g)||[]).length;for(let t=0;t<n;t++)e+=`]`;for(let n=0;n<t;n++)e+=`}`;return JSON.parse(e)},()=>{let e=a.accumulatedJson;e=e.replace(/,\s*"[^"]*"?\s*:\s*("([^"\\]|\\.)*)?$/,``),e=e.replace(/,\s*"[^"]*$/,``),(e.match(/(?<!\\)"/g)||[]).length%2!=0&&(e+=`"`);let t=(e.match(/{/g)||[]).length-(e.match(/}/g)||[]).length,n=(e.match(/\[/g)||[]).length-(e.match(/]/g)||[]).length;for(let t=0;t<n;t++)e+=`]`;for(let n=0;n<t;n++)e+=`}`;return JSON.parse(e)}];for(let t of e)try{o=t();break}catch{}}}if(o){let e=u.find(e=>e.type===`tool-invocation`&&e.toolInvocation?.state===`streaming`&&e.toolInvocation?.toolName===a.name);if(e&&e.toolInvocation){let t=e.toolInvocation.partialArgs,n=t?Object.keys(t):[],r=Object.keys(o),i=n.reduce((e,n)=>e+String(t[n]??``).length,0),a=r.reduce((e,t)=>e+String(o[t]??``).length,0);(r.length>n.length||a>=i)&&(e.toolInvocation.partialArgs=o)}else u.push({type:`tool-invocation`,toolInvocation:{toolName:a.name,args:{},state:`streaming`,partialArgs:o}});s(e=>e.map(e=>e.id===n?{...e,parts:[...u]}:e)),await _()}}}}else if(e.event===`on_tool_start`){l&&=``;let t={};e.data?.input?t=e.data.input:e.data?.tool_input?t=e.data.tool_input:e.data&&(t=e.data),console.log(`[useChatMessagesClientSide] on_tool_start:`,{toolName:e.name,eventData:e.data,extractedArgs:t}),C++;let r=u.find(t=>t.type===`tool-invocation`&&t.toolInvocation?.state===`streaming`&&t.toolInvocation?.toolName===(e.name||`unknown`));r&&r.toolInvocation?(r.toolInvocation.args=t,r.toolInvocation.state=`pending`):u.push({type:`tool-invocation`,toolInvocation:{toolName:e.name||`unknown`,args:t,state:`pending`}}),d.clear(),s(e=>e.map(e=>e.id===n?{...e,parts:[...u]}:e))}else if(e.event===`on_tool_end`){let t=u.find(t=>t.type===`tool-invocation`&&t.toolInvocation?.toolName===e.name&&!t.toolInvocation?.result);if(console.log(`[useChatMessagesClientSide] on_tool_end event:`,{toolName:e.name,hasToolPart:!!t,output:e.data?.output}),t&&t.toolInvocation){let i=e.data?.output;if(i?.kwargs?.content&&typeof i.kwargs.content==`string`)try{i=JSON.parse(i.kwargs.content)}catch(e){console.warn(`[useChatMessagesClientSide] Failed to parse kwargs.content:`,e),i=i.kwargs.content}else if(i?.content&&typeof i.content==`string`)try{i=JSON.parse(i.content)}catch{i=i.content}t.toolInvocation.result=i,t.toolInvocation.state=i?.isError?`error`:`result`;let a=i?._meta?.[`openai/outputTemplate`];if(console.log(`[useChatMessagesClientSide] Tool result:`,{toolName:e.name,hasMeta:!!i?._meta,hasStructuredContent:!!i?.structuredContent,appsSdkUri:a}),a&&typeof a==`string`&&r){console.log(`[useChatMessagesClientSide] Detected Apps SDK component, fetching resource:`,a);try{let e=await r(a);console.log(`[useChatMessagesClientSide] Resource fetched:`,e);let n=i?.structuredContent||null;if(e?.contents&&Array.isArray(e.contents)){let r=e.contents.map(e=>({type:`resource`,resource:e}));console.log(`[useChatMessagesClientSide] Created MCP resources:`,r);let a={...i,content:[...i.content||[],...r],structuredContent:n};t.toolInvocation.result=a,console.log(`[useChatMessagesClientSide] Updated result with resources`)}else console.warn(`[useChatMessagesClientSide] No contents in resourceData:`,e)}catch(e){console.error(`Failed to fetch Apps SDK resource:`,e)}}s(e=>e.map(e=>e.id===n?{...e,parts:[...u]}:e))}}}if(f.current?.signal.aborted)for(let e of u)e.type===`tool-invocation`&&e.toolInvocation?.state===`pending`&&(e.toolInvocation.state=`error`,e.toolInvocation.result=`Cancelled by user`);s(e=>e.map(e=>e.id===n?{...e,parts:[...u],content:``}:e)),t&&Km.getInstance().capture(new Bm({serverId:e.url,provider:t.provider,model:t.model,messageCount:o.length+1,toolCallsCount:C,success:!0,executionMode:`client-side`,duration:Date.now()-S})).catch(()=>{})}catch(n){if(n instanceof DOMException&&n.name===`AbortError`)return;console.error(`Client-side agent error:`,n);let r=`Unknown error occurred`;if(n instanceof Error){r=n.message;let e=n;e.status&&(r=`HTTP ${e.status}: ${r}`),(e.code===401||r.includes(`401`)||r.includes(`Unauthorized`))&&(r=`Authentication failed (401). Check your Authorization header in the connection settings.`)}t&&Km.getInstance().capture(new Bm({serverId:e.url,provider:t.provider,model:t.model,messageCount:o.length+1,toolCallsCount:C,success:!1,executionMode:`client-side`,duration:Date.now()-S,error:r})).catch(()=>{});let i={id:`error-${Date.now()}`,role:`assistant`,content:`Error: ${r}`,timestamp:Date.now()};s(e=>[...e,i])}finally{l(!1),f.current=null}},[e,t,n,o,r,u,a]),clearMessages:(0,G.useCallback)(()=>{s([]),p.current&&p.current.clearConversationHistory()},[]),setMessages:s,stop:(0,G.useCallback)(()=>{f.current&&f.current.abort()},[]),addAttachment:(0,G.useCallback)(async e=>{try{let t=await DL(e);d(e=>{let n=[...e,t];return TL(n)?n:(alert(`Total attachment size exceeds 20MB limit`),e)})}catch(e){e instanceof Error?alert(e.message):alert(`Failed to add attachment`)}},[]),removeAttachment:(0,G.useCallback)(e=>{d(t=>t.filter((t,n)=>n!==e))},[]),clearAttachments:(0,G.useCallback)(()=>{d([])},[])}}var f5={openai:`gpt-4o`,anthropic:`claude-haiku-4-5-20251001`,google:`gemini-2.5-flash`};function p5({mcpServerUrl:e}){let[t,n]=(0,G.useState)(null),[r,i]=(0,G.useState)(null),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(`openai`),[l,u]=(0,G.useState)(``),[d,f]=(0,G.useState)(f5.openai),p=(0,G.useCallback)(()=>{let e=localStorage.getItem(`mcp-inspector-api-keys`);if(e)try{return JSON.parse(e)}catch(e){return console.error(`Failed to load API keys:`,e),{}}return{}},[]),m=(0,G.useCallback)(e=>{localStorage.setItem(`mcp-inspector-api-keys`,JSON.stringify(e))},[]),[h,g]=(0,G.useState)(`none`),[_,v]=(0,G.useState)(``),[y,b]=(0,G.useState)(``),[x,S]=(0,G.useState)(``);return(0,G.useEffect)(()=>{let e=()=>{let e=localStorage.getItem(`mcp-inspector-llm-config`),t=p();if(e)try{let r=JSON.parse(e);n(r),c(r.provider),u(t[r.provider]||r.apiKey||``),f(r.model)}catch(e){console.error(`Failed to load LLM config:`,e)}};e();let t=()=>{e()},r=t=>{(t.key===`mcp-inspector-llm-config`||t.key===`mcp-inspector-api-keys`)&&e()};return window.addEventListener(`llm-config-updated`,t),window.addEventListener(`storage`,r),()=>{window.removeEventListener(`llm-config-updated`,t),window.removeEventListener(`storage`,r)}},[p]),(0,G.useEffect)(()=>{let t=localStorage.getItem(`mcp-inspector-auth-config`);if(t)try{let e=JSON.parse(t);i(e),g(e.type),e.username&&v(e.username),e.password&&b(e.password),e.token&&S(e.token)}catch(e){console.error(`Failed to load auth config:`,e)}else try{let t=`mcp:auth_${yL(e)}_tokens`;localStorage.getItem(t)&&(i({type:`oauth`}),g(`oauth`))}catch(e){console.error(`Failed to check for OAuth tokens:`,e)}},[e]),(0,G.useEffect)(()=>{f(f5[s]),u(p()[s]||``)},[s,p]),{llmConfig:t,authConfig:r,configDialogOpen:a,setConfigDialogOpen:o,tempProvider:s,setTempProvider:c,tempApiKey:l,setTempApiKey:u,tempModel:d,setTempModel:f,tempAuthType:h,saveLLMConfig:(0,G.useCallback)(()=>{if(!l.trim())return;let e=p();e[s]=l,m(e);let t={provider:s,apiKey:l,model:d},r={type:h,...h===`basic`&&{username:_.trim(),password:y.trim()},...h===`bearer`&&{token:x.trim()}};n(t),i(r),localStorage.setItem(`mcp-inspector-llm-config`,JSON.stringify(t)),localStorage.setItem(`mcp-inspector-auth-config`,JSON.stringify(r)),window.dispatchEvent(new CustomEvent(`llm-config-updated`)),o(!1)},[s,l,d,h,_,y,x,p,m]),clearConfig:(0,G.useCallback)(()=>{n(null),i(null);let e=p();delete e[s],m(e),u(``),v(``),b(``),S(``),g(`none`),localStorage.removeItem(`mcp-inspector-llm-config`),localStorage.removeItem(`mcp-inspector-auth-config`)},[s,p,m])}}var ybe=/(?:^\/$|\s+\/$)/,bbe=[`ArrowDown`,`ArrowUp`,`Escape`,`Enter`];function m5({connection:e,isConnected:t,useClientSide:n=!0,enableKeyboardShortcuts:r=!0,prompts:i,serverId:a,callPrompt:o,readResource:s,chatApiUrl:c,waitForChatApiUrl:l,initialMessages:u,managedLlmConfig:d,clearButtonLabel:f,hideTitle:p,hideModelBadge:m,hideServerUrl:h,clearButtonHideIcon:g,clearButtonHideShortcut:_,clearButtonVariant:v,hideClearButton:y,hideToolSelector:b,chatQuickQuestions:x=[],chatFollowups:S=[]}){let[C,w]=(0,G.useState)(``),[T,E]=(0,G.useState)(!1),[D,O]=(0,G.useState)(-1),[k,A]=(0,G.useState)(x),[j,M]=(0,G.useState)(S),[N,P]=(0,G.useState)(new Set),F=(0,G.useRef)(null),I=(0,G.useRef)(null),L=(0,G.useMemo)(()=>(e.tools??[]).map(e=>({name:e.name,description:e.description})),[e.tools]),{llmConfig:ee,authConfig:te,configDialogOpen:R,setConfigDialogOpen:z,tempProvider:ne,setTempProvider:re,tempApiKey:ie,setTempApiKey:ae,tempModel:oe,setTempModel:se,saveLLMConfig:ce,clearConfig:le}=p5({mcpServerUrl:e.url}),ue=d??ee,de=!!d,{getAllModelContexts:B}=XB(),fe=B(),pe={connection:e,llmConfig:ue,isConnected:t,readResource:s,widgetModelContexts:fe,disabledTools:N},me=_be({mcpServerUrl:e.url,llmConfig:ue,authConfig:te,isConnected:t,chatApiUrl:c,waitForChatApiUrl:l,widgetModelContexts:fe,initialMessages:u}),V=vbe(pe),{messages:H,isLoading:he,attachments:ge,sendMessage:_e,clearMessages:ve,setMessages:ye,stop:U,addAttachment:be,removeAttachment:xe}=n?V:me,{filteredPrompts:Se,setSelectedPrompt:Ce,selectedPrompt:we,setPromptArgs:Te,executePrompt:Ee,results:De,handleDeleteResult:Oe,clearPromptResults:ke}=uI({prompts:i,callPrompt:o,serverId:a}),Ae=(0,G.useCallback)(e=>Array.isArray(e)?e.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean).slice(0,8):[],[]),je=(0,G.useCallback)(e=>typeof e.content==`string`?e.content:Array.isArray(e.content)?e.content.map(e=>typeof e==`string`?e:e.text??``).join(``):``,[]),Me=(0,G.useCallback)(()=>H.map(e=>({id:e.id,role:e.role,content:je(e),timestamp:e.timestamp})),[H,je]),Ne=(0,G.useCallback)((e,t={})=>{typeof window>`u`||window.parent===window||window.parent.postMessage({type:e,serverId:a,...t},`*`)},[a]);(0,G.useEffect)(()=>{Ne(`mcp-inspector:chat:ready`,{capabilities:{send:!0,clear:!0,getState:!0,setQuickQuestions:!0,setFollowups:!0,loadMessages:!0}})},[Ne]),(0,G.useEffect)(()=>{Ne(`mcp-inspector:chat:state_changed`,{isLoading:he,messageCount:H.length,messages:Me(),quickQuestions:k,followups:j})},[j,Me,he,H.length,Ne,k]),(0,G.useEffect)(()=>{let e=e=>{if(!e.data||typeof e.data!=`object`)return;let n=e.data;if(!n.type?.startsWith(`mcp-inspector:chat:`)||n.serverId&&n.serverId!==a)return;let r=n.requestId,i=(e,t={})=>{Ne(`mcp-inspector:chat:command_result`,{requestId:r,ok:e,...t})};if(n.type===`mcp-inspector:chat:send`){let e=(n.message??n.prompt??``).trim();if(!e){i(!1,{error:`Missing message`});return}if(!ue||!t){i(!1,{error:`Chat is not ready to send messages`});return}_e(e,[]).then(()=>{Ne(`mcp-inspector:chat:message_sent`,{requestId:r,message:e,source:`bridge`}),i(!0)}).catch(e=>{i(!1,{error:e instanceof Error?e.message:String(e)})});return}if(n.type===`mcp-inspector:chat:clear`){ve(),Ne(`mcp-inspector:chat:cleared`,{requestId:r}),i(!0);return}if(n.type===`mcp-inspector:chat:get_state`){Ne(`mcp-inspector:chat:state`,{requestId:r,isLoading:he,messageCount:H.length,messages:Me(),quickQuestions:k,followups:j}),i(!0);return}if(n.type===`mcp-inspector:chat:set_quick_questions`){let e=Ae(n.questions);A(e),i(!0,{quickQuestions:e});return}if(n.type===`mcp-inspector:chat:set_followups`){let e=Ae(n.followups);M(e),i(!0,{followups:e});return}if(n.type===`mcp-inspector:chat:load_messages`){let e=n.messages;if(!Array.isArray(e)){i(!1,{error:`messages must be an array`});return}ye(e),i(!0,{count:e.length});return}};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[ve,ye,j,Me,he,H.length,Ne,k,Ae,_e,a,ue,t]),TF(r?{onNewChat:ve}:{});let Pe=(0,G.useCallback)(()=>{O(-1),E(!1),I.current=null},[]),Fe=(0,G.useCallback)(()=>{if(!F.current)return;let e=F.current.selectionStart,t=C.slice(0,e),n=ybe.test(t);E(n),n?(I.current={start:e-1,end:e},O(0)):Pe()},[C,Pe]);(0,G.useEffect)(()=>{ue&&H.length===0&&F.current&&F.current.focus()},[ue,H.length]),(0,G.useEffect)(()=>{!he&&H.length>0&&F.current&&F.current.focus()},[he,H.length]),(0,G.useEffect)(()=>{F.current&&Fe()},[C,Fe]);let Ie=(0,G.useCallback)(()=>{Ce(null),Te({}),Pe()},[Pe]),Le=(0,G.useCallback)(async e=>{if(Ce(e),e.arguments&&e.arguments.length>0){Ce(null),xv.error(`Prompts with arguments are not supported`,{description:`This prompt requires arguments which are not yet supported in chat mode.`});return}try{await Ee(e,{})}catch(e){console.error(`Error executing prompt`,e)}finally{if(F.current&&I.current){let{start:e,end:t}=I.current;w(C.slice(0,e)+C.slice(t)),requestAnimationFrame(()=>{F.current?.focus(),F.current?.setSelectionRange(e,e)})}Ie()}},[Ee,Ie,C]),Re=(0,G.useCallback)(()=>{(C.trim()||De.length>0||ge.length>0)&&(_e(C,De),w(``),ke())},[C,De,_e,ke,ge]),ze=(0,G.useCallback)(e=>{if(e.key===`ArrowDown`)O(e=>Se.length===0?-1:(e+1)%Se.length);else if(e.key===`ArrowUp`)O(e=>Se.length===0?-1:(e-1+Se.length)%Se.length);else if(e.key===`Escape`)e.stopPropagation(),Pe();else if(e.key===`Enter`&&D>=0){let e=Se[D];e&&Le(e)}},[Se,D,Le,Pe]),Be=(0,G.useCallback)(e=>{bbe.includes(e.key)&&T?(e.preventDefault(),ze(e)):e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Re())},[Re,ze,T]),Ve=(0,G.useCallback)(e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&Fe()},[Fe]),He=(0,G.useCallback)(()=>{le(),ve()},[le,ve]),Ue=(0,G.useCallback)(e=>{e.trim()&&(!ue||!t||_e(e,[]).then(()=>{Ne(`mcp-inspector:chat:message_sent`,{message:e,source:`quick_question`})}))},[Ne,_e,ue,t]),W=(0,G.useCallback)(e=>{e.trim()&&(!ue||!t||_e(e,[]).then(()=>{Ne(`mcp-inspector:chat:message_sent`,{message:e,source:`followup`})}))},[Ne,_e,ue,t]);return ue&&H.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col h-full`,children:[!de&&(0,K.jsx)(`div`,{className:`absolute top-4 right-4 z-10`,children:(0,K.jsx)($I,{open:R,onOpenChange:z,tempProvider:ne,tempModel:oe,tempApiKey:ie,onProviderChange:re,onModelChange:se,onApiKeyChange:ae,onSave:ce,onClear:He,showClearButton:!0,buttonLabel:`Change API Key`})}),(0,K.jsx)(PL,{mcpServerUrl:e.url,inputValue:C,isConnected:t,isLoading:he,textareaRef:F,llmConfig:ue,promptsDropdownOpen:T,promptFocusedIndex:D,prompts:Se,selectedPrompt:we,promptResults:De,attachments:ge,tools:b?void 0:L,disabledTools:b?void 0:N,onDisabledToolsChange:b?void 0:P,onDeletePromptResult:Oe,onPromptSelect:Le,onInputChange:w,onKeyDown:Be,onKeyUp:Ve,onClick:Fe,onSubmit:e=>{e.preventDefault(),Re()},onConfigDialogOpenChange:z,onAttachmentAdd:be,onAttachmentRemove:xe,hideModelBadge:m,hideServerUrl:h,quickQuestions:k,onQuickQuestionSelect:Ue})]}):(0,K.jsxs)(`div`,{className:`flex flex-col h-full relative`,children:[(0,K.jsx)(eL,{llmConfig:ue,hasMessages:H.length>0,configDialogOpen:de?!1:R,onConfigDialogOpenChange:de?()=>{}:z,onClearChat:ve,tempProvider:ne,tempModel:oe,tempApiKey:ie,onProviderChange:re,onModelChange:se,onApiKeyChange:ae,onSaveConfig:ce,onClearConfig:He,hideConfigButton:de,clearButtonLabel:f,hideTitle:p,clearButtonHideIcon:g,clearButtonHideShortcut:_,clearButtonVariant:v,hideClearButton:y}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto p-2 sm:p-4 pt-[80px] sm:pt-[100px]`,children:ue?(0,K.jsx)(ime,{messages:H,isLoading:he,serverId:e.url,readResource:s,tools:e.tools,sendMessage:(e,t)=>_e(e,[],t),serverBaseUrl:e.url}):(0,K.jsx)(FL,{onConfigureClick:()=>z(!0)})}),ue&&(0,K.jsx)(ML,{inputValue:C,isConnected:t,isLoading:he,textareaRef:F,promptsDropdownOpen:T,promptFocusedIndex:D,prompts:Se,promptResults:De,selectedPrompt:we,attachments:ge,tools:b?void 0:L,disabledTools:b?void 0:N,onDisabledToolsChange:b?void 0:P,onDeletePromptResult:Oe,onPromptSelect:Le,onInputChange:w,onKeyDown:Be,onKeyUp:Ve,onClick:Fe,onSendMessage:Re,onStopStreaming:U,onAttachmentAdd:be,onAttachmentRemove:xe,followups:j,onFollowupSelect:W})]})}var xbe=r({Group:()=>y7,Panel:()=>S7,Separator:()=>C7,isCoarsePointer:()=>w5,useDefaultLayout:()=>Jbe,useGroupCallbackRef:()=>Xbe,useGroupRef:()=>Zbe,usePanelCallbackRef:()=>exe,usePanelRef:()=>txe});function Sbe(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function Cbe(e,t){let n=getComputedStyle(e.ownerDocument.body);return t*parseFloat(n.fontSize)}function wbe(e){return e/100*window.innerHeight}function Tbe(e){return e/100*window.innerWidth}function Ebe(e){switch(typeof e){case`number`:return[e,`px`];case`string`:{let t=parseFloat(e);return e.endsWith(`%`)?[t,`%`]:e.endsWith(`px`)?[t,`px`]:e.endsWith(`rem`)?[t,`rem`]:e.endsWith(`em`)?[t,`em`]:e.endsWith(`vh`)?[t,`vh`]:e.endsWith(`vw`)?[t,`vw`]:[t,`%`]}}}function h5({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=Ebe(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=Cbe(t,i);break;case`em`:r=Sbe(t,i);break;case`vh`:r=wbe(i);break;case`vw`:r=Tbe(i);break}return r}function g5(e){return parseFloat(e.toFixed(3))}function _5({group:e}){let{orientation:t,panels:n}=e;return n.reduce((e,n)=>(e+=t===`horizontal`?n.element.offsetWidth:n.element.offsetHeight,e),0)}function v5(e){let{panels:t}=e,n=_5({group:e});return n===0?t.map(e=>({collapsedSize:0,collapsible:e.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:e.panelConstraints.disabled,minSize:0,maxSize:100,panelId:e.id})):t.map(e=>{let{element:t,panelConstraints:r}=e,i=0;r.collapsedSize!==void 0&&(i=g5(h5({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=g5(h5({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=g5(h5({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=g5(h5({groupSize:n,panelElement:t,styleProp:r.maxSize})/n*100)),{collapsedSize:i,collapsible:r.collapsible===!0,defaultSize:a,disabled:r.disabled,minSize:o,maxSize:s,panelId:e.id}})}function y5(e,t=`Assertion error`){if(!e)throw Error(t)}function b5(e,t){return Array.from(t).sort(e===`horizontal`?Dbe:Obe)}function Dbe(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function Obe(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function x5(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function S5(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function kbe({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},i,a=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=S5(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return y5(i,`No rect found`),i}var C5;function w5(){return C5===void 0&&(C5=typeof matchMedia==`function`?!!matchMedia(`(pointer:coarse)`).matches:!1),C5}function T5(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=b5(n,Array.from(t.children).filter(x5).map(e=>({element:e}))).map(({element:e})=>e),o=[],s=!1,c=!1,l=-1,u=-1,d=0,f,p=[];{let e=-1;for(let t of a)t.hasAttribute(`data-panel`)&&(e++,t.ariaDisabled===null&&(d++,l===-1&&(l=e),u=e))}if(d>1){let t=-1;for(let d of a)if(d.hasAttribute(`data-panel`)){t++;let i=r.find(e=>e.element===d);if(i){if(f){let r=f.element.getBoundingClientRect(),a=d.getBoundingClientRect(),m;if(c){let e=n===`horizontal`?new DOMRect(r.right,r.top,0,r.height):new DOMRect(r.left,r.bottom,r.width,0),t=n===`horizontal`?new DOMRect(a.left,a.top,0,a.height):new DOMRect(a.left,a.top,a.width,0);switch(p.length){case 0:m=[e,t];break;case 1:{let i=p[0];m=[i,kbe({orientation:n,rects:[r,a],targetRect:i.element.getBoundingClientRect()})===r?t:e];break}default:m=p;break}}else m=p.length?p:[n===`horizontal`?new DOMRect(r.right,a.top,a.left-r.right,a.height):new DOMRect(a.left,r.bottom,a.width,a.top-r.bottom)];for(let n of m){let r=`width`in n?n:n.element.getBoundingClientRect(),a=w5()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(r.width<a){let e=a-r.width;r=new DOMRect(r.x-e/2,r.y,r.width+e,r.height)}if(r.height<a){let e=a-r.height;r=new DOMRect(r.x,r.y-e/2,r.width,r.height+e)}!s&&!(t<=l||t>u)&&o.push({group:e,groupSize:_5({group:e}),panels:[f,i],separator:`width`in n?void 0:n,rect:r}),s=!1}}c=!1,f=i,p=[]}}else if(d.hasAttribute(`data-separator`)){d.ariaDisabled!==null&&(s=!0);let e=i.find(e=>e.element===d);e?p.push(e):(f=void 0,p=[])}else c=!0}return o}var Abe=class{#e={};addListener(e,t){let n=this.#e[e];return n===void 0?this.#e[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#e[e];if(n!==void 0)if(n.length===1)n[0].call(null,t);else{let e=!1,r=null,i=Array.from(n);for(let n=0;n<i.length;n++){let a=i[n];try{a.call(null,t)}catch(t){r===null&&(e=!0,r=t)}}if(e)throw r}}removeAllListeners(){this.#e={}}removeListener(e,t){let n=this.#e[e];if(n!==void 0){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}};function E5(e,t,n=0){return Math.abs(g5(e)-g5(t))<=n}var D5={cursorFlags:0,interactionState:{state:`inactive`},mountedGroups:new Map},O5=new Abe;function k5(){return D5}function A5(e){let t=typeof e==`function`?e(D5):e;if(D5===t)return D5;let n=D5;return D5={...D5,...t},t.cursorFlags!==void 0&&O5.emit(`cursorFlagsChange`,D5.cursorFlags),t.interactionState!==void 0&&O5.emit(`interactionStateChange`,D5.interactionState),t.mountedGroups!==void 0&&(D5.mountedGroups.forEach((e,t)=>{e.derivedPanelConstraints.forEach(r=>{if(r.collapsible){let{layout:i}=n.mountedGroups.get(t)??{};if(i){let n=E5(r.collapsedSize,e.layout[r.panelId]),a=E5(r.collapsedSize,i[r.panelId]);n&&!a&&(t.inMemoryLastExpandedPanelSizes[r.panelId]=i[r.panelId])}}})}),O5.emit(`mountedGroupsChange`,D5.mountedGroups)),D5}function jbe(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=S5(n,a.rect);switch(e){case`horizontal`:t.x<=i.x&&(r=a,i=t);break;case`vertical`:t.y<=i.y&&(r=a,i=t);break}}return r?{distance:i,hitRegion:r}:void 0}function Mbe(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Nbe(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:N5(e),b:N5(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();y5(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:M5(j5(n.a)),b:M5(j5(n.b))};if(i.a===i.b){let e=r.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let n=e[i];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(i.a-i.b)}var Pbe=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Fbe(e){let t=getComputedStyle(P5(e)??e).display;return t===`flex`||t===`inline-flex`}function Ibe(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||Fbe(e))||+t.opacity<1||`transform`in t&&t.transform!==`none`||`webkitTransform`in t&&t.webkitTransform!==`none`||`mixBlendMode`in t&&t.mixBlendMode!==`normal`||`filter`in t&&t.filter!==`none`||`webkitFilter`in t&&t.webkitFilter!==`none`||`isolation`in t&&t.isolation===`isolate`||Pbe.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function j5(e){let t=e.length;for(;t--;){let n=e[t];if(y5(n,`Missing node`),Ibe(n))return n}return null}function M5(e){return e&&Number(getComputedStyle(e).zIndex)||0}function N5(e){let t=[];for(;e;)t.push(e),e=P5(e);return t}function P5(e){let{parentNode:t}=e;return Mbe(t)?t.host:t}function Lbe(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Rbe({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!x5(n)||n.contains(e)||e.contains(n))return!0;if(Nbe(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(Lbe(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function F5(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=T5(r),a=jbe(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&Rbe({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function zbe(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function I5(e,t){return E5(e,t)?0:e>t?1:-1}function L5({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){let{collapsedSize:i=0,collapsible:a,disabled:o,maxSize:s=100,minSize:c=0}=t;if(o&&!e)return n;if(I5(r,c)<0)if(a){let e=(i+c)/2;r=I5(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=g5(r),r}function R5({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(E5(e,0))return t;let o=a===`imperative-api`,s=Object.values(t),c=Object.values(i),l=[...s],[u,d]=r;y5(u!=null,`Invalid first pivot index`),y5(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];y5(r,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(y5(n!=null,`Previous layout not found for panel index ${t}`),E5(n,i)){let t=o-n;I5(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];y5(r,`No panel constraints found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(y5(n!=null,`Previous layout not found for panel index ${t}`),E5(n,o)){let t=n-i;I5(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];y5(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsible:a,collapsedSize:o,minSize:c}=r;if(a&&I5(i,c)<0)if(e>0){let t=c-o,n=t/2;I5(i+e,c)<0&&(e=I5(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;I5(i-e,c)<0&&(e=I5(100+e,n)>0?0:-t)}break}}{let t=e<0?1:-1,r=e<0?d:u,i=0;for(;;){let e=s[r];y5(e!=null,`Previous layout not found for panel index ${r}`);let a=L5({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:e,size:100})-e;if(i+=a,r+=t,r<0||r>=n.length)break}let a=Math.min(Math.abs(e),Math.abs(i));e=e<0?0-a:a}{let t=e<0?u:d;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(f),i=s[t];y5(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=L5({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!E5(i,c)&&(f+=i-c,l[t]=c,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(zbe(c,l))return i;{let t=e<0?d:u,r=s[t];y5(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=L5({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!E5(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];y5(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=L5({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(E5(i,s)||(t-=s-i,l[r]=s),E5(t,0))break;e>0?r--:r++}}}if(!E5(Object.values(l).reduce((e,t)=>t+e,0),100,.1))return i;let p=Object.keys(i);return l.reduce((e,t,n)=>(e[p[n]]=t,e),{})}function z5(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||I5(e[n],t[n])!==0)return!1;return!0}function B5({layout:e,panelConstraints:t}){let n=Object.values(e),r=[...n],i=r.reduce((e,t)=>e+t,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(e=>`${e}%`).join(`, `)}`);if(!E5(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];y5(t!=null,`No layout data found for index ${e}`),r[e]=100/i*t}let a=0;for(let e=0;e<t.length;e++){let i=n[e];y5(i!=null,`No layout data found for index ${e}`);let o=r[e];y5(o!=null,`No layout data found for index ${e}`);let s=L5({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!E5(a,0))for(let e=0;e<t.length;e++){let n=r[e];y5(n!=null,`No layout data found for index ${e}`);let i=n+a,o=L5({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,E5(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function V5({groupId:e,panelId:t}){let n=()=>{let{mountedGroups:t}=k5();for(let[n,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:a,separatorToPanels:o}]of t)if(n.id===e)return{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:n,layout:a,separatorToPanels:o};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedPanelConstraints.find(e=>e.panelId===t);if(e!==void 0)return e;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{let e=n().group.panels.find(e=>e.id===t);if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},a=()=>{let e=n().layout[t];if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},o=e=>{let r=a();if(e===r)return;let{defaultLayoutDeferred:i,derivedPanelConstraints:o,group:s,layout:c,separatorToPanels:l}=n(),u=s.panels.findIndex(e=>e.id===t),d=u===s.panels.length-1,f=B5({layout:R5({delta:d?r-e:e-r,initialLayout:c,panelConstraints:o,pivotIndices:d?[u-1,u]:[u,u+1],prevLayout:c,trigger:`imperative-api`}),panelConstraints:o});z5(c,f)||A5(e=>({mountedGroups:new Map(e.mountedGroups).set(s,{defaultLayoutDeferred:i,derivedPanelConstraints:o,layout:f,separatorToPanels:l})}))};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=i(),s=a();e&&s!==t&&(n.expandToSize=s,o(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:s}=i(),c=a();if(e&&c===t){let e=s.expandToSize??n;e===0&&(e=1),o(e)}},getSize:()=>{let{group:e}=n(),t=a(),{element:r}=i();return{asPercentage:t,inPixels:e.orientation===`horizontal`?r.offsetWidth:r.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=a();return e&&E5(t,n)},resize:e=>{if(a()!==e){let t;switch(typeof e){case`number`:{let{group:r}=n();t=g5(e/_5({group:r})*100);break}case`string`:t=parseFloat(e);break}o(t)}}}}function H5(e){if(e.defaultPrevented)return;let{mountedGroups:t}=k5();F5(e,t).forEach(t=>{if(t.separator){let n=t.panels.find(e=>e.panelConstraints.defaultSize!==void 0);if(n){let r=n.panelConstraints.defaultSize,i=V5({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function U5(e){let{mountedGroups:t}=k5();for(let[n]of t)if(n.separators.some(t=>t.element===e))return n;throw Error(`Could not find parent Group for separator element`)}function W5({groupId:e}){let t=()=>{let{mountedGroups:t}=k5();for(let[n,r]of t)if(n.id===e)return{group:n,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{defaultLayoutDeferred:n,derivedPanelConstraints:r,group:i,layout:a,separatorToPanels:o}=t(),s=B5({layout:e,panelConstraints:r});if(n)return a;if(!z5(a,s)){A5(e=>({mountedGroups:new Map(e.mountedGroups).set(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,layout:s,separatorToPanels:o})}));let e=i.panels.map(({id:e})=>e).join(`,`);i.inMemoryLayouts[e]=s}return s}}}function G5(e){let{mountedGroups:t}=k5(),n=t.get(e);return y5(n,`Mounted Group ${e.id} not found`),n}function K5(e,t){let n=U5(e),r=G5(n),i=n.separators.find(t=>t.element===e);y5(i,`Matching separator not found`);let a=r.separatorToPanels.get(i);y5(a,`Matching panels not found`);let o=a.map(e=>n.panels.indexOf(e)),s=W5({groupId:n.id}).getLayout(),c=B5({layout:R5({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});z5(s,c)||A5(e=>({mountedGroups:new Map(e.mountedGroups).set(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,layout:c,separatorToPanels:r.separatorToPanels})}))}function q5(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=U5(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&K5(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&K5(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&K5(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&K5(t,-5);break;case`End`:e.preventDefault(),K5(t,100);break;case`Enter`:{e.preventDefault();let n=U5(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=G5(n),o=n.separators.find(e=>e.element===t);y5(o,`Matching separator not found`);let s=a.get(o);y5(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.panelId===c.id);if(y5(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];K5(t,(l.collapsedSize===e?n.inMemoryLastExpandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=U5(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);y5(r!==null,`Index not found`),n[e.shiftKey?r>0?r-1:n.length-1:r+1<n.length?r+1:0].focus();break}case`Home`:e.preventDefault(),K5(t,-100);break}}function J5(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let{mountedGroups:t}=k5(),n=F5(e,t),r=new Map,i=!1;n.forEach(e=>{e.separator&&(i||(i=!0,e.separator.element.focus()));let n=t.get(e.group);n&&r.set(e.group,n.layout)}),A5({interactionState:{hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}}),n.length&&e.preventDefault()}var Bbe=e=>e,Y5=()=>{},X5=1,Z5=2,Q5=4,$5=8,e7=3,t7=12,n7;function r7(){return n7===void 0&&(n7=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(n7=!0)),n7}function Vbe({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case`active`:case`hover`:t.forEach(e=>{if(!e.disableCursor)switch(e.orientation){case`horizontal`:r++;break;case`vertical`:i++;break}})}if(!(r===0&&i===0)){switch(n){case`active`:if(e&&r7()){let t=(e&X5)!==0,n=(e&Z5)!==0,r=(e&Q5)!==0,i=(e&$5)!==0;if(t)return r?`se-resize`:i?`ne-resize`:`e-resize`;if(n)return r?`sw-resize`:i?`nw-resize`:`w-resize`;if(r)return`s-resize`;if(i)return`n-resize`}break}return r7()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var i7=new WeakMap;function a7(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=i7.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets.push(n));let{cursorFlags:r,interactionState:i}=k5();switch(i.state){case`active`:case`hover`:{let e=Vbe({cursorFlags:r,groups:i.hitRegions.map(e=>e.group),state:i.state}),a=`*, *:hover {cursor: ${e} !important; }`;if(t===a)return;t=a,e?n.cssRules.length===0?n.insertRule(a):n.replaceSync(a):n.cssRules.length===1&&n.deleteRule(0);break}case`inactive`:t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}i7.set(e,{prevStyle:t,styleSheet:n})}function o7({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:a,prevCursorFlags:o}){let s=0,c=new Map(i);n.forEach(e=>{let{group:n,groupSize:o}=e,{disableCursor:l,orientation:u,panels:d}=n,f=0;f=a?u===`horizontal`?(t.clientX-a.x)/o*100:(t.clientY-a.y)/o*100:u===`horizontal`?t.clientX<0?-100:100:t.clientY<0?-100:100;let p=r.get(n),{defaultLayoutDeferred:m,derivedPanelConstraints:h,layout:g,separatorToPanels:_}=i.get(n)??{defaultLayoutDeferred:!1};if(h&&p&&g&&_){let t=R5({delta:f,initialLayout:p,panelConstraints:h,pivotIndices:e.panels.map(e=>d.indexOf(e)),prevLayout:g,trigger:`mouse-or-touch`});if(z5(t,g)){if(f!==0&&!l)switch(u){case`horizontal`:s|=f<0?X5:Z5;break;case`vertical`:s|=f<0?Q5:$5;break}}else{c.set(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,layout:t,separatorToPanels:_});let n=e.group.panels.map(({id:e})=>e).join(`,`);e.group.inMemoryLayouts[n]=t}}});let l=0;t.movementX===0?l|=o&e7:l|=s&e7,t.movementY===0?l|=o&t7:l|=s&t7,A5({cursorFlags:l,mountedGroups:c}),a7(e)}function s7(e){let{cursorFlags:t,interactionState:n,mountedGroups:r}=k5();switch(n.state){case`active`:o7({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:r,prevCursorFlags:t})}}function c7(e){if(e.defaultPrevented)return;let{cursorFlags:t,interactionState:n,mountedGroups:r}=k5();switch(n.state){case`active`:if(e.buttons===0){A5(e=>e.interactionState.state===`inactive`?e:{cursorFlags:0,interactionState:{state:`inactive`}}),A5(e=>({mountedGroups:new Map(e.mountedGroups)}));return}o7({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:r,pointerDownAtPoint:n.pointerDownAtPoint,prevCursorFlags:t});break;default:{let t=F5(e,r);t.length===0?n.state!==`inactive`&&A5({interactionState:{state:`inactive`}}):A5({interactionState:{hitRegions:t,state:`hover`}}),a7(e.currentTarget);break}}}function l7(e){if(e.relatedTarget instanceof HTMLIFrameElement){let{interactionState:e}=k5();switch(e.state){case`hover`:A5({interactionState:{state:`inactive`}})}}}function u7(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let{interactionState:t}=k5();switch(t.state){case`active`:A5({cursorFlags:0,interactionState:{state:`inactive`}}),t.hitRegions.length>0&&(a7(e.currentTarget),A5(e=>({mountedGroups:new Map(e.mountedGroups)})),e.preventDefault())}}function d7(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=g5(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=g5((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function Hbe(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=_5({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:g5(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function Ube(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function Wbe(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}var f7=new Map;function Gbe(e){let t=!0;y5(e.element.ownerDocument.defaultView,`Cannot register an unmounted Group`);let n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,a=new n(n=>{for(let r of n){let{borderBoxSize:n,target:i}=r;if(i===e.element){if(t){if(_5({group:e})===0)return;A5(t=>{let n=t.mountedGroups.get(e);if(n){let r=v5(e),i=n.defaultLayoutDeferred?d7(r):n.layout,a=B5({layout:i,panelConstraints:r});return!n.defaultLayoutDeferred&&z5(i,a)&&Ube(n.derivedPanelConstraints,r)?t:{mountedGroups:new Map(t.mountedGroups).set(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,layout:a,separatorToPanels:n.separatorToPanels})}}return t})}}else Hbe(e,i,n)}});a.observe(e.element),e.panels.forEach(e=>{y5(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&a.observe(e.element)});let o=_5({group:e}),s=v5(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.defaultLayout;l&&(Wbe(e.panels,l)||(l=void 0));let u=B5({layout:e.inMemoryLayouts[c]??l??d7(s),panelConstraints:s}),d=T5(e),f=e.element.ownerDocument;return A5(t=>{let n=new Map;return f7.set(f,(f7.get(f)??0)+1),d.forEach(e=>{e.separator&&n.set(e.separator,e.panels)}),{mountedGroups:new Map(t.mountedGroups).set(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:s,layout:u,separatorToPanels:n})}}),e.separators.forEach(e=>{y5(!i.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),i.add(e.id),e.element.addEventListener(`keydown`,q5)}),f7.get(f)===1&&(f.addEventListener(`dblclick`,H5,!0),f.addEventListener(`pointerdown`,J5,!0),f.addEventListener(`pointerleave`,s7),f.addEventListener(`pointermove`,c7),f.addEventListener(`pointerout`,l7),f.addEventListener(`pointerup`,u7,!0)),function(){t=!1,f7.set(f,Math.max(0,(f7.get(f)??0)-1)),A5(t=>{let n=new Map(t.mountedGroups);return n.delete(e),{mountedGroups:n}}),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,q5)}),f7.get(f)||(f.removeEventListener(`dblclick`,H5,!0),f.removeEventListener(`pointerdown`,J5,!0),f.removeEventListener(`pointerleave`,s7),f.removeEventListener(`pointermove`,c7),f.removeEventListener(`pointerout`,l7),f.removeEventListener(`pointerup`,u7,!0)),a.disconnect()}}function Kbe(){let[e,t]=(0,G.useState)({});return[e,(0,G.useCallback)(()=>t({}),[])]}function p7(e){let t=(0,G.useId)();return`${e??t}`}var m7=typeof window<`u`?G.useLayoutEffect:G.useEffect;function h7(e){let t=(0,G.useRef)(e);return m7(()=>{t.current=e},[e]),(0,G.useCallback)((...e)=>t.current?.(...e),[t])}function g7(...e){return h7(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function _7(e){let t=(0,G.useRef)({...e});return m7(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var v7=(0,G.createContext)(null);function qbe(e,t){let n=(0,G.useRef)({getLayout:()=>({}),setLayout:Bbe});(0,G.useImperativeHandle)(t,()=>n.current,[]),m7(()=>{Object.assign(n.current,W5({groupId:e}))})}function y7({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:o,id:s,onLayoutChange:c,onLayoutChanged:l,orientation:u=`horizontal`,resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){let m=(0,G.useRef)({onLayoutChange:{},onLayoutChanged:{}}),h=h7(e=>{z5(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=h7(e=>{z5(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e))}),_=p7(s),v=(0,G.useRef)(null),[y,b]=Kbe(),x=(0,G.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=g7(v,a);qbe(_,o);let C=h7((e,t)=>{let{interactionState:r,mountedGroups:i}=k5();for(let n of i.keys())if(n.id===e){let e=i.get(n);if(e){let i=!1;switch(r.state){case`active`:i=r.hitRegions.some(e=>e.group===n);break}return{flexGrow:e.layout[t]??1,pointerEvents:i?`none`:void 0}}}return{flexGrow:n?.[t]??1}}),w=_7({defaultLayout:n,disableCursor:r}),T=(0,G.useMemo)(()=>({get disableCursor(){return!!w.disableCursor},getPanelStyles:C,id:_,orientation:u,registerPanel:e=>{let t=x.current;return t.panels=b5(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=b5(u,[...t.separators,e]),b(),()=>{t.separators=t.separators.filter(t=>t!==e),b()}},togglePanelDisabled:(e,t)=>{let n=x.current.panels.find(t=>t.id===e);n&&(n.panelConstraints.disabled=t);let{mountedGroups:r}=k5();for(let e of r.keys())if(e.id===_){let t=r.get(e);t&&(t.derivedPanelConstraints=v5(e))}},toggleSeparatorDisabled:(e,t)=>{let n=x.current.separators.find(t=>t.id===e);n&&(n.disabled=t)}}),[C,_,b,u,w]),E=(0,G.useRef)(null);return m7(()=>{let e=v.current;if(e===null)return;let t=x.current,n;if(w.defaultLayout!==void 0&&Object.keys(w.defaultLayout).length===t.panels.length){n={};for(let e of t.panels){let t=w.defaultLayout[e.id];t!==void 0&&(n[e.id]=t)}}let r={defaultLayout:n,disableCursor:!!w.disableCursor,disabled:!!i,element:e,id:_,inMemoryLastExpandedPanelSizes:x.current.lastExpandedPanelSizes,inMemoryLayouts:x.current.layouts,orientation:u,panels:t.panels,resizeTargetMinimumSize:t.resizeTargetMinimumSize,separators:t.separators};E.current=r;let a=Gbe(r),o=k5().mountedGroups.get(r);if(o){let{defaultLayoutDeferred:e,derivedPanelConstraints:t,layout:n}=o;!e&&t.length>0&&(h(n),g(n))}let s=O5.addListener(`interactionStateChange`,e=>{e.state}),c=O5.addListener(`mountedGroupsChange`,e=>{let t=e.get(r);if(t){let{defaultLayoutDeferred:e,derivedPanelConstraints:n,layout:r}=t;if(e||n.length===0)return;let{interactionState:i}=k5(),a=i.state!==`active`;h(r),a&&g(r)}});return()=>{E.current=null,a(),s(),c()}},[i,_,g,h,u,y,w]),(0,G.useEffect)(()=>{let e=E.current;e&&(e.defaultLayout=n,e.disableCursor=!!r)}),(0,K.jsx)(v7.Provider,{value:T,children:(0,K.jsx)(`div`,{...p,className:t,"data-group":!0,"data-testid":_,id:_,ref:S,style:{height:`100%`,width:`100%`,overflow:`hidden`,...f,display:`flex`,flexDirection:u===`horizontal`?`row`:`column`,flexWrap:`nowrap`,touchAction:u===`horizontal`?`pan-y`:`pan-x`},children:e})})}y7.displayName=`Group`;function b7(e,t){return`react-resizable-panels:${[e,...t].join(`:`)}`}function Jbe({debounceSaveMs:e=100,panelIds:t,storage:n=localStorage,...r}){let i=t!==void 0,a=`id`in r?r.id:r.groupId,o=b7(a,t??[]),s=(0,G.useSyncExternalStore)(Ybe,()=>n.getItem(o),()=>n.getItem(o)),c=(0,G.useMemo)(()=>s?JSON.parse(s):void 0,[s]),l=(0,G.useRef)(null),u=(0,G.useCallback)(()=>{let e=l.current;e&&(l.current=null,clearTimeout(e))},[]);(0,G.useLayoutEffect)(()=>()=>{u()},[u]);let d=(0,G.useCallback)(e=>{u();let t;t=i?b7(a,Object.keys(e)):b7(a,[]);try{n.setItem(t,JSON.stringify(e))}catch(e){console.error(e)}},[u,i,a,n]);return{defaultLayout:c,onLayoutChange:(0,G.useCallback)(t=>{u(),e===0?d(t):l.current=setTimeout(()=>{d(t)},e)},[u,e,d]),onLayoutChanged:d}}function Ybe(){return function(){}}function Xbe(){return(0,G.useState)(null)}function Zbe(){return(0,G.useRef)(null)}function x7(){let e=(0,G.useContext)(v7);return y5(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function Qbe(e,t){let{id:n}=x7(),r=(0,G.useRef)({collapse:Y5,expand:Y5,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Y5});(0,G.useImperativeHandle)(t,()=>r.current,[]),m7(()=>{Object.assign(r.current,V5({groupId:n,panelId:e}))})}function S7({children:e,className:t,collapsedSize:n=`0%`,collapsible:r=!1,defaultSize:i,disabled:a,elementRef:o,id:s,maxSize:c=`100%`,minSize:l=`0%`,onResize:u,panelRef:d,style:f,...p}){let m=!!s,h=p7(s),g=_7({disabled:a}),_=(0,G.useRef)(null),v=g7(_,o),{getPanelStyles:y,id:b,orientation:x,registerPanel:S,togglePanelDisabled:C}=x7(),w=u!==null,T=h7((e,t,n)=>{u?.(e,s,n)});m7(()=>{let e=_.current;if(e!==null)return S({element:e,id:h,idIsStable:m,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:w?T:void 0,panelConstraints:{collapsedSize:n,collapsible:r,defaultSize:i,disabled:g.disabled,maxSize:c,minSize:l}})},[n,r,i,w,h,m,c,l,T,S,g]),(0,G.useEffect)(()=>{C(h,!!a)},[a,h,C]),Qbe(h,d);let E=(0,G.useSyncExternalStore)(e=>(O5.addListener(`mountedGroupsChange`,e),()=>{O5.removeListener(`mountedGroupsChange`,e)}),()=>JSON.stringify(y(b,h)),()=>JSON.stringify(y(b,h)));return(0,K.jsx)(`div`,{...p,"aria-disabled":a||void 0,"data-panel":!0,"data-testid":h,id:h,ref:v,style:{...$be,display:`flex`,flexBasis:0,flexShrink:1,overflow:`hidden`,...JSON.parse(E)},children:(0,K.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,...f,touchAction:x===`horizontal`?`pan-y`:`pan-x`},children:e})})}S7.displayName=`Panel`;var $be={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function exe(){return(0,G.useState)(null)}function txe(){return(0,G.useRef)(null)}function nxe({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,a,o=e[n],s=t.find(e=>e.panelId===n);if(s){let c=s.maxSize,l=s.collapsible?s.collapsedSize:s.minSize,u=[r,r+1];a=B5({layout:R5({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=B5({layout:R5({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function C7({children:e,className:t,disabled:n,elementRef:r,id:i,style:a,...o}){let s=p7(i),c=_7({disabled:n}),[l,u]=(0,G.useState)({}),[d,f]=(0,G.useState)(`inactive`),p=(0,G.useRef)(null),m=g7(p,r),{disableCursor:h,id:g,orientation:_,registerSeparator:v,toggleSeparatorDisabled:y}=x7(),b=_===`horizontal`?`vertical`:`horizontal`;m7(()=>{let e=p.current;if(e!==null){let t={disabled:c.disabled,element:e,id:s},n=v(t),r=O5.addListener(`interactionStateChange`,e=>{f(e.state!==`inactive`&&e.hitRegions.some(e=>e.separator===t)?e.state:`inactive`)}),i=O5.addListener(`mountedGroupsChange`,e=>{e.forEach(({derivedPanelConstraints:e,layout:n,separatorToPanels:r},i)=>{if(i.id===g){let a=r.get(t);if(a){let t=a[0],r=i.panels.indexOf(t);u(nxe({layout:n,panelConstraints:e,panelId:t.id,panelIndex:r}))}}})});return()=>{r(),i(),n()}}},[g,s,v,c]),(0,G.useEffect)(()=>{y(s,!!n)},[n,s,y]);let x;return n&&!h&&(x=`not-allowed`),(0,K.jsx)(`div`,{...o,"aria-controls":l.valueControls,"aria-disabled":n||void 0,"aria-orientation":b,"aria-valuemax":l.valueMax,"aria-valuemin":l.valueMin,"aria-valuenow":l.valueNow,children:e,className:t,"data-separator":n?`disabled`:d,"data-testid":s,id:s,ref:m,role:`separator`,style:{flexBasis:`auto`,cursor:x,...a,flexGrow:0,flexShrink:0,touchAction:`none`},tabIndex:n?void 0:0})}C7.displayName=`Separator`;var{usePanelRef:w7}=xbe;function T7({className:e,...t}){return(0,K.jsx)(y7,{"data-slot":`resizable-panel-group`,className:q(`flex h-full w-full aria-[orientation=vertical]:flex-col`,e),...t})}function E7({...e}){return(0,K.jsx)(S7,{"data-slot":`resizable-panel`,...e})}function D7({withHandle:e,className:t,...n}){return(0,K.jsx)(C7,{"data-slot":`resizable-handle`,className:q(`relative flex items-center justify-center bg-border`,`focus-visible:ring-ring focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden`,`after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2`,`aria-[orientation=vertical]:h-auto aria-[orientation=vertical]:w-px`,`aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full`,`aria-[orientation=vertical]:after:left-0 aria-[orientation=vertical]:after:h-1 aria-[orientation=vertical]:after:w-full aria-[orientation=vertical]:after:translate-x-0 aria-[orientation=vertical]:after:-translate-y-1/2`,`[&[aria-orientation=horizontal]>div]:rotate-90`,t),...n,children:e&&(0,K.jsx)(`div`,{className:`bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border`,children:(0,K.jsx)(Ch,{className:`size-2.5`})})})}function O7({className:e,...t}){return(0,K.jsx)(`kbd`,{"data-slot":`kbd`,className:q(`bg-muted text-muted-foreground pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none`,`[&_svg:not([class*='size-'])]:size-3`,`[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10`,e),...t})}function rxe({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:r,onSearchExpand:i,onSearchChange:a,onSearchBlur:o,onCancelAll:s,searchInputRef:c}){return(0,K.jsxs)(`div`,{className:`flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2`,children:[(0,K.jsx)(`div`,{className:`flex items-center gap-2 flex-1`,children:e?(0,K.jsx)(uy,{ref:c,placeholder:`Search requests...`,value:t,onChange:e=>a(e.target.value),onBlur:o,className:`h-8 border-gray-300 dark:border-zinc-600`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-medium text-gray-900 dark:text-gray-100`,"data-testid":`elicitation-tab-header`,children:`Elicitation`}),(0,K.jsx)(Aa,{className:`bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent`,variant:`outline`,children:n}),(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:i,className:`h-8 w-8 p-0`,children:(0,K.jsx)(Vh,{className:`h-4 w-4`})})}),(0,K.jsxs)(Im,{side:`bottom`,className:`flex gap-2`,children:[`Search`,(0,K.jsx)(O7,{children:`F`})]})]})]})}),(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:s,disabled:r===0,className:`h-8 w-8 p-0`,children:(0,K.jsx)(tg,{className:`h-4 w-4`})})}),(0,K.jsx)(Im,{side:`bottom`,children:`Cancel all`})]})})]})}function k7({id:e,isSelected:t,isFocused:n,icon:r,title:i,description:a,metadata:o,onClick:s,className:c,"data-testid":l}){return(0,K.jsx)(`button`,{id:e,"data-testid":l,type:`button`,onClick:s,className:q(`w-full text-left cursor-pointer p-2 sm:p-4 border-b dark:border-zinc-700 hover:bg-gray-50 dark:hover:bg-zinc-800/50 transition-colors group`,t&&`bg-zinc-50 dark:bg-zinc-800 border-l-4 border-l-zinc-500`,n&&`ring-2 ring-zinc-500 dark:ring-zinc-400 ring-inset`,c),children:(0,K.jsxs)(`div`,{className:`flex items-start gap-2 sm:gap-3`,children:[r&&(0,K.jsx)(`div`,{className:`flex-shrink-0 mt-1`,children:(0,K.jsx)(`div`,{className:q(`p-2.5 rounded-full transition-colors`,t?`bg-zinc-500 dark:bg-zinc-100/80 text-zinc-100 dark:text-zinc-900`:`bg-gray-100 dark:bg-zinc-700 text-gray-600 dark:text-gray-400 group-hover:bg-gray-200 dark:group-hover:bg-zinc-600`),children:r})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`flex items-center gap-2 mb-1`,children:(0,K.jsx)(`h3`,{className:q(`font-medium truncate font-mono text-sm`),children:i})}),a&&(0,K.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 line-clamp-2`,children:a})]}),o&&(0,K.jsx)(`div`,{className:`flex-shrink-0 flex items-center self-center`,children:o})]})})}function ixe({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:r,formatRelativeTime:i,listRef:a}){return e.length===0?(0,K.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:(0,K.jsx)(nm,{vertical:!0,noBorder:!0,message:`No elicitation requests`})}):(0,K.jsx)(`div`,{ref:a,className:`overflow-y-auto flex-1 overscroll-contain`,children:e.map((e,a)=>{let o=e.request.mode||`form`,s=o===`form`&&`requestedSchema`in e.request&&e.request.requestedSchema;return(0,K.jsx)(k7,{id:`elicitation-request-${e.id}`,"data-testid":`elicitation-request-item-${a}`,isSelected:t?.id===e.id,isFocused:r===a,title:(0,K.jsxs)(`span`,{className:`flex items-center gap-3`,children:[e.serverName,(0,K.jsx)(Aa,{variant:`outline`,className:o===`url`?`bg-blue-500/20 text-blue-600 dark:text-blue-400 border-blue-500/50`:`bg-green-500/20 text-green-600 dark:text-green-400 border-green-500/50`,children:o})]}),description:(()=>{let t=i(e.timestamp),n=[];return s&&n.push(`with schema`),o===`url`&&n.push(`external action`),t+(n.length>0?` | ${n.join(`, `)}`:``)})(),onClick:()=>n(e)},e.id)})})}function A7(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.const==`string`&&(t.title===void 0||typeof t.title==`string`)}function axe(e){let t=Array.isArray(e.oneOf)?e.oneOf.filter(A7):[],n=Array.isArray(e.anyOf)?e.anyOf.filter(A7):[];return t.length>0?t:n}function oxe(e){let t=e.items&&typeof e.items==`object`?e.items:{},n=Array.isArray(t.anyOf)?t.anyOf.filter(A7):[],r=Array.isArray(t.oneOf)?t.oneOf.filter(A7):[];return n.length>0?n:r}function sxe({request:e,onApprove:t,onReject:r,onClose:i,previewMode:a,onTogglePreview:o,isCopied:s,onCopy:c,onDownload:l,onFullscreen:u}){let[d,f]=(0,G.useState)({}),[p,m]=(0,G.useState)(!1),h=e?.request.mode||`form`,g=h===`form`,_=h===`url`;(0,G.useEffect)(()=>{if(e&&g&&`requestedSchema`in e.request){let t=e.request.requestedSchema,n={};if(t?.type===`object`&&t.properties)for(let[e,r]of Object.entries(t.properties)){let t=r;t.default===void 0?t.type===`array`?n[e]=[]:t.type===`boolean`?n[e]=!1:t.type===`number`||t.type===`integer`?n[e]=0:n[e]=``:n[e]=t.default}f(n)}m(!1)},[e?.id,g]);let v=(e,t)=>{f(n=>({...n,[e]:t}))},y=()=>{if(e){if(g){if(`requestedSchema`in e.request){let t=e.request.requestedSchema;if(t?.required){let e=t.required.filter(e=>d[e]===void 0||d[e]===``||d[e]===null);if(e.length>0){xv.error(`Missing required fields`,{description:`Please fill in: ${e.join(`, `)}`});return}}}t(e.id,{action:`accept`,content:d})}else _&&t(e.id,{action:`accept`});i(),B(()=>import(`./react-Cg35ZZKt.js`).then(e=>n(e.default,1)).then(e=>{let t=xv(e.createElement(`div`,{className:`space-y-3`},e.createElement(`div`,null,e.createElement(`strong`,null,`Elicitation Response Sent`),e.createElement(`p`,{className:`text-sm text-muted-foreground mt-1`},`The tool will continue executing.`)),e.createElement(`div`,{className:`flex gap-2`},e.createElement(`button`,{"data-testid":`elicitation-view-tool-result`,className:`px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90`,onClick:()=>{let e=new globalThis.CustomEvent(`navigate-to-tool-result`,{detail:{toolName:null}});window.dispatchEvent(e),xv.dismiss(t)}},`View Tool Result`))),{duration:5e3})}),[])}},b=()=>{e&&(t(e.id,{action:`decline`}),i())},x=()=>{e&&(r(e.id,`User cancelled elicitation request`),i())},S=()=>{e&&_&&`url`in e.request&&(window.open(e.request.url,`_blank`),m(!0))},C=(0,G.useMemo)(()=>{if(!e||!g||!(`requestedSchema`in e.request))return null;let t=e.request.requestedSchema;if(!t||t.type!==`object`||!t.properties)return(0,K.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:`No form schema available`});let n=t.properties,r=t.required||[];return(0,K.jsx)(`div`,{className:`space-y-4`,children:Object.entries(n).map(([e,t])=>{let n=t,i=r.includes(e),a=n.type||`string`,o=n.title||e,s=n.description,c=axe(n),l=c.length>0,u=Array.isArray(n.enum),f=a===`array`&&Array.isArray(n.items?.enum),p=oxe(n),m=a===`array`&&p.length>0,h=Array.isArray(d[e])?d[e]:[];return(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(py,{htmlFor:`field-${e}`,children:[o,i&&(0,K.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),s&&(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s}),a===`boolean`?(0,K.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,K.jsx)(_L,{id:`field-${e}`,"data-testid":`elicitation-field-${e}`,checked:d[e]||!1,onCheckedChange:t=>v(e,t)}),(0,K.jsx)(py,{htmlFor:`field-${e}`,className:`text-sm font-normal cursor-pointer`,children:n.title||e})]}):a===`number`||a===`integer`?(0,K.jsx)(uy,{id:`field-${e}`,"data-testid":`elicitation-field-${e}`,type:`number`,value:d[e]||``,onChange:t=>v(e,a===`integer`?parseInt(t.target.value,10):parseFloat(t.target.value)),placeholder:n.default?.toString()||``}):l?(0,K.jsxs)(`select`,{id:`field-${e}`,"data-testid":`elicitation-field-${e}`,value:d[e]||``,onChange:t=>v(e,t.target.value),className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:[(0,K.jsx)(`option`,{value:``,children:`Select...`}),c.map(e=>(0,K.jsx)(`option`,{value:e.const,children:e.title||e.const},e.const))]}):u?(0,K.jsxs)(`select`,{id:`field-${e}`,"data-testid":`elicitation-field-${e}`,value:d[e]||``,onChange:t=>v(e,t.target.value),className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:[(0,K.jsx)(`option`,{value:``,children:`Select...`}),n.enum.map((e,t)=>(0,K.jsx)(`option`,{value:e,children:n.enumNames?.[t]||e},e))]}):f?(0,K.jsx)(`div`,{className:`space-y-2`,"data-testid":`elicitation-field-${e}`,children:n.items.enum.map(t=>{let n=`field-${e}-${t}`;return(0,K.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,K.jsx)(_L,{id:n,checked:h.includes(t),onCheckedChange:n=>{v(e,n?[...h,t]:h.filter(e=>e!==t))}}),(0,K.jsx)(py,{htmlFor:n,className:`text-sm font-normal cursor-pointer`,children:t})]},t)})}):m?(0,K.jsx)(`div`,{className:`space-y-2`,"data-testid":`elicitation-field-${e}`,children:p.map(t=>{let n=`field-${e}-${t.const}`;return(0,K.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,K.jsx)(_L,{id:n,checked:h.includes(t.const),onCheckedChange:n=>{v(e,n?[...h,t.const]:h.filter(e=>e!==t.const))}}),(0,K.jsx)(py,{htmlFor:n,className:`text-sm font-normal cursor-pointer`,children:t.title||t.const})]},t.const)})}):a===`string`&&(n.format===`textarea`||n.maxLength>100)?(0,K.jsx)(tL,{id:`field-${e}`,"data-testid":`elicitation-field-${e}`,value:d[e]||``,onChange:t=>v(e,t.target.value),placeholder:n.default||``,rows:4}):(0,K.jsx)(uy,{id:`field-${e}`,"data-testid":`elicitation-field-${e}`,type:`text`,value:d[e]||``,onChange:t=>v(e,t.target.value),placeholder:n.default||``})]},e)})})},[e,d,g]);return e?(0,K.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b dark:border-zinc-700`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`h3`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:e.serverName}),(0,K.jsx)(Aa,{variant:`outline`,className:_?`bg-blue-500/20 text-blue-600 dark:text-blue-400 border-blue-500/50`:`bg-green-500/20 text-green-600 dark:text-green-400 border-green-500/50`,children:h}),(0,K.jsx)(`span`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:new Date(e.timestamp).toLocaleString()})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:c,className:`h-8 w-8 p-0`,children:s?(0,K.jsx)($m,{className:`h-4 w-4 text-green-600`}):(0,K.jsx)(uh,{className:`h-4 w-4`})})}),(0,K.jsx)(Im,{children:`Copy request`})]}),(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:l,className:`h-8 w-8 p-0`,children:(0,K.jsx)(fh,{className:`h-4 w-4`})})}),(0,K.jsx)(Im,{children:`Download request`})]}),(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:u,className:`h-8 w-8 p-0`,children:(0,K.jsx)(Ah,{className:`h-4 w-4`})})}),(0,K.jsx)(Im,{children:`Fullscreen`})]}),(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:i,className:`h-8 w-8 p-0`,children:(0,K.jsx)(tg,{className:`h-4 w-4`})})]})]}),(0,K.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-6`,children:[(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`Message`}),(0,K.jsx)(`p`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e.request.message})]}),_&&`url`in e.request&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`External Action Required`}),(0,K.jsxs)(`div`,{className:`bg-muted rounded-lg p-4 space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This request requires you to complete an action at an external URL:`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-background rounded border`,children:[(0,K.jsx)(`code`,{className:`flex-1 text-xs font-mono break-all`,children:e.request.url}),(0,K.jsxs)(J,{size:`sm`,variant:`outline`,onClick:S,className:`flex items-center gap-2`,children:[(0,K.jsx)(mh,{className:`h-4 w-4`}),`Open URL`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center space-x-2 pt-2`,children:[(0,K.jsx)(_L,{id:`url-completed`,checked:p,onCheckedChange:e=>m(!!e)}),(0,K.jsx)(py,{htmlFor:`url-completed`,className:`text-sm font-normal cursor-pointer`,children:`I have completed the required action`})]})]})]}),g&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`Form Data`}),C]}),g&&`requestedSchema`in e.request&&e.request.requestedSchema&&(0,K.jsxs)(`details`,{className:`space-y-2`,children:[(0,K.jsx)(`summary`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100 cursor-pointer`,children:`Schema (for reference)`}),(0,K.jsx)(`div`,{className:`bg-muted rounded-lg p-3 max-h-64 overflow-auto`,children:(0,K.jsx)(bO,{data:e.request.requestedSchema})})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 p-4 border-t dark:border-zinc-700`,children:[(0,K.jsx)(J,{onClick:y,className:`flex-1`,"data-testid":`elicitation-accept-button`,children:`Accept`}),(0,K.jsx)(J,{onClick:b,variant:`outline`,className:`flex-1`,"data-testid":`elicitation-decline-button`,children:`Decline`}),(0,K.jsx)(J,{onClick:x,variant:`outline`,className:`flex-1`,"data-testid":`elicitation-cancel-button`,children:`Cancel`})]})]}):(0,K.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:(0,K.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Select an elicitation request to view details`})})}function j7(e){let t=Date.now()-e,n=Math.floor(t/1e3),r=Math.floor(n/60),i=Math.floor(r/60),a=Math.floor(i/24);return n<60?`just now`:r<60?`${r}m ago`:i<24?`${i}h ago`:a<7?`${a}d ago`:new Date(e).toLocaleDateString()}function cxe({pendingRequests:e=[],onApprove:t,onReject:n,serverId:r,isConnected:i}){let{selectedElicitationRequestId:a,setSelectedElicitationRequestId:o}=SF(),[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(``),[d,f]=(0,G.useState)(-1),[p,m]=(0,G.useState)(!0),[h,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(!0),[y,b]=(0,G.useState)(!1),x=(0,G.useRef)(null),S=(0,G.useRef)(null),C=(0,G.useRef)(null),w=(0,G.useRef)(!1);(0,G.useEffect)(()=>{if(console.log(`[ElicitationTab] Auto-selection check:`,{selectedElicitationRequestId:a,pendingRequestsCount:e.length,currentSelectedId:s?.id}),a&&e.length>0){let t=e.find(e=>e.id===a);console.log(`[ElicitationTab] Found request for auto-selection:`,!!t,t?.id),t&&(console.log(`[ElicitationTab] Auto-selecting request:`,t.id),o(null),c(t),setTimeout(()=>{let e=document.getElementById(`elicitation-request-${t.id}`);console.log(`[ElicitationTab] Scrolling to element:`,!!e),e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},100))}},[a,e,o]),(0,G.useEffect)(()=>{let t=t=>{let n=t.detail.requestId;console.log(`[ElicitationTab] Custom navigate event received:`,n);let r=e.find(e=>e.id===n);r&&(console.log(`[ElicitationTab] Selecting request from event:`,n),c(r),setTimeout(()=>{let e=document.getElementById(`elicitation-request-${n}`);e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},200))};return window.addEventListener(`navigate-to-elicitation`,t),()=>window.removeEventListener(`navigate-to-elicitation`,t)},[e]),(0,G.useEffect)(()=>{p&&e.length>0&&x.current&&!w.current&&(x.current.scrollTop=0)},[e.length,p]),(0,G.useEffect)(()=>{let e=x.current;if(!e)return;let t=()=>{e.scrollTop>0&&(w.current=!0,m(!1))};return e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)},[]),(0,G.useEffect)(()=>{e.length===0&&(w.current=!1,m(!0))},[e.length]),(0,G.useEffect)(()=>{h&&C.current&&C.current.focus()},[h]);let T=(0,G.useCallback)(()=>{l.trim()||g(!1)},[l]),E=(0,G.useMemo)(()=>{if(!l.trim())return e;let t=l.toLowerCase();return e.filter(e=>e.serverName.toLowerCase().includes(t)||e.request.message.toLowerCase().includes(t)||JSON.stringify(e.request||{}).toLowerCase().includes(t))},[e,l]);(0,G.useEffect)(()=>{f(-1)},[l]),(0,G.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.contentEditable===`true`||e.metaKey||e.ctrlKey||e.altKey)return;let n=E;if(e.key===`ArrowDown`)e.preventDefault(),f(e=>{let t=e+1;return t>=n.length?0:t});else if(e.key===`ArrowUp`)e.preventDefault(),f(e=>{let t=e-1;return t<0?n.length-1:t});else if(e.key===`Enter`&&d>=0){e.preventDefault();let t=E[d];t&&D(t)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[d,E]),(0,G.useEffect)(()=>{if(d>=0){let e=`elicitation-request-${E[d]?.id}`,t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[d,E]);let D=(0,G.useCallback)(e=>{c(e)},[]),O=(0,G.useCallback)(()=>{window.confirm(`Are you sure you want to cancel all elicitation requests? This cannot be undone.`)&&(e.forEach(e=>{n(e.id,`User cancelled all requests`)}),c(null))},[e,n]),k=(0,G.useCallback)(async()=>{if(s)try{await rg(JSON.stringify({id:s.id,serverName:s.serverName,timestamp:s.timestamp,request:s.request},null,2)),b(!0),setTimeout(()=>b(!1),2e3)}catch(e){console.error(`[ElicitationTab] Failed to copy request:`,e)}},[s]),A=(0,G.useCallback)(()=>{if(s)try{let e=new globalThis.Blob([JSON.stringify({id:s.id,serverName:s.serverName,timestamp:s.timestamp,request:s.request},null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`elicitation-request-${Date.now()}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}catch(e){console.error(`[ElicitationTab] Failed to download request:`,e)}},[s]),j=(0,G.useCallback)(async()=>{if(S.current)try{document.fullscreenElement?await document.exitFullscreen():await S.current.requestFullscreen()}catch(e){console.error(`[ElicitationTab] Failed to toggle fullscreen:`,e)}},[]);return i?(0,K.jsxs)(T7,{orientation:`horizontal`,className:`h-full`,children:[(0,K.jsx)(E7,{defaultSize:40,minSize:30,children:(0,K.jsx)(T7,{orientation:`vertical`,className:`h-full border-r dark:border-zinc-700`,children:(0,K.jsxs)(E7,{defaultSize:75,minSize:30,children:[(0,K.jsx)(rxe,{isSearchExpanded:h,searchQuery:l,filteredRequestsCount:E.length,requestsCount:e.length,onSearchExpand:()=>g(!0),onSearchChange:u,onSearchBlur:T,onCancelAll:O,searchInputRef:C}),(0,K.jsx)(`div`,{className:`flex flex-col h-full`,children:(0,K.jsx)(ixe,{requests:E,selectedRequest:s,onRequestSelect:D,focusedIndex:d,formatRelativeTime:j7,listRef:x})})]})})}),(0,K.jsx)(D7,{}),(0,K.jsx)(E7,{defaultSize:60,minSize:40,children:(0,K.jsx)(`div`,{ref:S,className:`h-full bg-white dark:bg-zinc-900`,children:(0,K.jsx)(sxe,{request:s,onApprove:t,onReject:n,onClose:()=>c(null),previewMode:_,onTogglePreview:()=>v(!_),isCopied:y,onCopy:k,onDownload:A,onFullscreen:j})})})]}):(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,K.jsx)(Jh,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,K.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Not connected to server`})]})}function lxe({isSearchExpanded:e,searchQuery:t,filteredNotificationsCount:n,notificationsCount:r,onSearchExpand:i,onSearchChange:a,onSearchBlur:o,onClearAll:s,searchInputRef:c}){return(0,K.jsxs)(`div`,{className:`flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2`,children:[(0,K.jsx)(`div`,{className:`flex items-center gap-2 flex-1`,children:e?(0,K.jsx)(uy,{ref:c,placeholder:`Search notifications...`,value:t,onChange:e=>a(e.target.value),onBlur:o,className:`h-8 border-gray-300 dark:border-zinc-600`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-medium text-gray-900 dark:text-gray-100`,children:`Notifications`}),(0,K.jsx)(Aa,{className:`bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent`,variant:`outline`,children:n}),(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:i,className:`h-8 w-8 p-0`,children:(0,K.jsx)(Vh,{className:`h-4 w-4`})})}),(0,K.jsxs)(Im,{side:`bottom`,className:`flex gap-2`,children:[`Search`,(0,K.jsx)(O7,{children:`F`})]})]})]})}),(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:s,disabled:r===0,className:`h-8 w-8 p-0`,children:(0,K.jsx)($h,{className:`h-4 w-4`})})}),(0,K.jsx)(Im,{side:`bottom`,children:`Clear all`})]})})]})}function uxe({notifications:e,selectedNotification:t,onNotificationSelect:n,focusedIndex:r,formatRelativeTime:i,listRef:a}){return e.length===0?(0,K.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:(0,K.jsx)(nm,{vertical:!0,noBorder:!0,message:`No notifications yet`})}):(0,K.jsx)(`div`,{ref:a,className:`overflow-y-auto flex-1 overscroll-contain`,children:e.map((e,a)=>(0,K.jsx)(k7,{id:`notification-${e.id}`,isSelected:t?.id===e.id,isFocused:r===a,title:(0,K.jsxs)(`span`,{className:`flex items-center gap-3`,children:[e.method,!e.read&&(0,K.jsx)(`span`,{className:`size-1.5 block rounded-full bg-orange-500`})]}),description:(()=>{let t=i(e.timestamp),n=e.params&&Object.keys(e.params).length>0?Object.keys(e.params).length:0;return t+(n>0?` | ${n} param${n>1?`s`:``}`:``)})(),onClick:()=>n(e)},e.id))})}function dxe({notification:e,previewMode:t,onTogglePreview:n,onCopy:r,onDownload:i,onFullscreen:a,isCopied:o=!1,onClose:s}){return e?(0,K.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,K.jsxs)(`div`,{className:`flex-shrink-0 px-4 py-3 border-b border-gray-200 dark:border-zinc-700 flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(oh,{className:`h-3 w-3 text-gray-400`}),(0,K.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:new Date(e.timestamp).toLocaleTimeString()})]}),(0,K.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e.formatRelativeTime(e.timestamp)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsxs)(J,{variant:`ghost`,size:`sm`,onClick:n,className:t?``:`text-purple-600 dark:text-purple-400`,children:[t?(0,K.jsx)(sh,{className:`h-4 w-4 mr-1`}):(0,K.jsx)(Qm,{className:`h-4 w-4 mr-1`}),t?`JSON`:`Formatted`]}),(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:r,children:o?(0,K.jsx)($m,{className:`h-4 w-4`}):(0,K.jsx)(uh,{className:`h-4 w-4`})}),(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:i,children:(0,K.jsx)(fh,{className:`h-4 w-4`})}),(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:a,children:(0,K.jsx)(jh,{className:`h-4 w-4`})}),s&&(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:s,children:(0,K.jsx)(tg,{className:`h-4 w-4`})})]})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,K.jsx)(`div`,{className:`px-4 pt-4`,children:(0,K.jsx)(bO,{data:{method:e.method,timestamp:e.timestamp,read:e.read,params:e.params},filename:`notification-${e.method.replace(/[^a-zA-Z0-9]/g,`-`)}-${Date.now()}.json`})})})]}):(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,K.jsx)(Xm,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,K.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Select a notification to view details`})]})}function fxe({notifications:e,unreadCount:t,markNotificationRead:n,markAllNotificationsRead:r,clearNotifications:i,serverId:a,isConnected:o}){let[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(``),[d,f]=(0,G.useState)(-1),[p,m]=(0,G.useState)(!0),[h,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(!0),[y,b]=(0,G.useState)(!1),x=(0,G.useRef)(null),S=(0,G.useRef)(null),C=(0,G.useRef)(null),w=(0,G.useRef)(!1);(0,G.useEffect)(()=>{p&&e.length>0&&x.current&&!w.current&&(x.current.scrollTop=0)},[e.length,p]),(0,G.useEffect)(()=>{let e=x.current;if(!e)return;let t=()=>{e.scrollTop>0&&(w.current=!0,m(!1))};return e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)},[]),(0,G.useEffect)(()=>{e.length===0&&(w.current=!1,m(!0))},[e.length]),(0,G.useEffect)(()=>{s&&!s.read&&n(s.id)},[s,n]),(0,G.useEffect)(()=>{h&&C.current&&C.current.focus()},[h]);let T=(0,G.useCallback)(()=>{l.trim()||g(!1)},[l]),E=(0,G.useMemo)(()=>{if(!l.trim())return e;let t=l.toLowerCase();return e.filter(e=>e.method.toLowerCase().includes(t)||JSON.stringify(e.params||{}).toLowerCase().includes(t))},[e,l]);(0,G.useEffect)(()=>{f(-1)},[l]),(0,G.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.contentEditable===`true`||e.metaKey||e.ctrlKey||e.altKey)return;let n=E;if(e.key===`ArrowDown`)e.preventDefault(),f(e=>{let t=e+1;return t>=n.length?0:t});else if(e.key===`ArrowUp`)e.preventDefault(),f(e=>{let t=e-1;return t<0?n.length-1:t});else if(e.key===`Enter`&&d>=0){e.preventDefault();let t=E[d];t&&D(t)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[d,E]),(0,G.useEffect)(()=>{if(d>=0){let e=`notification-${E[d]?.id}`,t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[d,E]);let D=(0,G.useCallback)(e=>{c(e)},[]),O=(0,G.useCallback)(()=>{window.confirm(`Are you sure you want to clear all notifications? This cannot be undone.`)&&(i(),c(null))},[i]),k=(0,G.useCallback)(async()=>{if(s)try{await rg(JSON.stringify({method:s.method,timestamp:s.timestamp,read:s.read,params:s.params},null,2)),b(!0),setTimeout(()=>b(!1),2e3)}catch(e){console.error(`[NotificationsTab] Failed to copy notification:`,e)}},[s]),A=(0,G.useCallback)(()=>{if(s)try{let e=new globalThis.Blob([JSON.stringify({method:s.method,timestamp:s.timestamp,read:s.read,params:s.params},null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`notification-${Date.now()}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}catch(e){console.error(`[NotificationsTab] Failed to download notification:`,e)}},[s]),j=(0,G.useCallback)(async()=>{if(S.current)try{document.fullscreenElement?await document.exitFullscreen():await S.current.requestFullscreen()}catch(e){console.error(`[NotificationsTab] Failed to toggle fullscreen:`,e)}},[]),M=s?{method:s.method,params:s.params,timestamp:s.timestamp,read:s.read,formatRelativeTime:j7}:null;return o?(0,K.jsxs)(T7,{orientation:`horizontal`,className:`h-full`,children:[(0,K.jsx)(E7,{defaultSize:40,minSize:30,children:(0,K.jsx)(T7,{orientation:`vertical`,className:`h-full border-r dark:border-zinc-700`,children:(0,K.jsxs)(E7,{defaultSize:75,minSize:30,children:[(0,K.jsx)(lxe,{isSearchExpanded:h,searchQuery:l,filteredNotificationsCount:E.length,notificationsCount:e.length,onSearchExpand:()=>g(!0),onSearchChange:u,onSearchBlur:T,onClearAll:O,searchInputRef:C}),(0,K.jsx)(`div`,{className:`flex flex-col h-full`,children:(0,K.jsx)(uxe,{notifications:E,selectedNotification:s,onNotificationSelect:D,focusedIndex:d,formatRelativeTime:j7,listRef:x})})]})})}),(0,K.jsx)(D7,{}),(0,K.jsx)(E7,{defaultSize:60,minSize:40,children:(0,K.jsx)(`div`,{ref:S,className:`h-full bg-white dark:bg-zinc-900`,children:(0,K.jsx)(dxe,{notification:M,previewMode:_,onTogglePreview:()=>v(!_),onCopy:k,onDownload:A,onFullscreen:j,onClose:()=>c(null),isCopied:y})})})]}):(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,K.jsx)(Xm,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,K.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Not connected to server`})]})}function M7({activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabTitle:r,secondaryTabTitle:i,primaryCount:a,secondaryCount:o,secondaryIcon:s,primaryIcon:c,searchPlaceholder:l=`Search...`,onSearchExpand:u,onSearchChange:d,onSearchBlur:f,onTabSwitch:p,searchInputRef:m,primaryTabName:h,onRefresh:g,isRefreshing:_=!1}){let v=e===h;return(0,K.jsxs)(`div`,{className:`flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2`,children:[(0,K.jsx)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:t?(0,K.jsx)(uy,{ref:m,placeholder:l,value:n,onChange:e=>d(e.target.value),onBlur:f,className:`h-8 border-gray-300 dark:border-zinc-600`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-medium text-gray-900 dark:text-gray-100`,children:v?r:i}),v&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Aa,{className:`bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent`,variant:`outline`,children:a}),(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:u,className:`h-8 w-8 p-0`,children:(0,K.jsx)(Vh,{className:`h-4 w-4`})})}),(0,K.jsxs)(Im,{side:`bottom`,className:`flex gap-2`,children:[`Search`,(0,K.jsx)(O7,{children:`F`})]})]}),g&&(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:g,disabled:_,className:`h-8 w-8 p-0`,children:(0,K.jsx)(Rh,{className:`h-4 w-4 ${_?`animate-spin`:``}`})})}),(0,K.jsxs)(Im,{side:`bottom`,className:`flex gap-2`,children:[`Refresh list`,(0,K.jsx)(O7,{children:`R`})]})]})]})]})}),(0,K.jsxs)(J,{variant:`ghost`,size:`sm`,onClick:p,className:`gap-2 flex-shrink-0`,children:[v?(0,K.jsx)(s,{}):(0,K.jsx)(c,{}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:v?i:r}),v&&o>0&&(0,K.jsx)(Aa,{className:`bg-purple-500/20 text-purple-600 dark:text-purple-400 border-transparent`,variant:`outline`,children:o})]})]})}function pxe({serverIds:e,onCountChange:t,onClearRef:n,onExportRef:r}={}){let[i,a]=(0,G.useState)([]),o=(0,G.useRef)(null),[s,c]=(0,G.useState)(new Set),[l]=(0,G.useState)(``),u=e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},d=async()=>{a([]),c(new Set),t?.(0),e&&e.length>0?e.forEach(e=>vn(e)):vn()},f=async e=>{try{await rg(JSON.stringify(e,null,2)),xv.success(`Message copied to clipboard`)}catch(e){console.error(`Failed to copy message:`,e),xv.error(`Failed to copy to clipboard`)}},p=async()=>{try{await rg(JSON.stringify(h,null,2)),xv.success(`All messages copied to clipboard (${h.length})`)}catch(e){console.error(`Failed to copy all messages:`,e),xv.error(`Failed to copy to clipboard`)}},m=(0,G.useMemo)(()=>!e||e.length===0?``:[...e].sort().join(`,`),[e]);(0,G.useEffect)(()=>(n&&(n.current=d),()=>{n&&(n.current=null)}),[n,d]),(0,G.useEffect)(()=>(r&&(r.current=p),()=>{r&&(r.current=null)}),[r,p]),(0,G.useEffect)(()=>{t?.(i.length)},[i.length,t]),(0,G.useEffect)(()=>{console.log(`[RPC Logger] Subscribing to RPC logs for servers:`,e);let n=gn(),r=(e&&e.length>0?n.filter(t=>e.includes(t.serverId)):n).map(e=>{let t=e.message,n=typeof t?.method==`string`?t.method:t?.result===void 0?t?.error===void 0?`unknown`:`error`:`result`;return{id:`${e.timestamp}-${Math.random().toString(36).slice(2)}`,serverId:e.serverId,direction:e.direction.toUpperCase(),method:n,timestamp:e.timestamp,payload:e.message}}).reverse();a(r),t?.(r.length);let i=_n(n=>{if(e&&e.length>0&&!e.includes(n.serverId))return;let r=n.message,i=typeof r?.method==`string`?r.method:r?.result===void 0?r?.error===void 0?`unknown`:`error`:`result`,o={id:`${n.timestamp}-${Math.random().toString(36).slice(2)}`,serverId:n.serverId,direction:n.direction.toUpperCase(),method:i,timestamp:n.timestamp,payload:n.message};console.log(`[RPC Logger] New RPC log:`,{method:i,direction:n.direction,serverId:n.serverId}),a(e=>{let n=[o,...e].slice(0,1e3);return t?.(n.length),n})});return()=>{i(),console.log(`[RPC Logger] Unsubscribed from RPC logs`)}},[m,t]);let h=(0,G.useMemo)(()=>{let t=i;if(e&&e.length>0){let n=new Set(e);t=t.filter(e=>n.has(e.serverId))}if(l.trim()){let e=l.toLowerCase();t=t.filter(t=>t.serverId.toLowerCase().includes(e)||t.method.toLowerCase().includes(e)||t.direction.toLowerCase().includes(e)||JSON.stringify(t.payload).toLowerCase().includes(e))}return t=[...t].sort((e,t)=>new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime()),t},[i,l,e]);return(0,K.jsx)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,children:(0,K.jsx)(`div`,{ref:o,className:`flex-1 min-h-0 overflow-y-auto`,children:h.length===0?(0,K.jsxs)(`div`,{className:`text-center py-8`,children:[(0,K.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No messages yet`}),(0,K.jsx)(`div`,{className:`text-[10px] text-muted-foreground mt-1`,children:`JSON-RPC messages will appear here`})]}):h.map(e=>{let t=s.has(e.id);return(0,K.jsxs)(`div`,{className:`group hover:bg-muted/50 transition-all duration-200 overflow-hidden`,"data-testid":`rpc-message-${e.method.replace(/\//g,`-`)}`,children:[(0,K.jsxs)(`div`,{className:`px-3 py-2 flex items-center gap-2 cursor-pointer hover:bg-muted/50 transition-colors`,onClick:()=>u(e.id),children:[(0,K.jsx)(`div`,{className:`flex-shrink-0`,children:t?(0,K.jsx)(eh,{className:`h-3 w-3 text-muted-foreground transition-transform`}):(0,K.jsx)(nh,{className:`h-3 w-3 text-muted-foreground transition-transform`})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:new Date(e.timestamp).toLocaleTimeString()}),(0,K.jsx)(`span`,{className:`flex items-center justify-center px-1 py-0.5 rounded ${e.direction===`RECEIVE`?`bg-blue-500/10 text-blue-600 dark:text-blue-400`:`bg-green-500/10 text-green-600 dark:text-green-400`}`,title:e.direction===`RECEIVE`?`Incoming`:`Outgoing`,children:e.direction===`RECEIVE`?(0,K.jsx)(jee,{className:`h-3 w-3`}):(0,K.jsx)(Mee,{className:`h-3 w-3`})}),(0,K.jsx)(`span`,{className:`text-xs font-mono text-foreground truncate`,children:e.method})]})]}),t&&(0,K.jsx)(`div`,{className:`border-t bg-muted/20`,children:(0,K.jsxs)(`div`,{className:`p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Message Payload`}),(0,K.jsxs)(J,{variant:`ghost`,size:`sm`,onClick:t=>{t.stopPropagation(),f(e.payload)},className:`h-6 px-2`,title:`Copy message to clipboard`,children:[(0,K.jsx)(uh,{className:`h-3 w-3 mr-1`}),(0,K.jsx)(`span`,{className:`text-xs`,children:`Copy`})]})]}),(0,K.jsx)(`div`,{className:`max-h-[40vh] overflow-auto rounded-sm bg-background/60 p-2`,children:(0,K.jsx)(bO,{data:e.payload})})]})})]},e.id)})})})}function N7({serverId:e,className:t}){let[n,r]=(0,G.useState)(0),[i,a]=(0,G.useState)(!0),o=w7(),s=(0,G.useRef)(null),c=(0,G.useRef)(null);return(0,G.useEffect)(()=>{o.current?.collapse()},[]),(0,K.jsxs)(E7,{panelRef:o,defaultSize:46,collapsible:!0,minSize:150,collapsedSize:46,onResize:e=>{i&&e.inPixels>46?a(!1):!i&&e.inPixels<=46&&a(!0)},className:`flex flex-col border-t dark:border-zinc-700 ${t||``}`,children:[(0,K.jsxs)(`div`,{"data-testid":`rpc-panel-toggle`,className:`group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors`,onClick:e=>{e.preventDefault(),e.stopPropagation(),i?(a(!1),setTimeout(()=>{o.current?.expand()},100)):(o.current?.collapse(),setTimeout(()=>{a(!0)},100))},children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium`,children:`RPC Messages`}),n>0&&(0,K.jsx)(Aa,{"data-testid":`rpc-message-count`,variant:`secondary`,className:`bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent`,children:n})]}),n>0&&!i&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:e=>{e.preventDefault(),e.stopPropagation(),c.current?.()},className:`h-6 w-6 p-0`,title:`Copy all messages to clipboard`,children:(0,K.jsx)(uh,{className:`h-3.5 w-3.5`})}),(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:e=>{e.preventDefault(),e.stopPropagation(),s.current?.()},className:`h-6 w-6 p-0`,title:`Clear all messages`,children:(0,K.jsx)($h,{className:`h-3.5 w-3.5`})})]})]}),(0,K.jsx)(eh,{className:`h-4 w-4 text-muted-foreground transition-transform ${i?``:`rotate-180`}`})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-hidden min-h-0 ${i?`hidden`:``}`,children:(0,K.jsx)(pxe,{serverIds:[e],onCountChange:r,onClearRef:s,onExportRef:c})})]})}N7.displayName=`RpcPanel`;function P7({prompts:e,selectedPrompt:t,onPromptSelect:n,focusedIndex:r}){return e.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,K.jsx)(Mh,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,K.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`No prompts available`})]}):(0,K.jsx)(`div`,{className:`overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain`,children:e.map((e,i)=>(0,K.jsx)(k7,{id:`prompt-${e.name}`,"data-testid":`prompt-item-${e.name}`,isSelected:t?.name===e.name,isFocused:r===i,icon:(0,K.jsx)(Mh,{className:`h-4 w-4`}),title:e.name,description:e.description,metadata:e.arguments&&e.arguments.length>0&&(0,K.jsxs)(Aa,{variant:`outline`,className:`text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400`,children:[e.arguments.length,` args`]}),onClick:()=>n(e)},e.name))})}function F7({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredPromptsCount:r,savedPromptsCount:i,onSearchExpand:a,onSearchChange:o,onSearchBlur:s,onTabSwitch:c,searchInputRef:l,onRefresh:u,isRefreshing:d}){return(0,K.jsx)(M7,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:`prompts`,secondaryTabName:`saved`,primaryTabTitle:`Prompts`,secondaryTabTitle:`History`,primaryCount:r,secondaryCount:i,primaryIcon:Mh,secondaryIcon:oh,searchPlaceholder:`Search prompts...`,onSearchExpand:a,onSearchChange:o,onSearchBlur:s,onTabSwitch:c,searchInputRef:l,onRefresh:u,isRefreshing:d})}function I7({savedPrompts:e,selectedPrompt:t,onLoadPrompt:n,onDeletePrompt:r,focusedIndex:i}){return e.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,K.jsx)(oh,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,K.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`No history`}),(0,K.jsx)(`p`,{className:`text-sm text-gray-400 dark:text-gray-500 mt-1`,children:`Prompts you execute will appear here`})]}):(0,K.jsx)(`div`,{className:`overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain`,children:e.map((e,r)=>(0,K.jsx)(k7,{id:`saved-prompt-${e.id}`,isSelected:t?.id===e.id,isFocused:i===r,icon:(0,K.jsx)(oh,{className:`h-4 w-4`}),title:e.name,description:`${e.promptName} - ${new Date(e.savedAt).toLocaleString()}`,onClick:()=>n(e)},e.id))})}function mxe({selectedPrompt:e,promptArgs:t,onArgChange:n}){let r=e?.arguments||[];if(!(r.length>0))return(0,K.jsx)(`div`,{className:`flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm`,children:`No arguments required`});let i=e=>{let r=e.name,i=t[r],a=typeof i==`string`?i:JSON.stringify(i);return e.type===`boolean`?(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(py,{htmlFor:r,className:`text-sm font-medium`,children:[r,e.required&&(0,K.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),(0,K.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,K.jsx)(`input`,{id:r,type:`checkbox`,checked:!!i,onChange:e=>n(r,e.target.checked),className:`rounded`,"aria-label":`Toggle ${r}`}),(0,K.jsx)(`span`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:e.description})]})]},r):e.type===`number`?(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(py,{htmlFor:r,className:`text-sm font-medium`,children:[r,e.required&&(0,K.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),(0,K.jsx)(uy,{id:r,type:`number`,value:Number(i)||0,onChange:e=>n(r,Number(e.target.value)),placeholder:e.description||`Enter ${r}`}),e.description&&(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e.description})]},r):e.type===`array`||e.type===`object`?(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(py,{htmlFor:r,className:`text-sm font-medium`,children:[r,e.required&&(0,K.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),(0,K.jsx)(tL,{id:r,value:a,onChange:e=>{try{n(r,JSON.parse(e.target.value))}catch{n(r,e.target.value)}},placeholder:e.description||`Enter ${r} as JSON`,className:`font-mono text-sm min-h-[100px]`}),e.description&&(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e.description})]},r):(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(py,{htmlFor:r,className:`text-sm font-medium`,children:[r,e.required&&(0,K.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),(0,K.jsx)(uy,{id:r,"data-testid":`prompt-param-${r}`,value:a,onChange:e=>n(r,e.target.value),placeholder:e.description||`Enter ${r}`}),e.description&&(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e.description})]},r)};return(0,K.jsx)(`div`,{className:`space-y-4`,children:r.map(e=>i(e))})}function L7({selectedPrompt:e,promptArgs:t,isExecuting:n,isConnected:r,onArgChange:i,onExecute:a,onSave:o}){return(0,G.useEffect)(()=>{let t=t=>{(t.metaKey||t.ctrlKey)&&t.key===`Enter`&&e&&!n&&r&&(t.preventDefault(),a())};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,n,r,a]),e?(0,K.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,K.jsx)(`div`,{className:`flex-shrink-0 p-3 sm:p-6 pt-3 pb-4 pr-3`,children:(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex flex-row items-center justify-between mb-0 gap-2`,children:[(0,K.jsx)(`h3`,{className:`text-base sm:text-lg font-semibold`,children:e.name}),(0,K.jsxs)(`div`,{className:`flex gap-2 flex-shrink-0`,children:[(0,K.jsx)(J,{onClick:a,disabled:n||!r,size:`sm`,className:`lg:size-default pr-1! gap-0`,"data-testid":`prompt-execute-button`,children:n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(yF,{className:`mr-2`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:`Executing...`})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ih,{className:`h-4 w-4 sm:mr-2`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:`Execute`}),(0,K.jsx)(`span`,{className:`hidden sm:inline text-[12px] border text-zinc-300 p-1 rounded-full border-zinc-300 dark:text-zinc-600 dark:border-zinc-500 ml-2`,children:`⌘↵`})]})}),(0,K.jsxs)(J,{variant:`outline`,onClick:o,disabled:n,size:`sm`,className:`lg:size-default gap-2`,children:[(0,K.jsx)(Bh,{className:`h-4 w-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:`Save`})]})]})]}),e.description&&(0,K.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 leading-relaxed mt-2`,children:e.description})]})}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto px-3 sm:px-6 pb-4 pr-3`,children:(0,K.jsx)(mxe,{selectedPrompt:e,promptArgs:t,onArgChange:i})})]}):(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,K.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400 mb-2`,children:`Select a prompt to get started`}),(0,K.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:`Choose a prompt from the list to view its details and execute it`})]})}function hxe(e){switch(e){case`system`:return`default`;case`user`:return`outline`;case`assistant`:return`secondary`;default:return`outline`}}function gxe(e){return e.charAt(0).toUpperCase()+e.slice(1)}function _xe(e){return typeof e==`string`?e:e.text?e.text:e.type===`resource`&&e.resource?.text?e.resource.text:e.type===`image`?`[Image: ${e.mimeType||`unknown type`}]`:JSON.stringify(e,null,2)}function vxe({message:e,index:t}){let[n,r]=(0,G.useState)(!1),i=async()=>{await rg(_xe(e.content)),r(!0),setTimeout(()=>r(!1),2e3)},a=()=>{let t=e.content;return typeof t==`string`?(0,K.jsx)(VB,{content:t}):t.type===`text`&&t.text?(0,K.jsx)(VB,{content:t.text}):t.type===`image`?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,K.jsxs)(`span`,{className:`font-mono bg-muted px-2 py-1 rounded`,children:[`Image: `,t.mimeType||`unknown type`]}),t.data&&(0,K.jsx)(`img`,{src:`data:${t.mimeType};base64,${t.data}`,alt:`Prompt image`,className:`max-w-full max-h-[300px] object-contain rounded-lg border border-border mt-2`})]}):t.type===`resource`&&t.resource?(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:`Resource:`}),(0,K.jsx)(`code`,{className:`bg-muted px-2 py-0.5 rounded text-xs font-mono`,children:t.resource.uri})]}),t.resource.text&&(0,K.jsx)(`div`,{className:`mt-2`,children:(0,K.jsx)(VB,{content:t.resource.text})})]}):(0,K.jsx)(`pre`,{className:`bg-muted p-3 rounded-lg text-sm overflow-x-auto`,children:(0,K.jsx)(`code`,{children:JSON.stringify(t,null,2)})})};return(0,K.jsxs)(`div`,{className:`border border-border rounded-lg overflow-hidden bg-white dark:bg-zinc-900`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 bg-muted/30 border-b border-border`,children:[(0,K.jsx)(Aa,{variant:hxe(e.role),children:gxe(e.role)}),(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:i,className:`h-6 px-2`,title:`Copy message content`,children:n?(0,K.jsx)($m,{className:`h-3.5 w-3.5`}):(0,K.jsx)(uh,{className:`h-3.5 w-3.5`})})]}),(0,K.jsx)(`div`,{className:`px-4 py-3`,"data-testid":`prompt-message-content-${t}`,children:a()})]})}function yxe(e){let t=Date.now()-e,n=Math.floor(t/1e3),r=Math.floor(n/60),i=Math.floor(r/60),a=Math.floor(i/24);return n<10?`now`:n<60?`${n}s ago`:r<60?`${r}m ago`:i<24?`${i}h ago`:`${a}d ago`}function bxe(e){return`isError`in e&&!e.isError?null:`error`in e&&e.error?String(e.error):`isError`in e&&e.isError?`An error occurred`:null}function R7({results:e,copiedResult:t,previewMode:n=!0,onCopy:r,onDelete:i,onFullscreen:a,onTogglePreview:o,onMaximize:s,isMaximized:c=!1}){let[l,u]=(0,G.useState)(0),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(!0),h=e[0],g=h?e.filter(e=>e.promptName===h.promptName):[],_=g[l]||g[0],v=e.findIndex(e=>e===_);if((0,G.useEffect)(()=>{g.length>0&&l>=g.length&&u(0)},[g.length,l]),(0,G.useEffect)(()=>{let e=()=>{_&&f(yxe(_.timestamp))};e();let t=setInterval(e,1e3);return()=>clearInterval(t)},[_]),e.length===0)return(0,K.jsx)(`div`,{className:`flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700`,children:(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto h-full`,children:(0,K.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,K.jsx)(`div`,{className:`text-center`,children:(0,K.jsx)(nm,{vertical:!0,noBorder:!0,message:`No Results yet`})})})})});let y=_.error||bxe(_.result),b=`messages`in _.result&&Array.isArray(_.result.messages);return(0,K.jsx)(`div`,{className:`flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700`,children:(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto h-full`,children:(0,K.jsxs)(`div`,{className:`space-y-0 flex-1 h-full flex flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-4 pt-2 border-b border-gray-200 dark:border-zinc-600 pb-2`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium hidden sm:block`,children:`Response`}),_.duration!==void 0&&(0,K.jsxs)(`div`,{className:`hidden sm:flex items-center gap-1`,children:[(0,K.jsx)(ng,{className:`h-3 w-3 text-gray-400`}),(0,K.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[_.duration,`ms`]})]}),b&&(0,K.jsx)(`div`,{className:`flex items-center gap-4 sm:ml-4`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`button`,{onClick:()=>m(!0),className:`text-xs font-medium ${p?`text-black dark:text-white`:`text-zinc-500 dark:text-zinc-400`}`,children:`Formatted`}),(0,K.jsx)(`span`,{className:`text-xs text-zinc-400`,children:`|`}),(0,K.jsx)(`button`,{onClick:()=>m(!1),className:`text-xs font-medium ${p?`text-zinc-500 dark:text-zinc-400`:`text-black dark:text-white`}`,children:`Raw`})]})}),(0,K.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[g.length>1&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mr-2`,children:[(0,K.jsx)(Th,{className:`h-3 w-3 text-gray-400`}),(0,K.jsxs)(ab,{value:l.toString(),onValueChange:e=>u(parseInt(e)),children:[(0,K.jsx)(sb,{className:`h-7 w-[120px] text-xs`,children:(0,K.jsx)(ob,{})}),(0,K.jsx)(cb,{children:g.map((e,t)=>(0,K.jsx)(lb,{value:t.toString(),children:t===0?`Latest`:`${t+1} call ago`},t))})]})]}),(0,K.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400 mr-2`,children:d}),(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>r(v,_.result),className:`h-7 w-7 p-0`,title:`Copy result`,children:t===v?(0,K.jsx)($m,{className:`h-4 w-4`}):(0,K.jsx)(uh,{className:`h-4 w-4`})}),i&&(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>i(v),className:`h-7 w-7 p-0`,title:`Delete result`,children:(0,K.jsx)($h,{className:`h-4 w-4`})}),a&&(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>a(v),className:`h-7 w-7 p-0 sm:hidden`,title:`Fullscreen`,children:(0,K.jsx)(jh,{className:`h-4 w-4`})}),s&&(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:s,className:`h-7 w-7 p-0 hidden sm:flex`,title:c?`Restore`:`Maximize`,children:c?(0,K.jsx)(Nh,{className:`h-4 w-4`}):(0,K.jsx)(jh,{className:`h-4 w-4`})})]})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:y?(0,K.jsxs)(`div`,{className:`bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3`,children:[(0,K.jsx)(`p`,{className:`text-red-800 dark:text-red-300 font-medium`,children:`Error:`}),(0,K.jsx)(`p`,{className:`text-red-700 dark:text-red-400 text-sm`,children:y})]}):p&&b?(0,K.jsx)(`div`,{className:`space-y-3`,children:(`messages`in _.result?_.result.messages:[]).map((e,t)=>(0,K.jsx)(vxe,{message:e,index:t},t))}):(0,K.jsx)(bO,{data:_.result,filename:`prompt-result-${_.promptName}-${Date.now()}.json`})})]})})})}var z7=`mcp-inspector-saved-prompts`;function B7({ref:e,prompts:t,callPrompt:n,serverId:r,isConnected:i,refreshPrompts:a}){let[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(null),{selectedPromptName:u,setSelectedPromptName:d}=SF(),[f,p]=(0,G.useState)(null),[m,h]=(0,G.useState)(`prompts`),[g,_]=(0,G.useState)([]),[v,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(``),[S,C]=(0,G.useState)(!1),[w,T]=(0,G.useState)(-1),E=(0,G.useRef)(null),[D,O]=(0,G.useState)(!1),[k,A]=(0,G.useState)(`list`),[j,M]=(0,G.useState)(!1),{filteredPrompts:N,selectedPrompt:P,setSelectedPrompt:F,results:I,handleDeleteResult:L,promptArgs:ee,setPromptArgs:te,isExecuting:R,handlePromptSelect:z,handleArgChange:ne,executeSelectedPrompt:re,searchQuery:ie,setSearchQuery:ae}=uI({prompts:t,callPrompt:n,serverId:r}),oe=w7(),se=w7();(0,G.useEffect)(()=>{let e=()=>{O(window.innerWidth<1024)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,G.useEffect)(()=>{A(P?`detail`:`list`)},[P]),(0,G.useEffect)(()=>{D&&I.length>0&&!R&&A(`response`)},[I,R,D]),(0,G.useImperativeHandle)(e,()=>({focusSearch:()=>{C(!0),setTimeout(()=>{E.current&&E.current.focus()},0)},blurSearch:()=>{ae(``),C(!1),E.current&&E.current.blur()}})),(0,G.useEffect)(()=>{try{let e=localStorage.getItem(z7);e&&_(JSON.parse(e))}catch(e){console.error(`[PromptsTab] Failed to load saved prompts:`,e)}},[]);let ce=(0,G.useCallback)(e=>{try{localStorage.setItem(z7,JSON.stringify(e))}catch(e){console.error(`[PromptsTab] Failed to save prompts:`,e)}},[]);(0,G.useEffect)(()=>{S&&E.current&&E.current.focus()},[S]);let le=(0,G.useCallback)(()=>{ie.trim()||C(!1)},[ie]),ue=(0,G.useCallback)(async()=>{if(a){s(!0);try{await a()}finally{s(!1)}}},[a]),de=(0,G.useCallback)(e=>{let n=t.find(t=>t.name===e.promptName);n&&(F(n),te(e.args),l(e))},[t,F,te]);(0,G.useEffect)(()=>{T(-1)},[ie,m]),(0,G.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.contentEditable===`true`||e.metaKey||e.ctrlKey||e.altKey)return;let n=m===`prompts`?N:g;if(e.key===`ArrowDown`)e.preventDefault(),T(e=>{let t=e+1;return t>=n.length?0:t});else if(e.key===`ArrowUp`)e.preventDefault(),T(e=>{let t=e-1;return t<0?n.length-1:t});else if(e.key===`Enter`&&w>=0)if(e.preventDefault(),m===`prompts`){let e=N[w];e&&z(e)}else{let e=g[w];e&&de(e)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[w,N,g,m,z,de]),(0,G.useEffect)(()=>{if(w>=0){let e=m===`prompts`?`prompt-${N[w]?.name}`:`saved-prompt-${g[w]?.id}`,t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[w,N,g,m]),(0,G.useEffect)(()=>{if(console.warn(`[PromptsTab] Auto-selection effect triggered:`,{selectedPromptName:u,promptsCount:t.length,currentSelectedPrompt:P?.name}),u&&t.length>0){let e=t.find(e=>e.name===u);if(console.warn(`[PromptsTab] Prompt lookup result:`,{selectedPromptName:u,promptFound:!!e,promptName:e?.name,shouldSelect:e&&P?.name!==e.name}),e&&P?.name!==e.name){console.warn(`[PromptsTab] Selecting prompt:`,e.name),d(null);let t=setTimeout(()=>{z(e);let t=document.getElementById(`prompt-${e.name}`);t&&(console.warn(`[PromptsTab] Scrolling to prompt element`),t.scrollIntoView({behavior:`smooth`,block:`nearest`}))},100);return()=>clearTimeout(t)}}},[u,t,P,z,d]);let B=(0,G.useCallback)(async(e,t)=>{try{await rg(JSON.stringify(t,null,2)),p(e),setTimeout(()=>p(null),2e3)}catch(e){console.error(`[PromptsTab] Failed to copy result:`,e)}},[]),fe=(0,G.useCallback)(e=>{if(D)A(`response`);else{let t=I[e];if(t){let e=window.open(``,`_blank`,`width=800,height=600`);if(e){let n=t.result;e.document.write(`
|
|
429
429
|
<html>
|
|
430
430
|
<head>
|
|
431
431
|
<title>${t.promptName} Result</title>
|
|
@@ -440,7 +440,7 @@ Instead got an unsupported type.`)}var J8=class extends B8{static lc_name(){retu
|
|
|
440
440
|
</body>
|
|
441
441
|
</html>
|
|
442
442
|
`),e.document.close()}}}},[D,I]),pe=(0,G.useCallback)(()=>{j?(oe.current&&oe.current.expand(),se.current&&se.current.expand(),M(!1)):(oe.current&&oe.current.collapse(),se.current&&se.current.collapse(),M(!0))},[j,oe,se]),me=(0,G.useCallback)(()=>{P&&(x(``),y(!0))},[P]),V=(0,G.useCallback)(e=>{ce(g.filter(t=>t.id!==e)),c?.id===e&&l(null)},[g,ce,c]);return D?(0,K.jsxs)(`div`,{className:`h-full flex flex-col overflow-hidden relative bg-background`,children:[k!==`list`&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10`,children:[(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>{k===`response`?A(`detail`):(F(null),A(`list`))},className:`p-0 h-8 w-8`,children:(0,K.jsx)(th,{className:`h-4 w-4`})}),(0,K.jsxs)(`div`,{className:`flex items-center text-sm font-medium`,children:[(0,K.jsx)(`button`,{onClick:()=>{F(null),A(`list`)},className:`text-muted-foreground hover:text-foreground hover:underline cursor-pointer`,children:`Prompts`}),k===`detail`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`mx-2 text-muted-foreground`,children:`/`}),(0,K.jsx)(`button`,{onClick:()=>{A(`response`)},className:k===`detail`?`text-foreground hover:underline`:k===`response`?`text-muted-foreground hover:text-foreground hover:underline cursor-pointer`:`text-muted-foreground`,children:`Execute`})]}),k===`response`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`mx-2 text-muted-foreground`,children:`/`}),(0,K.jsx)(`span`,{className:`text-foreground`,children:`Response`})]})]})]}),(0,K.jsx)(`div`,{className:`flex-1 relative overflow-hidden`,children:(0,K.jsxs)(OP,{initial:!1,mode:`popLayout`,children:[k===`list`&&(0,K.jsxs)(_F.div,{initial:{x:`-100%`},animate:{x:0},exit:{x:`-100%`},transition:{type:`spring`,stiffness:300,damping:30},className:`absolute inset-0 flex flex-col bg-background z-0`,children:[(0,K.jsx)(F7,{activeTab:m,isSearchExpanded:S,searchQuery:ie,filteredPromptsCount:N.length,savedPromptsCount:g.length,onSearchExpand:()=>C(!0),onSearchChange:ae,onSearchBlur:le,onTabSwitch:()=>h(m===`prompts`?`saved`:`prompts`),searchInputRef:E,onRefresh:a?ue:void 0,isRefreshing:o}),m===`prompts`?(0,K.jsx)(P7,{prompts:N,selectedPrompt:P,onPromptSelect:z,focusedIndex:w}):(0,K.jsx)(I7,{savedPrompts:g,selectedPrompt:c,onLoadPrompt:de,onDeletePrompt:V,focusedIndex:w})]},`list`),k===`detail`&&(0,K.jsx)(_F.div,{initial:{x:`100%`},animate:{x:0},exit:{x:`-100%`},transition:{type:`spring`,stiffness:300,damping:30},className:`absolute inset-0 bg-background z-10`,children:(0,K.jsx)(L7,{selectedPrompt:P,promptArgs:ee,isExecuting:R,isConnected:i,onArgChange:ne,onExecute:re,onSave:me})},`detail`),k===`response`&&(0,K.jsx)(_F.div,{initial:{x:`100%`},animate:{x:0},exit:{x:`100%`},transition:{type:`spring`,stiffness:300,damping:30},className:`absolute inset-0 bg-background z-20`,children:(0,K.jsx)(R7,{results:I,copiedResult:f,onCopy:B,onDelete:L,onFullscreen:fe})},`response`)]})})]}):(0,K.jsxs)(T7,{orientation:`horizontal`,className:`h-full`,children:[(0,K.jsx)(E7,{id:`left-panel`,panelRef:oe,defaultSize:`33%`,collapsible:!0,className:`flex flex-col h-full relative`,children:(0,K.jsxs)(T7,{orientation:`vertical`,className:`h-full border-r dark:border-zinc-700`,children:[(0,K.jsx)(E7,{defaultSize:`75%`,minSize:`30%`,children:(0,K.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,K.jsx)(F7,{activeTab:m,isSearchExpanded:S,searchQuery:ie,filteredPromptsCount:N.length,savedPromptsCount:g.length,onSearchExpand:()=>C(!0),onSearchChange:ae,onSearchBlur:le,onTabSwitch:()=>h(m===`prompts`?`saved`:`prompts`),searchInputRef:E,onRefresh:a?ue:void 0,isRefreshing:o}),m===`prompts`?(0,K.jsx)(P7,{prompts:N,selectedPrompt:P,onPromptSelect:z,focusedIndex:w}):(0,K.jsx)(I7,{savedPrompts:g,selectedPrompt:c,onLoadPrompt:de,onDeletePrompt:V,focusedIndex:w})]})}),(0,K.jsx)(D7,{withHandle:!0}),(0,K.jsx)(N7,{serverId:r})]})}),(0,K.jsx)(D7,{withHandle:!0}),(0,K.jsx)(E7,{defaultSize:`67%`,children:(0,K.jsxs)(T7,{orientation:`vertical`,children:[(0,K.jsx)(E7,{panelRef:se,defaultSize:`40%`,collapsible:!0,children:(0,K.jsx)(L7,{selectedPrompt:P,promptArgs:ee,isExecuting:R,isConnected:i,onArgChange:ne,onExecute:re,onSave:me})}),(0,K.jsx)(D7,{withHandle:!0}),(0,K.jsx)(E7,{defaultSize:`60%`,children:(0,K.jsx)(`div`,{className:`flex flex-col h-full`,children:(0,K.jsx)(R7,{results:I,copiedResult:f,onCopy:B,onDelete:L,onFullscreen:fe,onMaximize:pe,isMaximized:j})})})]})})]})}B7.displayName=`PromptsTab`;function V7(e){if(!e?.mimeType)return!1;let t=e.mimeType.toLowerCase();return t===`text/html`||t===`text/html;profile=mcp-app`||t===`text/html+skybridge`||t===`text/uri-list`||t.startsWith(`application/vnd.mcp-ui.remote-dom`)}function H7({resource:e,className:t}){let n=e,r=(0,G.useMemo)(()=>{if(n.text)return n.text;if(n.blob)try{return atob(n.blob)}catch{return null}return null},[n.text,n.blob]);return r?(0,K.jsx)(`div`,{className:t,children:(0,K.jsx)(`iframe`,{srcDoc:r,sandbox:`allow-scripts allow-forms allow-popups`,title:e.uri??`MCP UI Resource`,style:{width:`100%`,minHeight:`200px`,border:`none`}})}):null}function xxe(e){if(`error`in e&&e.error&&typeof e.error==`string`)return e.error;if(!(`isError`in e&&e.isError))return null;if(`contents`in e&&Array.isArray(e.contents)){let t=e.contents.filter(e=>`text`in e).map(e=>e.text).filter(Boolean);if(t.length>0)return t.join(`
|
|
443
|
-
`)}return`An error occurred`}function U7({result:e,isLoading:t,previewMode:n,serverId:r,readResource:i,onTogglePreview:a,onCopy:o,onDownload:s,onFullscreen:c,isCopied:l=!1,selectedResource:u,llmConfig:d}){let f=(0,G.useMemo)(()=>({}),[]),[p,m]=(0,G.useState)(null),h=(0,G.useCallback)(e=>{m(e)},[]),[g,_]=(0,G.useState)(`inline`),v=[],y;if(e?.resourceAnnotations&&(v=Object.keys(e.resourceAnnotations).filter(e=>e.startsWith(`openai/`)),y=e.resourceAnnotations[`openai/outputTemplate`]),e?.result&&`contents`in e.result&&Array.isArray(e.result.contents)&&e.result.contents[0]?._meta){let t=e.result.contents[0]._meta,n=Object.keys(t).filter(e=>e.startsWith(`openai/`));n.length>0&&(v=[...v,...n]),!y&&t[`openai/outputTemplate`]&&(y=t[`openai/outputTemplate`]),!y&&e.uri&&e.uri.startsWith(`ui://widget/`)&&(y=e.uri)}let b=!!(v.length>0&&y&&typeof y==`string`&&r&&i),x=e?.result&&`contents`in e.result&&Array.isArray(e.result.contents)&&e.result.contents[0]?._meta||{},S={...e?.resourceAnnotations,...x},C=(0,G.useMemo)(()=>{let e=S?.[`mcp-use/propsSchema`];if(!e)return[];let t=e.def?.shape;return t?Object.entries(t).filter(([,e])=>{let t=e?.def?.type??e?.type;return t!==`optional`&&t!==`default`}).map(([e])=>e):e.required??[]},[S]),w=$B(S,e?.result),T=e?.result&&`contents`in e.result&&Array.isArray(e.result.contents)&&e.result.contents.some(e=>e.mimeType===`text/html;profile=mcp-app`),E=S?.ui?.resourceUri||x?.ui?.resourceUri||(T?e.uri:void 0),D=(w===`mcp-apps`||T)&&!!E,O=C.length>0&&!p;if(t)return(0,K.jsx)(`div`,{className:`flex absolute left-0 top-0 items-center justify-center w-full h-full`,children:(0,K.jsx)(yF,{className:`size-5`})});if(!e)return(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,K.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400 mb-2`,children:`Select a resource to view its contents`}),(0,K.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:`Choose a resource from the list to see its data`})]});let k=e.error||(e.result?xxe(e.result):null);if(k)return(0,K.jsx)(`div`,{className:`p-4`,children:(0,K.jsxs)(`div`,{className:`bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3`,children:[(0,K.jsx)(`p`,{className:`text-red-800 dark:text-red-300 font-medium`,children:`Error:`}),(0,K.jsx)(`p`,{className:`text-red-700 dark:text-red-400 text-sm`,children:k})]})});let A=e?.result&&`contents`in e.result&&Array.isArray(e.result.contents)&&e.result.contents.some(e=>e.mimeType&&V7(e)),j=A&&e.result&&`contents`in e.result&&Array.isArray(e.result.contents)?e.result.contents.filter(e=>e.mimeType&&V7(e)):[];return(0,K.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,K.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-b border-gray-200 dark:border-zinc-700 flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(oh,{className:`h-3 w-3 text-gray-400`}),(0,K.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:new Date(e.timestamp).toLocaleTimeString()})]}),(()=>{let t=e?.duration??e.result?.duration??e.result?.metrics?.durationMs;return t===void 0?null:(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(ng,{className:`h-3 w-3 text-gray-400`}),(0,K.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[t,`ms`]})]})})(),A&&(0,K.jsx)(Aa,{variant:`outline`,className:`text-xs bg-purple-50 dark:bg-purple-900/20 border-none border-purple-200 dark:border-purple-800/50 text-purple-600 dark:text-purple-400`,children:`MCP UI`}),D&&(0,K.jsx)(Aa,{variant:`outline`,className:`text-xs bg-green-50 dark:bg-green-900/20 border-none border-green-200 dark:border-green-800/50 text-green-600 dark:text-green-400`,children:`MCP Apps`}),b&&(0,K.jsx)(Aa,{variant:`outline`,className:`text-xs bg-blue-50 dark:bg-blue-900/20 border-none border-blue-200 dark:border-blue-800/50 text-blue-600 dark:text-blue-400`,children:`OpenAI Widget`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(D||A||b)&&(0,K.jsxs)(J,{variant:`ghost`,size:`sm`,onClick:a,className:n?``:`text-purple-600 dark:text-purple-400`,children:[n?(0,K.jsx)(sh,{className:`h-4 w-4 mr-1`}):(0,K.jsx)(Qm,{className:`h-4 w-4 mr-1`}),n?`JSON`:b?`Component`:`Preview`]}),(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:o,children:l?(0,K.jsx)($m,{className:`h-4 w-4`}):(0,K.jsx)(uh,{className:`h-4 w-4`})}),(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:s,children:(0,K.jsx)(fh,{className:`h-4 w-4`})}),(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:c,children:(0,K.jsx)(jh,{className:`h-4 w-4`})})]})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto relative`,children:D&&r&&i&&E?n?(0,K.jsxs)(`div`,{className:`flex-1 h-full relative`,"data-testid":`resource-widget-preview`,children:[(0,K.jsx)(`div`,{className:`absolute top-2 right-2 z-10 flex items-center gap-2`,children:(0,K.jsx)(C$,{toolCallId:`resource-${e.timestamp}`,displayMode:g,onDisplayModeChange:_,propsContext:`resource`,resourceUri:e.uri,resourceAnnotations:S,llmConfig:d||null,resource:u||null,onPropsChange:h,requiredProps:C.length>0&&!p?C:void 0})}),O?(0,K.jsx)(`div`,{className:`flex items-center justify-center w-full h-full min-h-[200px] rounded-xl border-2 border-dashed border-gray-300 dark:border-zinc-600 bg-gray-50 dark:bg-zinc-800/50 m-4`,children:(0,K.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 text-center px-6`,children:`This widget requires props, set or generate them in the props debugger`})}):(0,K.jsx)(d$,{serverId:r,toolCallId:`resource-${e.timestamp}`,toolName:e.uri,toolInput:f,toolOutput:e.result,toolMetadata:S,resourceUri:E,readResource:i,className:`w-full h-full relative flex p-4`,customProps:p||void 0,displayMode:g,onDisplayModeChange:_})]}):(0,K.jsx)(`div`,{className:`px-4 pt-4`,"data-testid":`resource-result-json`,children:(0,K.jsx)(bO,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,`-`)}-mcp-apps-${Date.now()}.json`})}):b&&r&&i&&y?n?(0,K.jsx)(`div`,{className:`flex-1 h-full relative`,children:O?(0,K.jsx)(`div`,{className:`flex items-center justify-center w-full h-full min-h-[200px] rounded-xl border-2 border-dashed border-gray-300 dark:border-zinc-600 bg-gray-50 dark:bg-zinc-800/50 m-4`,children:(0,K.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 text-center px-6`,children:`This widget requires props, set or generate them in the props debugger`})}):(0,K.jsx)(T$,{componentUrl:y,toolName:e.uri,toolArgs:{},toolResult:e.result,serverId:r,readResource:i,className:`w-full h-full relative flex p-4`,customProps:p||void 0})}):(0,K.jsx)(`div`,{className:`px-4 pt-4`,"data-testid":`resource-result-json`,children:(0,K.jsx)(bO,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,`-`)}-${Date.now()}.json`})}):A?n?(0,K.jsxs)(`div`,{className:`space-y-0 h-full`,children:[j.map((e,t)=>(0,K.jsx)(`div`,{className:`mx-0 size-full`,children:(0,K.jsx)(`div`,{className:`w-full h-full`,children:(0,K.jsx)(H7,{resource:e,className:`w-full h-full`,customProps:p||void 0})})},`mcp-ui-${e.uri||`resource-${Date.now()}-${Math.random()}`}`)),(()=>{if(e.result&&`contents`in e.result&&Array.isArray(e.result.contents)){let t=e.result.contents.filter(e=>!(e.mimeType&&V7(e)));if(t.length>0)return(0,K.jsx)(`div`,{className:`px-4`,children:(0,K.jsx)(bO,{data:t,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,`-`)}-non-ui-${Date.now()}.json`})})}return null})()]}):(0,K.jsx)(`div`,{className:`px-4 pt-4`,"data-testid":`resource-result-json`,children:(0,K.jsx)(bO,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,`-`)}-mcp-ui-${Date.now()}.json`})}):(0,K.jsx)(`div`,{className:`px-4 pt-4`,"data-testid":`resource-result-json`,children:(0,K.jsx)(bO,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,`-`)}-${Date.now()}.json`})})})]})}function Sxe(e,t){if(!e&&!t)return(0,K.jsx)(bh,{className:`h-5 w-5`});let n=(e||t||``).toLowerCase();return n.includes(`image`)?(0,K.jsx)(vh,{className:`h-5 w-5`}):n.includes(`json`)||n.includes(`javascript`)||n.includes(`typescript`)?(0,K.jsx)(_h,{className:`h-5 w-5`}):n.includes(`html`)||n.includes(`xml`)?(0,K.jsx)(Sh,{className:`h-5 w-5`}):n.includes(`database`)||n.includes(`sql`)?(0,K.jsx)(dh,{className:`h-5 w-5`}):(0,K.jsx)(yh,{className:`h-5 w-5`})}function W7({resources:e,selectedResource:t,onResourceSelect:n,focusedIndex:r}){return e.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,K.jsx)(dh,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,K.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`No resources available`})]}):(0,K.jsx)(`div`,{className:`overflow-y-auto flex-1 overscroll-contain`,children:e.map((e,i)=>{let a=Sxe(e.mimeType,e.uri),o=[e.description,e.mimeType&&(0,K.jsx)(`span`,{className:`font-mono`,children:e.mimeType},`mime`)].filter(Boolean);return(0,K.jsx)(k7,{id:`resource-${e.uri}`,"data-testid":`resource-item-${e.name}`,isSelected:t?.uri===e.uri,isFocused:r===i,icon:a,title:e.name,description:o.length>0?(0,K.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[e.description&&(0,K.jsx)(`span`,{children:e.description}),e.mimeType&&(0,K.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-500 font-mono`,children:e.mimeType})]}):void 0,onClick:()=>n(e)},e.uri)})})}function G7({isSearchExpanded:e,searchQuery:t,filteredResourcesCount:n,onSearchExpand:r,onSearchChange:i,onSearchBlur:a,searchInputRef:o,onRefresh:s,isRefreshing:c=!1}){return(0,K.jsx)(`div`,{className:`flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2`,children:(0,K.jsx)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:e?(0,K.jsx)(uy,{ref:o,placeholder:`Search resources...`,value:t,onChange:e=>i(e.target.value),onBlur:a,className:`h-8 border-gray-300 dark:border-zinc-600`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-medium text-gray-900 dark:text-gray-100`,children:`Resources`}),(0,K.jsx)(Aa,{className:`bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent`,variant:`outline`,children:n}),(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:r,className:`h-8 w-8 p-0`,children:(0,K.jsx)(Vh,{className:`h-4 w-4`})})}),(0,K.jsxs)(Im,{side:`bottom`,className:`flex gap-2`,children:[`Search`,(0,K.jsx)(O7,{children:`F`})]})]}),s&&(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:s,disabled:c,className:`h-8 w-8 p-0`,children:(0,K.jsx)(Rh,{className:`h-4 w-4 ${c?`animate-spin`:``}`})})}),(0,K.jsxs)(Im,{side:`bottom`,className:`flex gap-2`,children:[`Refresh list`,(0,K.jsx)(O7,{children:`R`})]})]})]})})})}function K7({ref:e,resources:t,readResource:n,serverId:r,isConnected:i,mcpServerUrl:a,refreshResources:o}){let[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(null),{selectedResourceUri:d,setSelectedResourceUri:f}=SF(),{llmConfig:p}=p5({mcpServerUrl:a}),[m,h]=(0,G.useState)(null),[g,_]=(0,G.useState)(!1),[v,y]=(0,G.useState)(``),[b]=(0,G.useState)(`resources`),[x,S]=(0,G.useState)(!0),[C,w]=(0,G.useState)(!1),[T,E]=(0,G.useState)(-1),[D,O]=(0,G.useState)(!1),k=(0,G.useRef)(null),A=(0,G.useRef)(null),[j,M]=(0,G.useState)(!1),[N,P]=(0,G.useState)(`list`);(0,G.useEffect)(()=>{let e=()=>{M(window.innerWidth<1024)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,G.useEffect)(()=>{P(l?`detail`:`list`)},[l]),(0,G.useImperativeHandle)(e,()=>({focusSearch:()=>{w(!0),setTimeout(()=>{k.current&&k.current.focus()},0)},blurSearch:()=>{y(``),w(!1),k.current&&k.current.blur()}})),(0,G.useEffect)(()=>{C&&k.current&&k.current.focus()},[C]);let F=(0,G.useCallback)(()=>{v.trim()||w(!1)},[v]),I=(0,G.useCallback)(async()=>{if(o){c(!0);try{await o()}finally{c(!1)}}},[o]),L=(0,G.useMemo)(()=>{if(!v)return t;let e=v.toLowerCase();return t.filter(t=>t.name.toLowerCase().includes(e)||t.description?.toLowerCase().includes(e)||t.uri.toLowerCase().includes(e))},[t,v]),ee=(0,G.useCallback)(async e=>{if(u(e),i){_(!0);let t=Date.now();try{let i=await n(e.uri);Km.getInstance().capture(new Rm({resourceUri:e.uri,serverId:r,success:!0})).catch(()=>{}),h({uri:e.uri,result:i,timestamp:t,resourceAnnotations:{...e.annotations,...e._meta||{}}})}catch(n){Km.getInstance().capture(new Rm({resourceUri:e.uri,serverId:r,success:!1,error:n instanceof Error?n.message:`Unknown error`})).catch(()=>{}),h({uri:e.uri,result:{contents:[],_meta:{}},error:n instanceof Error?n.message:`Unknown error`,timestamp:t,resourceAnnotations:{...e.annotations,...e._meta||{}}})}finally{_(!1)}}},[n,r,i]);(0,G.useEffect)(()=>{E(-1)},[v,b]),(0,G.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.contentEditable===`true`||e.metaKey||e.ctrlKey||e.altKey)return;let n=L;if(e.key===`ArrowDown`)e.preventDefault(),E(e=>{let t=e+1;return t>=n.length?0:t});else if(e.key===`ArrowUp`)e.preventDefault(),E(e=>{let t=e-1;return t<0?n.length-1:t});else if(e.key===`Enter`&&T>=0){e.preventDefault();let t=L[T];t&&ee(t)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[T,L,ee]),(0,G.useEffect)(()=>{if(T>=0){let e=`resource-${L[T]?.uri}`,t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[T,L]),(0,G.useEffect)(()=>{if(d&&t.length>0){let e=t.find(e=>e.uri===d);e&&l?.uri!==e.uri&&(f(null),setTimeout(()=>{ee(e);let t=document.getElementById(`resource-${e.uri}`);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})},100))}},[d,t,l,ee,f]),(0,G.useEffect)(()=>{if(l){let e=t.find(e=>e.uri===l.uri);e&&e!==l&&(e.description!==l.description||e.mimeType!==l.mimeType||e.name!==l.name)&&u(e)}},[t,l]);let te=(0,G.useCallback)(async()=>{if(m)try{await rg(JSON.stringify(m.result,null,2)),O(!0),setTimeout(()=>O(!1),2e3)}catch(e){console.error(`[ResourcesTab] Failed to copy result:`,e)}},[m]),R=(0,G.useCallback)(()=>{if(m)try{let e=new globalThis.Blob([JSON.stringify(m.result,null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`resource-${Date.now()}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}catch(e){console.error(`[ResourcesTab] Failed to download result:`,e)}},[m]),z=(0,G.useCallback)(async()=>{if(A.current)try{document.fullscreenElement?await document.exitFullscreen():await A.current.requestFullscreen()}catch(e){console.error(`[ResourcesTab] Failed to toggle fullscreen:`,e)}},[]);return j?(0,K.jsxs)(`div`,{className:`h-full flex flex-col overflow-hidden relative bg-background`,children:[N!==`list`&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10`,children:[(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>{u(null),P(`list`)},className:`p-0 h-8 w-8`,children:(0,K.jsx)(th,{className:`h-4 w-4`})}),(0,K.jsxs)(`div`,{className:`flex items-center text-sm font-medium`,children:[(0,K.jsx)(`button`,{onClick:()=>{u(null),P(`list`)},className:`text-muted-foreground hover:text-foreground hover:underline cursor-pointer`,children:`Resources`}),N===`detail`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`mx-2 text-muted-foreground`,children:`/`}),(0,K.jsx)(`span`,{className:`text-foreground`,children:`Content`})]})]})]}),(0,K.jsx)(`div`,{className:`flex-1 relative overflow-hidden`,children:(0,K.jsxs)(OP,{initial:!1,mode:`popLayout`,children:[N===`list`&&(0,K.jsxs)(_F.div,{initial:{x:`-100%`},animate:{x:0},exit:{x:`-100%`},transition:{type:`spring`,stiffness:300,damping:30},className:`absolute inset-0 flex flex-col bg-background z-0`,children:[(0,K.jsx)(G7,{activeTab:b,isSearchExpanded:C,searchQuery:v,filteredResourcesCount:L.length,onSearchExpand:()=>w(!0),onSearchChange:y,onSearchBlur:F,onTabSwitch:()=>{},searchInputRef:k,onRefresh:o?I:void 0,isRefreshing:s}),(0,K.jsx)(`div`,{className:`flex flex-col h-full`,children:(0,K.jsx)(W7,{resources:L,selectedResource:l,onResourceSelect:ee,focusedIndex:T})})]},`list`),N===`detail`&&(0,K.jsx)(_F.div,{initial:{x:`100%`},animate:{x:0},exit:{x:`100%`},transition:{type:`spring`,stiffness:300,damping:30},className:`absolute inset-0 bg-white dark:bg-zinc-900 z-10`,children:(0,K.jsx)(`div`,{ref:A,className:`h-full`,children:(0,K.jsx)(U7,{result:m,isLoading:g,previewMode:x,serverId:r,readResource:n,onTogglePreview:()=>S(!x),onCopy:te,onDownload:R,onFullscreen:z,isCopied:D,selectedResource:l,llmConfig:p})})},`detail`)]})})]}):(0,K.jsxs)(T7,{orientation:`horizontal`,className:`h-full`,children:[(0,K.jsx)(E7,{defaultSize:`33%`,children:(0,K.jsxs)(T7,{orientation:`vertical`,className:`h-full border-r dark:border-zinc-700`,children:[(0,K.jsx)(E7,{minSize:`30%`,children:(0,K.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,K.jsx)(G7,{activeTab:b,isSearchExpanded:C,searchQuery:v,filteredResourcesCount:L.length,onSearchExpand:()=>w(!0),onSearchChange:y,onSearchBlur:F,onTabSwitch:()=>{},searchInputRef:k,onRefresh:o?I:void 0,isRefreshing:s}),(0,K.jsx)(W7,{resources:L,selectedResource:l,onResourceSelect:ee,focusedIndex:T})]})}),(0,K.jsx)(D7,{withHandle:!0}),(0,K.jsx)(N7,{serverId:r})]})}),(0,K.jsx)(D7,{}),(0,K.jsx)(E7,{defaultSize:`67%`,children:(0,K.jsx)(`div`,{ref:A,className:`h-full bg-white dark:bg-zinc-900`,children:(0,K.jsx)(U7,{result:m,isLoading:g,previewMode:x,serverId:r,readResource:n,onTogglePreview:()=>S(!x),onCopy:te,onDownload:R,onFullscreen:z,isCopied:D,selectedResource:l,llmConfig:p})})})]})}K7.displayName=`ResourcesTab`;function Cxe({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:r,onSearchExpand:i,onSearchChange:a,onSearchBlur:o,onRejectAll:s,searchInputRef:c}){return(0,K.jsxs)(`div`,{className:`flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2`,children:[(0,K.jsx)(`div`,{className:`flex items-center gap-2 flex-1`,children:e?(0,K.jsx)(uy,{ref:c,placeholder:`Search requests...`,value:t,onChange:e=>a(e.target.value),onBlur:o,className:`h-8 border-gray-300 dark:border-zinc-600`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-medium text-gray-900 dark:text-gray-100`,children:`Sampling`}),(0,K.jsx)(Aa,{className:`bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent`,variant:`outline`,children:n}),(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:i,className:`h-8 w-8 p-0`,children:(0,K.jsx)(Vh,{className:`h-4 w-4`})})}),(0,K.jsxs)(Im,{side:`bottom`,className:`flex gap-2`,children:[`Search`,(0,K.jsx)(O7,{children:`F`})]})]})]})}),(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:s,disabled:r===0,className:`h-8 w-8 p-0`,children:(0,K.jsx)($h,{className:`h-4 w-4`})})}),(0,K.jsx)(Im,{side:`bottom`,children:`Reject all`})]})})]})}function wxe({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:r,formatRelativeTime:i,listRef:a}){return e.length===0?(0,K.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:(0,K.jsx)(nm,{vertical:!0,noBorder:!0,message:`No sampling requests`})}):(0,K.jsx)(`div`,{ref:a,className:`overflow-y-auto flex-1 overscroll-contain`,children:e.map((e,a)=>{let o=e.request.params?.messages?.length||0,s=e.request.params?.maxTokens;return(0,K.jsx)(k7,{id:`sampling-request-${e.id}`,isSelected:t?.id===e.id,isFocused:r===a,title:(0,K.jsxs)(`span`,{className:`flex items-center gap-3`,children:[e.serverName,(0,K.jsx)(`span`,{className:`size-1.5 block rounded-full bg-orange-500`})]}),description:(()=>{let t=i(e.timestamp),n=[];return o>0&&n.push(`${o} message${o>1?`s`:``}`),s&&n.push(`max ${s} tokens`),t+(n.length>0?` | ${n.join(`, `)}`:``)})(),onClick:()=>n(e)},e.id)})})}function Txe({llmConfig:e}){let t=(0,G.useRef)(null);return{generateResponse:(0,G.useCallback)(async({request:n})=>{if(!e)throw Error(`LLM config is not available`);let r=n.params||{},i=r.maxTokens,a=r.temperature;r.modelPreferences;let o=r.messages||[];if(console.log(`[useSamplingLLM] Request structure:`,{hasParams:!!r,messagesCount:o.length,messages:o,params:r}),o.length===0)throw Error(`No messages found in sampling request`);let s=[],{HumanMessage:c,AIMessage:l}=await B(async()=>{let{HumanMessage:e,AIMessage:t}=await import(`./messages-D9QOZWGX.js`);return{HumanMessage:e,AIMessage:t}},[]);for(let e of o){if(!e||!e.role){console.warn(`Skipping invalid message:`,e);continue}let t=Array.isArray(e.content)?e.content[0]:e.content;if(!t){console.warn(`Skipping message with no content:`,e);continue}t.type===`text`&&t.text?e.role===`user`?s.push(new c(t.text)):e.role===`assistant`&&s.push(new l(t.text)):console.warn(`Skipping message with unsupported content type:`,t)}if(s.length===0)throw Error(`No valid messages could be converted. Please ensure messages have 'text' content type.`);if(!t.current||t.current.provider!==e.provider||t.current.model!==e.model||t.current.apiKey!==e.apiKey){let n,r={model:e.model,apiKey:e.apiKey};if(i!==void 0&&(r.maxTokens=i),a===void 0?e.temperature!==void 0&&(r.temperature=e.temperature):r.temperature=a,e.provider===`openai`){let{ChatOpenAI:e}=await B(async()=>{let{ChatOpenAI:e}=await import(`./dist-DXjAPY-W.js`);return{ChatOpenAI:e}},__vite__mapDeps([197,198,3,199,200,201,202,203]));n=new e(r)}else if(e.provider===`anthropic`){let{ChatAnthropic:e}=await B(async()=>{let{ChatAnthropic:e}=await import(`./dist-jBWD8iGG.js`);return{ChatAnthropic:e}},__vite__mapDeps([204,198,3,201,202,203]));n=new e(r)}else if(e.provider===`google`){let{ChatGoogleGenerativeAI:e}=await B(async()=>{let{ChatGoogleGenerativeAI:e}=await import(`./dist-CFOVbGE_.js`);return{ChatGoogleGenerativeAI:e}},__vite__mapDeps([205,198,3,199]));n=new e(r)}else throw Error(`Unsupported LLM provider: ${e.provider}`);t.current={instance:n,provider:e.provider,model:e.model,apiKey:e.apiKey}}let u=await t.current.instance.invoke(s);return{role:`assistant`,content:{type:`text`,text:u.content||u.text||``},model:e.model,stopReason:`endTurn`}},[e]),isAvailable:e!==null}}function Exe({request:e,onApprove:t,onReject:r,onClose:i,previewMode:a,onTogglePreview:o,isCopied:s,onCopy:c,onDownload:l,onFullscreen:u,llmConfig:d}){let[f,p]=(0,G.useState)(`manual`),[m,h]=(0,G.useState)(`stub-model`),[g,_]=(0,G.useState)(`endTurn`),[v,y]=(0,G.useState)(`assistant`),[b,x]=(0,G.useState)(`text`),[S,C]=(0,G.useState)(`positive`),[w,T]=(0,G.useState)(``),[E,D]=(0,G.useState)(`image/png`),[O,k]=(0,G.useState)(!1),[A,j]=(0,G.useState)(null),{generateResponse:M,isAvailable:N}=Txe({llmConfig:d});(0,G.useEffect)(()=>{e&&(h(f===`llm`&&d?.model?d.model:`stub-model`),_(`endTurn`),y(`assistant`),x(`text`),C(`positive`),T(``),D(`image/png`),j(null))},[e?.id]),(0,G.useEffect)(()=>{f===`llm`&&d?.model&&h(d.model)},[f,d?.model]);let P=async()=>{if(!e||!N){console.log(`[SamplingRequestDisplay] Cannot generate:`,{hasRequest:!!e,isAvailable:N});return}console.log(`[SamplingRequestDisplay] Starting LLM generation:`,{requestId:e.id,llmConfig:d}),k(!0),j(null);try{let t=await M({request:e.request});console.log(`[SamplingRequestDisplay] LLM generation result:`,{result:t,model:t.model,stopReason:t.stopReason,role:t.role,contentIsArray:Array.isArray(t.content),content:t.content}),h(t.model||d?.model||`stub-model`),_(t.stopReason||`endTurn`),y(t.role||`assistant`);let n=Array.isArray(t.content)?t.content[0]:t.content;console.log(`[SamplingRequestDisplay] Setting content:`,{contentType:n.type,hasText:`text`in n,text:`text`in n?n.text:void 0}),n.type===`text`?(x(`text`),C(n.text||``),console.log(`[SamplingRequestDisplay] Set text content:`,n.text)):n.type===`image`&&(x(`image`),T(n.data||``),D(n.mimeType||`image/png`),console.log(`[SamplingRequestDisplay] Set image content`)),console.log(`[SamplingRequestDisplay] Form state after update:`,{model:m,stopReason:g,role:v,contentType:b,textContent:S})}catch(e){console.error(`[SamplingRequestDisplay] LLM generation error:`,e);let t=e instanceof Error?e.message:`Failed to generate response`;j(t),xv.error(`LLM Generation Failed`,{description:t})}finally{k(!1),console.log(`[SamplingRequestDisplay] Generation complete`)}},F=(0,G.useMemo)(()=>{let e={model:m,stopReason:g,role:v,content:{type:b}};return b===`text`?e.content.text=S:b===`image`&&(e.content.data=w,e.content.mimeType=E),e},[m,g,v,b,S,w,E]),L=()=>{if(!e)return;let r=I.safeParse(F);if(!r.success){xv.error(`Invalid response`,{description:`Validation failed: ${r.error.message}`});return}t(e.id,r.data),i(),B(()=>import(`./react-DDmrI2D-.js`).then(e=>n(e.default,1)).then(t=>{let n=xv(t.createElement(`div`,{className:`space-y-3`},t.createElement(`div`,null,t.createElement(`strong`,null,`Sampling Response Sent`),t.createElement(`p`,{className:`text-sm text-muted-foreground mt-1`},`The tool will continue executing.`)),t.createElement(`div`,{className:`flex gap-2`},t.createElement(`button`,{"data-testid":`sampling-view-tool-result`,className:`px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90`,onClick:()=>{let t=new globalThis.CustomEvent(`navigate-to-tool-result`,{detail:{toolName:e.toolName}});window.dispatchEvent(t),xv.dismiss(n)}},`View Tool Result`))),{duration:5e3})}),[])},ee=()=>{e&&(r(e.id,`User rejected sampling request`),i())};return e?(0,K.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b dark:border-zinc-700`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`h3`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:e.serverName}),(0,K.jsx)(`span`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:new Date(e.timestamp).toLocaleString()})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:c,className:`h-8 w-8 p-0`,children:s?(0,K.jsx)($m,{className:`h-4 w-4 text-green-600`}):(0,K.jsx)(uh,{className:`h-4 w-4`})})}),(0,K.jsx)(Im,{children:`Copy request`})]}),(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:l,className:`h-8 w-8 p-0`,children:(0,K.jsx)(fh,{className:`h-4 w-4`})})}),(0,K.jsx)(Im,{children:`Download request`})]}),(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:u,className:`h-8 w-8 p-0`,children:(0,K.jsx)(Ah,{className:`h-4 w-4`})})}),(0,K.jsx)(Im,{children:`Fullscreen`})]}),(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:i,className:`h-8 w-8 p-0`,children:(0,K.jsx)(tg,{className:`h-4 w-4`})})]})]}),(0,K.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-6`,children:[(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`Request`}),(0,K.jsx)(`div`,{className:`bg-muted rounded-lg p-3 max-h-64 overflow-auto`,children:(0,K.jsx)(bO,{data:e.request})})]}),(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`Response`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(py,{htmlFor:`responseMode-${e.id}`,className:`text-xs text-gray-500 dark:text-gray-400`,children:`Mode:`}),(0,K.jsxs)(ab,{value:f,onValueChange:e=>p(e),children:[(0,K.jsx)(sb,{id:`responseMode-${e.id}`,className:`w-32 h-8 text-xs`,"data-testid":`sampling-response-mode-select`,children:(0,K.jsx)(ob,{})}),(0,K.jsxs)(cb,{children:[(0,K.jsx)(lb,{value:`manual`,"data-testid":`sampling-response-mode-manual`,children:`Manual`}),(0,K.jsx)(lb,{value:`llm`,"data-testid":`sampling-response-mode-llm`,children:`LLM`})]})]})]})]}),f===`llm`&&(0,K.jsxs)(`div`,{className:`space-y-2 p-3 bg-muted rounded-lg`,children:[N?(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(J,{onClick:P,disabled:O,size:`sm`,className:`flex items-center gap-2`,"data-testid":`sampling-generate-llm-button`,children:O?(0,K.jsxs)(`span`,{"data-testid":`sampling-generating`,className:`flex items-center gap-2`,children:[(0,K.jsx)(kh,{className:`h-4 w-4 animate-spin`}),`Generating...`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(qh,{className:`h-4 w-4`}),`Generate with LLM`]})}),(0,K.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[`Using `,d?.provider,` (`,d?.model,`)`]})]}):(0,K.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:`LLM not configured. Please configure LLM in the Chat tab.`}),A&&(0,K.jsx)(`div`,{className:`text-xs text-red-600 dark:text-red-400`,"data-testid":`sampling-generation-error`,children:A})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(py,{htmlFor:`model-${e.id}`,children:`Model`}),(0,K.jsx)(uy,{id:`model-${e.id}`,value:m,onChange:e=>h(e.target.value),placeholder:`stub-model`,disabled:f===`llm`&&O,"data-testid":`sampling-model-input`})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(py,{htmlFor:`stopReason-${e.id}`,children:`Stop Reason`}),(0,K.jsx)(uy,{id:`stopReason-${e.id}`,value:g,onChange:e=>_(e.target.value),placeholder:`endTurn`,disabled:f===`llm`&&O,"data-testid":`sampling-stop-reason-input`})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(py,{htmlFor:`role-${e.id}`,children:`Role`}),(0,K.jsxs)(ab,{value:v,onValueChange:e=>y(e),disabled:f===`llm`&&O,children:[(0,K.jsx)(sb,{id:`role-${e.id}`,"data-testid":`sampling-role-select`,children:(0,K.jsx)(ob,{})}),(0,K.jsxs)(cb,{children:[(0,K.jsx)(lb,{value:`assistant`,children:`assistant`}),(0,K.jsx)(lb,{value:`user`,children:`user`})]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(py,{htmlFor:`contentType-${e.id}`,children:`Content Type`}),(0,K.jsxs)(ab,{value:b,onValueChange:e=>x(e),disabled:f===`llm`&&O,children:[(0,K.jsx)(sb,{id:`contentType-${e.id}`,"data-testid":`sampling-content-type-select`,children:(0,K.jsx)(ob,{})}),(0,K.jsxs)(cb,{children:[(0,K.jsx)(lb,{value:`text`,children:`text`}),(0,K.jsx)(lb,{value:`image`,children:`image`})]})]})]}),b===`text`&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(py,{htmlFor:`text-${e.id}`,children:`Text Content`}),(0,K.jsx)(tL,{id:`text-${e.id}`,value:S,onChange:e=>C(e.target.value),placeholder:`Enter response text...`,rows:6,disabled:f===`llm`&&O,"data-testid":`sampling-text-content`})]}),b===`image`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(py,{htmlFor:`imageData-${e.id}`,children:`Base64 Image Data`}),(0,K.jsx)(tL,{id:`imageData-${e.id}`,value:w,onChange:e=>T(e.target.value),placeholder:`Base64 encoded image data...`,rows:4,disabled:f===`llm`&&O})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(py,{htmlFor:`mimeType-${e.id}`,children:`MIME Type`}),(0,K.jsx)(uy,{id:`mimeType-${e.id}`,value:E,onChange:e=>D(e.target.value),placeholder:`image/png`,disabled:f===`llm`&&O})]})]})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 p-4 border-t dark:border-zinc-700`,children:[(0,K.jsx)(J,{onClick:L,className:`flex-1`,disabled:f===`llm`&&O,"data-testid":`sampling-approve-button`,children:`Approve`}),(0,K.jsx)(J,{onClick:ee,variant:`outline`,className:`flex-1`,disabled:f===`llm`&&O,"data-testid":`sampling-reject-button`,children:`Reject`})]})]}):(0,K.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:(0,K.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Select a sampling request to view details`})})}var Dxe={model:`stub-model`,stopReason:`endTurn`,role:`assistant`,content:{type:`text`,text:`positive`}};function Oxe({requestId:e,serverName:t,onViewDetails:n,onApprove:r,onDeny:i}){return(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`strong`,{children:`Sampling Request Received`}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:[`New request from `,t]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`button`,{"data-testid":`sampling-toast-view-details`,className:`px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground`,onClick:e=>{e.stopPropagation(),n()},children:`View Details`}),(0,K.jsx)(`button`,{"data-testid":`sampling-toast-approve`,className:`px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground`,onClick:e=>{e.stopPropagation(),r(Dxe)},children:`Approve`}),(0,K.jsx)(`button`,{"data-testid":`sampling-toast-deny`,className:`px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground`,onClick:e=>{e.stopPropagation(),i()},children:`Deny`})]})]})}function kxe({pendingRequests:e,onApprove:t,onReject:n,serverId:r,isConnected:i,mcpServerUrl:a}){let{selectedSamplingRequestId:o,setSelectedSamplingRequestId:s}=SF(),{llmConfig:c}=p5({mcpServerUrl:a}),[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(-1),[h,g]=(0,G.useState)(!0),[_,v]=(0,G.useState)(!1),[y,b]=(0,G.useState)(!0),[x,S]=(0,G.useState)(!1),C=(0,G.useRef)(null),w=(0,G.useRef)(null),T=(0,G.useRef)(null),E=(0,G.useRef)(!1);(0,G.useEffect)(()=>{if(console.log(`[SamplingTab] Auto-selection check:`,{selectedSamplingRequestId:o,pendingRequestsCount:e.length,currentSelectedId:l?.id}),o&&e.length>0){let t=e.find(e=>e.id===o);console.log(`[SamplingTab] Found request for auto-selection:`,!!t,t?.id),t&&(console.log(`[SamplingTab] Auto-selecting request:`,t.id),s(null),u(t),setTimeout(()=>{let e=document.getElementById(`sampling-request-${t.id}`);console.log(`[SamplingTab] Scrolling to element:`,!!e),e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},100))}},[o,e,s]),(0,G.useEffect)(()=>{let t=t=>{let n=t.detail.requestId;console.log(`[SamplingTab] Custom navigate event received:`,n);let r=e.find(e=>e.id===n);r&&(console.log(`[SamplingTab] Selecting request from event:`,n),u(r),setTimeout(()=>{let e=document.getElementById(`sampling-request-${n}`);e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},200))};return window.addEventListener(`navigate-to-sampling`,t),()=>window.removeEventListener(`navigate-to-sampling`,t)},[e]),(0,G.useEffect)(()=>{h&&e.length>0&&C.current&&!E.current&&(C.current.scrollTop=0)},[e.length,h]),(0,G.useEffect)(()=>{let e=C.current;if(!e)return;let t=()=>{e.scrollTop>0&&(E.current=!0,g(!1))};return e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)},[]),(0,G.useEffect)(()=>{e.length===0&&(E.current=!1,g(!0))},[e.length]),(0,G.useEffect)(()=>{_&&T.current&&T.current.focus()},[_]);let D=(0,G.useCallback)(()=>{d.trim()||v(!1)},[d]),O=(0,G.useMemo)(()=>{if(!d.trim())return e;let t=d.toLowerCase();return e.filter(e=>e.serverName.toLowerCase().includes(t)||JSON.stringify(e.request||{}).toLowerCase().includes(t))},[e,d]);(0,G.useEffect)(()=>{m(-1)},[d]),(0,G.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.contentEditable===`true`||e.metaKey||e.ctrlKey||e.altKey)return;let n=O;if(e.key===`ArrowDown`)e.preventDefault(),m(e=>{let t=e+1;return t>=n.length?0:t});else if(e.key===`ArrowUp`)e.preventDefault(),m(e=>{let t=e-1;return t<0?n.length-1:t});else if(e.key===`Enter`&&p>=0){e.preventDefault();let t=O[p];t&&k(t)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[p,O]),(0,G.useEffect)(()=>{if(p>=0){let e=`sampling-request-${O[p]?.id}`,t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[p,O]);let k=(0,G.useCallback)(e=>{u(e)},[]),A=(0,G.useCallback)(()=>{window.confirm(`Are you sure you want to reject all sampling requests? This cannot be undone.`)&&(e.forEach(e=>{n(e.id,`User rejected all requests`)}),u(null))},[e,n]),j=(0,G.useCallback)(async()=>{if(l)try{await rg(JSON.stringify({id:l.id,serverName:l.serverName,timestamp:l.timestamp,request:l.request},null,2)),S(!0),setTimeout(()=>S(!1),2e3)}catch(e){console.error(`[SamplingTab] Failed to copy request:`,e)}},[l]),M=(0,G.useCallback)(()=>{if(l)try{let e=new globalThis.Blob([JSON.stringify({id:l.id,serverName:l.serverName,timestamp:l.timestamp,request:l.request},null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`sampling-request-${Date.now()}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}catch(e){console.error(`[SamplingTab] Failed to download request:`,e)}},[l]),N=(0,G.useCallback)(async()=>{if(w.current)try{document.fullscreenElement?await document.exitFullscreen():await w.current.requestFullscreen()}catch(e){console.error(`[SamplingTab] Failed to toggle fullscreen:`,e)}},[]);return i?(0,K.jsxs)(T7,{orientation:`horizontal`,className:`h-full`,children:[(0,K.jsx)(E7,{defaultSize:40,minSize:30,children:(0,K.jsx)(T7,{orientation:`vertical`,className:`h-full border-r dark:border-zinc-700`,children:(0,K.jsxs)(E7,{defaultSize:75,minSize:30,children:[(0,K.jsx)(Cxe,{isSearchExpanded:_,searchQuery:d,filteredRequestsCount:O.length,requestsCount:e.length,onSearchExpand:()=>v(!0),onSearchChange:f,onSearchBlur:D,onRejectAll:A,searchInputRef:T}),(0,K.jsx)(`div`,{className:`flex flex-col h-full`,children:(0,K.jsx)(wxe,{requests:O,selectedRequest:l,onRequestSelect:k,focusedIndex:p,formatRelativeTime:j7,listRef:C})})]})})}),(0,K.jsx)(D7,{}),(0,K.jsx)(E7,{defaultSize:60,minSize:40,children:(0,K.jsx)(`div`,{ref:w,className:`h-full bg-white dark:bg-zinc-900`,children:(0,K.jsx)(Exe,{request:l,onApprove:t,onReject:n,onClose:()=>u(null),previewMode:y,onTogglePreview:()=>b(!y),isCopied:x,onCopy:j,onDownload:M,onFullscreen:N,llmConfig:c})})})]}):(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,K.jsx)(wh,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,K.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Not connected to server`})]})}function q7({savedRequests:e,selectedRequest:t,onLoadRequest:n,onDeleteRequest:r,focusedIndex:i}){if(e.length===0)return(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,K.jsx)(dh,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,K.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400 mb-2`,children:`No saved requests yet`}),(0,K.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:`Execute a tool and click Save to store requests`})]});let a=(e,t)=>{e.stopPropagation(),t()};return(0,K.jsx)(`div`,{className:`overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain`,children:e.map((e,o)=>(0,K.jsxs)(`div`,{className:`relative group`,children:[(0,K.jsx)(k7,{id:`saved-${e.id}`,isSelected:t?.id===e.id,isFocused:i===o,icon:(0,K.jsx)(Th,{className:`h-4 w-4`}),title:e.name,description:e.toolName,metadata:(0,K.jsx)(`div`,{className:`flex flex-col gap-1`,children:(0,K.jsx)(`span`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:new Date(e.savedAt).toLocaleString()})}),onClick:()=>n(e)}),(0,K.jsx)(`div`,{className:`absolute top-1/2 right-2 -translate-y-1/2 opacity-0 group-hover:opacity-100 transition-opacity z-10`,children:(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`secondary`,size:`sm`,onClick:t=>a(t,()=>r(e.id)),className:`h-8 w-8 p-0`,children:(0,K.jsx)($h,{className:`h-4 w-4`})})}),(0,K.jsx)(Im,{children:(0,K.jsx)(`p`,{children:`Delete saved request`})})]})})]},e.id))})}function J7({isOpen:e,requestName:t,defaultPlaceholder:n,onRequestNameChange:r,onSave:i,onCancel:a}){return e?(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,onClick:a,children:(0,K.jsxs)(`div`,{className:`bg-white dark:bg-zinc-800 rounded-lg p-6 w-[400px] shadow-xl border border-gray-200 dark:border-zinc-700`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold mb-4 text-gray-900 dark:text-gray-100`,children:`Save Request`}),(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(py,{htmlFor:`request-name`,children:`Request Name (optional)`}),(0,K.jsx)(uy,{id:`request-name`,value:t,onChange:e=>r(e.target.value),placeholder:n,className:`mt-2`,onKeyDown:e=>{e.key===`Enter`&&i()},autoFocus:!0})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)(J,{variant:`outline`,onClick:a,children:`Cancel`}),(0,K.jsxs)(J,{onClick:i,children:[(0,K.jsx)(Bh,{className:`h-4 w-4 mr-2`}),`Save`]})]})]})]})}):null}function Y7(e,t){if(!e?.$ref)return e;let n=e.$ref;if(!n.startsWith(`#/`))return e;let r=n.substring(2).split(`/`),i=t;for(let t of r)if(i&&typeof i==`object`&&t in i)i=i[t];else return e;return i}function Axe(e,t){if(e?.anyOf&&Array.isArray(e.anyOf)){let n=e.anyOf.find(e=>Y7(e,t)?.type!==`null`);if(n)return{...Y7(n,t),nullable:!0}}return e}function X7(e,t){let n=Axe(e||{},t);return n=Y7(n,t),n}function Z7(e,t){let n=X7(e,t);if(typeof n.type==`string`)return n.type;if(Array.isArray(n.type)){let e=n.type.find(e=>e!==`null`);return typeof e==`string`?e:void 0}}function jxe(e){let t=e?.enum;return Array.isArray(t)&&t.every(e=>typeof e==`string`)?t:null}function Q7(e){let t=e.trim().toLowerCase();return[`true`,`1`,`yes`,`on`].includes(t)?!0:[`false`,`0`,`no`,`off`].includes(t)?!1:e}function Mxe(e,t){if(t===`number`||t===`integer`){let t=e.trim();if(!t)return e;let n=Number(t);return Number.isFinite(n)?n:e}return t===`boolean`?Q7(e):e}function Nxe(e,t){if(e===void 0)return e;if(t===`object`||t===`array`){if(typeof e==`string`)try{return JSON.parse(e)}catch{return e}return e}if(t===`number`||t===`integer`){if(typeof e==`number`)return e;if(typeof e==`string`){let t=e.trim();if(!t)return e;let n=Number(t);return Number.isFinite(n)?n:e}return e}return t===`boolean`?typeof e==`boolean`?e:typeof e==`string`?Q7(e):e:e}function Pxe(e){let t=``,n=0,r=!1,i=!1;for(;n<e.length;){let a=e[n];if(i){t+=a,i=!1,n++;continue}if(a===`\\`){i=!0,t+=a,n++;continue}if(a==="`"){r?(t+=`"`,r=!1):(t+=`"`,r=!0),n++;continue}if(r&&a===`"`){t+=`\\"`,n++;continue}t+=a,n++}return t}function Fxe(e){if(!e||typeof e!=`string`)return null;let t=e.trim();if(!t.startsWith(`{`))return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return e}catch{try{let e=Pxe(t),n=JSON.parse(e);if(n&&typeof n==`object`&&!Array.isArray(n))return n}catch{return null}}return null}function Ixe({selectedTool:e,toolArgs:t,onArgChange:n,onBulkPaste:r,autoFilledFields:i,setFields:a,sendEmptyFields:o,onToggleEmpty:s}){let c=e?.inputSchema?.properties||{},l=e?.inputSchema?.required||[],u=Object.keys(c).length>0,d=async(e,t)=>{r&&await r(e.clipboardData.getData(`text`),t)&&e.preventDefault()};return u?(0,K.jsx)(`div`,{className:`space-y-4`,children:Object.entries(c).map(([r,c])=>{let u=X7(c,e?.inputSchema||{}),f=jxe(u),p=u.type===`string`&&f!==null,m=u;m.required=l.includes(r);let h=t[r],g=``;h!=null&&(g=typeof h==`string`?h:typeof h==`object`&&h?JSON.stringify(h,null,2):String(h));let _=m.type===`object`||m.type===`array`,v=_?m.type===`array`?`array`:`object`:`string`,y=a?.has(r)??!0,b=s&&(m.type===`string`||_);return _?(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsxs)(py,{htmlFor:r,className:`text-sm font-medium`,children:[r,m?.required&&(0,K.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),b&&s&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:v===`array`?`Send empty array explicitly`:`Send empty object explicitly`}),(0,K.jsx)(_b,{checked:o?.has(r)??!1,onCheckedChange:e=>s(r,v,e),"aria-label":v===`array`?`Send empty array`:`Send empty object`,title:v===`array`?`Send empty array []`:`Send empty object {}`})]})]}),(0,K.jsx)(tL,{id:r,"data-testid":`tool-param-${r}`,value:g,onChange:e=>n(r,e.target.value),onPaste:e=>d(e,r),placeholder:m?.description||`Enter ${r}`,disabled:o?.has(r)??!1,className:`min-h-[100px] ${y?``:`opacity-70`} ${i?.has(r)?`animate-pulse ring-2 ring-green-500 dark:ring-green-400`:``}`}),m?.description&&(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:m.description})]},r):p&&f?(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(py,{htmlFor:r,className:`text-sm font-medium`,children:[r,m.required&&(0,K.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),(0,K.jsxs)(ab,{value:String(t[r]||``),onValueChange:e=>n(r,e),children:[(0,K.jsx)(sb,{id:r,className:`w-full ${y?``:`opacity-70`}`,"data-testid":`tool-param-${r}`,children:(0,K.jsx)(ob,{placeholder:m.description||`Select an option`})}),(0,K.jsx)(cb,{children:f.map((e,t)=>(0,K.jsx)(lb,{value:e,children:m.enumNames?.[t]||e},e))})]}),m.description&&(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:m.description})]},r):(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsxs)(py,{htmlFor:r,className:`text-sm font-medium`,children:[r,m?.required&&(0,K.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),b&&s&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`Send empty string`}),(0,K.jsx)(_b,{checked:o?.has(r)??!1,onCheckedChange:e=>s(r,`string`,e),"aria-label":`Send empty string`,title:`Send empty string`})]})]}),(0,K.jsx)(uy,{id:r,"data-testid":`tool-param-${r}`,value:g,onChange:e=>n(r,e.target.value),onPaste:e=>d(e,r),placeholder:m?.description||`Enter ${r}`,disabled:o?.has(r)??!1,className:`${y?``:`opacity-70`} ${i?.has(r)?`animate-pulse ring-2 ring-green-500 dark:ring-green-400`:``}`}),m?.description&&(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:m.description})]},r)})}):(0,K.jsx)(`div`,{className:`flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm`,children:`No parameters required`})}function $7({selectedTool:e,toolArgs:t,payloadToSend:n,isExecuting:r,isConnected:i,onArgChange:a,onExecute:o,onSave:s,onCancel:c,onBulkPaste:l,autoFilledFields:u,setFields:d,sendEmptyFields:f,onToggleEmpty:p}){let[m,h]=(0,G.useState)(!1),[g,_]=(0,G.useState)(!1),[v,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(!1),[S,C]=(0,G.useState)(!1),[w,T]=(0,G.useState)(!1),E=(0,G.useRef)(null);(0,G.useEffect)(()=>{if(E.current&&e?.description){let e=E.current,t=parseFloat(getComputedStyle(e).lineHeight),n=e.scrollHeight;T(Math.round(n/t)>3),C(!1)}},[e?.description]);let D=async()=>{if(e)try{await rg(JSON.stringify(e,null,2)),y(!0),setTimeout(()=>y(!1),2e3)}catch{}},O=async()=>{if(e)try{let e=n??t;await rg(JSON.stringify(e,null,2)),x(!0),setTimeout(()=>x(!1),2e3)}catch{}};return(0,G.useEffect)(()=>{let t=t=>{(t.metaKey||t.ctrlKey)&&t.key===`Enter`&&e&&!r&&i&&(t.preventDefault(),o()),t.key===`Escape`&&r&&c&&(t.preventDefault(),c())};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,r,i,o,c]),e?(0,K.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,K.jsx)(`div`,{className:`shrink-0 p-3 sm:p-5 pt-3 sm:pt-4 pb-4 sm:pr-4`,children:(0,K.jsx)(`div`,{children:(0,K.jsxs)(`div`,{className:`flex flex-row items-center justify-between mb-0 gap-2`,children:[(0,K.jsx)(`h3`,{className:`text-base sm:text-lg font-semibold`,"data-testid":`tool-execution-title`,children:e.name}),(0,K.jsxs)(`div`,{className:`flex gap-2 shrink-0`,children:[(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsxs)(J,{"data-testid":`tool-execution-metadata-button`,variant:g?`default`:`outline`,onClick:()=>_(!g),disabled:r,size:`sm`,className:`lg:size-default gap-2`,title:`View tool metadata`,children:[(0,K.jsx)(sh,{className:`h-4 w-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:`Metadata`})]})}),(0,K.jsx)(Im,{children:(0,K.jsx)(`p`,{children:`View tool definition metadata`})})]}),(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsxs)(J,{"data-testid":`tool-execution-copy-payload-button`,variant:`outline`,onClick:O,disabled:r,size:`sm`,className:`lg:size-default gap-2`,title:`Copy payload as JSON`,children:[b?(0,K.jsx)($m,{className:`h-4 w-4 text-green-600`}):(0,K.jsx)(uh,{className:`h-4 w-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:b?`Copied!`:`Payload`})]})}),(0,K.jsx)(Im,{children:(0,K.jsx)(`p`,{children:`Copy payload as JSON`})})]}),(0,K.jsxs)(J,{"data-testid":`tool-execution-save-button`,variant:`outline`,onClick:s,disabled:r,size:`sm`,className:`lg:size-default gap-2`,children:[(0,K.jsx)(Bh,{className:`h-4 w-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:`Save`})]}),r&&c?(0,K.jsxs)(Pm,{open:m?void 0:!1,children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(`div`,{onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),className:`relative`,children:(0,K.jsx)(J,{"data-testid":`tool-execution-cancel-button`,onClick:c,variant:m?`destructive`:`default`,size:`sm`,className:`lg:size-default gap-2 transition-all`,children:m?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(tg,{className:`h-4 w-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:`Cancel`}),(0,K.jsx)(`span`,{className:`hidden sm:inline text-[12px] border border-current p-1 rounded-full ml-2`,children:`Esc`})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(yF,{className:`mr-2`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:`Executing...`})]})})})}),(0,K.jsx)(Im,{children:(0,K.jsx)(`p`,{children:`Hover to cancel (or press Esc)`})})]}):(0,K.jsx)(J,{"data-testid":`tool-execution-execute-button`,onClick:o,disabled:r||!i,size:`sm`,className:`lg:size-default pr-1! gap-0`,children:r?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(yF,{className:`mr-2`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:`Executing...`})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ih,{className:`h-4 w-4 sm:mr-2`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:`Execute`}),(0,K.jsx)(`span`,{className:`hidden sm:inline text-[12px] border text-zinc-300 p-1 rounded-full border-zinc-300 dark:text-zinc-600 dark:border-zinc-500 ml-2`,children:`⌘↵`})]})})]})]})})}),(0,K.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-3 sm:px-5 pb-4 pr-3`,children:[e.description&&(0,K.jsxs)(`div`,{className:`relative mb-4`,children:[(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`p`,{ref:E,"data-testid":`tool-execution-description`,className:`text-sm text-gray-600 dark:text-gray-400 leading-relaxed transition-all duration-300 ${!S&&w?`line-clamp-3`:``}`,children:e.description}),w&&!S&&(0,K.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-[1.4em] bg-linear-to-t from-white/95 dark:from-black/95 via-white/55 dark:via-black/55 to-transparent pointer-events-none`})]}),w&&(0,K.jsx)(`div`,{className:`flex justify-end`,children:(0,K.jsx)(`button`,{onClick:()=>C(!S),className:`relative z-10 inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 mt-1 transition-colors`,children:S?(0,K.jsxs)(K.Fragment,{children:[`Show less`,(0,K.jsx)(rh,{className:`h-3 w-3`})]}):(0,K.jsxs)(K.Fragment,{children:[`Show more`,(0,K.jsx)(eh,{className:`h-3 w-3`})]})})})]}),(0,K.jsx)(Ixe,{selectedTool:e,toolArgs:t,onArgChange:a,onBulkPaste:l,autoFilledFields:u,setFields:d,sendEmptyFields:f,onToggleEmpty:p})]}),(0,K.jsx)(iy,{open:g,onOpenChange:_,children:(0,K.jsxs)(oy,{className:`max-w-3xl max-h-[80vh] overflow-y-auto`,children:[(0,K.jsx)(sy,{children:(0,K.jsxs)(cy,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsx)(`span`,{children:`Tool Definition`}),(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:D,className:`h-7 w-7 p-0`,title:`Copy metadata`,children:v?(0,K.jsx)($m,{className:`h-3.5 w-3.5 text-green-600`}):(0,K.jsx)(uh,{className:`h-3.5 w-3.5`})})]})}),(0,K.jsx)(bO,{data:e,filename:`tool-definition-${e.name}-${Date.now()}.json`})]})})]}):(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,K.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400 mb-2`,children:`Select a tool to get started`}),(0,K.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:`Choose a tool from the list to view its details and execute it`})]})}function Lxe({timestamp:e}){let[t,n]=(0,G.useState)(()=>e9(e));return(0,G.useEffect)(()=>{let t=()=>n(e9(e));t();let r=setInterval(t,1e3);return()=>clearInterval(r)},[e]),(0,K.jsx)(`span`,{children:t})}function e9(e){let t=Date.now()-e,n=Math.floor(t/1e3),r=Math.floor(n/60),i=Math.floor(r/60),a=Math.floor(i/24);return n<10?`now`:n<60?`${n}s ago`:r<60?`${r}m ago`:i<24?`${i}h ago`:`${a}d ago`}function t9(e){if(!e?.isError)return null;let t=e.content;if(Array.isArray(t)){let e=t.filter(e=>e.type===`text`).map(e=>e.text).filter(Boolean);if(e.length>0)return e.join(`
|
|
443
|
+
`)}return`An error occurred`}function U7({result:e,isLoading:t,previewMode:n,serverId:r,readResource:i,onTogglePreview:a,onCopy:o,onDownload:s,onFullscreen:c,isCopied:l=!1,selectedResource:u,llmConfig:d}){let f=(0,G.useMemo)(()=>({}),[]),[p,m]=(0,G.useState)(null),h=(0,G.useCallback)(e=>{m(e)},[]),[g,_]=(0,G.useState)(`inline`),v=[],y;if(e?.resourceAnnotations&&(v=Object.keys(e.resourceAnnotations).filter(e=>e.startsWith(`openai/`)),y=e.resourceAnnotations[`openai/outputTemplate`]),e?.result&&`contents`in e.result&&Array.isArray(e.result.contents)&&e.result.contents[0]?._meta){let t=e.result.contents[0]._meta,n=Object.keys(t).filter(e=>e.startsWith(`openai/`));n.length>0&&(v=[...v,...n]),!y&&t[`openai/outputTemplate`]&&(y=t[`openai/outputTemplate`]),!y&&e.uri&&e.uri.startsWith(`ui://widget/`)&&(y=e.uri)}let b=!!(v.length>0&&y&&typeof y==`string`&&r&&i),x=e?.result&&`contents`in e.result&&Array.isArray(e.result.contents)&&e.result.contents[0]?._meta||{},S={...e?.resourceAnnotations,...x},C=(0,G.useMemo)(()=>{let e=S?.[`mcp-use/propsSchema`];if(!e)return[];let t=e.def?.shape;return t?Object.entries(t).filter(([,e])=>{let t=e?.def?.type??e?.type;return t!==`optional`&&t!==`default`}).map(([e])=>e):e.required??[]},[S]),w=$B(S,e?.result),T=e?.result&&`contents`in e.result&&Array.isArray(e.result.contents)&&e.result.contents.some(e=>e.mimeType===`text/html;profile=mcp-app`),E=S?.ui?.resourceUri||x?.ui?.resourceUri||(T?e.uri:void 0),D=(w===`mcp-apps`||T)&&!!E,O=C.length>0&&!p;if(t)return(0,K.jsx)(`div`,{className:`flex absolute left-0 top-0 items-center justify-center w-full h-full`,children:(0,K.jsx)(yF,{className:`size-5`})});if(!e)return(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,K.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400 mb-2`,children:`Select a resource to view its contents`}),(0,K.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:`Choose a resource from the list to see its data`})]});let k=e.error||(e.result?xxe(e.result):null);if(k)return(0,K.jsx)(`div`,{className:`p-4`,children:(0,K.jsxs)(`div`,{className:`bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3`,children:[(0,K.jsx)(`p`,{className:`text-red-800 dark:text-red-300 font-medium`,children:`Error:`}),(0,K.jsx)(`p`,{className:`text-red-700 dark:text-red-400 text-sm`,children:k})]})});let A=e?.result&&`contents`in e.result&&Array.isArray(e.result.contents)&&e.result.contents.some(e=>e.mimeType&&V7(e)),j=A&&e.result&&`contents`in e.result&&Array.isArray(e.result.contents)?e.result.contents.filter(e=>e.mimeType&&V7(e)):[];return(0,K.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,K.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-b border-gray-200 dark:border-zinc-700 flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(oh,{className:`h-3 w-3 text-gray-400`}),(0,K.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:new Date(e.timestamp).toLocaleTimeString()})]}),(()=>{let t=e?.duration??e.result?.duration??e.result?.metrics?.durationMs;return t===void 0?null:(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(ng,{className:`h-3 w-3 text-gray-400`}),(0,K.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[t,`ms`]})]})})(),A&&(0,K.jsx)(Aa,{variant:`outline`,className:`text-xs bg-purple-50 dark:bg-purple-900/20 border-none border-purple-200 dark:border-purple-800/50 text-purple-600 dark:text-purple-400`,children:`MCP UI`}),D&&(0,K.jsx)(Aa,{variant:`outline`,className:`text-xs bg-green-50 dark:bg-green-900/20 border-none border-green-200 dark:border-green-800/50 text-green-600 dark:text-green-400`,children:`MCP Apps`}),b&&(0,K.jsx)(Aa,{variant:`outline`,className:`text-xs bg-blue-50 dark:bg-blue-900/20 border-none border-blue-200 dark:border-blue-800/50 text-blue-600 dark:text-blue-400`,children:`OpenAI Widget`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(D||A||b)&&(0,K.jsxs)(J,{variant:`ghost`,size:`sm`,onClick:a,className:n?``:`text-purple-600 dark:text-purple-400`,children:[n?(0,K.jsx)(sh,{className:`h-4 w-4 mr-1`}):(0,K.jsx)(Qm,{className:`h-4 w-4 mr-1`}),n?`JSON`:b?`Component`:`Preview`]}),(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:o,children:l?(0,K.jsx)($m,{className:`h-4 w-4`}):(0,K.jsx)(uh,{className:`h-4 w-4`})}),(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:s,children:(0,K.jsx)(fh,{className:`h-4 w-4`})}),(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:c,children:(0,K.jsx)(jh,{className:`h-4 w-4`})})]})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto relative`,children:D&&r&&i&&E?n?(0,K.jsxs)(`div`,{className:`flex-1 h-full relative`,"data-testid":`resource-widget-preview`,children:[(0,K.jsx)(`div`,{className:`absolute top-2 right-2 z-10 flex items-center gap-2`,children:(0,K.jsx)(C$,{toolCallId:`resource-${e.timestamp}`,displayMode:g,onDisplayModeChange:_,propsContext:`resource`,resourceUri:e.uri,resourceAnnotations:S,llmConfig:d||null,resource:u||null,onPropsChange:h,requiredProps:C.length>0&&!p?C:void 0})}),O?(0,K.jsx)(`div`,{className:`flex items-center justify-center w-full h-full min-h-[200px] rounded-xl border-2 border-dashed border-gray-300 dark:border-zinc-600 bg-gray-50 dark:bg-zinc-800/50 m-4`,children:(0,K.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 text-center px-6`,children:`This widget requires props, set or generate them in the props debugger`})}):(0,K.jsx)(d$,{serverId:r,toolCallId:`resource-${e.timestamp}`,toolName:e.uri,toolInput:f,toolOutput:e.result,toolMetadata:S,resourceUri:E,readResource:i,className:`w-full h-full relative flex p-4`,customProps:p||void 0,displayMode:g,onDisplayModeChange:_})]}):(0,K.jsx)(`div`,{className:`px-4 pt-4`,"data-testid":`resource-result-json`,children:(0,K.jsx)(bO,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,`-`)}-mcp-apps-${Date.now()}.json`})}):b&&r&&i&&y?n?(0,K.jsx)(`div`,{className:`flex-1 h-full relative`,children:O?(0,K.jsx)(`div`,{className:`flex items-center justify-center w-full h-full min-h-[200px] rounded-xl border-2 border-dashed border-gray-300 dark:border-zinc-600 bg-gray-50 dark:bg-zinc-800/50 m-4`,children:(0,K.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 text-center px-6`,children:`This widget requires props, set or generate them in the props debugger`})}):(0,K.jsx)(T$,{componentUrl:y,toolName:e.uri,toolArgs:{},toolResult:e.result,serverId:r,readResource:i,className:`w-full h-full relative flex p-4`,customProps:p||void 0})}):(0,K.jsx)(`div`,{className:`px-4 pt-4`,"data-testid":`resource-result-json`,children:(0,K.jsx)(bO,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,`-`)}-${Date.now()}.json`})}):A?n?(0,K.jsxs)(`div`,{className:`space-y-0 h-full`,children:[j.map((e,t)=>(0,K.jsx)(`div`,{className:`mx-0 size-full`,children:(0,K.jsx)(`div`,{className:`w-full h-full`,children:(0,K.jsx)(H7,{resource:e,className:`w-full h-full`,customProps:p||void 0})})},`mcp-ui-${e.uri||`resource-${Date.now()}-${Math.random()}`}`)),(()=>{if(e.result&&`contents`in e.result&&Array.isArray(e.result.contents)){let t=e.result.contents.filter(e=>!(e.mimeType&&V7(e)));if(t.length>0)return(0,K.jsx)(`div`,{className:`px-4`,children:(0,K.jsx)(bO,{data:t,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,`-`)}-non-ui-${Date.now()}.json`})})}return null})()]}):(0,K.jsx)(`div`,{className:`px-4 pt-4`,"data-testid":`resource-result-json`,children:(0,K.jsx)(bO,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,`-`)}-mcp-ui-${Date.now()}.json`})}):(0,K.jsx)(`div`,{className:`px-4 pt-4`,"data-testid":`resource-result-json`,children:(0,K.jsx)(bO,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,`-`)}-${Date.now()}.json`})})})]})}function Sxe(e,t){if(!e&&!t)return(0,K.jsx)(bh,{className:`h-5 w-5`});let n=(e||t||``).toLowerCase();return n.includes(`image`)?(0,K.jsx)(vh,{className:`h-5 w-5`}):n.includes(`json`)||n.includes(`javascript`)||n.includes(`typescript`)?(0,K.jsx)(_h,{className:`h-5 w-5`}):n.includes(`html`)||n.includes(`xml`)?(0,K.jsx)(Sh,{className:`h-5 w-5`}):n.includes(`database`)||n.includes(`sql`)?(0,K.jsx)(dh,{className:`h-5 w-5`}):(0,K.jsx)(yh,{className:`h-5 w-5`})}function W7({resources:e,selectedResource:t,onResourceSelect:n,focusedIndex:r}){return e.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,K.jsx)(dh,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,K.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`No resources available`})]}):(0,K.jsx)(`div`,{className:`overflow-y-auto flex-1 overscroll-contain`,children:e.map((e,i)=>{let a=Sxe(e.mimeType,e.uri),o=[e.description,e.mimeType&&(0,K.jsx)(`span`,{className:`font-mono`,children:e.mimeType},`mime`)].filter(Boolean);return(0,K.jsx)(k7,{id:`resource-${e.uri}`,"data-testid":`resource-item-${e.name}`,isSelected:t?.uri===e.uri,isFocused:r===i,icon:a,title:e.name,description:o.length>0?(0,K.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[e.description&&(0,K.jsx)(`span`,{children:e.description}),e.mimeType&&(0,K.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-500 font-mono`,children:e.mimeType})]}):void 0,onClick:()=>n(e)},e.uri)})})}function G7({isSearchExpanded:e,searchQuery:t,filteredResourcesCount:n,onSearchExpand:r,onSearchChange:i,onSearchBlur:a,searchInputRef:o,onRefresh:s,isRefreshing:c=!1}){return(0,K.jsx)(`div`,{className:`flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2`,children:(0,K.jsx)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:e?(0,K.jsx)(uy,{ref:o,placeholder:`Search resources...`,value:t,onChange:e=>i(e.target.value),onBlur:a,className:`h-8 border-gray-300 dark:border-zinc-600`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-medium text-gray-900 dark:text-gray-100`,children:`Resources`}),(0,K.jsx)(Aa,{className:`bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent`,variant:`outline`,children:n}),(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:r,className:`h-8 w-8 p-0`,children:(0,K.jsx)(Vh,{className:`h-4 w-4`})})}),(0,K.jsxs)(Im,{side:`bottom`,className:`flex gap-2`,children:[`Search`,(0,K.jsx)(O7,{children:`F`})]})]}),s&&(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:s,disabled:c,className:`h-8 w-8 p-0`,children:(0,K.jsx)(Rh,{className:`h-4 w-4 ${c?`animate-spin`:``}`})})}),(0,K.jsxs)(Im,{side:`bottom`,className:`flex gap-2`,children:[`Refresh list`,(0,K.jsx)(O7,{children:`R`})]})]})]})})})}function K7({ref:e,resources:t,readResource:n,serverId:r,isConnected:i,mcpServerUrl:a,refreshResources:o}){let[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(null),{selectedResourceUri:d,setSelectedResourceUri:f}=SF(),{llmConfig:p}=p5({mcpServerUrl:a}),[m,h]=(0,G.useState)(null),[g,_]=(0,G.useState)(!1),[v,y]=(0,G.useState)(``),[b]=(0,G.useState)(`resources`),[x,S]=(0,G.useState)(!0),[C,w]=(0,G.useState)(!1),[T,E]=(0,G.useState)(-1),[D,O]=(0,G.useState)(!1),k=(0,G.useRef)(null),A=(0,G.useRef)(null),[j,M]=(0,G.useState)(!1),[N,P]=(0,G.useState)(`list`);(0,G.useEffect)(()=>{let e=()=>{M(window.innerWidth<1024)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,G.useEffect)(()=>{P(l?`detail`:`list`)},[l]),(0,G.useImperativeHandle)(e,()=>({focusSearch:()=>{w(!0),setTimeout(()=>{k.current&&k.current.focus()},0)},blurSearch:()=>{y(``),w(!1),k.current&&k.current.blur()}})),(0,G.useEffect)(()=>{C&&k.current&&k.current.focus()},[C]);let F=(0,G.useCallback)(()=>{v.trim()||w(!1)},[v]),I=(0,G.useCallback)(async()=>{if(o){c(!0);try{await o()}finally{c(!1)}}},[o]),L=(0,G.useMemo)(()=>{if(!v)return t;let e=v.toLowerCase();return t.filter(t=>t.name.toLowerCase().includes(e)||t.description?.toLowerCase().includes(e)||t.uri.toLowerCase().includes(e))},[t,v]),ee=(0,G.useCallback)(async e=>{if(u(e),i){_(!0);let t=Date.now();try{let i=await n(e.uri);Km.getInstance().capture(new Rm({resourceUri:e.uri,serverId:r,success:!0})).catch(()=>{}),h({uri:e.uri,result:i,timestamp:t,resourceAnnotations:{...e.annotations,...e._meta||{}}})}catch(n){Km.getInstance().capture(new Rm({resourceUri:e.uri,serverId:r,success:!1,error:n instanceof Error?n.message:`Unknown error`})).catch(()=>{}),h({uri:e.uri,result:{contents:[],_meta:{}},error:n instanceof Error?n.message:`Unknown error`,timestamp:t,resourceAnnotations:{...e.annotations,...e._meta||{}}})}finally{_(!1)}}},[n,r,i]);(0,G.useEffect)(()=>{E(-1)},[v,b]),(0,G.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.contentEditable===`true`||e.metaKey||e.ctrlKey||e.altKey)return;let n=L;if(e.key===`ArrowDown`)e.preventDefault(),E(e=>{let t=e+1;return t>=n.length?0:t});else if(e.key===`ArrowUp`)e.preventDefault(),E(e=>{let t=e-1;return t<0?n.length-1:t});else if(e.key===`Enter`&&T>=0){e.preventDefault();let t=L[T];t&&ee(t)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[T,L,ee]),(0,G.useEffect)(()=>{if(T>=0){let e=`resource-${L[T]?.uri}`,t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[T,L]),(0,G.useEffect)(()=>{if(d&&t.length>0){let e=t.find(e=>e.uri===d);e&&l?.uri!==e.uri&&(f(null),setTimeout(()=>{ee(e);let t=document.getElementById(`resource-${e.uri}`);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})},100))}},[d,t,l,ee,f]),(0,G.useEffect)(()=>{if(l){let e=t.find(e=>e.uri===l.uri);e&&e!==l&&(e.description!==l.description||e.mimeType!==l.mimeType||e.name!==l.name)&&u(e)}},[t,l]);let te=(0,G.useCallback)(async()=>{if(m)try{await rg(JSON.stringify(m.result,null,2)),O(!0),setTimeout(()=>O(!1),2e3)}catch(e){console.error(`[ResourcesTab] Failed to copy result:`,e)}},[m]),R=(0,G.useCallback)(()=>{if(m)try{let e=new globalThis.Blob([JSON.stringify(m.result,null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`resource-${Date.now()}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}catch(e){console.error(`[ResourcesTab] Failed to download result:`,e)}},[m]),z=(0,G.useCallback)(async()=>{if(A.current)try{document.fullscreenElement?await document.exitFullscreen():await A.current.requestFullscreen()}catch(e){console.error(`[ResourcesTab] Failed to toggle fullscreen:`,e)}},[]);return j?(0,K.jsxs)(`div`,{className:`h-full flex flex-col overflow-hidden relative bg-background`,children:[N!==`list`&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10`,children:[(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>{u(null),P(`list`)},className:`p-0 h-8 w-8`,children:(0,K.jsx)(th,{className:`h-4 w-4`})}),(0,K.jsxs)(`div`,{className:`flex items-center text-sm font-medium`,children:[(0,K.jsx)(`button`,{onClick:()=>{u(null),P(`list`)},className:`text-muted-foreground hover:text-foreground hover:underline cursor-pointer`,children:`Resources`}),N===`detail`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`mx-2 text-muted-foreground`,children:`/`}),(0,K.jsx)(`span`,{className:`text-foreground`,children:`Content`})]})]})]}),(0,K.jsx)(`div`,{className:`flex-1 relative overflow-hidden`,children:(0,K.jsxs)(OP,{initial:!1,mode:`popLayout`,children:[N===`list`&&(0,K.jsxs)(_F.div,{initial:{x:`-100%`},animate:{x:0},exit:{x:`-100%`},transition:{type:`spring`,stiffness:300,damping:30},className:`absolute inset-0 flex flex-col bg-background z-0`,children:[(0,K.jsx)(G7,{activeTab:b,isSearchExpanded:C,searchQuery:v,filteredResourcesCount:L.length,onSearchExpand:()=>w(!0),onSearchChange:y,onSearchBlur:F,onTabSwitch:()=>{},searchInputRef:k,onRefresh:o?I:void 0,isRefreshing:s}),(0,K.jsx)(`div`,{className:`flex flex-col h-full`,children:(0,K.jsx)(W7,{resources:L,selectedResource:l,onResourceSelect:ee,focusedIndex:T})})]},`list`),N===`detail`&&(0,K.jsx)(_F.div,{initial:{x:`100%`},animate:{x:0},exit:{x:`100%`},transition:{type:`spring`,stiffness:300,damping:30},className:`absolute inset-0 bg-white dark:bg-zinc-900 z-10`,children:(0,K.jsx)(`div`,{ref:A,className:`h-full`,children:(0,K.jsx)(U7,{result:m,isLoading:g,previewMode:x,serverId:r,readResource:n,onTogglePreview:()=>S(!x),onCopy:te,onDownload:R,onFullscreen:z,isCopied:D,selectedResource:l,llmConfig:p})})},`detail`)]})})]}):(0,K.jsxs)(T7,{orientation:`horizontal`,className:`h-full`,children:[(0,K.jsx)(E7,{defaultSize:`33%`,children:(0,K.jsxs)(T7,{orientation:`vertical`,className:`h-full border-r dark:border-zinc-700`,children:[(0,K.jsx)(E7,{minSize:`30%`,children:(0,K.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,K.jsx)(G7,{activeTab:b,isSearchExpanded:C,searchQuery:v,filteredResourcesCount:L.length,onSearchExpand:()=>w(!0),onSearchChange:y,onSearchBlur:F,onTabSwitch:()=>{},searchInputRef:k,onRefresh:o?I:void 0,isRefreshing:s}),(0,K.jsx)(W7,{resources:L,selectedResource:l,onResourceSelect:ee,focusedIndex:T})]})}),(0,K.jsx)(D7,{withHandle:!0}),(0,K.jsx)(N7,{serverId:r})]})}),(0,K.jsx)(D7,{}),(0,K.jsx)(E7,{defaultSize:`67%`,children:(0,K.jsx)(`div`,{ref:A,className:`h-full bg-white dark:bg-zinc-900`,children:(0,K.jsx)(U7,{result:m,isLoading:g,previewMode:x,serverId:r,readResource:n,onTogglePreview:()=>S(!x),onCopy:te,onDownload:R,onFullscreen:z,isCopied:D,selectedResource:l,llmConfig:p})})})]})}K7.displayName=`ResourcesTab`;function Cxe({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:r,onSearchExpand:i,onSearchChange:a,onSearchBlur:o,onRejectAll:s,searchInputRef:c}){return(0,K.jsxs)(`div`,{className:`flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2`,children:[(0,K.jsx)(`div`,{className:`flex items-center gap-2 flex-1`,children:e?(0,K.jsx)(uy,{ref:c,placeholder:`Search requests...`,value:t,onChange:e=>a(e.target.value),onBlur:o,className:`h-8 border-gray-300 dark:border-zinc-600`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-medium text-gray-900 dark:text-gray-100`,children:`Sampling`}),(0,K.jsx)(Aa,{className:`bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent`,variant:`outline`,children:n}),(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:i,className:`h-8 w-8 p-0`,children:(0,K.jsx)(Vh,{className:`h-4 w-4`})})}),(0,K.jsxs)(Im,{side:`bottom`,className:`flex gap-2`,children:[`Search`,(0,K.jsx)(O7,{children:`F`})]})]})]})}),(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:s,disabled:r===0,className:`h-8 w-8 p-0`,children:(0,K.jsx)($h,{className:`h-4 w-4`})})}),(0,K.jsx)(Im,{side:`bottom`,children:`Reject all`})]})})]})}function wxe({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:r,formatRelativeTime:i,listRef:a}){return e.length===0?(0,K.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:(0,K.jsx)(nm,{vertical:!0,noBorder:!0,message:`No sampling requests`})}):(0,K.jsx)(`div`,{ref:a,className:`overflow-y-auto flex-1 overscroll-contain`,children:e.map((e,a)=>{let o=e.request.params?.messages?.length||0,s=e.request.params?.maxTokens;return(0,K.jsx)(k7,{id:`sampling-request-${e.id}`,isSelected:t?.id===e.id,isFocused:r===a,title:(0,K.jsxs)(`span`,{className:`flex items-center gap-3`,children:[e.serverName,(0,K.jsx)(`span`,{className:`size-1.5 block rounded-full bg-orange-500`})]}),description:(()=>{let t=i(e.timestamp),n=[];return o>0&&n.push(`${o} message${o>1?`s`:``}`),s&&n.push(`max ${s} tokens`),t+(n.length>0?` | ${n.join(`, `)}`:``)})(),onClick:()=>n(e)},e.id)})})}function Txe({llmConfig:e}){let t=(0,G.useRef)(null);return{generateResponse:(0,G.useCallback)(async({request:n})=>{if(!e)throw Error(`LLM config is not available`);let r=n.params||{},i=r.maxTokens,a=r.temperature;r.modelPreferences;let o=r.messages||[];if(console.log(`[useSamplingLLM] Request structure:`,{hasParams:!!r,messagesCount:o.length,messages:o,params:r}),o.length===0)throw Error(`No messages found in sampling request`);let s=[],{HumanMessage:c,AIMessage:l}=await B(async()=>{let{HumanMessage:e,AIMessage:t}=await import(`./messages-DmWRSzWI.js`);return{HumanMessage:e,AIMessage:t}},[]);for(let e of o){if(!e||!e.role){console.warn(`Skipping invalid message:`,e);continue}let t=Array.isArray(e.content)?e.content[0]:e.content;if(!t){console.warn(`Skipping message with no content:`,e);continue}t.type===`text`&&t.text?e.role===`user`?s.push(new c(t.text)):e.role===`assistant`&&s.push(new l(t.text)):console.warn(`Skipping message with unsupported content type:`,t)}if(s.length===0)throw Error(`No valid messages could be converted. Please ensure messages have 'text' content type.`);if(!t.current||t.current.provider!==e.provider||t.current.model!==e.model||t.current.apiKey!==e.apiKey){let n,r={model:e.model,apiKey:e.apiKey};if(i!==void 0&&(r.maxTokens=i),a===void 0?e.temperature!==void 0&&(r.temperature=e.temperature):r.temperature=a,e.provider===`openai`){let{ChatOpenAI:e}=await B(async()=>{let{ChatOpenAI:e}=await import(`./dist-BG8NAFfu.js`);return{ChatOpenAI:e}},__vite__mapDeps([197,198,3,199,200,201,202,203]));n=new e(r)}else if(e.provider===`anthropic`){let{ChatAnthropic:e}=await B(async()=>{let{ChatAnthropic:e}=await import(`./dist-YxwKnKYL.js`);return{ChatAnthropic:e}},__vite__mapDeps([204,198,3,201,202,203]));n=new e(r)}else if(e.provider===`google`){let{ChatGoogleGenerativeAI:e}=await B(async()=>{let{ChatGoogleGenerativeAI:e}=await import(`./dist-CKth7ANk.js`);return{ChatGoogleGenerativeAI:e}},__vite__mapDeps([205,198,3,199]));n=new e(r)}else throw Error(`Unsupported LLM provider: ${e.provider}`);t.current={instance:n,provider:e.provider,model:e.model,apiKey:e.apiKey}}let u=await t.current.instance.invoke(s);return{role:`assistant`,content:{type:`text`,text:u.content||u.text||``},model:e.model,stopReason:`endTurn`}},[e]),isAvailable:e!==null}}function Exe({request:e,onApprove:t,onReject:r,onClose:i,previewMode:a,onTogglePreview:o,isCopied:s,onCopy:c,onDownload:l,onFullscreen:u,llmConfig:d}){let[f,p]=(0,G.useState)(`manual`),[m,h]=(0,G.useState)(`stub-model`),[g,_]=(0,G.useState)(`endTurn`),[v,y]=(0,G.useState)(`assistant`),[b,x]=(0,G.useState)(`text`),[S,C]=(0,G.useState)(`positive`),[w,T]=(0,G.useState)(``),[E,D]=(0,G.useState)(`image/png`),[O,k]=(0,G.useState)(!1),[A,j]=(0,G.useState)(null),{generateResponse:M,isAvailable:N}=Txe({llmConfig:d});(0,G.useEffect)(()=>{e&&(h(f===`llm`&&d?.model?d.model:`stub-model`),_(`endTurn`),y(`assistant`),x(`text`),C(`positive`),T(``),D(`image/png`),j(null))},[e?.id]),(0,G.useEffect)(()=>{f===`llm`&&d?.model&&h(d.model)},[f,d?.model]);let P=async()=>{if(!e||!N){console.log(`[SamplingRequestDisplay] Cannot generate:`,{hasRequest:!!e,isAvailable:N});return}console.log(`[SamplingRequestDisplay] Starting LLM generation:`,{requestId:e.id,llmConfig:d}),k(!0),j(null);try{let t=await M({request:e.request});console.log(`[SamplingRequestDisplay] LLM generation result:`,{result:t,model:t.model,stopReason:t.stopReason,role:t.role,contentIsArray:Array.isArray(t.content),content:t.content}),h(t.model||d?.model||`stub-model`),_(t.stopReason||`endTurn`),y(t.role||`assistant`);let n=Array.isArray(t.content)?t.content[0]:t.content;console.log(`[SamplingRequestDisplay] Setting content:`,{contentType:n.type,hasText:`text`in n,text:`text`in n?n.text:void 0}),n.type===`text`?(x(`text`),C(n.text||``),console.log(`[SamplingRequestDisplay] Set text content:`,n.text)):n.type===`image`&&(x(`image`),T(n.data||``),D(n.mimeType||`image/png`),console.log(`[SamplingRequestDisplay] Set image content`)),console.log(`[SamplingRequestDisplay] Form state after update:`,{model:m,stopReason:g,role:v,contentType:b,textContent:S})}catch(e){console.error(`[SamplingRequestDisplay] LLM generation error:`,e);let t=e instanceof Error?e.message:`Failed to generate response`;j(t),xv.error(`LLM Generation Failed`,{description:t})}finally{k(!1),console.log(`[SamplingRequestDisplay] Generation complete`)}},F=(0,G.useMemo)(()=>{let e={model:m,stopReason:g,role:v,content:{type:b}};return b===`text`?e.content.text=S:b===`image`&&(e.content.data=w,e.content.mimeType=E),e},[m,g,v,b,S,w,E]),L=()=>{if(!e)return;let r=I.safeParse(F);if(!r.success){xv.error(`Invalid response`,{description:`Validation failed: ${r.error.message}`});return}t(e.id,r.data),i(),B(()=>import(`./react-Cg35ZZKt.js`).then(e=>n(e.default,1)).then(t=>{let n=xv(t.createElement(`div`,{className:`space-y-3`},t.createElement(`div`,null,t.createElement(`strong`,null,`Sampling Response Sent`),t.createElement(`p`,{className:`text-sm text-muted-foreground mt-1`},`The tool will continue executing.`)),t.createElement(`div`,{className:`flex gap-2`},t.createElement(`button`,{"data-testid":`sampling-view-tool-result`,className:`px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90`,onClick:()=>{let t=new globalThis.CustomEvent(`navigate-to-tool-result`,{detail:{toolName:e.toolName}});window.dispatchEvent(t),xv.dismiss(n)}},`View Tool Result`))),{duration:5e3})}),[])},ee=()=>{e&&(r(e.id,`User rejected sampling request`),i())};return e?(0,K.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b dark:border-zinc-700`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`h3`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:e.serverName}),(0,K.jsx)(`span`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:new Date(e.timestamp).toLocaleString()})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:c,className:`h-8 w-8 p-0`,children:s?(0,K.jsx)($m,{className:`h-4 w-4 text-green-600`}):(0,K.jsx)(uh,{className:`h-4 w-4`})})}),(0,K.jsx)(Im,{children:`Copy request`})]}),(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:l,className:`h-8 w-8 p-0`,children:(0,K.jsx)(fh,{className:`h-4 w-4`})})}),(0,K.jsx)(Im,{children:`Download request`})]}),(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:u,className:`h-8 w-8 p-0`,children:(0,K.jsx)(Ah,{className:`h-4 w-4`})})}),(0,K.jsx)(Im,{children:`Fullscreen`})]}),(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:i,className:`h-8 w-8 p-0`,children:(0,K.jsx)(tg,{className:`h-4 w-4`})})]})]}),(0,K.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-6`,children:[(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`Request`}),(0,K.jsx)(`div`,{className:`bg-muted rounded-lg p-3 max-h-64 overflow-auto`,children:(0,K.jsx)(bO,{data:e.request})})]}),(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`Response`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(py,{htmlFor:`responseMode-${e.id}`,className:`text-xs text-gray-500 dark:text-gray-400`,children:`Mode:`}),(0,K.jsxs)(ab,{value:f,onValueChange:e=>p(e),children:[(0,K.jsx)(sb,{id:`responseMode-${e.id}`,className:`w-32 h-8 text-xs`,"data-testid":`sampling-response-mode-select`,children:(0,K.jsx)(ob,{})}),(0,K.jsxs)(cb,{children:[(0,K.jsx)(lb,{value:`manual`,"data-testid":`sampling-response-mode-manual`,children:`Manual`}),(0,K.jsx)(lb,{value:`llm`,"data-testid":`sampling-response-mode-llm`,children:`LLM`})]})]})]})]}),f===`llm`&&(0,K.jsxs)(`div`,{className:`space-y-2 p-3 bg-muted rounded-lg`,children:[N?(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(J,{onClick:P,disabled:O,size:`sm`,className:`flex items-center gap-2`,"data-testid":`sampling-generate-llm-button`,children:O?(0,K.jsxs)(`span`,{"data-testid":`sampling-generating`,className:`flex items-center gap-2`,children:[(0,K.jsx)(kh,{className:`h-4 w-4 animate-spin`}),`Generating...`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(qh,{className:`h-4 w-4`}),`Generate with LLM`]})}),(0,K.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[`Using `,d?.provider,` (`,d?.model,`)`]})]}):(0,K.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:`LLM not configured. Please configure LLM in the Chat tab.`}),A&&(0,K.jsx)(`div`,{className:`text-xs text-red-600 dark:text-red-400`,"data-testid":`sampling-generation-error`,children:A})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(py,{htmlFor:`model-${e.id}`,children:`Model`}),(0,K.jsx)(uy,{id:`model-${e.id}`,value:m,onChange:e=>h(e.target.value),placeholder:`stub-model`,disabled:f===`llm`&&O,"data-testid":`sampling-model-input`})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(py,{htmlFor:`stopReason-${e.id}`,children:`Stop Reason`}),(0,K.jsx)(uy,{id:`stopReason-${e.id}`,value:g,onChange:e=>_(e.target.value),placeholder:`endTurn`,disabled:f===`llm`&&O,"data-testid":`sampling-stop-reason-input`})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(py,{htmlFor:`role-${e.id}`,children:`Role`}),(0,K.jsxs)(ab,{value:v,onValueChange:e=>y(e),disabled:f===`llm`&&O,children:[(0,K.jsx)(sb,{id:`role-${e.id}`,"data-testid":`sampling-role-select`,children:(0,K.jsx)(ob,{})}),(0,K.jsxs)(cb,{children:[(0,K.jsx)(lb,{value:`assistant`,children:`assistant`}),(0,K.jsx)(lb,{value:`user`,children:`user`})]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(py,{htmlFor:`contentType-${e.id}`,children:`Content Type`}),(0,K.jsxs)(ab,{value:b,onValueChange:e=>x(e),disabled:f===`llm`&&O,children:[(0,K.jsx)(sb,{id:`contentType-${e.id}`,"data-testid":`sampling-content-type-select`,children:(0,K.jsx)(ob,{})}),(0,K.jsxs)(cb,{children:[(0,K.jsx)(lb,{value:`text`,children:`text`}),(0,K.jsx)(lb,{value:`image`,children:`image`})]})]})]}),b===`text`&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(py,{htmlFor:`text-${e.id}`,children:`Text Content`}),(0,K.jsx)(tL,{id:`text-${e.id}`,value:S,onChange:e=>C(e.target.value),placeholder:`Enter response text...`,rows:6,disabled:f===`llm`&&O,"data-testid":`sampling-text-content`})]}),b===`image`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(py,{htmlFor:`imageData-${e.id}`,children:`Base64 Image Data`}),(0,K.jsx)(tL,{id:`imageData-${e.id}`,value:w,onChange:e=>T(e.target.value),placeholder:`Base64 encoded image data...`,rows:4,disabled:f===`llm`&&O})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(py,{htmlFor:`mimeType-${e.id}`,children:`MIME Type`}),(0,K.jsx)(uy,{id:`mimeType-${e.id}`,value:E,onChange:e=>D(e.target.value),placeholder:`image/png`,disabled:f===`llm`&&O})]})]})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 p-4 border-t dark:border-zinc-700`,children:[(0,K.jsx)(J,{onClick:L,className:`flex-1`,disabled:f===`llm`&&O,"data-testid":`sampling-approve-button`,children:`Approve`}),(0,K.jsx)(J,{onClick:ee,variant:`outline`,className:`flex-1`,disabled:f===`llm`&&O,"data-testid":`sampling-reject-button`,children:`Reject`})]})]}):(0,K.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:(0,K.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Select a sampling request to view details`})})}var Dxe={model:`stub-model`,stopReason:`endTurn`,role:`assistant`,content:{type:`text`,text:`positive`}};function Oxe({requestId:e,serverName:t,onViewDetails:n,onApprove:r,onDeny:i}){return(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`strong`,{children:`Sampling Request Received`}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:[`New request from `,t]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`button`,{"data-testid":`sampling-toast-view-details`,className:`px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground`,onClick:e=>{e.stopPropagation(),n()},children:`View Details`}),(0,K.jsx)(`button`,{"data-testid":`sampling-toast-approve`,className:`px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground`,onClick:e=>{e.stopPropagation(),r(Dxe)},children:`Approve`}),(0,K.jsx)(`button`,{"data-testid":`sampling-toast-deny`,className:`px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground`,onClick:e=>{e.stopPropagation(),i()},children:`Deny`})]})]})}function kxe({pendingRequests:e,onApprove:t,onReject:n,serverId:r,isConnected:i,mcpServerUrl:a}){let{selectedSamplingRequestId:o,setSelectedSamplingRequestId:s}=SF(),{llmConfig:c}=p5({mcpServerUrl:a}),[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(-1),[h,g]=(0,G.useState)(!0),[_,v]=(0,G.useState)(!1),[y,b]=(0,G.useState)(!0),[x,S]=(0,G.useState)(!1),C=(0,G.useRef)(null),w=(0,G.useRef)(null),T=(0,G.useRef)(null),E=(0,G.useRef)(!1);(0,G.useEffect)(()=>{if(console.log(`[SamplingTab] Auto-selection check:`,{selectedSamplingRequestId:o,pendingRequestsCount:e.length,currentSelectedId:l?.id}),o&&e.length>0){let t=e.find(e=>e.id===o);console.log(`[SamplingTab] Found request for auto-selection:`,!!t,t?.id),t&&(console.log(`[SamplingTab] Auto-selecting request:`,t.id),s(null),u(t),setTimeout(()=>{let e=document.getElementById(`sampling-request-${t.id}`);console.log(`[SamplingTab] Scrolling to element:`,!!e),e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},100))}},[o,e,s]),(0,G.useEffect)(()=>{let t=t=>{let n=t.detail.requestId;console.log(`[SamplingTab] Custom navigate event received:`,n);let r=e.find(e=>e.id===n);r&&(console.log(`[SamplingTab] Selecting request from event:`,n),u(r),setTimeout(()=>{let e=document.getElementById(`sampling-request-${n}`);e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},200))};return window.addEventListener(`navigate-to-sampling`,t),()=>window.removeEventListener(`navigate-to-sampling`,t)},[e]),(0,G.useEffect)(()=>{h&&e.length>0&&C.current&&!E.current&&(C.current.scrollTop=0)},[e.length,h]),(0,G.useEffect)(()=>{let e=C.current;if(!e)return;let t=()=>{e.scrollTop>0&&(E.current=!0,g(!1))};return e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)},[]),(0,G.useEffect)(()=>{e.length===0&&(E.current=!1,g(!0))},[e.length]),(0,G.useEffect)(()=>{_&&T.current&&T.current.focus()},[_]);let D=(0,G.useCallback)(()=>{d.trim()||v(!1)},[d]),O=(0,G.useMemo)(()=>{if(!d.trim())return e;let t=d.toLowerCase();return e.filter(e=>e.serverName.toLowerCase().includes(t)||JSON.stringify(e.request||{}).toLowerCase().includes(t))},[e,d]);(0,G.useEffect)(()=>{m(-1)},[d]),(0,G.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.contentEditable===`true`||e.metaKey||e.ctrlKey||e.altKey)return;let n=O;if(e.key===`ArrowDown`)e.preventDefault(),m(e=>{let t=e+1;return t>=n.length?0:t});else if(e.key===`ArrowUp`)e.preventDefault(),m(e=>{let t=e-1;return t<0?n.length-1:t});else if(e.key===`Enter`&&p>=0){e.preventDefault();let t=O[p];t&&k(t)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[p,O]),(0,G.useEffect)(()=>{if(p>=0){let e=`sampling-request-${O[p]?.id}`,t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[p,O]);let k=(0,G.useCallback)(e=>{u(e)},[]),A=(0,G.useCallback)(()=>{window.confirm(`Are you sure you want to reject all sampling requests? This cannot be undone.`)&&(e.forEach(e=>{n(e.id,`User rejected all requests`)}),u(null))},[e,n]),j=(0,G.useCallback)(async()=>{if(l)try{await rg(JSON.stringify({id:l.id,serverName:l.serverName,timestamp:l.timestamp,request:l.request},null,2)),S(!0),setTimeout(()=>S(!1),2e3)}catch(e){console.error(`[SamplingTab] Failed to copy request:`,e)}},[l]),M=(0,G.useCallback)(()=>{if(l)try{let e=new globalThis.Blob([JSON.stringify({id:l.id,serverName:l.serverName,timestamp:l.timestamp,request:l.request},null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`sampling-request-${Date.now()}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}catch(e){console.error(`[SamplingTab] Failed to download request:`,e)}},[l]),N=(0,G.useCallback)(async()=>{if(w.current)try{document.fullscreenElement?await document.exitFullscreen():await w.current.requestFullscreen()}catch(e){console.error(`[SamplingTab] Failed to toggle fullscreen:`,e)}},[]);return i?(0,K.jsxs)(T7,{orientation:`horizontal`,className:`h-full`,children:[(0,K.jsx)(E7,{defaultSize:40,minSize:30,children:(0,K.jsx)(T7,{orientation:`vertical`,className:`h-full border-r dark:border-zinc-700`,children:(0,K.jsxs)(E7,{defaultSize:75,minSize:30,children:[(0,K.jsx)(Cxe,{isSearchExpanded:_,searchQuery:d,filteredRequestsCount:O.length,requestsCount:e.length,onSearchExpand:()=>v(!0),onSearchChange:f,onSearchBlur:D,onRejectAll:A,searchInputRef:T}),(0,K.jsx)(`div`,{className:`flex flex-col h-full`,children:(0,K.jsx)(wxe,{requests:O,selectedRequest:l,onRequestSelect:k,focusedIndex:p,formatRelativeTime:j7,listRef:C})})]})})}),(0,K.jsx)(D7,{}),(0,K.jsx)(E7,{defaultSize:60,minSize:40,children:(0,K.jsx)(`div`,{ref:w,className:`h-full bg-white dark:bg-zinc-900`,children:(0,K.jsx)(Exe,{request:l,onApprove:t,onReject:n,onClose:()=>u(null),previewMode:y,onTogglePreview:()=>b(!y),isCopied:x,onCopy:j,onDownload:M,onFullscreen:N,llmConfig:c})})})]}):(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,K.jsx)(wh,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,K.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Not connected to server`})]})}function q7({savedRequests:e,selectedRequest:t,onLoadRequest:n,onDeleteRequest:r,focusedIndex:i}){if(e.length===0)return(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,K.jsx)(dh,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,K.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400 mb-2`,children:`No saved requests yet`}),(0,K.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:`Execute a tool and click Save to store requests`})]});let a=(e,t)=>{e.stopPropagation(),t()};return(0,K.jsx)(`div`,{className:`overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain`,children:e.map((e,o)=>(0,K.jsxs)(`div`,{className:`relative group`,children:[(0,K.jsx)(k7,{id:`saved-${e.id}`,isSelected:t?.id===e.id,isFocused:i===o,icon:(0,K.jsx)(Th,{className:`h-4 w-4`}),title:e.name,description:e.toolName,metadata:(0,K.jsx)(`div`,{className:`flex flex-col gap-1`,children:(0,K.jsx)(`span`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:new Date(e.savedAt).toLocaleString()})}),onClick:()=>n(e)}),(0,K.jsx)(`div`,{className:`absolute top-1/2 right-2 -translate-y-1/2 opacity-0 group-hover:opacity-100 transition-opacity z-10`,children:(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`secondary`,size:`sm`,onClick:t=>a(t,()=>r(e.id)),className:`h-8 w-8 p-0`,children:(0,K.jsx)($h,{className:`h-4 w-4`})})}),(0,K.jsx)(Im,{children:(0,K.jsx)(`p`,{children:`Delete saved request`})})]})})]},e.id))})}function J7({isOpen:e,requestName:t,defaultPlaceholder:n,onRequestNameChange:r,onSave:i,onCancel:a}){return e?(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,onClick:a,children:(0,K.jsxs)(`div`,{className:`bg-white dark:bg-zinc-800 rounded-lg p-6 w-[400px] shadow-xl border border-gray-200 dark:border-zinc-700`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold mb-4 text-gray-900 dark:text-gray-100`,children:`Save Request`}),(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(py,{htmlFor:`request-name`,children:`Request Name (optional)`}),(0,K.jsx)(uy,{id:`request-name`,value:t,onChange:e=>r(e.target.value),placeholder:n,className:`mt-2`,onKeyDown:e=>{e.key===`Enter`&&i()},autoFocus:!0})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)(J,{variant:`outline`,onClick:a,children:`Cancel`}),(0,K.jsxs)(J,{onClick:i,children:[(0,K.jsx)(Bh,{className:`h-4 w-4 mr-2`}),`Save`]})]})]})]})}):null}function Y7(e,t){if(!e?.$ref)return e;let n=e.$ref;if(!n.startsWith(`#/`))return e;let r=n.substring(2).split(`/`),i=t;for(let t of r)if(i&&typeof i==`object`&&t in i)i=i[t];else return e;return i}function Axe(e,t){if(e?.anyOf&&Array.isArray(e.anyOf)){let n=e.anyOf.find(e=>Y7(e,t)?.type!==`null`);if(n)return{...Y7(n,t),nullable:!0}}return e}function X7(e,t){let n=Axe(e||{},t);return n=Y7(n,t),n}function Z7(e,t){let n=X7(e,t);if(typeof n.type==`string`)return n.type;if(Array.isArray(n.type)){let e=n.type.find(e=>e!==`null`);return typeof e==`string`?e:void 0}}function jxe(e){let t=e?.enum;return Array.isArray(t)&&t.every(e=>typeof e==`string`)?t:null}function Q7(e){let t=e.trim().toLowerCase();return[`true`,`1`,`yes`,`on`].includes(t)?!0:[`false`,`0`,`no`,`off`].includes(t)?!1:e}function Mxe(e,t){if(t===`number`||t===`integer`){let t=e.trim();if(!t)return e;let n=Number(t);return Number.isFinite(n)?n:e}return t===`boolean`?Q7(e):e}function Nxe(e,t){if(e===void 0)return e;if(t===`object`||t===`array`){if(typeof e==`string`)try{return JSON.parse(e)}catch{return e}return e}if(t===`number`||t===`integer`){if(typeof e==`number`)return e;if(typeof e==`string`){let t=e.trim();if(!t)return e;let n=Number(t);return Number.isFinite(n)?n:e}return e}return t===`boolean`?typeof e==`boolean`?e:typeof e==`string`?Q7(e):e:e}function Pxe(e){let t=``,n=0,r=!1,i=!1;for(;n<e.length;){let a=e[n];if(i){t+=a,i=!1,n++;continue}if(a===`\\`){i=!0,t+=a,n++;continue}if(a==="`"){r?(t+=`"`,r=!1):(t+=`"`,r=!0),n++;continue}if(r&&a===`"`){t+=`\\"`,n++;continue}t+=a,n++}return t}function Fxe(e){if(!e||typeof e!=`string`)return null;let t=e.trim();if(!t.startsWith(`{`))return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return e}catch{try{let e=Pxe(t),n=JSON.parse(e);if(n&&typeof n==`object`&&!Array.isArray(n))return n}catch{return null}}return null}function Ixe({selectedTool:e,toolArgs:t,onArgChange:n,onBulkPaste:r,autoFilledFields:i,setFields:a,sendEmptyFields:o,onToggleEmpty:s}){let c=e?.inputSchema?.properties||{},l=e?.inputSchema?.required||[],u=Object.keys(c).length>0,d=async(e,t)=>{r&&await r(e.clipboardData.getData(`text`),t)&&e.preventDefault()};return u?(0,K.jsx)(`div`,{className:`space-y-4`,children:Object.entries(c).map(([r,c])=>{let u=X7(c,e?.inputSchema||{}),f=jxe(u),p=u.type===`string`&&f!==null,m=u;m.required=l.includes(r);let h=t[r],g=``;h!=null&&(g=typeof h==`string`?h:typeof h==`object`&&h?JSON.stringify(h,null,2):String(h));let _=m.type===`object`||m.type===`array`,v=_?m.type===`array`?`array`:`object`:`string`,y=a?.has(r)??!0,b=s&&(m.type===`string`||_);return _?(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsxs)(py,{htmlFor:r,className:`text-sm font-medium`,children:[r,m?.required&&(0,K.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),b&&s&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:v===`array`?`Send empty array explicitly`:`Send empty object explicitly`}),(0,K.jsx)(_b,{checked:o?.has(r)??!1,onCheckedChange:e=>s(r,v,e),"aria-label":v===`array`?`Send empty array`:`Send empty object`,title:v===`array`?`Send empty array []`:`Send empty object {}`})]})]}),(0,K.jsx)(tL,{id:r,"data-testid":`tool-param-${r}`,value:g,onChange:e=>n(r,e.target.value),onPaste:e=>d(e,r),placeholder:m?.description||`Enter ${r}`,disabled:o?.has(r)??!1,className:`min-h-[100px] ${y?``:`opacity-70`} ${i?.has(r)?`animate-pulse ring-2 ring-green-500 dark:ring-green-400`:``}`}),m?.description&&(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:m.description})]},r):p&&f?(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(py,{htmlFor:r,className:`text-sm font-medium`,children:[r,m.required&&(0,K.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),(0,K.jsxs)(ab,{value:String(t[r]||``),onValueChange:e=>n(r,e),children:[(0,K.jsx)(sb,{id:r,className:`w-full ${y?``:`opacity-70`}`,"data-testid":`tool-param-${r}`,children:(0,K.jsx)(ob,{placeholder:m.description||`Select an option`})}),(0,K.jsx)(cb,{children:f.map((e,t)=>(0,K.jsx)(lb,{value:e,children:m.enumNames?.[t]||e},e))})]}),m.description&&(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:m.description})]},r):(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsxs)(py,{htmlFor:r,className:`text-sm font-medium`,children:[r,m?.required&&(0,K.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),b&&s&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`Send empty string`}),(0,K.jsx)(_b,{checked:o?.has(r)??!1,onCheckedChange:e=>s(r,`string`,e),"aria-label":`Send empty string`,title:`Send empty string`})]})]}),(0,K.jsx)(uy,{id:r,"data-testid":`tool-param-${r}`,value:g,onChange:e=>n(r,e.target.value),onPaste:e=>d(e,r),placeholder:m?.description||`Enter ${r}`,disabled:o?.has(r)??!1,className:`${y?``:`opacity-70`} ${i?.has(r)?`animate-pulse ring-2 ring-green-500 dark:ring-green-400`:``}`}),m?.description&&(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:m.description})]},r)})}):(0,K.jsx)(`div`,{className:`flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm`,children:`No parameters required`})}function $7({selectedTool:e,toolArgs:t,payloadToSend:n,isExecuting:r,isConnected:i,onArgChange:a,onExecute:o,onSave:s,onCancel:c,onBulkPaste:l,autoFilledFields:u,setFields:d,sendEmptyFields:f,onToggleEmpty:p}){let[m,h]=(0,G.useState)(!1),[g,_]=(0,G.useState)(!1),[v,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(!1),[S,C]=(0,G.useState)(!1),[w,T]=(0,G.useState)(!1),E=(0,G.useRef)(null);(0,G.useEffect)(()=>{if(E.current&&e?.description){let e=E.current,t=parseFloat(getComputedStyle(e).lineHeight),n=e.scrollHeight;T(Math.round(n/t)>3),C(!1)}},[e?.description]);let D=async()=>{if(e)try{await rg(JSON.stringify(e,null,2)),y(!0),setTimeout(()=>y(!1),2e3)}catch{}},O=async()=>{if(e)try{let e=n??t;await rg(JSON.stringify(e,null,2)),x(!0),setTimeout(()=>x(!1),2e3)}catch{}};return(0,G.useEffect)(()=>{let t=t=>{(t.metaKey||t.ctrlKey)&&t.key===`Enter`&&e&&!r&&i&&(t.preventDefault(),o()),t.key===`Escape`&&r&&c&&(t.preventDefault(),c())};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,r,i,o,c]),e?(0,K.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,K.jsx)(`div`,{className:`shrink-0 p-3 sm:p-5 pt-3 sm:pt-4 pb-4 sm:pr-4`,children:(0,K.jsx)(`div`,{children:(0,K.jsxs)(`div`,{className:`flex flex-row items-center justify-between mb-0 gap-2`,children:[(0,K.jsx)(`h3`,{className:`text-base sm:text-lg font-semibold`,"data-testid":`tool-execution-title`,children:e.name}),(0,K.jsxs)(`div`,{className:`flex gap-2 shrink-0`,children:[(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsxs)(J,{"data-testid":`tool-execution-metadata-button`,variant:g?`default`:`outline`,onClick:()=>_(!g),disabled:r,size:`sm`,className:`lg:size-default gap-2`,title:`View tool metadata`,children:[(0,K.jsx)(sh,{className:`h-4 w-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:`Metadata`})]})}),(0,K.jsx)(Im,{children:(0,K.jsx)(`p`,{children:`View tool definition metadata`})})]}),(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsxs)(J,{"data-testid":`tool-execution-copy-payload-button`,variant:`outline`,onClick:O,disabled:r,size:`sm`,className:`lg:size-default gap-2`,title:`Copy payload as JSON`,children:[b?(0,K.jsx)($m,{className:`h-4 w-4 text-green-600`}):(0,K.jsx)(uh,{className:`h-4 w-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:b?`Copied!`:`Payload`})]})}),(0,K.jsx)(Im,{children:(0,K.jsx)(`p`,{children:`Copy payload as JSON`})})]}),(0,K.jsxs)(J,{"data-testid":`tool-execution-save-button`,variant:`outline`,onClick:s,disabled:r,size:`sm`,className:`lg:size-default gap-2`,children:[(0,K.jsx)(Bh,{className:`h-4 w-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:`Save`})]}),r&&c?(0,K.jsxs)(Pm,{open:m?void 0:!1,children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(`div`,{onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),className:`relative`,children:(0,K.jsx)(J,{"data-testid":`tool-execution-cancel-button`,onClick:c,variant:m?`destructive`:`default`,size:`sm`,className:`lg:size-default gap-2 transition-all`,children:m?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(tg,{className:`h-4 w-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:`Cancel`}),(0,K.jsx)(`span`,{className:`hidden sm:inline text-[12px] border border-current p-1 rounded-full ml-2`,children:`Esc`})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(yF,{className:`mr-2`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:`Executing...`})]})})})}),(0,K.jsx)(Im,{children:(0,K.jsx)(`p`,{children:`Hover to cancel (or press Esc)`})})]}):(0,K.jsx)(J,{"data-testid":`tool-execution-execute-button`,onClick:o,disabled:r||!i,size:`sm`,className:`lg:size-default pr-1! gap-0`,children:r?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(yF,{className:`mr-2`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:`Executing...`})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ih,{className:`h-4 w-4 sm:mr-2`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:`Execute`}),(0,K.jsx)(`span`,{className:`hidden sm:inline text-[12px] border text-zinc-300 p-1 rounded-full border-zinc-300 dark:text-zinc-600 dark:border-zinc-500 ml-2`,children:`⌘↵`})]})})]})]})})}),(0,K.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-3 sm:px-5 pb-4 pr-3`,children:[e.description&&(0,K.jsxs)(`div`,{className:`relative mb-4`,children:[(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`p`,{ref:E,"data-testid":`tool-execution-description`,className:`text-sm text-gray-600 dark:text-gray-400 leading-relaxed transition-all duration-300 ${!S&&w?`line-clamp-3`:``}`,children:e.description}),w&&!S&&(0,K.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-[1.4em] bg-linear-to-t from-white/95 dark:from-black/95 via-white/55 dark:via-black/55 to-transparent pointer-events-none`})]}),w&&(0,K.jsx)(`div`,{className:`flex justify-end`,children:(0,K.jsx)(`button`,{onClick:()=>C(!S),className:`relative z-10 inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 mt-1 transition-colors`,children:S?(0,K.jsxs)(K.Fragment,{children:[`Show less`,(0,K.jsx)(rh,{className:`h-3 w-3`})]}):(0,K.jsxs)(K.Fragment,{children:[`Show more`,(0,K.jsx)(eh,{className:`h-3 w-3`})]})})})]}),(0,K.jsx)(Ixe,{selectedTool:e,toolArgs:t,onArgChange:a,onBulkPaste:l,autoFilledFields:u,setFields:d,sendEmptyFields:f,onToggleEmpty:p})]}),(0,K.jsx)(iy,{open:g,onOpenChange:_,children:(0,K.jsxs)(oy,{className:`max-w-3xl max-h-[80vh] overflow-y-auto`,children:[(0,K.jsx)(sy,{children:(0,K.jsxs)(cy,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsx)(`span`,{children:`Tool Definition`}),(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:D,className:`h-7 w-7 p-0`,title:`Copy metadata`,children:v?(0,K.jsx)($m,{className:`h-3.5 w-3.5 text-green-600`}):(0,K.jsx)(uh,{className:`h-3.5 w-3.5`})})]})}),(0,K.jsx)(bO,{data:e,filename:`tool-definition-${e.name}-${Date.now()}.json`})]})})]}):(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,K.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400 mb-2`,children:`Select a tool to get started`}),(0,K.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:`Choose a tool from the list to view its details and execute it`})]})}function Lxe({timestamp:e}){let[t,n]=(0,G.useState)(()=>e9(e));return(0,G.useEffect)(()=>{let t=()=>n(e9(e));t();let r=setInterval(t,1e3);return()=>clearInterval(r)},[e]),(0,K.jsx)(`span`,{children:t})}function e9(e){let t=Date.now()-e,n=Math.floor(t/1e3),r=Math.floor(n/60),i=Math.floor(r/60),a=Math.floor(i/24);return n<10?`now`:n<60?`${n}s ago`:r<60?`${r}m ago`:i<24?`${i}h ago`:`${a}d ago`}function t9(e){if(!e?.isError)return null;let t=e.content;if(Array.isArray(t)){let e=t.filter(e=>e.type===`text`).map(e=>e.text).filter(Boolean);if(e.length>0)return e.join(`
|
|
444
444
|
`)}return`An error occurred`}function Rxe(e){try{return JSON.parse(e),!0}catch{return!1}}function zxe({content:e}){let[t,n]=(0,G.useState)(new Set),r=(0,G.useCallback)(e=>{n(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]);return!Array.isArray(e)||e.length===0?(0,K.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:`No content`}):(0,K.jsx)(`div`,{className:`space-y-4`,children:e.map((e,n)=>{if(e.type===`text`){let i=e.text||``,a=t.has(n),o=Rxe(i),s=o?(()=>{try{return JSON.parse(i)}catch{return null}})():null;return(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsxs)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400`,children:[`Text Content`,a?` (formatted)`:``]}),o&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>r(n),className:`text-xs text-blue-600 dark:text-blue-400 hover:underline`,"data-testid":`tool-result-format-toggle-${n}`,children:a?`Show as text`:`Try to format`})]}),a&&s!==null?(0,K.jsx)(bO,{data:s,filename:`content-${n}.json`}):(0,K.jsx)(`div`,{className:`bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 font-mono text-sm whitespace-pre-wrap break-words`,"data-testid":`tool-execution-results-text-content`,children:i})]},n)}if(e.type===`image`)return(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400`,children:`Image Content`}),(0,K.jsxs)(`div`,{className:`bg-gray-50 dark:bg-zinc-900 rounded-lg p-3`,children:[(0,K.jsx)(`img`,{src:`data:${e.mimeType||`image/png`};base64,${e.data}`,alt:`Result`,className:`max-w-full rounded`,"data-testid":`tool-execution-results-image-content`}),e.annotations&&(0,K.jsx)(`div`,{className:`mt-2 text-xs text-gray-500 dark:text-gray-400`,children:(0,K.jsx)(bO,{data:e.annotations,filename:`image-annotations-${n}.json`,"data-testid":`tool-execution-results-image-annotations`})})]})]},n);if(e.type===`audio`)return(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400`,children:`Audio Content`}),(0,K.jsxs)(`div`,{className:`bg-gray-50 dark:bg-zinc-900 rounded-lg p-3`,children:[(0,K.jsx)(`audio`,{controls:!0,src:`data:${e.mimeType||`audio/wav`};base64,${e.data}`,className:`w-full`,"data-testid":`tool-execution-results-audio-content`}),e.annotations&&(0,K.jsx)(`div`,{className:`mt-2 text-xs text-gray-500 dark:text-gray-400`,children:(0,K.jsx)(bO,{data:e.annotations,filename:`audio-annotations-${n}.json`,"data-testid":`tool-execution-results-audio-annotations`})})]})]},n);if(e.type===`resource_link`)return(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400`,children:`Resource Link`}),(0,K.jsxs)(`div`,{className:`bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2`,children:[(0,K.jsxs)(`div`,{className:`font-mono text-sm break-all`,children:[(0,K.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:`URI:`}),` `,e.uri]}),e.name&&(0,K.jsxs)(`div`,{className:`text-sm`,children:[(0,K.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:`Name:`}),` `,e.name]}),e.description&&(0,K.jsxs)(`div`,{className:`text-sm`,children:[(0,K.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:`Description:`}),` `,e.description]}),e.mimeType&&(0,K.jsxs)(`div`,{className:`text-sm`,children:[(0,K.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:`MIME Type:`}),` `,e.mimeType]}),e.annotations&&(0,K.jsxs)(`div`,{className:`mt-2`,children:[(0,K.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-1`,children:`Annotations:`}),(0,K.jsx)(bO,{data:e.annotations,filename:`resource-link-annotations-${n}.json`,"data-testid":`tool-execution-results-resource-link-annotations`})]})]})]},n);if(e.type===`resource`){let t=e.resource||{};return(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400`,children:`Embedded Resource`}),(0,K.jsxs)(`div`,{className:`bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2`,children:[(0,K.jsxs)(`div`,{className:`font-mono text-sm break-all`,"data-testid":`tool-execution-results-resource-uri`,children:[(0,K.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:`URI:`}),` `,t.uri]}),t.mimeType&&(0,K.jsxs)(`div`,{className:`text-sm`,children:[(0,K.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,"data-testid":`tool-execution-results-mime-type`,children:`MIME Type:`}),` `,t.mimeType]}),t.text&&(0,K.jsxs)(`div`,{"data-testid":`tool-execution-results-resource-text-content`,children:[(0,K.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-1`,children:`Content:`}),(0,K.jsx)(`div`,{className:`bg-white dark:bg-black rounded p-2 font-mono text-sm whitespace-pre-wrap break-words max-h-60 overflow-y-auto`,children:t.text})]}),t.blob&&(0,K.jsxs)(`div`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:[`[Binary content: `,t.blob.length||0,` bytes]`]}),t.annotations&&(0,K.jsxs)(`div`,{className:`mt-2`,children:[(0,K.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-1`,children:`Annotations:`}),(0,K.jsx)(bO,{data:t.annotations,filename:`resource-annotations-${n}.json`,"data-testid":`tool-execution-results-resource-annotations`})]})]})]},n)}return(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400`,children:[`Unknown Content Type: `,e.type||`N/A`]}),(0,K.jsx)(bO,{data:e,filename:`content-${n}.json`,"data-testid":`tool-execution-results-unknown-content`})]},n)})})}function n9({results:e,copiedResult:t,serverId:n,readResource:r,onCopy:i,onMaximize:a,isMaximized:o=!1,onRerunTool:s}){let[c,l]=(0,G.useState)(0),[u,d]=(0,G.useState)(!0),[f,p]=(0,G.useState)(null),[m,h]=(0,G.useState)(`inline`),[g,_]=(0,G.useState)(null),v=(0,G.useRef)(!1),y=e[0],b=y?e.filter(e=>e.toolName===y.toolName):[],x=b[c]||b[0],S=e.findIndex(e=>e===x),C=(x?x.error||t9(x.result):null)??(x==null?``:JSON.stringify(x.result,null,2));(0,G.useEffect)(()=>{b.length>0&&c>=b.length&&l(0)},[b.length,c]),(0,G.useEffect)(()=>{v.current=!1,p(null)},[y?.toolName]);let w=(0,G.useMemo)(()=>x?.args,[x?.timestamp,c]),T=(0,G.useMemo)(()=>x?.result,[x?.timestamp,x?.duration,c]),E=(0,G.useCallback)(e=>r(e),[r]),D=(0,G.useCallback)(e=>{let t=e.filter(e=>e.type===`text`&&`text`in e).map(e=>e.text).join(`
|
|
445
445
|
`),n=e.filter(e=>e.type===`image`).length,r=e.filter(e=>e.type===`resource`).length,i=[n>0&&`${n} image${n>1?`s`:``}`,r>0&&`${r} resource${r>1?`s`:``}`].filter(Boolean).join(`, `);xv.info(`Widget follow-up`,{description:[t,i].filter(Boolean).join(` — `),duration:5e3})},[]),{playground:O}=XB(),k=(0,G.useMemo)(()=>x?$B(x.toolMeta,x.result):null,[x]),A=(0,G.useMemo)(()=>x?QB(x.toolMeta):!1,[x]),j=(0,G.useMemo)(()=>k?k===`both`?O.selectedProtocol?O.selectedProtocol:`mcp-apps`:k:null,[k,O.selectedProtocol]),M=(0,G.useMemo)(()=>x?A?eV(`mcp-apps`,x.toolMeta):x.toolMeta?.ui?.resourceUri:null,[x,A]),N=(0,G.useMemo)(()=>(j===`mcp-apps`||A)&&!!M,[j,A,M]),P=(0,G.useMemo)(()=>x?A?eV(`chatgpt-app`,x.toolMeta):x.toolMeta?.[`openai/outputTemplate`]:null,[x,A]),F=(0,G.useMemo)(()=>!!((j===`chatgpt-app`||A)&&P&&typeof P==`string`&&x?.appsSdkResource),[j,A,P,x]),I=P,L=(0,G.useMemo)(()=>x?.result?.content||[],[x]),ee=(0,G.useMemo)(()=>L.filter(e=>e.type===`resource`&&V7(e.resource)),[L]),te=ee.length>0,R=(0,G.useMemo)(()=>I||M||ee[0]?.resource?.uri||null,[I,M,ee]),z=(0,G.useMemo)(()=>!!(L&&L.length>0||x?.result?.structuredContent),[L,x]),ne=(0,G.useMemo)(()=>!N&&!te&&!F&&z,[N,te,F,z]),re=(0,G.useMemo)(()=>{let e=[];return(N||A&&M)&&e.push({mode:`mcp-apps`,label:`Component (MCP Apps)`}),(F||A&&P)&&e.push({mode:`chatgpt-app`,label:`Component (Apps SDK)`}),te&&e.push({mode:`mcp-ui`,label:`Component (MCP-UI)`}),e.push({mode:`json`,label:`Raw JSON`}),e},[F,N,te,A,P,M]);return(0,G.useEffect)(()=>{if(re.length===0)return;let e=f&&re.some(e=>e.mode===f),t=re.find(e=>e.mode!==`json`);if(t){let n=v.current;if(v.current=!0,!f||!e||f===`json`&&!n){p(t.mode);return}}else (!f||!e)&&p(`json`)},[re,f]),e.length===0?(0,K.jsx)(`div`,{className:`flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700`,children:(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto h-full`,children:(0,K.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,K.jsx)(`div`,{className:`text-center`,children:(0,K.jsx)(nm,{vertical:!0,noBorder:!0,message:`No Results yet`})})})})}):(0,K.jsxs)(`div`,{className:`relative flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700`,children:[(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto h-full`,children:(0,K.jsxs)(`div`,{className:`space-y-0 flex flex-col flex-1 h-full`,children:[(0,K.jsxs)(`div`,{className:`sticky top-0 z-40 flex items-center gap-2 px-4 pt-2 backdrop-blur-xs bg-white/50 dark:bg-black/50 ${N||te||F||ne?`border-b border-gray-200 dark:border-zinc-600 pb-2`:``}`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium hidden sm:block`,children:`Response`}),x.duration!==void 0&&(0,K.jsxs)(`div`,{className:`hidden sm:flex items-center gap-1`,children:[(0,K.jsx)(ng,{className:`h-3 w-3 text-gray-400`}),(0,K.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[x.duration,`ms`]})]}),(F||N||te)&&(0,K.jsx)(`div`,{className:`flex items-center gap-4 sm:ml-4`,children:(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:re.map((e,t)=>(0,K.jsxs)(G.Fragment,{children:[t>0&&(0,K.jsx)(`span`,{className:`text-xs text-zinc-400`,children:`|`}),(0,K.jsx)(`button`,{"data-testid":`tool-result-view-${e.mode}`,onClick:()=>p(e.mode),className:`text-xs font-medium ${f===e.mode?`text-black dark:text-white`:`text-zinc-500 dark:text-zinc-400`}`,children:e.label})]},e.mode))})}),ne&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 sm:ml-4`,children:[(0,K.jsx)(`button`,{onClick:()=>d(!0),className:`text-xs font-medium ${u?`text-black dark:text-white`:`text-zinc-500 dark:text-zinc-400`}`,children:`Formatted`}),(0,K.jsx)(`span`,{className:`text-xs text-zinc-400`,children:`|`}),(0,K.jsx)(`button`,{onClick:()=>d(!1),className:`text-xs font-medium ${u?`text-zinc-500 dark:text-zinc-400`:`text-black dark:text-white`}`,children:`Raw`})]}),(0,K.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[o&&s&&(0,K.jsxs)(J,{"data-testid":`tool-result-rerun`,variant:`ghost`,size:`sm`,onClick:s,title:`Re-run with same arguments`,children:[(0,K.jsx)(Ih,{className:`h-4 w-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline ml-1`,children:`Re-run`})]}),(N||F||te)&&a&&(0,K.jsx)(J,{"data-testid":`tool-result-maximize`,variant:`ghost`,size:`sm`,onClick:a,title:o?`Restore`:`Maximize`,children:o?(0,K.jsx)(Nh,{className:`h-4 w-4`}):(0,K.jsx)(jh,{className:`h-4 w-4`})}),b.length>1&&(0,K.jsxs)(ab,{value:c.toString(),onValueChange:e=>l(parseInt(e)),children:[(0,K.jsx)(sb,{size:`sm`,className:`w-[140px] h-8 text-xs`,children:(0,K.jsx)(ob,{children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(Th,{className:`h-3 w-3`}),(0,K.jsx)(Lxe,{timestamp:x.timestamp})]})})}),(0,K.jsx)(cb,{children:b.map((e,t)=>(0,K.jsx)(lb,{value:t.toString(),children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Th,{className:`h-3 w-3`}),(0,K.jsx)(`span`,{children:e9(e.timestamp)}),(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`(`,new Date(e.timestamp).toLocaleTimeString(),`)`]})]})},t))})]}),(0,K.jsx)(J,{"data-testid":`tool-result-copy-${S}`,variant:`ghost`,size:`sm`,onClick:()=>i(S,C),children:t===S?(0,K.jsx)($m,{className:`h-4 w-4`}):(0,K.jsx)(uh,{className:`h-4 w-4`})})]})]}),(()=>{let e=x.error||t9(x.result);return e?(0,K.jsxs)(`div`,{className:`bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3 mx-4`,children:[(0,K.jsx)(`p`,{className:`text-red-800 dark:text-red-300 font-medium`,children:`Error:`}),(0,K.jsx)(`p`,{className:`text-red-700 dark:text-red-400 text-sm`,children:e})]}):(()=>{if(!f)return(0,K.jsx)(`div`,{className:`flex items-center justify-center w-full h-[200px]`,children:(0,K.jsx)(yF,{className:`size-5`})});switch(f){case`chatgpt-app`:{if(!F||!x.appsSdkResource)return(0,K.jsx)(`div`,{className:`px-4 pt-4`,children:(0,K.jsx)(`div`,{className:`bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3`,children:(0,K.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:`Apps SDK resource not available`})})});let e=x.appsSdkResource;return e.isLoading?(0,K.jsx)(`div`,{className:`flex items-center justify-center w-full h-[200px]`,children:(0,K.jsx)(yF,{className:`size-5`})}):e.error?(0,K.jsxs)(`div`,{className:`bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3 mx-4`,children:[(0,K.jsx)(`p`,{className:`text-red-800 dark:text-red-300 font-medium`,children:`Resource Error:`}),(0,K.jsx)(`p`,{className:`text-red-700 dark:text-red-400 text-sm`,children:e.error})]}):(0,K.jsx)(`div`,{className:`flex-1`,children:(0,K.jsx)(T$,{componentUrl:e.uri,toolName:x.toolName,toolArgs:w,toolResult:T,serverId:n,readResource:E,className:`w-full h-full relative p-4`,invoking:x.toolMeta?.[`openai/toolInvocation/invoking`],invoked:x.toolMeta?.[`openai/toolInvocation/invoked`]},`openai-${x.timestamp}`)})}case`mcp-apps`:return!N||!M?(0,K.jsx)(`div`,{className:`px-4 pt-4`,children:(0,K.jsx)(`div`,{className:`bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3`,children:(0,K.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:`MCP Apps resource not available`})})}):(0,K.jsxs)(`div`,{className:`flex-1 relative`,children:[(0,K.jsx)(`div`,{className:`absolute top-2 right-2 z-30 flex items-center gap-2`,children:(0,K.jsx)(C$,{toolCallId:`tool-${x.timestamp}`,displayMode:m,onDisplayModeChange:h,propsContext:`tool`,resourceUri:M,toolInput:x.args,resourceAnnotations:x.toolMeta,llmConfig:null,resource:null,onPropsChange:_})}),(0,K.jsx)(d$,{serverId:n,invoking:x.toolMeta?.[`openai/toolInvocation/invoking`],invoked:x.toolMeta?.[`openai/toolInvocation/invoked`],toolCallId:`tool-${x.timestamp}`,toolName:x.toolName,toolInput:w,toolOutput:T,toolMetadata:x.toolMeta,resourceUri:M,readResource:E,className:`w-full h-full relative p-4`,customProps:g||void 0,displayMode:m,onDisplayModeChange:h,onSendFollowUp:D,onRerun:s},`mcp-apps-${x.timestamp}`)]});case`mcp-ui`:return te?(0,K.jsxs)(`div`,{className:`space-y-0 h-full`,children:[ee.map((e,t)=>(0,K.jsx)(`div`,{className:`mx-0 size-full`,children:(0,K.jsx)(H7,{resource:e.resource,onUIAction:e=>{},className:`w-full h-full relative`})},t)),L.filter(e=>!(e.type===`resource`&&V7(e.resource))).length>0&&(0,K.jsx)(`div`,{className:`px-4`,children:(0,K.jsx)(bO,{data:L.filter(e=>!(e.type===`resource`&&V7(e.resource))),filename:`tool-result-${x.toolName}-non-ui-${Date.now()}.json`})})]}):(0,K.jsx)(`div`,{className:`px-4 pt-4`,children:(0,K.jsx)(`div`,{className:`bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3`,children:(0,K.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:`MCP-UI resource not available`})})});case`json`:if(ne&&u){let e=x.result?.structuredContent;return(0,K.jsxs)(`div`,{className:`px-4 pt-4 space-y-4`,"data-testid":`tool-execution-results-content`,children:[e&&(0,K.jsxs)(`div`,{className:`space-y-2`,"data-testid":`tool-execution-results-structured-content`,children:[(0,K.jsx)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400`,children:`Structured Content`}),(0,K.jsx)(bO,{data:e,filename:`structured-content-${x.toolName}-${Date.now()}.json`})]}),L&&L.length>0&&(0,K.jsx)(zxe,{content:L}),!e&&(!L||L.length===0)&&(0,K.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-gray-400`,"data-testid":`tool-execution-results-no-content`,children:`No content to display`})]})}return(0,K.jsx)(`div`,{className:`px-4 pt-4`,children:(0,K.jsx)(bO,{data:x.result,filename:`tool-result-${x.toolName}-${Date.now()}.json`})});default:return null}})()})()]})}),R&&(f===`chatgpt-app`||f===`mcp-apps`||f===`mcp-ui`)&&(0,K.jsx)(`div`,{className:`absolute bottom-0 left-1/2 -translate-x-1/2 z-40 pointer-events-none`,children:(0,K.jsx)(`span`,{className:`text-[11px] bg-gray-200 dark:bg-zinc-800 text-gray-500 dark:text-gray-400 px-3 py-0.5 rounded-t-xl font-mono max-w-[320px] truncate block`,children:R})})]})}function r9({tools:e,selectedTool:t,onToolSelect:n,focusedIndex:r}){if(e.length===0)return(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,K.jsx)(eg,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,K.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`No tools available`})]});let i=e.some(e=>e.inputSchema?.properties&&Object.keys(e.inputSchema.properties).length>0);return(0,K.jsx)(`div`,{className:`overflow-y-auto flex-1 overscroll-contain`,children:e.map((e,a)=>{let o=e._meta,s=$B(o,void 0),c=e.inputSchema?.properties,l=c?Object.keys(c).length:0,u=i&&l>0&&(0,K.jsxs)(Aa,{variant:`outline`,className:`text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400`,children:[l,` params`]}),d=s===`mcp-apps`||s===`chatgpt-app`||s===`both`||u?(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(s===`mcp-apps`||s===`both`)&&(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(`span`,{className:`inline-flex`,children:(0,K.jsx)(Hle,{className:`h-3.5 w-3.5`})})}),(0,K.jsx)(Im,{children:(0,K.jsx)(`p`,{children:`MCP-APP`})})]}),(s===`chatgpt-app`||s===`both`)&&(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(`span`,{className:`inline-flex`,children:(0,K.jsx)(Ule,{className:`h-3.5 w-3.5`})})}),(0,K.jsx)(Im,{children:(0,K.jsx)(`p`,{children:`Apps SDK`})})]}),u]}):void 0;return(0,K.jsx)(k7,{id:`tool-${e.name}`,"data-testid":`tool-item-${e.name}`,isSelected:t?.name===e.name,isFocused:r===a,icon:(0,K.jsx)(eg,{className:`h-4 w-4`}),title:e.name,description:e.description,metadata:d,onClick:()=>n(e)},e.name)})})}function i9({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredToolsCount:r,savedRequestsCount:i,onSearchExpand:a,onSearchChange:o,onSearchBlur:s,onTabSwitch:c,searchInputRef:l,onRefresh:u,isRefreshing:d}){return(0,K.jsx)(M7,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:`tools`,secondaryTabName:`saved`,primaryTabTitle:`Tools`,secondaryTabTitle:`Saved`,primaryCount:r,secondaryCount:i,primaryIcon:eg,secondaryIcon:dh,searchPlaceholder:`Search tools...`,onSearchExpand:a,onSearchChange:o,onSearchBlur:s,onTabSwitch:c,searchInputRef:l,onRefresh:u,isRefreshing:d})}var a9=`AlertDialog`,[Bxe,Vxe]=Pa(a9,[Ov]),o9=Ov(),s9=e=>{let{__scopeAlertDialog:t,...n}=e,r=o9(t);return(0,K.jsx)(Xv,{...r,...n,modal:!0})};s9.displayName=a9;var Hxe=`AlertDialogTrigger`,Uxe=G.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=o9(n);return(0,K.jsx)(Zv,{...i,...r,ref:t})});Uxe.displayName=Hxe;var Wxe=`AlertDialogPortal`,c9=e=>{let{__scopeAlertDialog:t,...n}=e,r=o9(t);return(0,K.jsx)(Qv,{...r,...n})};c9.displayName=Wxe;var Gxe=`AlertDialogOverlay`,l9=G.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=o9(n);return(0,K.jsx)($v,{...i,...r,ref:t})});l9.displayName=Gxe;var u9=`AlertDialogContent`,[Kxe,qxe]=Bxe(u9),Jxe=Ga(`AlertDialogContent`),d9=G.forwardRef((e,t)=>{let{__scopeAlertDialog:n,children:r,...i}=e,a=o9(n),o=G.useRef(null),s=Br(t,o),c=G.useRef(null);return(0,K.jsx)(tne,{contentName:u9,titleName:f9,docsSlug:`alert-dialog`,children:(0,K.jsx)(Kxe,{scope:n,cancelRef:c,children:(0,K.jsxs)(ey,{role:`alertdialog`,...a,...i,ref:s,onOpenAutoFocus:Ma(i.onOpenAutoFocus,e=>{e.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,K.jsx)(Jxe,{children:r}),(0,K.jsx)(Xxe,{contentRef:o})]})})})});d9.displayName=u9;var f9=`AlertDialogTitle`,p9=G.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=o9(n);return(0,K.jsx)(ty,{...i,...r,ref:t})});p9.displayName=f9;var m9=`AlertDialogDescription`,h9=G.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=o9(n);return(0,K.jsx)(ny,{...i,...r,ref:t})});h9.displayName=m9;var Yxe=`AlertDialogAction`,g9=G.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=o9(n);return(0,K.jsx)(ry,{...i,...r,ref:t})});g9.displayName=Yxe;var _9=`AlertDialogCancel`,v9=G.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,{cancelRef:i}=qxe(_9,n),a=o9(n),o=Br(t,i);return(0,K.jsx)(ry,{...a,...r,ref:o})});v9.displayName=_9;var Xxe=({contentRef:e})=>{let t=`\`${u9}\` requires a description for the component to be accessible for screen reader users.
|
|
446
446
|
|
|
@@ -462,4 +462,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/alert-
|
|
|
462
462
|
<pre>${JSON.stringify(t.result,null,2)}</pre>
|
|
463
463
|
</body>
|
|
464
464
|
</html>
|
|
465
|
-
`),e.document.close())}},[x]),Ae=(0,G.useCallback)(()=>{l&&(ee(``),I(!0))},[l]),je=(0,G.useCallback)(()=>{if(!l)return;let e={id:`${Date.now()}-${Math.random()}`,name:L.trim()||`${l.name} - ${new Date().toLocaleString()}`,toolName:l.name,args:we,savedAt:Date.now(),serverId:l._serverId,serverName:l._serverName};H([...N,e]),Km.getInstance().capture(new Tee({toolName:l.name,serverId:i})).catch(()=>{}),I(!1),ee(``)},[l,L,we,N,H,i]),Me=(0,G.useCallback)(e=>{H(N.filter(t=>t.id!==e)),d?.id===e&&f(null)},[N,H,d]);return ie?(0,K.jsxs)(`div`,{className:`h-full flex flex-col overflow-hidden relative bg-background`,children:[oe!==`list`&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10`,children:[(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>{oe===`response`?se(`detail`):(u(null),se(`list`))},className:`p-0 h-8 w-8`,children:(0,K.jsx)(th,{className:`h-4 w-4`})}),(0,K.jsxs)(`div`,{className:`flex items-center text-sm font-medium`,children:[(0,K.jsx)(`button`,{onClick:()=>{u(null),se(`list`)},className:`text-muted-foreground hover:text-foreground hover:underline cursor-pointer`,children:`Tools`}),oe===`detail`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`mx-2 text-muted-foreground`,children:`/`}),(0,K.jsx)(`button`,{onClick:()=>{se(`response`)},className:oe===`detail`?`text-foreground hover:underline`:oe===`response`?`text-muted-foreground hover:text-foreground hover:underline cursor-pointer`:`text-muted-foreground`,children:`Execute`})]}),oe===`response`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`mx-2 text-muted-foreground`,children:`/`}),(0,K.jsx)(`span`,{className:`text-foreground`,children:`Response`})]})]})]}),(0,K.jsx)(`div`,{className:`flex-1 relative overflow-hidden`,children:(0,K.jsxs)(OP,{initial:!1,mode:`popLayout`,children:[oe===`list`&&(0,K.jsxs)(_F.div,{initial:{x:`-100%`},animate:{x:0},exit:{x:`-100%`},transition:{type:`spring`,stiffness:300,damping:30},className:`absolute inset-0 flex flex-col bg-background z-0`,children:[(0,K.jsx)(i9,{activeTab:j,isSearchExpanded:te,searchQuery:k,filteredToolsCount:he.length,savedRequestsCount:N.length,onSearchExpand:()=>R(!0),onSearchChange:A,onSearchBlur:ve,onTabSwitch:()=>M(j===`tools`?`saved`:`tools`),searchInputRef:re,onRefresh:o?ye:void 0,isRefreshing:s}),j===`tools`?(0,K.jsx)(r9,{tools:he,selectedTool:l,onToolSelect:ge,focusedIndex:z}):(0,K.jsx)(q7,{savedRequests:N,selectedRequest:d,onLoadRequest:_e,onDeleteRequest:Me,focusedIndex:z})]},`list`),oe===`detail`&&(0,K.jsx)(_F.div,{initial:{x:`100%`},animate:{x:0},exit:{x:`-100%`},transition:{type:`spring`,stiffness:300,damping:30},className:`absolute inset-0 bg-background z-10`,children:(0,K.jsx)($7,{selectedTool:l,toolArgs:h,payloadToSend:we,isExecuting:C,isConnected:a,onArgChange:U,onExecute:Te,onSave:Ae,onBulkPaste:xe,autoFilledFields:B,setFields:_,sendEmptyFields:y,onToggleEmpty:be})},`detail`),oe===`response`&&(0,K.jsx)(_F.div,{initial:{x:`100%`},animate:{x:0},exit:{x:`100%`},transition:{type:`spring`,stiffness:300,damping:30},className:`absolute inset-0 bg-background z-20`,children:(0,K.jsx)(n9,{results:Oe,copiedResult:T,serverId:i,readResource:r,onCopy:Ee,onDelete:De,onFullscreen:ke,onRerunTool:Te})},`response`)]})}),(0,K.jsx)(J7,{isOpen:F,requestName:L,defaultPlaceholder:`${l?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ee,onSave:je,onCancel:()=>I(!1)}),(0,K.jsx)(y9,{open:ue.open,onOpenChange:e=>{e||Ce()},children:(0,K.jsxs)(b9,{children:[(0,K.jsxs)(x9,{children:[(0,K.jsx)(C9,{children:`Auto-fill fields from pasted object?`}),(0,K.jsxs)(w9,{children:[ue.fieldsToUpdate.length>0&&(0,K.jsxs)(`div`,{className:`mb-3`,children:[(0,K.jsx)(`p`,{className:`font-medium mb-2`,children:`The following fields will be updated:`}),(0,K.jsx)(`ul`,{className:`text-sm space-y-1 max-h-[200px] overflow-y-auto`,children:ue.fieldsToUpdate.map(({key:e,oldValue:t,newValue:n})=>(0,K.jsxs)(`li`,{className:`font-mono`,children:[(0,K.jsxs)(`span`,{className:`font-semibold`,children:[e,`:`]}),` `,(0,K.jsx)(`span`,{className:`text-red-600 dark:text-red-400 line-through`,children:typeof t==`object`?JSON.stringify(t).substring(0,30)+`...`:String(t).substring(0,30)}),` `,`→`,` `,(0,K.jsx)(`span`,{className:`text-green-600 dark:text-green-400`,children:typeof n==`string`&&n.length>30?n.substring(0,30)+`...`:String(n).substring(0,30)})]},e))})]}),ue.newFields.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-medium mb-1`,children:`New fields to be filled:`}),(0,K.jsx)(`p`,{className:`text-sm font-mono`,children:ue.newFields.join(`, `)})]})]})]}),(0,K.jsxs)(S9,{children:[(0,K.jsx)(E9,{onClick:Ce,children:`Cancel`}),(0,K.jsx)(T9,{onClick:Se,children:`Auto-fill`})]})]})})]}):(0,K.jsxs)(T7,{orientation:`horizontal`,className:`h-full`,children:[(0,K.jsx)(E7,{id:`left-panel`,defaultSize:`33%`,minSize:`20%`,collapsible:!0,className:`flex flex-col h-full relative`,panelRef:pe,children:(0,K.jsxs)(T7,{orientation:`vertical`,className:`h-full border-r dark:border-zinc-700`,children:[(0,K.jsx)(E7,{minSize:`30%`,children:(0,K.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,K.jsx)(i9,{activeTab:j,isSearchExpanded:te,searchQuery:k,filteredToolsCount:he.length,savedRequestsCount:N.length,onSearchExpand:()=>R(!0),onSearchChange:A,onSearchBlur:ve,onTabSwitch:()=>M(j===`tools`?`saved`:`tools`),searchInputRef:re,onRefresh:o?ye:void 0,isRefreshing:s}),j===`tools`?(0,K.jsx)(r9,{tools:he,selectedTool:l,onToolSelect:ge,focusedIndex:z}):(0,K.jsx)(q7,{savedRequests:N,selectedRequest:d,onLoadRequest:_e,onDeleteRequest:Me,focusedIndex:z})]})}),(0,K.jsx)(D7,{withHandle:!0}),(0,K.jsx)(N7,{serverId:i})]})}),(0,K.jsx)(D7,{withHandle:!0}),(0,K.jsx)(E7,{defaultSize:`67%`,children:(0,K.jsxs)(T7,{orientation:`vertical`,children:[(0,K.jsx)(E7,{defaultSize:`40%`,collapsible:!0,panelRef:me,children:(0,K.jsx)($7,{selectedTool:l,toolArgs:h,payloadToSend:we,isExecuting:C,isConnected:a,onArgChange:U,onExecute:Te,onSave:Ae,onCancel:()=>{D&&D.abort()},onBulkPaste:xe,autoFilledFields:B,setFields:_,sendEmptyFields:y,onToggleEmpty:be})}),(0,K.jsx)(D7,{withHandle:!0}),(0,K.jsx)(E7,{defaultSize:`60%`,children:(0,K.jsx)(`div`,{className:`flex flex-col h-full`,children:(0,K.jsx)(n9,{results:Oe,copiedResult:T,serverId:i,readResource:r,onCopy:Ee,onDelete:De,onFullscreen:ke,onMaximize:V,isMaximized:ce,onRerunTool:Te})})})]})}),(0,K.jsx)(J7,{isOpen:F,requestName:L,defaultPlaceholder:`${l?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ee,onSave:je,onCancel:()=>I(!1)}),(0,K.jsx)(y9,{open:ue.open,onOpenChange:e=>{e||Ce()},children:(0,K.jsxs)(b9,{children:[(0,K.jsxs)(x9,{children:[(0,K.jsx)(C9,{children:`Auto-fill fields from pasted object?`}),(0,K.jsxs)(w9,{children:[ue.fieldsToUpdate.length>0&&(0,K.jsxs)(`div`,{className:`mb-3`,children:[(0,K.jsx)(`p`,{className:`font-medium mb-2`,children:`The following fields will be updated:`}),(0,K.jsx)(`ul`,{className:`text-sm space-y-1 max-h-[200px] overflow-y-auto`,children:ue.fieldsToUpdate.map(({key:e,oldValue:t,newValue:n})=>(0,K.jsxs)(`li`,{className:`font-mono`,children:[(0,K.jsxs)(`span`,{className:`font-semibold`,children:[e,`:`]}),` `,(0,K.jsx)(`span`,{className:`text-red-600 dark:text-red-400 line-through`,children:typeof t==`object`?JSON.stringify(t).substring(0,30)+`...`:String(t).substring(0,30)}),` `,`→`,` `,(0,K.jsx)(`span`,{className:`text-green-600 dark:text-green-400`,children:typeof n==`string`&&n.length>30?n.substring(0,30)+`...`:String(n).substring(0,30)})]},e))})]}),ue.newFields.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-medium mb-1`,children:`New fields to be filled:`}),(0,K.jsx)(`p`,{className:`text-sm font-mono`,children:ue.newFields.join(`, `)})]})]})]}),(0,K.jsxs)(S9,{children:[(0,K.jsx)(E9,{onClick:Ce,children:`Cancel`}),(0,K.jsx)(T9,{onClick:Se,children:`Auto-fill`})]})]})})]})}O9.displayName=`ToolsTab`;function sSe({selectedServer:e,activeTab:t,toolsSearchRef:n,promptsSearchRef:r,resourcesSearchRef:i,children:a}){let{embeddedConfig:o}=SF();if(!e&&o.forceConnected)return o.chatApiUrl?(0,K.jsx)(m5,{connection:{id:`force-connected`,url:``,name:``,state:`ready`,tools:[],prompts:[],resources:[]},isConnected:!0,prompts:[],serverId:`force-connected`,callPrompt:async()=>({messages:[]}),readResource:async()=>({contents:[]}),useClientSide:!1,chatApiUrl:o.chatApiUrl,managedLlmConfig:o.managedLlmConfig??{provider:`anthropic`,model:`server-managed`,apiKey:`server-managed`},hideTitle:o.chatHideTitle,hideModelBadge:o.chatHideModelBadge??!0,hideServerUrl:o.chatHideServerUrl??!0,clearButtonLabel:o.chatClearButtonLabel,clearButtonHideIcon:o.chatClearButtonHideIcon,clearButtonHideShortcut:o.chatClearButtonHideShortcut,clearButtonVariant:o.chatClearButtonVariant,chatQuickQuestions:o.chatQuickQuestions,chatFollowups:o.chatFollowups,hideClearButton:o.chatHideClearButton,hideToolSelector:o.chatHideToolSelector,enableKeyboardShortcuts:!1},`chat-force-connected`):(0,K.jsx)(K.Fragment,{children:a});if(!e)return(0,K.jsx)(K.Fragment,{children:a});let s=e=>o.visibleTabs?o.visibleTabs.includes(e):!0;return(0,K.jsxs)(K.Fragment,{children:[s(`tools`)&&(0,K.jsx)(`div`,{style:{display:t===`tools`?`block`:`none`},className:`h-full`,children:(0,K.jsx)(O9,{ref:n,tools:e.tools,callTool:e.callTool,readResource:e.readResource,serverId:e.id,isConnected:e.state===`ready`,refreshTools:e.refreshTools},`tools-${e.id}-${e.state}`)}),s(`prompts`)&&(0,K.jsx)(`div`,{style:{display:t===`prompts`?`block`:`none`},className:`h-full`,children:(0,K.jsx)(B7,{ref:r,prompts:e.prompts,callPrompt:(t,n)=>e.getPrompt(t,n?Object.fromEntries(Object.entries(n).map(([e,t])=>[e,typeof t==`string`?t:String(t??``)])):void 0),serverId:e.id,isConnected:e.state===`ready`,refreshPrompts:e.refreshPrompts},`prompts-${e.id}-${e.state}`)}),s(`resources`)&&(0,K.jsx)(`div`,{style:{display:t===`resources`?`block`:`none`},className:`h-full`,children:(0,K.jsx)(K7,{ref:i,resources:e.resources,readResource:e.readResource,serverId:e.id,isConnected:e.state===`ready`,mcpServerUrl:e.url||``,refreshResources:e.refreshResources},`resources-${e.id}-${e.state}`)}),s(`chat`)&&(0,K.jsx)(`div`,{style:{display:t===`chat`?`block`:`none`},className:`h-full`,children:(0,K.jsx)(m5,{connection:e,isConnected:o.forceConnected||e.state===`ready`,prompts:e.prompts,serverId:e.id,callPrompt:e.getPrompt,readResource:e.readResource,useClientSide:!o.chatApiUrl,chatApiUrl:o.chatApiUrl,managedLlmConfig:o.managedLlmConfig??(o.chatApiUrl?{provider:`anthropic`,model:`server-managed`,apiKey:`server-managed`}:void 0),hideTitle:o.chatHideTitle,hideModelBadge:o.chatHideModelBadge??!!o.chatApiUrl,hideServerUrl:o.chatHideServerUrl??!!o.chatApiUrl,clearButtonLabel:o.chatClearButtonLabel,clearButtonHideIcon:o.chatClearButtonHideIcon,clearButtonHideShortcut:o.chatClearButtonHideShortcut,clearButtonVariant:o.chatClearButtonVariant,chatQuickQuestions:o.chatQuickQuestions,chatFollowups:o.chatFollowups,hideClearButton:o.chatHideClearButton,hideToolSelector:o.chatHideToolSelector},`chat-${e.id}-${e.state}`)}),s(`sampling`)&&(0,K.jsx)(`div`,{style:{display:t===`sampling`?`block`:`none`},className:`h-full`,children:(0,K.jsx)(kxe,{pendingRequests:e.pendingSamplingRequests,onApprove:e.approveSampling,onReject:e.rejectSampling,serverId:e.id,isConnected:e.state===`ready`,mcpServerUrl:e.url},`sampling-${e.id}-${e.state}`)}),s(`elicitation`)&&(0,K.jsx)(`div`,{style:{display:t===`elicitation`?`block`:`none`},className:`h-full`,children:(0,K.jsx)(cxe,{pendingRequests:e.pendingElicitationRequests,onApprove:e.approveElicitation,onReject:e.rejectElicitation,serverId:e.id,isConnected:e.state===`ready`},`elicitation-${e.id}-${e.state}`)}),s(`notifications`)&&(0,K.jsx)(`div`,{style:{display:t===`notifications`?`block`:`none`},className:`h-full`,children:(0,K.jsx)(fxe,{notifications:e.notifications,unreadCount:e.unreadNotificationCount,markNotificationRead:e.markNotificationRead,markAllNotificationsRead:e.markAllNotificationsRead,clearNotifications:e.clearNotifications,serverId:e.id,isConnected:e.state===`ready`},`notifications-${e.id}-${e.state}`)}),![`tools`,`prompts`,`resources`,`chat`,`sampling`,`elicitation`,`notifications`].includes(t)&&(0,K.jsx)(K.Fragment,{children:a})]})}function k9({className:e}){return(0,K.jsxs)(`svg`,{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`,className:e,children:[(0,K.jsx)(`path`,{d:`M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4`}),(0,K.jsx)(`path`,{d:`M9 18c-4.51 2-5-2-7-2`})]})}var A9=G.createContext(void 0);function j9(){let e=G.use(A9);if(!e)throw Error(`useTabs must be used within a TabsProvider`);return e}var M9=G.createContext(void 0);function cSe(){return G.use(M9)}function N9({ref:e,children:t,defaultValue:n,value:r,onValueChange:i,className:a,collapsed:o,onCollapsedChange:s,...c}){let[l,u]=G.useState(n||``),d=r!==void 0,f=o!==void 0,[p,m]=G.useState(!1),h=G.useCallback(e=>{d||u(e),i?.(e)},[d,i]);return(0,K.jsx)(A9,{value:{activeValue:d?r:l,handleValueChange:h,collapsed:f?o:p,handleCollapsedChange:G.useCallback(e=>{f||m(e),s?.(e)},[f,s])},children:(0,K.jsx)(`div`,{ref:e,className:q(`flex flex-col gap-2`,a),...c,children:t})})}N9.displayName=`Tabs`;function P9({ref:e,children:t,className:n,variant:r=`default`,collapsible:i=!1,...a}){let{activeValue:o,collapsed:s,handleCollapsedChange:c}=j9(),[l,u]=G.useState({width:0,left:0}),d=G.useRef(null),f=G.useRef(null),p=G.useRef(null),m=G.useCallback(()=>{let e=d.current;if(!e)return;let t=e.querySelector(`div:first-child`);if(!t)return;let n=t.querySelector(`button[data-tab-value="${o}"]`);if(n&&o){let e=t.getBoundingClientRect(),r=n.getBoundingClientRect();u({width:r.width,left:r.left-e.left})}else u({width:0,left:0})},[o]),h=G.useCallback(()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(m,16)},[m]);G.useEffect(()=>{let e=setTimeout(m,10);return()=>clearTimeout(e)},[m,s]),G.useEffect(()=>{let e=d.current;if(!e)return;f.current=new ResizeObserver(()=>{h()}),f.current.observe(e);let t=e.querySelector(`div:first-child`);return t&&t.querySelectorAll(`button[data-tab-value]`).forEach(e=>{f.current&&f.current.observe(e)}),()=>{f.current&&f.current.disconnect(),p.current&&clearTimeout(p.current)}},[h]),G.useEffect(()=>{let e=()=>{h()};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[h]);let g=G.useRef(null);return G.useEffect(()=>{g.current&&(g.current.style.width=`${l.width}px`,g.current.style.left=`${l.left}px`)},[l]),(0,K.jsx)(M9,{value:{variant:r,collapsed:s,handleCollapsedChange:c},children:(0,K.jsx)(`div`,{ref:d,className:q(`relative flex items-center bg-none gap-1`,r===`default`&&`p-1 rounded-full border border-zinc-300 dark:border-zinc-600`,r===`underline`&&`border-b border-zinc-200 dark:border-zinc-700`,n),...a,children:(0,K.jsxs)(`div`,{role:`tablist`,className:`flex-1 flex items-center relative`,children:[t,(0,K.jsx)(`span`,{ref:g,className:q(`absolute transition-all duration-500 ease-in-out z-0`,r===`default`&&`bg-white dark:bg-zinc-700 rounded-full h-[calc(100%)] top-0 border border-zinc-300 dark:border-zinc-600`,r===`underline`&&`bottom-0 h-0.5 bg-black dark:bg-white`)})]})})})}P9.displayName=`TabsList`;var lSe=({children:e,title:t,collapsed:n})=>!t||!n?e:(0,K.jsx)(Nm,{children:(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{children:e}),(0,K.jsx)(Im,{children:t})]})}),F9=G.forwardRef(({children:e,value:t,className:n,disabled:r,icon:i,title:a,showDot:o=!1,...s},c)=>{let{activeValue:l,handleValueChange:u,collapsed:d}=j9(),f=cSe()?.variant||`default`,p=l===t,m=d&&a?a:void 0;return(0,K.jsx)(lSe,{title:a,collapsed:d,children:(0,K.jsxs)(`button`,{ref:c,disabled:r,onClick:()=>u(t),"data-tab-value":t,"data-tab-active":p,role:`tab`,"aria-selected":p?`true`:`false`,title:m,className:q(`relative z-10 flex-1 inline-flex items-center justify-center whitespace-nowrap text-sm font-medium ring-offset-background transition-all duration-500 ease-in-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 cursor-pointer`,f===`default`&&`py-2.5`,f===`default`&&`rounded-md px-4`,f===`underline`&&`px-6 py-3 border-b-2 border-transparent`,p&&`text-foreground`,!p&&`text-muted-foreground hover:text-foreground`,n),...s,children:[i&&(0,K.jsx)(i,{className:q(`h-4 w-4 transition-all duration-500 ease-in-out`,!d&&`mr-2`,d&&`mr-0!`)}),o&&(0,K.jsx)(`span`,{className:`absolute top-1.5 right-1.5 w-2 h-2 bg-orange-500 dark:bg-orange-400 border-2 border-white dark:border-zinc-900 rounded-full transition-opacity duration-300 z-10 animate-status-pulse-orange`}),(0,K.jsx)(`span`,{className:q(`transition-all duration-500 ease-in-out overflow-hidden`,d?`w-0 opacity-0`:`w-auto opacity-100`),children:e})]})})});F9.displayName=`TabsTrigger`;function uSe({ref:e,children:t,value:n,className:r,...i}){let{activeValue:a}=j9();return a===n?(0,K.jsx)(`div`,{ref:e,role:`tabpanel`,className:q(`mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,r),...i,children:t}):null}uSe.displayName=`TabsContent`;function I9({serverConfig:e,additionalItems:t=[],showClients:n={cursor:!0,vsCode:!0,vsCodeInsiders:!0,claudeDesktop:!0,claudeCode:!0,geminiCli:!0,codexCli:!0},className:r=``,onSuccess:i,onError:a,trigger:o}){let[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)(!1),{url:p,name:m,headers:h}=e,g=()=>{try{let e=tI(p,m,h);window.location.href=e,i?.(`Cursor`)}catch(e){console.error(`Failed to generate Cursor deep link:`,e),a?.(e)}},_=()=>{try{let e=nI(p,m,h);window.location.href=e,i?.(`VS Code`)}catch(e){console.error(`Failed to generate VS Code deep link:`,e),a?.(e)}},v=()=>{try{let e=rI(p,m,h);window.location.href=e,i?.(`VS Code Insiders`)}catch(e){console.error(`Failed to generate VS Code Insiders deep link:`,e),a?.(e)}},y=()=>{try{iI(p,m,h),i?.(`Claude Desktop`)}catch(e){console.error(`Failed to download .mcpb file:`,e),a?.(e)}},b=()=>{u(`claude-code`),c(!0)},x=()=>{u(`gemini-cli`),c(!0)},S=()=>{u(`codex-cli`),c(!0)},C=async e=>{try{await rg(e),f(!0),setTimeout(()=>f(!1),2e3)}catch(e){console.error(`Failed to copy:`,e),a?.(e)}},w=()=>{if(l===`claude-code`){let{command:e,envVars:t}=aI(p,m,h),n=cI(t);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(sy,{children:[(0,K.jsx)(cy,{children:`Add to Claude Code`}),(0,K.jsx)(ly,{children:`Execute the following command in your shell to add this server to Claude Code.`})]}),(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h5`,{className:`font-semibold text-sm mb-2`,children:`Instructions`}),(0,K.jsxs)(`ol`,{className:`space-y-2 text-xs text-muted-foreground`,children:[(0,K.jsxs)(`li`,{className:`flex gap-2`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-foreground`,children:`1.`}),(0,K.jsx)(`span`,{children:`Ensure the Claude Code executable is available in your path`})]}),(0,K.jsxs)(`li`,{className:`flex gap-2`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-foreground`,children:`2.`}),(0,K.jsx)(`span`,{children:`Execute the following snippet in your shell:`})]})]})]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`div`,{className:`absolute top-2 right-2 z-10`,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-7 px-2 bg-background hover:bg-accent border border-border`,onClick:()=>C(e),children:d?(0,K.jsx)($m,{className:`size-3.5 text-green-600`}):(0,K.jsx)(uh,{className:`size-3.5`})})}),(0,K.jsx)(`pre`,{className:`bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto`,children:(0,K.jsx)(`code`,{children:e})})]}),n&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h5`,{className:`font-semibold text-sm mb-2`,children:`Environment Variables`}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground mb-2`,children:`After installation, set these environment variables in your shell:`}),(0,K.jsx)(`pre`,{className:`bg-muted p-3 rounded-md text-xs overflow-x-auto`,children:(0,K.jsx)(`code`,{children:n})})]}),(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`The MCP configuration supports environment variable expansion using `,(0,K.jsx)(`code`,{className:`text-foreground`,children:"${VAR}"}),` `,`syntax.`]})]})]})}if(l===`gemini-cli`){let{command:e,envVars:t}=oI(p,m,h),n=cI(t);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(sy,{children:[(0,K.jsx)(cy,{children:`Add to Gemini CLI`}),(0,K.jsx)(ly,{children:`Execute the following command in your shell to add this server to Gemini CLI.`})]}),(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h5`,{className:`font-semibold text-sm mb-2`,children:`Instructions`}),(0,K.jsxs)(`ol`,{className:`space-y-2 text-xs text-muted-foreground`,children:[(0,K.jsxs)(`li`,{className:`flex gap-2`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-foreground`,children:`1.`}),(0,K.jsx)(`span`,{children:`Ensure the Gemini CLI executable is available in your path`})]}),n&&(0,K.jsxs)(`li`,{className:`flex gap-2`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-foreground`,children:`2.`}),(0,K.jsx)(`span`,{children:`Set these environment variables in your shell before running the command:`})]}),(0,K.jsxs)(`li`,{className:`flex gap-2`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-foreground`,children:n?`3.`:`2.`}),(0,K.jsx)(`span`,{children:`Execute the following snippet in your shell:`})]})]})]}),n&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h5`,{className:`font-semibold text-sm mb-2`,children:`Environment Variables`}),(0,K.jsx)(`pre`,{className:`bg-muted p-3 rounded-md text-xs overflow-x-auto`,children:(0,K.jsx)(`code`,{children:n})})]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`div`,{className:`absolute top-2 right-2 z-10`,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-7 px-2 bg-background hover:bg-accent border border-border`,onClick:()=>C(e),children:d?(0,K.jsx)($m,{className:`size-3.5 text-green-600`}):(0,K.jsx)(uh,{className:`size-3.5`})})}),(0,K.jsx)(`pre`,{className:`bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto`,children:(0,K.jsx)(`code`,{children:e})})]}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Restart Gemini CLI to load the new configuration.`})]})]})}if(l===`codex-cli`){let{config:e,envVars:t}=sI(p,m,h);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(sy,{children:[(0,K.jsx)(cy,{children:`Add to Codex CLI`}),(0,K.jsxs)(ly,{children:[`Add this configuration to your`,` `,(0,K.jsx)(`code`,{className:`text-foreground`,children:`~/.codex/config.toml`}),` `,`file.`]})]}),(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h5`,{className:`font-semibold text-sm mb-2`,children:`Instructions`}),(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Add this configuration to your`,` `,(0,K.jsx)(`code`,{className:`text-foreground`,children:`~/.codex/config.toml`}),`:`]})]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`div`,{className:`absolute top-2 right-2 z-10`,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-7 px-2 bg-background hover:bg-accent border border-border`,onClick:()=>C(e),children:d?(0,K.jsx)($m,{className:`size-3.5 text-green-600`}):(0,K.jsx)(uh,{className:`size-3.5`})})}),(0,K.jsx)(`pre`,{className:`bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto`,children:(0,K.jsx)(`code`,{children:e})})]}),t.length>0&&(0,K.jsx)(`div`,{children:(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`(optional) If you would rather use variables from your system's environment, replace the`,` `,(0,K.jsx)(`code`,{className:`text-foreground`,children:`http_headers`}),` key with the `,(0,K.jsx)(`code`,{className:`text-foreground`,children:`env_http_headers`}),` `,`key as shown in the commented section above.`]})}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Restart Codex CLI to load the new configuration.`})]})]})}return null},T=(0,K.jsxs)(J,{variant:`ghost`,className:`bg-zinc-200 dark:bg-zinc-800 hover:bg-zinc-300 dark:hover:bg-zinc-700 rounded-full transition-colors px-3 flex items-center justify-center ${r}`,children:[(0,K.jsxs)(`span`,{className:`xl:hidden hidden sm:flex items-center gap-1`,children:[(0,K.jsx)(Lh,{className:`size-3`}),`Client`]}),(0,K.jsxs)(`span`,{className:`hidden xl:flex items-center gap-1`,children:[`Add to Client`,(0,K.jsx)(eh,{className:`size-3`})]})]});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Jp,{children:[(0,K.jsx)(Yp,{asChild:!0,children:o?typeof o==`function`?o({isOpen:!1,onClick:()=>{}}):o:T}),(0,K.jsxs)(Xp,{align:`end`,className:`w-auto min-w-[300px]`,children:[t.map(e=>(0,K.jsxs)(Zp,{onClick:async()=>{await e.onClick()},className:`flex items-center gap-2`,children:[e.icon,(0,K.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:e.label})]},e.id)),t.length>0&&(0,K.jsx)(em,{}),n.cursor&&(0,K.jsxs)(Zp,{onClick:g,className:`flex items-center gap-2`,children:[(0,K.jsx)(`img`,{src:`https://cdn.simpleicons.org/cursor`,alt:`Cursor`,className:`h-4 w-4`}),(0,K.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:`Cursor`})]}),n.claudeCode&&(0,K.jsxs)(Zp,{onClick:b,className:`flex items-center gap-2`,children:[(0,K.jsx)(`img`,{src:`https://cdn.simpleicons.org/claude`,alt:`Claude`,className:`h-4 w-4`}),(0,K.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:`Claude Code`})]}),n.claudeDesktop&&(0,K.jsxs)(Zp,{onClick:y,className:`flex items-center gap-2`,children:[(0,K.jsx)(`img`,{src:`https://cdn.simpleicons.org/claude`,alt:`Claude`,className:`h-4 w-4`}),(0,K.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:`Claude Desktop`})]}),n.vsCode&&(0,K.jsxs)(Zp,{onClick:_,className:`flex items-center gap-2`,children:[(0,K.jsx)(lI,{className:`h-4 w-4 text-blue-500`}),(0,K.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:`VS Code`})]}),n.vsCodeInsiders&&(0,K.jsxs)(Zp,{onClick:v,className:`flex items-center gap-2`,children:[(0,K.jsx)(lI,{className:`h-4 w-4 text-teal-400`}),(0,K.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:`VS Code Insiders`})]}),n.geminiCli&&(0,K.jsxs)(Zp,{onClick:x,className:`flex items-center gap-2`,children:[(0,K.jsx)(`img`,{src:`https://cdn.simpleicons.org/googlegemini`,alt:`Gemini`,className:`h-4 w-4`}),(0,K.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:`Gemini CLI`})]}),n.codexCli&&(0,K.jsxs)(Zp,{onClick:S,className:`flex items-center gap-2`,children:[(0,K.jsx)(`img`,{src:`https://inspector-cdn.mcp-use.com/providers/openai.png`,alt:`Codex`,className:`h-4 w-4`}),(0,K.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:`Codex CLI`})]})]})]}),(0,K.jsx)(iy,{open:s,onOpenChange:c,children:(0,K.jsx)(oy,{className:`max-w-3xl max-h-[80vh] overflow-y-auto`,children:w()})})]})}function L9({className:e,state:t=`collapsed`,href:n=`https://mcp-use.com`}){let[r,i]=(0,G.useState)(!1),a=.2,o=.7,s=a+o+.6,c=a/s,l=(a+o)/s;return(0,K.jsxs)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,className:q(`flex items-center transition-opacity -my-3`,t===`expanded`?`space-x-2`:``,e),onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[(0,K.jsx)(`div`,{className:`relative`,children:(0,K.jsxs)(_F.svg,{viewBox:`0 0 303 303`,initial:`rest`,animate:r?`hover`:`rest`,className:q(`text-foreground`,t===`expanded`?`size-[40px]`:`size-[20px]`),children:[(0,K.jsxs)(_F.g,{variants:{rest:{opacity:1},hover:{opacity:[1,0,0,1],transition:{duration:s,times:[0,c,l,1],ease:`easeInOut`}}},fill:`currentColor`,fillRule:`nonzero`,stroke:`currentColor`,strokeWidth:4,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`path`,{d:`m105.5 34.8.6.6c9.5 9.5 14.4 21.9 14.6 34.4a112.6 112.6 0 0 0 112.2 112.1h.6c12 .4 24 5.1 33.2 14.1l.6.6a50 50 0 0 1-70.1 71.3l-.6-.6A49.9 49.9 0 0 1 182 230 112.6 112.6 0 0 0 73.4 120.7h-.8a49.9 49.9 0 0 1-36.7-14l-.5-.6a50 50 0 0 1-.6-70.2l.6-.5a50 50 0 0 1 69.5-1.2l.6.6Z`}),(0,K.jsx)(`circle`,{cx:`70.3`,cy:`232.3`,r:`50`}),(0,K.jsx)(`circle`,{cx:`232.3`,cy:`70.3`,r:`50`})]}),(0,K.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeWidth:4,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(dSe,{d:`m105.5 34.8.6.6c9.5 9.5 14.4 21.9 14.6 34.4a112.6 112.6 0 0 0 112.2 112.1h.6c12 .4 24 5.1 33.2 14.1l.6.6a50 50 0 0 1-70.1 71.3l-.6-.6A49.9 49.9 0 0 1 182 230 112.6 112.6 0 0 0 73.4 120.7h-.8a49.9 49.9 0 0 1-36.7-14l-.5-.6a50 50 0 0 1-.6-70.2l.6-.5a50 50 0 0 1 69.5-1.2l.6.6Z`,times:{T0:0,T1:c,T2:l,T3:1},total:s}),(0,K.jsx)(R9,{cx:70.3,cy:232.3,r:50,times:{T0:0,T1:c,T2:l,T3:1},total:s}),(0,K.jsx)(R9,{cx:232.3,cy:70.3,r:50,times:{T0:0,T1:c,T2:l,T3:1},total:s})]})]})}),t===`expanded`&&(0,K.jsxs)(`div`,{className:`font-ubuntu flex-col items-start -space-y-1 mr-3 hidden xl:flex`,children:[(0,K.jsx)(`h1`,{className:`text-xl font-medium`,children:`mcp-use`}),(0,K.jsx)(`span`,{className:`text-lg text-muted-foreground tracking-wide font-sans font-light`,children:`Inspector`})]})]})}function dSe({d:e,times:t,total:n}){let{T0:r,T1:i,T2:a,T3:o}=t;return(0,K.jsx)(_F.path,{d:e,variants:{rest:{pathLength:0,opacity:0},hover:{pathLength:[0,0,1,1],opacity:[0,0,1,1],transition:{duration:n,times:[r,i,a,o],ease:`easeInOut`}}}})}function R9({cx:e,cy:t,r:n,times:r,total:i}){let{T0:a,T1:o,T2:s,T3:c}=r;return(0,K.jsx)(_F.circle,{cx:e,cy:t,r:n,variants:{rest:{pathLength:0,opacity:0},hover:{pathLength:[0,0,1,1],opacity:[0,0,1,1],transition:{duration:i,times:[a,o,s,c],ease:`easeInOut`}}}})}function z9({open:e,onOpenChange:t,serverUrl:n,serverName:r,serverId:i,headers:a,language:o}){let{prismStyle:s}=Hb(),[c,l]=(0,G.useState)(!1),u=o===`typescript`?zle(n,r,i,a):Ble(n,r,i,a),d=async()=>{await rg(u),l(!0),setTimeout(()=>l(!1),2e3)},f=o===`typescript`?`TypeScript`:`Python`;return(0,K.jsx)(iy,{open:e,onOpenChange:t,children:(0,K.jsxs)(oy,{className:`max-w-[90vw] max-h-[90vh] overflow-hidden flex flex-col`,children:[(0,K.jsxs)(sy,{children:[(0,K.jsxs)(cy,{children:[`Add to `,f,` SDK`]}),(0,K.jsxs)(ly,{children:[`Copy the following code to integrate this server into your`,` `,f,` application using the mcp-use SDK.`]})]}),(0,K.jsxs)(`div`,{className:`space-y-4 overflow-y-auto flex-1 min-h-0`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h5`,{className:`font-semibold text-sm mb-2`,children:`Instructions`}),(0,K.jsxs)(`ol`,{className:`space-y-2 text-xs text-muted-foreground`,children:[(0,K.jsxs)(`li`,{className:`flex gap-2`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-foreground`,children:`1.`}),(0,K.jsxs)(`span`,{children:[`Install the mcp-use package:`,` `,(0,K.jsx)(`code`,{className:`text-foreground`,children:o===`typescript`?`npm install mcp-use`:`pip install mcp-use`})]})]}),(0,K.jsxs)(`li`,{className:`flex gap-2`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-foreground`,children:`2.`}),(0,K.jsxs)(`span`,{children:[`Copy the following code into your `,f,` project:`]})]})]})]}),(0,K.jsxs)(`div`,{className:`relative w-full overflow-x-auto overflow-y-auto max-h-[60vh]`,children:[(0,K.jsx)(`div`,{className:`absolute top-2 right-2 z-10`,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-7 px-2 bg-background hover:bg-accent border border-border`,onClick:d,children:c?(0,K.jsx)($m,{className:`size-3.5 text-green-600`}):(0,K.jsx)(uh,{className:`size-3.5`})})}),(0,K.jsx)(yO,{language:o,style:s,customStyle:{margin:0,padding:`1rem`,paddingRight:`3rem`,borderRadius:`0.5rem`,fontSize:`0.75rem`,background:`var(--muted)`,width:`100%`,maxWidth:`100%`,overflow:`auto`},wrapLines:!0,wrapLongLines:!0,PreTag:`div`,children:u})]})]})]})})}function B9({ref:e,shimmerColor:t,shimmerSize:n=`0.05em`,shimmerDuration:r=`3s`,borderRadius:i=`100px`,background:a,className:o,children:s,...c}){let{theme:l}=bb(),u=l===`dark`?`#000000`:`#ffffff`,d=l===`dark`?`rgba(255, 255, 255, 1)`:`rgba(0, 0, 0, 1)`,f=t||u,p=a||d;return(0,K.jsxs)(`button`,{style:{"--spread":`90deg`,"--shimmer-color":f,"--radius":i,"--speed":r,"--cut":n,"--bg":p},className:q(`group relative z-0 flex cursor-pointer items-center justify-center overflow-hidden [border-radius:var(--radius)] border px-6 py-3 whitespace-nowrap [background:var(--bg)]`,`transform-gpu transition-transform duration-300 ease-in-out active:translate-y-px`,`dark:text-white text-black dark:border-white/10 border-black/10`,o),ref:e,...c,children:[(0,K.jsx)(`div`,{className:q(`-z-30 blur-[2px]`,`@container-[size] absolute inset-0 overflow-visible`),children:(0,K.jsx)(`div`,{className:`animate-shimmer-slide absolute inset-0 aspect-[1] h-[100cqh] rounded-none mask-none`,children:(0,K.jsx)(`div`,{className:`animate-spin-around absolute -inset-full w-auto [translate:0_0] rotate-0 [background:conic-gradient(from_calc(270deg-(var(--spread)*0.5)),transparent_0,var(--shimmer-color)_var(--spread),transparent_var(--spread))]`})})}),s,(0,K.jsx)(`div`,{className:q(`absolute inset-0 size-full`,`rounded-2xl px-4 py-1.5 text-sm font-medium`,`transform-gpu transition-all duration-300 ease-in-out`,`dark:shadow-[inset_0_-8px_10px_#0000001f] dark:group-hover:shadow-[inset_0_-6px_10px_#0000003f] dark:group-active:shadow-[inset_0_-10px_10px_#0000003f] shadow-[inset_0_-8px_10px_#ffffff1f] group-hover:shadow-[inset_0_-6px_10px_#ffffff3f] group-active:shadow-[inset_0_-10px_10px_#ffffff3f]`)}),(0,K.jsx)(`div`,{className:q(`absolute [inset:var(--cut)] -z-20 [border-radius:var(--radius)] bg-black dark:bg-white`)})]})}B9.displayName=`ShimmerButton`;function V9({status:e}){let{color:t,ringColor:n,tooltip:r}=(e=>{switch(e){case`ready`:return{color:`bg-emerald-500`,ringColor:`ring-emerald-500`,tooltip:`Connected`};case`failed`:return{color:`bg-red-500`,ringColor:`ring-red-500`,tooltip:`Failed`};default:return{color:`bg-yellow-500`,ringColor:`ring-yellow-500`,tooltip:e}}})(e);return(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`div`,{className:`absolute w-2 h-2 rounded-full ${n} animate-ping`}),(0,K.jsx)(`div`,{className:`relative w-2 h-2 rounded-full ${t}`})]})}),(0,K.jsx)(Im,{children:(0,K.jsx)(`p`,{children:r})})]})}function H9({connections:e,selectedServer:t,onServerSelect:n,onOpenConnectionOptions:r,mobileMode:i=!1}){let a=n_(),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(null),u=t=>{let r=e.find(e=>e.id===t);if(!r||r.state!==`ready`){xv.error(`Server is not connected and cannot be inspected`);return}n(t)};return i?(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`relative`,children:(0,K.jsxs)(Jp,{children:[(0,K.jsx)(Yp,{asChild:!0,children:(0,K.jsxs)(J,{variant:`ghost`,className:`h-11 px-2 bg-black dark:bg-white text-white dark:text-black border-black dark:border-white hover:bg-gray-800 dark:hover:bg-zinc-100 hover:border-gray-800 dark:hover:border-zinc-200 flex items-center gap-1.5`,children:[t?(0,K.jsx)(bF,{server:t,size:`md`}):(0,K.jsx)(Hh,{className:`h-5 w-5`}),(0,K.jsx)(eh,{className:`h-4 w-4`})]})}),(0,K.jsxs)(Xp,{className:`w-[calc(100vw-2rem)] sm:w-[300px]`,align:`start`,children:[(0,K.jsx)($p,{className:`cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800`,onClick:()=>a(`/`),children:`MCP Servers`}),(0,K.jsx)(em,{}),e.length===0?(0,K.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground dark:text-zinc-400 text-center`,children:`No servers connected. Go to the dashboard to add one.`}):e.map(e=>(0,K.jsxs)(Zp,{onClick:()=>u(e.id),className:`flex items-center gap-3`,children:[(0,K.jsx)(bF,{server:e,size:`sm`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-1`,children:[(0,K.jsx)(`div`,{className:`font-medium`,children:e.name}),(0,K.jsx)(V9,{status:e.state})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800`,onClick:t=>{t.stopPropagation(),l(e),s(!0)},children:(0,K.jsx)(Dh,{className:`h-3 w-3`})}),(0,K.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800`,onClick:t=>{t.stopPropagation(),r(e.id)},children:(0,K.jsx)(Uh,{className:`h-3 w-3`})})]})]},e.id)),(0,K.jsx)(em,{}),(0,K.jsx)(Zp,{onClick:()=>a(`/`),children:(0,K.jsx)(`span`,{className:`text-blue-600 dark:text-blue-400`,children:`+ Add new server`})})]})]})}),(0,K.jsx)(xO,{open:o,onOpenChange:s,connection:c})]}):(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)(Jp,{children:[(0,K.jsx)(Yp,{asChild:!0,children:(0,K.jsxs)(B9,{className:q(`min-w-0 sm:min-w-[200px] p-0 px-1 text-sm h-11 justify-start text-white dark:text-black border-black dark:border-white hover:bg-gray-800 dark:hover:bg-zinc-100 hover:border-gray-800 dark:hover:border-zinc-200`,!t&&`pl-4`,t&&`pr-20`),children:[t&&(0,K.jsx)(bF,{server:t,size:`md`,className:`mr-2`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-1`,children:[(0,K.jsx)(`span`,{className:`truncate lg:max-w-[120px] xl:max-w-none`,children:t?t.serverInfo?.title||t.serverInfo?.name||t.name:`Select server to inspect`}),t&&(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:t.error&&t.state!==`ready`?(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation()},className:`w-2 h-2 rounded-full bg-rose-500 animate-status-pulse-red hover:bg-rose-600 transition-colors`,title:`Click to copy error message`,"aria-label":`Copy error message to clipboard`})}),(0,K.jsx)(Im,{children:(0,K.jsx)(`p`,{className:`max-w-xs`,children:t.error})})]}):(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full ${t.state===`ready`?`bg-emerald-600 animate-status-pulse`:t.state===`failed`?`bg-rose-600 animate-status-pulse-red`:`bg-yellow-500 animate-status-pulse-yellow`}`})})]})]})}),t&&(0,K.jsxs)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1`,children:[(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(`button`,{type:`button`,onClick:()=>{l(t),s(!0)},className:`p-1.5 hover:bg-white/10 dark:hover:bg-black/10 rounded-full transition-colors text-white dark:text-black`,"aria-label":`View server info`,children:(0,K.jsx)(Dh,{className:`h-4 w-4`})})}),(0,K.jsx)(Im,{children:(0,K.jsx)(`p`,{children:`View server info`})})]}),(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(`button`,{type:`button`,onClick:()=>{r(t.id)},className:`p-1.5 hover:bg-white/10 dark:hover:bg-black/10 rounded-full transition-colors text-white dark:text-black`,"aria-label":`Edit connection settings`,children:(0,K.jsx)(Uh,{className:`h-4 w-4`})})}),(0,K.jsx)(Im,{children:(0,K.jsx)(`p`,{children:`Edit connection settings`})})]})]}),(0,K.jsxs)(Xp,{className:`w-[calc(100vw-2rem)] sm:w-[300px]`,align:`start`,children:[(0,K.jsx)($p,{className:`cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800`,onClick:()=>a(`/`),children:`MCP Servers`}),(0,K.jsx)(em,{}),e.length===0?(0,K.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground dark:text-zinc-400 text-center`,children:`No servers connected. Go to the dashboard to add one.`}):e.map(e=>(0,K.jsxs)(Zp,{onClick:()=>u(e.id),className:`flex items-center gap-3`,children:[(0,K.jsx)(bF,{server:e,size:`sm`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-1`,children:[(0,K.jsx)(`div`,{className:`font-medium`,children:e.serverInfo?.title||e.serverInfo?.name||e.name}),(0,K.jsx)(V9,{status:e.state})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800`,onClick:t=>{t.stopPropagation(),l(e),s(!0)},children:(0,K.jsx)(Dh,{className:`h-3 w-3`})}),(0,K.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800`,onClick:t=>{t.stopPropagation(),r(e.id)},children:(0,K.jsx)(Uh,{className:`h-3 w-3`})})]})]},e.id)),(0,K.jsx)(em,{}),(0,K.jsx)(Zp,{onClick:()=>a(`/`),children:(0,K.jsx)(`span`,{className:`text-blue-600 dark:text-blue-400`,children:`+ Add new server`})})]})]}),(0,K.jsx)(xO,{open:o,onOpenChange:s,connection:c})]})})}function U9({className:e}){let{theme:t,setTheme:n}=bb(),r=(0,G.useRef)(null),i=()=>t===`system`?(0,K.jsx)(Ph,{className:`size-4`}):t===`light`?(0,K.jsx)(Xh,{className:`size-5`}):(0,K.jsx)(Fh,{className:`size-4`}),a=async e=>{let t=r.current;if(!t){n(e);return}if(typeof document<`u`&&`startViewTransition`in document){await document.startViewTransition(()=>{(0,Va.flushSync)(()=>{n(e)})}).ready;let{top:r,left:i,width:a,height:o}=t.getBoundingClientRect(),s=r+o/2,c=i+a/2,l=window.innerWidth-i,u=window.innerHeight-r,d=Math.hypot(Math.max(i,l),Math.max(r,u));document.documentElement.animate({clipPath:[`circle(0px at ${c}px ${s}px)`,`circle(${d}px at ${c}px ${s}px)`]},{duration:700,easing:`ease-in-out`,pseudoElement:`::view-transition-new(root)`})}else n(e)};return(0,K.jsxs)(Jp,{children:[(0,K.jsx)(Yp,{asChild:!0,children:(0,K.jsx)(J,{ref:r,variant:`ghost`,size:`sm`,className:q(`p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors`,e),"aria-label":`Toggle theme`,children:i()})}),(0,K.jsx)(Xp,{align:`end`,className:`min-w-0`,children:(0,K.jsxs)(tee,{value:t,onValueChange:e=>a(e),children:[(0,K.jsxs)(Qp,{value:`light`,className:`pl-2 pr-0 flex items-center gap-2 justify-end`,children:[(0,K.jsx)(`span`,{children:`Light`}),(0,K.jsx)(Xh,{className:`mr-2 size-5`})]}),(0,K.jsxs)(Qp,{value:`dark`,className:`pl-2 pr-0 flex items-center gap-2 justify-end`,children:[(0,K.jsx)(`span`,{children:`Dark`}),(0,K.jsx)(Fh,{className:`mr-2 h-4 w-4`})]}),(0,K.jsxs)(Qp,{value:`system`,className:`pl-2 pr-0 flex items-center gap-2 justify-end`,children:[(0,K.jsx)(`span`,{children:`System`}),(0,K.jsx)(Ph,{className:`mr-2 h-4 w-4`})]})]})})]})}var W9=[{id:`tools`,label:`Tools`,icon:eg},{id:`prompts`,label:`Prompts`,icon:Mh},{id:`resources`,label:`Resources`,icon:xh},{id:`sampling`,label:`Sampling`,icon:wh},{id:`elicitation`,label:`Elicitation`,icon:Jh},{id:`notifications`,label:`Notifications`,icon:Xm},{id:`chat`,label:`Chat`,icon:Lee}];function G9(e,t){return e===`tools`?t.tools.length:e===`prompts`?t.prompts.length:e===`resources`?t.resources.length:e===`sampling`?t.pendingSamplingRequests?.length||0:e===`elicitation`?t.pendingElicitationRequests?.length||0:e===`notifications`?t.unreadNotificationCount:0}function K9(e,t,n){return n&&t>0&&[`sampling`,`elicitation`,`notifications`].includes(e)}function fSe({collapsed:e,onToggle:t}){return(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(`button`,{onClick:t,className:q(`shrink-0 p-1.5 rounded-md transition-all duration-500 ease-in-out cursor-pointer`,`text-muted-foreground hover:text-foreground`,`hover:bg-zinc-100 dark:hover:bg-zinc-800`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`),"aria-label":e?`Expand tabs`:`Collapse tabs`,type:`button`,children:e?(0,K.jsx)(nh,{className:`h-4 w-4 transition-transform duration-500 ease-in-out`}):(0,K.jsx)(th,{className:`h-4 w-4 transition-transform duration-500 ease-in-out`})})}),(0,K.jsx)(Im,{children:(0,K.jsx)(`p`,{children:e?`Expand tabs`:`Collapse tabs`})})]})}function pSe(e){try{let t=new URL(e).hostname.toLowerCase();return t===`localhost`||t===`127.0.0.1`||t===`::1`||t===`0.0.0.0`}catch{return!1}}function mSe(e){try{return new URL(e).hostname.endsWith(`.mcp-use.run`)}catch{return!1}}function hSe(e){if(!e)return null;try{let t=new URL(e);if(t.protocol===`https:`)return t.origin}catch{}return null}var q9={starting:`Starting tunnel…`,stopping:`Stopping tunnel…`,reconnecting:`Reconnecting…`};function gSe({tunnelUrl:e,isTunnelStarting:t,setTunnelUrl:n,setIsTunnelStarting:r,copied:i,setCopied:a,handleCopy:o}){let[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)(0),[p,m]=(0,G.useState)(q9.starting);(0,G.useEffect)(()=>{if(!t){f(20);return}f(20);let e=setInterval(()=>f(e=>e>0?e-1:0),1e3);return()=>clearInterval(e)},[t]),(0,G.useEffect)(()=>{if(!e)return;c(!0);let t=new URLSearchParams(window.location.search);if(t.has(`openTunnelPopover`)){t.delete(`openTunnelPopover`);let e=t.toString();window.history.replaceState({},``,`${window.location.pathname}${e?`?${e}`:``}`)}},[e]),(0,G.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await fetch(`/inspector/api/dev/info`);if(!t.ok||e)return;let r=await t.json();if(e)return;if(u(!!r.fromCli),r.tunnelUrl)n(new URL(r.tunnelUrl).origin);else{let e=hSe(r.mcpUrl??null);e&&n(e)}}catch{e||u(!1)}})(),()=>{e=!0}},[n]);let h=async e=>{let t=window.location.port||`3000`,i=`http://localhost:${t}/inspector/api/dev/info`,a=Date.now()+9e4;for(m(e?`Restarting with tunnel…`:`Restarting…`),await new Promise(e=>setTimeout(e,1500));Date.now()<a;){try{let r=await fetch(i,{cache:`no-store`});if(r.ok){let i=await r.json();if(!!i.tunnelUrl===e){let r=(i.tunnelUrl||i.mcpUrl||`http://localhost:${t}`).replace(/\/+$/,``)+`/mcp`;i.tunnelUrl?n(new URL(i.tunnelUrl).origin):n(null),sessionStorage.setItem(CF,JSON.stringify({url:r,name:`Local MCP Server`,transportType:`http`,connectionType:`Direct`})),xv.success(e?`Tunnel ready — reconnecting…`:`Tunnel stopped — reconnecting…`),m(q9.reconnecting);let a=new URL(window.location.href);a.searchParams.delete(`server`),a.searchParams.delete(`tunnelUrl`),a.searchParams.delete(`autoConnect`),e&&a.searchParams.set(`openTunnelPopover`,`1`),window.location.assign(a.toString());return}}}catch{}await new Promise(e=>setTimeout(e,1500))}xv.error(`Timeout waiting for server to restart`),r(!1)},g=async()=>{if(l===!1){xv.error("Start Tunnel requires `mcp-use dev` from your project directory.");return}m(q9.starting),r(!0);try{let e=await fetch(`/inspector/api/dev/start-tunnel`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));xv.error(t.error||`Failed to start tunnel`),r(!1);return}await h(!0)}catch{xv.error(`Failed to start tunnel`),r(!1)}},_=async()=>{m(q9.stopping),r(!0);try{let e=await fetch(`/inspector/api/dev/stop-tunnel`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));xv.error(t.error||`Failed to stop tunnel`),r(!1);return}a(!1),c(!1),await h(!1)}catch{xv.error(`Failed to stop tunnel`),r(!1)}};if(t)return(0,K.jsxs)(`button`,{disabled:!0,className:`flex items-center gap-2 h-9 px-3 bg-zinc-100 dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 rounded-full opacity-75 cursor-wait`,children:[(0,K.jsx)(kh,{className:`size-4 text-zinc-500 dark:text-zinc-400 animate-spin`}),(0,K.jsxs)(`span`,{className:`text-sm font-medium text-zinc-600 dark:text-zinc-300 hidden lg:inline`,children:[`Start Tunnel `,(0,K.jsxs)(`span`,{className:`tabular-nums`,children:[d,`s`]})]})]});if(!e){let e=l===!0,t=l===null;return(0,K.jsxs)(`button`,{type:`button`,onClick:g,disabled:!e||t,title:l===!1?"Run `mcp-use dev` from your project to enable tunneling.":t?`Checking dev server…`:void 0,className:q(`flex items-center gap-2 h-9 px-3 border rounded-full transition-colors`,e&&!t?`bg-zinc-100 dark:bg-zinc-800 border-zinc-200 dark:border-zinc-700 hover:bg-zinc-200 dark:hover:bg-zinc-700 cursor-pointer`:`bg-zinc-100/60 dark:bg-zinc-800/60 border-zinc-200 dark:border-zinc-700 cursor-not-allowed opacity-70`),children:[t?(0,K.jsx)(kh,{className:`size-4 text-zinc-500 dark:text-zinc-400 animate-spin`}):(0,K.jsx)(ih,{className:`size-4 text-zinc-500 dark:text-zinc-400`}),(0,K.jsx)(`span`,{className:`text-sm font-medium text-zinc-600 dark:text-zinc-300 hidden lg:inline`,children:`Start Tunnel`})]})}return(0,K.jsxs)(HI,{open:s,onOpenChange:c,children:[(0,K.jsx)(UI,{asChild:!0,children:(0,K.jsxs)(`button`,{className:`flex items-center gap-2 h-9 px-3 bg-gradient-to-r from-purple-500/10 to-pink-500/10 dark:from-purple-500/20 dark:to-pink-500/20 border border-purple-500/30 dark:border-purple-500/40 rounded-full hover:from-purple-500/20 hover:to-pink-500/20 dark:hover:from-purple-500/30 dark:hover:to-pink-500/30 transition-colors cursor-pointer`,children:[(0,K.jsx)(ih,{className:`size-4 text-purple-600 dark:text-purple-400`}),(0,K.jsx)(`span`,{className:`text-sm font-medium text-purple-700 dark:text-purple-300 hidden lg:inline`,children:`Tunnel`})]})}),(0,K.jsx)(WI,{className:`w-[calc(100vw-2rem)] sm:w-96 overflow-hidden`,align:`end`,children:(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,K.jsx)(`h4`,{className:`font-semibold text-sm`,children:`Tunnel URL`}),(0,K.jsxs)(`a`,{href:`https://manufact.com/docs/tunneling`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[`Docs`,(0,K.jsx)(Nee,{className:`size-3`})]})]}),(0,K.jsxs)(`button`,{onClick:o,className:`-mx-4 px-4 py-3 bg-muted hover:bg-accent transition-colors cursor-pointer flex items-center gap-3 w-[calc(100%+2rem)]`,children:[(0,K.jsxs)(`code`,{className:`flex-1 text-[10px] font-mono truncate text-left`,children:[e,`/mcp`]}),i?(0,K.jsx)($m,{className:`size-3.5 text-green-600 shrink-0`}):(0,K.jsx)(uh,{className:`size-3.5 shrink-0 text-muted-foreground`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h5`,{className:`font-semibold text-sm mb-2`,children:`Use in ChatGPT`}),(0,K.jsxs)(`ol`,{className:`space-y-2 text-xs text-muted-foreground`,children:[(0,K.jsxs)(`li`,{className:`flex gap-2`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-foreground`,children:`1.`}),(0,K.jsxs)(`span`,{children:[`Enable`,` `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`dev mode`}),` `,`from settings`]})]}),(0,K.jsxs)(`li`,{className:`flex gap-2`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-foreground`,children:`2.`}),(0,K.jsxs)(`span`,{children:[`In`,` `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`App & Connectors`}),` `,`click on`,` `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`create`})]})]}),(0,K.jsxs)(`li`,{className:`flex gap-2`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-foreground`,children:`3.`}),(0,K.jsx)(`span`,{children:`Use the tunnel URL in the input`})]})]})]}),(0,K.jsxs)(`button`,{onClick:_,className:`flex items-center gap-1.5 text-xs text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 transition-colors cursor-pointer`,children:[(0,K.jsx)(Yh,{className:`size-3 fill-current`}),`Stop Tunnel`]})]})})]})}function _Se({connections:e,selectedServer:t,activeTab:n,onServerSelect:r,onTabChange:i,onCommandPaletteOpen:a,onOpenConnectionOptions:o,embedded:s=!1}){let{tunnelUrl:c,isTunnelStarting:l,setTunnelUrl:u,setIsTunnelStarting:d,embeddedConfig:f}=SF(),p=!!t&&(pSe(t.url)||mSe(t.url)||!!c),[m,h]=(0,G.useState)(!1),[g,_]=(0,G.useState)(!1),[v,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(!0);if(f.singleTab)return null;let S=f.visibleTabs?W9.filter(e=>f.visibleTabs.includes(e.id)):W9,C=async()=>{if(c)try{await rg(`${c}/mcp`),h(!0),xv.success(`Tunnel URL copied to clipboard`),setTimeout(()=>h(!1),2e3)}catch{xv.error(`Failed to copy URL`)}};return(0,K.jsxs)(`header`,{className:`w-full mx-auto`,children:[(0,K.jsxs)(`div`,{className:`flex lg:hidden flex-col gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between w-full`,children:[!s&&(0,K.jsx)(`div`,{className:`flex-1 flex justify-start`,children:(0,K.jsx)(H9,{connections:e,selectedServer:t,onServerSelect:r,onOpenConnectionOptions:o,mobileMode:!0})}),!s&&(0,K.jsx)(`div`,{className:`flex-shrink-0 flex justify-center`,children:(0,K.jsx)(`div`,{className:`scale-150`,children:(0,K.jsx)(L9,{state:`collapsed`})})}),!s&&(0,K.jsxs)(`div`,{className:`flex-1 flex justify-end items-center gap-2`,children:[t&&(()=>{let e=t.serverInfo?.title||t.serverInfo?.name||t.name;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(I9,{serverConfig:{url:c?`${c}/mcp`:t.url,name:e,headers:t.customHeaders,serverId:t.id},onSuccess:e=>xv.success(`Opening in ${e}...`),onError:e=>xv.error(`Failed: ${e.message}`),additionalItems:[{id:`ts-sdk`,label:`TypeScript SDK`,icon:(0,K.jsx)(`img`,{src:`https://cdn.simpleicons.org/typescript`,alt:`TypeScript`,className:`h-4 w-4`}),onClick:()=>_(!0)},{id:`py-sdk`,label:`Python SDK`,icon:(0,K.jsx)(`img`,{src:`https://cdn.simpleicons.org/python`,alt:`Python`,className:`h-4 w-4`}),onClick:()=>y(!0)}],trigger:(0,K.jsxs)(J,{variant:`ghost`,className:`bg-zinc-200 dark:bg-zinc-800 hover:bg-zinc-300 dark:hover:bg-zinc-700 rounded-full transition-colors px-3 flex items-center justify-center p-2`,"aria-label":`Add to Client`,children:[(0,K.jsxs)(`span`,{className:`xl:hidden hidden sm:flex items-center gap-1`,children:[(0,K.jsx)(Lh,{className:`size-3`}),`Client`]}),(0,K.jsxs)(`span`,{className:`hidden xl:flex items-center gap-1`,children:[`Add to Client`,(0,K.jsx)(eh,{className:`size-3`})]})]})}),(0,K.jsx)(z9,{open:g,onOpenChange:_,serverUrl:c?`${c}/mcp`:t.url,serverName:e,serverId:void 0,headers:t.customHeaders,language:`typescript`}),(0,K.jsx)(z9,{open:v,onOpenChange:y,serverUrl:c?`${c}/mcp`:t.url,serverName:e,serverId:void 0,headers:t.customHeaders,language:`python`})]})})(),(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,asChild:!0,children:(0,K.jsx)(`a`,{href:`https://github.com/mcp-use/mcp-use`,target:`_blank`,rel:`noopener noreferrer`,className:`p-2`,"aria-label":`GitHub`,children:(0,K.jsx)(k9,{className:`h-4 w-4`})})})}),(0,K.jsx)(Im,{children:(0,K.jsx)(`p`,{children:`Give us a star ⭐`})})]}),(0,K.jsx)(U9,{})]})]}),t&&(0,K.jsx)(`div`,{className:`w-full`,children:(0,K.jsx)(N9,{value:n,onValueChange:e=>i(e),collapsed:b,onCollapsedChange:x,children:(0,K.jsx)(P9,{className:`w-full justify-center`,children:S.map(e=>{let r=G9(e.id,t),i=K9(e.id,r,b);return(0,K.jsxs)(F9,{value:e.id,"data-testid":`tab-${e.id}`,icon:e.icon,showDot:i,className:q(`[&>svg]:mr-0 flex-1 flex-row gap-2 relative`,b&&`pl-2`),children:[r>0&&!b&&(0,K.jsx)(`span`,{className:q(n===e.id?`dark:bg-black`:`dark:bg-zinc-700`,`bg-zinc-200 text-zinc-700 dark:text-zinc-300 text-[10px] px-1.5 py-0.5 rounded-full font-medium`),children:r}),(0,K.jsx)(`span`,{className:`sr-only`,children:e.label})]},e.id)})})})})]}),(0,K.jsxs)(`div`,{className:`hidden lg:flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center flex-wrap gap-2 md:space-x-6 space-x-2`,children:[!s&&(0,K.jsx)(H9,{connections:e,selectedServer:t,onServerSelect:r,onOpenConnectionOptions:o}),t&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(N9,{value:n,onValueChange:e=>i(e),collapsed:b,onCollapsedChange:x,children:(0,K.jsx)(P9,{className:`overflow-x-auto`,collapsible:!0,children:S.map(e=>{let r=G9(e.id,t),i=r>0?`${e.label} (${r})`:e.label,a=K9(e.id,r,b);return(0,K.jsx)(F9,{value:e.id,"data-testid":`tab-${e.id}`,icon:e.icon,showDot:a,className:q(`[&>svg]:mr-0 lg:[&>svg]:mr-2 relative`,b&&`pl-4`),title:i,children:(0,K.jsxs)(`div`,{className:`items-center gap-2 hidden lg:flex`,children:[e.label,r>0&&(0,K.jsx)(`span`,{className:q(n===e.id?` dark:bg-black `:`dark:bg-zinc-700`,`bg-zinc-200 text-zinc-700 dark:text-zinc-300 text-xs px-2 py-0.5 rounded-full font-medium`),children:r})]})})})})}),(0,K.jsx)(fSe,{collapsed:b,onToggle:()=>x(!b)})]})]}),!s&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 sm:gap-4 flex-shrink-0`,children:[p&&(0,K.jsx)(gSe,{tunnelUrl:c,isTunnelStarting:l,setTunnelUrl:u,setIsTunnelStarting:d,copied:m,setCopied:h,handleCopy:C}),t&&(()=>{let e=t.serverInfo?.title||t.serverInfo?.name||t.name;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(I9,{serverConfig:{url:c?`${c}/mcp`:t.url,name:e,headers:t.customHeaders,serverId:t.id},onSuccess:e=>xv.success(`Opening in ${e}...`),onError:e=>xv.error(`Failed: ${e.message}`),additionalItems:[{id:`ts-sdk`,label:`TypeScript SDK`,icon:(0,K.jsx)(`img`,{src:`https://cdn.simpleicons.org/typescript`,alt:`TypeScript`,className:`h-4 w-4`}),onClick:()=>_(!0)},{id:`py-sdk`,label:`Python SDK`,icon:(0,K.jsx)(`img`,{src:`https://cdn.simpleicons.org/python`,alt:`Python`,className:`h-4 w-4`}),onClick:()=>y(!0)}],trigger:(0,K.jsxs)(J,{variant:`ghost`,className:`bg-zinc-200 dark:bg-zinc-800 hover:bg-zinc-300 dark:hover:bg-zinc-700 rounded-full transition-colors px-3 flex items-center justify-center`,"aria-label":`Add to Client`,children:[(0,K.jsxs)(`span`,{className:`xl:hidden hidden sm:flex items-center gap-1`,children:[(0,K.jsx)(Lh,{className:`size-3`}),`Client`]}),(0,K.jsxs)(`span`,{className:`hidden xl:flex items-center gap-1`,children:[`Add to Client`,(0,K.jsx)(eh,{className:`size-3`})]})]})}),(0,K.jsx)(z9,{open:g,onOpenChange:_,serverUrl:c?`${c}/mcp`:t.url,serverName:e,serverId:void 0,headers:t.customHeaders,language:`typescript`}),(0,K.jsx)(z9,{open:v,onOpenChange:y,serverUrl:c?`${c}/mcp`:t.url,serverName:e,serverId:void 0,headers:t.customHeaders,language:`python`})]})})(),(0,K.jsx)(U9,{}),(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsxs)(J,{variant:`ghost`,className:`hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full px-1 -mx-3 flex gap-1`,onClick:a,"data-testid":`command-palette-trigger-button`,children:[(0,K.jsx)(lh,{className:`size-4`}),(0,K.jsx)(`span`,{className:`text-base font-mono hidden sm:inline`,children:`K`})]})}),(0,K.jsx)(Im,{children:(0,K.jsx)(`p`,{children:`Command Palette`})})]}),(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,asChild:!0,children:(0,K.jsxs)(`a`,{href:`https://github.com/mcp-use/mcp-use`,className:`flex items-center gap-2`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,K.jsx)(k9,{className:`h-4 w-4`}),(0,K.jsx)(`span`,{className:`hidden xl:inline`,children:`Github`})]})})}),(0,K.jsx)(Im,{children:(0,K.jsx)(`p`,{children:`Give us a star ⭐`})})]}),(0,K.jsx)(L9,{state:`expanded`})]})]})]})}function vSe({children:e}){let t=n_(),n=$g(),{servers:r,addServer:i,removeServer:a,updateServer:o,storageLoaded:s}=Er(),c=(0,G.useCallback)((e,t,n,r)=>{i(e,{url:e,name:t,proxyConfig:n,transportType:r,preventAutoAuth:!0,clientOptions:{capabilities:{extensions:{"io.modelcontextprotocol/ui":{mimeTypes:[`text/html;profile=mcp-app`]}}}}})},[i]),l=(0,G.useCallback)(async(e,t)=>{try{await o(e,t)}catch(t){console.error(`[Layout] Failed to update connection ${e}:`,t)}},[o]),{selectedServerId:u,setSelectedServerId:d,activeTab:f,setActiveTab:p,navigateToItem:m,setTunnelUrl:h,tunnelUrl:g,isEmbedded:_,embeddedConfig:v,setEmbeddedMode:y}=SF(),[b,x]=(0,G.useState)(!1),[S,C]=(0,G.useState)(null),w=ple();(0,G.useEffect)(()=>{let e=new URLSearchParams(n.search),t=e.get(`embedded`)===`true`,r=e.get(`embeddedConfig`);if(t){let e={};if(r)try{e=JSON.parse(r)}catch(e){console.error(`Failed to parse embeddedConfig:`,e)}y(!0,e),e.defaultTab&&p(e.defaultTab)}},[]),(0,G.useEffect)(()=>{h(new URLSearchParams(n.search).get(`tunnelUrl`))},[n.search,h]),(0,G.useEffect)(()=>{let e=new URLSearchParams(n.search).get(`tab`);e&&[`tools`,`prompts`,`resources`,`chat`,`sampling`,`elicitation`,`notifications`].includes(e)&&p(e)},[n.search,p]),(0,G.useEffect)(()=>{let e=e=>{let t=e.detail.requestId;u&&m(u,`sampling`,t)},t=e=>{let t=e.detail.requestId;u&&m(u,`elicitation`,t)},n=e=>{let t=e.detail.toolName;u&&t?m(u,`tools`,t):u&&p(`tools`)};return window.addEventListener(`navigate-to-sampling`,e),window.addEventListener(`navigate-to-elicitation`,t),window.addEventListener(`navigate-to-tool-result`,n),()=>{window.removeEventListener(`navigate-to-sampling`,e),window.removeEventListener(`navigate-to-elicitation`,t),window.removeEventListener(`navigate-to-tool-result`,n)}},[u,p,m]);let T=(0,G.useRef)(null),E=(0,G.useRef)(null),D=(0,G.useRef)(null),{isAutoConnecting:O}=fle({connections:r,addConnection:c,removeConnection:a,configLoaded:s,embedded:_}),k=(0,G.useCallback)(e=>{Km.getInstance().capture(new wee({trigger:e})).catch(()=>{}),x(!0)},[]),A=e=>{let i=r.find(t=>t.id===e);if(!i||i.state!==`ready`){xv.error(`Server is not connected and cannot be inspected`);return}d(e);let a=new URLSearchParams(n.search),o=a.get(`tunnelUrl`),s=a.get(`tab`),c=new URLSearchParams;c.set(`server`,e),o&&c.set(`tunnelUrl`,o),s&&c.set(`tab`,s),t(`/?${c.toString()}`)},j=(0,G.useCallback)(e=>{C(e)},[]),M=(0,G.useCallback)(e=>{S&&(e.url===S?l(S,{name:e.name,proxyConfig:e.proxyConfig,transportType:e.transportType}):(a(S),c(e.url,e.name,e.proxyConfig,e.transportType)),C(null),xv.success(`Connection settings updated`))},[S,a,c,l]),N=(e,i,a)=>{if(console.warn(`[Layout] handleCommandPaletteNavigate called:`,{tab:e,itemName:i,serverId:a}),a){let o=r.find(e=>e.id===a);if(console.warn(`[Layout] Server lookup:`,{serverId:a,serverFound:!!o,serverState:o?.state}),!o||o.state!==`ready`){console.warn(`[Layout] Server not ready, showing error`),xv.error(`Server is not connected and cannot be inspected`);return}console.warn(`[Layout] Calling navigateToItem:`,{serverId:a,tab:e,itemName:i}),m(a,e,i);let s=new URLSearchParams(n.search),c=s.get(`tunnelUrl`),l=s.get(`tab`),u=new URLSearchParams;u.set(`server`,a),c&&u.set(`tunnelUrl`,c),e?u.set(`tab`,e):l&&u.set(`tab`,l);let d=`/?${u.toString()}`;console.warn(`[Layout] Navigating to:`,d),t(d)}else console.warn(`[Layout] No serverId, just updating tab to:`,e),p(e)},P=r.find(e=>e.id===u),F=P?P.tools.map(e=>({...e,_serverId:P.id})):r.flatMap(e=>e.state===`ready`?e.tools.map(t=>({...t,_serverId:e.id,_serverName:e.name})):[]),I=P?P.prompts.map(e=>({...e,_serverId:P.id})):r.flatMap(e=>e.state===`ready`?e.prompts.map(t=>({...t,_serverId:e.id,_serverName:e.name})):[]),L=P?P.resources.map(e=>({...e,_serverId:P.id})):r.flatMap(e=>e.state===`ready`?e.resources.map(t=>({...t,_serverId:e.id,_serverName:e.name})):[]);(0,G.useEffect)(()=>{let e=new URLSearchParams(n.search),i=e.get(`server`);if(i&&(i.startsWith(`http://`)||i.startsWith(`https://`))&&!r.find(e=>e.id===i)){let n=new URLSearchParams(e);n.delete(`server`),n.set(`autoConnect`,i),t(`/?${n.toString()}`,{replace:!0});return}i!==u&&d(i)},[n.search,u,d,r,t]),(0,G.useEffect)(()=>{let e=new URLSearchParams(n.search).get(`server`);if(!e)return;let i=r.find(t=>t.id===e);if(!i){let e=setTimeout(()=>t(`/`),3e3);return()=>clearTimeout(e)}if(i.state===`failed`){let e=setTimeout(()=>t(`/`),2e3);return()=>clearTimeout(e)}},[n.search,t,r]),(0,G.useEffect)(()=>{if(!_)return;let e=e=>{if(!e.data||typeof e.data!=`object`||e.data.type!==`mcp-inspector:connect_servers`)return;let t=e.data.servers;if(!Array.isArray(t)||t.length===0)return;let n=null;for(let e of t){if(!e.url||typeof e.url!=`string`)continue;let t=e.url,i=e.name??`Server`,a=e.transportType??`http`,o={...e.headers??{}};if(e.auth?.access_token){let t=e.auth.token_type||`bearer`;o.Authorization=`${t.charAt(0).toUpperCase()+t.slice(1)} ${e.auth.access_token}`}let s={proxyAddress:`${window.location.origin}/inspector/api/proxy`,...Object.keys(o).length>0&&{headers:o}};r.find(e=>e.url===t)||c(t,i,s,a),n||=t}window.parent!==window&&window.parent.postMessage({type:`mcp-inspector:servers_connected`,count:t.length},`*`)};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[_,r,c]);let ee=(0,G.useRef)(!1);if((0,G.useEffect)(()=>{if(!_||ee.current||u)return;let e=r.find(e=>e.state===`ready`);if(e){ee.current=!0,d(e.id);let r=new URLSearchParams(n.search);r.set(`server`,e.id),t(`/?${r.toString()}`,{replace:!0})}},[_,r,u,d,t,n.search]),TF({onCommandPalette:()=>k(`keyboard`),onToolsTab:()=>{P&&p(`tools`)},onPromptsTab:()=>{P&&p(`prompts`)},onResourcesTab:()=>{P&&p(`resources`)},onChatTab:()=>{P&&p(`chat`)},onHome:()=>{t(`/`)},onFocusSearch:()=>{f===`tools`&&T.current?T.current.focusSearch():f===`prompts`&&E.current?E.current.focusSearch():f===`resources`&&D.current&&D.current.focusSearch()},onBlurSearch:()=>{f===`tools`&&T.current?T.current.blurSearch():f===`prompts`&&E.current?E.current.blurSearch():f===`resources`&&D.current&&D.current.blurSearch()}}),O)return(0,K.jsx)(`div`,{className:`h-screen bg-white dark:bg-zinc-900 flex items-center justify-center`,children:(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,K.jsx)(yF,{className:`h-8 w-8 text-zinc-600 dark:text-zinc-400`}),(0,K.jsx)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400`,children:`Connecting to MCP server...`})]})});let te=_&&v.singleTab,R=_?{backgroundColor:v.backgroundColor||`#f3f3f3`,padding:te?`0`:v.padding||`0.5rem`}:{};return(0,K.jsx)(Nm,{children:(0,K.jsxs)(`div`,{className:_?te?`h-screen flex flex-col`:`h-screen flex flex-col gap-2 sm:gap-4`:`h-screen bg-[#f3f3f3] dark:bg-black flex flex-col px-2 py-2 sm:px-4 sm:py-4 gap-2 sm:gap-4`,style:R,children:[!te&&(0,K.jsx)(_Se,{connections:r,selectedServer:P,activeTab:f,onServerSelect:A,onTabChange:p,onCommandPaletteOpen:()=>k(`button`),onOpenConnectionOptions:j,embedded:_}),(0,K.jsx)(`main`,{className:te?`flex-1 w-full bg-white dark:bg-black p-0 overflow-auto`:`flex-1 w-full mx-auto bg-white dark:bg-black rounded-2xl border border-zinc-200 dark:border-zinc-700 p-0 overflow-auto`,children:(0,K.jsx)(sSe,{selectedServer:P,activeTab:f,toolsSearchRef:T,promptsSearchRef:E,resourcesSearchRef:D,children:e})}),(0,K.jsx)(Gle,{isOpen:b,onOpenChange:x,tools:F,prompts:I,resources:L,savedRequests:w,connections:r,selectedServer:P,tunnelUrl:g,onNavigate:N,onServerSelect:A}),(0,K.jsx)(SO,{connection:S&&r.find(e=>e.id===S)||null,open:S!==null,onOpenChange:e=>{e||C(null)},onConnect:M})]})})}function J9(e){let t=a(()=>{throw Error(`Invalid url to pass to open(): ${e}`)},`abort`),n;try{n=new URL(e)}catch{t()}return n.protocol!==`https:`&&n.protocol!==`http:`&&t(),n.hostname!==encodeURIComponent(n.hostname)&&t(),n.username&&=encodeURIComponent(n.username),n.password&&=encodeURIComponent(n.password),n.pathname=n.pathname.slice(0,1)+encodeURIComponent(n.pathname.slice(1)).replace(/%2f/gi,`/`),n.search=n.search.slice(0,1)+Array.from(n.searchParams.entries()).map(Y9).join(`&`),n.hash=n.hash.slice(0,1)+encodeURIComponent(n.hash.slice(1)),n.href}a(J9,`sanitizeUrl`);function Y9([e,t]){return`${encodeURIComponent(e)}${t.length>0?`=${encodeURIComponent(t)}`:``}`}a(Y9,`sanitizeParam`);async function X9(e){return typeof e==`string`?e:e instanceof URLSearchParams||e instanceof FormData?Object.fromEntries(e.entries()):e instanceof Blob?await e.text():e}a(X9,`serializeBody`);var ySe=class{static{a(this,`BrowserOAuthClientProvider`)}serverUrl;storageKeyPrefix;serverUrlHash;clientName;clientUri;logoUri;callbackUrl;preventAutoAuth;useRedirectFlow;oauthProxyUrl;connectionUrl;originalFetch;pendingCodeVerifier=null;_lastOriginalResource=null;_cachedAuthServerUrl=null;_cachedMetadata=null;_refreshPromise=null;onPopupWindow;constructor(e,t={}){this.serverUrl=e,this.storageKeyPrefix=t.storageKeyPrefix||`mcp:auth`,this.serverUrlHash=this.hashString(e),this.clientName=t.clientName||`mcp-use`,this.clientUri=t.clientUri||(typeof window<`u`?window.location.origin:``),this.logoUri=t.logoUri||`https://mcp-use.com/logo.png`,this.callbackUrl=J9(t.callbackUrl||(typeof window<`u`?new URL(`/oauth/callback`,window.location.origin).toString():`/oauth/callback`)),this.preventAutoAuth=t.preventAutoAuth,this.useRedirectFlow=t.useRedirectFlow,this.oauthProxyUrl=t.oauthProxyUrl,this.connectionUrl=t.connectionUrl,this.onPopupWindow=t.onPopupWindow}installFetchInterceptor(){if(!this.oauthProxyUrl){console.warn(`[BrowserOAuthProvider] No OAuth proxy URL configured, skipping fetch interceptor installation`);return}if(!this.originalFetch)this.originalFetch=window.fetch;else{console.warn(`[BrowserOAuthProvider] Fetch interceptor already installed`);return}let e=this.oauthProxyUrl,t=this.connectionUrl,n=this.serverUrl,r=this.originalFetch;console.log(`[BrowserOAuthProvider] Installing fetch interceptor with proxy: ${e}`),window.fetch=async(i,a)=>{let o=typeof i==`string`?i:i instanceof URL?i.toString():i.url;if(!(o.includes(`/.well-known/`)||o.match(/\/(register|token|authorize)$/)))return await r(i,a);try{let t=new URL(o),n=new URL(e);if(t.origin===n.origin&&(t.pathname.startsWith(n.pathname)||o.includes(`/inspector/api/oauth`)))return await r(i,a)}catch{}try{let i=o.includes(`/.well-known/`),s=i?`${e}/metadata?url=${encodeURIComponent(o)}`:`${e}/proxy`;if(console.log(`[OAuth Proxy] Routing ${i?`metadata`:`request`} through: ${s}`),i){let e={...a?.headers?Object.fromEntries(new Headers(a.headers)):{}};t&&(e[`X-Connection-URL`]=t);let i=new URL(s);n&&i.searchParams.set(`mcp_url`,n);let o=await r(i.toString(),{...a,method:`GET`,headers:e});try{if((o.headers.get(`content-type`)||``).includes(`application/json`)){let e=await o.clone().json(),t=e&&typeof e==`object`&&typeof e._original_resource==`string`?e._original_resource:null;t&&(this._lastOriginalResource=t)}}catch{}return o}let c=a?.body?await X9(a.body):void 0,l=await(await r(s,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:o,method:a?.method||`POST`,headers:a?.headers?Object.fromEntries(new Headers(a.headers)):{},body:c})})).json();return new Response(JSON.stringify(l.body),{status:l.status,statusText:l.statusText,headers:new Headers(l.headers)})}catch(e){return console.error(`[OAuth Proxy] Request failed, falling back to direct fetch:`,e),await r(i,a)}}}restoreFetch(){this.originalFetch&&=(console.log(`[BrowserOAuthProvider] Restoring original fetch`),window.fetch=this.originalFetch,void 0)}get redirectUrl(){return J9(this.callbackUrl)}get clientMetadata(){return{redirect_uris:[this.redirectUrl],token_endpoint_auth_method:`none`,grant_types:[`authorization_code`,`refresh_token`],response_types:[`code`],client_name:this.clientName,client_uri:this.clientUri,logo_uri:this.logoUri}}async clientInformation(){let e=this.getKey(`client_info`),t=localStorage.getItem(e);if(t)try{let n=JSON.parse(t),r=Array.isArray(n.redirect_uris)?n.redirect_uris:[];if(!(r.length===0||r.includes(this.redirectUrl))){console.info(`[${this.storageKeyPrefix}] Invalidating cached OAuth client info due to redirect URI mismatch.`),localStorage.removeItem(e),localStorage.removeItem(this.getKey(`tokens`)),localStorage.removeItem(this.getKey(`last_auth_url`));return}return n}catch(t){console.warn(`[${this.storageKeyPrefix}] Failed to parse client information:`,t),localStorage.removeItem(e);return}}async saveClientInformation(e){let t=this.getKey(`client_info`);localStorage.setItem(t,JSON.stringify(e))}async tokens(){let e=this.getKey(`tokens`),t=localStorage.getItem(e);if(t)try{let e=JSON.parse(t);if(e.access_token&&e.refresh_token)try{let t=JSON.parse(atob(e.access_token.split(`.`)[1]));if(t.exp&&Date.now()>=(t.exp-30)*1e3){console.log(`[tokens] Access token expiring soon, refreshing...`);let t=await this._dedupedRefresh(e);if(t)return console.log(`[tokens] Refreshed successfully`),t}}catch{}return e}catch(t){console.warn(`[${this.storageKeyPrefix}] Failed to parse tokens:`,t),localStorage.removeItem(e);return}}async saveTokens(e){let t=this.getKey(`tokens`);localStorage.setItem(t,JSON.stringify(e)),localStorage.removeItem(this.getKey(`code_verifier`)),localStorage.removeItem(this.getKey(`last_auth_url`)),this.pendingCodeVerifier=null}async _refresh(e){try{if(!this._cachedAuthServerUrl||!this._cachedMetadata){let e=(await oe(this.serverUrl)).authorization_servers?.[0];if(!e)return null;let t=await ie(e);if(!t)return null;this._cachedAuthServerUrl=e,this._cachedMetadata=t}let t=await this.clientInformation();if(!t)return null;let n=await ae(this._cachedAuthServerUrl,{metadata:this._cachedMetadata,clientInformation:t,refreshToken:e.refresh_token});return await this.saveTokens(n),n}catch{return null}}async _dedupedRefresh(e){if(this._refreshPromise)return this._refreshPromise;this._refreshPromise=this._refresh(e);try{return await this._refreshPromise}finally{this._refreshPromise=null}}async invalidateCredentials(e){switch(e){case`all`:localStorage.removeItem(this.getKey(`tokens`)),localStorage.removeItem(this.getKey(`client_info`)),localStorage.removeItem(this.getKey(`code_verifier`)),localStorage.removeItem(this.getKey(`last_auth_url`)),this.pendingCodeVerifier=null;break;case`client`:localStorage.removeItem(this.getKey(`client_info`));break;case`tokens`:localStorage.removeItem(this.getKey(`tokens`));break;case`verifier`:localStorage.removeItem(this.getKey(`code_verifier`)),this.pendingCodeVerifier=null;break;default:break}}async saveCodeVerifier(e){let t=this.getKey(`code_verifier`);localStorage.setItem(t,e),this.pendingCodeVerifier=e}async codeVerifier(){let e=this.getKey(`code_verifier`),t=localStorage.getItem(e);if(!t)throw Error(`[${this.storageKeyPrefix}] Code verifier not found in storage for key ${e}. Auth flow likely corrupted or timed out.`);return t}async prepareAuthorizationUrl(e){let t=e.searchParams.get(`resource`),n=!!(t&&(t.includes(`/inspector/api/proxy`)||t.includes(`/api/proxy`)||t.includes(`localhost:3000`))),r=!!(t&&this.connectionUrl&&t===this.connectionUrl),i=!!(t&&(this._lastOriginalResource||this.serverUrl)&&(r||n)),a=this._lastOriginalResource||this.serverUrl;i&&a&&e.searchParams.set(`resource`,a);let o=globalThis.crypto.randomUUID(),s=`${this.storageKeyPrefix}:state_${o}`,c=this.pendingCodeVerifier||localStorage.getItem(this.getKey(`code_verifier`)),l={serverUrlHash:this.serverUrlHash,expiry:Date.now()+1e3*60*10,codeVerifier:c||void 0,providerOptions:{serverUrl:this.serverUrl,storageKeyPrefix:this.storageKeyPrefix,clientName:this.clientName,clientUri:this.clientUri,callbackUrl:this.callbackUrl,oauthProxyUrl:this.oauthProxyUrl,connectionUrl:this.connectionUrl},flowType:this.useRedirectFlow?`redirect`:`popup`,returnUrl:typeof window<`u`?window.location.href:void 0};console.log(`[OAuth] Storing state key: ${s}`),localStorage.setItem(s,JSON.stringify(l));let u=localStorage.getItem(s);console.log(`[OAuth] State stored successfully: ${!!u}`),e.searchParams.set(`state`,o);let d=J9(e.toString());return localStorage.setItem(this.getKey(`last_auth_url`),d),d}async redirectToAuthorization(e){let t=await this.prepareAuthorizationUrl(e);if(this.preventAutoAuth){console.info(`[${this.storageKeyPrefix}] Auto-auth prevented. Authorization URL stored for manual trigger.`);return}if(this.useRedirectFlow){console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL (full-page redirect).`),window.location.href=t;return}let n=`width=600,height=700,resizable=yes,scrollbars=yes,status=yes`;try{let e=window.open(t,`mcp_auth_${this.serverUrlHash}`,n);this.onPopupWindow&&this.onPopupWindow(t,n,e),!e||e.closed||e.closed===void 0?console.warn(`[${this.storageKeyPrefix}] Popup likely blocked by browser. Manual navigation might be required using the stored URL.`):(e.focus(),console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL in popup.`))}catch(e){console.error(`[${this.storageKeyPrefix}] Error opening popup window:`,e)}}getLastAttemptedAuthUrl(){let e=localStorage.getItem(this.getKey(`last_auth_url`));return e?J9(e):null}clearStorage(){let e=`${this.storageKeyPrefix}_${this.serverUrlHash}_`,t=`${this.storageKeyPrefix}:state_`,n=[],r=0;for(let r=0;r<localStorage.length;r++){let i=localStorage.key(r);if(i){if(i.startsWith(e))n.push(i);else if(i.startsWith(t))try{let e=localStorage.getItem(i);e&&JSON.parse(e).serverUrlHash===this.serverUrlHash&&n.push(i)}catch(e){console.warn(`[${this.storageKeyPrefix}] Error parsing state key ${i} during clearStorage:`,e)}}}return[...new Set(n)].forEach(e=>{localStorage.removeItem(e),r++}),r}hashString(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return Math.abs(t).toString(16)}getKey(e){return`${this.storageKeyPrefix}_${this.serverUrlHash}_${e}`}};async function Z9(){let e=new URLSearchParams(window.location.search),t=e.get(`code`),n=e.get(`state`),r=e.get(`error`),i=e.get(`error_description`),a=`[mcp-callback]`;console.log(`${a} Handling callback...`,{code:t,state:n,error:r,errorDescription:i});let o=null,s=null,c=null;try{if(r)throw Error(`OAuth error: ${r} - ${i||`No description provided.`}`);if(!t)throw Error(`Authorization code not found in callback query parameters.`);if(!n)throw Error(`State parameter not found or invalid in callback query parameters.`);console.log(`[mcp-callback] Looking for state: ${n}`),console.log(`[mcp-callback] All localStorage keys:`,Object.keys(localStorage));let e=`mcp:auth:state_${n}`;if(localStorage.getItem(e))c=e,console.log(`[mcp-callback] Found state with default key: ${e}`);else{let e=`:state_${n}`;for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n&&n.endsWith(e)){c=n,console.log(`[mcp-callback] Found state with dynamic key: ${n}`);break}}}if(!c){let e=Object.keys(localStorage).filter(e=>e.includes(`state`));throw console.log(`[mcp-callback] State keys in storage:`,e),Error(`Invalid or expired state parameter "${n}". No matching state found in storage.`)}let l=localStorage.getItem(c);if(!l)throw Error(`Invalid or expired state parameter "${n}". No matching state found in storage.`);try{s=JSON.parse(l)}catch{throw Error(`Failed to parse stored OAuth state.`)}if(!s.expiry||s.expiry<Date.now())throw localStorage.removeItem(c),Error(`OAuth state has expired. Please try initiating authentication again.`);if(!s.providerOptions)throw Error(`Stored state is missing required provider options.`);let{serverUrl:u,...d}=s.providerOptions,f=d.connectionUrl,p=!!(f&&/run\.mcp-use\.com|mcp-use\.run/.test(f)),m=p?f:void 0,h=d.oauthProxyUrl,g=m;if(!h&&g)try{let e=new URL(window.location.href);if(e.pathname.includes(`/oauth/callback`)){let t=e.pathname.replace(/\/oauth\/callback.*$/,``);(!t||t===``)&&(/run\.mcp-use\.com|mcp-use\.run/.test(g)?console.log(`${a} Gateway connection detected; skipping default /inspector OAuth proxy inference`):(t=`/inspector`,console.log(`${a} Callback at root /oauth/callback, using /inspector as base path for OAuth proxy`))),t&&(h=`${e.origin}${t}/api/oauth`),console.log(`${a} Inferred OAuth proxy URL from callback: ${h}`)}}catch(e){console.warn(`${a} Could not infer OAuth proxy URL:`,e)}console.log(`${a} Re-instantiating provider for server: ${u}`),o=new ySe(u,{...d,oauthProxyUrl:h,connectionUrl:g});let _=`${d.storageKeyPrefix}_${s.serverUrlHash}_code_verifier`,v=s.codeVerifier||localStorage.getItem(_);if(v)localStorage.setItem(_,v),localStorage.setItem(o.getKey(`code_verifier`),v);else throw Error(`[${d.storageKeyPrefix}] Code verifier missing for OAuth state ${n}. Please restart authentication.`);h&&(console.log(`${a} Installing fetch interceptor for token exchange (proxy: ${h})`),o.installFetchInterceptor()),console.log(`${a} Calling SDK auth() to exchange code...`);let y=p&&g?g:u;console.log(`${a} Using SDK serverUrl: ${y} (connectionUrl: ${g||`none`})`);let b=await le(o,{serverUrl:y,authorizationCode:t});if(b===`AUTHORIZED`)if(console.log(`${a} Authorization successful via SDK auth().`),s.flowType===`redirect`&&s.returnUrl)console.log(`${a} Redirect flow complete. Returning to: ${s.returnUrl}`),localStorage.removeItem(c),window.location.href=s.returnUrl;else if(window.opener&&!window.opener.closed)console.log(`${a} Popup flow complete. Notifying opener...`),window.opener.postMessage({type:`mcp_auth_callback`,success:!0},window.location.origin),localStorage.removeItem(c),window.close();else if(s.returnUrl)console.log(`${a} Popup flow without opener. Returning to: ${s.returnUrl}`),localStorage.removeItem(c),window.location.href=s.returnUrl;else{console.warn(`${a} No opener window or return URL detected. Redirecting to root.`),localStorage.removeItem(c);let e=window.location.pathname.split(`/`).filter(Boolean),t=e.length>0&&e[e.length-1]===`callback`?`/`+e.slice(0,-2).join(`/`):`/`;window.location.href=t||`/`}else throw console.warn(`${a} SDK auth() returned unexpected status: ${b}`),Error(`Unexpected result from authentication library: ${b}`)}catch(e){console.error(`${a} Error during OAuth callback handling:`,e);let t=e instanceof Error?e.message:String(e);window.opener&&!window.opener.closed&&window.opener.postMessage({type:`mcp_auth_callback`,success:!1,error:t},window.location.origin);try{document.body.innerHTML=``;let n=document.createElement(`div`);n.style.fontFamily=`sans-serif`,n.style.padding=`20px`;let r=document.createElement(`h1`);r.textContent=`Authentication Error`,n.appendChild(r);let i=document.createElement(`p`);i.style.color=`red`,i.style.backgroundColor=`#ffebeb`,i.style.border=`1px solid red`,i.style.padding=`10px`,i.style.borderRadius=`4px`,i.textContent=t,n.appendChild(i);let a=document.createElement(`p`);a.textContent=`You can close this window or `;let o=document.createElement(`a`);if(o.href=`#`,o.textContent=`click here to close`,o.onclick=e=>(e.preventDefault(),window.close(),!1),a.appendChild(o),a.appendChild(document.createTextNode(`.`)),n.appendChild(a),e instanceof Error&&e.stack){let t=document.createElement(`pre`);t.style.fontSize=`0.8em`,t.style.color=`#555`,t.style.marginTop=`20px`,t.style.whiteSpace=`pre-wrap`,t.textContent=e.stack,n.appendChild(t)}document.body.appendChild(n)}catch(e){console.error(`${a} Could not display error in callback window:`,e)}c&&localStorage.removeItem(c),o&&localStorage.removeItem(o.getKey(`last_auth_url`))}}a(Z9,`onMcpAuthorization`);async function bSe(e,t=fetch){let n=e.replace(/\/$/,``),r=await t(n.endsWith(`/mcp`)?n:`${n}/mcp`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({jsonrpc:`2.0`,method:`initialize`,id:1,params:{}})});if(r.status!==401)return{};let{resourceMetadataUrl:i,scope:a}=de(r);return{resourceMetadataUrl:i,scope:a}}a(bSe,`probeAuthParams`);function xSe(){let[e,t]=(0,G.useState)(`processing`),[n,r]=(0,G.useState)(``);return(0,G.useEffect)(()=>{console.log(`[OAuthCallback] Component mounted, handling authorization...`),console.log(`[OAuthCallback] Current URL:`,window.location.href),Z9().then(()=>{console.log(`[OAuthCallback] Authorization successful`),t(`success`)}).catch(e=>{console.error(`[OAuthCallback] Authorization failed:`,e),t(`error`),r(e instanceof Error?e.message:String(e))})},[]),e===`processing`?(0,K.jsx)(`div`,{className:`h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900`,children:(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,K.jsx)(kh,{className:`h-8 w-8 animate-spin text-zinc-600 dark:text-zinc-400`}),(0,K.jsx)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400`,children:`Completing authentication...`})]})}):e===`error`?(0,K.jsx)(`div`,{className:`h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900`,children:(0,K.jsxs)(`div`,{className:`max-w-md p-6`,children:[(0,K.jsx)(`h1`,{className:`text-xl font-semibold text-red-600 dark:text-red-400 mb-2`,children:`Authentication Error`}),(0,K.jsx)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400 mb-4`,children:n}),(0,K.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-500`,children:`You can close this window and try again.`})]})}):(0,K.jsx)(`div`,{className:`h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900`,children:(0,K.jsxs)(`div`,{className:`max-w-md p-6`,children:[(0,K.jsx)(`h1`,{className:`text-xl font-semibold text-green-600 dark:text-green-400 mb-2`,children:`Authentication Successful!`}),(0,K.jsx)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400`,children:`Redirecting you back...`})]})})}var SSe=(e,t,n,r,i,a,o,s)=>{let c=document.documentElement,l=[`light`,`dark`];function u(t){(Array.isArray(e)?e:[e]).forEach(e=>{let n=e===`class`,r=n&&a?i.map(e=>a[e]||e):i;n?(c.classList.remove(...r),c.classList.add(a&&a[t]?a[t]:t)):c.setAttribute(e,t)}),d(t)}function d(e){s&&l.includes(e)&&(c.style.colorScheme=e)}function f(){return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}if(r)u(r);else try{let e=localStorage.getItem(t)||n;u(o&&e===`system`?f():e)}catch{}},CSe=G.createContext(void 0),wSe={setTheme:e=>{},themes:[]},TSe=()=>G.useContext(CSe)??wSe;G.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:i,defaultTheme:a,value:o,themes:s,nonce:c,scriptProps:l})=>{let u=JSON.stringify([n,t,a,e,s,o,r,i]).slice(1,-1);return G.createElement(`script`,{...l,suppressHydrationWarning:!0,nonce:typeof window>`u`?c:``,dangerouslySetInnerHTML:{__html:`(${SSe.toString()})(${u})`}})});function ESe({...e}){let{theme:t=`system`}=TSe();return(0,K.jsx)(Jte,{theme:t,className:`toaster group`,style:{"--normal-bg":`var(--popover)`,"--normal-text":`var(--popover-foreground)`,"--normal-border":`var(--border)`},...e})}function DSe(){let e=new URLSearchParams(window.location.search),t=e.get(`embedded`)===`true`,n=e.get(`theme`),r=(0,G.useMemo)(()=>t?void 0:new Or(`mcp-inspector-connections`),[t]),i=window.__MCP_PROXY_URL__,a=i?`${window.location.origin}${i}`:void 0;return(0,K.jsx)(tre,{forcedTheme:n||void 0,children:(0,K.jsx)(zue,{children:(0,K.jsx)(Tr,{storageProvider:r,enableRpcLogging:!0,defaultAutoProxyFallback:a?{enabled:!0,proxyAddress:a}:!1,clientInfo:{name:`mcp-use Inspector`,version:window.__INSPECTOR_VERSION__,websiteUrl:`https://mcp-use.com`,icons:[{src:`https://mcp-use.com/logo.png`}],capabilities:{extensions:{"io.modelcontextprotocol/ui":{mimeTypes:[`text/html;profile=mcp-app`]}}}},onServerAdded:(e,t)=>{console.log(`[Inspector] Server added:`,e,t.state)},onServerRemoved:e=>{console.log(`[Inspector] Server removed:`,e)},onServerStateChange:(e,t)=>{console.log(`[Inspector] Server state changed:`,e,t)},onSamplingRequest:(e,t,n,r,i)=>{let a=xv((0,K.jsx)(Oxe,{requestId:e.id,serverName:n,onViewDetails:()=>{let t=new CustomEvent(`navigate-to-sampling`,{detail:{requestId:e.id}});window.dispatchEvent(t),xv.dismiss(a)},onApprove:t=>{r(e.id,t),xv.success(`Sampling request approved`),xv.dismiss(a)},onDeny:()=>{i(e.id,`User denied from toast`),xv.dismiss(a)}}),{duration:1/0})},onElicitationRequest:(e,t,n,r,i)=>{let a=e.request.mode||`form`,o=e.request.message,s=a===`url`&&`url`in e.request?e.request.url:void 0,c=xv((0,K.jsx)(Lr,{requestId:e.id,serverName:n,mode:a,message:o,url:s,onViewDetails:()=>{let t=new CustomEvent(`navigate-to-elicitation`,{detail:{requestId:e.id}});window.dispatchEvent(t),xv.dismiss(c)},onOpenUrl:a===`url`&&s?()=>{window.open(s,`_blank`),xv.dismiss(c)}:void 0,onCancel:()=>{i(e.id,`User cancelled from toast`),xv.dismiss(c)}}),{duration:1/0})},children:(0,K.jsxs)(dle,{children:[(0,K.jsx)(dte,{basename:`/inspector`,children:(0,K.jsxs)(k_,{children:[(0,K.jsx)(D_,{path:`/oauth/callback`,element:(0,K.jsx)(xSe,{})}),(0,K.jsx)(D_,{path:`/`,element:(0,K.jsx)(vSe,{children:(0,K.jsx)(ule,{})})})]})}),(0,K.jsx)(ESe,{position:`top-center`})]})})})})}var Q9=new URLSearchParams(window.location.search);if(Q9.has(`code`)||Q9.has(`error`))try{fn()}catch(e){console.error(`[inspector] OAuth callback error:`,e)}var $9=document.getElementById(`root`);$9?Ir.createRoot($9).render((0,K.jsx)(DSe,{})):console.error(`[inspector] Root element not found`);export{G6 as $,U$ as $n,m0 as $t,Pve as A,C1 as An,rn as Ar,b3 as At,X6 as B,m1 as Bn,R0 as Bt,O8 as C,N1 as Cn,fn as Cr,W3 as Ct,E8 as D,k1 as Dn,Zt as Dr,E3 as Dt,D8 as E,O1 as En,Xt as Er,P3 as Et,Ove as F,D1 as Fn,Qt as Fr,Y0 as Ft,R6 as G,p1 as Gn,O0 as Gt,Rve as H,h1 as Hn,N0 as Ht,Dve as I,x1 as In,an as Ir,q0 as It,K6 as J,_1 as Jn,v0 as Jt,Ave as K,s1 as Kn,j0 as Kt,Lve as L,v1 as Ln,en as Lr,J0 as Lt,H6 as M,T1 as Mn,Kt as Mr,s3 as Mt,kve as N,S1 as Nn,nn as Nr,r3 as Nt,y8 as O,A1 as On,Yt as Or,D3 as Ot,V6 as P,E1 as Pn,Jt as Pr,W4 as Pt,W6 as Q,G$ as Qn,g0 as Qt,Nve as R,b1 as Rn,qt as Rr,H0 as Rt,j8 as S,M1 as Sn,dn as Sr,U3 as St,A8 as T,F1 as Tn,Me as Tr,R3 as Tt,Eve as U,d1 as Un,M0 as Ut,$6 as V,u1 as Vn,I0 as Vt,jve as W,f1 as Wn,S0 as Wt,B6 as X,o1 as Xn,p0 as Xt,z6 as Y,l1 as Yn,_0 as Yt,J6 as Z,K$ as Zn,u0 as Zt,X8 as _,B1 as _n,gn as _r,K3 as _t,e5 as a,Ime as an,N$ as ar,M6 as at,q8 as b,R1 as bn,yn as br,B3 as bt,J8 as c,Fme as cn,O$ as cr,T6 as ct,G8 as d,K1 as dn,k$ as dr,lve as dt,h0 as en,B$ as er,q6 as et,W8 as f,G1 as fn,F$ as fr,f6 as ft,U8 as g,W1 as gn,vn as gr,q3 as gt,H8 as h,U1 as hn,xn as hr,X3 as ht,Q8 as i,c0 as in,L$ as ir,N6 as it,Y6 as j,w1 as jn,tn as jr,l3 as jt,Mve as k,j1 as kn,Wt as kr,w3 as kt,V8 as l,J1 as ln,M$ as lr,w6 as lt,Y8 as m,H1 as mn,D$ as mr,J3 as mt,c5 as n,l0 as nn,dme as nr,L6 as nt,n5 as o,X1 as on,I$ as or,D6 as ot,lbe as p,V1 as pn,P$ as pr,Z3 as pt,U6 as q,g1 as qn,f0 as qt,s5 as r,s0 as rn,R$ as rr,I6 as rt,B8 as s,Y1 as sn,A$ as sr,E6 as st,l5 as t,o0 as tn,H$ as tr,Tve as tt,obe as u,q1 as un,j$ as ur,_6 as ut,K8 as v,I1 as vn,hn as vr,G3 as vt,k8 as w,P1 as wn,Gt as wr,z3 as wt,M8 as x,z1 as xn,sn as xr,V3 as xt,z8 as y,L1 as yn,_n as yr,H3 as yt,Z6 as z,c1 as zn,$t as zr,B0 as zt};
|
|
465
|
+
`),e.document.close())}},[x]),Ae=(0,G.useCallback)(()=>{l&&(ee(``),I(!0))},[l]),je=(0,G.useCallback)(()=>{if(!l)return;let e={id:`${Date.now()}-${Math.random()}`,name:L.trim()||`${l.name} - ${new Date().toLocaleString()}`,toolName:l.name,args:we,savedAt:Date.now(),serverId:l._serverId,serverName:l._serverName};H([...N,e]),Km.getInstance().capture(new Tee({toolName:l.name,serverId:i})).catch(()=>{}),I(!1),ee(``)},[l,L,we,N,H,i]),Me=(0,G.useCallback)(e=>{H(N.filter(t=>t.id!==e)),d?.id===e&&f(null)},[N,H,d]);return ie?(0,K.jsxs)(`div`,{className:`h-full flex flex-col overflow-hidden relative bg-background`,children:[oe!==`list`&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10`,children:[(0,K.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>{oe===`response`?se(`detail`):(u(null),se(`list`))},className:`p-0 h-8 w-8`,children:(0,K.jsx)(th,{className:`h-4 w-4`})}),(0,K.jsxs)(`div`,{className:`flex items-center text-sm font-medium`,children:[(0,K.jsx)(`button`,{onClick:()=>{u(null),se(`list`)},className:`text-muted-foreground hover:text-foreground hover:underline cursor-pointer`,children:`Tools`}),oe===`detail`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`mx-2 text-muted-foreground`,children:`/`}),(0,K.jsx)(`button`,{onClick:()=>{se(`response`)},className:oe===`detail`?`text-foreground hover:underline`:oe===`response`?`text-muted-foreground hover:text-foreground hover:underline cursor-pointer`:`text-muted-foreground`,children:`Execute`})]}),oe===`response`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`mx-2 text-muted-foreground`,children:`/`}),(0,K.jsx)(`span`,{className:`text-foreground`,children:`Response`})]})]})]}),(0,K.jsx)(`div`,{className:`flex-1 relative overflow-hidden`,children:(0,K.jsxs)(OP,{initial:!1,mode:`popLayout`,children:[oe===`list`&&(0,K.jsxs)(_F.div,{initial:{x:`-100%`},animate:{x:0},exit:{x:`-100%`},transition:{type:`spring`,stiffness:300,damping:30},className:`absolute inset-0 flex flex-col bg-background z-0`,children:[(0,K.jsx)(i9,{activeTab:j,isSearchExpanded:te,searchQuery:k,filteredToolsCount:he.length,savedRequestsCount:N.length,onSearchExpand:()=>R(!0),onSearchChange:A,onSearchBlur:ve,onTabSwitch:()=>M(j===`tools`?`saved`:`tools`),searchInputRef:re,onRefresh:o?ye:void 0,isRefreshing:s}),j===`tools`?(0,K.jsx)(r9,{tools:he,selectedTool:l,onToolSelect:ge,focusedIndex:z}):(0,K.jsx)(q7,{savedRequests:N,selectedRequest:d,onLoadRequest:_e,onDeleteRequest:Me,focusedIndex:z})]},`list`),oe===`detail`&&(0,K.jsx)(_F.div,{initial:{x:`100%`},animate:{x:0},exit:{x:`-100%`},transition:{type:`spring`,stiffness:300,damping:30},className:`absolute inset-0 bg-background z-10`,children:(0,K.jsx)($7,{selectedTool:l,toolArgs:h,payloadToSend:we,isExecuting:C,isConnected:a,onArgChange:U,onExecute:Te,onSave:Ae,onBulkPaste:xe,autoFilledFields:B,setFields:_,sendEmptyFields:y,onToggleEmpty:be})},`detail`),oe===`response`&&(0,K.jsx)(_F.div,{initial:{x:`100%`},animate:{x:0},exit:{x:`100%`},transition:{type:`spring`,stiffness:300,damping:30},className:`absolute inset-0 bg-background z-20`,children:(0,K.jsx)(n9,{results:Oe,copiedResult:T,serverId:i,readResource:r,onCopy:Ee,onDelete:De,onFullscreen:ke,onRerunTool:Te})},`response`)]})}),(0,K.jsx)(J7,{isOpen:F,requestName:L,defaultPlaceholder:`${l?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ee,onSave:je,onCancel:()=>I(!1)}),(0,K.jsx)(y9,{open:ue.open,onOpenChange:e=>{e||Ce()},children:(0,K.jsxs)(b9,{children:[(0,K.jsxs)(x9,{children:[(0,K.jsx)(C9,{children:`Auto-fill fields from pasted object?`}),(0,K.jsxs)(w9,{children:[ue.fieldsToUpdate.length>0&&(0,K.jsxs)(`div`,{className:`mb-3`,children:[(0,K.jsx)(`p`,{className:`font-medium mb-2`,children:`The following fields will be updated:`}),(0,K.jsx)(`ul`,{className:`text-sm space-y-1 max-h-[200px] overflow-y-auto`,children:ue.fieldsToUpdate.map(({key:e,oldValue:t,newValue:n})=>(0,K.jsxs)(`li`,{className:`font-mono`,children:[(0,K.jsxs)(`span`,{className:`font-semibold`,children:[e,`:`]}),` `,(0,K.jsx)(`span`,{className:`text-red-600 dark:text-red-400 line-through`,children:typeof t==`object`?JSON.stringify(t).substring(0,30)+`...`:String(t).substring(0,30)}),` `,`→`,` `,(0,K.jsx)(`span`,{className:`text-green-600 dark:text-green-400`,children:typeof n==`string`&&n.length>30?n.substring(0,30)+`...`:String(n).substring(0,30)})]},e))})]}),ue.newFields.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-medium mb-1`,children:`New fields to be filled:`}),(0,K.jsx)(`p`,{className:`text-sm font-mono`,children:ue.newFields.join(`, `)})]})]})]}),(0,K.jsxs)(S9,{children:[(0,K.jsx)(E9,{onClick:Ce,children:`Cancel`}),(0,K.jsx)(T9,{onClick:Se,children:`Auto-fill`})]})]})})]}):(0,K.jsxs)(T7,{orientation:`horizontal`,className:`h-full`,children:[(0,K.jsx)(E7,{id:`left-panel`,defaultSize:`33%`,minSize:`20%`,collapsible:!0,className:`flex flex-col h-full relative`,panelRef:pe,children:(0,K.jsxs)(T7,{orientation:`vertical`,className:`h-full border-r dark:border-zinc-700`,children:[(0,K.jsx)(E7,{minSize:`30%`,children:(0,K.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,K.jsx)(i9,{activeTab:j,isSearchExpanded:te,searchQuery:k,filteredToolsCount:he.length,savedRequestsCount:N.length,onSearchExpand:()=>R(!0),onSearchChange:A,onSearchBlur:ve,onTabSwitch:()=>M(j===`tools`?`saved`:`tools`),searchInputRef:re,onRefresh:o?ye:void 0,isRefreshing:s}),j===`tools`?(0,K.jsx)(r9,{tools:he,selectedTool:l,onToolSelect:ge,focusedIndex:z}):(0,K.jsx)(q7,{savedRequests:N,selectedRequest:d,onLoadRequest:_e,onDeleteRequest:Me,focusedIndex:z})]})}),(0,K.jsx)(D7,{withHandle:!0}),(0,K.jsx)(N7,{serverId:i})]})}),(0,K.jsx)(D7,{withHandle:!0}),(0,K.jsx)(E7,{defaultSize:`67%`,children:(0,K.jsxs)(T7,{orientation:`vertical`,children:[(0,K.jsx)(E7,{defaultSize:`40%`,collapsible:!0,panelRef:me,children:(0,K.jsx)($7,{selectedTool:l,toolArgs:h,payloadToSend:we,isExecuting:C,isConnected:a,onArgChange:U,onExecute:Te,onSave:Ae,onCancel:()=>{D&&D.abort()},onBulkPaste:xe,autoFilledFields:B,setFields:_,sendEmptyFields:y,onToggleEmpty:be})}),(0,K.jsx)(D7,{withHandle:!0}),(0,K.jsx)(E7,{defaultSize:`60%`,children:(0,K.jsx)(`div`,{className:`flex flex-col h-full`,children:(0,K.jsx)(n9,{results:Oe,copiedResult:T,serverId:i,readResource:r,onCopy:Ee,onDelete:De,onFullscreen:ke,onMaximize:V,isMaximized:ce,onRerunTool:Te})})})]})}),(0,K.jsx)(J7,{isOpen:F,requestName:L,defaultPlaceholder:`${l?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ee,onSave:je,onCancel:()=>I(!1)}),(0,K.jsx)(y9,{open:ue.open,onOpenChange:e=>{e||Ce()},children:(0,K.jsxs)(b9,{children:[(0,K.jsxs)(x9,{children:[(0,K.jsx)(C9,{children:`Auto-fill fields from pasted object?`}),(0,K.jsxs)(w9,{children:[ue.fieldsToUpdate.length>0&&(0,K.jsxs)(`div`,{className:`mb-3`,children:[(0,K.jsx)(`p`,{className:`font-medium mb-2`,children:`The following fields will be updated:`}),(0,K.jsx)(`ul`,{className:`text-sm space-y-1 max-h-[200px] overflow-y-auto`,children:ue.fieldsToUpdate.map(({key:e,oldValue:t,newValue:n})=>(0,K.jsxs)(`li`,{className:`font-mono`,children:[(0,K.jsxs)(`span`,{className:`font-semibold`,children:[e,`:`]}),` `,(0,K.jsx)(`span`,{className:`text-red-600 dark:text-red-400 line-through`,children:typeof t==`object`?JSON.stringify(t).substring(0,30)+`...`:String(t).substring(0,30)}),` `,`→`,` `,(0,K.jsx)(`span`,{className:`text-green-600 dark:text-green-400`,children:typeof n==`string`&&n.length>30?n.substring(0,30)+`...`:String(n).substring(0,30)})]},e))})]}),ue.newFields.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-medium mb-1`,children:`New fields to be filled:`}),(0,K.jsx)(`p`,{className:`text-sm font-mono`,children:ue.newFields.join(`, `)})]})]})]}),(0,K.jsxs)(S9,{children:[(0,K.jsx)(E9,{onClick:Ce,children:`Cancel`}),(0,K.jsx)(T9,{onClick:Se,children:`Auto-fill`})]})]})})]})}O9.displayName=`ToolsTab`;function sSe({selectedServer:e,activeTab:t,toolsSearchRef:n,promptsSearchRef:r,resourcesSearchRef:i,children:a}){let{embeddedConfig:o}=SF();if(!e&&o.forceConnected)return o.chatApiUrl?(0,K.jsx)(m5,{connection:{id:`force-connected`,url:``,name:``,state:`ready`,tools:[],prompts:[],resources:[]},isConnected:!0,prompts:[],serverId:`force-connected`,callPrompt:async()=>({messages:[]}),readResource:async()=>({contents:[]}),useClientSide:!1,chatApiUrl:o.chatApiUrl,managedLlmConfig:o.managedLlmConfig??{provider:`anthropic`,model:`server-managed`,apiKey:`server-managed`},hideTitle:o.chatHideTitle,hideModelBadge:o.chatHideModelBadge??!0,hideServerUrl:o.chatHideServerUrl??!0,clearButtonLabel:o.chatClearButtonLabel,clearButtonHideIcon:o.chatClearButtonHideIcon,clearButtonHideShortcut:o.chatClearButtonHideShortcut,clearButtonVariant:o.chatClearButtonVariant,chatQuickQuestions:o.chatQuickQuestions,chatFollowups:o.chatFollowups,hideClearButton:o.chatHideClearButton,hideToolSelector:o.chatHideToolSelector,enableKeyboardShortcuts:!1},`chat-force-connected`):(0,K.jsx)(K.Fragment,{children:a});if(!e)return(0,K.jsx)(K.Fragment,{children:a});let s=e=>o.visibleTabs?o.visibleTabs.includes(e):!0;return(0,K.jsxs)(K.Fragment,{children:[s(`tools`)&&(0,K.jsx)(`div`,{style:{display:t===`tools`?`block`:`none`},className:`h-full`,children:(0,K.jsx)(O9,{ref:n,tools:e.tools,callTool:e.callTool,readResource:e.readResource,serverId:e.id,isConnected:e.state===`ready`,refreshTools:e.refreshTools},`tools-${e.id}`)}),s(`prompts`)&&(0,K.jsx)(`div`,{style:{display:t===`prompts`?`block`:`none`},className:`h-full`,children:(0,K.jsx)(B7,{ref:r,prompts:e.prompts,callPrompt:(t,n)=>e.getPrompt(t,n?Object.fromEntries(Object.entries(n).map(([e,t])=>[e,typeof t==`string`?t:String(t??``)])):void 0),serverId:e.id,isConnected:e.state===`ready`,refreshPrompts:e.refreshPrompts},`prompts-${e.id}`)}),s(`resources`)&&(0,K.jsx)(`div`,{style:{display:t===`resources`?`block`:`none`},className:`h-full`,children:(0,K.jsx)(K7,{ref:i,resources:e.resources,readResource:e.readResource,serverId:e.id,isConnected:e.state===`ready`,mcpServerUrl:e.url||``,refreshResources:e.refreshResources},`resources-${e.id}`)}),s(`chat`)&&(0,K.jsx)(`div`,{style:{display:t===`chat`?`block`:`none`},className:`h-full`,children:(0,K.jsx)(m5,{connection:e,isConnected:o.forceConnected||e.state===`ready`,prompts:e.prompts,serverId:e.id,callPrompt:e.getPrompt,readResource:e.readResource,useClientSide:!o.chatApiUrl,chatApiUrl:o.chatApiUrl,managedLlmConfig:o.managedLlmConfig??(o.chatApiUrl?{provider:`anthropic`,model:`server-managed`,apiKey:`server-managed`}:void 0),hideTitle:o.chatHideTitle,hideModelBadge:o.chatHideModelBadge??!!o.chatApiUrl,hideServerUrl:o.chatHideServerUrl??!!o.chatApiUrl,clearButtonLabel:o.chatClearButtonLabel,clearButtonHideIcon:o.chatClearButtonHideIcon,clearButtonHideShortcut:o.chatClearButtonHideShortcut,clearButtonVariant:o.chatClearButtonVariant,chatQuickQuestions:o.chatQuickQuestions,chatFollowups:o.chatFollowups,hideClearButton:o.chatHideClearButton,hideToolSelector:o.chatHideToolSelector},`chat-${e.id}`)}),s(`sampling`)&&(0,K.jsx)(`div`,{style:{display:t===`sampling`?`block`:`none`},className:`h-full`,children:(0,K.jsx)(kxe,{pendingRequests:e.pendingSamplingRequests,onApprove:e.approveSampling,onReject:e.rejectSampling,serverId:e.id,isConnected:e.state===`ready`,mcpServerUrl:e.url},`sampling-${e.id}`)}),s(`elicitation`)&&(0,K.jsx)(`div`,{style:{display:t===`elicitation`?`block`:`none`},className:`h-full`,children:(0,K.jsx)(cxe,{pendingRequests:e.pendingElicitationRequests,onApprove:e.approveElicitation,onReject:e.rejectElicitation,serverId:e.id,isConnected:e.state===`ready`},`elicitation-${e.id}`)}),s(`notifications`)&&(0,K.jsx)(`div`,{style:{display:t===`notifications`?`block`:`none`},className:`h-full`,children:(0,K.jsx)(fxe,{notifications:e.notifications,unreadCount:e.unreadNotificationCount,markNotificationRead:e.markNotificationRead,markAllNotificationsRead:e.markAllNotificationsRead,clearNotifications:e.clearNotifications,serverId:e.id,isConnected:e.state===`ready`},`notifications-${e.id}`)}),![`tools`,`prompts`,`resources`,`chat`,`sampling`,`elicitation`,`notifications`].includes(t)&&(0,K.jsx)(K.Fragment,{children:a})]})}function k9({className:e}){return(0,K.jsxs)(`svg`,{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`,className:e,children:[(0,K.jsx)(`path`,{d:`M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4`}),(0,K.jsx)(`path`,{d:`M9 18c-4.51 2-5-2-7-2`})]})}var A9=G.createContext(void 0);function j9(){let e=G.use(A9);if(!e)throw Error(`useTabs must be used within a TabsProvider`);return e}var M9=G.createContext(void 0);function cSe(){return G.use(M9)}function N9({ref:e,children:t,defaultValue:n,value:r,onValueChange:i,className:a,collapsed:o,onCollapsedChange:s,...c}){let[l,u]=G.useState(n||``),d=r!==void 0,f=o!==void 0,[p,m]=G.useState(!1),h=G.useCallback(e=>{d||u(e),i?.(e)},[d,i]);return(0,K.jsx)(A9,{value:{activeValue:d?r:l,handleValueChange:h,collapsed:f?o:p,handleCollapsedChange:G.useCallback(e=>{f||m(e),s?.(e)},[f,s])},children:(0,K.jsx)(`div`,{ref:e,className:q(`flex flex-col gap-2`,a),...c,children:t})})}N9.displayName=`Tabs`;function P9({ref:e,children:t,className:n,variant:r=`default`,collapsible:i=!1,...a}){let{activeValue:o,collapsed:s,handleCollapsedChange:c}=j9(),[l,u]=G.useState({width:0,left:0}),d=G.useRef(null),f=G.useRef(null),p=G.useRef(null),m=G.useCallback(()=>{let e=d.current;if(!e)return;let t=e.querySelector(`div:first-child`);if(!t)return;let n=t.querySelector(`button[data-tab-value="${o}"]`);if(n&&o){let e=t.getBoundingClientRect(),r=n.getBoundingClientRect();u({width:r.width,left:r.left-e.left})}else u({width:0,left:0})},[o]),h=G.useCallback(()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(m,16)},[m]);G.useEffect(()=>{let e=setTimeout(m,10);return()=>clearTimeout(e)},[m,s]),G.useEffect(()=>{let e=d.current;if(!e)return;f.current=new ResizeObserver(()=>{h()}),f.current.observe(e);let t=e.querySelector(`div:first-child`);return t&&t.querySelectorAll(`button[data-tab-value]`).forEach(e=>{f.current&&f.current.observe(e)}),()=>{f.current&&f.current.disconnect(),p.current&&clearTimeout(p.current)}},[h]),G.useEffect(()=>{let e=()=>{h()};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[h]);let g=G.useRef(null);return G.useEffect(()=>{g.current&&(g.current.style.width=`${l.width}px`,g.current.style.left=`${l.left}px`)},[l]),(0,K.jsx)(M9,{value:{variant:r,collapsed:s,handleCollapsedChange:c},children:(0,K.jsx)(`div`,{ref:d,className:q(`relative flex items-center bg-none gap-1`,r===`default`&&`p-1 rounded-full border border-zinc-300 dark:border-zinc-600`,r===`underline`&&`border-b border-zinc-200 dark:border-zinc-700`,n),...a,children:(0,K.jsxs)(`div`,{role:`tablist`,className:`flex-1 flex items-center relative`,children:[t,(0,K.jsx)(`span`,{ref:g,className:q(`absolute transition-all duration-500 ease-in-out z-0`,r===`default`&&`bg-white dark:bg-zinc-700 rounded-full h-[calc(100%)] top-0 border border-zinc-300 dark:border-zinc-600`,r===`underline`&&`bottom-0 h-0.5 bg-black dark:bg-white`)})]})})})}P9.displayName=`TabsList`;var lSe=({children:e,title:t,collapsed:n})=>!t||!n?e:(0,K.jsx)(Nm,{children:(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{children:e}),(0,K.jsx)(Im,{children:t})]})}),F9=G.forwardRef(({children:e,value:t,className:n,disabled:r,icon:i,title:a,showDot:o=!1,...s},c)=>{let{activeValue:l,handleValueChange:u,collapsed:d}=j9(),f=cSe()?.variant||`default`,p=l===t,m=d&&a?a:void 0;return(0,K.jsx)(lSe,{title:a,collapsed:d,children:(0,K.jsxs)(`button`,{ref:c,disabled:r,onClick:()=>u(t),"data-tab-value":t,"data-tab-active":p,role:`tab`,"aria-selected":p?`true`:`false`,title:m,className:q(`relative z-10 flex-1 inline-flex items-center justify-center whitespace-nowrap text-sm font-medium ring-offset-background transition-all duration-500 ease-in-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 cursor-pointer`,f===`default`&&`py-2.5`,f===`default`&&`rounded-md px-4`,f===`underline`&&`px-6 py-3 border-b-2 border-transparent`,p&&`text-foreground`,!p&&`text-muted-foreground hover:text-foreground`,n),...s,children:[i&&(0,K.jsx)(i,{className:q(`h-4 w-4 transition-all duration-500 ease-in-out`,!d&&`mr-2`,d&&`mr-0!`)}),o&&(0,K.jsx)(`span`,{className:`absolute top-1.5 right-1.5 w-2 h-2 bg-orange-500 dark:bg-orange-400 border-2 border-white dark:border-zinc-900 rounded-full transition-opacity duration-300 z-10 animate-status-pulse-orange`}),(0,K.jsx)(`span`,{className:q(`transition-all duration-500 ease-in-out overflow-hidden`,d?`w-0 opacity-0`:`w-auto opacity-100`),children:e})]})})});F9.displayName=`TabsTrigger`;function uSe({ref:e,children:t,value:n,className:r,...i}){let{activeValue:a}=j9();return a===n?(0,K.jsx)(`div`,{ref:e,role:`tabpanel`,className:q(`mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,r),...i,children:t}):null}uSe.displayName=`TabsContent`;function I9({serverConfig:e,additionalItems:t=[],showClients:n={cursor:!0,vsCode:!0,vsCodeInsiders:!0,claudeDesktop:!0,claudeCode:!0,geminiCli:!0,codexCli:!0},className:r=``,onSuccess:i,onError:a,trigger:o}){let[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)(!1),{url:p,name:m,headers:h}=e,g=()=>{try{let e=tI(p,m,h);window.location.href=e,i?.(`Cursor`)}catch(e){console.error(`Failed to generate Cursor deep link:`,e),a?.(e)}},_=()=>{try{let e=nI(p,m,h);window.location.href=e,i?.(`VS Code`)}catch(e){console.error(`Failed to generate VS Code deep link:`,e),a?.(e)}},v=()=>{try{let e=rI(p,m,h);window.location.href=e,i?.(`VS Code Insiders`)}catch(e){console.error(`Failed to generate VS Code Insiders deep link:`,e),a?.(e)}},y=()=>{try{iI(p,m,h),i?.(`Claude Desktop`)}catch(e){console.error(`Failed to download .mcpb file:`,e),a?.(e)}},b=()=>{u(`claude-code`),c(!0)},x=()=>{u(`gemini-cli`),c(!0)},S=()=>{u(`codex-cli`),c(!0)},C=async e=>{try{await rg(e),f(!0),setTimeout(()=>f(!1),2e3)}catch(e){console.error(`Failed to copy:`,e),a?.(e)}},w=()=>{if(l===`claude-code`){let{command:e,envVars:t}=aI(p,m,h),n=cI(t);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(sy,{children:[(0,K.jsx)(cy,{children:`Add to Claude Code`}),(0,K.jsx)(ly,{children:`Execute the following command in your shell to add this server to Claude Code.`})]}),(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h5`,{className:`font-semibold text-sm mb-2`,children:`Instructions`}),(0,K.jsxs)(`ol`,{className:`space-y-2 text-xs text-muted-foreground`,children:[(0,K.jsxs)(`li`,{className:`flex gap-2`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-foreground`,children:`1.`}),(0,K.jsx)(`span`,{children:`Ensure the Claude Code executable is available in your path`})]}),(0,K.jsxs)(`li`,{className:`flex gap-2`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-foreground`,children:`2.`}),(0,K.jsx)(`span`,{children:`Execute the following snippet in your shell:`})]})]})]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`div`,{className:`absolute top-2 right-2 z-10`,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-7 px-2 bg-background hover:bg-accent border border-border`,onClick:()=>C(e),children:d?(0,K.jsx)($m,{className:`size-3.5 text-green-600`}):(0,K.jsx)(uh,{className:`size-3.5`})})}),(0,K.jsx)(`pre`,{className:`bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto`,children:(0,K.jsx)(`code`,{children:e})})]}),n&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h5`,{className:`font-semibold text-sm mb-2`,children:`Environment Variables`}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground mb-2`,children:`After installation, set these environment variables in your shell:`}),(0,K.jsx)(`pre`,{className:`bg-muted p-3 rounded-md text-xs overflow-x-auto`,children:(0,K.jsx)(`code`,{children:n})})]}),(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`The MCP configuration supports environment variable expansion using `,(0,K.jsx)(`code`,{className:`text-foreground`,children:"${VAR}"}),` `,`syntax.`]})]})]})}if(l===`gemini-cli`){let{command:e,envVars:t}=oI(p,m,h),n=cI(t);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(sy,{children:[(0,K.jsx)(cy,{children:`Add to Gemini CLI`}),(0,K.jsx)(ly,{children:`Execute the following command in your shell to add this server to Gemini CLI.`})]}),(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h5`,{className:`font-semibold text-sm mb-2`,children:`Instructions`}),(0,K.jsxs)(`ol`,{className:`space-y-2 text-xs text-muted-foreground`,children:[(0,K.jsxs)(`li`,{className:`flex gap-2`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-foreground`,children:`1.`}),(0,K.jsx)(`span`,{children:`Ensure the Gemini CLI executable is available in your path`})]}),n&&(0,K.jsxs)(`li`,{className:`flex gap-2`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-foreground`,children:`2.`}),(0,K.jsx)(`span`,{children:`Set these environment variables in your shell before running the command:`})]}),(0,K.jsxs)(`li`,{className:`flex gap-2`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-foreground`,children:n?`3.`:`2.`}),(0,K.jsx)(`span`,{children:`Execute the following snippet in your shell:`})]})]})]}),n&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h5`,{className:`font-semibold text-sm mb-2`,children:`Environment Variables`}),(0,K.jsx)(`pre`,{className:`bg-muted p-3 rounded-md text-xs overflow-x-auto`,children:(0,K.jsx)(`code`,{children:n})})]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`div`,{className:`absolute top-2 right-2 z-10`,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-7 px-2 bg-background hover:bg-accent border border-border`,onClick:()=>C(e),children:d?(0,K.jsx)($m,{className:`size-3.5 text-green-600`}):(0,K.jsx)(uh,{className:`size-3.5`})})}),(0,K.jsx)(`pre`,{className:`bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto`,children:(0,K.jsx)(`code`,{children:e})})]}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Restart Gemini CLI to load the new configuration.`})]})]})}if(l===`codex-cli`){let{config:e,envVars:t}=sI(p,m,h);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(sy,{children:[(0,K.jsx)(cy,{children:`Add to Codex CLI`}),(0,K.jsxs)(ly,{children:[`Add this configuration to your`,` `,(0,K.jsx)(`code`,{className:`text-foreground`,children:`~/.codex/config.toml`}),` `,`file.`]})]}),(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h5`,{className:`font-semibold text-sm mb-2`,children:`Instructions`}),(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Add this configuration to your`,` `,(0,K.jsx)(`code`,{className:`text-foreground`,children:`~/.codex/config.toml`}),`:`]})]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`div`,{className:`absolute top-2 right-2 z-10`,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-7 px-2 bg-background hover:bg-accent border border-border`,onClick:()=>C(e),children:d?(0,K.jsx)($m,{className:`size-3.5 text-green-600`}):(0,K.jsx)(uh,{className:`size-3.5`})})}),(0,K.jsx)(`pre`,{className:`bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto`,children:(0,K.jsx)(`code`,{children:e})})]}),t.length>0&&(0,K.jsx)(`div`,{children:(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`(optional) If you would rather use variables from your system's environment, replace the`,` `,(0,K.jsx)(`code`,{className:`text-foreground`,children:`http_headers`}),` key with the `,(0,K.jsx)(`code`,{className:`text-foreground`,children:`env_http_headers`}),` `,`key as shown in the commented section above.`]})}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Restart Codex CLI to load the new configuration.`})]})]})}return null},T=(0,K.jsxs)(J,{variant:`ghost`,className:`bg-zinc-200 dark:bg-zinc-800 hover:bg-zinc-300 dark:hover:bg-zinc-700 rounded-full transition-colors px-3 flex items-center justify-center ${r}`,children:[(0,K.jsxs)(`span`,{className:`xl:hidden hidden sm:flex items-center gap-1`,children:[(0,K.jsx)(Lh,{className:`size-3`}),`Client`]}),(0,K.jsxs)(`span`,{className:`hidden xl:flex items-center gap-1`,children:[`Add to Client`,(0,K.jsx)(eh,{className:`size-3`})]})]});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Jp,{children:[(0,K.jsx)(Yp,{asChild:!0,children:o?typeof o==`function`?o({isOpen:!1,onClick:()=>{}}):o:T}),(0,K.jsxs)(Xp,{align:`end`,className:`w-auto min-w-[300px]`,children:[t.map(e=>(0,K.jsxs)(Zp,{onClick:async()=>{await e.onClick()},className:`flex items-center gap-2`,children:[e.icon,(0,K.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:e.label})]},e.id)),t.length>0&&(0,K.jsx)(em,{}),n.cursor&&(0,K.jsxs)(Zp,{onClick:g,className:`flex items-center gap-2`,children:[(0,K.jsx)(`img`,{src:`https://cdn.simpleicons.org/cursor`,alt:`Cursor`,className:`h-4 w-4`}),(0,K.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:`Cursor`})]}),n.claudeCode&&(0,K.jsxs)(Zp,{onClick:b,className:`flex items-center gap-2`,children:[(0,K.jsx)(`img`,{src:`https://cdn.simpleicons.org/claude`,alt:`Claude`,className:`h-4 w-4`}),(0,K.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:`Claude Code`})]}),n.claudeDesktop&&(0,K.jsxs)(Zp,{onClick:y,className:`flex items-center gap-2`,children:[(0,K.jsx)(`img`,{src:`https://cdn.simpleicons.org/claude`,alt:`Claude`,className:`h-4 w-4`}),(0,K.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:`Claude Desktop`})]}),n.vsCode&&(0,K.jsxs)(Zp,{onClick:_,className:`flex items-center gap-2`,children:[(0,K.jsx)(lI,{className:`h-4 w-4 text-blue-500`}),(0,K.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:`VS Code`})]}),n.vsCodeInsiders&&(0,K.jsxs)(Zp,{onClick:v,className:`flex items-center gap-2`,children:[(0,K.jsx)(lI,{className:`h-4 w-4 text-teal-400`}),(0,K.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:`VS Code Insiders`})]}),n.geminiCli&&(0,K.jsxs)(Zp,{onClick:x,className:`flex items-center gap-2`,children:[(0,K.jsx)(`img`,{src:`https://cdn.simpleicons.org/googlegemini`,alt:`Gemini`,className:`h-4 w-4`}),(0,K.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:`Gemini CLI`})]}),n.codexCli&&(0,K.jsxs)(Zp,{onClick:S,className:`flex items-center gap-2`,children:[(0,K.jsx)(`img`,{src:`https://inspector-cdn.mcp-use.com/providers/openai.png`,alt:`Codex`,className:`h-4 w-4`}),(0,K.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:`Codex CLI`})]})]})]}),(0,K.jsx)(iy,{open:s,onOpenChange:c,children:(0,K.jsx)(oy,{className:`max-w-3xl max-h-[80vh] overflow-y-auto`,children:w()})})]})}function L9({className:e,state:t=`collapsed`,href:n=`https://mcp-use.com`}){let[r,i]=(0,G.useState)(!1),a=.2,o=.7,s=a+o+.6,c=a/s,l=(a+o)/s;return(0,K.jsxs)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,className:q(`flex items-center transition-opacity -my-3`,t===`expanded`?`space-x-2`:``,e),onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[(0,K.jsx)(`div`,{className:`relative`,children:(0,K.jsxs)(_F.svg,{viewBox:`0 0 303 303`,initial:`rest`,animate:r?`hover`:`rest`,className:q(`text-foreground`,t===`expanded`?`size-[40px]`:`size-[20px]`),children:[(0,K.jsxs)(_F.g,{variants:{rest:{opacity:1},hover:{opacity:[1,0,0,1],transition:{duration:s,times:[0,c,l,1],ease:`easeInOut`}}},fill:`currentColor`,fillRule:`nonzero`,stroke:`currentColor`,strokeWidth:4,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`path`,{d:`m105.5 34.8.6.6c9.5 9.5 14.4 21.9 14.6 34.4a112.6 112.6 0 0 0 112.2 112.1h.6c12 .4 24 5.1 33.2 14.1l.6.6a50 50 0 0 1-70.1 71.3l-.6-.6A49.9 49.9 0 0 1 182 230 112.6 112.6 0 0 0 73.4 120.7h-.8a49.9 49.9 0 0 1-36.7-14l-.5-.6a50 50 0 0 1-.6-70.2l.6-.5a50 50 0 0 1 69.5-1.2l.6.6Z`}),(0,K.jsx)(`circle`,{cx:`70.3`,cy:`232.3`,r:`50`}),(0,K.jsx)(`circle`,{cx:`232.3`,cy:`70.3`,r:`50`})]}),(0,K.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeWidth:4,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(dSe,{d:`m105.5 34.8.6.6c9.5 9.5 14.4 21.9 14.6 34.4a112.6 112.6 0 0 0 112.2 112.1h.6c12 .4 24 5.1 33.2 14.1l.6.6a50 50 0 0 1-70.1 71.3l-.6-.6A49.9 49.9 0 0 1 182 230 112.6 112.6 0 0 0 73.4 120.7h-.8a49.9 49.9 0 0 1-36.7-14l-.5-.6a50 50 0 0 1-.6-70.2l.6-.5a50 50 0 0 1 69.5-1.2l.6.6Z`,times:{T0:0,T1:c,T2:l,T3:1},total:s}),(0,K.jsx)(R9,{cx:70.3,cy:232.3,r:50,times:{T0:0,T1:c,T2:l,T3:1},total:s}),(0,K.jsx)(R9,{cx:232.3,cy:70.3,r:50,times:{T0:0,T1:c,T2:l,T3:1},total:s})]})]})}),t===`expanded`&&(0,K.jsxs)(`div`,{className:`font-ubuntu flex-col items-start -space-y-1 mr-3 hidden xl:flex`,children:[(0,K.jsx)(`h1`,{className:`text-xl font-medium`,children:`mcp-use`}),(0,K.jsx)(`span`,{className:`text-lg text-muted-foreground tracking-wide font-sans font-light`,children:`Inspector`})]})]})}function dSe({d:e,times:t,total:n}){let{T0:r,T1:i,T2:a,T3:o}=t;return(0,K.jsx)(_F.path,{d:e,variants:{rest:{pathLength:0,opacity:0},hover:{pathLength:[0,0,1,1],opacity:[0,0,1,1],transition:{duration:n,times:[r,i,a,o],ease:`easeInOut`}}}})}function R9({cx:e,cy:t,r:n,times:r,total:i}){let{T0:a,T1:o,T2:s,T3:c}=r;return(0,K.jsx)(_F.circle,{cx:e,cy:t,r:n,variants:{rest:{pathLength:0,opacity:0},hover:{pathLength:[0,0,1,1],opacity:[0,0,1,1],transition:{duration:i,times:[a,o,s,c],ease:`easeInOut`}}}})}function z9({open:e,onOpenChange:t,serverUrl:n,serverName:r,serverId:i,headers:a,language:o}){let{prismStyle:s}=Hb(),[c,l]=(0,G.useState)(!1),u=o===`typescript`?zle(n,r,i,a):Ble(n,r,i,a),d=async()=>{await rg(u),l(!0),setTimeout(()=>l(!1),2e3)},f=o===`typescript`?`TypeScript`:`Python`;return(0,K.jsx)(iy,{open:e,onOpenChange:t,children:(0,K.jsxs)(oy,{className:`max-w-[90vw] max-h-[90vh] overflow-hidden flex flex-col`,children:[(0,K.jsxs)(sy,{children:[(0,K.jsxs)(cy,{children:[`Add to `,f,` SDK`]}),(0,K.jsxs)(ly,{children:[`Copy the following code to integrate this server into your`,` `,f,` application using the mcp-use SDK.`]})]}),(0,K.jsxs)(`div`,{className:`space-y-4 overflow-y-auto flex-1 min-h-0`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h5`,{className:`font-semibold text-sm mb-2`,children:`Instructions`}),(0,K.jsxs)(`ol`,{className:`space-y-2 text-xs text-muted-foreground`,children:[(0,K.jsxs)(`li`,{className:`flex gap-2`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-foreground`,children:`1.`}),(0,K.jsxs)(`span`,{children:[`Install the mcp-use package:`,` `,(0,K.jsx)(`code`,{className:`text-foreground`,children:o===`typescript`?`npm install mcp-use`:`pip install mcp-use`})]})]}),(0,K.jsxs)(`li`,{className:`flex gap-2`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-foreground`,children:`2.`}),(0,K.jsxs)(`span`,{children:[`Copy the following code into your `,f,` project:`]})]})]})]}),(0,K.jsxs)(`div`,{className:`relative w-full overflow-x-auto overflow-y-auto max-h-[60vh]`,children:[(0,K.jsx)(`div`,{className:`absolute top-2 right-2 z-10`,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-7 px-2 bg-background hover:bg-accent border border-border`,onClick:d,children:c?(0,K.jsx)($m,{className:`size-3.5 text-green-600`}):(0,K.jsx)(uh,{className:`size-3.5`})})}),(0,K.jsx)(yO,{language:o,style:s,customStyle:{margin:0,padding:`1rem`,paddingRight:`3rem`,borderRadius:`0.5rem`,fontSize:`0.75rem`,background:`var(--muted)`,width:`100%`,maxWidth:`100%`,overflow:`auto`},wrapLines:!0,wrapLongLines:!0,PreTag:`div`,children:u})]})]})]})})}function B9({ref:e,shimmerColor:t,shimmerSize:n=`0.05em`,shimmerDuration:r=`3s`,borderRadius:i=`100px`,background:a,className:o,children:s,...c}){let{theme:l}=bb(),u=l===`dark`?`#000000`:`#ffffff`,d=l===`dark`?`rgba(255, 255, 255, 1)`:`rgba(0, 0, 0, 1)`,f=t||u,p=a||d;return(0,K.jsxs)(`button`,{style:{"--spread":`90deg`,"--shimmer-color":f,"--radius":i,"--speed":r,"--cut":n,"--bg":p},className:q(`group relative z-0 flex cursor-pointer items-center justify-center overflow-hidden [border-radius:var(--radius)] border px-6 py-3 whitespace-nowrap [background:var(--bg)]`,`transform-gpu transition-transform duration-300 ease-in-out active:translate-y-px`,`dark:text-white text-black dark:border-white/10 border-black/10`,o),ref:e,...c,children:[(0,K.jsx)(`div`,{className:q(`-z-30 blur-[2px]`,`@container-[size] absolute inset-0 overflow-visible`),children:(0,K.jsx)(`div`,{className:`animate-shimmer-slide absolute inset-0 aspect-[1] h-[100cqh] rounded-none mask-none`,children:(0,K.jsx)(`div`,{className:`animate-spin-around absolute -inset-full w-auto [translate:0_0] rotate-0 [background:conic-gradient(from_calc(270deg-(var(--spread)*0.5)),transparent_0,var(--shimmer-color)_var(--spread),transparent_var(--spread))]`})})}),s,(0,K.jsx)(`div`,{className:q(`absolute inset-0 size-full`,`rounded-2xl px-4 py-1.5 text-sm font-medium`,`transform-gpu transition-all duration-300 ease-in-out`,`dark:shadow-[inset_0_-8px_10px_#0000001f] dark:group-hover:shadow-[inset_0_-6px_10px_#0000003f] dark:group-active:shadow-[inset_0_-10px_10px_#0000003f] shadow-[inset_0_-8px_10px_#ffffff1f] group-hover:shadow-[inset_0_-6px_10px_#ffffff3f] group-active:shadow-[inset_0_-10px_10px_#ffffff3f]`)}),(0,K.jsx)(`div`,{className:q(`absolute [inset:var(--cut)] -z-20 [border-radius:var(--radius)] bg-black dark:bg-white`)})]})}B9.displayName=`ShimmerButton`;function V9({status:e}){let{color:t,ringColor:n,tooltip:r}=(e=>{switch(e){case`ready`:return{color:`bg-emerald-500`,ringColor:`ring-emerald-500`,tooltip:`Connected`};case`failed`:return{color:`bg-red-500`,ringColor:`ring-red-500`,tooltip:`Failed`};default:return{color:`bg-yellow-500`,ringColor:`ring-yellow-500`,tooltip:e}}})(e);return(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`div`,{className:`absolute w-2 h-2 rounded-full ${n} animate-ping`}),(0,K.jsx)(`div`,{className:`relative w-2 h-2 rounded-full ${t}`})]})}),(0,K.jsx)(Im,{children:(0,K.jsx)(`p`,{children:r})})]})}function H9({connections:e,selectedServer:t,onServerSelect:n,onOpenConnectionOptions:r,mobileMode:i=!1}){let a=n_(),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(null),u=t=>{let r=e.find(e=>e.id===t);if(!r||r.state!==`ready`){xv.error(`Server is not connected and cannot be inspected`);return}n(t)};return i?(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`relative`,children:(0,K.jsxs)(Jp,{children:[(0,K.jsx)(Yp,{asChild:!0,children:(0,K.jsxs)(J,{variant:`ghost`,className:`h-11 px-2 bg-black dark:bg-white text-white dark:text-black border-black dark:border-white hover:bg-gray-800 dark:hover:bg-zinc-100 hover:border-gray-800 dark:hover:border-zinc-200 flex items-center gap-1.5`,children:[t?(0,K.jsx)(bF,{server:t,size:`md`}):(0,K.jsx)(Hh,{className:`h-5 w-5`}),(0,K.jsx)(eh,{className:`h-4 w-4`})]})}),(0,K.jsxs)(Xp,{className:`w-[calc(100vw-2rem)] sm:w-[300px]`,align:`start`,children:[(0,K.jsx)($p,{className:`cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800`,onClick:()=>a(`/`),children:`MCP Servers`}),(0,K.jsx)(em,{}),e.length===0?(0,K.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground dark:text-zinc-400 text-center`,children:`No servers connected. Go to the dashboard to add one.`}):e.map(e=>(0,K.jsxs)(Zp,{onClick:()=>u(e.id),className:`flex items-center gap-3`,children:[(0,K.jsx)(bF,{server:e,size:`sm`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-1`,children:[(0,K.jsx)(`div`,{className:`font-medium`,children:e.name}),(0,K.jsx)(V9,{status:e.state})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800`,onClick:t=>{t.stopPropagation(),l(e),s(!0)},children:(0,K.jsx)(Dh,{className:`h-3 w-3`})}),(0,K.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800`,onClick:t=>{t.stopPropagation(),r(e.id)},children:(0,K.jsx)(Uh,{className:`h-3 w-3`})})]})]},e.id)),(0,K.jsx)(em,{}),(0,K.jsx)(Zp,{onClick:()=>a(`/`),children:(0,K.jsx)(`span`,{className:`text-blue-600 dark:text-blue-400`,children:`+ Add new server`})})]})]})}),(0,K.jsx)(xO,{open:o,onOpenChange:s,connection:c})]}):(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)(Jp,{children:[(0,K.jsx)(Yp,{asChild:!0,children:(0,K.jsxs)(B9,{className:q(`min-w-0 sm:min-w-[200px] p-0 px-1 text-sm h-11 justify-start text-white dark:text-black border-black dark:border-white hover:bg-gray-800 dark:hover:bg-zinc-100 hover:border-gray-800 dark:hover:border-zinc-200`,!t&&`pl-4`,t&&`pr-20`),children:[t&&(0,K.jsx)(bF,{server:t,size:`md`,className:`mr-2`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-1`,children:[(0,K.jsx)(`span`,{className:`truncate lg:max-w-[120px] xl:max-w-none`,children:t?t.serverInfo?.title||t.serverInfo?.name||t.name:`Select server to inspect`}),t&&(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:t.error&&t.state!==`ready`?(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation()},className:`w-2 h-2 rounded-full bg-rose-500 animate-status-pulse-red hover:bg-rose-600 transition-colors`,title:`Click to copy error message`,"aria-label":`Copy error message to clipboard`})}),(0,K.jsx)(Im,{children:(0,K.jsx)(`p`,{className:`max-w-xs`,children:t.error})})]}):(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full ${t.state===`ready`?`bg-emerald-600 animate-status-pulse`:t.state===`failed`?`bg-rose-600 animate-status-pulse-red`:`bg-yellow-500 animate-status-pulse-yellow`}`})})]})]})}),t&&(0,K.jsxs)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1`,children:[(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(`button`,{type:`button`,onClick:()=>{l(t),s(!0)},className:`p-1.5 hover:bg-white/10 dark:hover:bg-black/10 rounded-full transition-colors text-white dark:text-black`,"aria-label":`View server info`,children:(0,K.jsx)(Dh,{className:`h-4 w-4`})})}),(0,K.jsx)(Im,{children:(0,K.jsx)(`p`,{children:`View server info`})})]}),(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(`button`,{type:`button`,onClick:()=>{r(t.id)},className:`p-1.5 hover:bg-white/10 dark:hover:bg-black/10 rounded-full transition-colors text-white dark:text-black`,"aria-label":`Edit connection settings`,children:(0,K.jsx)(Uh,{className:`h-4 w-4`})})}),(0,K.jsx)(Im,{children:(0,K.jsx)(`p`,{children:`Edit connection settings`})})]})]}),(0,K.jsxs)(Xp,{className:`w-[calc(100vw-2rem)] sm:w-[300px]`,align:`start`,children:[(0,K.jsx)($p,{className:`cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800`,onClick:()=>a(`/`),children:`MCP Servers`}),(0,K.jsx)(em,{}),e.length===0?(0,K.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground dark:text-zinc-400 text-center`,children:`No servers connected. Go to the dashboard to add one.`}):e.map(e=>(0,K.jsxs)(Zp,{onClick:()=>u(e.id),className:`flex items-center gap-3`,children:[(0,K.jsx)(bF,{server:e,size:`sm`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-1`,children:[(0,K.jsx)(`div`,{className:`font-medium`,children:e.serverInfo?.title||e.serverInfo?.name||e.name}),(0,K.jsx)(V9,{status:e.state})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800`,onClick:t=>{t.stopPropagation(),l(e),s(!0)},children:(0,K.jsx)(Dh,{className:`h-3 w-3`})}),(0,K.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800`,onClick:t=>{t.stopPropagation(),r(e.id)},children:(0,K.jsx)(Uh,{className:`h-3 w-3`})})]})]},e.id)),(0,K.jsx)(em,{}),(0,K.jsx)(Zp,{onClick:()=>a(`/`),children:(0,K.jsx)(`span`,{className:`text-blue-600 dark:text-blue-400`,children:`+ Add new server`})})]})]}),(0,K.jsx)(xO,{open:o,onOpenChange:s,connection:c})]})})}function U9({className:e}){let{theme:t,setTheme:n}=bb(),r=(0,G.useRef)(null),i=()=>t===`system`?(0,K.jsx)(Ph,{className:`size-4`}):t===`light`?(0,K.jsx)(Xh,{className:`size-5`}):(0,K.jsx)(Fh,{className:`size-4`}),a=async e=>{let t=r.current;if(!t){n(e);return}if(typeof document<`u`&&`startViewTransition`in document){await document.startViewTransition(()=>{(0,Va.flushSync)(()=>{n(e)})}).ready;let{top:r,left:i,width:a,height:o}=t.getBoundingClientRect(),s=r+o/2,c=i+a/2,l=window.innerWidth-i,u=window.innerHeight-r,d=Math.hypot(Math.max(i,l),Math.max(r,u));document.documentElement.animate({clipPath:[`circle(0px at ${c}px ${s}px)`,`circle(${d}px at ${c}px ${s}px)`]},{duration:700,easing:`ease-in-out`,pseudoElement:`::view-transition-new(root)`})}else n(e)};return(0,K.jsxs)(Jp,{children:[(0,K.jsx)(Yp,{asChild:!0,children:(0,K.jsx)(J,{ref:r,variant:`ghost`,size:`sm`,className:q(`p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors`,e),"aria-label":`Toggle theme`,children:i()})}),(0,K.jsx)(Xp,{align:`end`,className:`min-w-0`,children:(0,K.jsxs)(tee,{value:t,onValueChange:e=>a(e),children:[(0,K.jsxs)(Qp,{value:`light`,className:`pl-2 pr-0 flex items-center gap-2 justify-end`,children:[(0,K.jsx)(`span`,{children:`Light`}),(0,K.jsx)(Xh,{className:`mr-2 size-5`})]}),(0,K.jsxs)(Qp,{value:`dark`,className:`pl-2 pr-0 flex items-center gap-2 justify-end`,children:[(0,K.jsx)(`span`,{children:`Dark`}),(0,K.jsx)(Fh,{className:`mr-2 h-4 w-4`})]}),(0,K.jsxs)(Qp,{value:`system`,className:`pl-2 pr-0 flex items-center gap-2 justify-end`,children:[(0,K.jsx)(`span`,{children:`System`}),(0,K.jsx)(Ph,{className:`mr-2 h-4 w-4`})]})]})})]})}var W9=[{id:`tools`,label:`Tools`,icon:eg},{id:`prompts`,label:`Prompts`,icon:Mh},{id:`resources`,label:`Resources`,icon:xh},{id:`sampling`,label:`Sampling`,icon:wh},{id:`elicitation`,label:`Elicitation`,icon:Jh},{id:`notifications`,label:`Notifications`,icon:Xm},{id:`chat`,label:`Chat`,icon:Lee}];function G9(e,t){return e===`tools`?t.tools.length:e===`prompts`?t.prompts.length:e===`resources`?t.resources.length:e===`sampling`?t.pendingSamplingRequests?.length||0:e===`elicitation`?t.pendingElicitationRequests?.length||0:e===`notifications`?t.unreadNotificationCount:0}function K9(e,t,n){return n&&t>0&&[`sampling`,`elicitation`,`notifications`].includes(e)}function fSe({collapsed:e,onToggle:t}){return(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(`button`,{onClick:t,className:q(`shrink-0 p-1.5 rounded-md transition-all duration-500 ease-in-out cursor-pointer`,`text-muted-foreground hover:text-foreground`,`hover:bg-zinc-100 dark:hover:bg-zinc-800`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`),"aria-label":e?`Expand tabs`:`Collapse tabs`,type:`button`,children:e?(0,K.jsx)(nh,{className:`h-4 w-4 transition-transform duration-500 ease-in-out`}):(0,K.jsx)(th,{className:`h-4 w-4 transition-transform duration-500 ease-in-out`})})}),(0,K.jsx)(Im,{children:(0,K.jsx)(`p`,{children:e?`Expand tabs`:`Collapse tabs`})})]})}function pSe(e){try{let t=new URL(e).hostname.toLowerCase();return t===`localhost`||t===`127.0.0.1`||t===`::1`||t===`0.0.0.0`}catch{return!1}}function mSe(e){try{return new URL(e).hostname.endsWith(`.mcp-use.run`)}catch{return!1}}function hSe(e){if(!e)return null;try{let t=new URL(e);if(t.protocol===`https:`)return t.origin}catch{}return null}var q9={starting:`Starting tunnel…`,stopping:`Stopping tunnel…`,reconnecting:`Reconnecting…`};function gSe({tunnelUrl:e,isTunnelStarting:t,setTunnelUrl:n,setIsTunnelStarting:r,copied:i,setCopied:a,handleCopy:o}){let[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)(0),[p,m]=(0,G.useState)(q9.starting);(0,G.useEffect)(()=>{if(!t){f(20);return}f(20);let e=setInterval(()=>f(e=>e>0?e-1:0),1e3);return()=>clearInterval(e)},[t]),(0,G.useEffect)(()=>{if(!e)return;c(!0);let t=new URLSearchParams(window.location.search);if(t.has(`openTunnelPopover`)){t.delete(`openTunnelPopover`);let e=t.toString();window.history.replaceState({},``,`${window.location.pathname}${e?`?${e}`:``}`)}},[e]),(0,G.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await fetch(`/inspector/api/dev/info`);if(!t.ok||e)return;let r=await t.json();if(e)return;if(u(!!r.fromCli),r.tunnelUrl)n(new URL(r.tunnelUrl).origin);else{let e=hSe(r.mcpUrl??null);e&&n(e)}}catch{e||u(!1)}})(),()=>{e=!0}},[n]);let h=async e=>{let t=window.location.port||`3000`,i=`http://localhost:${t}/inspector/api/dev/info`,a=Date.now()+9e4;for(m(e?`Restarting with tunnel…`:`Restarting…`),await new Promise(e=>setTimeout(e,1500));Date.now()<a;){try{let r=await fetch(i,{cache:`no-store`});if(r.ok){let i=await r.json();if(!!i.tunnelUrl===e){let r=(i.tunnelUrl||i.mcpUrl||`http://localhost:${t}`).replace(/\/+$/,``)+`/mcp`;i.tunnelUrl?n(new URL(i.tunnelUrl).origin):n(null),sessionStorage.setItem(CF,JSON.stringify({url:r,name:`Local MCP Server`,transportType:`http`,connectionType:`Direct`})),xv.success(e?`Tunnel ready — reconnecting…`:`Tunnel stopped — reconnecting…`),m(q9.reconnecting);let a=new URL(window.location.href);a.searchParams.delete(`server`),a.searchParams.delete(`tunnelUrl`),a.searchParams.delete(`autoConnect`),e&&a.searchParams.set(`openTunnelPopover`,`1`),window.location.assign(a.toString());return}}}catch{}await new Promise(e=>setTimeout(e,1500))}xv.error(`Timeout waiting for server to restart`),r(!1)},g=async()=>{if(l===!1){xv.error("Start Tunnel requires `mcp-use dev` from your project directory.");return}m(q9.starting),r(!0);try{let e=await fetch(`/inspector/api/dev/start-tunnel`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));xv.error(t.error||`Failed to start tunnel`),r(!1);return}await h(!0)}catch{xv.error(`Failed to start tunnel`),r(!1)}},_=async()=>{m(q9.stopping),r(!0);try{let e=await fetch(`/inspector/api/dev/stop-tunnel`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));xv.error(t.error||`Failed to stop tunnel`),r(!1);return}a(!1),c(!1),await h(!1)}catch{xv.error(`Failed to stop tunnel`),r(!1)}};if(t)return(0,K.jsxs)(`button`,{disabled:!0,className:`flex items-center gap-2 h-9 px-3 bg-zinc-100 dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 rounded-full opacity-75 cursor-wait`,children:[(0,K.jsx)(kh,{className:`size-4 text-zinc-500 dark:text-zinc-400 animate-spin`}),(0,K.jsxs)(`span`,{className:`text-sm font-medium text-zinc-600 dark:text-zinc-300 hidden lg:inline`,children:[`Start Tunnel `,(0,K.jsxs)(`span`,{className:`tabular-nums`,children:[d,`s`]})]})]});if(!e){let e=l===!0,t=l===null;return(0,K.jsxs)(`button`,{type:`button`,onClick:g,disabled:!e||t,title:l===!1?"Run `mcp-use dev` from your project to enable tunneling.":t?`Checking dev server…`:void 0,className:q(`flex items-center gap-2 h-9 px-3 border rounded-full transition-colors`,e&&!t?`bg-zinc-100 dark:bg-zinc-800 border-zinc-200 dark:border-zinc-700 hover:bg-zinc-200 dark:hover:bg-zinc-700 cursor-pointer`:`bg-zinc-100/60 dark:bg-zinc-800/60 border-zinc-200 dark:border-zinc-700 cursor-not-allowed opacity-70`),children:[t?(0,K.jsx)(kh,{className:`size-4 text-zinc-500 dark:text-zinc-400 animate-spin`}):(0,K.jsx)(ih,{className:`size-4 text-zinc-500 dark:text-zinc-400`}),(0,K.jsx)(`span`,{className:`text-sm font-medium text-zinc-600 dark:text-zinc-300 hidden lg:inline`,children:`Start Tunnel`})]})}return(0,K.jsxs)(HI,{open:s,onOpenChange:c,children:[(0,K.jsx)(UI,{asChild:!0,children:(0,K.jsxs)(`button`,{className:`flex items-center gap-2 h-9 px-3 bg-gradient-to-r from-purple-500/10 to-pink-500/10 dark:from-purple-500/20 dark:to-pink-500/20 border border-purple-500/30 dark:border-purple-500/40 rounded-full hover:from-purple-500/20 hover:to-pink-500/20 dark:hover:from-purple-500/30 dark:hover:to-pink-500/30 transition-colors cursor-pointer`,children:[(0,K.jsx)(ih,{className:`size-4 text-purple-600 dark:text-purple-400`}),(0,K.jsx)(`span`,{className:`text-sm font-medium text-purple-700 dark:text-purple-300 hidden lg:inline`,children:`Tunnel`})]})}),(0,K.jsx)(WI,{className:`w-[calc(100vw-2rem)] sm:w-96 overflow-hidden`,align:`end`,children:(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,K.jsx)(`h4`,{className:`font-semibold text-sm`,children:`Tunnel URL`}),(0,K.jsxs)(`a`,{href:`https://manufact.com/docs/tunneling`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[`Docs`,(0,K.jsx)(Nee,{className:`size-3`})]})]}),(0,K.jsxs)(`button`,{onClick:o,className:`-mx-4 px-4 py-3 bg-muted hover:bg-accent transition-colors cursor-pointer flex items-center gap-3 w-[calc(100%+2rem)]`,children:[(0,K.jsxs)(`code`,{className:`flex-1 text-[10px] font-mono truncate text-left`,children:[e,`/mcp`]}),i?(0,K.jsx)($m,{className:`size-3.5 text-green-600 shrink-0`}):(0,K.jsx)(uh,{className:`size-3.5 shrink-0 text-muted-foreground`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h5`,{className:`font-semibold text-sm mb-2`,children:`Use in ChatGPT`}),(0,K.jsxs)(`ol`,{className:`space-y-2 text-xs text-muted-foreground`,children:[(0,K.jsxs)(`li`,{className:`flex gap-2`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-foreground`,children:`1.`}),(0,K.jsxs)(`span`,{children:[`Enable`,` `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`dev mode`}),` `,`from settings`]})]}),(0,K.jsxs)(`li`,{className:`flex gap-2`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-foreground`,children:`2.`}),(0,K.jsxs)(`span`,{children:[`In`,` `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`App & Connectors`}),` `,`click on`,` `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`create`})]})]}),(0,K.jsxs)(`li`,{className:`flex gap-2`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-foreground`,children:`3.`}),(0,K.jsx)(`span`,{children:`Use the tunnel URL in the input`})]})]})]}),(0,K.jsxs)(`button`,{onClick:_,className:`flex items-center gap-1.5 text-xs text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 transition-colors cursor-pointer`,children:[(0,K.jsx)(Yh,{className:`size-3 fill-current`}),`Stop Tunnel`]})]})})]})}function _Se({connections:e,selectedServer:t,activeTab:n,onServerSelect:r,onTabChange:i,onCommandPaletteOpen:a,onOpenConnectionOptions:o,embedded:s=!1}){let{tunnelUrl:c,isTunnelStarting:l,setTunnelUrl:u,setIsTunnelStarting:d,embeddedConfig:f}=SF(),p=!!t&&(pSe(t.url)||mSe(t.url)||!!c),[m,h]=(0,G.useState)(!1),[g,_]=(0,G.useState)(!1),[v,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(!0);if(f.singleTab)return null;let S=f.visibleTabs?W9.filter(e=>f.visibleTabs.includes(e.id)):W9,C=async()=>{if(c)try{await rg(`${c}/mcp`),h(!0),xv.success(`Tunnel URL copied to clipboard`),setTimeout(()=>h(!1),2e3)}catch{xv.error(`Failed to copy URL`)}};return(0,K.jsxs)(`header`,{className:`w-full mx-auto`,children:[(0,K.jsxs)(`div`,{className:`flex lg:hidden flex-col gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between w-full`,children:[!s&&(0,K.jsx)(`div`,{className:`flex-1 flex justify-start`,children:(0,K.jsx)(H9,{connections:e,selectedServer:t,onServerSelect:r,onOpenConnectionOptions:o,mobileMode:!0})}),!s&&(0,K.jsx)(`div`,{className:`flex-shrink-0 flex justify-center`,children:(0,K.jsx)(`div`,{className:`scale-150`,children:(0,K.jsx)(L9,{state:`collapsed`})})}),!s&&(0,K.jsxs)(`div`,{className:`flex-1 flex justify-end items-center gap-2`,children:[t&&(()=>{let e=t.serverInfo?.title||t.serverInfo?.name||t.name;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(I9,{serverConfig:{url:c?`${c}/mcp`:t.url,name:e,headers:t.customHeaders,serverId:t.id},onSuccess:e=>xv.success(`Opening in ${e}...`),onError:e=>xv.error(`Failed: ${e.message}`),additionalItems:[{id:`ts-sdk`,label:`TypeScript SDK`,icon:(0,K.jsx)(`img`,{src:`https://cdn.simpleicons.org/typescript`,alt:`TypeScript`,className:`h-4 w-4`}),onClick:()=>_(!0)},{id:`py-sdk`,label:`Python SDK`,icon:(0,K.jsx)(`img`,{src:`https://cdn.simpleicons.org/python`,alt:`Python`,className:`h-4 w-4`}),onClick:()=>y(!0)}],trigger:(0,K.jsxs)(J,{variant:`ghost`,className:`bg-zinc-200 dark:bg-zinc-800 hover:bg-zinc-300 dark:hover:bg-zinc-700 rounded-full transition-colors px-3 flex items-center justify-center p-2`,"aria-label":`Add to Client`,children:[(0,K.jsxs)(`span`,{className:`xl:hidden hidden sm:flex items-center gap-1`,children:[(0,K.jsx)(Lh,{className:`size-3`}),`Client`]}),(0,K.jsxs)(`span`,{className:`hidden xl:flex items-center gap-1`,children:[`Add to Client`,(0,K.jsx)(eh,{className:`size-3`})]})]})}),(0,K.jsx)(z9,{open:g,onOpenChange:_,serverUrl:c?`${c}/mcp`:t.url,serverName:e,serverId:void 0,headers:t.customHeaders,language:`typescript`}),(0,K.jsx)(z9,{open:v,onOpenChange:y,serverUrl:c?`${c}/mcp`:t.url,serverName:e,serverId:void 0,headers:t.customHeaders,language:`python`})]})})(),(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,asChild:!0,children:(0,K.jsx)(`a`,{href:`https://github.com/mcp-use/mcp-use`,target:`_blank`,rel:`noopener noreferrer`,className:`p-2`,"aria-label":`GitHub`,children:(0,K.jsx)(k9,{className:`h-4 w-4`})})})}),(0,K.jsx)(Im,{children:(0,K.jsx)(`p`,{children:`Give us a star ⭐`})})]}),(0,K.jsx)(U9,{})]})]}),t&&(0,K.jsx)(`div`,{className:`w-full`,children:(0,K.jsx)(N9,{value:n,onValueChange:e=>i(e),collapsed:b,onCollapsedChange:x,children:(0,K.jsx)(P9,{className:`w-full justify-center`,children:S.map(e=>{let r=G9(e.id,t),i=K9(e.id,r,b);return(0,K.jsxs)(F9,{value:e.id,"data-testid":`tab-${e.id}`,icon:e.icon,showDot:i,className:q(`[&>svg]:mr-0 flex-1 flex-row gap-2 relative`,b&&`pl-2`),children:[r>0&&!b&&(0,K.jsx)(`span`,{className:q(n===e.id?`dark:bg-black`:`dark:bg-zinc-700`,`bg-zinc-200 text-zinc-700 dark:text-zinc-300 text-[10px] px-1.5 py-0.5 rounded-full font-medium`),children:r}),(0,K.jsx)(`span`,{className:`sr-only`,children:e.label})]},e.id)})})})})]}),(0,K.jsxs)(`div`,{className:`hidden lg:flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center flex-wrap gap-2 md:space-x-6 space-x-2`,children:[!s&&(0,K.jsx)(H9,{connections:e,selectedServer:t,onServerSelect:r,onOpenConnectionOptions:o}),t&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(N9,{value:n,onValueChange:e=>i(e),collapsed:b,onCollapsedChange:x,children:(0,K.jsx)(P9,{className:`overflow-x-auto`,collapsible:!0,children:S.map(e=>{let r=G9(e.id,t),i=r>0?`${e.label} (${r})`:e.label,a=K9(e.id,r,b);return(0,K.jsx)(F9,{value:e.id,"data-testid":`tab-${e.id}`,icon:e.icon,showDot:a,className:q(`[&>svg]:mr-0 lg:[&>svg]:mr-2 relative`,b&&`pl-4`),title:i,children:(0,K.jsxs)(`div`,{className:`items-center gap-2 hidden lg:flex`,children:[e.label,r>0&&(0,K.jsx)(`span`,{className:q(n===e.id?` dark:bg-black `:`dark:bg-zinc-700`,`bg-zinc-200 text-zinc-700 dark:text-zinc-300 text-xs px-2 py-0.5 rounded-full font-medium`),children:r})]})})})})}),(0,K.jsx)(fSe,{collapsed:b,onToggle:()=>x(!b)})]})]}),!s&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 sm:gap-4 flex-shrink-0`,children:[p&&(0,K.jsx)(gSe,{tunnelUrl:c,isTunnelStarting:l,setTunnelUrl:u,setIsTunnelStarting:d,copied:m,setCopied:h,handleCopy:C}),t&&(()=>{let e=t.serverInfo?.title||t.serverInfo?.name||t.name;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(I9,{serverConfig:{url:c?`${c}/mcp`:t.url,name:e,headers:t.customHeaders,serverId:t.id},onSuccess:e=>xv.success(`Opening in ${e}...`),onError:e=>xv.error(`Failed: ${e.message}`),additionalItems:[{id:`ts-sdk`,label:`TypeScript SDK`,icon:(0,K.jsx)(`img`,{src:`https://cdn.simpleicons.org/typescript`,alt:`TypeScript`,className:`h-4 w-4`}),onClick:()=>_(!0)},{id:`py-sdk`,label:`Python SDK`,icon:(0,K.jsx)(`img`,{src:`https://cdn.simpleicons.org/python`,alt:`Python`,className:`h-4 w-4`}),onClick:()=>y(!0)}],trigger:(0,K.jsxs)(J,{variant:`ghost`,className:`bg-zinc-200 dark:bg-zinc-800 hover:bg-zinc-300 dark:hover:bg-zinc-700 rounded-full transition-colors px-3 flex items-center justify-center`,"aria-label":`Add to Client`,children:[(0,K.jsxs)(`span`,{className:`xl:hidden hidden sm:flex items-center gap-1`,children:[(0,K.jsx)(Lh,{className:`size-3`}),`Client`]}),(0,K.jsxs)(`span`,{className:`hidden xl:flex items-center gap-1`,children:[`Add to Client`,(0,K.jsx)(eh,{className:`size-3`})]})]})}),(0,K.jsx)(z9,{open:g,onOpenChange:_,serverUrl:c?`${c}/mcp`:t.url,serverName:e,serverId:void 0,headers:t.customHeaders,language:`typescript`}),(0,K.jsx)(z9,{open:v,onOpenChange:y,serverUrl:c?`${c}/mcp`:t.url,serverName:e,serverId:void 0,headers:t.customHeaders,language:`python`})]})})(),(0,K.jsx)(U9,{}),(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsxs)(J,{variant:`ghost`,className:`hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full px-1 -mx-3 flex gap-1`,onClick:a,"data-testid":`command-palette-trigger-button`,children:[(0,K.jsx)(lh,{className:`size-4`}),(0,K.jsx)(`span`,{className:`text-base font-mono hidden sm:inline`,children:`K`})]})}),(0,K.jsx)(Im,{children:(0,K.jsx)(`p`,{children:`Command Palette`})})]}),(0,K.jsxs)(Pm,{children:[(0,K.jsx)(Fm,{asChild:!0,children:(0,K.jsx)(J,{variant:`ghost`,size:`sm`,asChild:!0,children:(0,K.jsxs)(`a`,{href:`https://github.com/mcp-use/mcp-use`,className:`flex items-center gap-2`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,K.jsx)(k9,{className:`h-4 w-4`}),(0,K.jsx)(`span`,{className:`hidden xl:inline`,children:`Github`})]})})}),(0,K.jsx)(Im,{children:(0,K.jsx)(`p`,{children:`Give us a star ⭐`})})]}),(0,K.jsx)(L9,{state:`expanded`})]})]})]})}function vSe({children:e}){let t=n_(),n=$g(),{servers:r,addServer:i,removeServer:a,updateServer:o,storageLoaded:s}=Er(),c=(0,G.useCallback)((e,t,n,r)=>{i(e,{url:e,name:t,proxyConfig:n,transportType:r,preventAutoAuth:!0,clientOptions:{capabilities:{extensions:{"io.modelcontextprotocol/ui":{mimeTypes:[`text/html;profile=mcp-app`]}}}}})},[i]),l=(0,G.useCallback)(async(e,t)=>{try{await o(e,t)}catch(t){console.error(`[Layout] Failed to update connection ${e}:`,t)}},[o]),{selectedServerId:u,setSelectedServerId:d,activeTab:f,setActiveTab:p,navigateToItem:m,setTunnelUrl:h,tunnelUrl:g,isEmbedded:_,embeddedConfig:v,setEmbeddedMode:y}=SF(),[b,x]=(0,G.useState)(!1),[S,C]=(0,G.useState)(null),w=ple();(0,G.useEffect)(()=>{let e=new URLSearchParams(n.search),t=e.get(`embedded`)===`true`,r=e.get(`embeddedConfig`);if(t){let e={};if(r)try{e=JSON.parse(r)}catch(e){console.error(`Failed to parse embeddedConfig:`,e)}y(!0,e),e.defaultTab&&p(e.defaultTab)}},[]),(0,G.useEffect)(()=>{h(new URLSearchParams(n.search).get(`tunnelUrl`))},[n.search,h]),(0,G.useEffect)(()=>{let e=new URLSearchParams(n.search).get(`tab`);e&&[`tools`,`prompts`,`resources`,`chat`,`sampling`,`elicitation`,`notifications`].includes(e)&&p(e)},[n.search,p]),(0,G.useEffect)(()=>{let e=e=>{let t=e.detail.requestId;u&&m(u,`sampling`,t)},t=e=>{let t=e.detail.requestId;u&&m(u,`elicitation`,t)},n=e=>{let t=e.detail.toolName;u&&t?m(u,`tools`,t):u&&p(`tools`)};return window.addEventListener(`navigate-to-sampling`,e),window.addEventListener(`navigate-to-elicitation`,t),window.addEventListener(`navigate-to-tool-result`,n),()=>{window.removeEventListener(`navigate-to-sampling`,e),window.removeEventListener(`navigate-to-elicitation`,t),window.removeEventListener(`navigate-to-tool-result`,n)}},[u,p,m]);let T=(0,G.useRef)(null),E=(0,G.useRef)(null),D=(0,G.useRef)(null),{isAutoConnecting:O}=fle({connections:r,addConnection:c,removeConnection:a,configLoaded:s,embedded:_}),k=(0,G.useCallback)(e=>{Km.getInstance().capture(new wee({trigger:e})).catch(()=>{}),x(!0)},[]),A=e=>{let i=r.find(t=>t.id===e);if(!i||i.state!==`ready`){xv.error(`Server is not connected and cannot be inspected`);return}d(e);let a=new URLSearchParams(n.search),o=a.get(`tunnelUrl`),s=a.get(`tab`),c=new URLSearchParams;c.set(`server`,e),o&&c.set(`tunnelUrl`,o),s&&c.set(`tab`,s),t(`/?${c.toString()}`)},j=(0,G.useCallback)(e=>{C(e)},[]),M=(0,G.useCallback)(e=>{S&&(e.url===S?l(S,{name:e.name,proxyConfig:e.proxyConfig,transportType:e.transportType}):(a(S),c(e.url,e.name,e.proxyConfig,e.transportType)),C(null),xv.success(`Connection settings updated`))},[S,a,c,l]),N=(e,i,a)=>{if(console.warn(`[Layout] handleCommandPaletteNavigate called:`,{tab:e,itemName:i,serverId:a}),a){let o=r.find(e=>e.id===a);if(console.warn(`[Layout] Server lookup:`,{serverId:a,serverFound:!!o,serverState:o?.state}),!o||o.state!==`ready`){console.warn(`[Layout] Server not ready, showing error`),xv.error(`Server is not connected and cannot be inspected`);return}console.warn(`[Layout] Calling navigateToItem:`,{serverId:a,tab:e,itemName:i}),m(a,e,i);let s=new URLSearchParams(n.search),c=s.get(`tunnelUrl`),l=s.get(`tab`),u=new URLSearchParams;u.set(`server`,a),c&&u.set(`tunnelUrl`,c),e?u.set(`tab`,e):l&&u.set(`tab`,l);let d=`/?${u.toString()}`;console.warn(`[Layout] Navigating to:`,d),t(d)}else console.warn(`[Layout] No serverId, just updating tab to:`,e),p(e)},P=r.find(e=>e.id===u),F=P?P.tools.map(e=>({...e,_serverId:P.id})):r.flatMap(e=>e.state===`ready`?e.tools.map(t=>({...t,_serverId:e.id,_serverName:e.name})):[]),I=P?P.prompts.map(e=>({...e,_serverId:P.id})):r.flatMap(e=>e.state===`ready`?e.prompts.map(t=>({...t,_serverId:e.id,_serverName:e.name})):[]),L=P?P.resources.map(e=>({...e,_serverId:P.id})):r.flatMap(e=>e.state===`ready`?e.resources.map(t=>({...t,_serverId:e.id,_serverName:e.name})):[]);(0,G.useEffect)(()=>{let e=new URLSearchParams(n.search),i=e.get(`server`);if(i&&(i.startsWith(`http://`)||i.startsWith(`https://`))&&!r.find(e=>e.id===i)){let n=new URLSearchParams(e);n.delete(`server`),n.set(`autoConnect`,i),t(`/?${n.toString()}`,{replace:!0});return}i!==u&&d(i)},[n.search,u,d,r,t]),(0,G.useEffect)(()=>{let e=new URLSearchParams(n.search).get(`server`);if(!e)return;let i=r.find(t=>t.id===e);if(!i){let e=setTimeout(()=>t(`/`),3e3);return()=>clearTimeout(e)}if(i.state===`failed`){let e=setTimeout(()=>t(`/`),2e3);return()=>clearTimeout(e)}},[n.search,t,r]),(0,G.useEffect)(()=>{if(!_)return;let e=e=>{if(!e.data||typeof e.data!=`object`||e.data.type!==`mcp-inspector:connect_servers`)return;let t=e.data.servers;if(!Array.isArray(t)||t.length===0)return;let n=null;for(let e of t){if(!e.url||typeof e.url!=`string`)continue;let t=e.url,i=e.name??`Server`,a=e.transportType??`http`,o={...e.headers??{}};if(e.auth?.access_token){let t=e.auth.token_type||`bearer`;o.Authorization=`${t.charAt(0).toUpperCase()+t.slice(1)} ${e.auth.access_token}`}let s={proxyAddress:`${window.location.origin}/inspector/api/proxy`,...Object.keys(o).length>0&&{headers:o}};r.find(e=>e.url===t)||c(t,i,s,a),n||=t}window.parent!==window&&window.parent.postMessage({type:`mcp-inspector:servers_connected`,count:t.length},`*`)};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[_,r,c]);let ee=(0,G.useRef)(!1);if((0,G.useEffect)(()=>{if(!_||ee.current||u)return;let e=r.find(e=>e.state===`ready`);if(e){ee.current=!0,d(e.id);let r=new URLSearchParams(n.search);r.set(`server`,e.id),t(`/?${r.toString()}`,{replace:!0})}},[_,r,u,d,t,n.search]),TF({onCommandPalette:()=>k(`keyboard`),onToolsTab:()=>{P&&p(`tools`)},onPromptsTab:()=>{P&&p(`prompts`)},onResourcesTab:()=>{P&&p(`resources`)},onChatTab:()=>{P&&p(`chat`)},onHome:()=>{t(`/`)},onFocusSearch:()=>{f===`tools`&&T.current?T.current.focusSearch():f===`prompts`&&E.current?E.current.focusSearch():f===`resources`&&D.current&&D.current.focusSearch()},onBlurSearch:()=>{f===`tools`&&T.current?T.current.blurSearch():f===`prompts`&&E.current?E.current.blurSearch():f===`resources`&&D.current&&D.current.blurSearch()}}),O)return(0,K.jsx)(`div`,{className:`h-screen bg-white dark:bg-zinc-900 flex items-center justify-center`,children:(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,K.jsx)(yF,{className:`h-8 w-8 text-zinc-600 dark:text-zinc-400`}),(0,K.jsx)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400`,children:`Connecting to MCP server...`})]})});let te=_&&v.singleTab,R=_?{backgroundColor:v.backgroundColor||`#f3f3f3`,padding:te?`0`:v.padding||`0.5rem`}:{};return(0,K.jsx)(Nm,{children:(0,K.jsxs)(`div`,{className:_?te?`h-screen flex flex-col`:`h-screen flex flex-col gap-2 sm:gap-4`:`h-screen bg-[#f3f3f3] dark:bg-black flex flex-col px-2 py-2 sm:px-4 sm:py-4 gap-2 sm:gap-4`,style:R,children:[!te&&(0,K.jsx)(_Se,{connections:r,selectedServer:P,activeTab:f,onServerSelect:A,onTabChange:p,onCommandPaletteOpen:()=>k(`button`),onOpenConnectionOptions:j,embedded:_}),(0,K.jsx)(`main`,{className:te?`flex-1 w-full bg-white dark:bg-black p-0 overflow-auto`:`flex-1 w-full mx-auto bg-white dark:bg-black rounded-2xl border border-zinc-200 dark:border-zinc-700 p-0 overflow-auto`,children:(0,K.jsx)(sSe,{selectedServer:P,activeTab:f,toolsSearchRef:T,promptsSearchRef:E,resourcesSearchRef:D,children:e})}),(0,K.jsx)(Gle,{isOpen:b,onOpenChange:x,tools:F,prompts:I,resources:L,savedRequests:w,connections:r,selectedServer:P,tunnelUrl:g,onNavigate:N,onServerSelect:A}),(0,K.jsx)(SO,{connection:S&&r.find(e=>e.id===S)||null,open:S!==null,onOpenChange:e=>{e||C(null)},onConnect:M})]})})}function J9(e){let t=a(()=>{throw Error(`Invalid url to pass to open(): ${e}`)},`abort`),n;try{n=new URL(e)}catch{t()}return n.protocol!==`https:`&&n.protocol!==`http:`&&t(),n.hostname!==encodeURIComponent(n.hostname)&&t(),n.username&&=encodeURIComponent(n.username),n.password&&=encodeURIComponent(n.password),n.pathname=n.pathname.slice(0,1)+encodeURIComponent(n.pathname.slice(1)).replace(/%2f/gi,`/`),n.search=n.search.slice(0,1)+Array.from(n.searchParams.entries()).map(Y9).join(`&`),n.hash=n.hash.slice(0,1)+encodeURIComponent(n.hash.slice(1)),n.href}a(J9,`sanitizeUrl`);function Y9([e,t]){return`${encodeURIComponent(e)}${t.length>0?`=${encodeURIComponent(t)}`:``}`}a(Y9,`sanitizeParam`);async function X9(e){return typeof e==`string`?e:e instanceof URLSearchParams||e instanceof FormData?Object.fromEntries(e.entries()):e instanceof Blob?await e.text():e}a(X9,`serializeBody`);var ySe=class{static{a(this,`BrowserOAuthClientProvider`)}serverUrl;storageKeyPrefix;serverUrlHash;clientName;clientUri;logoUri;callbackUrl;preventAutoAuth;useRedirectFlow;oauthProxyUrl;connectionUrl;originalFetch;pendingCodeVerifier=null;_lastOriginalResource=null;_cachedAuthServerUrl=null;_cachedMetadata=null;_refreshPromise=null;onPopupWindow;constructor(e,t={}){this.serverUrl=e,this.storageKeyPrefix=t.storageKeyPrefix||`mcp:auth`,this.serverUrlHash=this.hashString(e),this.clientName=t.clientName||`mcp-use`,this.clientUri=t.clientUri||(typeof window<`u`?window.location.origin:``),this.logoUri=t.logoUri||`https://mcp-use.com/logo.png`,this.callbackUrl=J9(t.callbackUrl||(typeof window<`u`?new URL(`/oauth/callback`,window.location.origin).toString():`/oauth/callback`)),this.preventAutoAuth=t.preventAutoAuth,this.useRedirectFlow=t.useRedirectFlow,this.oauthProxyUrl=t.oauthProxyUrl,this.connectionUrl=t.connectionUrl,this.onPopupWindow=t.onPopupWindow}installFetchInterceptor(){if(!this.oauthProxyUrl){console.warn(`[BrowserOAuthProvider] No OAuth proxy URL configured, skipping fetch interceptor installation`);return}if(!this.originalFetch)this.originalFetch=window.fetch;else{console.warn(`[BrowserOAuthProvider] Fetch interceptor already installed`);return}let e=this.oauthProxyUrl,t=this.connectionUrl,n=this.serverUrl,r=this.originalFetch;console.log(`[BrowserOAuthProvider] Installing fetch interceptor with proxy: ${e}`),window.fetch=async(i,a)=>{let o=typeof i==`string`?i:i instanceof URL?i.toString():i.url;if(!(o.includes(`/.well-known/`)||o.match(/\/(register|token|authorize)$/)))return await r(i,a);try{let t=new URL(o),n=new URL(e);if(t.origin===n.origin&&(t.pathname.startsWith(n.pathname)||o.includes(`/inspector/api/oauth`)))return await r(i,a)}catch{}try{let i=o.includes(`/.well-known/`),s=i?`${e}/metadata?url=${encodeURIComponent(o)}`:`${e}/proxy`;if(console.log(`[OAuth Proxy] Routing ${i?`metadata`:`request`} through: ${s}`),i){let e={...a?.headers?Object.fromEntries(new Headers(a.headers)):{}};t&&(e[`X-Connection-URL`]=t);let i=new URL(s);n&&i.searchParams.set(`mcp_url`,n);let o=await r(i.toString(),{...a,method:`GET`,headers:e});try{if((o.headers.get(`content-type`)||``).includes(`application/json`)){let e=await o.clone().json(),t=e&&typeof e==`object`&&typeof e._original_resource==`string`?e._original_resource:null;t&&(this._lastOriginalResource=t)}}catch{}return o}let c=a?.body?await X9(a.body):void 0,l=await(await r(s,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:o,method:a?.method||`POST`,headers:a?.headers?Object.fromEntries(new Headers(a.headers)):{},body:c})})).json();return new Response(JSON.stringify(l.body),{status:l.status,statusText:l.statusText,headers:new Headers(l.headers)})}catch(e){return console.error(`[OAuth Proxy] Request failed, falling back to direct fetch:`,e),await r(i,a)}}}restoreFetch(){this.originalFetch&&=(console.log(`[BrowserOAuthProvider] Restoring original fetch`),window.fetch=this.originalFetch,void 0)}get redirectUrl(){return J9(this.callbackUrl)}get clientMetadata(){return{redirect_uris:[this.redirectUrl],token_endpoint_auth_method:`none`,grant_types:[`authorization_code`,`refresh_token`],response_types:[`code`],client_name:this.clientName,client_uri:this.clientUri,logo_uri:this.logoUri}}async clientInformation(){let e=this.getKey(`client_info`),t=localStorage.getItem(e);if(t)try{let n=JSON.parse(t),r=Array.isArray(n.redirect_uris)?n.redirect_uris:[];if(!(r.length===0||r.includes(this.redirectUrl))){console.info(`[${this.storageKeyPrefix}] Invalidating cached OAuth client info due to redirect URI mismatch.`),localStorage.removeItem(e),localStorage.removeItem(this.getKey(`tokens`)),localStorage.removeItem(this.getKey(`last_auth_url`));return}return n}catch(t){console.warn(`[${this.storageKeyPrefix}] Failed to parse client information:`,t),localStorage.removeItem(e);return}}async saveClientInformation(e){let t=this.getKey(`client_info`);localStorage.setItem(t,JSON.stringify(e))}async tokens(){let e=this.getKey(`tokens`),t=localStorage.getItem(e);if(t)try{let e=JSON.parse(t);if(e.access_token&&e.refresh_token)try{let t=JSON.parse(atob(e.access_token.split(`.`)[1]));if(t.exp&&Date.now()>=(t.exp-30)*1e3){console.log(`[tokens] Access token expiring soon, refreshing...`);let t=await this._dedupedRefresh(e);if(t)return console.log(`[tokens] Refreshed successfully`),t}}catch{}return e}catch(t){console.warn(`[${this.storageKeyPrefix}] Failed to parse tokens:`,t),localStorage.removeItem(e);return}}async saveTokens(e){let t=this.getKey(`tokens`);localStorage.setItem(t,JSON.stringify(e)),localStorage.removeItem(this.getKey(`code_verifier`)),localStorage.removeItem(this.getKey(`last_auth_url`)),this.pendingCodeVerifier=null}async _refresh(e){try{if(!this._cachedAuthServerUrl||!this._cachedMetadata){let e=(await oe(this.serverUrl)).authorization_servers?.[0];if(!e)return null;let t=await ie(e);if(!t)return null;this._cachedAuthServerUrl=e,this._cachedMetadata=t}let t=await this.clientInformation();if(!t)return null;let n=await ae(this._cachedAuthServerUrl,{metadata:this._cachedMetadata,clientInformation:t,refreshToken:e.refresh_token});return await this.saveTokens(n),n}catch{return null}}async _dedupedRefresh(e){if(this._refreshPromise)return this._refreshPromise;this._refreshPromise=this._refresh(e);try{return await this._refreshPromise}finally{this._refreshPromise=null}}async invalidateCredentials(e){switch(e){case`all`:localStorage.removeItem(this.getKey(`tokens`)),localStorage.removeItem(this.getKey(`client_info`)),localStorage.removeItem(this.getKey(`code_verifier`)),localStorage.removeItem(this.getKey(`last_auth_url`)),this.pendingCodeVerifier=null;break;case`client`:localStorage.removeItem(this.getKey(`client_info`));break;case`tokens`:localStorage.removeItem(this.getKey(`tokens`));break;case`verifier`:localStorage.removeItem(this.getKey(`code_verifier`)),this.pendingCodeVerifier=null;break;default:break}}async saveCodeVerifier(e){let t=this.getKey(`code_verifier`);localStorage.setItem(t,e),this.pendingCodeVerifier=e}async codeVerifier(){let e=this.getKey(`code_verifier`),t=localStorage.getItem(e);if(!t)throw Error(`[${this.storageKeyPrefix}] Code verifier not found in storage for key ${e}. Auth flow likely corrupted or timed out.`);return t}async prepareAuthorizationUrl(e){let t=e.searchParams.get(`resource`),n=!!(t&&(t.includes(`/inspector/api/proxy`)||t.includes(`/api/proxy`)||t.includes(`localhost:3000`))),r=!!(t&&this.connectionUrl&&t===this.connectionUrl),i=!!(t&&(this._lastOriginalResource||this.serverUrl)&&(r||n)),a=this._lastOriginalResource||this.serverUrl;i&&a&&e.searchParams.set(`resource`,a);let o=globalThis.crypto.randomUUID(),s=`${this.storageKeyPrefix}:state_${o}`,c=this.pendingCodeVerifier||localStorage.getItem(this.getKey(`code_verifier`)),l={serverUrlHash:this.serverUrlHash,expiry:Date.now()+1e3*60*10,codeVerifier:c||void 0,providerOptions:{serverUrl:this.serverUrl,storageKeyPrefix:this.storageKeyPrefix,clientName:this.clientName,clientUri:this.clientUri,callbackUrl:this.callbackUrl,oauthProxyUrl:this.oauthProxyUrl,connectionUrl:this.connectionUrl},flowType:this.useRedirectFlow?`redirect`:`popup`,returnUrl:typeof window<`u`?window.location.href:void 0};console.log(`[OAuth] Storing state key: ${s}`),localStorage.setItem(s,JSON.stringify(l));let u=localStorage.getItem(s);console.log(`[OAuth] State stored successfully: ${!!u}`),e.searchParams.set(`state`,o);let d=J9(e.toString());return localStorage.setItem(this.getKey(`last_auth_url`),d),d}async redirectToAuthorization(e){let t=await this.prepareAuthorizationUrl(e);if(this.preventAutoAuth){console.info(`[${this.storageKeyPrefix}] Auto-auth prevented. Authorization URL stored for manual trigger.`);return}if(this.useRedirectFlow){console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL (full-page redirect).`),window.location.href=t;return}let n=`width=600,height=700,resizable=yes,scrollbars=yes,status=yes`;try{let e=window.open(t,`mcp_auth_${this.serverUrlHash}`,n);this.onPopupWindow&&this.onPopupWindow(t,n,e),!e||e.closed||e.closed===void 0?console.warn(`[${this.storageKeyPrefix}] Popup likely blocked by browser. Manual navigation might be required using the stored URL.`):(e.focus(),console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL in popup.`))}catch(e){console.error(`[${this.storageKeyPrefix}] Error opening popup window:`,e)}}getLastAttemptedAuthUrl(){let e=localStorage.getItem(this.getKey(`last_auth_url`));return e?J9(e):null}clearStorage(){let e=`${this.storageKeyPrefix}_${this.serverUrlHash}_`,t=`${this.storageKeyPrefix}:state_`,n=[],r=0;for(let r=0;r<localStorage.length;r++){let i=localStorage.key(r);if(i){if(i.startsWith(e))n.push(i);else if(i.startsWith(t))try{let e=localStorage.getItem(i);e&&JSON.parse(e).serverUrlHash===this.serverUrlHash&&n.push(i)}catch(e){console.warn(`[${this.storageKeyPrefix}] Error parsing state key ${i} during clearStorage:`,e)}}}return[...new Set(n)].forEach(e=>{localStorage.removeItem(e),r++}),r}hashString(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return Math.abs(t).toString(16)}getKey(e){return`${this.storageKeyPrefix}_${this.serverUrlHash}_${e}`}};async function Z9(){let e=new URLSearchParams(window.location.search),t=e.get(`code`),n=e.get(`state`),r=e.get(`error`),i=e.get(`error_description`),a=`[mcp-callback]`;console.log(`${a} Handling callback...`,{code:t,state:n,error:r,errorDescription:i});let o=null,s=null,c=null;try{if(r)throw Error(`OAuth error: ${r} - ${i||`No description provided.`}`);if(!t)throw Error(`Authorization code not found in callback query parameters.`);if(!n)throw Error(`State parameter not found or invalid in callback query parameters.`);console.log(`[mcp-callback] Looking for state: ${n}`),console.log(`[mcp-callback] All localStorage keys:`,Object.keys(localStorage));let e=`mcp:auth:state_${n}`;if(localStorage.getItem(e))c=e,console.log(`[mcp-callback] Found state with default key: ${e}`);else{let e=`:state_${n}`;for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n&&n.endsWith(e)){c=n,console.log(`[mcp-callback] Found state with dynamic key: ${n}`);break}}}if(!c){let e=Object.keys(localStorage).filter(e=>e.includes(`state`));throw console.log(`[mcp-callback] State keys in storage:`,e),Error(`Invalid or expired state parameter "${n}". No matching state found in storage.`)}let l=localStorage.getItem(c);if(!l)throw Error(`Invalid or expired state parameter "${n}". No matching state found in storage.`);try{s=JSON.parse(l)}catch{throw Error(`Failed to parse stored OAuth state.`)}if(!s.expiry||s.expiry<Date.now())throw localStorage.removeItem(c),Error(`OAuth state has expired. Please try initiating authentication again.`);if(!s.providerOptions)throw Error(`Stored state is missing required provider options.`);let{serverUrl:u,...d}=s.providerOptions,f=d.connectionUrl,p=!!(f&&/run\.mcp-use\.com|mcp-use\.run/.test(f)),m=p?f:void 0,h=d.oauthProxyUrl,g=m;if(!h&&g)try{let e=new URL(window.location.href);if(e.pathname.includes(`/oauth/callback`)){let t=e.pathname.replace(/\/oauth\/callback.*$/,``);(!t||t===``)&&(/run\.mcp-use\.com|mcp-use\.run/.test(g)?console.log(`${a} Gateway connection detected; skipping default /inspector OAuth proxy inference`):(t=`/inspector`,console.log(`${a} Callback at root /oauth/callback, using /inspector as base path for OAuth proxy`))),t&&(h=`${e.origin}${t}/api/oauth`),console.log(`${a} Inferred OAuth proxy URL from callback: ${h}`)}}catch(e){console.warn(`${a} Could not infer OAuth proxy URL:`,e)}console.log(`${a} Re-instantiating provider for server: ${u}`),o=new ySe(u,{...d,oauthProxyUrl:h,connectionUrl:g});let _=`${d.storageKeyPrefix}_${s.serverUrlHash}_code_verifier`,v=s.codeVerifier||localStorage.getItem(_);if(v)localStorage.setItem(_,v),localStorage.setItem(o.getKey(`code_verifier`),v);else throw Error(`[${d.storageKeyPrefix}] Code verifier missing for OAuth state ${n}. Please restart authentication.`);h&&(console.log(`${a} Installing fetch interceptor for token exchange (proxy: ${h})`),o.installFetchInterceptor()),console.log(`${a} Calling SDK auth() to exchange code...`);let y=p&&g?g:u;console.log(`${a} Using SDK serverUrl: ${y} (connectionUrl: ${g||`none`})`);let b=await le(o,{serverUrl:y,authorizationCode:t});if(b===`AUTHORIZED`)if(console.log(`${a} Authorization successful via SDK auth().`),s.flowType===`redirect`&&s.returnUrl)console.log(`${a} Redirect flow complete. Returning to: ${s.returnUrl}`),localStorage.removeItem(c),window.location.href=s.returnUrl;else if(window.opener&&!window.opener.closed)console.log(`${a} Popup flow complete. Notifying opener...`),window.opener.postMessage({type:`mcp_auth_callback`,success:!0},window.location.origin),localStorage.removeItem(c),window.close();else if(s.returnUrl)console.log(`${a} Popup flow without opener. Returning to: ${s.returnUrl}`),localStorage.removeItem(c),window.location.href=s.returnUrl;else{console.warn(`${a} No opener window or return URL detected. Redirecting to root.`),localStorage.removeItem(c);let e=window.location.pathname.split(`/`).filter(Boolean),t=e.length>0&&e[e.length-1]===`callback`?`/`+e.slice(0,-2).join(`/`):`/`;window.location.href=t||`/`}else throw console.warn(`${a} SDK auth() returned unexpected status: ${b}`),Error(`Unexpected result from authentication library: ${b}`)}catch(e){console.error(`${a} Error during OAuth callback handling:`,e);let t=e instanceof Error?e.message:String(e);window.opener&&!window.opener.closed&&window.opener.postMessage({type:`mcp_auth_callback`,success:!1,error:t},window.location.origin);try{document.body.innerHTML=``;let n=document.createElement(`div`);n.style.fontFamily=`sans-serif`,n.style.padding=`20px`;let r=document.createElement(`h1`);r.textContent=`Authentication Error`,n.appendChild(r);let i=document.createElement(`p`);i.style.color=`red`,i.style.backgroundColor=`#ffebeb`,i.style.border=`1px solid red`,i.style.padding=`10px`,i.style.borderRadius=`4px`,i.textContent=t,n.appendChild(i);let a=document.createElement(`p`);a.textContent=`You can close this window or `;let o=document.createElement(`a`);if(o.href=`#`,o.textContent=`click here to close`,o.onclick=e=>(e.preventDefault(),window.close(),!1),a.appendChild(o),a.appendChild(document.createTextNode(`.`)),n.appendChild(a),e instanceof Error&&e.stack){let t=document.createElement(`pre`);t.style.fontSize=`0.8em`,t.style.color=`#555`,t.style.marginTop=`20px`,t.style.whiteSpace=`pre-wrap`,t.textContent=e.stack,n.appendChild(t)}document.body.appendChild(n)}catch(e){console.error(`${a} Could not display error in callback window:`,e)}c&&localStorage.removeItem(c),o&&localStorage.removeItem(o.getKey(`last_auth_url`))}}a(Z9,`onMcpAuthorization`);async function bSe(e,t=fetch){let n=e.replace(/\/$/,``),r=await t(n.endsWith(`/mcp`)?n:`${n}/mcp`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({jsonrpc:`2.0`,method:`initialize`,id:1,params:{}})});if(r.status!==401)return{};let{resourceMetadataUrl:i,scope:a}=de(r);return{resourceMetadataUrl:i,scope:a}}a(bSe,`probeAuthParams`);function xSe(){let[e,t]=(0,G.useState)(`processing`),[n,r]=(0,G.useState)(``);return(0,G.useEffect)(()=>{console.log(`[OAuthCallback] Component mounted, handling authorization...`),console.log(`[OAuthCallback] Current URL:`,window.location.href),Z9().then(()=>{console.log(`[OAuthCallback] Authorization successful`),t(`success`)}).catch(e=>{console.error(`[OAuthCallback] Authorization failed:`,e),t(`error`),r(e instanceof Error?e.message:String(e))})},[]),e===`processing`?(0,K.jsx)(`div`,{className:`h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900`,children:(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,K.jsx)(kh,{className:`h-8 w-8 animate-spin text-zinc-600 dark:text-zinc-400`}),(0,K.jsx)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400`,children:`Completing authentication...`})]})}):e===`error`?(0,K.jsx)(`div`,{className:`h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900`,children:(0,K.jsxs)(`div`,{className:`max-w-md p-6`,children:[(0,K.jsx)(`h1`,{className:`text-xl font-semibold text-red-600 dark:text-red-400 mb-2`,children:`Authentication Error`}),(0,K.jsx)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400 mb-4`,children:n}),(0,K.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-500`,children:`You can close this window and try again.`})]})}):(0,K.jsx)(`div`,{className:`h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900`,children:(0,K.jsxs)(`div`,{className:`max-w-md p-6`,children:[(0,K.jsx)(`h1`,{className:`text-xl font-semibold text-green-600 dark:text-green-400 mb-2`,children:`Authentication Successful!`}),(0,K.jsx)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400`,children:`Redirecting you back...`})]})})}var SSe=(e,t,n,r,i,a,o,s)=>{let c=document.documentElement,l=[`light`,`dark`];function u(t){(Array.isArray(e)?e:[e]).forEach(e=>{let n=e===`class`,r=n&&a?i.map(e=>a[e]||e):i;n?(c.classList.remove(...r),c.classList.add(a&&a[t]?a[t]:t)):c.setAttribute(e,t)}),d(t)}function d(e){s&&l.includes(e)&&(c.style.colorScheme=e)}function f(){return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}if(r)u(r);else try{let e=localStorage.getItem(t)||n;u(o&&e===`system`?f():e)}catch{}},CSe=G.createContext(void 0),wSe={setTheme:e=>{},themes:[]},TSe=()=>G.useContext(CSe)??wSe;G.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:i,defaultTheme:a,value:o,themes:s,nonce:c,scriptProps:l})=>{let u=JSON.stringify([n,t,a,e,s,o,r,i]).slice(1,-1);return G.createElement(`script`,{...l,suppressHydrationWarning:!0,nonce:typeof window>`u`?c:``,dangerouslySetInnerHTML:{__html:`(${SSe.toString()})(${u})`}})});function ESe({...e}){let{theme:t=`system`}=TSe();return(0,K.jsx)(Jte,{theme:t,className:`toaster group`,style:{"--normal-bg":`var(--popover)`,"--normal-text":`var(--popover-foreground)`,"--normal-border":`var(--border)`},...e})}function DSe(){let e=new URLSearchParams(window.location.search),t=e.get(`embedded`)===`true`,n=e.get(`theme`),r=(0,G.useMemo)(()=>t?void 0:new Or(`mcp-inspector-connections`),[t]),i=window.__MCP_PROXY_URL__,a=i?`${window.location.origin}${i}`:void 0;return(0,K.jsx)(tre,{forcedTheme:n||void 0,children:(0,K.jsx)(zue,{children:(0,K.jsx)(Tr,{storageProvider:r,enableRpcLogging:!0,defaultAutoProxyFallback:a?{enabled:!0,proxyAddress:a}:!1,clientInfo:{name:`mcp-use Inspector`,version:window.__INSPECTOR_VERSION__,websiteUrl:`https://mcp-use.com`,icons:[{src:`https://mcp-use.com/logo.png`}],capabilities:{extensions:{"io.modelcontextprotocol/ui":{mimeTypes:[`text/html;profile=mcp-app`]}}}},onServerAdded:(e,t)=>{console.log(`[Inspector] Server added:`,e,t.state)},onServerRemoved:e=>{console.log(`[Inspector] Server removed:`,e)},onServerStateChange:(e,t)=>{console.log(`[Inspector] Server state changed:`,e,t)},onSamplingRequest:(e,t,n,r,i)=>{let a=xv((0,K.jsx)(Oxe,{requestId:e.id,serverName:n,onViewDetails:()=>{let t=new CustomEvent(`navigate-to-sampling`,{detail:{requestId:e.id}});window.dispatchEvent(t),xv.dismiss(a)},onApprove:t=>{r(e.id,t),xv.success(`Sampling request approved`),xv.dismiss(a)},onDeny:()=>{i(e.id,`User denied from toast`),xv.dismiss(a)}}),{duration:1/0})},onElicitationRequest:(e,t,n,r,i)=>{let a=e.request.mode||`form`,o=e.request.message,s=a===`url`&&`url`in e.request?e.request.url:void 0,c=xv((0,K.jsx)(Lr,{requestId:e.id,serverName:n,mode:a,message:o,url:s,onViewDetails:()=>{let t=new CustomEvent(`navigate-to-elicitation`,{detail:{requestId:e.id}});window.dispatchEvent(t),xv.dismiss(c)},onOpenUrl:a===`url`&&s?()=>{window.open(s,`_blank`),xv.dismiss(c)}:void 0,onCancel:()=>{i(e.id,`User cancelled from toast`),xv.dismiss(c)}}),{duration:1/0})},children:(0,K.jsxs)(dle,{children:[(0,K.jsx)(dte,{basename:`/inspector`,children:(0,K.jsxs)(k_,{children:[(0,K.jsx)(D_,{path:`/oauth/callback`,element:(0,K.jsx)(xSe,{})}),(0,K.jsx)(D_,{path:`/`,element:(0,K.jsx)(vSe,{children:(0,K.jsx)(ule,{})})})]})}),(0,K.jsx)(ESe,{position:`top-center`})]})})})})}var Q9=new URLSearchParams(window.location.search);if(Q9.has(`code`)||Q9.has(`error`))try{fn()}catch(e){console.error(`[inspector] OAuth callback error:`,e)}var $9=document.getElementById(`root`);$9?Ir.createRoot($9).render((0,K.jsx)(DSe,{})):console.error(`[inspector] Root element not found`);export{G6 as $,U$ as $n,m0 as $t,Pve as A,C1 as An,rn as Ar,b3 as At,X6 as B,m1 as Bn,R0 as Bt,O8 as C,N1 as Cn,fn as Cr,W3 as Ct,E8 as D,k1 as Dn,Zt as Dr,E3 as Dt,D8 as E,O1 as En,Xt as Er,P3 as Et,Ove as F,D1 as Fn,Qt as Fr,Y0 as Ft,R6 as G,p1 as Gn,O0 as Gt,Rve as H,h1 as Hn,N0 as Ht,Dve as I,x1 as In,an as Ir,q0 as It,K6 as J,_1 as Jn,v0 as Jt,Ave as K,s1 as Kn,j0 as Kt,Lve as L,v1 as Ln,en as Lr,J0 as Lt,H6 as M,T1 as Mn,Kt as Mr,s3 as Mt,kve as N,S1 as Nn,nn as Nr,r3 as Nt,y8 as O,A1 as On,Yt as Or,D3 as Ot,V6 as P,E1 as Pn,Jt as Pr,W4 as Pt,W6 as Q,G$ as Qn,g0 as Qt,Nve as R,b1 as Rn,qt as Rr,H0 as Rt,j8 as S,M1 as Sn,dn as Sr,U3 as St,A8 as T,F1 as Tn,Me as Tr,R3 as Tt,Eve as U,d1 as Un,M0 as Ut,$6 as V,u1 as Vn,I0 as Vt,jve as W,f1 as Wn,S0 as Wt,B6 as X,o1 as Xn,p0 as Xt,z6 as Y,l1 as Yn,_0 as Yt,J6 as Z,K$ as Zn,u0 as Zt,X8 as _,B1 as _n,gn as _r,K3 as _t,e5 as a,Ime as an,N$ as ar,M6 as at,q8 as b,R1 as bn,yn as br,B3 as bt,J8 as c,Fme as cn,O$ as cr,T6 as ct,G8 as d,K1 as dn,k$ as dr,lve as dt,h0 as en,B$ as er,q6 as et,W8 as f,G1 as fn,F$ as fr,f6 as ft,U8 as g,W1 as gn,vn as gr,q3 as gt,H8 as h,U1 as hn,xn as hr,X3 as ht,Q8 as i,c0 as in,L$ as ir,N6 as it,Y6 as j,w1 as jn,tn as jr,l3 as jt,Mve as k,j1 as kn,Wt as kr,w3 as kt,V8 as l,J1 as ln,M$ as lr,w6 as lt,Y8 as m,H1 as mn,D$ as mr,J3 as mt,c5 as n,l0 as nn,dme as nr,L6 as nt,n5 as o,X1 as on,I$ as or,D6 as ot,lbe as p,V1 as pn,P$ as pr,Z3 as pt,U6 as q,g1 as qn,f0 as qt,s5 as r,s0 as rn,R$ as rr,I6 as rt,B8 as s,Y1 as sn,A$ as sr,E6 as st,l5 as t,o0 as tn,H$ as tr,Tve as tt,obe as u,q1 as un,j$ as ur,_6 as ut,K8 as v,I1 as vn,hn as vr,G3 as vt,k8 as w,P1 as wn,Gt as wr,z3 as wt,M8 as x,z1 as xn,sn as xr,V3 as xt,z8 as y,L1 as yn,_n as yr,H3 as yt,Z6 as z,c1 as zn,$t as zr,B0 as zt};
|