@tonyclaw/agent-inspector 2.1.14 → 2.1.15
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/.output/nitro.json +1 -1
- package/.output/public/assets/CompareDrawer-BcEd6V-V.js +1 -0
- package/.output/public/assets/ProxyViewerContainer-h851qWNp.js +106 -0
- package/.output/public/assets/ReplayDialog-BNpC0548.js +1 -0
- package/.output/public/assets/{RequestAnatomy-BNahe83D.js → RequestAnatomy-Ds1uRLVB.js} +1 -1
- package/.output/public/assets/{ResponseView-DSOnGqi6.js → ResponseView-7KPVqKl5.js} +2 -2
- package/.output/public/assets/{StreamingChunkSequence-BEKTDklB.js → StreamingChunkSequence-BHQT261s.js} +1 -1
- package/.output/public/assets/_sessionId-DWePGjnS.js +1 -0
- package/.output/public/assets/index-CI1-G8ua.js +1 -0
- package/.output/public/assets/index-DdhFqPsI.css +1 -0
- package/.output/public/assets/{index-DWOkqdCa.js → index-DjKt8XKe.js} +1 -1
- package/.output/public/assets/{json-viewer-C2JpgcW0.js → json-viewer-CkCu-rka.js} +1 -1
- package/.output/public/assets/{main-CSONBwwn.js → main-DpD1N0S8.js} +2 -2
- package/.output/server/_libs/lucide-react.mjs +194 -200
- package/.output/server/{_sessionId-CPAa37n5.mjs → _sessionId-DF9Sy8cP.mjs} +2 -2
- package/.output/server/_ssr/{CompareDrawer-ceW5VxMo.mjs → CompareDrawer-BoxztaO7.mjs} +36 -15
- package/.output/server/_ssr/{ProxyViewerContainer-CDfEE_w-.mjs → ProxyViewerContainer-CRBkqFlJ.mjs} +362 -124
- package/.output/server/_ssr/{ReplayDialog-V0s_eEbR.mjs → ReplayDialog-Cc1dyDuK.mjs} +14 -7
- package/.output/server/_ssr/{RequestAnatomy-f1ccwR9d.mjs → RequestAnatomy-CMGSsz5Z.mjs} +2 -2
- package/.output/server/_ssr/{ResponseView-BIRrqG4H.mjs → ResponseView-Cp10DM1D.mjs} +3 -3
- package/.output/server/_ssr/{StreamingChunkSequence-V3JFjCgX.mjs → StreamingChunkSequence-B1VGxy3A.mjs} +2 -2
- package/.output/server/_ssr/{index-DsykulzS.mjs → index-47XVPghS.mjs} +2 -2
- package/.output/server/_ssr/index.mjs +2 -2
- package/.output/server/_ssr/{json-viewer-Dcnm0Ivf.mjs → json-viewer-zDE2rrmJ.mjs} +3 -3
- package/.output/server/_ssr/{router-4bdm6Mt2.mjs → router-DVeuZFqI.mjs} +10 -5
- package/.output/server/{_tanstack-start-manifest_v-Xp4CO64V.mjs → _tanstack-start-manifest_v-Bp8JxtPW.mjs} +1 -1
- package/.output/server/index.mjs +68 -68
- package/package.json +1 -1
- package/src/components/ProxyViewer.tsx +28 -2
- package/src/components/clients/ClientLogo.tsx +132 -0
- package/src/components/groups/GroupsDialog.tsx +18 -13
- package/src/components/proxy-viewer/AgentTraceSummary.tsx +56 -23
- package/src/components/proxy-viewer/CompareDrawer.tsx +38 -8
- package/src/components/proxy-viewer/ConversationHeader.tsx +33 -41
- package/src/components/proxy-viewer/LogEntry.tsx +10 -1
- package/src/components/proxy-viewer/LogEntryHeader.tsx +14 -14
- package/src/components/proxy-viewer/ProviderLogoStack.tsx +60 -0
- package/src/components/proxy-viewer/ReplayDialog.tsx +8 -2
- package/src/components/proxy-viewer/ThreadConnector.tsx +18 -7
- package/src/components/proxy-viewer/TurnGroup.tsx +14 -25
- package/src/components/proxy-viewer/viewerState.ts +5 -2
- package/src/lib/sessionInfoContract.ts +1 -0
- package/src/lib/stopReason.ts +48 -16
- package/src/proxy/sessionInfo.ts +5 -1
- package/.output/public/assets/CompareDrawer-DjgjIFx7.js +0 -1
- package/.output/public/assets/ProxyViewerContainer-CWUQZLYy.js +0 -106
- package/.output/public/assets/ReplayDialog-CU0Tbb2c.js +0 -1
- package/.output/public/assets/_sessionId-Cif8JZdn.js +0 -1
- package/.output/public/assets/index-D_WfwzUi.js +0 -1
- package/.output/public/assets/index-DtLuQrs0.css +0 -1
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CompareDrawer-BcEd6V-V.js","assets/main-DpD1N0S8.js","assets/ReplayDialog-BNpC0548.js","assets/ResponseView-7KPVqKl5.js","assets/RequestAnatomy-Ds1uRLVB.js","assets/StreamingChunkSequence-BHQT261s.js","assets/json-viewer-CkCu-rka.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{u as _n,a as Tu,r as p,j as s,c as Hr,g as Nm,b as Eu,d as Ar,e as Tm,f as rt,h as Au,_ as jn}from"./main-DpD1N0S8.js";function X(e,t,n){function r(l,c){if(l._zod||Object.defineProperty(l,"_zod",{value:{def:c,constr:a,traits:new Set},enumerable:!1}),l._zod.traits.has(e))return;l._zod.traits.add(e),t(l,c);const u=a.prototype,d=Object.keys(u);for(let f=0;f<d.length;f++){const h=d[f];h in l||(l[h]=u[h].bind(l))}}const o=n?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function a(l){var c;const u=n?.Parent?new i:this;r(u,l),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(a,"init",{value:r}),Object.defineProperty(a,Symbol.hasInstance,{value:l=>n?.Parent&&l instanceof n.Parent?!0:l?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}class $n extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ru extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Iu={};function Qt(e){return Iu}function zu(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function pi(e,t){return typeof t=="bigint"?t.toString():t}function so(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function sa(e){return e==null}function oa(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Em(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let o=(r.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(r)){const c=r.match(/\d?e-(\d?)/);c?.[1]&&(o=Number.parseInt(c[1]))}const i=n>o?n:o,a=Number.parseInt(e.toFixed(i).replace(".","")),l=Number.parseInt(t.toFixed(i).replace(".",""));return a%l/10**i}const xl=Symbol("evaluating");function ze(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==xl)return r===void 0&&(r=xl,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Sn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function sn(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function bl(e){return JSON.stringify(e)}function Am(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Ou="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function yr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Rm=so(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Hn(e){if(yr(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(yr(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Pu(e){return Hn(e)?{...e}:Array.isArray(e)?[...e]:e}const Im=new Set(["string","number","symbol"]);function Zn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function on(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function we(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function zm(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Om={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Pm(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=sn(e._zod.def,{get shape(){const a={};for(const l in t){if(!(l in n.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&(a[l]=n.shape[l])}return Sn(this,"shape",a),a},checks:[]});return on(e,i)}function Mm(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=sn(e._zod.def,{get shape(){const a={...e._zod.def.shape};for(const l in t){if(!(l in n.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&delete a[l]}return Sn(this,"shape",a),a},checks:[]});return on(e,i)}function Lm(e,t){if(!Hn(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const i=e._zod.def.shape;for(const a in t)if(Object.getOwnPropertyDescriptor(i,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=sn(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Sn(this,"shape",i),i}});return on(e,o)}function Dm(e,t){if(!Hn(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=sn(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Sn(this,"shape",r),r}});return on(e,n)}function $m(e,t){const n=sn(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return Sn(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return on(e,n)}function Fm(e,t,n){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const a=sn(t._zod.def,{get shape(){const l=t._zod.def.shape,c={...l};if(n)for(const u in n){if(!(u in l))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(c[u]=e?new e({type:"optional",innerType:l[u]}):l[u])}else for(const u in l)c[u]=e?new e({type:"optional",innerType:l[u]}):l[u];return Sn(this,"shape",c),c},checks:[]});return on(t,a)}function Bm(e,t,n){const r=sn(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const a in n){if(!(a in i))throw new Error(`Unrecognized key: "${a}"`);n[a]&&(i[a]=new e({type:"nonoptional",innerType:o[a]}))}else for(const a in o)i[a]=new e({type:"nonoptional",innerType:o[a]});return Sn(this,"shape",i),i}});return on(t,r)}function Ln(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Dn(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Zr(e){return typeof e=="string"?e:e?.message}function en(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const o=Zr(e.inst?._zod.def?.error?.(e))??Zr(t?.error?.(e))??Zr(n.customError?.(e))??Zr(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function ia(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function wr(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const Mu=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,pi,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Lu=X("$ZodError",Mu),Du=X("$ZodError",Mu,{Parent:Error});function Um(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function Wm(e,t=n=>n.message){const n={_errors:[]},r=o=>{for(const i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>r({issues:a}));else if(i.code==="invalid_key")r({issues:i.issues});else if(i.code==="invalid_element")r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let a=n,l=0;for(;l<i.path.length;){const c=i.path[l];l===i.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(t(i))):a[c]=a[c]||{_errors:[]},a=a[c],l++}}};return r(e),n}const aa=e=>(t,n,r,o)=>{const i=r?Object.assign(r,{async:!1}):{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new $n;if(a.issues.length){const l=new(o?.Err??e)(a.issues.map(c=>en(c,i,Qt())));throw Ou(l,o?.callee),l}return a.value},la=e=>async(t,n,r,o)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){const l=new(o?.Err??e)(a.issues.map(c=>en(c,i,Qt())));throw Ou(l,o?.callee),l}return a.value},oo=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new $n;return i.issues.length?{success:!1,error:new(e??Lu)(i.issues.map(a=>en(a,o,Qt())))}:{success:!0,data:i.value}},Hm=oo(Du),io=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(a=>en(a,o,Qt())))}:{success:!0,data:i.value}},Zm=io(Du),Vm=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return aa(e)(t,n,o)},qm=e=>(t,n,r)=>aa(e)(t,n,r),Gm=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return la(e)(t,n,o)},Km=e=>async(t,n,r)=>la(e)(t,n,r),Jm=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return oo(e)(t,n,o)},Ym=e=>(t,n,r)=>oo(e)(t,n,r),Xm=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return io(e)(t,n,o)},Qm=e=>async(t,n,r)=>io(e)(t,n,r),eg=/^[cC][^\s-]{8,}$/,tg=/^[0-9a-z]+$/,ng=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,rg=/^[0-9a-vA-V]{20}$/,sg=/^[A-Za-z0-9]{27}$/,og=/^[a-zA-Z0-9_-]{21}$/,ig=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ag=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,vl=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,lg=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,cg="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function ug(){return new RegExp(cg,"u")}const dg=/^(?:(?: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])$/,fg=/^(([0-9a-fA-F]{1,4}:){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}|:))$/,pg=/^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/,hg=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,mg=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,$u=/^[A-Za-z0-9_-]*$/,gg=/^\+[1-9]\d{6,14}$/,Fu="(?:(?:\\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])))",xg=new RegExp(`^${Fu}$`);function Bu(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function bg(e){return new RegExp(`^${Bu(e)}$`)}function vg(e){const t=Bu({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${Fu}T(?:${r})$`)}const yg=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},wg=/^-?\d+$/,Uu=/^-?\d+(?:\.\d+)?$/,kg=/^(?:true|false)$/i,_g=/^null$/i,jg=/^[^A-Z]*$/,Sg=/^[^a-z]*$/,st=X("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Wu={number:"number",bigint:"bigint",object:"date"},Hu=X("$ZodCheckLessThan",(e,t)=>{st.init(e,t);const n=Wu[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Zu=X("$ZodCheckGreaterThan",(e,t)=>{st.init(e,t);const n=Wu[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Cg=X("$ZodCheckMultipleOf",(e,t)=>{st.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):Em(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Ng=X("$ZodCheckNumberFormat",(e,t)=>{st.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,i]=Om[t.format];e._zod.onattach.push(a=>{const l=a._zod.bag;l.format=t.format,l.minimum=o,l.maximum=i,n&&(l.pattern=wg)}),e._zod.check=a=>{const l=a.value;if(n){if(!Number.isInteger(l)){a.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:l,inst:e});return}if(!Number.isSafeInteger(l)){l>0?a.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):a.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}l<o&&a.issues.push({origin:"number",input:l,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),l>i&&a.issues.push({origin:"number",input:l,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),Tg=X("$ZodCheckMaxLength",(e,t)=>{var n;st.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!sa(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const a=ia(o);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Eg=X("$ZodCheckMinLength",(e,t)=>{var n;st.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!sa(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const a=ia(o);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ag=X("$ZodCheckLengthEquals",(e,t)=>{var n;st.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!sa(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,i=o.length;if(i===t.length)return;const a=ia(o),l=i>t.length;r.issues.push({origin:a,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),ao=X("$ZodCheckStringFormat",(e,t)=>{var n,r;st.init(e,t),e._zod.onattach.push(o=>{const i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Rg=X("$ZodCheckRegex",(e,t)=>{ao.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ig=X("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=jg),ao.init(e,t)}),zg=X("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Sg),ao.init(e,t)}),Og=X("$ZodCheckIncludes",(e,t)=>{st.init(e,t);const n=Zn(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Pg=X("$ZodCheckStartsWith",(e,t)=>{st.init(e,t);const n=new RegExp(`^${Zn(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Mg=X("$ZodCheckEndsWith",(e,t)=>{st.init(e,t);const n=new RegExp(`.*${Zn(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),Lg=X("$ZodCheckOverwrite",(e,t)=>{st.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Dg{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
3
|
+
`).filter(a=>a),o=Math.min(...r.map(a=>a.length-a.trimStart().length)),i=r.map(a=>a.slice(o)).map(a=>" ".repeat(this.indent*2)+a);for(const a of i)this.content.push(a)}compile(){const t=Function,n=this?.args,o=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...n,o.join(`
|
|
4
|
+
`))}}const $g={major:4,minor:3,patch:6},Ue=X("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=$g;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const i of o._zod.onattach)i(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(a,l,c)=>{let u=Ln(a),d;for(const f of l){if(f._zod.def.when){if(!f._zod.def.when(a))continue}else if(u)continue;const h=a.issues.length,m=f._zod.check(a);if(m instanceof Promise&&c?.async===!1)throw new $n;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await m,a.issues.length!==h&&(u||(u=Ln(a,h)))});else{if(a.issues.length===h)continue;u||(u=Ln(a,h))}}return d?d.then(()=>a):a},i=(a,l,c)=>{if(Ln(a))return a.aborted=!0,a;const u=o(l,r,c);if(u instanceof Promise){if(c.async===!1)throw new $n;return u.then(d=>e._zod.parse(d,c))}return e._zod.parse(u,c)};e._zod.run=(a,l)=>{if(l.skipChecks)return e._zod.parse(a,l);if(l.direction==="backward"){const u=e._zod.parse({value:a.value,issues:[]},{...l,skipChecks:!0});return u instanceof Promise?u.then(d=>i(d,a,l)):i(u,a,l)}const c=e._zod.parse(a,l);if(c instanceof Promise){if(l.async===!1)throw new $n;return c.then(u=>o(u,r,l))}return o(c,r,l)}}ze(e,"~standard",()=>({validate:o=>{try{const i=Hm(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return Zm(e,o).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}))}),ca=X("$ZodString",(e,t)=>{Ue.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??yg(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),He=X("$ZodStringFormat",(e,t)=>{ao.init(e,t),ca.init(e,t)}),Fg=X("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ag),He.init(e,t)}),Bg=X("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=vl(r))}else t.pattern??(t.pattern=vl());He.init(e,t)}),Ug=X("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=lg),He.init(e,t)}),Wg=X("$ZodURL",(e,t)=>{He.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Hg=X("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=ug()),He.init(e,t)}),Zg=X("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=og),He.init(e,t)}),Vg=X("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=eg),He.init(e,t)}),qg=X("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=tg),He.init(e,t)}),Gg=X("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ng),He.init(e,t)}),Kg=X("$ZodXID",(e,t)=>{t.pattern??(t.pattern=rg),He.init(e,t)}),Jg=X("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=sg),He.init(e,t)}),Yg=X("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=vg(t)),He.init(e,t)}),Xg=X("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=xg),He.init(e,t)}),Qg=X("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=bg(t)),He.init(e,t)}),ex=X("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ig),He.init(e,t)}),tx=X("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=dg),He.init(e,t),e._zod.bag.format="ipv4"}),nx=X("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=fg),He.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),rx=X("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=pg),He.init(e,t)}),sx=X("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=hg),He.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[o,i]=r;if(!i)throw new Error;const a=Number(i);if(`${a}`!==i)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Vu(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const ox=X("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=mg),He.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Vu(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function ix(e){if(!$u.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Vu(n)}const ax=X("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=$u),He.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{ix(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),lx=X("$ZodE164",(e,t)=>{t.pattern??(t.pattern=gg),He.init(e,t)});function cx(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const ux=X("$ZodJWT",(e,t)=>{He.init(e,t),e._zod.check=n=>{cx(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),qu=X("$ZodNumber",(e,t)=>{Ue.init(e,t),e._zod.pattern=e._zod.bag.pattern??Uu,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),n}}),dx=X("$ZodNumberFormat",(e,t)=>{Ng.init(e,t),qu.init(e,t)}),fx=X("$ZodBoolean",(e,t)=>{Ue.init(e,t),e._zod.pattern=kg,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),px=X("$ZodNull",(e,t)=>{Ue.init(e,t),e._zod.pattern=_g,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{const o=n.value;return o===null||n.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),n}}),hx=X("$ZodUnknown",(e,t)=>{Ue.init(e,t),e._zod.parse=n=>n}),mx=X("$ZodNever",(e,t)=>{Ue.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function yl(e,t,n){e.issues.length&&t.issues.push(...Dn(n,e.issues)),t.value[n]=e.value}const gx=X("$ZodArray",(e,t)=>{Ue.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const i=[];for(let a=0;a<o.length;a++){const l=o[a],c=t.element._zod.run({value:l,issues:[]},r);c instanceof Promise?i.push(c.then(u=>yl(u,n,a))):yl(c,n,a)}return i.length?Promise.all(i).then(()=>n):n}});function Ss(e,t,n,r,o){if(e.issues.length){if(o&&!(n in r))return;t.issues.push(...Dn(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Gu(e){const t=Object.keys(e.shape);for(const r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const n=zm(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Ku(e,t,n,r,o,i){const a=[],l=o.keySet,c=o.catchall._zod,u=c.def.type,d=c.optout==="optional";for(const f in t){if(l.has(f))continue;if(u==="never"){a.push(f);continue}const h=c.run({value:t[f],issues:[]},r);h instanceof Promise?e.push(h.then(m=>Ss(m,n,f,t,d))):Ss(h,n,f,t,d)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const xx=X("$ZodObject",(e,t)=>{if(Ue.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const l=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...l};return Object.defineProperty(t,"shape",{value:c}),c}})}const r=so(()=>Gu(t));ze(e._zod,"propValues",()=>{const l=t.shape,c={};for(const u in l){const d=l[u]._zod;if(d.values){c[u]??(c[u]=new Set);for(const f of d.values)c[u].add(f)}}return c});const o=yr,i=t.catchall;let a;e._zod.parse=(l,c)=>{a??(a=r.value);const u=l.value;if(!o(u))return l.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),l;l.value={};const d=[],f=a.shape;for(const h of a.keys){const m=f[h],v=m._zod.optout==="optional",g=m._zod.run({value:u[h],issues:[]},c);g instanceof Promise?d.push(g.then(x=>Ss(x,l,h,u,v))):Ss(g,l,h,u,v)}return i?Ku(d,u,l,c,r.value,e):d.length?Promise.all(d).then(()=>l):l}}),bx=X("$ZodObjectJIT",(e,t)=>{xx.init(e,t);const n=e._zod.parse,r=so(()=>Gu(t)),o=h=>{const m=new Dg(["shape","payload","ctx"]),v=r.value,g=_=>{const j=bl(_);return`shape[${j}]._zod.run({ value: input[${j}], issues: [] }, ctx)`};m.write("const input = payload.value;");const x=Object.create(null);let b=0;for(const _ of v.keys)x[_]=`key_${b++}`;m.write("const newResult = {};");for(const _ of v.keys){const j=x[_],S=bl(_),C=h[_]?._zod?.optout==="optional";m.write(`const ${j} = ${g(_)};`),C?m.write(`
|
|
5
|
+
if (${j}.issues.length) {
|
|
6
|
+
if (${S} in input) {
|
|
7
|
+
payload.issues = payload.issues.concat(${j}.issues.map(iss => ({
|
|
8
|
+
...iss,
|
|
9
|
+
path: iss.path ? [${S}, ...iss.path] : [${S}]
|
|
10
|
+
})));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (${j}.value === undefined) {
|
|
15
|
+
if (${S} in input) {
|
|
16
|
+
newResult[${S}] = undefined;
|
|
17
|
+
}
|
|
18
|
+
} else {
|
|
19
|
+
newResult[${S}] = ${j}.value;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
`):m.write(`
|
|
23
|
+
if (${j}.issues.length) {
|
|
24
|
+
payload.issues = payload.issues.concat(${j}.issues.map(iss => ({
|
|
25
|
+
...iss,
|
|
26
|
+
path: iss.path ? [${S}, ...iss.path] : [${S}]
|
|
27
|
+
})));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (${j}.value === undefined) {
|
|
31
|
+
if (${S} in input) {
|
|
32
|
+
newResult[${S}] = undefined;
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
newResult[${S}] = ${j}.value;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
`)}m.write("payload.value = newResult;"),m.write("return payload;");const y=m.compile();return(_,j)=>y(h,_,j)};let i;const a=yr,l=!Iu.jitless,u=l&&Rm.value,d=t.catchall;let f;e._zod.parse=(h,m)=>{f??(f=r.value);const v=h.value;return a(v)?l&&u&&m?.async===!1&&m.jitless!==!0?(i||(i=o(t.shape)),h=i(h,m),d?Ku([],v,h,m,f,e):h):n(h,m):(h.issues.push({expected:"object",code:"invalid_type",input:v,inst:e}),h)}});function wl(e,t,n,r){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!Ln(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(a=>en(a,r,Qt())))}),t)}const Ju=X("$ZodUnion",(e,t)=>{Ue.init(e,t),ze(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),ze(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),ze(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),ze(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>oa(i.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(n)return r(o,i);let a=!1;const l=[];for(const c of t.options){const u=c._zod.run({value:o.value,issues:[]},i);if(u instanceof Promise)l.push(u),a=!0;else{if(u.issues.length===0)return u;l.push(u)}}return a?Promise.all(l).then(c=>wl(c,o,e,i)):wl(l,o,e,i)}}),vx=X("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ju.init(e,t);const n=e._zod.parse;ze(e._zod,"propValues",()=>{const o={};for(const i of t.options){const a=i._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const[l,c]of Object.entries(a)){o[l]||(o[l]=new Set);for(const u of c)o[l].add(u)}}return o});const r=so(()=>{const o=t.options,i=new Map;for(const a of o){const l=a._zod.propValues?.[t.discriminator];if(!l||l.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(const c of l){if(i.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);i.set(c,a)}}return i});e._zod.parse=(o,i)=>{const a=o.value;if(!yr(a))return o.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),o;const l=r.value.get(a?.[t.discriminator]);return l?l._zod.run(o,i):t.unionFallback?n(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:e}),o)}}),yx=X("$ZodIntersection",(e,t)=>{Ue.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},r),a=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([c,u])=>kl(n,c,u)):kl(n,i,a)}});function hi(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Hn(e)&&Hn(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};for(const i of r){const a=hi(e[i],t[i]);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};o[i]=a.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],i=t[r],a=hi(o,i);if(!a.valid)return{valid:!1,mergeErrorPath:[r,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function kl(e,t,n){const r=new Map;let o;for(const l of t.issues)if(l.code==="unrecognized_keys"){o??(o=l);for(const c of l.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else e.issues.push(l);for(const l of n.issues)if(l.code==="unrecognized_keys")for(const c of l.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else e.issues.push(l);const i=[...r].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(i.length&&o&&e.issues.push({...o,keys:i}),Ln(e))return e;const a=hi(t.value,n.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}const wx=X("$ZodRecord",(e,t)=>{Ue.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Hn(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const i=[],a=t.keyType._zod.values;if(a){n.value={};const l=new Set;for(const u of a)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){l.add(typeof u=="number"?u.toString():u);const d=t.valueType._zod.run({value:o[u],issues:[]},r);d instanceof Promise?i.push(d.then(f=>{f.issues.length&&n.issues.push(...Dn(u,f.issues)),n.value[u]=f.value})):(d.issues.length&&n.issues.push(...Dn(u,d.issues)),n.value[u]=d.value)}let c;for(const u in o)l.has(u)||(c=c??[],c.push(u));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c})}else{n.value={};for(const l of Reflect.ownKeys(o)){if(l==="__proto__")continue;let c=t.keyType._zod.run({value:l,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof l=="string"&&Uu.test(l)&&c.issues.length){const f=t.keyType._zod.run({value:Number(l),issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");f.issues.length===0&&(c=f)}if(c.issues.length){t.mode==="loose"?n.value[l]=o[l]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(f=>en(f,r,Qt())),input:l,path:[l],inst:e});continue}const d=t.valueType._zod.run({value:o[l],issues:[]},r);d instanceof Promise?i.push(d.then(f=>{f.issues.length&&n.issues.push(...Dn(l,f.issues)),n.value[c.value]=f.value})):(d.issues.length&&n.issues.push(...Dn(l,d.issues)),n.value[c.value]=d.value)}}return i.length?Promise.all(i).then(()=>n):n}}),kx=X("$ZodEnum",(e,t)=>{Ue.init(e,t);const n=zu(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>Im.has(typeof o)).map(o=>typeof o=="string"?Zn(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{const a=o.value;return r.has(a)||o.issues.push({code:"invalid_value",values:n,input:a,inst:e}),o}}),_x=X("$ZodLiteral",(e,t)=>{if(Ue.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?Zn(r):r?Zn(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,o)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}),jx=X("$ZodTransform",(e,t)=>{Ue.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ru(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(a=>(n.value=a,n));if(o instanceof Promise)throw new $n;return n.value=o,n}});function _l(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Yu=X("$ZodOptional",(e,t)=>{Ue.init(e,t),e._zod.optin="optional",e._zod.optout="optional",ze(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ze(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${oa(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>_l(i,n.value)):_l(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),Sx=X("$ZodExactOptional",(e,t)=>{Yu.init(e,t),ze(e._zod,"values",()=>t.innerType._zod.values),ze(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),Cx=X("$ZodNullable",(e,t)=>{Ue.init(e,t),ze(e._zod,"optin",()=>t.innerType._zod.optin),ze(e._zod,"optout",()=>t.innerType._zod.optout),ze(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${oa(n.source)}|null)$`):void 0}),ze(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),Nx=X("$ZodDefault",(e,t)=>{Ue.init(e,t),e._zod.optin="optional",ze(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>jl(i,t)):jl(o,t)}});function jl(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Tx=X("$ZodPrefault",(e,t)=>{Ue.init(e,t),e._zod.optin="optional",ze(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),Ex=X("$ZodNonOptional",(e,t)=>{Ue.init(e,t),ze(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>Sl(i,e)):Sl(o,e)}});function Sl(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Ax=X("$ZodCatch",(e,t)=>{Ue.init(e,t),ze(e._zod,"optin",()=>t.innerType._zod.optin),ze(e._zod,"optout",()=>t.innerType._zod.optout),ze(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(a=>en(a,r,Qt()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(i=>en(i,r,Qt()))},input:n.value}),n.issues=[]),n)}}),Rx=X("$ZodPipe",(e,t)=>{Ue.init(e,t),ze(e._zod,"values",()=>t.in._zod.values),ze(e._zod,"optin",()=>t.in._zod.optin),ze(e._zod,"optout",()=>t.out._zod.optout),ze(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(a=>Vr(a,t.in,r)):Vr(i,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>Vr(i,t.out,r)):Vr(o,t.out,r)}});function Vr(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Ix=X("$ZodReadonly",(e,t)=>{Ue.init(e,t),ze(e._zod,"propValues",()=>t.innerType._zod.propValues),ze(e._zod,"values",()=>t.innerType._zod.values),ze(e._zod,"optin",()=>t.innerType?._zod?.optin),ze(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(Cl):Cl(o)}});function Cl(e){return e.value=Object.freeze(e.value),e}const zx=X("$ZodLazy",(e,t)=>{Ue.init(e,t),ze(e._zod,"innerType",()=>t.getter()),ze(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),ze(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),ze(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),ze(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),Ox=X("$ZodCustom",(e,t)=>{st.init(e,t),Ue.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(i=>Nl(i,n,r,e));Nl(o,n,r,e)}});function Nl(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(wr(o))}}var Tl;class Px{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Mx(){return new Px}(Tl=globalThis).__zod_globalRegistry??(Tl.__zod_globalRegistry=Mx());const mr=globalThis.__zod_globalRegistry;function Lx(e,t){return new e({type:"string",...we(t)})}function Dx(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...we(t)})}function El(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...we(t)})}function $x(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...we(t)})}function Fx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...we(t)})}function Bx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...we(t)})}function Ux(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...we(t)})}function Wx(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...we(t)})}function Hx(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...we(t)})}function Zx(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...we(t)})}function Vx(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...we(t)})}function qx(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...we(t)})}function Gx(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...we(t)})}function Kx(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...we(t)})}function Jx(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...we(t)})}function Yx(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...we(t)})}function Xx(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...we(t)})}function Qx(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...we(t)})}function e0(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...we(t)})}function t0(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...we(t)})}function n0(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...we(t)})}function r0(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...we(t)})}function s0(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...we(t)})}function o0(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...we(t)})}function i0(e,t){return new e({type:"string",format:"date",check:"string_format",...we(t)})}function a0(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...we(t)})}function l0(e,t){return new e({type:"string",format:"duration",check:"string_format",...we(t)})}function c0(e,t){return new e({type:"number",checks:[],...we(t)})}function u0(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...we(t)})}function d0(e,t){return new e({type:"boolean",...we(t)})}function f0(e,t){return new e({type:"null",...we(t)})}function p0(e){return new e({type:"unknown"})}function h0(e,t){return new e({type:"never",...we(t)})}function Al(e,t){return new Hu({check:"less_than",...we(t),value:e,inclusive:!1})}function Po(e,t){return new Hu({check:"less_than",...we(t),value:e,inclusive:!0})}function Rl(e,t){return new Zu({check:"greater_than",...we(t),value:e,inclusive:!1})}function Mo(e,t){return new Zu({check:"greater_than",...we(t),value:e,inclusive:!0})}function Il(e,t){return new Cg({check:"multiple_of",...we(t),value:e})}function Xu(e,t){return new Tg({check:"max_length",...we(t),maximum:e})}function Cs(e,t){return new Eg({check:"min_length",...we(t),minimum:e})}function Qu(e,t){return new Ag({check:"length_equals",...we(t),length:e})}function m0(e,t){return new Rg({check:"string_format",format:"regex",...we(t),pattern:e})}function g0(e){return new Ig({check:"string_format",format:"lowercase",...we(e)})}function x0(e){return new zg({check:"string_format",format:"uppercase",...we(e)})}function b0(e,t){return new Og({check:"string_format",format:"includes",...we(t),includes:e})}function v0(e,t){return new Pg({check:"string_format",format:"starts_with",...we(t),prefix:e})}function y0(e,t){return new Mg({check:"string_format",format:"ends_with",...we(t),suffix:e})}function Qn(e){return new Lg({check:"overwrite",tx:e})}function w0(e){return Qn(t=>t.normalize(e))}function k0(){return Qn(e=>e.trim())}function _0(){return Qn(e=>e.toLowerCase())}function j0(){return Qn(e=>e.toUpperCase())}function S0(){return Qn(e=>Am(e))}function C0(e,t,n){return new e({type:"array",element:t,...we(n)})}function N0(e,t,n){return new e({type:"custom",check:"custom",fn:t,...we(n)})}function T0(e){const t=E0(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(wr(r,n.value,t._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),n.issues.push(wr(o))}},e(n.value,n)));return t}function E0(e,t){const n=new st({check:"custom",...we(t)});return n._zod.check=e,n}function ed(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??mr,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function Ve(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a);const l=e._zod.toJSONSchema?.();if(l)a.schema=l;else{const d={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,d);else{const h=a.schema,m=t.processors[o.type];if(!m)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);m(e,t,h,d)}const f=e._zod.parent;f&&(a.ref||(a.ref=f),Ve(f,t,d),t.seen.get(f).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(a.schema,c),t.io==="input"&&tt(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&a.schema._prefault&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function td(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const a of e.seen.entries()){const l=e.metadataRegistry.get(a[0])?.id;if(l){const c=r.get(l);if(c&&c!==a[0])throw new Error(`Duplicate schema id "${l}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(l,a[0])}}const o=a=>{const l=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const f=e.external.registry.get(a[0])?.id,h=e.external.uri??(v=>v);if(f)return{ref:h(f)};const m=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=m,{defId:m,ref:`${h("__shared")}#/${l}/${m}`}}if(a[1]===n)return{ref:"#"};const u=`#/${l}/`,d=a[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:u+d}},i=a=>{if(a[1].schema.$ref)return;const l=a[1],{ref:c,defId:u}=o(a);l.def={...l.schema},u&&(l.defId=u);const d=l.schema;for(const f in d)delete d[f];d.$ref=c};if(e.cycles==="throw")for(const a of e.seen.entries()){const l=a[1];if(l.cycle)throw new Error(`Cycle detected: #/${l.cycle?.join("/")}/<root>
|
|
39
|
+
|
|
40
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const a of e.seen.entries()){const l=a[1];if(t===a[0]){i(a);continue}if(e.external){const u=e.external.registry.get(a[0])?.id;if(t!==a[0]&&u){i(a);continue}}if(e.metadataRegistry.get(a[0])?.id){i(a);continue}if(l.cycle){i(a);continue}if(l.count>1&&e.reused==="ref"){i(a);continue}}}function nd(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=a=>{const l=e.seen.get(a);if(l.ref===null)return;const c=l.def??l.schema,u={...c},d=l.ref;if(l.ref=null,d){r(d);const h=e.seen.get(d),m=h.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(m)):Object.assign(c,m),Object.assign(c,u),a._zod.parent===d)for(const g in c)g==="$ref"||g==="allOf"||g in u||delete c[g];if(m.$ref&&h.def)for(const g in c)g==="$ref"||g==="allOf"||g in h.def&&JSON.stringify(c[g])===JSON.stringify(h.def[g])&&delete c[g]}const f=a._zod.parent;if(f&&f!==d){r(f);const h=e.seen.get(f);if(h?.schema.$ref&&(c.$ref=h.schema.$ref,h.def))for(const m in c)m==="$ref"||m==="allOf"||m in h.def&&JSON.stringify(c[m])===JSON.stringify(h.def[m])&&delete c[m]}e.override({zodSchema:a,jsonSchema:c,path:l.path??[]})};for(const a of[...e.seen.entries()].reverse())r(a[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}Object.assign(o,n.def??n.schema);const i=e.external?.defs??{};for(const a of e.seen.entries()){const l=a[1];l.def&&l.defId&&(i[l.defId]=l.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{const a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ns(t,"input",e.processors),output:Ns(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function tt(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return tt(r.element,n);if(r.type==="set")return tt(r.valueType,n);if(r.type==="lazy")return tt(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return tt(r.innerType,n);if(r.type==="intersection")return tt(r.left,n)||tt(r.right,n);if(r.type==="record"||r.type==="map")return tt(r.keyType,n)||tt(r.valueType,n);if(r.type==="pipe")return tt(r.in,n)||tt(r.out,n);if(r.type==="object"){for(const o in r.shape)if(tt(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(tt(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(tt(o,n))return!0;return!!(r.rest&&tt(r.rest,n))}return!1}const A0=(e,t={})=>n=>{const r=ed({...n,processors:t});return Ve(e,r),td(r,e),nd(r,e)},Ns=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},a=ed({...o??{},target:i,io:t,processors:n});return Ve(e,a),td(a,e),nd(a,e)},R0={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},I0=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:i,maximum:a,format:l,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof a=="number"&&(o.maxLength=a),l&&(o.format=R0[l]??l,o.format===""&&delete o.format,l==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){const d=[...c];d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},z0=(e,t,n,r)=>{const o=n,{minimum:i,maximum:a,format:l,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:d}=e._zod.bag;typeof l=="string"&&l.includes("int")?o.type="integer":o.type="number",typeof d=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.minimum=d,o.exclusiveMinimum=!0):o.exclusiveMinimum=d),typeof i=="number"&&(o.minimum=i,typeof d=="number"&&t.target!=="draft-04"&&(d>=i?delete o.minimum:delete o.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u),typeof a=="number"&&(o.maximum=a,typeof u=="number"&&t.target!=="draft-04"&&(u<=a?delete o.maximum:delete o.exclusiveMaximum)),typeof c=="number"&&(o.multipleOf=c)},O0=(e,t,n,r)=>{n.type="boolean"},P0=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},M0=(e,t,n,r)=>{n.not={}},L0=(e,t,n,r)=>{},D0=(e,t,n,r)=>{const o=e._zod.def,i=zu(o.entries);i.every(a=>typeof a=="number")&&(n.type="number"),i.every(a=>typeof a=="string")&&(n.type="string"),n.enum=i},$0=(e,t,n,r)=>{const o=e._zod.def,i=[];for(const a of o.values)if(a===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(a))}else i.push(a);if(i.length!==0)if(i.length===1){const a=i[0];n.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[a]:n.const=a}else i.every(a=>typeof a=="number")&&(n.type="number"),i.every(a=>typeof a=="string")&&(n.type="string"),i.every(a=>typeof a=="boolean")&&(n.type="boolean"),i.every(a=>a===null)&&(n.type="null"),n.enum=i},F0=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},B0=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},U0=(e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:a,maximum:l}=e._zod.bag;typeof a=="number"&&(o.minItems=a),typeof l=="number"&&(o.maxItems=l),o.type="array",o.items=Ve(i.element,t,{...r,path:[...r.path,"items"]})},W0=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object",o.properties={};const a=i.shape;for(const u in a)o.properties[u]=Ve(a[u],t,{...r,path:[...r.path,"properties",u]});const l=new Set(Object.keys(a)),c=new Set([...l].filter(u=>{const d=i.shape[u]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));c.size>0&&(o.required=Array.from(c)),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=Ve(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},H0=(e,t,n,r)=>{const o=e._zod.def,i=o.inclusive===!1,a=o.options.map((l,c)=>Ve(l,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=a:n.anyOf=a},Z0=(e,t,n,r)=>{const o=e._zod.def,i=Ve(o.left,t,{...r,path:[...r.path,"allOf",0]}),a=Ve(o.right,t,{...r,path:[...r.path,"allOf",1]}),l=u=>"allOf"in u&&Object.keys(u).length===1,c=[...l(i)?i.allOf:[i],...l(a)?a.allOf:[a]];n.allOf=c},V0=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object";const a=i.keyType,c=a._zod.bag?.patterns;if(i.mode==="loose"&&c&&c.size>0){const d=Ve(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(const f of c)o.patternProperties[f.source]=d}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(o.propertyNames=Ve(i.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=Ve(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const u=a._zod.values;if(u){const d=[...u].filter(f=>typeof f=="string"||typeof f=="number");d.length>0&&(o.required=d)}},q0=(e,t,n,r)=>{const o=e._zod.def,i=Ve(o.innerType,t,r),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},G0=(e,t,n,r)=>{const o=e._zod.def;Ve(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},K0=(e,t,n,r)=>{const o=e._zod.def;Ve(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},J0=(e,t,n,r)=>{const o=e._zod.def;Ve(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Y0=(e,t,n,r)=>{const o=e._zod.def;Ve(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;let a;try{a=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=a},X0=(e,t,n,r)=>{const o=e._zod.def,i=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;Ve(i,t,r);const a=t.seen.get(e);a.ref=i},Q0=(e,t,n,r)=>{const o=e._zod.def;Ve(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},rd=(e,t,n,r)=>{const o=e._zod.def;Ve(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},eb=(e,t,n,r)=>{const o=e._zod.innerType;Ve(o,t,r);const i=t.seen.get(e);i.ref=o},tb=X("ZodISODateTime",(e,t)=>{Yg.init(e,t),Ze.init(e,t)});function nb(e){return o0(tb,e)}const rb=X("ZodISODate",(e,t)=>{Xg.init(e,t),Ze.init(e,t)});function sb(e){return i0(rb,e)}const ob=X("ZodISOTime",(e,t)=>{Qg.init(e,t),Ze.init(e,t)});function ib(e){return a0(ob,e)}const ab=X("ZodISODuration",(e,t)=>{ex.init(e,t),Ze.init(e,t)});function lb(e){return l0(ab,e)}const cb=(e,t)=>{Lu.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Wm(e,n)},flatten:{value:n=>Um(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,pi,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,pi,2)}},isEmpty:{get(){return e.issues.length===0}}})},mt=X("ZodError",cb,{Parent:Error}),ub=aa(mt),db=la(mt),fb=oo(mt),pb=io(mt),hb=Vm(mt),mb=qm(mt),gb=Gm(mt),xb=Km(mt),bb=Jm(mt),vb=Ym(mt),yb=Xm(mt),wb=Qm(mt),We=X("ZodType",(e,t)=>(Ue.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Ns(e,"input"),output:Ns(e,"output")}}),e.toJSONSchema=A0(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(sn(t,{checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),e.with=e.check,e.clone=(n,r)=>on(e,n,r),e.brand=()=>e,e.register=((n,r)=>(n.add(e,r),e)),e.parse=(n,r)=>ub(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>fb(e,n,r),e.parseAsync=async(n,r)=>db(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>pb(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>hb(e,n,r),e.decode=(n,r)=>mb(e,n,r),e.encodeAsync=async(n,r)=>gb(e,n,r),e.decodeAsync=async(n,r)=>xb(e,n,r),e.safeEncode=(n,r)=>bb(e,n,r),e.safeDecode=(n,r)=>vb(e,n,r),e.safeEncodeAsync=async(n,r)=>yb(e,n,r),e.safeDecodeAsync=async(n,r)=>wb(e,n,r),e.refine=(n,r)=>e.check(xv(n,r)),e.superRefine=n=>e.check(bv(n)),e.overwrite=n=>e.check(Qn(n)),e.optional=()=>Pl(e),e.exactOptional=()=>nv(e),e.nullable=()=>Ml(e),e.nullish=()=>Pl(Ml(e)),e.nonoptional=n=>lv(e,n),e.array=()=>he(e),e.or=n=>zt([e,n]),e.and=n=>Jb(e,n),e.transform=n=>Ll(e,ev(n)),e.default=n=>ov(e,n),e.prefault=n=>av(e,n),e.catch=n=>uv(e,n),e.pipe=n=>Ll(e,n),e.readonly=()=>pv(e),e.describe=n=>{const r=e.clone();return mr.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){return mr.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return mr.get(e);const r=e.clone();return mr.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),sd=X("_ZodString",(e,t)=>{ca.init(e,t),We.init(e,t),e._zod.processJSONSchema=(r,o,i)=>I0(e,r,o);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(m0(...r)),e.includes=(...r)=>e.check(b0(...r)),e.startsWith=(...r)=>e.check(v0(...r)),e.endsWith=(...r)=>e.check(y0(...r)),e.min=(...r)=>e.check(Cs(...r)),e.max=(...r)=>e.check(Xu(...r)),e.length=(...r)=>e.check(Qu(...r)),e.nonempty=(...r)=>e.check(Cs(1,...r)),e.lowercase=r=>e.check(g0(r)),e.uppercase=r=>e.check(x0(r)),e.trim=()=>e.check(k0()),e.normalize=(...r)=>e.check(w0(...r)),e.toLowerCase=()=>e.check(_0()),e.toUpperCase=()=>e.check(j0()),e.slugify=()=>e.check(S0())}),kb=X("ZodString",(e,t)=>{ca.init(e,t),sd.init(e,t),e.email=n=>e.check(Dx(_b,n)),e.url=n=>e.check(Wx(jb,n)),e.jwt=n=>e.check(s0($b,n)),e.emoji=n=>e.check(Hx(Sb,n)),e.guid=n=>e.check(El(zl,n)),e.uuid=n=>e.check($x(qr,n)),e.uuidv4=n=>e.check(Fx(qr,n)),e.uuidv6=n=>e.check(Bx(qr,n)),e.uuidv7=n=>e.check(Ux(qr,n)),e.nanoid=n=>e.check(Zx(Cb,n)),e.guid=n=>e.check(El(zl,n)),e.cuid=n=>e.check(Vx(Nb,n)),e.cuid2=n=>e.check(qx(Tb,n)),e.ulid=n=>e.check(Gx(Eb,n)),e.base64=n=>e.check(t0(Mb,n)),e.base64url=n=>e.check(n0(Lb,n)),e.xid=n=>e.check(Kx(Ab,n)),e.ksuid=n=>e.check(Jx(Rb,n)),e.ipv4=n=>e.check(Yx(Ib,n)),e.ipv6=n=>e.check(Xx(zb,n)),e.cidrv4=n=>e.check(Qx(Ob,n)),e.cidrv6=n=>e.check(e0(Pb,n)),e.e164=n=>e.check(r0(Db,n)),e.datetime=n=>e.check(nb(n)),e.date=n=>e.check(sb(n)),e.time=n=>e.check(ib(n)),e.duration=n=>e.check(lb(n))});function N(e){return Lx(kb,e)}const Ze=X("ZodStringFormat",(e,t)=>{He.init(e,t),sd.init(e,t)}),_b=X("ZodEmail",(e,t)=>{Ug.init(e,t),Ze.init(e,t)}),zl=X("ZodGUID",(e,t)=>{Fg.init(e,t),Ze.init(e,t)}),qr=X("ZodUUID",(e,t)=>{Bg.init(e,t),Ze.init(e,t)}),jb=X("ZodURL",(e,t)=>{Wg.init(e,t),Ze.init(e,t)}),Sb=X("ZodEmoji",(e,t)=>{Hg.init(e,t),Ze.init(e,t)}),Cb=X("ZodNanoID",(e,t)=>{Zg.init(e,t),Ze.init(e,t)}),Nb=X("ZodCUID",(e,t)=>{Vg.init(e,t),Ze.init(e,t)}),Tb=X("ZodCUID2",(e,t)=>{qg.init(e,t),Ze.init(e,t)}),Eb=X("ZodULID",(e,t)=>{Gg.init(e,t),Ze.init(e,t)}),Ab=X("ZodXID",(e,t)=>{Kg.init(e,t),Ze.init(e,t)}),Rb=X("ZodKSUID",(e,t)=>{Jg.init(e,t),Ze.init(e,t)}),Ib=X("ZodIPv4",(e,t)=>{tx.init(e,t),Ze.init(e,t)}),zb=X("ZodIPv6",(e,t)=>{nx.init(e,t),Ze.init(e,t)}),Ob=X("ZodCIDRv4",(e,t)=>{rx.init(e,t),Ze.init(e,t)}),Pb=X("ZodCIDRv6",(e,t)=>{sx.init(e,t),Ze.init(e,t)}),Mb=X("ZodBase64",(e,t)=>{ox.init(e,t),Ze.init(e,t)}),Lb=X("ZodBase64URL",(e,t)=>{ax.init(e,t),Ze.init(e,t)}),Db=X("ZodE164",(e,t)=>{lx.init(e,t),Ze.init(e,t)}),$b=X("ZodJWT",(e,t)=>{ux.init(e,t),Ze.init(e,t)}),od=X("ZodNumber",(e,t)=>{qu.init(e,t),We.init(e,t),e._zod.processJSONSchema=(r,o,i)=>z0(e,r,o),e.gt=(r,o)=>e.check(Rl(r,o)),e.gte=(r,o)=>e.check(Mo(r,o)),e.min=(r,o)=>e.check(Mo(r,o)),e.lt=(r,o)=>e.check(Al(r,o)),e.lte=(r,o)=>e.check(Po(r,o)),e.max=(r,o)=>e.check(Po(r,o)),e.int=r=>e.check(Ol(r)),e.safe=r=>e.check(Ol(r)),e.positive=r=>e.check(Rl(0,r)),e.nonnegative=r=>e.check(Mo(0,r)),e.negative=r=>e.check(Al(0,r)),e.nonpositive=r=>e.check(Po(0,r)),e.multipleOf=(r,o)=>e.check(Il(r,o)),e.step=(r,o)=>e.check(Il(r,o)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function q(e){return c0(od,e)}const Fb=X("ZodNumberFormat",(e,t)=>{dx.init(e,t),od.init(e,t)});function Ol(e){return u0(Fb,e)}const Bb=X("ZodBoolean",(e,t)=>{fx.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,o)=>O0(e,n,r)});function $e(e){return d0(Bb,e)}const Ub=X("ZodNull",(e,t)=>{px.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,o)=>P0(e,n,r)});function Ts(e){return f0(Ub,e)}const Wb=X("ZodUnknown",(e,t)=>{hx.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,o)=>L0()});function mn(){return p0(Wb)}const Hb=X("ZodNever",(e,t)=>{mx.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,o)=>M0(e,n,r)});function Zb(e){return h0(Hb,e)}const Vb=X("ZodArray",(e,t)=>{gx.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,o)=>U0(e,n,r,o),e.element=t.element,e.min=(n,r)=>e.check(Cs(n,r)),e.nonempty=n=>e.check(Cs(1,n)),e.max=(n,r)=>e.check(Xu(n,r)),e.length=(n,r)=>e.check(Qu(n,r)),e.unwrap=()=>e.element});function he(e,t){return C0(Vb,e,t)}const qb=X("ZodObject",(e,t)=>{bx.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,o)=>W0(e,n,r,o),ze(e,"shape",()=>t.shape),e.keyof=()=>Ee(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:mn()}),e.loose=()=>e.clone({...e._zod.def,catchall:mn()}),e.strict=()=>e.clone({...e._zod.def,catchall:Zb()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>Lm(e,n),e.safeExtend=n=>Dm(e,n),e.merge=n=>$m(e,n),e.pick=n=>Pm(e,n),e.omit=n=>Mm(e,n),e.partial=(...n)=>Fm(ad,e,n[0]),e.required=(...n)=>Bm(ld,e,n[0])});function G(e,t){const n={type:"object",shape:e??{},...we(t)};return new qb(n)}const id=X("ZodUnion",(e,t)=>{Ju.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,o)=>H0(e,n,r,o),e.options=t.options});function zt(e,t){return new id({type:"union",options:e,...we(t)})}const Gb=X("ZodDiscriminatedUnion",(e,t)=>{id.init(e,t),vx.init(e,t)});function Cn(e,t,n){return new Gb({type:"union",options:t,discriminator:e,...we(n)})}const Kb=X("ZodIntersection",(e,t)=>{yx.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Z0(e,n,r,o)});function Jb(e,t){return new Kb({type:"intersection",left:e,right:t})}const Yb=X("ZodRecord",(e,t)=>{wx.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,o)=>V0(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType});function qe(e,t,n){return new Yb({type:"record",keyType:e,valueType:t,...we(n)})}const mi=X("ZodEnum",(e,t)=>{kx.init(e,t),We.init(e,t),e._zod.processJSONSchema=(r,o,i)=>D0(e,r,o),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const i={};for(const a of r)if(n.has(a))i[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new mi({...t,checks:[],...we(o),entries:i})},e.exclude=(r,o)=>{const i={...t.entries};for(const a of r)if(n.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new mi({...t,checks:[],...we(o),entries:i})}});function Ee(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new mi({type:"enum",entries:n,...we(t)})}const Xb=X("ZodLiteral",(e,t)=>{_x.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,o)=>$0(e,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Te(e,t){return new Xb({type:"literal",values:Array.isArray(e)?e:[e],...we(t)})}const Qb=X("ZodTransform",(e,t)=>{jx.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,o)=>B0(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ru(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(wr(i,n.value,t));else{const a=i;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=n.value),a.inst??(a.inst=e),n.issues.push(wr(a))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n)):(n.value=o,n)}});function ev(e){return new Qb({type:"transform",transform:e})}const ad=X("ZodOptional",(e,t)=>{Yu.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,o)=>rd(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Pl(e){return new ad({type:"optional",innerType:e})}const tv=X("ZodExactOptional",(e,t)=>{Sx.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,o)=>rd(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function nv(e){return new tv({type:"optional",innerType:e})}const rv=X("ZodNullable",(e,t)=>{Cx.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,o)=>q0(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Ml(e){return new rv({type:"nullable",innerType:e})}const sv=X("ZodDefault",(e,t)=>{Nx.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,o)=>K0(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ov(e,t){return new sv({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Pu(t)}})}const iv=X("ZodPrefault",(e,t)=>{Tx.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,o)=>J0(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function av(e,t){return new iv({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Pu(t)}})}const ld=X("ZodNonOptional",(e,t)=>{Ex.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,o)=>G0(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function lv(e,t){return new ld({type:"nonoptional",innerType:e,...we(t)})}const cv=X("ZodCatch",(e,t)=>{Ax.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Y0(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function uv(e,t){return new cv({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const dv=X("ZodPipe",(e,t)=>{Rx.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,o)=>X0(e,n,r,o),e.in=t.in,e.out=t.out});function Ll(e,t){return new dv({type:"pipe",in:e,out:t})}const fv=X("ZodReadonly",(e,t)=>{Ix.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Q0(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function pv(e){return new fv({type:"readonly",innerType:e})}const hv=X("ZodLazy",(e,t)=>{zx.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,o)=>eb(e,n,r,o),e.unwrap=()=>e._zod.def.getter()});function mv(e){return new hv({type:"lazy",getter:e})}const gv=X("ZodCustom",(e,t)=>{Ox.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,o)=>F0(e,n)});function xv(e,t={}){return N0(gv,e,t)}function bv(e){return T0(e)}const Xe=mv(()=>zt([N(),q(),$e(),Ts(),he(Xe),qe(N(),Xe)]));const cd=G({index:q(),timestamp:q(),type:N(),data:Xe}),vv=G({chunks:he(cd),truncated:$e().optional().default(!1)}),yv=Ee(["request","response"]),wv=G({logId:q().int().positive(),part:yv,text:N(),offset:q().int().nonnegative(),limit:q().int().positive(),totalBytes:q().int().nonnegative(),textBytes:q().int().nonnegative(),nextOffset:q().int().nonnegative().nullable(),hasMore:$e(),contentMode:Ee(["empty","partial","full"])}),kr=G({id:q(),timestamp:N(),method:N(),path:N(),model:N().nullable(),sessionId:N().nullable(),rawRequestBody:N().nullable(),responseStatus:q().nullable(),responseText:N().nullable(),inputTokens:q().nullable(),outputTokens:q().nullable(),cacheCreationInputTokens:q().nullable(),cacheReadInputTokens:q().nullable(),elapsedMs:q().nullable(),firstChunkMs:q().nullable().optional(),totalStreamMs:q().nullable().optional(),tokensPerSecond:q().nullable().optional(),streaming:$e(),userAgent:N().nullable(),origin:N().nullable(),rawHeaders:qe(N(),N()).optional(),headers:qe(N(),N()).optional(),apiFormat:Ee(["anthropic","openai","unknown"]).default("unknown"),isTest:$e().optional().default(!1),replayOfLogId:q().nullable().optional(),providerName:N().nullable().optional(),clientPort:q().nullable().optional(),clientPid:q().nullable().optional(),clientCwd:N().nullable().optional(),clientProjectFolder:N().nullable().optional(),streamingChunks:vv.optional(),streamingChunksPath:N().nullable().optional(),rawRequestBodyBytes:q().int().nonnegative().nullable().optional(),responseTextBytes:q().int().nonnegative().nullable().optional(),bodyContentMode:Ee(["full","compact","truncated"]).optional(),warnings:he(N()).optional(),error:N().nullable().optional()}),ua=G({type:N(),ttl:N().optional(),scope:N().optional()}),da=G({type:Te("text"),text:N(),cache_control:ua.optional()}),ud=G({type:Te("thinking"),thinking:N(),signature:N().optional()}),kv=G({type:Te("think"),thinking:N(),signature:N().optional()}),_v=G({type:Te("base64"),media_type:N(),data:N()}),dd=G({type:Te("image"),source:_v}),fd=G({type:Te("tool_use"),id:N(),name:N(),input:qe(N(),Xe)}),jv=Cn("type",[da,dd]),Sv=G({type:Te("tool_result"),tool_use_id:N().optional(),content:zt([N(),he(jv)]),is_error:$e().optional()}),Cv=Cn("type",[da,ud,dd,fd,Sv]),Nv=zt([N(),he(Cv)]),Tv=G({role:Ee(["user","assistant"]),content:Nv}),Ev=G({type:Te("text"),text:N(),cache_control:ua.optional()}),Av=G({type:N(),properties:qe(N(),qe(N(),Xe)).optional(),required:he(N()).optional(),additionalProperties:$e().optional(),$schema:N().optional()}),Rv=G({name:N(),description:N().optional(),input_schema:Av.optional(),cache_control:ua.optional()}),Iv=Cn("type",[G({type:Te("enabled"),budget_tokens:q()}),G({type:Te("disabled")}),G({type:Te("adaptive")})]),pd=G({model:N(),messages:he(Tv),system:he(Ev).optional(),tools:he(Rv).optional(),max_tokens:q().optional(),temperature:q().optional(),stream:$e().optional(),thinking:Iv.optional(),metadata:G({user_id:N().optional()}).optional()}),fa=Cn("type",[da,ud,kv,fd]),zv=G({input_tokens:q().nullable().optional(),output_tokens:q().nullable().optional(),cache_creation_input_tokens:q().nullable().optional(),cache_read_input_tokens:q().nullable().optional()}).passthrough(),hd=G({id:N(),type:Te("message"),model:N(),role:Te("assistant"),content:he(fa),stop_reason:N().nullable(),stop_sequence:N().nullable().optional(),usage:zv}).passthrough(),Ov=G({type:Te("message_start"),message:G({id:N(),type:Te("message"),model:N(),role:Te("assistant"),content:he(fa),stop_reason:Ts(),stop_sequence:Ts(),usage:G({input_tokens:q(),cache_creation_input_tokens:q().optional(),cache_read_input_tokens:q().optional()}).passthrough()})}),Pv=G({type:Te("content_block_start"),index:q(),content_block:fa}),Mv=Cn("type",[G({type:Te("text_delta"),text:N()}),G({type:Te("input_json_delta"),partial_json:N()}),G({type:Te("thinking_delta"),thinking:N()}),G({type:Te("signature_delta"),signature:N()})]),Lv=G({type:Te("content_block_delta"),index:q(),delta:Mv}),Dv=G({type:Te("content_block_stop"),index:q()}),$v=G({type:Te("message_delta"),delta:G({stop_reason:N().nullable(),stop_sequence:N().nullable().optional()}),usage:G({output_tokens:q(),input_tokens:q().optional(),cache_creation_input_tokens:q().optional(),cache_read_input_tokens:q().optional()}).passthrough()}),Fv=G({type:Te("message_stop")}),Bv=G({type:Te("ping")}),Uv=G({type:Te("error"),error:G({type:N(),message:N()})}),Wv=Cn("type",[Ov,Pv,Lv,Dv,$v,Fv,Bv,Uv]),Hv=zt([N(),he(Cn("type",[G({type:Te("text"),text:N()}),G({type:Te("image_url"),image_url:G({url:N(),detail:N().optional()})})]))]),md=G({role:Ee(["system","user","assistant","tool"]),content:Hv,name:N().optional(),reasoning_content:N().optional(),thinking:N().optional(),think:N().optional()}),Zv=G({name:N(),arguments:N()}),gd=G({index:q().optional(),id:N().optional(),type:Te("function").optional(),function:G({name:N().optional(),arguments:N().optional()})});md.extend({content:zt([N(),he(G({type:Te("text"),text:N()}))]).optional(),function_call:Zv.optional(),tool_calls:he(gd).optional()});const Vv=G({type:Te("function"),function:G({name:N(),description:N().optional(),parameters:qe(N(),Xe)})}),xd=G({model:N(),messages:he(md),temperature:q().optional(),max_tokens:q().optional(),stream:$e().optional(),tools:he(Vv).optional(),tool_choice:zt([Ee(["auto","none","required"]),G({type:Te("auto")}),G({type:Te("none")}),G({type:Te("function"),function:G({name:N()})})]).optional(),user:N().optional()}),qv=G({type:N(),name:N().optional(),description:N().optional(),parameters:Xe.optional(),function:G({name:N().optional(),description:N().optional(),parameters:Xe.optional()}).optional()}).passthrough(),bd=G({model:N(),input:mn().optional(),instructions:zt([N(),Ts()]).optional(),stream:$e().optional(),tools:he(qv).optional(),tool_choice:mn().optional(),max_output_tokens:q().optional(),temperature:q().optional(),user:N().optional(),metadata:qe(N(),mn()).optional()}).passthrough(),vd=G({role:Ee(["assistant"]).optional(),content:N().nullable().optional(),reasoning_content:N().nullable().optional(),thinking:N().nullable().optional(),think:N().nullable().optional(),function_call:G({name:N().optional(),arguments:N().optional()}).nullable().optional(),tool_calls:he(G({index:q(),id:N().optional(),type:Te("function").optional(),function:G({name:N().optional(),arguments:N().optional()})})).nullable().optional()}),Gv=G({index:q(),message:G({role:Ee(["assistant"]),content:N().nullable(),reasoning_content:N().optional(),thinking:N().optional(),think:N().optional(),function_call:G({name:N(),arguments:N()}).nullable().optional(),tool_calls:he(gd).optional()}).optional(),delta:vd.optional(),finish_reason:N().nullable()}),Kv=G({id:N(),object:Te("chat.completion"),created:q(),model:N(),choices:he(Gv),usage:G({prompt_tokens:q().nullable().optional(),completion_tokens:q().nullable().optional(),total_tokens:q().nullable().optional()}).passthrough(),service_tier:N().nullable().optional(),system_fingerprint:N().nullable().optional()}).passthrough(),Jv=G({id:N(),object:Te("chat.completion.chunk"),created:q(),model:N(),choices:he(G({index:q(),delta:vd,finish_reason:N().nullable().optional()})),usage:G({prompt_tokens:q().nullable().optional(),completion_tokens:q().nullable().optional(),total_tokens:q().nullable().optional()}).passthrough().nullable().optional()}).passthrough(),Yv=G({input_tokens:q().nullable().optional(),output_tokens:q().nullable().optional(),total_tokens:q().nullable().optional(),input_tokens_details:G({cached_tokens:q().nullable().optional()}).passthrough().nullable().optional(),output_tokens_details:G({reasoning_tokens:q().nullable().optional()}).passthrough().nullable().optional()}).passthrough(),Xv=G({type:N()}).passthrough(),Es=G({id:N(),object:Te("response").optional(),created_at:q().optional(),status:N().nullable().optional(),model:N().optional(),output:he(Xv).optional(),output_text:N().optional(),usage:Yv.nullable().optional(),error:mn().optional()}).passthrough(),Qv=G({type:N()}).passthrough();function yd(e){try{const t=JSON.parse(e),n=Kv.safeParse(t);return n.success?n.data:null}catch{return null}}function wd(e){try{const t=JSON.parse(e),n=Es.safeParse(t);return n.success?n.data:null}catch{return null}}const e1=G({error:N()});async function wt(e,t){const n=await e.json();return t.parse(n)}async function Ft(e,t){try{const n=await e.json(),r=e1.safeParse(n);return r.success?r.data.error:t}catch{return t}}async function tn(e,t,n,r){const o=await fetch(e,n);if(!o.ok){const i=r?.(o)??`Request failed with status ${o.status}`;throw new Error(await Ft(o,i))}return wt(o,t)}function t1(e){return e<1e3?`${String(e)}ms`:`${String(Math.round(e/1e3))}s`}class kd extends Error{constructor(t){super(`Request timed out after ${t1(t)}`),this.name="ApiTimeoutError"}}async function Vn(e,t,n,r,o){const i=new AbortController,a=setTimeout(()=>i.abort(),n);try{return await tn(e,t,{...r,signal:i.signal},o)}catch(l){throw l instanceof DOMException&&l.name==="AbortError"?new kd(n):l}finally{clearTimeout(a)}}const _d=G({input:q().int().nonnegative(),output:q().int().nonnegative(),cacheCreate:q().int().nonnegative(),cacheRead:q().int().nonnegative(),total:q().int().nonnegative()}),n1=G({id:q().int().positive(),sessionLogNumber:q().int().positive().optional(),timestamp:N(),provider:N().nullable(),model:N().nullable(),apiFormat:Ee(["anthropic","openai","unknown"]),method:N(),path:N(),status:q().nullable(),isStreaming:$e(),hasError:$e(),error:N().nullable(),latencyMs:q().nullable(),firstChunkMs:q().nullable().optional(),totalStreamMs:q().nullable().optional(),tokensPerSecond:q().nullable().optional(),tokens:G({input:q().nullable(),output:q().nullable(),cacheCreate:q().nullable(),cacheRead:q().nullable()}),sessionId:N().nullable()}),jd=G({id:N(),status:Ee(["active","failed","completed","empty"]),logCoverage:Ee(["recent","history"]),source:Ee(["explicit","client-process","client-connection","provider-test"]).nullable(),runtimeMode:Ee(["in-process","worker-thread","child-process"]).nullable(),createdAt:N().nullable(),updatedAt:N().nullable(),requestCount:q().int().nonnegative(),activeRequests:q().int().nonnegative(),completedRequests:q().int().nonnegative(),failedRequests:q().int().nonnegative(),queuedTasks:q().int().nonnegative(),runningTasks:q().int().nonnegative(),lastTaskError:N().nullable(),logCount:q().int().nonnegative(),errorCount:q().int().nonnegative(),models:he(N()),providers:he(N()),tokenUsage:_d,lastLogId:q().nullable(),lastModel:N().nullable(),clientPid:q().nullable(),clientProjectFolder:N().nullable(),inspectorPath:N(),inspectorUrl:N(),apiPath:N(),apiUrl:N(),compactLogsPath:N(),compactLogsUrl:N(),latestLogLimit:q().int().positive(),latestLogs:he(n1)}),Rr=Ee(["created","running","completed","failed","cancelled"]),pa=G({jsonPath:N(),markdownPath:N(),htmlPath:N(),exportedAt:N()}),r1=Ee(["run-created","session-started","request","session-finished","evidence-exported"]),s1=Ee(["info","success","warning","error"]),o1=G({timestamp:N(),kind:r1,severity:s1,title:N(),details:N(),logId:q().int().positive().nullable(),status:q().nullable(),model:N().nullable(),provider:N().nullable(),latencyMs:q().nullable(),isStreaming:$e().nullable()}),i1=Ee(["none","active","provider-timeout","provider-http-error","provider-auth-error","provider-rate-limit","network-or-container","streaming-mismatch","context-pressure","runtime-task-error","model-output-error","unknown-failure","no-session-data"]),Sd=G({outcome:Ee(["success","failure","active","unknown"]),severity:Ee(["none","low","medium","high"]),category:i1,summary:N(),evidenceLogIds:he(q().int().positive()),hints:he(N())}),ha=G({status:Ee(["PASS","FAIL","RUNNING","UNKNOWN"]),summary:N(),markdown:N()}),Cd=ha,ma=G({id:N(),sessionId:N(),groupId:N().nullable().default(null),title:N(),task:N().nullable(),project:N().nullable(),agent:N().nullable(),status:Rr,tags:he(N()),metadata:qe(N(),Xe),evidence:pa.nullable(),createdAt:N(),updatedAt:N()});G({runId:N().min(1).optional(),sessionId:N().min(1).optional(),groupId:N().min(1).nullable().optional(),title:N().min(1).optional(),task:N().nullable().optional(),project:N().nullable().optional(),agent:N().nullable().optional(),status:Rr.optional(),tags:he(N()).optional(),metadata:qe(N(),Xe).optional()}).optional();G({sessionId:N().min(1).optional(),groupId:N().min(1).nullable().optional(),title:N().min(1).optional(),task:N().nullable().optional(),project:N().nullable().optional(),agent:N().nullable().optional(),status:Rr.optional(),tags:he(N()).optional(),metadata:qe(N(),Xe).optional()});G({includeHistory:$e().optional(),latestLogLimit:q().int().positive().max(50).optional()}).optional();G({run:ma,evidence:pa,session:jd.nullable(),timeline:he(o1),classification:Sd,jenkinsReport:ha});const a1=G({run:ma,classification:Sd,evidence:pa.nullable(),jenkinsReport:ha.nullable(),sessionId:N(),inspectorUrl:N().nullable(),evidenceMarkdownPath:N().nullable(),updatedAt:N()});G({failures:he(a1),total:q().int().nonnegative(),limit:q().int().positive()});const ga=Ee(["created","running","completed","failed","cancelled"]),xa=Ee(["evaluation","batch","manual"]),ba=G({jsonPath:N(),markdownPath:N(),htmlPath:N(),exportedAt:N()}),Nd=G({id:N(),groupId:N(),sessionId:N(),runId:N().nullable(),label:N().nullable(),agent:N().nullable(),provider:N().nullable(),model:N().nullable(),status:Rr.nullable(),metadata:qe(N(),Xe),addedAt:N(),updatedAt:N()}),va=G({id:N(),title:N(),kind:xa,task:N().nullable(),project:N().nullable(),status:ga,tags:he(N()),metadata:qe(N(),Xe),evidence:ba.nullable(),members:he(Nd),createdAt:N(),updatedAt:N()});G({groupId:N().min(1).optional(),title:N().min(1).optional(),kind:xa.optional(),task:N().nullable().optional(),project:N().nullable().optional(),status:ga.optional(),tags:he(N()).optional(),metadata:qe(N(),Xe).optional()}).optional();G({title:N().min(1).optional(),kind:xa.optional(),task:N().nullable().optional(),project:N().nullable().optional(),status:ga.optional(),tags:he(N()).optional(),metadata:qe(N(),Xe).optional()});G({memberId:N().min(1).optional(),sessionId:N().min(1),runId:N().min(1).nullable().optional(),label:N().min(1).nullable().optional(),agent:N().min(1).nullable().optional(),provider:N().min(1).nullable().optional(),model:N().min(1).nullable().optional(),status:Rr.nullable().optional(),metadata:qe(N(),Xe).optional()});G({includeHistory:$e().optional(),latestLogLimit:q().int().positive().max(50).optional()}).optional();G({deleteEvidence:$e().optional()});const l1=G({groupId:N(),deleted:$e(),evidenceDeleted:$e(),evidencePath:N().nullable()}),Td=G({member:Nd,run:ma.nullable(),session:jd.nullable()}),Ed=G({memberCount:q().int().nonnegative(),sessionsWithData:q().int().nonnegative(),missingSessions:q().int().nonnegative(),requestCount:q().int().nonnegative(),errorCount:q().int().nonnegative(),tokenUsage:_d,models:he(N()),providers:he(N()),completedMembers:q().int().nonnegative(),failedMembers:q().int().nonnegative(),runningMembers:q().int().nonnegative()}),c1=G({group:va,evidence:ba,members:he(Td).nullable(),markdown:N(),summary:Ed.nullable(),report:Cd.nullable()}),u1=G({group:va,evidence:ba,members:he(Td),summary:Ed,jenkinsReport:Cd}),Ad=G({groups:he(va)}),d1=G({sessionId:N(),imported:q().int().nonnegative(),skipped:q().int().nonnegative(),warnings:he(N()),logs:he(kr)}),As=10,gi=600,Rs=60,xi=600,Is="time",ya="simple",Rd=Ee(["time","full"]),f1=Ee(["simple","full"]),lo=G({stripClaudeCodeBillingHeader:$e(),hasSeenOnboarding:$e().default(!1),slowResponseThresholdSeconds:q().int().min(0).max(gi).default(As),providerTestTimeoutSeconds:q().int().min(1).max(xi).default(Rs),timeDisplayFormat:Rd.default(Is),captureMode:f1.default(ya)}),Mn="/api/config";async function p1(e){return tn(e,lo,void 0,t=>`Failed to fetch ${e}: ${t.status}`)}async function Gr(e){return tn(Mn,lo,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},t=>`PATCH failed with status ${t.status}`)}function wa(){const e=_n(Mn,p1,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:t}=Tu(),n=e.data?.stripClaudeCodeBillingHeader??!1,r=e.data?.captureMode??ya,o=e.data?.slowResponseThresholdSeconds??As,i=e.data?.providerTestTimeoutSeconds??Rs,a=e.data?.timeDisplayFormat??Is,l=h=>({stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:e.data?.hasSeenOnboarding??!1,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??As,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??Rs,timeDisplayFormat:e.data?.timeDisplayFormat??Is,captureMode:r,...h}),c=async h=>{await t(Mn,Gr({stripClaudeCodeBillingHeader:h}),{optimisticData:l({stripClaudeCodeBillingHeader:h}),rollbackOnError:!0,revalidate:!1})},u=async h=>{await t(Mn,Gr({slowResponseThresholdSeconds:h}),{optimisticData:l({slowResponseThresholdSeconds:h}),rollbackOnError:!0,revalidate:!1})},d=async h=>{await t(Mn,Gr({timeDisplayFormat:h}),{optimisticData:l({timeDisplayFormat:h}),rollbackOnError:!0,revalidate:!1})},f=async h=>{await t(Mn,Gr({providerTestTimeoutSeconds:h}),{optimisticData:l({providerTestTimeoutSeconds:h}),rollbackOnError:!0,revalidate:!1})};return{strip:n,captureMode:r,slowResponseThresholdSeconds:o,providerTestTimeoutSeconds:i,timeDisplayFormat:a,isLoading:e.isLoading,isError:e.error!==void 0,setStrip:c,setSlowResponseThresholdSeconds:u,setProviderTestTimeoutSeconds:f,setTimeDisplayFormat:d}}const Id=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();const h1=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const m1=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase());const Dl=e=>{const t=m1(e);return t.charAt(0).toUpperCase()+t.slice(1)};var g1={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const x1=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};const b1=p.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:i,iconNode:a,...l},c)=>p.createElement("svg",{ref:c,...g1,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Id("lucide",o),...!i&&!x1(l)&&{"aria-hidden":"true"},...l},[...a.map(([u,d])=>p.createElement(u,d)),...Array.isArray(i)?i:[i]]));const ge=(e,t)=>{const n=p.forwardRef(({className:r,...o},i)=>p.createElement(b1,{ref:i,iconNode:t,className:Id(`lucide-${h1(Dl(e))}`,`lucide-${e}`,r),...o}));return n.displayName=Dl(e),n};const v1=[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]],y1=ge("arrow-down-right",v1);const w1=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],k1=ge("arrow-down",w1);const _1=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],j1=ge("arrow-left",_1);const S1=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],C1=ge("arrow-up-right",S1);const N1=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],T1=ge("arrow-up",N1);const E1=[["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"}]],A1=ge("bell",E1);const R1=[["path",{d:"M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2",key:"1ah6g2"}],["rect",{x:"14",y:"2",width:"8",height:"8",rx:"1",key:"88lufb"}]],I1=ge("blocks",R1);const z1=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],zd=ge("brain",z1);const O1=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ge=ge("check",O1);const P1=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],ct=ge("chevron-down",P1);const M1=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],L1=ge("chevron-left",M1);const D1=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ot=ge("chevron-right",D1);const $1=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],ka=ge("chevron-up",$1);const F1=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],B1=ge("chevrons-down",F1);const U1=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],W1=ge("chevrons-left",U1);const H1=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],Z1=ge("chevrons-right",H1);const V1=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],q1=ge("chevrons-up",V1);const G1=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],_r=ge("circle-alert",G1);const K1=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],J1=ge("circle-check-big",K1);const Y1=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],$l=ge("circle-check",Y1);const X1=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Q1=ge("circle-question-mark",X1);const ey=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Od=ge("circle-x",ey);const ty=[["path",{d:"M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3Z",key:"1tn4o7"}],["path",{d:"m6.2 5.3 3.1 3.9",key:"iuk76l"}],["path",{d:"m12.4 3.4 3.1 4",key:"6hsd6n"}],["path",{d:"M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z",key:"ltgou9"}]],ny=ge("clapperboard",ty);const ry=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],sy=ge("clock-3",ry);const oy=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Bt=ge("clock",oy);const iy=[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]],ay=ge("cloud-upload",iy);const ly=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],cy=ge("code-xml",ly);const uy=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],dy=ge("columns-2",uy);const fy=[["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"}]],St=ge("copy",fy);const py=[["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"}]],co=ge("download",py);const hy=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],my=ge("ellipsis",hy);const gy=[["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"}]],_a=ge("external-link",gy);const xy=[["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"}]],ja=ge("eye-off",xy);const by=[["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"}]],Sa=ge("eye",by);const vy=[["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 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]],yy=ge("file-braces",vy);const wy=[["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:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]],ky=ge("file-diff",wy);const _y=[["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:"11.5",cy:"14.5",r:"2.5",key:"1bq0ko"}],["path",{d:"M13.3 16.3 15 18",key:"2quom7"}]],jy=ge("file-search",_y);const Sy=[["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:"m8 16 2-2-2-2",key:"10vzyd"}],["path",{d:"M12 18h4",key:"1wd2n7"}]],Cy=ge("file-terminal",Sy);const Ny=[["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"}]],Ty=ge("file-text",Ny);const Ey=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Ca=ge("gauge",Ey);const Ay=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"M12 18H7a2 2 0 0 1-2-2V9",key:"16sdep"}],["path",{d:"m9 15 3 3-3 3",key:"1m3kbl"}]],Ry=ge("git-compare-arrows",Ay);const Iy=[["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"}]],Pd=ge("globe",Iy);const zy=[["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"}]],Oy=ge("history",zy);const Py=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],My=ge("info",Py);const Ly=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],Fl=ge("layers",Ly);const Dy=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],ht=ge("loader-circle",Dy);const $y=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],Fy=ge("lock",$y);const By=[["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"}]],uo=ge("message-square",By);const Uy=[["path",{d:"M5 12h14",key:"1ays0h"}]],Wy=ge("minus",Uy);const Hy=[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]],Zy=ge("mouse-pointer-click",Hy);const Vy=[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]],qy=ge("octagon-alert",Vy);const Gy=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Md=ge("pencil",Gy);const Ky=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],bi=ge("plus",Ky);const Jy=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],Bl=ge("radio",Jy);const Yy=[["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"}]],zs=ge("refresh-cw",Yy);const Xy=[["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"}]],Qy=ge("rotate-ccw",Xy);const e2=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],vi=ge("rotate-cw",e2);const t2=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],n2=ge("rows-3",t2);const r2=[["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"}]],s2=ge("save",r2);const o2=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]],i2=ge("scan",o2);const a2=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],l2=ge("search",a2);const c2=[["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"}]],u2=ge("server",c2);const d2=[["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"}]],f2=ge("settings",d2);const p2=[["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:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],h2=ge("shield-alert",p2);const m2=[["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"}]],Ul=ge("shield-check",m2);const g2=[["path",{d:"M7 18v-6a5 5 0 1 1 10 0v6",key:"pcx96s"}],["path",{d:"M5 21a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2z",key:"1b4s83"}],["path",{d:"M21 12h1",key:"jtio3y"}],["path",{d:"M18.5 4.5 18 5",key:"g5sp9y"}],["path",{d:"M2 12h1",key:"1uaihz"}],["path",{d:"M12 2v1",key:"11qlp1"}],["path",{d:"m4.929 4.929.707.707",key:"1i51kw"}],["path",{d:"M12 12v6",key:"3ahymv"}]],yi=ge("siren",g2);const x2=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Na=ge("terminal",x2);const b2=[["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"}]],qn=ge("trash-2",b2);const v2=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],gn=ge("triangle-alert",v2);const y2=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],Ld=ge("upload",y2);const w2=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],k2=ge("wifi-off",w2);const _2=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],j2=ge("wifi",_2);const S2=[["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"}]],Ir=ge("wrench",S2);const C2=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ta=ge("x",C2);const N2=[["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"}]],jr=ge("zap",N2),wi="/api/config";async function T2(e){return tn(e,lo,void 0,t=>`Failed to fetch ${e}: ${t.status}`)}async function E2(e){return tn(wi,lo,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},t=>`PATCH failed with status ${t.status}`)}function A2(){const e=_n(wi,T2,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:t}=Tu(),n=e.data?.hasSeenOnboarding??!1,r=e.data?.captureMode??ya,o=async()=>{await t(wi,E2({hasSeenOnboarding:!0}),{optimisticData:{stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:!0,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??As,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??Rs,timeDisplayFormat:e.data?.timeDisplayFormat??Is,captureMode:r},rollbackOnError:!0,revalidate:!1})};return{hasSeenOnboarding:n,captureMode:r,isLoading:e.isLoading,markSeen:o}}function R2(){const{hasSeenOnboarding:e,isLoading:t,markSeen:n}=A2(),[r,o]=p.useState(!1);if(t||e)return null;const i=r?"grid":"hidden sm:grid";return s.jsx("div",{role:"note","aria-label":"Onboarding tip",className:"mx-4 mt-2 mb-1 rounded-md border border-amber-500/30 bg-[#130d04] px-3 py-2 text-sm shadow-[0_12px_40px_rgba(0,0,0,0.16)]",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(My,{className:"mt-0.5 size-4 shrink-0 text-amber-300","aria-hidden":"true"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsx("span",{className:"font-medium text-amber-200",children:"Inspector ready"}),s.jsx("span",{className:"hidden truncate text-xs text-muted-foreground sm:inline",children:"Request, response, tool, timing, token, replay, and memory signals are active."})]}),s.jsx("div",{className:"mt-1 text-xs leading-relaxed text-muted-foreground sm:hidden",children:"Core capture is active."}),s.jsxs("div",{className:`${i} mt-2 gap-x-4 gap-y-1 text-xs leading-relaxed text-muted-foreground sm:grid-cols-2`,children:[s.jsxs("div",{children:[s.jsx("strong",{children:"Evidence"}),": logs, sessions, groups, and MCP exports are available."]}),s.jsxs("div",{children:[s.jsx("strong",{children:"Network"}),": replace ",s.jsx("code",{children:"localhost"})," if containers differ."]})]})]}),s.jsx("button",{type:"button",onClick:()=>o(a=>!a),className:"inline-flex h-8 shrink-0 items-center gap-1 rounded-md border border-amber-500/30 px-2 text-xs text-amber-200 transition-colors hover:bg-amber-500/10 sm:hidden","aria-expanded":r,"aria-label":r?"Hide onboarding details":"Show onboarding details",children:s.jsx(ct,{className:`size-3.5 transition-transform ${r?"rotate-180":""}`})}),s.jsxs("button",{type:"button",onClick:()=>{n()},className:"hidden h-8 shrink-0 items-center gap-1.5 rounded-md border border-amber-500/40 px-3 text-xs text-amber-200 transition-colors hover:bg-amber-500/10 sm:inline-flex","aria-label":"Dismiss onboarding tip",children:[s.jsx(Ge,{className:"size-3.5"}),"Got it"]}),s.jsx("button",{type:"button",onClick:()=>{n()},className:"-m-1 shrink-0 p-1 text-muted-foreground transition-colors hover:text-foreground","aria-label":"Dismiss",children:s.jsx(Ta,{className:"size-3.5"})})]})})}function Kr(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Lo={exports:{}};var Wl;function I2(){return Wl||(Wl=1,(function(e,t){(function(n){e.exports=n()})(function(){return(function n(r,o,i){function a(u,d){if(!o[u]){if(!r[u]){var f=typeof Kr=="function"&&Kr;if(!d&&f)return f(u,!0);if(l)return l(u,!0);var h=new Error("Cannot find module '"+u+"'");throw h.code="MODULE_NOT_FOUND",h}var m=o[u]={exports:{}};r[u][0].call(m.exports,function(v){var g=r[u][1][v];return a(g||v)},m,m.exports,n,r,o,i)}return o[u].exports}for(var l=typeof Kr=="function"&&Kr,c=0;c<i.length;c++)a(i[c]);return a})({1:[function(n,r,o){var i=n("./utils"),a=n("./support"),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";o.encode=function(c){for(var u,d,f,h,m,v,g,x=[],b=0,y=c.length,_=y,j=i.getTypeOf(c)!=="string";b<c.length;)_=y-b,f=j?(u=c[b++],d=b<y?c[b++]:0,b<y?c[b++]:0):(u=c.charCodeAt(b++),d=b<y?c.charCodeAt(b++):0,b<y?c.charCodeAt(b++):0),h=u>>2,m=(3&u)<<4|d>>4,v=1<_?(15&d)<<2|f>>6:64,g=2<_?63&f:64,x.push(l.charAt(h)+l.charAt(m)+l.charAt(v)+l.charAt(g));return x.join("")},o.decode=function(c){var u,d,f,h,m,v,g=0,x=0,b="data:";if(c.substr(0,b.length)===b)throw new Error("Invalid base64 input, it looks like a data url.");var y,_=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===l.charAt(64)&&_--,c.charAt(c.length-2)===l.charAt(64)&&_--,_%1!=0)throw new Error("Invalid base64 input, bad content length.");for(y=a.uint8array?new Uint8Array(0|_):new Array(0|_);g<c.length;)u=l.indexOf(c.charAt(g++))<<2|(h=l.indexOf(c.charAt(g++)))>>4,d=(15&h)<<4|(m=l.indexOf(c.charAt(g++)))>>2,f=(3&m)<<6|(v=l.indexOf(c.charAt(g++))),y[x++]=u,m!==64&&(y[x++]=d),v!==64&&(y[x++]=f);return y}},{"./support":30,"./utils":32}],2:[function(n,r,o){var i=n("./external"),a=n("./stream/DataWorker"),l=n("./stream/Crc32Probe"),c=n("./stream/DataLengthProbe");function u(d,f,h,m,v){this.compressedSize=d,this.uncompressedSize=f,this.crc32=h,this.compression=m,this.compressedContent=v}u.prototype={getContentWorker:function(){var d=new a(i.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),f=this;return d.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),d},getCompressedWorker:function(){return new a(i.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(d,f,h){return d.pipe(new l).pipe(new c("uncompressedSize")).pipe(f.compressWorker(h)).pipe(new c("compressedSize")).withStreamInfo("compression",f)},r.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,o){var i=n("./stream/GenericWorker");o.STORE={magic:"\0\0",compressWorker:function(){return new i("STORE compression")},uncompressWorker:function(){return new i("STORE decompression")}},o.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,o){var i=n("./utils"),a=(function(){for(var l,c=[],u=0;u<256;u++){l=u;for(var d=0;d<8;d++)l=1&l?3988292384^l>>>1:l>>>1;c[u]=l}return c})();r.exports=function(l,c){return l!==void 0&&l.length?i.getTypeOf(l)!=="string"?(function(u,d,f,h){var m=a,v=h+f;u^=-1;for(var g=h;g<v;g++)u=u>>>8^m[255&(u^d[g])];return-1^u})(0|c,l,l.length,0):(function(u,d,f,h){var m=a,v=h+f;u^=-1;for(var g=h;g<v;g++)u=u>>>8^m[255&(u^d.charCodeAt(g))];return-1^u})(0|c,l,l.length,0):0}},{"./utils":32}],5:[function(n,r,o){o.base64=!1,o.binary=!1,o.dir=!1,o.createFolders=!0,o.date=null,o.compression=null,o.compressionOptions=null,o.comment=null,o.unixPermissions=null,o.dosPermissions=null},{}],6:[function(n,r,o){var i=null;i=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:i}},{lie:37}],7:[function(n,r,o){var i=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=n("pako"),l=n("./utils"),c=n("./stream/GenericWorker"),u=i?"uint8array":"array";function d(f,h){c.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=h,this.meta={}}o.magic="\b\0",l.inherits(d,c),d.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(l.transformTo(u,f.data),!1)},d.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},d.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},d.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(h){f.push({data:h,meta:f.meta})}},o.compressWorker=function(f){return new d("Deflate",f)},o.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,o){function i(m,v){var g,x="";for(g=0;g<v;g++)x+=String.fromCharCode(255&m),m>>>=8;return x}function a(m,v,g,x,b,y){var _,j,S=m.file,T=m.compression,C=y!==u.utf8encode,A=l.transformTo("string",y(S.name)),E=l.transformTo("string",u.utf8encode(S.name)),P=S.comment,J=l.transformTo("string",y(P)),R=l.transformTo("string",u.utf8encode(P)),F=E.length!==S.name.length,k=R.length!==P.length,M="",Y="",D="",B=S.dir,U=S.date,ie={crc32:0,compressedSize:0,uncompressedSize:0};v&&!g||(ie.crc32=m.crc32,ie.compressedSize=m.compressedSize,ie.uncompressedSize=m.uncompressedSize);var W=0;v&&(W|=8),C||!F&&!k||(W|=2048);var H=0,ue=0;B&&(H|=16),b==="UNIX"?(ue=798,H|=(function(se,je){var ce=se;return se||(ce=je?16893:33204),(65535&ce)<<16})(S.unixPermissions,B)):(ue=20,H|=(function(se){return 63&(se||0)})(S.dosPermissions)),_=U.getUTCHours(),_<<=6,_|=U.getUTCMinutes(),_<<=5,_|=U.getUTCSeconds()/2,j=U.getUTCFullYear()-1980,j<<=4,j|=U.getUTCMonth()+1,j<<=5,j|=U.getUTCDate(),F&&(Y=i(1,1)+i(d(A),4)+E,M+="up"+i(Y.length,2)+Y),k&&(D=i(1,1)+i(d(J),4)+R,M+="uc"+i(D.length,2)+D);var ne="";return ne+=`
|
|
41
|
+
\0`,ne+=i(W,2),ne+=T.magic,ne+=i(_,2),ne+=i(j,2),ne+=i(ie.crc32,4),ne+=i(ie.compressedSize,4),ne+=i(ie.uncompressedSize,4),ne+=i(A.length,2),ne+=i(M.length,2),{fileRecord:f.LOCAL_FILE_HEADER+ne+A+M,dirRecord:f.CENTRAL_FILE_HEADER+i(ue,2)+ne+i(J.length,2)+"\0\0\0\0"+i(H,4)+i(x,4)+A+M+J}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function h(m,v,g,x){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=v,this.zipPlatform=g,this.encodeFileName=x,this.streamFiles=m,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}l.inherits(h,c),h.prototype.push=function(m){var v=m.meta.percent||0,g=this.entriesCount,x=this._sources.length;this.accumulate?this.contentBuffer.push(m):(this.bytesWritten+=m.data.length,c.prototype.push.call(this,{data:m.data,meta:{currentFile:this.currentFile,percent:g?(v+100*(g-x-1))/g:100}}))},h.prototype.openedSource=function(m){this.currentSourceOffset=this.bytesWritten,this.currentFile=m.file.name;var v=this.streamFiles&&!m.file.dir;if(v){var g=a(m,v,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:g.fileRecord,meta:{percent:0}})}else this.accumulate=!0},h.prototype.closedSource=function(m){this.accumulate=!1;var v=this.streamFiles&&!m.file.dir,g=a(m,v,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(g.dirRecord),v)this.push({data:(function(x){return f.DATA_DESCRIPTOR+i(x.crc32,4)+i(x.compressedSize,4)+i(x.uncompressedSize,4)})(m),meta:{percent:100}});else for(this.push({data:g.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},h.prototype.flush=function(){for(var m=this.bytesWritten,v=0;v<this.dirRecords.length;v++)this.push({data:this.dirRecords[v],meta:{percent:100}});var g=this.bytesWritten-m,x=(function(b,y,_,j,S){var T=l.transformTo("string",S(j));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+i(b,2)+i(b,2)+i(y,4)+i(_,4)+i(T.length,2)+T})(this.dirRecords.length,g,m,this.zipComment,this.encodeFileName);this.push({data:x,meta:{percent:100}})},h.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},h.prototype.registerPrevious=function(m){this._sources.push(m);var v=this;return m.on("data",function(g){v.processChunk(g)}),m.on("end",function(){v.closedSource(v.previous.streamInfo),v._sources.length?v.prepareNextSource():v.end()}),m.on("error",function(g){v.error(g)}),this},h.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},h.prototype.error=function(m){var v=this._sources;if(!c.prototype.error.call(this,m))return!1;for(var g=0;g<v.length;g++)try{v[g].error(m)}catch{}return!0},h.prototype.lock=function(){c.prototype.lock.call(this);for(var m=this._sources,v=0;v<m.length;v++)m[v].lock()},r.exports=h},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,o){var i=n("../compressions"),a=n("./ZipFileWorker");o.generateWorker=function(l,c,u){var d=new a(c.streamFiles,u,c.platform,c.encodeFileName),f=0;try{l.forEach(function(h,m){f++;var v=(function(y,_){var j=y||_,S=i[j];if(!S)throw new Error(j+" is not a valid compression method !");return S})(m.options.compression,c.compression),g=m.options.compressionOptions||c.compressionOptions||{},x=m.dir,b=m.date;m._compressWorker(v,g).withStreamInfo("file",{name:h,dir:x,date:b,comment:m.comment||"",unixPermissions:m.unixPermissions,dosPermissions:m.dosPermissions}).pipe(d)}),d.entriesCount=f}catch(h){d.error(h)}return d}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,o){function i(){if(!(this instanceof i))return new i;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var a=new i;for(var l in this)typeof this[l]!="function"&&(a[l]=this[l]);return a}}(i.prototype=n("./object")).loadAsync=n("./load"),i.support=n("./support"),i.defaults=n("./defaults"),i.version="3.10.1",i.loadAsync=function(a,l){return new i().loadAsync(a,l)},i.external=n("./external"),r.exports=i},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,o){var i=n("./utils"),a=n("./external"),l=n("./utf8"),c=n("./zipEntries"),u=n("./stream/Crc32Probe"),d=n("./nodejsUtils");function f(h){return new a.Promise(function(m,v){var g=h.decompressed.getContentWorker().pipe(new u);g.on("error",function(x){v(x)}).on("end",function(){g.streamInfo.crc32!==h.decompressed.crc32?v(new Error("Corrupted zip : CRC32 mismatch")):m()}).resume()})}r.exports=function(h,m){var v=this;return m=i.extend(m||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:l.utf8decode}),d.isNode&&d.isStream(h)?a.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):i.prepareContent("the loaded zip file",h,!0,m.optimizedBinaryString,m.base64).then(function(g){var x=new c(m);return x.load(g),x}).then(function(g){var x=[a.Promise.resolve(g)],b=g.files;if(m.checkCRC32)for(var y=0;y<b.length;y++)x.push(f(b[y]));return a.Promise.all(x)}).then(function(g){for(var x=g.shift(),b=x.files,y=0;y<b.length;y++){var _=b[y],j=_.fileNameStr,S=i.resolve(_.fileNameStr);v.file(S,_.decompressed,{binary:!0,optimizedBinaryString:!0,date:_.date,dir:_.dir,comment:_.fileCommentStr.length?_.fileCommentStr:null,unixPermissions:_.unixPermissions,dosPermissions:_.dosPermissions,createFolders:m.createFolders}),_.dir||(v.file(S).unsafeOriginalName=j)}return x.zipComment.length&&(v.comment=x.zipComment),v})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,o){var i=n("../utils"),a=n("../stream/GenericWorker");function l(c,u){a.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(u)}i.inherits(l,a),l.prototype._bindStream=function(c){var u=this;(this._stream=c).pause(),c.on("data",function(d){u.push({data:d,meta:{percent:0}})}).on("error",function(d){u.isPaused?this.generatedError=d:u.error(d)}).on("end",function(){u.isPaused?u._upstreamEnded=!0:u.end()})},l.prototype.pause=function(){return!!a.prototype.pause.call(this)&&(this._stream.pause(),!0)},l.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=l},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,o){var i=n("readable-stream").Readable;function a(l,c,u){i.call(this,c),this._helper=l;var d=this;l.on("data",function(f,h){d.push(f)||d._helper.pause(),u&&u(h)}).on("error",function(f){d.emit("error",f)}).on("end",function(){d.push(null)})}n("../utils").inherits(a,i),a.prototype._read=function(){this._helper.resume()},r.exports=a},{"../utils":32,"readable-stream":16}],14:[function(n,r,o){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(i,a){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(i,a);if(typeof i=="number")throw new Error('The "data" argument must not be a number');return new Buffer(i,a)},allocBuffer:function(i){if(Buffer.alloc)return Buffer.alloc(i);var a=new Buffer(i);return a.fill(0),a},isBuffer:function(i){return Buffer.isBuffer(i)},isStream:function(i){return i&&typeof i.on=="function"&&typeof i.pause=="function"&&typeof i.resume=="function"}}},{}],15:[function(n,r,o){function i(S,T,C){var A,E=l.getTypeOf(T),P=l.extend(C||{},d);P.date=P.date||new Date,P.compression!==null&&(P.compression=P.compression.toUpperCase()),typeof P.unixPermissions=="string"&&(P.unixPermissions=parseInt(P.unixPermissions,8)),P.unixPermissions&&16384&P.unixPermissions&&(P.dir=!0),P.dosPermissions&&16&P.dosPermissions&&(P.dir=!0),P.dir&&(S=b(S)),P.createFolders&&(A=x(S))&&y.call(this,A,!0);var J=E==="string"&&P.binary===!1&&P.base64===!1;C&&C.binary!==void 0||(P.binary=!J),(T instanceof f&&T.uncompressedSize===0||P.dir||!T||T.length===0)&&(P.base64=!1,P.binary=!0,T="",P.compression="STORE",E="string");var R=null;R=T instanceof f||T instanceof c?T:v.isNode&&v.isStream(T)?new g(S,T):l.prepareContent(S,T,P.binary,P.optimizedBinaryString,P.base64);var F=new h(S,R,P);this.files[S]=F}var a=n("./utf8"),l=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),f=n("./compressedObject"),h=n("./zipObject"),m=n("./generate"),v=n("./nodejsUtils"),g=n("./nodejs/NodejsStreamInputAdapter"),x=function(S){S.slice(-1)==="/"&&(S=S.substring(0,S.length-1));var T=S.lastIndexOf("/");return 0<T?S.substring(0,T):""},b=function(S){return S.slice(-1)!=="/"&&(S+="/"),S},y=function(S,T){return T=T!==void 0?T:d.createFolders,S=b(S),this.files[S]||i.call(this,S,null,{dir:!0,createFolders:T}),this.files[S]};function _(S){return Object.prototype.toString.call(S)==="[object RegExp]"}var j={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(S){var T,C,A;for(T in this.files)A=this.files[T],(C=T.slice(this.root.length,T.length))&&T.slice(0,this.root.length)===this.root&&S(C,A)},filter:function(S){var T=[];return this.forEach(function(C,A){S(C,A)&&T.push(A)}),T},file:function(S,T,C){if(arguments.length!==1)return S=this.root+S,i.call(this,S,T,C),this;if(_(S)){var A=S;return this.filter(function(P,J){return!J.dir&&A.test(P)})}var E=this.files[this.root+S];return E&&!E.dir?E:null},folder:function(S){if(!S)return this;if(_(S))return this.filter(function(E,P){return P.dir&&S.test(E)});var T=this.root+S,C=y.call(this,T),A=this.clone();return A.root=C.name,A},remove:function(S){S=this.root+S;var T=this.files[S];if(T||(S.slice(-1)!=="/"&&(S+="/"),T=this.files[S]),T&&!T.dir)delete this.files[S];else for(var C=this.filter(function(E,P){return P.name.slice(0,S.length)===S}),A=0;A<C.length;A++)delete this.files[C[A].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(S){var T,C={};try{if((C=l.extend(S||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=C.type.toLowerCase(),C.compression=C.compression.toUpperCase(),C.type==="binarystring"&&(C.type="string"),!C.type)throw new Error("No output type specified.");l.checkSupport(C.type),C.platform!=="darwin"&&C.platform!=="freebsd"&&C.platform!=="linux"&&C.platform!=="sunos"||(C.platform="UNIX"),C.platform==="win32"&&(C.platform="DOS");var A=C.comment||this.comment||"";T=m.generateWorker(this,C,A)}catch(E){(T=new c("error")).error(E)}return new u(T,C.type||"string",C.mimeType)},generateAsync:function(S,T){return this.generateInternalStream(S).accumulate(T)},generateNodeStream:function(S,T){return(S=S||{}).type||(S.type="nodebuffer"),this.generateInternalStream(S).toNodejsStream(T)}};r.exports=j},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,o){r.exports=n("stream")},{stream:void 0}],17:[function(n,r,o){var i=n("./DataReader");function a(l){i.call(this,l);for(var c=0;c<this.data.length;c++)l[c]=255&l[c]}n("../utils").inherits(a,i),a.prototype.byteAt=function(l){return this.data[this.zero+l]},a.prototype.lastIndexOfSignature=function(l){for(var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),f=l.charCodeAt(3),h=this.length-4;0<=h;--h)if(this.data[h]===c&&this.data[h+1]===u&&this.data[h+2]===d&&this.data[h+3]===f)return h-this.zero;return-1},a.prototype.readAndCheckSignature=function(l){var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),f=l.charCodeAt(3),h=this.readData(4);return c===h[0]&&u===h[1]&&d===h[2]&&f===h[3]},a.prototype.readData=function(l){if(this.checkOffset(l),l===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=a},{"../utils":32,"./DataReader":18}],18:[function(n,r,o){var i=n("../utils");function a(l){this.data=l,this.length=l.length,this.index=0,this.zero=0}a.prototype={checkOffset:function(l){this.checkIndex(this.index+l)},checkIndex:function(l){if(this.length<this.zero+l||l<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+l+"). Corrupted zip ?")},setIndex:function(l){this.checkIndex(l),this.index=l},skip:function(l){this.setIndex(this.index+l)},byteAt:function(){},readInt:function(l){var c,u=0;for(this.checkOffset(l),c=this.index+l-1;c>=this.index;c--)u=(u<<8)+this.byteAt(c);return this.index+=l,u},readString:function(l){return i.transformTo("string",this.readData(l))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var l=this.readInt(4);return new Date(Date.UTC(1980+(l>>25&127),(l>>21&15)-1,l>>16&31,l>>11&31,l>>5&63,(31&l)<<1))}},r.exports=a},{"../utils":32}],19:[function(n,r,o){var i=n("./Uint8ArrayReader");function a(l){i.call(this,l)}n("../utils").inherits(a,i),a.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,o){var i=n("./DataReader");function a(l){i.call(this,l)}n("../utils").inherits(a,i),a.prototype.byteAt=function(l){return this.data.charCodeAt(this.zero+l)},a.prototype.lastIndexOfSignature=function(l){return this.data.lastIndexOf(l)-this.zero},a.prototype.readAndCheckSignature=function(l){return l===this.readData(4)},a.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=a},{"../utils":32,"./DataReader":18}],21:[function(n,r,o){var i=n("./ArrayReader");function a(l){i.call(this,l)}n("../utils").inherits(a,i),a.prototype.readData=function(l){if(this.checkOffset(l),l===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,o){var i=n("../utils"),a=n("../support"),l=n("./ArrayReader"),c=n("./StringReader"),u=n("./NodeBufferReader"),d=n("./Uint8ArrayReader");r.exports=function(f){var h=i.getTypeOf(f);return i.checkSupport(h),h!=="string"||a.uint8array?h==="nodebuffer"?new u(f):a.uint8array?new d(i.transformTo("uint8array",f)):new l(i.transformTo("array",f)):new c(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,o){o.LOCAL_FILE_HEADER="PK",o.CENTRAL_FILE_HEADER="PK",o.CENTRAL_DIRECTORY_END="PK",o.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",o.ZIP64_CENTRAL_DIRECTORY_END="PK",o.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,o){var i=n("./GenericWorker"),a=n("../utils");function l(c){i.call(this,"ConvertWorker to "+c),this.destType=c}a.inherits(l,i),l.prototype.processChunk=function(c){this.push({data:a.transformTo(this.destType,c.data),meta:c.meta})},r.exports=l},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,o){var i=n("./GenericWorker"),a=n("../crc32");function l(){i.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(l,i),l.prototype.processChunk=function(c){this.streamInfo.crc32=a(c.data,this.streamInfo.crc32||0),this.push(c)},r.exports=l},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,o){var i=n("../utils"),a=n("./GenericWorker");function l(c){a.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}i.inherits(l,a),l.prototype.processChunk=function(c){if(c){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+c.data.length}a.prototype.processChunk.call(this,c)},r.exports=l},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,o){var i=n("../utils"),a=n("./GenericWorker");function l(c){a.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(d){u.dataIsReady=!0,u.data=d,u.max=d&&d.length||0,u.type=i.getTypeOf(d),u.isPaused||u._tickAndRepeat()},function(d){u.error(d)})}i.inherits(l,a),l.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},l.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,i.delay(this._tickAndRepeat,[],this)),!0)},l.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(i.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},l.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,u);break;case"uint8array":c=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":c=this.data.slice(this.index,u)}return this.index=u,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=l},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,o){function i(a){this.name=a||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}i.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,l){return this._listeners[a].push(l),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,l){if(this._listeners[a])for(var c=0;c<this._listeners[a].length;c++)this._listeners[a][c].call(this,l)},pipe:function(a){return a.registerPrevious(this)},registerPrevious:function(a){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=a.streamInfo,this.mergeStreamInfo(),this.previous=a;var l=this;return a.on("data",function(c){l.processChunk(c)}),a.on("end",function(){l.end()}),a.on("error",function(c){l.error(c)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var a=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),a=!0),this.previous&&this.previous.resume(),!a},flush:function(){},processChunk:function(a){this.push(a)},withStreamInfo:function(a,l){return this.extraStreamInfo[a]=l,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var a in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,a)&&(this.streamInfo[a]=this.extraStreamInfo[a])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var a="Worker "+this.name;return this.previous?this.previous+" -> "+a:a}},r.exports=i},{}],29:[function(n,r,o){var i=n("../utils"),a=n("./ConvertWorker"),l=n("./GenericWorker"),c=n("../base64"),u=n("../support"),d=n("../external"),f=null;if(u.nodestream)try{f=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function h(v,g){return new d.Promise(function(x,b){var y=[],_=v._internalType,j=v._outputType,S=v._mimeType;v.on("data",function(T,C){y.push(T),g&&g(C)}).on("error",function(T){y=[],b(T)}).on("end",function(){try{var T=(function(C,A,E){switch(C){case"blob":return i.newBlob(i.transformTo("arraybuffer",A),E);case"base64":return c.encode(A);default:return i.transformTo(C,A)}})(j,(function(C,A){var E,P=0,J=null,R=0;for(E=0;E<A.length;E++)R+=A[E].length;switch(C){case"string":return A.join("");case"array":return Array.prototype.concat.apply([],A);case"uint8array":for(J=new Uint8Array(R),E=0;E<A.length;E++)J.set(A[E],P),P+=A[E].length;return J;case"nodebuffer":return Buffer.concat(A);default:throw new Error("concat : unsupported type '"+C+"'")}})(_,y),S);x(T)}catch(C){b(C)}y=[]}).resume()})}function m(v,g,x){var b=g;switch(g){case"blob":case"arraybuffer":b="uint8array";break;case"base64":b="string"}try{this._internalType=b,this._outputType=g,this._mimeType=x,i.checkSupport(b),this._worker=v.pipe(new a(b)),v.lock()}catch(y){this._worker=new l("error"),this._worker.error(y)}}m.prototype={accumulate:function(v){return h(this,v)},on:function(v,g){var x=this;return v==="data"?this._worker.on(v,function(b){g.call(x,b.data,b.meta)}):this._worker.on(v,function(){i.delay(g,arguments,x)}),this},resume:function(){return i.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(v){if(i.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new f(this,{objectMode:this._outputType!=="nodebuffer"},v)}},r.exports=m},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,o){if(o.base64=!0,o.array=!0,o.string=!0,o.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",o.nodebuffer=typeof Buffer<"u",o.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")o.blob=!1;else{var i=new ArrayBuffer(0);try{o.blob=new Blob([i],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(i),o.blob=a.getBlob("application/zip").size===0}catch{o.blob=!1}}}try{o.nodestream=!!n("readable-stream").Readable}catch{o.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,o){for(var i=n("./utils"),a=n("./support"),l=n("./nodejsUtils"),c=n("./stream/GenericWorker"),u=new Array(256),d=0;d<256;d++)u[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;u[254]=u[254]=1;function f(){c.call(this,"utf-8 decode"),this.leftOver=null}function h(){c.call(this,"utf-8 encode")}o.utf8encode=function(m){return a.nodebuffer?l.newBufferFrom(m,"utf-8"):(function(v){var g,x,b,y,_,j=v.length,S=0;for(y=0;y<j;y++)(64512&(x=v.charCodeAt(y)))==55296&&y+1<j&&(64512&(b=v.charCodeAt(y+1)))==56320&&(x=65536+(x-55296<<10)+(b-56320),y++),S+=x<128?1:x<2048?2:x<65536?3:4;for(g=a.uint8array?new Uint8Array(S):new Array(S),y=_=0;_<S;y++)(64512&(x=v.charCodeAt(y)))==55296&&y+1<j&&(64512&(b=v.charCodeAt(y+1)))==56320&&(x=65536+(x-55296<<10)+(b-56320),y++),x<128?g[_++]=x:(x<2048?g[_++]=192|x>>>6:(x<65536?g[_++]=224|x>>>12:(g[_++]=240|x>>>18,g[_++]=128|x>>>12&63),g[_++]=128|x>>>6&63),g[_++]=128|63&x);return g})(m)},o.utf8decode=function(m){return a.nodebuffer?i.transformTo("nodebuffer",m).toString("utf-8"):(function(v){var g,x,b,y,_=v.length,j=new Array(2*_);for(g=x=0;g<_;)if((b=v[g++])<128)j[x++]=b;else if(4<(y=u[b]))j[x++]=65533,g+=y-1;else{for(b&=y===2?31:y===3?15:7;1<y&&g<_;)b=b<<6|63&v[g++],y--;1<y?j[x++]=65533:b<65536?j[x++]=b:(b-=65536,j[x++]=55296|b>>10&1023,j[x++]=56320|1023&b)}return j.length!==x&&(j.subarray?j=j.subarray(0,x):j.length=x),i.applyFromCharCode(j)})(m=i.transformTo(a.uint8array?"uint8array":"array",m))},i.inherits(f,c),f.prototype.processChunk=function(m){var v=i.transformTo(a.uint8array?"uint8array":"array",m.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var g=v;(v=new Uint8Array(g.length+this.leftOver.length)).set(this.leftOver,0),v.set(g,this.leftOver.length)}else v=this.leftOver.concat(v);this.leftOver=null}var x=(function(y,_){var j;for((_=_||y.length)>y.length&&(_=y.length),j=_-1;0<=j&&(192&y[j])==128;)j--;return j<0||j===0?_:j+u[y[j]]>_?j:_})(v),b=v;x!==v.length&&(a.uint8array?(b=v.subarray(0,x),this.leftOver=v.subarray(x,v.length)):(b=v.slice(0,x),this.leftOver=v.slice(x,v.length))),this.push({data:o.utf8decode(b),meta:m.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:o.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},o.Utf8DecodeWorker=f,i.inherits(h,c),h.prototype.processChunk=function(m){this.push({data:o.utf8encode(m.data),meta:m.meta})},o.Utf8EncodeWorker=h},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,o){var i=n("./support"),a=n("./base64"),l=n("./nodejsUtils"),c=n("./external");function u(g){return g}function d(g,x){for(var b=0;b<g.length;++b)x[b]=255&g.charCodeAt(b);return x}n("setimmediate"),o.newBlob=function(g,x){o.checkSupport("blob");try{return new Blob([g],{type:x})}catch{try{var b=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return b.append(g),b.getBlob(x)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(g,x,b){var y=[],_=0,j=g.length;if(j<=b)return String.fromCharCode.apply(null,g);for(;_<j;)x==="array"||x==="nodebuffer"?y.push(String.fromCharCode.apply(null,g.slice(_,Math.min(_+b,j)))):y.push(String.fromCharCode.apply(null,g.subarray(_,Math.min(_+b,j)))),_+=b;return y.join("")},stringifyByChar:function(g){for(var x="",b=0;b<g.length;b++)x+=String.fromCharCode(g[b]);return x},applyCanBeUsed:{uint8array:(function(){try{return i.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return i.nodebuffer&&String.fromCharCode.apply(null,l.allocBuffer(1)).length===1}catch{return!1}})()}};function h(g){var x=65536,b=o.getTypeOf(g),y=!0;if(b==="uint8array"?y=f.applyCanBeUsed.uint8array:b==="nodebuffer"&&(y=f.applyCanBeUsed.nodebuffer),y)for(;1<x;)try{return f.stringifyByChunk(g,b,x)}catch{x=Math.floor(x/2)}return f.stringifyByChar(g)}function m(g,x){for(var b=0;b<g.length;b++)x[b]=g[b];return x}o.applyFromCharCode=h;var v={};v.string={string:u,array:function(g){return d(g,new Array(g.length))},arraybuffer:function(g){return v.string.uint8array(g).buffer},uint8array:function(g){return d(g,new Uint8Array(g.length))},nodebuffer:function(g){return d(g,l.allocBuffer(g.length))}},v.array={string:h,array:u,arraybuffer:function(g){return new Uint8Array(g).buffer},uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return l.newBufferFrom(g)}},v.arraybuffer={string:function(g){return h(new Uint8Array(g))},array:function(g){return m(new Uint8Array(g),new Array(g.byteLength))},arraybuffer:u,uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return l.newBufferFrom(new Uint8Array(g))}},v.uint8array={string:h,array:function(g){return m(g,new Array(g.length))},arraybuffer:function(g){return g.buffer},uint8array:u,nodebuffer:function(g){return l.newBufferFrom(g)}},v.nodebuffer={string:h,array:function(g){return m(g,new Array(g.length))},arraybuffer:function(g){return v.nodebuffer.uint8array(g).buffer},uint8array:function(g){return m(g,new Uint8Array(g.length))},nodebuffer:u},o.transformTo=function(g,x){if(x=x||"",!g)return x;o.checkSupport(g);var b=o.getTypeOf(x);return v[b][g](x)},o.resolve=function(g){for(var x=g.split("/"),b=[],y=0;y<x.length;y++){var _=x[y];_==="."||_===""&&y!==0&&y!==x.length-1||(_===".."?b.pop():b.push(_))}return b.join("/")},o.getTypeOf=function(g){return typeof g=="string"?"string":Object.prototype.toString.call(g)==="[object Array]"?"array":i.nodebuffer&&l.isBuffer(g)?"nodebuffer":i.uint8array&&g instanceof Uint8Array?"uint8array":i.arraybuffer&&g instanceof ArrayBuffer?"arraybuffer":void 0},o.checkSupport=function(g){if(!i[g.toLowerCase()])throw new Error(g+" is not supported by this platform")},o.MAX_VALUE_16BITS=65535,o.MAX_VALUE_32BITS=-1,o.pretty=function(g){var x,b,y="";for(b=0;b<(g||"").length;b++)y+="\\x"+((x=g.charCodeAt(b))<16?"0":"")+x.toString(16).toUpperCase();return y},o.delay=function(g,x,b){setImmediate(function(){g.apply(b||null,x||[])})},o.inherits=function(g,x){function b(){}b.prototype=x.prototype,g.prototype=new b},o.extend=function(){var g,x,b={};for(g=0;g<arguments.length;g++)for(x in arguments[g])Object.prototype.hasOwnProperty.call(arguments[g],x)&&b[x]===void 0&&(b[x]=arguments[g][x]);return b},o.prepareContent=function(g,x,b,y,_){return c.Promise.resolve(x).then(function(j){return i.blob&&(j instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(j))!==-1)&&typeof FileReader<"u"?new c.Promise(function(S,T){var C=new FileReader;C.onload=function(A){S(A.target.result)},C.onerror=function(A){T(A.target.error)},C.readAsArrayBuffer(j)}):j}).then(function(j){var S=o.getTypeOf(j);return S?(S==="arraybuffer"?j=o.transformTo("uint8array",j):S==="string"&&(_?j=a.decode(j):b&&y!==!0&&(j=(function(T){return d(T,i.uint8array?new Uint8Array(T.length):new Array(T.length))})(j))),j):c.Promise.reject(new Error("Can't read the data of '"+g+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,o){var i=n("./reader/readerFor"),a=n("./utils"),l=n("./signature"),c=n("./zipEntry"),u=n("./support");function d(f){this.files=[],this.loadOptions=f}d.prototype={checkSignature:function(f){if(!this.reader.readAndCheckSignature(f)){this.reader.index-=4;var h=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+a.pretty(h)+", expected "+a.pretty(f)+")")}},isSignature:function(f,h){var m=this.reader.index;this.reader.setIndex(f);var v=this.reader.readString(4)===h;return this.reader.setIndex(m),v},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var f=this.reader.readData(this.zipCommentLength),h=u.uint8array?"uint8array":"array",m=a.transformTo(h,f);this.zipComment=this.loadOptions.decodeFileName(m)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var f,h,m,v=this.zip64EndOfCentralSize-44;0<v;)f=this.reader.readInt(2),h=this.reader.readInt(4),m=this.reader.readData(h),this.zip64ExtensibleData[f]={id:f,length:h,value:m}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var f,h;for(f=0;f<this.files.length;f++)h=this.files[f],this.reader.setIndex(h.localHeaderOffset),this.checkSignature(l.LOCAL_FILE_HEADER),h.readLocalPart(this.reader),h.handleUTF8(),h.processAttributes()},readCentralDir:function(){var f;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(l.CENTRAL_FILE_HEADER);)(f=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(f);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var f=this.reader.lastIndexOfSignature(l.CENTRAL_DIRECTORY_END);if(f<0)throw this.isSignature(0,l.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(f);var h=f;if(this.checkSignature(l.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===a.MAX_VALUE_16BITS||this.diskWithCentralDirStart===a.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===a.MAX_VALUE_16BITS||this.centralDirRecords===a.MAX_VALUE_16BITS||this.centralDirSize===a.MAX_VALUE_32BITS||this.centralDirOffset===a.MAX_VALUE_32BITS){if(this.zip64=!0,(f=this.reader.lastIndexOfSignature(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(f),this.checkSignature(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,l.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(l.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(l.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var m=this.centralDirOffset+this.centralDirSize;this.zip64&&(m+=20,m+=12+this.zip64EndOfCentralSize);var v=h-m;if(0<v)this.isSignature(h,l.CENTRAL_FILE_HEADER)||(this.reader.zero=v);else if(v<0)throw new Error("Corrupted zip: missing "+Math.abs(v)+" bytes.")},prepareReader:function(f){this.reader=i(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,o){var i=n("./reader/readerFor"),a=n("./utils"),l=n("./compressedObject"),c=n("./crc32"),u=n("./utf8"),d=n("./compressions"),f=n("./support");function h(m,v){this.options=m,this.loadOptions=v}h.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(m){var v,g;if(m.skip(22),this.fileNameLength=m.readInt(2),g=m.readInt(2),this.fileName=m.readData(this.fileNameLength),m.skip(g),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((v=(function(x){for(var b in d)if(Object.prototype.hasOwnProperty.call(d,b)&&d[b].magic===x)return d[b];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+a.pretty(this.compressionMethod)+" unknown (inner file : "+a.transformTo("string",this.fileName)+")");this.decompressed=new l(this.compressedSize,this.uncompressedSize,this.crc32,v,m.readData(this.compressedSize))},readCentralPart:function(m){this.versionMadeBy=m.readInt(2),m.skip(2),this.bitFlag=m.readInt(2),this.compressionMethod=m.readString(2),this.date=m.readDate(),this.crc32=m.readInt(4),this.compressedSize=m.readInt(4),this.uncompressedSize=m.readInt(4);var v=m.readInt(2);if(this.extraFieldsLength=m.readInt(2),this.fileCommentLength=m.readInt(2),this.diskNumberStart=m.readInt(2),this.internalFileAttributes=m.readInt(2),this.externalFileAttributes=m.readInt(4),this.localHeaderOffset=m.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");m.skip(v),this.readExtraFields(m),this.parseZIP64ExtraField(m),this.fileComment=m.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var m=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),m==0&&(this.dosPermissions=63&this.externalFileAttributes),m==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var m=i(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=m.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=m.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=m.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=m.readInt(4))}},readExtraFields:function(m){var v,g,x,b=m.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});m.index+4<b;)v=m.readInt(2),g=m.readInt(2),x=m.readData(g),this.extraFields[v]={id:v,length:g,value:x};m.setIndex(b)},handleUTF8:function(){var m=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var v=this.findExtraFieldUnicodePath();if(v!==null)this.fileNameStr=v;else{var g=a.transformTo(m,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(g)}var x=this.findExtraFieldUnicodeComment();if(x!==null)this.fileCommentStr=x;else{var b=a.transformTo(m,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(b)}}},findExtraFieldUnicodePath:function(){var m=this.extraFields[28789];if(m){var v=i(m.value);return v.readInt(1)!==1||c(this.fileName)!==v.readInt(4)?null:u.utf8decode(v.readData(m.length-5))}return null},findExtraFieldUnicodeComment:function(){var m=this.extraFields[25461];if(m){var v=i(m.value);return v.readInt(1)!==1||c(this.fileComment)!==v.readInt(4)?null:u.utf8decode(v.readData(m.length-5))}return null}},r.exports=h},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,o){function i(v,g,x){this.name=v,this.dir=x.dir,this.date=x.date,this.comment=x.comment,this.unixPermissions=x.unixPermissions,this.dosPermissions=x.dosPermissions,this._data=g,this._dataBinary=x.binary,this.options={compression:x.compression,compressionOptions:x.compressionOptions}}var a=n("./stream/StreamHelper"),l=n("./stream/DataWorker"),c=n("./utf8"),u=n("./compressedObject"),d=n("./stream/GenericWorker");i.prototype={internalStream:function(v){var g=null,x="string";try{if(!v)throw new Error("No output type specified.");var b=(x=v.toLowerCase())==="string"||x==="text";x!=="binarystring"&&x!=="text"||(x="string"),g=this._decompressWorker();var y=!this._dataBinary;y&&!b&&(g=g.pipe(new c.Utf8EncodeWorker)),!y&&b&&(g=g.pipe(new c.Utf8DecodeWorker))}catch(_){(g=new d("error")).error(_)}return new a(g,x,"")},async:function(v,g){return this.internalStream(v).accumulate(g)},nodeStream:function(v,g){return this.internalStream(v||"nodebuffer").toNodejsStream(g)},_compressWorker:function(v,g){if(this._data instanceof u&&this._data.compression.magic===v.magic)return this._data.getCompressedWorker();var x=this._decompressWorker();return this._dataBinary||(x=x.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(x,v,g)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new l(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],h=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},m=0;m<f.length;m++)i.prototype[f[m]]=h;r.exports=i},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,o){(function(i){var a,l,c=i.MutationObserver||i.WebKitMutationObserver;if(c){var u=0,d=new c(v),f=i.document.createTextNode("");d.observe(f,{characterData:!0}),a=function(){f.data=u=++u%2}}else if(i.setImmediate||i.MessageChannel===void 0)a="document"in i&&"onreadystatechange"in i.document.createElement("script")?function(){var g=i.document.createElement("script");g.onreadystatechange=function(){v(),g.onreadystatechange=null,g.parentNode.removeChild(g),g=null},i.document.documentElement.appendChild(g)}:function(){setTimeout(v,0)};else{var h=new i.MessageChannel;h.port1.onmessage=v,a=function(){h.port2.postMessage(0)}}var m=[];function v(){var g,x;l=!0;for(var b=m.length;b;){for(x=m,m=[],g=-1;++g<b;)x[g]();b=m.length}l=!1}r.exports=function(g){m.push(g)!==1||l||a()}}).call(this,typeof Hr<"u"?Hr:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,o){var i=n("immediate");function a(){}var l={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function f(b){if(typeof b!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,b!==a&&g(this,b)}function h(b,y,_){this.promise=b,typeof y=="function"&&(this.onFulfilled=y,this.callFulfilled=this.otherCallFulfilled),typeof _=="function"&&(this.onRejected=_,this.callRejected=this.otherCallRejected)}function m(b,y,_){i(function(){var j;try{j=y(_)}catch(S){return l.reject(b,S)}j===b?l.reject(b,new TypeError("Cannot resolve promise with itself")):l.resolve(b,j)})}function v(b){var y=b&&b.then;if(b&&(typeof b=="object"||typeof b=="function")&&typeof y=="function")return function(){y.apply(b,arguments)}}function g(b,y){var _=!1;function j(C){_||(_=!0,l.reject(b,C))}function S(C){_||(_=!0,l.resolve(b,C))}var T=x(function(){y(S,j)});T.status==="error"&&j(T.value)}function x(b,y){var _={};try{_.value=b(y),_.status="success"}catch(j){_.status="error",_.value=j}return _}(r.exports=f).prototype.finally=function(b){if(typeof b!="function")return this;var y=this.constructor;return this.then(function(_){return y.resolve(b()).then(function(){return _})},function(_){return y.resolve(b()).then(function(){throw _})})},f.prototype.catch=function(b){return this.then(null,b)},f.prototype.then=function(b,y){if(typeof b!="function"&&this.state===u||typeof y!="function"&&this.state===c)return this;var _=new this.constructor(a);return this.state!==d?m(_,this.state===u?b:y,this.outcome):this.queue.push(new h(_,b,y)),_},h.prototype.callFulfilled=function(b){l.resolve(this.promise,b)},h.prototype.otherCallFulfilled=function(b){m(this.promise,this.onFulfilled,b)},h.prototype.callRejected=function(b){l.reject(this.promise,b)},h.prototype.otherCallRejected=function(b){m(this.promise,this.onRejected,b)},l.resolve=function(b,y){var _=x(v,y);if(_.status==="error")return l.reject(b,_.value);var j=_.value;if(j)g(b,j);else{b.state=u,b.outcome=y;for(var S=-1,T=b.queue.length;++S<T;)b.queue[S].callFulfilled(y)}return b},l.reject=function(b,y){b.state=c,b.outcome=y;for(var _=-1,j=b.queue.length;++_<j;)b.queue[_].callRejected(y);return b},f.resolve=function(b){return b instanceof this?b:l.resolve(new this(a),b)},f.reject=function(b){var y=new this(a);return l.reject(y,b)},f.all=function(b){var y=this;if(Object.prototype.toString.call(b)!=="[object Array]")return this.reject(new TypeError("must be an array"));var _=b.length,j=!1;if(!_)return this.resolve([]);for(var S=new Array(_),T=0,C=-1,A=new this(a);++C<_;)E(b[C],C);return A;function E(P,J){y.resolve(P).then(function(R){S[J]=R,++T!==_||j||(j=!0,l.resolve(A,S))},function(R){j||(j=!0,l.reject(A,R))})}},f.race=function(b){var y=this;if(Object.prototype.toString.call(b)!=="[object Array]")return this.reject(new TypeError("must be an array"));var _=b.length,j=!1;if(!_)return this.resolve([]);for(var S=-1,T=new this(a);++S<_;)C=b[S],y.resolve(C).then(function(A){j||(j=!0,l.resolve(T,A))},function(A){j||(j=!0,l.reject(T,A))});var C;return T}},{immediate:36}],38:[function(n,r,o){var i={};(0,n("./lib/utils/common").assign)(i,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=i},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,o){var i=n("./zlib/deflate"),a=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/messages"),u=n("./zlib/zstream"),d=Object.prototype.toString,f=0,h=-1,m=0,v=8;function g(b){if(!(this instanceof g))return new g(b);this.options=a.assign({level:h,method:v,chunkSize:16384,windowBits:15,memLevel:8,strategy:m,to:""},b||{});var y=this.options;y.raw&&0<y.windowBits?y.windowBits=-y.windowBits:y.gzip&&0<y.windowBits&&y.windowBits<16&&(y.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var _=i.deflateInit2(this.strm,y.level,y.method,y.windowBits,y.memLevel,y.strategy);if(_!==f)throw new Error(c[_]);if(y.header&&i.deflateSetHeader(this.strm,y.header),y.dictionary){var j;if(j=typeof y.dictionary=="string"?l.string2buf(y.dictionary):d.call(y.dictionary)==="[object ArrayBuffer]"?new Uint8Array(y.dictionary):y.dictionary,(_=i.deflateSetDictionary(this.strm,j))!==f)throw new Error(c[_]);this._dict_set=!0}}function x(b,y){var _=new g(y);if(_.push(b,!0),_.err)throw _.msg||c[_.err];return _.result}g.prototype.push=function(b,y){var _,j,S=this.strm,T=this.options.chunkSize;if(this.ended)return!1;j=y===~~y?y:y===!0?4:0,typeof b=="string"?S.input=l.string2buf(b):d.call(b)==="[object ArrayBuffer]"?S.input=new Uint8Array(b):S.input=b,S.next_in=0,S.avail_in=S.input.length;do{if(S.avail_out===0&&(S.output=new a.Buf8(T),S.next_out=0,S.avail_out=T),(_=i.deflate(S,j))!==1&&_!==f)return this.onEnd(_),!(this.ended=!0);S.avail_out!==0&&(S.avail_in!==0||j!==4&&j!==2)||(this.options.to==="string"?this.onData(l.buf2binstring(a.shrinkBuf(S.output,S.next_out))):this.onData(a.shrinkBuf(S.output,S.next_out)))}while((0<S.avail_in||S.avail_out===0)&&_!==1);return j===4?(_=i.deflateEnd(this.strm),this.onEnd(_),this.ended=!0,_===f):j!==2||(this.onEnd(f),!(S.avail_out=0))},g.prototype.onData=function(b){this.chunks.push(b)},g.prototype.onEnd=function(b){b===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=b,this.msg=this.strm.msg},o.Deflate=g,o.deflate=x,o.deflateRaw=function(b,y){return(y=y||{}).raw=!0,x(b,y)},o.gzip=function(b,y){return(y=y||{}).gzip=!0,x(b,y)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,o){var i=n("./zlib/inflate"),a=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/constants"),u=n("./zlib/messages"),d=n("./zlib/zstream"),f=n("./zlib/gzheader"),h=Object.prototype.toString;function m(g){if(!(this instanceof m))return new m(g);this.options=a.assign({chunkSize:16384,windowBits:0,to:""},g||{});var x=this.options;x.raw&&0<=x.windowBits&&x.windowBits<16&&(x.windowBits=-x.windowBits,x.windowBits===0&&(x.windowBits=-15)),!(0<=x.windowBits&&x.windowBits<16)||g&&g.windowBits||(x.windowBits+=32),15<x.windowBits&&x.windowBits<48&&(15&x.windowBits)==0&&(x.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var b=i.inflateInit2(this.strm,x.windowBits);if(b!==c.Z_OK)throw new Error(u[b]);this.header=new f,i.inflateGetHeader(this.strm,this.header)}function v(g,x){var b=new m(x);if(b.push(g,!0),b.err)throw b.msg||u[b.err];return b.result}m.prototype.push=function(g,x){var b,y,_,j,S,T,C=this.strm,A=this.options.chunkSize,E=this.options.dictionary,P=!1;if(this.ended)return!1;y=x===~~x?x:x===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof g=="string"?C.input=l.binstring2buf(g):h.call(g)==="[object ArrayBuffer]"?C.input=new Uint8Array(g):C.input=g,C.next_in=0,C.avail_in=C.input.length;do{if(C.avail_out===0&&(C.output=new a.Buf8(A),C.next_out=0,C.avail_out=A),(b=i.inflate(C,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&E&&(T=typeof E=="string"?l.string2buf(E):h.call(E)==="[object ArrayBuffer]"?new Uint8Array(E):E,b=i.inflateSetDictionary(this.strm,T)),b===c.Z_BUF_ERROR&&P===!0&&(b=c.Z_OK,P=!1),b!==c.Z_STREAM_END&&b!==c.Z_OK)return this.onEnd(b),!(this.ended=!0);C.next_out&&(C.avail_out!==0&&b!==c.Z_STREAM_END&&(C.avail_in!==0||y!==c.Z_FINISH&&y!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(_=l.utf8border(C.output,C.next_out),j=C.next_out-_,S=l.buf2string(C.output,_),C.next_out=j,C.avail_out=A-j,j&&a.arraySet(C.output,C.output,_,j,0),this.onData(S)):this.onData(a.shrinkBuf(C.output,C.next_out)))),C.avail_in===0&&C.avail_out===0&&(P=!0)}while((0<C.avail_in||C.avail_out===0)&&b!==c.Z_STREAM_END);return b===c.Z_STREAM_END&&(y=c.Z_FINISH),y===c.Z_FINISH?(b=i.inflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===c.Z_OK):y!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(C.avail_out=0))},m.prototype.onData=function(g){this.chunks.push(g)},m.prototype.onEnd=function(g){g===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=g,this.msg=this.strm.msg},o.Inflate=m,o.inflate=v,o.inflateRaw=function(g,x){return(x=x||{}).raw=!0,v(g,x)},o.ungzip=v},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,o){var i=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";o.assign=function(c){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var d=u.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var f in d)d.hasOwnProperty(f)&&(c[f]=d[f])}}return c},o.shrinkBuf=function(c,u){return c.length===u?c:c.subarray?c.subarray(0,u):(c.length=u,c)};var a={arraySet:function(c,u,d,f,h){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+f),h);else for(var m=0;m<f;m++)c[h+m]=u[d+m]},flattenChunks:function(c){var u,d,f,h,m,v;for(u=f=0,d=c.length;u<d;u++)f+=c[u].length;for(v=new Uint8Array(f),u=h=0,d=c.length;u<d;u++)m=c[u],v.set(m,h),h+=m.length;return v}},l={arraySet:function(c,u,d,f,h){for(var m=0;m<f;m++)c[h+m]=u[d+m]},flattenChunks:function(c){return[].concat.apply([],c)}};o.setTyped=function(c){c?(o.Buf8=Uint8Array,o.Buf16=Uint16Array,o.Buf32=Int32Array,o.assign(o,a)):(o.Buf8=Array,o.Buf16=Array,o.Buf32=Array,o.assign(o,l))},o.setTyped(i)},{}],42:[function(n,r,o){var i=n("./common"),a=!0,l=!0;try{String.fromCharCode.apply(null,[0])}catch{a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{l=!1}for(var c=new i.Buf8(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function d(f,h){if(h<65537&&(f.subarray&&l||!f.subarray&&a))return String.fromCharCode.apply(null,i.shrinkBuf(f,h));for(var m="",v=0;v<h;v++)m+=String.fromCharCode(f[v]);return m}c[254]=c[254]=1,o.string2buf=function(f){var h,m,v,g,x,b=f.length,y=0;for(g=0;g<b;g++)(64512&(m=f.charCodeAt(g)))==55296&&g+1<b&&(64512&(v=f.charCodeAt(g+1)))==56320&&(m=65536+(m-55296<<10)+(v-56320),g++),y+=m<128?1:m<2048?2:m<65536?3:4;for(h=new i.Buf8(y),g=x=0;x<y;g++)(64512&(m=f.charCodeAt(g)))==55296&&g+1<b&&(64512&(v=f.charCodeAt(g+1)))==56320&&(m=65536+(m-55296<<10)+(v-56320),g++),m<128?h[x++]=m:(m<2048?h[x++]=192|m>>>6:(m<65536?h[x++]=224|m>>>12:(h[x++]=240|m>>>18,h[x++]=128|m>>>12&63),h[x++]=128|m>>>6&63),h[x++]=128|63&m);return h},o.buf2binstring=function(f){return d(f,f.length)},o.binstring2buf=function(f){for(var h=new i.Buf8(f.length),m=0,v=h.length;m<v;m++)h[m]=f.charCodeAt(m);return h},o.buf2string=function(f,h){var m,v,g,x,b=h||f.length,y=new Array(2*b);for(m=v=0;m<b;)if((g=f[m++])<128)y[v++]=g;else if(4<(x=c[g]))y[v++]=65533,m+=x-1;else{for(g&=x===2?31:x===3?15:7;1<x&&m<b;)g=g<<6|63&f[m++],x--;1<x?y[v++]=65533:g<65536?y[v++]=g:(g-=65536,y[v++]=55296|g>>10&1023,y[v++]=56320|1023&g)}return d(y,v)},o.utf8border=function(f,h){var m;for((h=h||f.length)>f.length&&(h=f.length),m=h-1;0<=m&&(192&f[m])==128;)m--;return m<0||m===0?h:m+c[f[m]]>h?m:h}},{"./common":41}],43:[function(n,r,o){r.exports=function(i,a,l,c){for(var u=65535&i|0,d=i>>>16&65535|0,f=0;l!==0;){for(l-=f=2e3<l?2e3:l;d=d+(u=u+a[c++]|0)|0,--f;);u%=65521,d%=65521}return u|d<<16|0}},{}],44:[function(n,r,o){r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,r,o){var i=(function(){for(var a,l=[],c=0;c<256;c++){a=c;for(var u=0;u<8;u++)a=1&a?3988292384^a>>>1:a>>>1;l[c]=a}return l})();r.exports=function(a,l,c,u){var d=i,f=u+c;a^=-1;for(var h=u;h<f;h++)a=a>>>8^d[255&(a^l[h])];return-1^a}},{}],46:[function(n,r,o){var i,a=n("../utils/common"),l=n("./trees"),c=n("./adler32"),u=n("./crc32"),d=n("./messages"),f=0,h=4,m=0,v=-2,g=-1,x=4,b=2,y=8,_=9,j=286,S=30,T=19,C=2*j+1,A=15,E=3,P=258,J=P+E+1,R=42,F=113,k=1,M=2,Y=3,D=4;function B(w,K){return w.msg=d[K],K}function U(w){return(w<<1)-(4<w?9:0)}function ie(w){for(var K=w.length;0<=--K;)w[K]=0}function W(w){var K=w.state,V=K.pending;V>w.avail_out&&(V=w.avail_out),V!==0&&(a.arraySet(w.output,K.pending_buf,K.pending_out,V,w.next_out),w.next_out+=V,K.pending_out+=V,w.total_out+=V,w.avail_out-=V,K.pending-=V,K.pending===0&&(K.pending_out=0))}function H(w,K){l._tr_flush_block(w,0<=w.block_start?w.block_start:-1,w.strstart-w.block_start,K),w.block_start=w.strstart,W(w.strm)}function ue(w,K){w.pending_buf[w.pending++]=K}function ne(w,K){w.pending_buf[w.pending++]=K>>>8&255,w.pending_buf[w.pending++]=255&K}function se(w,K){var V,z,I=w.max_chain_length,$=w.strstart,ee=w.prev_length,oe=w.nice_match,Z=w.strstart>w.w_size-J?w.strstart-(w.w_size-J):0,te=w.window,O=w.w_mask,L=w.prev,Q=w.strstart+P,fe=te[$+ee-1],xe=te[$+ee];w.prev_length>=w.good_match&&(I>>=2),oe>w.lookahead&&(oe=w.lookahead);do if(te[(V=K)+ee]===xe&&te[V+ee-1]===fe&&te[V]===te[$]&&te[++V]===te[$+1]){$+=2,V++;do;while(te[++$]===te[++V]&&te[++$]===te[++V]&&te[++$]===te[++V]&&te[++$]===te[++V]&&te[++$]===te[++V]&&te[++$]===te[++V]&&te[++$]===te[++V]&&te[++$]===te[++V]&&$<Q);if(z=P-(Q-$),$=Q-P,ee<z){if(w.match_start=K,oe<=(ee=z))break;fe=te[$+ee-1],xe=te[$+ee]}}while((K=L[K&O])>Z&&--I!=0);return ee<=w.lookahead?ee:w.lookahead}function je(w){var K,V,z,I,$,ee,oe,Z,te,O,L=w.w_size;do{if(I=w.window_size-w.lookahead-w.strstart,w.strstart>=L+(L-J)){for(a.arraySet(w.window,w.window,L,L,0),w.match_start-=L,w.strstart-=L,w.block_start-=L,K=V=w.hash_size;z=w.head[--K],w.head[K]=L<=z?z-L:0,--V;);for(K=V=L;z=w.prev[--K],w.prev[K]=L<=z?z-L:0,--V;);I+=L}if(w.strm.avail_in===0)break;if(ee=w.strm,oe=w.window,Z=w.strstart+w.lookahead,te=I,O=void 0,O=ee.avail_in,te<O&&(O=te),V=O===0?0:(ee.avail_in-=O,a.arraySet(oe,ee.input,ee.next_in,O,Z),ee.state.wrap===1?ee.adler=c(ee.adler,oe,O,Z):ee.state.wrap===2&&(ee.adler=u(ee.adler,oe,O,Z)),ee.next_in+=O,ee.total_in+=O,O),w.lookahead+=V,w.lookahead+w.insert>=E)for($=w.strstart-w.insert,w.ins_h=w.window[$],w.ins_h=(w.ins_h<<w.hash_shift^w.window[$+1])&w.hash_mask;w.insert&&(w.ins_h=(w.ins_h<<w.hash_shift^w.window[$+E-1])&w.hash_mask,w.prev[$&w.w_mask]=w.head[w.ins_h],w.head[w.ins_h]=$,$++,w.insert--,!(w.lookahead+w.insert<E)););}while(w.lookahead<J&&w.strm.avail_in!==0)}function ce(w,K){for(var V,z;;){if(w.lookahead<J){if(je(w),w.lookahead<J&&K===f)return k;if(w.lookahead===0)break}if(V=0,w.lookahead>=E&&(w.ins_h=(w.ins_h<<w.hash_shift^w.window[w.strstart+E-1])&w.hash_mask,V=w.prev[w.strstart&w.w_mask]=w.head[w.ins_h],w.head[w.ins_h]=w.strstart),V!==0&&w.strstart-V<=w.w_size-J&&(w.match_length=se(w,V)),w.match_length>=E)if(z=l._tr_tally(w,w.strstart-w.match_start,w.match_length-E),w.lookahead-=w.match_length,w.match_length<=w.max_lazy_match&&w.lookahead>=E){for(w.match_length--;w.strstart++,w.ins_h=(w.ins_h<<w.hash_shift^w.window[w.strstart+E-1])&w.hash_mask,V=w.prev[w.strstart&w.w_mask]=w.head[w.ins_h],w.head[w.ins_h]=w.strstart,--w.match_length!=0;);w.strstart++}else w.strstart+=w.match_length,w.match_length=0,w.ins_h=w.window[w.strstart],w.ins_h=(w.ins_h<<w.hash_shift^w.window[w.strstart+1])&w.hash_mask;else z=l._tr_tally(w,0,w.window[w.strstart]),w.lookahead--,w.strstart++;if(z&&(H(w,!1),w.strm.avail_out===0))return k}return w.insert=w.strstart<E-1?w.strstart:E-1,K===h?(H(w,!0),w.strm.avail_out===0?Y:D):w.last_lit&&(H(w,!1),w.strm.avail_out===0)?k:M}function me(w,K){for(var V,z,I;;){if(w.lookahead<J){if(je(w),w.lookahead<J&&K===f)return k;if(w.lookahead===0)break}if(V=0,w.lookahead>=E&&(w.ins_h=(w.ins_h<<w.hash_shift^w.window[w.strstart+E-1])&w.hash_mask,V=w.prev[w.strstart&w.w_mask]=w.head[w.ins_h],w.head[w.ins_h]=w.strstart),w.prev_length=w.match_length,w.prev_match=w.match_start,w.match_length=E-1,V!==0&&w.prev_length<w.max_lazy_match&&w.strstart-V<=w.w_size-J&&(w.match_length=se(w,V),w.match_length<=5&&(w.strategy===1||w.match_length===E&&4096<w.strstart-w.match_start)&&(w.match_length=E-1)),w.prev_length>=E&&w.match_length<=w.prev_length){for(I=w.strstart+w.lookahead-E,z=l._tr_tally(w,w.strstart-1-w.prev_match,w.prev_length-E),w.lookahead-=w.prev_length-1,w.prev_length-=2;++w.strstart<=I&&(w.ins_h=(w.ins_h<<w.hash_shift^w.window[w.strstart+E-1])&w.hash_mask,V=w.prev[w.strstart&w.w_mask]=w.head[w.ins_h],w.head[w.ins_h]=w.strstart),--w.prev_length!=0;);if(w.match_available=0,w.match_length=E-1,w.strstart++,z&&(H(w,!1),w.strm.avail_out===0))return k}else if(w.match_available){if((z=l._tr_tally(w,0,w.window[w.strstart-1]))&&H(w,!1),w.strstart++,w.lookahead--,w.strm.avail_out===0)return k}else w.match_available=1,w.strstart++,w.lookahead--}return w.match_available&&(z=l._tr_tally(w,0,w.window[w.strstart-1]),w.match_available=0),w.insert=w.strstart<E-1?w.strstart:E-1,K===h?(H(w,!0),w.strm.avail_out===0?Y:D):w.last_lit&&(H(w,!1),w.strm.avail_out===0)?k:M}function le(w,K,V,z,I){this.good_length=w,this.max_lazy=K,this.nice_length=V,this.max_chain=z,this.func=I}function ae(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=y,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new a.Buf16(2*C),this.dyn_dtree=new a.Buf16(2*(2*S+1)),this.bl_tree=new a.Buf16(2*(2*T+1)),ie(this.dyn_ltree),ie(this.dyn_dtree),ie(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new a.Buf16(A+1),this.heap=new a.Buf16(2*j+1),ie(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*j+1),ie(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function re(w){var K;return w&&w.state?(w.total_in=w.total_out=0,w.data_type=b,(K=w.state).pending=0,K.pending_out=0,K.wrap<0&&(K.wrap=-K.wrap),K.status=K.wrap?R:F,w.adler=K.wrap===2?0:1,K.last_flush=f,l._tr_init(K),m):B(w,v)}function pe(w){var K=re(w);return K===m&&(function(V){V.window_size=2*V.w_size,ie(V.head),V.max_lazy_match=i[V.level].max_lazy,V.good_match=i[V.level].good_length,V.nice_match=i[V.level].nice_length,V.max_chain_length=i[V.level].max_chain,V.strstart=0,V.block_start=0,V.lookahead=0,V.insert=0,V.match_length=V.prev_length=E-1,V.match_available=0,V.ins_h=0})(w.state),K}function ye(w,K,V,z,I,$){if(!w)return v;var ee=1;if(K===g&&(K=6),z<0?(ee=0,z=-z):15<z&&(ee=2,z-=16),I<1||_<I||V!==y||z<8||15<z||K<0||9<K||$<0||x<$)return B(w,v);z===8&&(z=9);var oe=new ae;return(w.state=oe).strm=w,oe.wrap=ee,oe.gzhead=null,oe.w_bits=z,oe.w_size=1<<oe.w_bits,oe.w_mask=oe.w_size-1,oe.hash_bits=I+7,oe.hash_size=1<<oe.hash_bits,oe.hash_mask=oe.hash_size-1,oe.hash_shift=~~((oe.hash_bits+E-1)/E),oe.window=new a.Buf8(2*oe.w_size),oe.head=new a.Buf16(oe.hash_size),oe.prev=new a.Buf16(oe.w_size),oe.lit_bufsize=1<<I+6,oe.pending_buf_size=4*oe.lit_bufsize,oe.pending_buf=new a.Buf8(oe.pending_buf_size),oe.d_buf=1*oe.lit_bufsize,oe.l_buf=3*oe.lit_bufsize,oe.level=K,oe.strategy=$,oe.method=V,pe(w)}i=[new le(0,0,0,0,function(w,K){var V=65535;for(V>w.pending_buf_size-5&&(V=w.pending_buf_size-5);;){if(w.lookahead<=1){if(je(w),w.lookahead===0&&K===f)return k;if(w.lookahead===0)break}w.strstart+=w.lookahead,w.lookahead=0;var z=w.block_start+V;if((w.strstart===0||w.strstart>=z)&&(w.lookahead=w.strstart-z,w.strstart=z,H(w,!1),w.strm.avail_out===0)||w.strstart-w.block_start>=w.w_size-J&&(H(w,!1),w.strm.avail_out===0))return k}return w.insert=0,K===h?(H(w,!0),w.strm.avail_out===0?Y:D):(w.strstart>w.block_start&&(H(w,!1),w.strm.avail_out),k)}),new le(4,4,8,4,ce),new le(4,5,16,8,ce),new le(4,6,32,32,ce),new le(4,4,16,16,me),new le(8,16,32,32,me),new le(8,16,128,128,me),new le(8,32,128,256,me),new le(32,128,258,1024,me),new le(32,258,258,4096,me)],o.deflateInit=function(w,K){return ye(w,K,y,15,8,0)},o.deflateInit2=ye,o.deflateReset=pe,o.deflateResetKeep=re,o.deflateSetHeader=function(w,K){return w&&w.state?w.state.wrap!==2?v:(w.state.gzhead=K,m):v},o.deflate=function(w,K){var V,z,I,$;if(!w||!w.state||5<K||K<0)return w?B(w,v):v;if(z=w.state,!w.output||!w.input&&w.avail_in!==0||z.status===666&&K!==h)return B(w,w.avail_out===0?-5:v);if(z.strm=w,V=z.last_flush,z.last_flush=K,z.status===R)if(z.wrap===2)w.adler=0,ue(z,31),ue(z,139),ue(z,8),z.gzhead?(ue(z,(z.gzhead.text?1:0)+(z.gzhead.hcrc?2:0)+(z.gzhead.extra?4:0)+(z.gzhead.name?8:0)+(z.gzhead.comment?16:0)),ue(z,255&z.gzhead.time),ue(z,z.gzhead.time>>8&255),ue(z,z.gzhead.time>>16&255),ue(z,z.gzhead.time>>24&255),ue(z,z.level===9?2:2<=z.strategy||z.level<2?4:0),ue(z,255&z.gzhead.os),z.gzhead.extra&&z.gzhead.extra.length&&(ue(z,255&z.gzhead.extra.length),ue(z,z.gzhead.extra.length>>8&255)),z.gzhead.hcrc&&(w.adler=u(w.adler,z.pending_buf,z.pending,0)),z.gzindex=0,z.status=69):(ue(z,0),ue(z,0),ue(z,0),ue(z,0),ue(z,0),ue(z,z.level===9?2:2<=z.strategy||z.level<2?4:0),ue(z,3),z.status=F);else{var ee=y+(z.w_bits-8<<4)<<8;ee|=(2<=z.strategy||z.level<2?0:z.level<6?1:z.level===6?2:3)<<6,z.strstart!==0&&(ee|=32),ee+=31-ee%31,z.status=F,ne(z,ee),z.strstart!==0&&(ne(z,w.adler>>>16),ne(z,65535&w.adler)),w.adler=1}if(z.status===69)if(z.gzhead.extra){for(I=z.pending;z.gzindex<(65535&z.gzhead.extra.length)&&(z.pending!==z.pending_buf_size||(z.gzhead.hcrc&&z.pending>I&&(w.adler=u(w.adler,z.pending_buf,z.pending-I,I)),W(w),I=z.pending,z.pending!==z.pending_buf_size));)ue(z,255&z.gzhead.extra[z.gzindex]),z.gzindex++;z.gzhead.hcrc&&z.pending>I&&(w.adler=u(w.adler,z.pending_buf,z.pending-I,I)),z.gzindex===z.gzhead.extra.length&&(z.gzindex=0,z.status=73)}else z.status=73;if(z.status===73)if(z.gzhead.name){I=z.pending;do{if(z.pending===z.pending_buf_size&&(z.gzhead.hcrc&&z.pending>I&&(w.adler=u(w.adler,z.pending_buf,z.pending-I,I)),W(w),I=z.pending,z.pending===z.pending_buf_size)){$=1;break}$=z.gzindex<z.gzhead.name.length?255&z.gzhead.name.charCodeAt(z.gzindex++):0,ue(z,$)}while($!==0);z.gzhead.hcrc&&z.pending>I&&(w.adler=u(w.adler,z.pending_buf,z.pending-I,I)),$===0&&(z.gzindex=0,z.status=91)}else z.status=91;if(z.status===91)if(z.gzhead.comment){I=z.pending;do{if(z.pending===z.pending_buf_size&&(z.gzhead.hcrc&&z.pending>I&&(w.adler=u(w.adler,z.pending_buf,z.pending-I,I)),W(w),I=z.pending,z.pending===z.pending_buf_size)){$=1;break}$=z.gzindex<z.gzhead.comment.length?255&z.gzhead.comment.charCodeAt(z.gzindex++):0,ue(z,$)}while($!==0);z.gzhead.hcrc&&z.pending>I&&(w.adler=u(w.adler,z.pending_buf,z.pending-I,I)),$===0&&(z.status=103)}else z.status=103;if(z.status===103&&(z.gzhead.hcrc?(z.pending+2>z.pending_buf_size&&W(w),z.pending+2<=z.pending_buf_size&&(ue(z,255&w.adler),ue(z,w.adler>>8&255),w.adler=0,z.status=F)):z.status=F),z.pending!==0){if(W(w),w.avail_out===0)return z.last_flush=-1,m}else if(w.avail_in===0&&U(K)<=U(V)&&K!==h)return B(w,-5);if(z.status===666&&w.avail_in!==0)return B(w,-5);if(w.avail_in!==0||z.lookahead!==0||K!==f&&z.status!==666){var oe=z.strategy===2?(function(Z,te){for(var O;;){if(Z.lookahead===0&&(je(Z),Z.lookahead===0)){if(te===f)return k;break}if(Z.match_length=0,O=l._tr_tally(Z,0,Z.window[Z.strstart]),Z.lookahead--,Z.strstart++,O&&(H(Z,!1),Z.strm.avail_out===0))return k}return Z.insert=0,te===h?(H(Z,!0),Z.strm.avail_out===0?Y:D):Z.last_lit&&(H(Z,!1),Z.strm.avail_out===0)?k:M})(z,K):z.strategy===3?(function(Z,te){for(var O,L,Q,fe,xe=Z.window;;){if(Z.lookahead<=P){if(je(Z),Z.lookahead<=P&&te===f)return k;if(Z.lookahead===0)break}if(Z.match_length=0,Z.lookahead>=E&&0<Z.strstart&&(L=xe[Q=Z.strstart-1])===xe[++Q]&&L===xe[++Q]&&L===xe[++Q]){fe=Z.strstart+P;do;while(L===xe[++Q]&&L===xe[++Q]&&L===xe[++Q]&&L===xe[++Q]&&L===xe[++Q]&&L===xe[++Q]&&L===xe[++Q]&&L===xe[++Q]&&Q<fe);Z.match_length=P-(fe-Q),Z.match_length>Z.lookahead&&(Z.match_length=Z.lookahead)}if(Z.match_length>=E?(O=l._tr_tally(Z,1,Z.match_length-E),Z.lookahead-=Z.match_length,Z.strstart+=Z.match_length,Z.match_length=0):(O=l._tr_tally(Z,0,Z.window[Z.strstart]),Z.lookahead--,Z.strstart++),O&&(H(Z,!1),Z.strm.avail_out===0))return k}return Z.insert=0,te===h?(H(Z,!0),Z.strm.avail_out===0?Y:D):Z.last_lit&&(H(Z,!1),Z.strm.avail_out===0)?k:M})(z,K):i[z.level].func(z,K);if(oe!==Y&&oe!==D||(z.status=666),oe===k||oe===Y)return w.avail_out===0&&(z.last_flush=-1),m;if(oe===M&&(K===1?l._tr_align(z):K!==5&&(l._tr_stored_block(z,0,0,!1),K===3&&(ie(z.head),z.lookahead===0&&(z.strstart=0,z.block_start=0,z.insert=0))),W(w),w.avail_out===0))return z.last_flush=-1,m}return K!==h?m:z.wrap<=0?1:(z.wrap===2?(ue(z,255&w.adler),ue(z,w.adler>>8&255),ue(z,w.adler>>16&255),ue(z,w.adler>>24&255),ue(z,255&w.total_in),ue(z,w.total_in>>8&255),ue(z,w.total_in>>16&255),ue(z,w.total_in>>24&255)):(ne(z,w.adler>>>16),ne(z,65535&w.adler)),W(w),0<z.wrap&&(z.wrap=-z.wrap),z.pending!==0?m:1)},o.deflateEnd=function(w){var K;return w&&w.state?(K=w.state.status)!==R&&K!==69&&K!==73&&K!==91&&K!==103&&K!==F&&K!==666?B(w,v):(w.state=null,K===F?B(w,-3):m):v},o.deflateSetDictionary=function(w,K){var V,z,I,$,ee,oe,Z,te,O=K.length;if(!w||!w.state||($=(V=w.state).wrap)===2||$===1&&V.status!==R||V.lookahead)return v;for($===1&&(w.adler=c(w.adler,K,O,0)),V.wrap=0,O>=V.w_size&&($===0&&(ie(V.head),V.strstart=0,V.block_start=0,V.insert=0),te=new a.Buf8(V.w_size),a.arraySet(te,K,O-V.w_size,V.w_size,0),K=te,O=V.w_size),ee=w.avail_in,oe=w.next_in,Z=w.input,w.avail_in=O,w.next_in=0,w.input=K,je(V);V.lookahead>=E;){for(z=V.strstart,I=V.lookahead-(E-1);V.ins_h=(V.ins_h<<V.hash_shift^V.window[z+E-1])&V.hash_mask,V.prev[z&V.w_mask]=V.head[V.ins_h],V.head[V.ins_h]=z,z++,--I;);V.strstart=z,V.lookahead=E-1,je(V)}return V.strstart+=V.lookahead,V.block_start=V.strstart,V.insert=V.lookahead,V.lookahead=0,V.match_length=V.prev_length=E-1,V.match_available=0,w.next_in=oe,w.input=Z,w.avail_in=ee,V.wrap=$,m},o.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,o){r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,o){r.exports=function(i,a){var l,c,u,d,f,h,m,v,g,x,b,y,_,j,S,T,C,A,E,P,J,R,F,k,M;l=i.state,c=i.next_in,k=i.input,u=c+(i.avail_in-5),d=i.next_out,M=i.output,f=d-(a-i.avail_out),h=d+(i.avail_out-257),m=l.dmax,v=l.wsize,g=l.whave,x=l.wnext,b=l.window,y=l.hold,_=l.bits,j=l.lencode,S=l.distcode,T=(1<<l.lenbits)-1,C=(1<<l.distbits)-1;e:do{_<15&&(y+=k[c++]<<_,_+=8,y+=k[c++]<<_,_+=8),A=j[y&T];t:for(;;){if(y>>>=E=A>>>24,_-=E,(E=A>>>16&255)===0)M[d++]=65535&A;else{if(!(16&E)){if((64&E)==0){A=j[(65535&A)+(y&(1<<E)-1)];continue t}if(32&E){l.mode=12;break e}i.msg="invalid literal/length code",l.mode=30;break e}P=65535&A,(E&=15)&&(_<E&&(y+=k[c++]<<_,_+=8),P+=y&(1<<E)-1,y>>>=E,_-=E),_<15&&(y+=k[c++]<<_,_+=8,y+=k[c++]<<_,_+=8),A=S[y&C];n:for(;;){if(y>>>=E=A>>>24,_-=E,!(16&(E=A>>>16&255))){if((64&E)==0){A=S[(65535&A)+(y&(1<<E)-1)];continue n}i.msg="invalid distance code",l.mode=30;break e}if(J=65535&A,_<(E&=15)&&(y+=k[c++]<<_,(_+=8)<E&&(y+=k[c++]<<_,_+=8)),m<(J+=y&(1<<E)-1)){i.msg="invalid distance too far back",l.mode=30;break e}if(y>>>=E,_-=E,(E=d-f)<J){if(g<(E=J-E)&&l.sane){i.msg="invalid distance too far back",l.mode=30;break e}if(F=b,(R=0)===x){if(R+=v-E,E<P){for(P-=E;M[d++]=b[R++],--E;);R=d-J,F=M}}else if(x<E){if(R+=v+x-E,(E-=x)<P){for(P-=E;M[d++]=b[R++],--E;);if(R=0,x<P){for(P-=E=x;M[d++]=b[R++],--E;);R=d-J,F=M}}}else if(R+=x-E,E<P){for(P-=E;M[d++]=b[R++],--E;);R=d-J,F=M}for(;2<P;)M[d++]=F[R++],M[d++]=F[R++],M[d++]=F[R++],P-=3;P&&(M[d++]=F[R++],1<P&&(M[d++]=F[R++]))}else{for(R=d-J;M[d++]=M[R++],M[d++]=M[R++],M[d++]=M[R++],2<(P-=3););P&&(M[d++]=M[R++],1<P&&(M[d++]=M[R++]))}break}}break}}while(c<u&&d<h);c-=P=_>>3,y&=(1<<(_-=P<<3))-1,i.next_in=c,i.next_out=d,i.avail_in=c<u?u-c+5:5-(c-u),i.avail_out=d<h?h-d+257:257-(d-h),l.hold=y,l.bits=_}},{}],49:[function(n,r,o){var i=n("../utils/common"),a=n("./adler32"),l=n("./crc32"),c=n("./inffast"),u=n("./inftrees"),d=1,f=2,h=0,m=-2,v=1,g=852,x=592;function b(R){return(R>>>24&255)+(R>>>8&65280)+((65280&R)<<8)+((255&R)<<24)}function y(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new i.Buf16(320),this.work=new i.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function _(R){var F;return R&&R.state?(F=R.state,R.total_in=R.total_out=F.total=0,R.msg="",F.wrap&&(R.adler=1&F.wrap),F.mode=v,F.last=0,F.havedict=0,F.dmax=32768,F.head=null,F.hold=0,F.bits=0,F.lencode=F.lendyn=new i.Buf32(g),F.distcode=F.distdyn=new i.Buf32(x),F.sane=1,F.back=-1,h):m}function j(R){var F;return R&&R.state?((F=R.state).wsize=0,F.whave=0,F.wnext=0,_(R)):m}function S(R,F){var k,M;return R&&R.state?(M=R.state,F<0?(k=0,F=-F):(k=1+(F>>4),F<48&&(F&=15)),F&&(F<8||15<F)?m:(M.window!==null&&M.wbits!==F&&(M.window=null),M.wrap=k,M.wbits=F,j(R))):m}function T(R,F){var k,M;return R?(M=new y,(R.state=M).window=null,(k=S(R,F))!==h&&(R.state=null),k):m}var C,A,E=!0;function P(R){if(E){var F;for(C=new i.Buf32(512),A=new i.Buf32(32),F=0;F<144;)R.lens[F++]=8;for(;F<256;)R.lens[F++]=9;for(;F<280;)R.lens[F++]=7;for(;F<288;)R.lens[F++]=8;for(u(d,R.lens,0,288,C,0,R.work,{bits:9}),F=0;F<32;)R.lens[F++]=5;u(f,R.lens,0,32,A,0,R.work,{bits:5}),E=!1}R.lencode=C,R.lenbits=9,R.distcode=A,R.distbits=5}function J(R,F,k,M){var Y,D=R.state;return D.window===null&&(D.wsize=1<<D.wbits,D.wnext=0,D.whave=0,D.window=new i.Buf8(D.wsize)),M>=D.wsize?(i.arraySet(D.window,F,k-D.wsize,D.wsize,0),D.wnext=0,D.whave=D.wsize):(M<(Y=D.wsize-D.wnext)&&(Y=M),i.arraySet(D.window,F,k-M,Y,D.wnext),(M-=Y)?(i.arraySet(D.window,F,k-M,M,0),D.wnext=M,D.whave=D.wsize):(D.wnext+=Y,D.wnext===D.wsize&&(D.wnext=0),D.whave<D.wsize&&(D.whave+=Y))),0}o.inflateReset=j,o.inflateReset2=S,o.inflateResetKeep=_,o.inflateInit=function(R){return T(R,15)},o.inflateInit2=T,o.inflate=function(R,F){var k,M,Y,D,B,U,ie,W,H,ue,ne,se,je,ce,me,le,ae,re,pe,ye,w,K,V,z,I=0,$=new i.Buf8(4),ee=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!R||!R.state||!R.output||!R.input&&R.avail_in!==0)return m;(k=R.state).mode===12&&(k.mode=13),B=R.next_out,Y=R.output,ie=R.avail_out,D=R.next_in,M=R.input,U=R.avail_in,W=k.hold,H=k.bits,ue=U,ne=ie,K=h;e:for(;;)switch(k.mode){case v:if(k.wrap===0){k.mode=13;break}for(;H<16;){if(U===0)break e;U--,W+=M[D++]<<H,H+=8}if(2&k.wrap&&W===35615){$[k.check=0]=255&W,$[1]=W>>>8&255,k.check=l(k.check,$,2,0),H=W=0,k.mode=2;break}if(k.flags=0,k.head&&(k.head.done=!1),!(1&k.wrap)||(((255&W)<<8)+(W>>8))%31){R.msg="incorrect header check",k.mode=30;break}if((15&W)!=8){R.msg="unknown compression method",k.mode=30;break}if(H-=4,w=8+(15&(W>>>=4)),k.wbits===0)k.wbits=w;else if(w>k.wbits){R.msg="invalid window size",k.mode=30;break}k.dmax=1<<w,R.adler=k.check=1,k.mode=512&W?10:12,H=W=0;break;case 2:for(;H<16;){if(U===0)break e;U--,W+=M[D++]<<H,H+=8}if(k.flags=W,(255&k.flags)!=8){R.msg="unknown compression method",k.mode=30;break}if(57344&k.flags){R.msg="unknown header flags set",k.mode=30;break}k.head&&(k.head.text=W>>8&1),512&k.flags&&($[0]=255&W,$[1]=W>>>8&255,k.check=l(k.check,$,2,0)),H=W=0,k.mode=3;case 3:for(;H<32;){if(U===0)break e;U--,W+=M[D++]<<H,H+=8}k.head&&(k.head.time=W),512&k.flags&&($[0]=255&W,$[1]=W>>>8&255,$[2]=W>>>16&255,$[3]=W>>>24&255,k.check=l(k.check,$,4,0)),H=W=0,k.mode=4;case 4:for(;H<16;){if(U===0)break e;U--,W+=M[D++]<<H,H+=8}k.head&&(k.head.xflags=255&W,k.head.os=W>>8),512&k.flags&&($[0]=255&W,$[1]=W>>>8&255,k.check=l(k.check,$,2,0)),H=W=0,k.mode=5;case 5:if(1024&k.flags){for(;H<16;){if(U===0)break e;U--,W+=M[D++]<<H,H+=8}k.length=W,k.head&&(k.head.extra_len=W),512&k.flags&&($[0]=255&W,$[1]=W>>>8&255,k.check=l(k.check,$,2,0)),H=W=0}else k.head&&(k.head.extra=null);k.mode=6;case 6:if(1024&k.flags&&(U<(se=k.length)&&(se=U),se&&(k.head&&(w=k.head.extra_len-k.length,k.head.extra||(k.head.extra=new Array(k.head.extra_len)),i.arraySet(k.head.extra,M,D,se,w)),512&k.flags&&(k.check=l(k.check,M,se,D)),U-=se,D+=se,k.length-=se),k.length))break e;k.length=0,k.mode=7;case 7:if(2048&k.flags){if(U===0)break e;for(se=0;w=M[D+se++],k.head&&w&&k.length<65536&&(k.head.name+=String.fromCharCode(w)),w&&se<U;);if(512&k.flags&&(k.check=l(k.check,M,se,D)),U-=se,D+=se,w)break e}else k.head&&(k.head.name=null);k.length=0,k.mode=8;case 8:if(4096&k.flags){if(U===0)break e;for(se=0;w=M[D+se++],k.head&&w&&k.length<65536&&(k.head.comment+=String.fromCharCode(w)),w&&se<U;);if(512&k.flags&&(k.check=l(k.check,M,se,D)),U-=se,D+=se,w)break e}else k.head&&(k.head.comment=null);k.mode=9;case 9:if(512&k.flags){for(;H<16;){if(U===0)break e;U--,W+=M[D++]<<H,H+=8}if(W!==(65535&k.check)){R.msg="header crc mismatch",k.mode=30;break}H=W=0}k.head&&(k.head.hcrc=k.flags>>9&1,k.head.done=!0),R.adler=k.check=0,k.mode=12;break;case 10:for(;H<32;){if(U===0)break e;U--,W+=M[D++]<<H,H+=8}R.adler=k.check=b(W),H=W=0,k.mode=11;case 11:if(k.havedict===0)return R.next_out=B,R.avail_out=ie,R.next_in=D,R.avail_in=U,k.hold=W,k.bits=H,2;R.adler=k.check=1,k.mode=12;case 12:if(F===5||F===6)break e;case 13:if(k.last){W>>>=7&H,H-=7&H,k.mode=27;break}for(;H<3;){if(U===0)break e;U--,W+=M[D++]<<H,H+=8}switch(k.last=1&W,H-=1,3&(W>>>=1)){case 0:k.mode=14;break;case 1:if(P(k),k.mode=20,F!==6)break;W>>>=2,H-=2;break e;case 2:k.mode=17;break;case 3:R.msg="invalid block type",k.mode=30}W>>>=2,H-=2;break;case 14:for(W>>>=7&H,H-=7&H;H<32;){if(U===0)break e;U--,W+=M[D++]<<H,H+=8}if((65535&W)!=(W>>>16^65535)){R.msg="invalid stored block lengths",k.mode=30;break}if(k.length=65535&W,H=W=0,k.mode=15,F===6)break e;case 15:k.mode=16;case 16:if(se=k.length){if(U<se&&(se=U),ie<se&&(se=ie),se===0)break e;i.arraySet(Y,M,D,se,B),U-=se,D+=se,ie-=se,B+=se,k.length-=se;break}k.mode=12;break;case 17:for(;H<14;){if(U===0)break e;U--,W+=M[D++]<<H,H+=8}if(k.nlen=257+(31&W),W>>>=5,H-=5,k.ndist=1+(31&W),W>>>=5,H-=5,k.ncode=4+(15&W),W>>>=4,H-=4,286<k.nlen||30<k.ndist){R.msg="too many length or distance symbols",k.mode=30;break}k.have=0,k.mode=18;case 18:for(;k.have<k.ncode;){for(;H<3;){if(U===0)break e;U--,W+=M[D++]<<H,H+=8}k.lens[ee[k.have++]]=7&W,W>>>=3,H-=3}for(;k.have<19;)k.lens[ee[k.have++]]=0;if(k.lencode=k.lendyn,k.lenbits=7,V={bits:k.lenbits},K=u(0,k.lens,0,19,k.lencode,0,k.work,V),k.lenbits=V.bits,K){R.msg="invalid code lengths set",k.mode=30;break}k.have=0,k.mode=19;case 19:for(;k.have<k.nlen+k.ndist;){for(;le=(I=k.lencode[W&(1<<k.lenbits)-1])>>>16&255,ae=65535&I,!((me=I>>>24)<=H);){if(U===0)break e;U--,W+=M[D++]<<H,H+=8}if(ae<16)W>>>=me,H-=me,k.lens[k.have++]=ae;else{if(ae===16){for(z=me+2;H<z;){if(U===0)break e;U--,W+=M[D++]<<H,H+=8}if(W>>>=me,H-=me,k.have===0){R.msg="invalid bit length repeat",k.mode=30;break}w=k.lens[k.have-1],se=3+(3&W),W>>>=2,H-=2}else if(ae===17){for(z=me+3;H<z;){if(U===0)break e;U--,W+=M[D++]<<H,H+=8}H-=me,w=0,se=3+(7&(W>>>=me)),W>>>=3,H-=3}else{for(z=me+7;H<z;){if(U===0)break e;U--,W+=M[D++]<<H,H+=8}H-=me,w=0,se=11+(127&(W>>>=me)),W>>>=7,H-=7}if(k.have+se>k.nlen+k.ndist){R.msg="invalid bit length repeat",k.mode=30;break}for(;se--;)k.lens[k.have++]=w}}if(k.mode===30)break;if(k.lens[256]===0){R.msg="invalid code -- missing end-of-block",k.mode=30;break}if(k.lenbits=9,V={bits:k.lenbits},K=u(d,k.lens,0,k.nlen,k.lencode,0,k.work,V),k.lenbits=V.bits,K){R.msg="invalid literal/lengths set",k.mode=30;break}if(k.distbits=6,k.distcode=k.distdyn,V={bits:k.distbits},K=u(f,k.lens,k.nlen,k.ndist,k.distcode,0,k.work,V),k.distbits=V.bits,K){R.msg="invalid distances set",k.mode=30;break}if(k.mode=20,F===6)break e;case 20:k.mode=21;case 21:if(6<=U&&258<=ie){R.next_out=B,R.avail_out=ie,R.next_in=D,R.avail_in=U,k.hold=W,k.bits=H,c(R,ne),B=R.next_out,Y=R.output,ie=R.avail_out,D=R.next_in,M=R.input,U=R.avail_in,W=k.hold,H=k.bits,k.mode===12&&(k.back=-1);break}for(k.back=0;le=(I=k.lencode[W&(1<<k.lenbits)-1])>>>16&255,ae=65535&I,!((me=I>>>24)<=H);){if(U===0)break e;U--,W+=M[D++]<<H,H+=8}if(le&&(240&le)==0){for(re=me,pe=le,ye=ae;le=(I=k.lencode[ye+((W&(1<<re+pe)-1)>>re)])>>>16&255,ae=65535&I,!(re+(me=I>>>24)<=H);){if(U===0)break e;U--,W+=M[D++]<<H,H+=8}W>>>=re,H-=re,k.back+=re}if(W>>>=me,H-=me,k.back+=me,k.length=ae,le===0){k.mode=26;break}if(32&le){k.back=-1,k.mode=12;break}if(64&le){R.msg="invalid literal/length code",k.mode=30;break}k.extra=15&le,k.mode=22;case 22:if(k.extra){for(z=k.extra;H<z;){if(U===0)break e;U--,W+=M[D++]<<H,H+=8}k.length+=W&(1<<k.extra)-1,W>>>=k.extra,H-=k.extra,k.back+=k.extra}k.was=k.length,k.mode=23;case 23:for(;le=(I=k.distcode[W&(1<<k.distbits)-1])>>>16&255,ae=65535&I,!((me=I>>>24)<=H);){if(U===0)break e;U--,W+=M[D++]<<H,H+=8}if((240&le)==0){for(re=me,pe=le,ye=ae;le=(I=k.distcode[ye+((W&(1<<re+pe)-1)>>re)])>>>16&255,ae=65535&I,!(re+(me=I>>>24)<=H);){if(U===0)break e;U--,W+=M[D++]<<H,H+=8}W>>>=re,H-=re,k.back+=re}if(W>>>=me,H-=me,k.back+=me,64&le){R.msg="invalid distance code",k.mode=30;break}k.offset=ae,k.extra=15&le,k.mode=24;case 24:if(k.extra){for(z=k.extra;H<z;){if(U===0)break e;U--,W+=M[D++]<<H,H+=8}k.offset+=W&(1<<k.extra)-1,W>>>=k.extra,H-=k.extra,k.back+=k.extra}if(k.offset>k.dmax){R.msg="invalid distance too far back",k.mode=30;break}k.mode=25;case 25:if(ie===0)break e;if(se=ne-ie,k.offset>se){if((se=k.offset-se)>k.whave&&k.sane){R.msg="invalid distance too far back",k.mode=30;break}je=se>k.wnext?(se-=k.wnext,k.wsize-se):k.wnext-se,se>k.length&&(se=k.length),ce=k.window}else ce=Y,je=B-k.offset,se=k.length;for(ie<se&&(se=ie),ie-=se,k.length-=se;Y[B++]=ce[je++],--se;);k.length===0&&(k.mode=21);break;case 26:if(ie===0)break e;Y[B++]=k.length,ie--,k.mode=21;break;case 27:if(k.wrap){for(;H<32;){if(U===0)break e;U--,W|=M[D++]<<H,H+=8}if(ne-=ie,R.total_out+=ne,k.total+=ne,ne&&(R.adler=k.check=k.flags?l(k.check,Y,ne,B-ne):a(k.check,Y,ne,B-ne)),ne=ie,(k.flags?W:b(W))!==k.check){R.msg="incorrect data check",k.mode=30;break}H=W=0}k.mode=28;case 28:if(k.wrap&&k.flags){for(;H<32;){if(U===0)break e;U--,W+=M[D++]<<H,H+=8}if(W!==(4294967295&k.total)){R.msg="incorrect length check",k.mode=30;break}H=W=0}k.mode=29;case 29:K=1;break e;case 30:K=-3;break e;case 31:return-4;default:return m}return R.next_out=B,R.avail_out=ie,R.next_in=D,R.avail_in=U,k.hold=W,k.bits=H,(k.wsize||ne!==R.avail_out&&k.mode<30&&(k.mode<27||F!==4))&&J(R,R.output,R.next_out,ne-R.avail_out)?(k.mode=31,-4):(ue-=R.avail_in,ne-=R.avail_out,R.total_in+=ue,R.total_out+=ne,k.total+=ne,k.wrap&&ne&&(R.adler=k.check=k.flags?l(k.check,Y,ne,R.next_out-ne):a(k.check,Y,ne,R.next_out-ne)),R.data_type=k.bits+(k.last?64:0)+(k.mode===12?128:0)+(k.mode===20||k.mode===15?256:0),(ue==0&&ne===0||F===4)&&K===h&&(K=-5),K)},o.inflateEnd=function(R){if(!R||!R.state)return m;var F=R.state;return F.window&&(F.window=null),R.state=null,h},o.inflateGetHeader=function(R,F){var k;return R&&R.state?(2&(k=R.state).wrap)==0?m:((k.head=F).done=!1,h):m},o.inflateSetDictionary=function(R,F){var k,M=F.length;return R&&R.state?(k=R.state).wrap!==0&&k.mode!==11?m:k.mode===11&&a(1,F,M,0)!==k.check?-3:J(R,F,M,M)?(k.mode=31,-4):(k.havedict=1,h):m},o.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,o){var i=n("../utils/common"),a=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],l=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],u=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(d,f,h,m,v,g,x,b){var y,_,j,S,T,C,A,E,P,J=b.bits,R=0,F=0,k=0,M=0,Y=0,D=0,B=0,U=0,ie=0,W=0,H=null,ue=0,ne=new i.Buf16(16),se=new i.Buf16(16),je=null,ce=0;for(R=0;R<=15;R++)ne[R]=0;for(F=0;F<m;F++)ne[f[h+F]]++;for(Y=J,M=15;1<=M&&ne[M]===0;M--);if(M<Y&&(Y=M),M===0)return v[g++]=20971520,v[g++]=20971520,b.bits=1,0;for(k=1;k<M&&ne[k]===0;k++);for(Y<k&&(Y=k),R=U=1;R<=15;R++)if(U<<=1,(U-=ne[R])<0)return-1;if(0<U&&(d===0||M!==1))return-1;for(se[1]=0,R=1;R<15;R++)se[R+1]=se[R]+ne[R];for(F=0;F<m;F++)f[h+F]!==0&&(x[se[f[h+F]]++]=F);if(C=d===0?(H=je=x,19):d===1?(H=a,ue-=257,je=l,ce-=257,256):(H=c,je=u,-1),R=k,T=g,B=F=W=0,j=-1,S=(ie=1<<(D=Y))-1,d===1&&852<ie||d===2&&592<ie)return 1;for(;;){for(A=R-B,P=x[F]<C?(E=0,x[F]):x[F]>C?(E=je[ce+x[F]],H[ue+x[F]]):(E=96,0),y=1<<R-B,k=_=1<<D;v[T+(W>>B)+(_-=y)]=A<<24|E<<16|P|0,_!==0;);for(y=1<<R-1;W&y;)y>>=1;if(y!==0?(W&=y-1,W+=y):W=0,F++,--ne[R]==0){if(R===M)break;R=f[h+x[F]]}if(Y<R&&(W&S)!==j){for(B===0&&(B=Y),T+=k,U=1<<(D=R-B);D+B<M&&!((U-=ne[D+B])<=0);)D++,U<<=1;if(ie+=1<<D,d===1&&852<ie||d===2&&592<ie)return 1;v[j=W&S]=Y<<24|D<<16|T-g|0}}return W!==0&&(v[T+W]=R-B<<24|64<<16|0),b.bits=Y,0}},{"../utils/common":41}],51:[function(n,r,o){r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,o){var i=n("../utils/common"),a=0,l=1;function c(I){for(var $=I.length;0<=--$;)I[$]=0}var u=0,d=29,f=256,h=f+1+d,m=30,v=19,g=2*h+1,x=15,b=16,y=7,_=256,j=16,S=17,T=18,C=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],A=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],E=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],P=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],J=new Array(2*(h+2));c(J);var R=new Array(2*m);c(R);var F=new Array(512);c(F);var k=new Array(256);c(k);var M=new Array(d);c(M);var Y,D,B,U=new Array(m);function ie(I,$,ee,oe,Z){this.static_tree=I,this.extra_bits=$,this.extra_base=ee,this.elems=oe,this.max_length=Z,this.has_stree=I&&I.length}function W(I,$){this.dyn_tree=I,this.max_code=0,this.stat_desc=$}function H(I){return I<256?F[I]:F[256+(I>>>7)]}function ue(I,$){I.pending_buf[I.pending++]=255&$,I.pending_buf[I.pending++]=$>>>8&255}function ne(I,$,ee){I.bi_valid>b-ee?(I.bi_buf|=$<<I.bi_valid&65535,ue(I,I.bi_buf),I.bi_buf=$>>b-I.bi_valid,I.bi_valid+=ee-b):(I.bi_buf|=$<<I.bi_valid&65535,I.bi_valid+=ee)}function se(I,$,ee){ne(I,ee[2*$],ee[2*$+1])}function je(I,$){for(var ee=0;ee|=1&I,I>>>=1,ee<<=1,0<--$;);return ee>>>1}function ce(I,$,ee){var oe,Z,te=new Array(x+1),O=0;for(oe=1;oe<=x;oe++)te[oe]=O=O+ee[oe-1]<<1;for(Z=0;Z<=$;Z++){var L=I[2*Z+1];L!==0&&(I[2*Z]=je(te[L]++,L))}}function me(I){var $;for($=0;$<h;$++)I.dyn_ltree[2*$]=0;for($=0;$<m;$++)I.dyn_dtree[2*$]=0;for($=0;$<v;$++)I.bl_tree[2*$]=0;I.dyn_ltree[2*_]=1,I.opt_len=I.static_len=0,I.last_lit=I.matches=0}function le(I){8<I.bi_valid?ue(I,I.bi_buf):0<I.bi_valid&&(I.pending_buf[I.pending++]=I.bi_buf),I.bi_buf=0,I.bi_valid=0}function ae(I,$,ee,oe){var Z=2*$,te=2*ee;return I[Z]<I[te]||I[Z]===I[te]&&oe[$]<=oe[ee]}function re(I,$,ee){for(var oe=I.heap[ee],Z=ee<<1;Z<=I.heap_len&&(Z<I.heap_len&&ae($,I.heap[Z+1],I.heap[Z],I.depth)&&Z++,!ae($,oe,I.heap[Z],I.depth));)I.heap[ee]=I.heap[Z],ee=Z,Z<<=1;I.heap[ee]=oe}function pe(I,$,ee){var oe,Z,te,O,L=0;if(I.last_lit!==0)for(;oe=I.pending_buf[I.d_buf+2*L]<<8|I.pending_buf[I.d_buf+2*L+1],Z=I.pending_buf[I.l_buf+L],L++,oe===0?se(I,Z,$):(se(I,(te=k[Z])+f+1,$),(O=C[te])!==0&&ne(I,Z-=M[te],O),se(I,te=H(--oe),ee),(O=A[te])!==0&&ne(I,oe-=U[te],O)),L<I.last_lit;);se(I,_,$)}function ye(I,$){var ee,oe,Z,te=$.dyn_tree,O=$.stat_desc.static_tree,L=$.stat_desc.has_stree,Q=$.stat_desc.elems,fe=-1;for(I.heap_len=0,I.heap_max=g,ee=0;ee<Q;ee++)te[2*ee]!==0?(I.heap[++I.heap_len]=fe=ee,I.depth[ee]=0):te[2*ee+1]=0;for(;I.heap_len<2;)te[2*(Z=I.heap[++I.heap_len]=fe<2?++fe:0)]=1,I.depth[Z]=0,I.opt_len--,L&&(I.static_len-=O[2*Z+1]);for($.max_code=fe,ee=I.heap_len>>1;1<=ee;ee--)re(I,te,ee);for(Z=Q;ee=I.heap[1],I.heap[1]=I.heap[I.heap_len--],re(I,te,1),oe=I.heap[1],I.heap[--I.heap_max]=ee,I.heap[--I.heap_max]=oe,te[2*Z]=te[2*ee]+te[2*oe],I.depth[Z]=(I.depth[ee]>=I.depth[oe]?I.depth[ee]:I.depth[oe])+1,te[2*ee+1]=te[2*oe+1]=Z,I.heap[1]=Z++,re(I,te,1),2<=I.heap_len;);I.heap[--I.heap_max]=I.heap[1],(function(xe,_e){var Pe,Se,ut,Ie,Vt,Oo,Lt=_e.dyn_tree,ml=_e.max_code,jm=_e.stat_desc.static_tree,Sm=_e.stat_desc.has_stree,Cm=_e.stat_desc.extra_bits,gl=_e.stat_desc.extra_base,or=_e.stat_desc.max_length,Wr=0;for(Ie=0;Ie<=x;Ie++)xe.bl_count[Ie]=0;for(Lt[2*xe.heap[xe.heap_max]+1]=0,Pe=xe.heap_max+1;Pe<g;Pe++)or<(Ie=Lt[2*Lt[2*(Se=xe.heap[Pe])+1]+1]+1)&&(Ie=or,Wr++),Lt[2*Se+1]=Ie,ml<Se||(xe.bl_count[Ie]++,Vt=0,gl<=Se&&(Vt=Cm[Se-gl]),Oo=Lt[2*Se],xe.opt_len+=Oo*(Ie+Vt),Sm&&(xe.static_len+=Oo*(jm[2*Se+1]+Vt)));if(Wr!==0){do{for(Ie=or-1;xe.bl_count[Ie]===0;)Ie--;xe.bl_count[Ie]--,xe.bl_count[Ie+1]+=2,xe.bl_count[or]--,Wr-=2}while(0<Wr);for(Ie=or;Ie!==0;Ie--)for(Se=xe.bl_count[Ie];Se!==0;)ml<(ut=xe.heap[--Pe])||(Lt[2*ut+1]!==Ie&&(xe.opt_len+=(Ie-Lt[2*ut+1])*Lt[2*ut],Lt[2*ut+1]=Ie),Se--)}})(I,$),ce(te,fe,I.bl_count)}function w(I,$,ee){var oe,Z,te=-1,O=$[1],L=0,Q=7,fe=4;for(O===0&&(Q=138,fe=3),$[2*(ee+1)+1]=65535,oe=0;oe<=ee;oe++)Z=O,O=$[2*(oe+1)+1],++L<Q&&Z===O||(L<fe?I.bl_tree[2*Z]+=L:Z!==0?(Z!==te&&I.bl_tree[2*Z]++,I.bl_tree[2*j]++):L<=10?I.bl_tree[2*S]++:I.bl_tree[2*T]++,te=Z,fe=(L=0)===O?(Q=138,3):Z===O?(Q=6,3):(Q=7,4))}function K(I,$,ee){var oe,Z,te=-1,O=$[1],L=0,Q=7,fe=4;for(O===0&&(Q=138,fe=3),oe=0;oe<=ee;oe++)if(Z=O,O=$[2*(oe+1)+1],!(++L<Q&&Z===O)){if(L<fe)for(;se(I,Z,I.bl_tree),--L!=0;);else Z!==0?(Z!==te&&(se(I,Z,I.bl_tree),L--),se(I,j,I.bl_tree),ne(I,L-3,2)):L<=10?(se(I,S,I.bl_tree),ne(I,L-3,3)):(se(I,T,I.bl_tree),ne(I,L-11,7));te=Z,fe=(L=0)===O?(Q=138,3):Z===O?(Q=6,3):(Q=7,4)}}c(U);var V=!1;function z(I,$,ee,oe){ne(I,(u<<1)+(oe?1:0),3),(function(Z,te,O,L){le(Z),ue(Z,O),ue(Z,~O),i.arraySet(Z.pending_buf,Z.window,te,O,Z.pending),Z.pending+=O})(I,$,ee)}o._tr_init=function(I){V||((function(){var $,ee,oe,Z,te,O=new Array(x+1);for(Z=oe=0;Z<d-1;Z++)for(M[Z]=oe,$=0;$<1<<C[Z];$++)k[oe++]=Z;for(k[oe-1]=Z,Z=te=0;Z<16;Z++)for(U[Z]=te,$=0;$<1<<A[Z];$++)F[te++]=Z;for(te>>=7;Z<m;Z++)for(U[Z]=te<<7,$=0;$<1<<A[Z]-7;$++)F[256+te++]=Z;for(ee=0;ee<=x;ee++)O[ee]=0;for($=0;$<=143;)J[2*$+1]=8,$++,O[8]++;for(;$<=255;)J[2*$+1]=9,$++,O[9]++;for(;$<=279;)J[2*$+1]=7,$++,O[7]++;for(;$<=287;)J[2*$+1]=8,$++,O[8]++;for(ce(J,h+1,O),$=0;$<m;$++)R[2*$+1]=5,R[2*$]=je($,5);Y=new ie(J,C,f+1,h,x),D=new ie(R,A,0,m,x),B=new ie(new Array(0),E,0,v,y)})(),V=!0),I.l_desc=new W(I.dyn_ltree,Y),I.d_desc=new W(I.dyn_dtree,D),I.bl_desc=new W(I.bl_tree,B),I.bi_buf=0,I.bi_valid=0,me(I)},o._tr_stored_block=z,o._tr_flush_block=function(I,$,ee,oe){var Z,te,O=0;0<I.level?(I.strm.data_type===2&&(I.strm.data_type=(function(L){var Q,fe=4093624447;for(Q=0;Q<=31;Q++,fe>>>=1)if(1&fe&&L.dyn_ltree[2*Q]!==0)return a;if(L.dyn_ltree[18]!==0||L.dyn_ltree[20]!==0||L.dyn_ltree[26]!==0)return l;for(Q=32;Q<f;Q++)if(L.dyn_ltree[2*Q]!==0)return l;return a})(I)),ye(I,I.l_desc),ye(I,I.d_desc),O=(function(L){var Q;for(w(L,L.dyn_ltree,L.l_desc.max_code),w(L,L.dyn_dtree,L.d_desc.max_code),ye(L,L.bl_desc),Q=v-1;3<=Q&&L.bl_tree[2*P[Q]+1]===0;Q--);return L.opt_len+=3*(Q+1)+5+5+4,Q})(I),Z=I.opt_len+3+7>>>3,(te=I.static_len+3+7>>>3)<=Z&&(Z=te)):Z=te=ee+5,ee+4<=Z&&$!==-1?z(I,$,ee,oe):I.strategy===4||te===Z?(ne(I,2+(oe?1:0),3),pe(I,J,R)):(ne(I,4+(oe?1:0),3),(function(L,Q,fe,xe){var _e;for(ne(L,Q-257,5),ne(L,fe-1,5),ne(L,xe-4,4),_e=0;_e<xe;_e++)ne(L,L.bl_tree[2*P[_e]+1],3);K(L,L.dyn_ltree,Q-1),K(L,L.dyn_dtree,fe-1)})(I,I.l_desc.max_code+1,I.d_desc.max_code+1,O+1),pe(I,I.dyn_ltree,I.dyn_dtree)),me(I),oe&&le(I)},o._tr_tally=function(I,$,ee){return I.pending_buf[I.d_buf+2*I.last_lit]=$>>>8&255,I.pending_buf[I.d_buf+2*I.last_lit+1]=255&$,I.pending_buf[I.l_buf+I.last_lit]=255&ee,I.last_lit++,$===0?I.dyn_ltree[2*ee]++:(I.matches++,$--,I.dyn_ltree[2*(k[ee]+f+1)]++,I.dyn_dtree[2*H($)]++),I.last_lit===I.lit_bufsize-1},o._tr_align=function(I){ne(I,2,3),se(I,_,J),(function($){$.bi_valid===16?(ue($,$.bi_buf),$.bi_buf=0,$.bi_valid=0):8<=$.bi_valid&&($.pending_buf[$.pending++]=255&$.bi_buf,$.bi_buf>>=8,$.bi_valid-=8)})(I)}},{"../utils/common":41}],53:[function(n,r,o){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,o){(function(i){(function(a,l){if(!a.setImmediate){var c,u,d,f,h=1,m={},v=!1,g=a.document,x=Object.getPrototypeOf&&Object.getPrototypeOf(a);x=x&&x.setTimeout?x:a,c={}.toString.call(a.process)==="[object process]"?function(j){process.nextTick(function(){y(j)})}:(function(){if(a.postMessage&&!a.importScripts){var j=!0,S=a.onmessage;return a.onmessage=function(){j=!1},a.postMessage("","*"),a.onmessage=S,j}})()?(f="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",_,!1):a.attachEvent("onmessage",_),function(j){a.postMessage(f+j,"*")}):a.MessageChannel?((d=new MessageChannel).port1.onmessage=function(j){y(j.data)},function(j){d.port2.postMessage(j)}):g&&"onreadystatechange"in g.createElement("script")?(u=g.documentElement,function(j){var S=g.createElement("script");S.onreadystatechange=function(){y(j),S.onreadystatechange=null,u.removeChild(S),S=null},u.appendChild(S)}):function(j){setTimeout(y,0,j)},x.setImmediate=function(j){typeof j!="function"&&(j=new Function(""+j));for(var S=new Array(arguments.length-1),T=0;T<S.length;T++)S[T]=arguments[T+1];var C={callback:j,args:S};return m[h]=C,c(h),h++},x.clearImmediate=b}function b(j){delete m[j]}function y(j){if(v)setTimeout(y,0,j);else{var S=m[j];if(S){v=!0;try{(function(T){var C=T.callback,A=T.args;switch(A.length){case 0:C();break;case 1:C(A[0]);break;case 2:C(A[0],A[1]);break;case 3:C(A[0],A[1],A[2]);break;default:C.apply(l,A)}})(S)}finally{b(j),v=!1}}}}function _(j){j.source===a&&typeof j.data=="string"&&j.data.indexOf(f)===0&&y(+j.data.slice(f.length))}})(typeof self>"u"?i===void 0?this:i:self)}).call(this,typeof Hr<"u"?Hr:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Lo)),Lo.exports}var z2=I2();const O2=Nm(z2),P2="2.1.15",ki={version:P2},Dd="[REDACTED]",M2=/(^|[-_])(api[-_]?key|authorization|cookie|token|secret|password|access[-_]?token|refresh[-_]?token)([-_]|$)/i,L2=[/Bearer\s+[A-Za-z0-9._~+/=-]{12,}/gi,/\bsk-[A-Za-z0-9_-]{12,}\b/g,/\bsk-ant-[A-Za-z0-9_-]{12,}\b/g,/\bghp_[A-Za-z0-9_]{12,}\b/g,/\bglpat-[A-Za-z0-9_-]{12,}\b/g],Hl=200,D2=25e6,$d=50;function $2(e){return e<1024?`${e} chars`:e<1024*1024?`${Math.ceil(e/1024)} KB`:`${Math.ceil(e/(1024*1024))} MB`}function F2(e){let t=0;for(const n of e)t+=n.rawRequestBody?.length??0,t+=n.responseText?.length??0;return t}function B2(e){if(e.length>Hl)return`Export is limited to ${Hl} logs at once. Narrow the filter and try again.`;const t=F2(e);return t>D2?`Export is too large (${$2(t)} of text). Narrow the filter and try again.`:null}async function U2(e){try{const t=await fetch(`/api/logs/${e}/chunks`);if(!t.ok)return null;const n=await t.json();return JSON.stringify(n,null,2)}catch{return null}}function W2(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function _i(e){if(Array.isArray(e))return e.map(n=>_i(n));if(!W2(e))return e;const t={};for(const[n,r]of Object.entries(e))t[n]=M2.test(n)?Dd:_i(r);return t}function H2(e){const t=n=>{let r=n;for(const o of L2)r=r.replace(o,Dd);return r};try{const n=JSON.parse(e);return t(JSON.stringify(_i(n),null,2))}catch{return t(e)}}function Do(e,t){return t==="redacted"?H2(e):e}function Z2(e,t){return{...e,rawRequestBody:null,responseText:null,rawHeaders:t==="raw"?e.rawHeaders:void 0,headers:t==="raw"?e.headers:void 0,streamingChunks:void 0,bodyContentMode:"compact"}}function V2(e,t,n,r=new Date().toISOString()){return{version:ki.version,exportedAt:r,mode:t,redacted:t==="redacted",logCount:e.length,logIds:e.map(o=>o.id),streamingChunkExportLimit:$d,streamingChunkLogIds:n.map(o=>o.id)}}async function q2(e,t="redacted"){const n=B2(e);if(n!==null)return{ok:!1,message:n};const r=new O2,o=t==="redacted"?"redacted":"raw",i=e.filter(u=>u.streaming).slice(0,$d);r.file("manifest.json",JSON.stringify(V2(e,t,i),null,2)),r.file("logs.json",JSON.stringify(e.map(u=>Z2(u,t)),null,2));for(const u of e)u.rawRequestBody!==null&&r.file(`#${u.id}.Request.json`,Do(u.rawRequestBody,t)),u.responseText!==null&&r.file(`#${u.id}.Response.json`,Do(u.responseText,t));for(const u of i){const d=await U2(u.id);d!==null&&r.file(`#${u.id}.SSE.Response.json`,Do(d,t))}const a=await r.generateAsync({type:"blob"}),l=URL.createObjectURL(a),c=document.createElement("a");return c.href=l,c.download=`agent-inspector-export-${o}-${new Date().toISOString().slice(0,10)}.zip`,document.body.appendChild(c),c.click(),document.body.removeChild(c),URL.revokeObjectURL(l),{ok:!0}}function G2(e,t){if(e!==null){e.removeAllRanges();for(const n of t)e.addRange(n)}}function K2(e){if(e===null)return[];const t=[];for(let n=0;n<e.rangeCount;n++)t.push(e.getRangeAt(n));return t}function J2(e){if(typeof document>"u")return!1;const t=document.activeElement,n=document.getSelection(),r=K2(n),o=document.createElement("textarea");o.value=e,o.setAttribute("readonly",""),o.style.position="fixed",o.style.top="0",o.style.left="-9999px",o.style.opacity="0",document.body.appendChild(o),o.focus(),o.select(),o.setSelectionRange(0,e.length);let i=!1;try{i=document.execCommand("copy")}catch{}finally{document.body.removeChild(o),G2(n,r),typeof HTMLElement<"u"&&t instanceof HTMLElement&&t.focus({preventScroll:!0})}return i}async function Ht(e){const t=globalThis.navigator?.clipboard;if(t!==void 0)try{return await t.writeText(e),!0}catch{}return J2(e)}function ji(e,t){switch(t){case"full":return e;case"time":return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}}function Ea(e,t,n){return`${ji(e,n)} - ${ji(t,n)}`}function Fd(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=Fd(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Bd(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=Fd(e))&&(r&&(r+=" "),r+=t);return r}const Y2=(e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},X2=(e,t)=>({classGroupId:e,validator:t}),Ud=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Os="-",Zl=[],Q2="arbitrary..",ew=e=>{const t=nw(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:a=>{if(a.startsWith("[")&&a.endsWith("]"))return tw(a);const l=a.split(Os),c=l[0]===""&&l.length>1?1:0;return Wd(l,c,t)},getConflictingClassGroupIds:(a,l)=>{if(l){const c=r[a],u=n[a];return c?u?Y2(u,c):c:u||Zl}return n[a]||Zl}}},Wd=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const o=e[t],i=n.nextPart.get(o);if(i){const u=Wd(e,t+1,i);if(u)return u}const a=n.validators;if(a===null)return;const l=t===0?e.join(Os):e.slice(t).join(Os),c=a.length;for(let u=0;u<c;u++){const d=a[u];if(d.validator(l))return d.classGroupId}},tw=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?Q2+r:void 0})(),nw=e=>{const{theme:t,classGroups:n}=e;return rw(n,t)},rw=(e,t)=>{const n=Ud();for(const r in e){const o=e[r];Aa(o,n,r,t)}return n},Aa=(e,t,n,r)=>{const o=e.length;for(let i=0;i<o;i++){const a=e[i];sw(a,t,n,r)}},sw=(e,t,n,r)=>{if(typeof e=="string"){ow(e,t,n);return}if(typeof e=="function"){iw(e,t,n,r);return}aw(e,t,n,r)},ow=(e,t,n)=>{const r=e===""?t:Hd(t,e);r.classGroupId=n},iw=(e,t,n,r)=>{if(lw(e)){Aa(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(X2(n,e))},aw=(e,t,n,r)=>{const o=Object.entries(e),i=o.length;for(let a=0;a<i;a++){const[l,c]=o[a];Aa(c,Hd(t,l),n,r)}},Hd=(e,t)=>{let n=e;const r=t.split(Os),o=r.length;for(let i=0;i<o;i++){const a=r[i];let l=n.nextPart.get(a);l||(l=Ud(),n.nextPart.set(a,l)),n=l}return n},lw=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,cw=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const o=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(i){let a=n[i];if(a!==void 0)return a;if((a=r[i])!==void 0)return o(i,a),a},set(i,a){i in n?n[i]=a:o(i,a)}}},Si="!",Vl=":",uw=[],ql=(e,t,n,r,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:o}),dw=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=o=>{const i=[];let a=0,l=0,c=0,u;const d=o.length;for(let g=0;g<d;g++){const x=o[g];if(a===0&&l===0){if(x===Vl){i.push(o.slice(c,g)),c=g+1;continue}if(x==="/"){u=g;continue}}x==="["?a++:x==="]"?a--:x==="("?l++:x===")"&&l--}const f=i.length===0?o:o.slice(c);let h=f,m=!1;f.endsWith(Si)?(h=f.slice(0,-1),m=!0):f.startsWith(Si)&&(h=f.slice(1),m=!0);const v=u&&u>c?u-c:void 0;return ql(i,m,h,v)};if(t){const o=t+Vl,i=r;r=a=>a.startsWith(o)?i(a.slice(o.length)):ql(uw,!1,a,void 0,!0)}if(n){const o=r;r=i=>n({className:i,parseClassName:o})}return r},fw=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];let o=[];for(let i=0;i<n.length;i++){const a=n[i],l=a[0]==="[",c=t.has(a);l||c?(o.length>0&&(o.sort(),r.push(...o),o=[]),r.push(a)):o.push(a)}return o.length>0&&(o.sort(),r.push(...o)),r}},pw=e=>({cache:cw(e.cacheSize),parseClassName:dw(e),sortModifiers:fw(e),...ew(e)}),hw=/\s+/,mw=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:i}=t,a=[],l=e.trim().split(hw);let c="";for(let u=l.length-1;u>=0;u-=1){const d=l[u],{isExternal:f,modifiers:h,hasImportantModifier:m,baseClassName:v,maybePostfixModifierPosition:g}=n(d);if(f){c=d+(c.length>0?" "+c:c);continue}let x=!!g,b=r(x?v.substring(0,g):v);if(!b){if(!x){c=d+(c.length>0?" "+c:c);continue}if(b=r(v),!b){c=d+(c.length>0?" "+c:c);continue}x=!1}const y=h.length===0?"":h.length===1?h[0]:i(h).join(":"),_=m?y+Si:y,j=_+b;if(a.indexOf(j)>-1)continue;a.push(j);const S=o(b,x);for(let T=0;T<S.length;++T){const C=S[T];a.push(_+C)}c=d+(c.length>0?" "+c:c)}return c},gw=(...e)=>{let t=0,n,r,o="";for(;t<e.length;)(n=e[t++])&&(r=Zd(n))&&(o&&(o+=" "),o+=r);return o},Zd=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=Zd(e[r]))&&(n&&(n+=" "),n+=t);return n},xw=(e,...t)=>{let n,r,o,i;const a=c=>{const u=t.reduce((d,f)=>f(d),e());return n=pw(u),r=n.cache.get,o=n.cache.set,i=l,l(c)},l=c=>{const u=r(c);if(u)return u;const d=mw(c,n);return o(c,d),d};return i=a,(...c)=>i(gw(...c))},bw=[],Ke=e=>{const t=n=>n[e]||bw;return t.isThemeGetter=!0,t},Vd=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,qd=/^\((?:(\w[\w-]*):)?(.+)\)$/i,vw=/^\d+\/\d+$/,yw=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,ww=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,kw=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,_w=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,jw=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Tn=e=>vw.test(e),Re=e=>!!e&&!Number.isNaN(Number(e)),qt=e=>!!e&&Number.isInteger(Number(e)),$o=e=>e.endsWith("%")&&Re(e.slice(0,-1)),Dt=e=>yw.test(e),Sw=()=>!0,Cw=e=>ww.test(e)&&!kw.test(e),Gd=()=>!1,Nw=e=>_w.test(e),Tw=e=>jw.test(e),Ew=e=>!be(e)&&!ve(e),Aw=e=>er(e,Yd,Gd),be=e=>Vd.test(e),dn=e=>er(e,Xd,Cw),Fo=e=>er(e,Pw,Re),Gl=e=>er(e,Kd,Gd),Rw=e=>er(e,Jd,Tw),Jr=e=>er(e,Qd,Nw),ve=e=>qd.test(e),ir=e=>tr(e,Xd),Iw=e=>tr(e,Mw),Kl=e=>tr(e,Kd),zw=e=>tr(e,Yd),Ow=e=>tr(e,Jd),Yr=e=>tr(e,Qd,!0),er=(e,t,n)=>{const r=Vd.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},tr=(e,t,n=!1)=>{const r=qd.exec(e);return r?r[1]?t(r[1]):n:!1},Kd=e=>e==="position"||e==="percentage",Jd=e=>e==="image"||e==="url",Yd=e=>e==="length"||e==="size"||e==="bg-size",Xd=e=>e==="length",Pw=e=>e==="number",Mw=e=>e==="family-name",Qd=e=>e==="shadow",Lw=()=>{const e=Ke("color"),t=Ke("font"),n=Ke("text"),r=Ke("font-weight"),o=Ke("tracking"),i=Ke("leading"),a=Ke("breakpoint"),l=Ke("container"),c=Ke("spacing"),u=Ke("radius"),d=Ke("shadow"),f=Ke("inset-shadow"),h=Ke("text-shadow"),m=Ke("drop-shadow"),v=Ke("blur"),g=Ke("perspective"),x=Ke("aspect"),b=Ke("ease"),y=Ke("animate"),_=()=>["auto","avoid","all","avoid-page","page","left","right","column"],j=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],S=()=>[...j(),ve,be],T=()=>["auto","hidden","clip","visible","scroll"],C=()=>["auto","contain","none"],A=()=>[ve,be,c],E=()=>[Tn,"full","auto",...A()],P=()=>[qt,"none","subgrid",ve,be],J=()=>["auto",{span:["full",qt,ve,be]},qt,ve,be],R=()=>[qt,"auto",ve,be],F=()=>["auto","min","max","fr",ve,be],k=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],M=()=>["start","end","center","stretch","center-safe","end-safe"],Y=()=>["auto",...A()],D=()=>[Tn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...A()],B=()=>[e,ve,be],U=()=>[...j(),Kl,Gl,{position:[ve,be]}],ie=()=>["no-repeat",{repeat:["","x","y","space","round"]}],W=()=>["auto","cover","contain",zw,Aw,{size:[ve,be]}],H=()=>[$o,ir,dn],ue=()=>["","none","full",u,ve,be],ne=()=>["",Re,ir,dn],se=()=>["solid","dashed","dotted","double"],je=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ce=()=>[Re,$o,Kl,Gl],me=()=>["","none",v,ve,be],le=()=>["none",Re,ve,be],ae=()=>["none",Re,ve,be],re=()=>[Re,ve,be],pe=()=>[Tn,"full",...A()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Dt],breakpoint:[Dt],color:[Sw],container:[Dt],"drop-shadow":[Dt],ease:["in","out","in-out"],font:[Ew],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Dt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Dt],shadow:[Dt],spacing:["px",Re],text:[Dt],"text-shadow":[Dt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Tn,be,ve,x]}],container:["container"],columns:[{columns:[Re,be,ve,l]}],"break-after":[{"break-after":_()}],"break-before":[{"break-before":_()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:S()}],overflow:[{overflow:T()}],"overflow-x":[{"overflow-x":T()}],"overflow-y":[{"overflow-y":T()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:E()}],"inset-x":[{"inset-x":E()}],"inset-y":[{"inset-y":E()}],start:[{start:E()}],end:[{end:E()}],top:[{top:E()}],right:[{right:E()}],bottom:[{bottom:E()}],left:[{left:E()}],visibility:["visible","invisible","collapse"],z:[{z:[qt,"auto",ve,be]}],basis:[{basis:[Tn,"full","auto",l,...A()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Re,Tn,"auto","initial","none",be]}],grow:[{grow:["",Re,ve,be]}],shrink:[{shrink:["",Re,ve,be]}],order:[{order:[qt,"first","last","none",ve,be]}],"grid-cols":[{"grid-cols":P()}],"col-start-end":[{col:J()}],"col-start":[{"col-start":R()}],"col-end":[{"col-end":R()}],"grid-rows":[{"grid-rows":P()}],"row-start-end":[{row:J()}],"row-start":[{"row-start":R()}],"row-end":[{"row-end":R()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":F()}],"auto-rows":[{"auto-rows":F()}],gap:[{gap:A()}],"gap-x":[{"gap-x":A()}],"gap-y":[{"gap-y":A()}],"justify-content":[{justify:[...k(),"normal"]}],"justify-items":[{"justify-items":[...M(),"normal"]}],"justify-self":[{"justify-self":["auto",...M()]}],"align-content":[{content:["normal",...k()]}],"align-items":[{items:[...M(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...M(),{baseline:["","last"]}]}],"place-content":[{"place-content":k()}],"place-items":[{"place-items":[...M(),"baseline"]}],"place-self":[{"place-self":["auto",...M()]}],p:[{p:A()}],px:[{px:A()}],py:[{py:A()}],ps:[{ps:A()}],pe:[{pe:A()}],pt:[{pt:A()}],pr:[{pr:A()}],pb:[{pb:A()}],pl:[{pl:A()}],m:[{m:Y()}],mx:[{mx:Y()}],my:[{my:Y()}],ms:[{ms:Y()}],me:[{me:Y()}],mt:[{mt:Y()}],mr:[{mr:Y()}],mb:[{mb:Y()}],ml:[{ml:Y()}],"space-x":[{"space-x":A()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":A()}],"space-y-reverse":["space-y-reverse"],size:[{size:D()}],w:[{w:[l,"screen",...D()]}],"min-w":[{"min-w":[l,"screen","none",...D()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[a]},...D()]}],h:[{h:["screen","lh",...D()]}],"min-h":[{"min-h":["screen","lh","none",...D()]}],"max-h":[{"max-h":["screen","lh",...D()]}],"font-size":[{text:["base",n,ir,dn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,ve,Fo]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",$o,be]}],"font-family":[{font:[Iw,be,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,ve,be]}],"line-clamp":[{"line-clamp":[Re,"none",ve,Fo]}],leading:[{leading:[i,...A()]}],"list-image":[{"list-image":["none",ve,be]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ve,be]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:B()}],"text-color":[{text:B()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...se(),"wavy"]}],"text-decoration-thickness":[{decoration:[Re,"from-font","auto",ve,dn]}],"text-decoration-color":[{decoration:B()}],"underline-offset":[{"underline-offset":[Re,"auto",ve,be]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:A()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ve,be]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ve,be]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:U()}],"bg-repeat":[{bg:ie()}],"bg-size":[{bg:W()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},qt,ve,be],radial:["",ve,be],conic:[qt,ve,be]},Ow,Rw]}],"bg-color":[{bg:B()}],"gradient-from-pos":[{from:H()}],"gradient-via-pos":[{via:H()}],"gradient-to-pos":[{to:H()}],"gradient-from":[{from:B()}],"gradient-via":[{via:B()}],"gradient-to":[{to:B()}],rounded:[{rounded:ue()}],"rounded-s":[{"rounded-s":ue()}],"rounded-e":[{"rounded-e":ue()}],"rounded-t":[{"rounded-t":ue()}],"rounded-r":[{"rounded-r":ue()}],"rounded-b":[{"rounded-b":ue()}],"rounded-l":[{"rounded-l":ue()}],"rounded-ss":[{"rounded-ss":ue()}],"rounded-se":[{"rounded-se":ue()}],"rounded-ee":[{"rounded-ee":ue()}],"rounded-es":[{"rounded-es":ue()}],"rounded-tl":[{"rounded-tl":ue()}],"rounded-tr":[{"rounded-tr":ue()}],"rounded-br":[{"rounded-br":ue()}],"rounded-bl":[{"rounded-bl":ue()}],"border-w":[{border:ne()}],"border-w-x":[{"border-x":ne()}],"border-w-y":[{"border-y":ne()}],"border-w-s":[{"border-s":ne()}],"border-w-e":[{"border-e":ne()}],"border-w-t":[{"border-t":ne()}],"border-w-r":[{"border-r":ne()}],"border-w-b":[{"border-b":ne()}],"border-w-l":[{"border-l":ne()}],"divide-x":[{"divide-x":ne()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ne()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...se(),"hidden","none"]}],"divide-style":[{divide:[...se(),"hidden","none"]}],"border-color":[{border:B()}],"border-color-x":[{"border-x":B()}],"border-color-y":[{"border-y":B()}],"border-color-s":[{"border-s":B()}],"border-color-e":[{"border-e":B()}],"border-color-t":[{"border-t":B()}],"border-color-r":[{"border-r":B()}],"border-color-b":[{"border-b":B()}],"border-color-l":[{"border-l":B()}],"divide-color":[{divide:B()}],"outline-style":[{outline:[...se(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Re,ve,be]}],"outline-w":[{outline:["",Re,ir,dn]}],"outline-color":[{outline:B()}],shadow:[{shadow:["","none",d,Yr,Jr]}],"shadow-color":[{shadow:B()}],"inset-shadow":[{"inset-shadow":["none",f,Yr,Jr]}],"inset-shadow-color":[{"inset-shadow":B()}],"ring-w":[{ring:ne()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:B()}],"ring-offset-w":[{"ring-offset":[Re,dn]}],"ring-offset-color":[{"ring-offset":B()}],"inset-ring-w":[{"inset-ring":ne()}],"inset-ring-color":[{"inset-ring":B()}],"text-shadow":[{"text-shadow":["none",h,Yr,Jr]}],"text-shadow-color":[{"text-shadow":B()}],opacity:[{opacity:[Re,ve,be]}],"mix-blend":[{"mix-blend":[...je(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":je()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Re]}],"mask-image-linear-from-pos":[{"mask-linear-from":ce()}],"mask-image-linear-to-pos":[{"mask-linear-to":ce()}],"mask-image-linear-from-color":[{"mask-linear-from":B()}],"mask-image-linear-to-color":[{"mask-linear-to":B()}],"mask-image-t-from-pos":[{"mask-t-from":ce()}],"mask-image-t-to-pos":[{"mask-t-to":ce()}],"mask-image-t-from-color":[{"mask-t-from":B()}],"mask-image-t-to-color":[{"mask-t-to":B()}],"mask-image-r-from-pos":[{"mask-r-from":ce()}],"mask-image-r-to-pos":[{"mask-r-to":ce()}],"mask-image-r-from-color":[{"mask-r-from":B()}],"mask-image-r-to-color":[{"mask-r-to":B()}],"mask-image-b-from-pos":[{"mask-b-from":ce()}],"mask-image-b-to-pos":[{"mask-b-to":ce()}],"mask-image-b-from-color":[{"mask-b-from":B()}],"mask-image-b-to-color":[{"mask-b-to":B()}],"mask-image-l-from-pos":[{"mask-l-from":ce()}],"mask-image-l-to-pos":[{"mask-l-to":ce()}],"mask-image-l-from-color":[{"mask-l-from":B()}],"mask-image-l-to-color":[{"mask-l-to":B()}],"mask-image-x-from-pos":[{"mask-x-from":ce()}],"mask-image-x-to-pos":[{"mask-x-to":ce()}],"mask-image-x-from-color":[{"mask-x-from":B()}],"mask-image-x-to-color":[{"mask-x-to":B()}],"mask-image-y-from-pos":[{"mask-y-from":ce()}],"mask-image-y-to-pos":[{"mask-y-to":ce()}],"mask-image-y-from-color":[{"mask-y-from":B()}],"mask-image-y-to-color":[{"mask-y-to":B()}],"mask-image-radial":[{"mask-radial":[ve,be]}],"mask-image-radial-from-pos":[{"mask-radial-from":ce()}],"mask-image-radial-to-pos":[{"mask-radial-to":ce()}],"mask-image-radial-from-color":[{"mask-radial-from":B()}],"mask-image-radial-to-color":[{"mask-radial-to":B()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":j()}],"mask-image-conic-pos":[{"mask-conic":[Re]}],"mask-image-conic-from-pos":[{"mask-conic-from":ce()}],"mask-image-conic-to-pos":[{"mask-conic-to":ce()}],"mask-image-conic-from-color":[{"mask-conic-from":B()}],"mask-image-conic-to-color":[{"mask-conic-to":B()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:U()}],"mask-repeat":[{mask:ie()}],"mask-size":[{mask:W()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ve,be]}],filter:[{filter:["","none",ve,be]}],blur:[{blur:me()}],brightness:[{brightness:[Re,ve,be]}],contrast:[{contrast:[Re,ve,be]}],"drop-shadow":[{"drop-shadow":["","none",m,Yr,Jr]}],"drop-shadow-color":[{"drop-shadow":B()}],grayscale:[{grayscale:["",Re,ve,be]}],"hue-rotate":[{"hue-rotate":[Re,ve,be]}],invert:[{invert:["",Re,ve,be]}],saturate:[{saturate:[Re,ve,be]}],sepia:[{sepia:["",Re,ve,be]}],"backdrop-filter":[{"backdrop-filter":["","none",ve,be]}],"backdrop-blur":[{"backdrop-blur":me()}],"backdrop-brightness":[{"backdrop-brightness":[Re,ve,be]}],"backdrop-contrast":[{"backdrop-contrast":[Re,ve,be]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Re,ve,be]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Re,ve,be]}],"backdrop-invert":[{"backdrop-invert":["",Re,ve,be]}],"backdrop-opacity":[{"backdrop-opacity":[Re,ve,be]}],"backdrop-saturate":[{"backdrop-saturate":[Re,ve,be]}],"backdrop-sepia":[{"backdrop-sepia":["",Re,ve,be]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":A()}],"border-spacing-x":[{"border-spacing-x":A()}],"border-spacing-y":[{"border-spacing-y":A()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ve,be]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Re,"initial",ve,be]}],ease:[{ease:["linear","initial",b,ve,be]}],delay:[{delay:[Re,ve,be]}],animate:[{animate:["none",y,ve,be]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[g,ve,be]}],"perspective-origin":[{"perspective-origin":S()}],rotate:[{rotate:le()}],"rotate-x":[{"rotate-x":le()}],"rotate-y":[{"rotate-y":le()}],"rotate-z":[{"rotate-z":le()}],scale:[{scale:ae()}],"scale-x":[{"scale-x":ae()}],"scale-y":[{"scale-y":ae()}],"scale-z":[{"scale-z":ae()}],"scale-3d":["scale-3d"],skew:[{skew:re()}],"skew-x":[{"skew-x":re()}],"skew-y":[{"skew-y":re()}],transform:[{transform:[ve,be,"","none","gpu","cpu"]}],"transform-origin":[{origin:S()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:pe()}],"translate-x":[{"translate-x":pe()}],"translate-y":[{"translate-y":pe()}],"translate-z":[{"translate-z":pe()}],"translate-none":["translate-none"],accent:[{accent:B()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:B()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ve,be]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":A()}],"scroll-mx":[{"scroll-mx":A()}],"scroll-my":[{"scroll-my":A()}],"scroll-ms":[{"scroll-ms":A()}],"scroll-me":[{"scroll-me":A()}],"scroll-mt":[{"scroll-mt":A()}],"scroll-mr":[{"scroll-mr":A()}],"scroll-mb":[{"scroll-mb":A()}],"scroll-ml":[{"scroll-ml":A()}],"scroll-p":[{"scroll-p":A()}],"scroll-px":[{"scroll-px":A()}],"scroll-py":[{"scroll-py":A()}],"scroll-ps":[{"scroll-ps":A()}],"scroll-pe":[{"scroll-pe":A()}],"scroll-pt":[{"scroll-pt":A()}],"scroll-pr":[{"scroll-pr":A()}],"scroll-pb":[{"scroll-pb":A()}],"scroll-pl":[{"scroll-pl":A()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ve,be]}],fill:[{fill:["none",...B()]}],"stroke-w":[{stroke:[Re,ir,dn,Fo]}],stroke:[{stroke:["none",...B()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Dw=xw(Lw);function de(...e){return Dw(Bd(e))}function Be(e){return e>=1e6?(e/1e6).toFixed(1).replace(/\.0$/,"")+"M":(e/1e3).toFixed(1).replace(/\.0$/,"")+"K"}function ef(e){return e>=1024*1024?(e/(1024*1024)).toFixed(1).replace(/\.0$/,"")+"M":(e/1024).toFixed(1).replace(/\.0$/,"")+"K"}function Jl(e,t,n){const r=e*10;return!Number.isSafeInteger(r)||r%t!==0?null:(r/t/10).toFixed(1).replace(/\.0$/,"")+n}function $w(e){if(!Number.isSafeInteger(e)||e<=0)return e.toString();if(e>=1024*1024){const n=Jl(e,1048576,"M");if(n!==null)return n}const t=Jl(e,1024,"K");return t!==null?t:e.toString()}function Fw(e){if(e===void 0||e==="")return 1;switch(e.toLowerCase()){case"k":return 1024;case"m":return 1024*1024;default:return null}}function Ps(e){const t=e.trim().replaceAll(",","");if(t==="")return null;const n=/^(\d+(?:\.\d+)?)\s*([kKmM])?$/.exec(t);if(n===null)return null;const r=n[1];if(r===void 0)return null;const o=Number(r),i=n[2],a=Fw(i);if(!Number.isFinite(o)||o<=0||a===null||(i===void 0||i==="")&&!Number.isInteger(o))return null;const l=Math.round(o*a);return!Number.isSafeInteger(l)||l<=0?null:l}function Bw(e){return e===null?"pending":e>=200&&e<300?"success":e>=400&&e<500?"client_error":e>=500?"server_error":"pending"}const Uw=G({model:N().min(1),contextWindow:q().int().positive().optional(),outputLimit:q().int().positive().optional(),source:Ee(["manual","registry"]).optional(),sourceUrl:N().optional(),updatedAt:N().optional()}),Ms=G({id:N(),name:N(),apiKey:N(),model:N().optional(),models:he(N()).min(1),format:Ee(["anthropic","openai"]).optional(),baseUrl:N().optional(),anthropicBaseUrl:N().optional(),openaiBaseUrl:N().optional(),openaiResponsesBaseUrl:N().optional(),authHeader:Ee(["bearer","x-api-key"]).optional().default("bearer"),apiDocsUrl:N().optional(),modelMetadataUrl:N().optional(),modelMetadata:he(Uw).optional(),source:Ee(["company","personal"]).optional(),createdAt:N(),updatedAt:N()});async function Ww(e){return tn(e,Ms.array(),void 0,t=>`Failed to fetch ${e}: ${t.status}`)}function tf(){const e=_n("/api/providers?includeSecrets=1",Ww,{revalidateOnFocus:!1,revalidateIfStale:!1});return{providers:e.data??[],isLoading:e.isLoading,isError:e.error,mutate:e.mutate}}function Ce(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e?.(o),n===!1||!o.defaultPrevented)return t?.(o)}}function Yl(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function nf(...e){return t=>{let n=!1;const r=e.map(o=>{const i=Yl(o,t);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let o=0;o<r.length;o++){const i=r[o];typeof i=="function"?i():Yl(e[o],null)}}}}function Oe(...e){return p.useCallback(nf(...e),e)}function Hw(e,t){const n=p.createContext(t),r=i=>{const{children:a,...l}=i,c=p.useMemo(()=>l,Object.values(l));return s.jsx(n.Provider,{value:c,children:a})};r.displayName=e+"Provider";function o(i){const a=p.useContext(n);if(a)return a;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[r,o]}function Zt(e,t=[]){let n=[];function r(i,a){const l=p.createContext(a),c=n.length;n=[...n,a];const u=f=>{const{scope:h,children:m,...v}=f,g=h?.[e]?.[c]||l,x=p.useMemo(()=>v,Object.values(v));return s.jsx(g.Provider,{value:x,children:m})};u.displayName=i+"Provider";function d(f,h){const m=h?.[e]?.[c]||l,v=p.useContext(m);if(v)return v;if(a!==void 0)return a;throw new Error(`\`${f}\` must be used within \`${i}\``)}return[u,d]}const o=()=>{const i=n.map(a=>p.createContext(a));return function(l){const c=l?.[e]||i;return p.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return o.scopeName=e,[r,Zw(o,...t)]}function Zw(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const a=r.reduce((l,{useScope:c,scopeName:u})=>{const f=c(i)[`__scope${u}`];return{...l,...f}},{});return p.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}var Ye=globalThis?.document?p.useLayoutEffect:()=>{},Vw=Eu[" useId ".trim().toString()]||(()=>{}),qw=0;function At(e){const[t,n]=p.useState(Vw());return Ye(()=>{n(r=>r??String(qw++))},[e]),e||(t?`radix-${t}`:"")}var Gw=Eu[" useInsertionEffect ".trim().toString()]||Ye;function bn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,i,a]=Kw({defaultProp:t,onChange:n}),l=e!==void 0,c=l?e:o;{const d=p.useRef(e!==void 0);p.useEffect(()=>{const f=d.current;f!==l&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=l},[l,r])}const u=p.useCallback(d=>{if(l){const f=Jw(d)?d(e):d;f!==e&&a.current?.(f)}else i(d)},[l,e,i,a]);return[c,u]}function Kw({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),o=p.useRef(n),i=p.useRef(t);return Gw(()=>{i.current=t},[t]),p.useEffect(()=>{o.current!==n&&(i.current?.(n),o.current=n)},[n,o]),[n,r,i]}function Jw(e){return typeof e=="function"}function Gn(e){const t=Xw(e),n=p.forwardRef((r,o)=>{const{children:i,...a}=r,l=p.Children.toArray(i),c=l.find(ek);if(c){const u=c.props.children,d=l.map(f=>f===c?p.Children.count(u)>1?p.Children.only(null):p.isValidElement(u)?u.props.children:null:f);return s.jsx(t,{...a,ref:o,children:p.isValidElement(u)?p.cloneElement(u,void 0,d):null})}return s.jsx(t,{...a,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}var Yw=Gn("Slot");function Xw(e){const t=p.forwardRef((n,r)=>{const{children:o,...i}=n;if(p.isValidElement(o)){const a=nk(o),l=tk(i,o.props);return o.type!==p.Fragment&&(l.ref=r?nf(r,a):a),p.cloneElement(o,l)}return p.Children.count(o)>1?p.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var rf=Symbol("radix.slottable");function Qw(e){const t=({children:n})=>s.jsx(s.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=rf,t}function ek(e){return p.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===rf}function tk(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const c=i(...l);return o(...l),c}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function nk(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var rk=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ae=rk.reduce((e,t)=>{const n=Gn(`Primitive.${t}`),r=p.forwardRef((o,i)=>{const{asChild:a,...l}=o,c=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(c,{...l,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function sk(e,t){e&&Ar.flushSync(()=>e.dispatchEvent(t))}function nt(e){const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),p.useMemo(()=>(...n)=>t.current?.(...n),[])}function ok(e,t=globalThis?.document){const n=nt(e);p.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var ik="DismissableLayer",Ci="dismissableLayer.update",ak="dismissableLayer.pointerDownOutside",lk="dismissableLayer.focusOutside",Xl,sf=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),fo=p.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:a,onDismiss:l,...c}=e,u=p.useContext(sf),[d,f]=p.useState(null),h=d?.ownerDocument??globalThis?.document,[,m]=p.useState({}),v=Oe(t,C=>f(C)),g=Array.from(u.layers),[x]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),b=g.indexOf(x),y=d?g.indexOf(d):-1,_=u.layersWithOutsidePointerEventsDisabled.size>0,j=y>=b,S=dk(C=>{const A=C.target,E=[...u.branches].some(P=>P.contains(A));!j||E||(o?.(C),a?.(C),C.defaultPrevented||l?.())},h),T=fk(C=>{const A=C.target;[...u.branches].some(P=>P.contains(A))||(i?.(C),a?.(C),C.defaultPrevented||l?.())},h);return ok(C=>{y===u.layers.size-1&&(r?.(C),!C.defaultPrevented&&l&&(C.preventDefault(),l()))},h),p.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Xl=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),Ql(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=Xl)}},[d,h,n,u]),p.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),Ql())},[d,u]),p.useEffect(()=>{const C=()=>m({});return document.addEventListener(Ci,C),()=>document.removeEventListener(Ci,C)},[]),s.jsx(Ae.div,{...c,ref:v,style:{pointerEvents:_?j?"auto":"none":void 0,...e.style},onFocusCapture:Ce(e.onFocusCapture,T.onFocusCapture),onBlurCapture:Ce(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:Ce(e.onPointerDownCapture,S.onPointerDownCapture)})});fo.displayName=ik;var ck="DismissableLayerBranch",uk=p.forwardRef((e,t)=>{const n=p.useContext(sf),r=p.useRef(null),o=Oe(t,r);return p.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),s.jsx(Ae.div,{...e,ref:o})});uk.displayName=ck;function dk(e,t=globalThis?.document){const n=nt(e),r=p.useRef(!1),o=p.useRef(()=>{});return p.useEffect(()=>{const i=l=>{if(l.target&&!r.current){let c=function(){of(ak,n,u,{discrete:!0})};const u={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",i),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function fk(e,t=globalThis?.document){const n=nt(e),r=p.useRef(!1);return p.useEffect(()=>{const o=i=>{i.target&&!r.current&&of(lk,n,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Ql(){const e=new CustomEvent(Ci);document.dispatchEvent(e)}function of(e,t,n,{discrete:r}){const o=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?sk(o,i):o.dispatchEvent(i)}var Bo="focusScope.autoFocusOnMount",Uo="focusScope.autoFocusOnUnmount",ec={bubbles:!1,cancelable:!0},pk="FocusScope",Ra=p.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...a}=e,[l,c]=p.useState(null),u=nt(o),d=nt(i),f=p.useRef(null),h=Oe(t,g=>c(g)),m=p.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;p.useEffect(()=>{if(r){let g=function(_){if(m.paused||!l)return;const j=_.target;l.contains(j)?f.current=j:Yt(f.current,{select:!0})},x=function(_){if(m.paused||!l)return;const j=_.relatedTarget;j!==null&&(l.contains(j)||Yt(f.current,{select:!0}))},b=function(_){if(document.activeElement===document.body)for(const S of _)S.removedNodes.length>0&&Yt(l)};document.addEventListener("focusin",g),document.addEventListener("focusout",x);const y=new MutationObserver(b);return l&&y.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",x),y.disconnect()}}},[r,l,m.paused]),p.useEffect(()=>{if(l){nc.add(m);const g=document.activeElement;if(!l.contains(g)){const b=new CustomEvent(Bo,ec);l.addEventListener(Bo,u),l.dispatchEvent(b),b.defaultPrevented||(hk(vk(af(l)),{select:!0}),document.activeElement===g&&Yt(l))}return()=>{l.removeEventListener(Bo,u),setTimeout(()=>{const b=new CustomEvent(Uo,ec);l.addEventListener(Uo,d),l.dispatchEvent(b),b.defaultPrevented||Yt(g??document.body,{select:!0}),l.removeEventListener(Uo,d),nc.remove(m)},0)}}},[l,u,d,m]);const v=p.useCallback(g=>{if(!n&&!r||m.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,b=document.activeElement;if(x&&b){const y=g.currentTarget,[_,j]=mk(y);_&&j?!g.shiftKey&&b===j?(g.preventDefault(),n&&Yt(_,{select:!0})):g.shiftKey&&b===_&&(g.preventDefault(),n&&Yt(j,{select:!0})):b===y&&g.preventDefault()}},[n,r,m.paused]);return s.jsx(Ae.div,{tabIndex:-1,...a,ref:h,onKeyDown:v})});Ra.displayName=pk;function hk(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Yt(r,{select:t}),document.activeElement!==n)return}function mk(e){const t=af(e),n=tc(t,e),r=tc(t.reverse(),e);return[n,r]}function af(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function tc(e,t){for(const n of e)if(!gk(n,{upTo:t}))return n}function gk(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function xk(e){return e instanceof HTMLInputElement&&"select"in e}function Yt(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&xk(e)&&t&&e.select()}}var nc=bk();function bk(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=rc(e,t),e.unshift(t)},remove(t){e=rc(e,t),e[0]?.resume()}}}function rc(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function vk(e){return e.filter(t=>t.tagName!=="A")}var yk="Portal",po=p.forwardRef((e,t)=>{const{container:n,...r}=e,[o,i]=p.useState(!1);Ye(()=>i(!0),[]);const a=n||o&&globalThis?.document?.body;return a?Tm.createPortal(s.jsx(Ae.div,{...r,ref:t}),a):null});po.displayName=yk;function wk(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var gt=e=>{const{present:t,children:n}=e,r=kk(t),o=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),i=Oe(r.ref,_k(o));return typeof n=="function"||r.isPresent?p.cloneElement(o,{ref:i}):null};gt.displayName="Presence";function kk(e){const[t,n]=p.useState(),r=p.useRef(null),o=p.useRef(e),i=p.useRef("none"),a=e?"mounted":"unmounted",[l,c]=wk(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const u=Xr(r.current);i.current=l==="mounted"?u:"none"},[l]),Ye(()=>{const u=r.current,d=o.current;if(d!==e){const h=i.current,m=Xr(u);e?c("MOUNT"):m==="none"||u?.display==="none"?c("UNMOUNT"):c(d&&h!==m?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),Ye(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=m=>{const g=Xr(r.current).includes(CSS.escape(m.animationName));if(m.target===t&&g&&(c("ANIMATION_END"),!o.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},h=m=>{m.target===t&&(i.current=Xr(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:p.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function Xr(e){return e?.animationName||"none"}function _k(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Wo=0;function lf(){p.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??sc()),document.body.insertAdjacentElement("beforeend",e[1]??sc()),Wo++,()=>{Wo===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Wo--}},[])}function sc(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Tt=function(){return Tt=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Tt.apply(this,arguments)};function cf(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function jk(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,i;r<o;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}var ws="right-scroll-bar-position",ks="width-before-scroll-bar",Sk="with-scroll-bars-hidden",Ck="--removed-body-scroll-bar-size";function Ho(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Nk(e,t){var n=p.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var Tk=typeof window<"u"?p.useLayoutEffect:p.useEffect,oc=new WeakMap;function Ek(e,t){var n=Nk(null,function(r){return e.forEach(function(o){return Ho(o,r)})});return Tk(function(){var r=oc.get(n);if(r){var o=new Set(r),i=new Set(e),a=n.current;o.forEach(function(l){i.has(l)||Ho(l,null)}),i.forEach(function(l){o.has(l)||Ho(l,a)})}oc.set(n,e)},[e]),n}function Ak(e){return e}function Rk(e,t){t===void 0&&(t=Ak);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(i){var a=t(i,r);return n.push(a),function(){n=n.filter(function(l){return l!==a})}},assignSyncMedium:function(i){for(r=!0;n.length;){var a=n;n=[],a.forEach(i)}n={push:function(l){return i(l)},filter:function(){return n}}},assignMedium:function(i){r=!0;var a=[];if(n.length){var l=n;n=[],l.forEach(i),a=n}var c=function(){var d=a;a=[],d.forEach(i)},u=function(){return Promise.resolve().then(c)};u(),n={push:function(d){a.push(d),u()},filter:function(d){return a=a.filter(d),n}}}};return o}function Ik(e){e===void 0&&(e={});var t=Rk(null);return t.options=Tt({async:!0,ssr:!1},e),t}var uf=function(e){var t=e.sideCar,n=cf(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return p.createElement(r,Tt({},n))};uf.isSideCarExport=!0;function zk(e,t){return e.useMedium(t),uf}var df=Ik(),Zo=function(){},ho=p.forwardRef(function(e,t){var n=p.useRef(null),r=p.useState({onScrollCapture:Zo,onWheelCapture:Zo,onTouchMoveCapture:Zo}),o=r[0],i=r[1],a=e.forwardProps,l=e.children,c=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,h=e.sideCar,m=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,b=e.as,y=b===void 0?"div":b,_=e.gapMode,j=cf(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=h,T=Ek([n,t]),C=Tt(Tt({},j),o);return p.createElement(p.Fragment,null,d&&p.createElement(S,{sideCar:df,removeScrollBar:u,shards:f,noRelative:m,noIsolation:v,inert:g,setCallbacks:i,allowPinchZoom:!!x,lockRef:n,gapMode:_}),a?p.cloneElement(p.Children.only(l),Tt(Tt({},C),{ref:T})):p.createElement(y,Tt({},C,{className:c,ref:T}),l))});ho.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};ho.classNames={fullWidth:ks,zeroRight:ws};var Ok=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Pk(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Ok();return t&&e.setAttribute("nonce",t),e}function Mk(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Lk(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Dk=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Pk())&&(Mk(t,n),Lk(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},$k=function(){var e=Dk();return function(t,n){p.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},ff=function(){var e=$k(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Fk={left:0,top:0,right:0,gap:0},Vo=function(e){return parseInt(e||"",10)||0},Bk=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[Vo(n),Vo(r),Vo(o)]},Uk=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Fk;var t=Bk(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Wk=ff(),Fn="data-scroll-locked",Hk=function(e,t,n,r){var o=e.left,i=e.top,a=e.right,l=e.gap;return n===void 0&&(n="margin"),`
|
|
42
|
+
.`.concat(Sk,` {
|
|
43
|
+
overflow: hidden `).concat(r,`;
|
|
44
|
+
padding-right: `).concat(l,"px ").concat(r,`;
|
|
45
|
+
}
|
|
46
|
+
body[`).concat(Fn,`] {
|
|
47
|
+
overflow: hidden `).concat(r,`;
|
|
48
|
+
overscroll-behavior: contain;
|
|
49
|
+
`).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
|
|
50
|
+
padding-left: `.concat(o,`px;
|
|
51
|
+
padding-top: `).concat(i,`px;
|
|
52
|
+
padding-right: `).concat(a,`px;
|
|
53
|
+
margin-left:0;
|
|
54
|
+
margin-top:0;
|
|
55
|
+
margin-right: `).concat(l,"px ").concat(r,`;
|
|
56
|
+
`),n==="padding"&&"padding-right: ".concat(l,"px ").concat(r,";")].filter(Boolean).join(""),`
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.`).concat(ws,` {
|
|
60
|
+
right: `).concat(l,"px ").concat(r,`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.`).concat(ks,` {
|
|
64
|
+
margin-right: `).concat(l,"px ").concat(r,`;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.`).concat(ws," .").concat(ws,` {
|
|
68
|
+
right: 0 `).concat(r,`;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.`).concat(ks," .").concat(ks,` {
|
|
72
|
+
margin-right: 0 `).concat(r,`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
body[`).concat(Fn,`] {
|
|
76
|
+
`).concat(Ck,": ").concat(l,`px;
|
|
77
|
+
}
|
|
78
|
+
`)},ic=function(){var e=parseInt(document.body.getAttribute(Fn)||"0",10);return isFinite(e)?e:0},Zk=function(){p.useEffect(function(){return document.body.setAttribute(Fn,(ic()+1).toString()),function(){var e=ic()-1;e<=0?document.body.removeAttribute(Fn):document.body.setAttribute(Fn,e.toString())}},[])},Vk=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Zk();var i=p.useMemo(function(){return Uk(o)},[o]);return p.createElement(Wk,{styles:Hk(i,!t,o,n?"":"!important")})},Ni=!1;if(typeof window<"u")try{var Qr=Object.defineProperty({},"passive",{get:function(){return Ni=!0,!0}});window.addEventListener("test",Qr,Qr),window.removeEventListener("test",Qr,Qr)}catch{Ni=!1}var En=Ni?{passive:!1}:!1,qk=function(e){return e.tagName==="TEXTAREA"},pf=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!qk(e)&&n[t]==="visible")},Gk=function(e){return pf(e,"overflowY")},Kk=function(e){return pf(e,"overflowX")},ac=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=hf(e,r);if(o){var i=mf(e,r),a=i[1],l=i[2];if(a>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Jk=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Yk=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},hf=function(e,t){return e==="v"?Gk(t):Kk(t)},mf=function(e,t){return e==="v"?Jk(t):Yk(t)},Xk=function(e,t){return e==="h"&&t==="rtl"?-1:1},Qk=function(e,t,n,r,o){var i=Xk(e,window.getComputedStyle(t).direction),a=i*r,l=n.target,c=t.contains(l),u=!1,d=a>0,f=0,h=0;do{if(!l)break;var m=mf(e,l),v=m[0],g=m[1],x=m[2],b=g-x-i*v;(v||b)&&hf(e,l)&&(f+=b,h+=v);var y=l.parentNode;l=y&&y.nodeType===Node.DOCUMENT_FRAGMENT_NODE?y.host:y}while(!c&&l!==document.body||c&&(t.contains(l)||t===l));return(d&&Math.abs(f)<1||!d&&Math.abs(h)<1)&&(u=!0),u},es=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},lc=function(e){return[e.deltaX,e.deltaY]},cc=function(e){return e&&"current"in e?e.current:e},e_=function(e,t){return e[0]===t[0]&&e[1]===t[1]},t_=function(e){return`
|
|
79
|
+
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
80
|
+
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
81
|
+
`)},n_=0,An=[];function r_(e){var t=p.useRef([]),n=p.useRef([0,0]),r=p.useRef(),o=p.useState(n_++)[0],i=p.useState(ff)[0],a=p.useRef(e);p.useEffect(function(){a.current=e},[e]),p.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=jk([e.lockRef.current],(e.shards||[]).map(cc),!0).filter(Boolean);return g.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var l=p.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!a.current.allowPinchZoom;var b=es(g),y=n.current,_="deltaX"in g?g.deltaX:y[0]-b[0],j="deltaY"in g?g.deltaY:y[1]-b[1],S,T=g.target,C=Math.abs(_)>Math.abs(j)?"h":"v";if("touches"in g&&C==="h"&&T.type==="range")return!1;var A=window.getSelection(),E=A&&A.anchorNode,P=E?E===T||E.contains(T):!1;if(P)return!1;var J=ac(C,T);if(!J)return!0;if(J?S=C:(S=C==="v"?"h":"v",J=ac(C,T)),!J)return!1;if(!r.current&&"changedTouches"in g&&(_||j)&&(r.current=S),!S)return!0;var R=r.current||S;return Qk(R,x,g,R==="h"?_:j)},[]),c=p.useCallback(function(g){var x=g;if(!(!An.length||An[An.length-1]!==i)){var b="deltaY"in x?lc(x):es(x),y=t.current.filter(function(S){return S.name===x.type&&(S.target===x.target||x.target===S.shadowParent)&&e_(S.delta,b)})[0];if(y&&y.should){x.cancelable&&x.preventDefault();return}if(!y){var _=(a.current.shards||[]).map(cc).filter(Boolean).filter(function(S){return S.contains(x.target)}),j=_.length>0?l(x,_[0]):!a.current.noIsolation;j&&x.cancelable&&x.preventDefault()}}},[]),u=p.useCallback(function(g,x,b,y){var _={name:g,delta:x,target:b,should:y,shadowParent:s_(b)};t.current.push(_),setTimeout(function(){t.current=t.current.filter(function(j){return j!==_})},1)},[]),d=p.useCallback(function(g){n.current=es(g),r.current=void 0},[]),f=p.useCallback(function(g){u(g.type,lc(g),g.target,l(g,e.lockRef.current))},[]),h=p.useCallback(function(g){u(g.type,es(g),g.target,l(g,e.lockRef.current))},[]);p.useEffect(function(){return An.push(i),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",c,En),document.addEventListener("touchmove",c,En),document.addEventListener("touchstart",d,En),function(){An=An.filter(function(g){return g!==i}),document.removeEventListener("wheel",c,En),document.removeEventListener("touchmove",c,En),document.removeEventListener("touchstart",d,En)}},[]);var m=e.removeScrollBar,v=e.inert;return p.createElement(p.Fragment,null,v?p.createElement(i,{styles:t_(o)}):null,m?p.createElement(Vk,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function s_(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const o_=zk(df,r_);var Ia=p.forwardRef(function(e,t){return p.createElement(ho,Tt({},e,{ref:t,sideCar:o_}))});Ia.classNames=ho.classNames;var i_=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Rn=new WeakMap,ts=new WeakMap,ns={},qo=0,gf=function(e){return e&&(e.host||gf(e.parentNode))},a_=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=gf(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},l_=function(e,t,n,r){var o=a_(t,Array.isArray(e)?e:[e]);ns[n]||(ns[n]=new WeakMap);var i=ns[n],a=[],l=new Set,c=new Set(o),u=function(f){!f||l.has(f)||(l.add(f),u(f.parentNode))};o.forEach(u);var d=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(h){if(l.has(h))d(h);else try{var m=h.getAttribute(r),v=m!==null&&m!=="false",g=(Rn.get(h)||0)+1,x=(i.get(h)||0)+1;Rn.set(h,g),i.set(h,x),a.push(h),g===1&&v&&ts.set(h,!0),x===1&&h.setAttribute(n,"true"),v||h.setAttribute(r,"true")}catch(b){console.error("aria-hidden: cannot operate on ",h,b)}})};return d(t),l.clear(),qo++,function(){a.forEach(function(f){var h=Rn.get(f)-1,m=i.get(f)-1;Rn.set(f,h),i.set(f,m),h||(ts.has(f)||f.removeAttribute(r),ts.delete(f)),m||f.removeAttribute(n)}),qo--,qo||(Rn=new WeakMap,Rn=new WeakMap,ts=new WeakMap,ns={})}},xf=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=i_(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),l_(r,o,n,"aria-hidden")):function(){return null}},mo="Dialog",[bf]=Zt(mo),[c_,Ct]=bf(mo),vf=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:a=!0}=e,l=p.useRef(null),c=p.useRef(null),[u,d]=bn({prop:r,defaultProp:o??!1,onChange:i,caller:mo});return s.jsx(c_,{scope:t,triggerRef:l,contentRef:c,contentId:At(),titleId:At(),descriptionId:At(),open:u,onOpenChange:d,onOpenToggle:p.useCallback(()=>d(f=>!f),[d]),modal:a,children:n})};vf.displayName=mo;var yf="DialogTrigger",wf=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ct(yf,n),i=Oe(t,o.triggerRef);return s.jsx(Ae.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Pa(o.open),...r,ref:i,onClick:Ce(e.onClick,o.onOpenToggle)})});wf.displayName=yf;var za="DialogPortal",[u_,kf]=bf(za,{forceMount:void 0}),_f=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,i=Ct(za,t);return s.jsx(u_,{scope:t,forceMount:n,children:p.Children.map(r,a=>s.jsx(gt,{present:n||i.open,children:s.jsx(po,{asChild:!0,container:o,children:a})}))})};_f.displayName=za;var Ls="DialogOverlay",jf=p.forwardRef((e,t)=>{const n=kf(Ls,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=Ct(Ls,e.__scopeDialog);return i.modal?s.jsx(gt,{present:r||i.open,children:s.jsx(f_,{...o,ref:t})}):null});jf.displayName=Ls;var d_=Gn("DialogOverlay.RemoveScroll"),f_=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ct(Ls,n);return s.jsx(Ia,{as:d_,allowPinchZoom:!0,shards:[o.contentRef],children:s.jsx(Ae.div,{"data-state":Pa(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),vn="DialogContent",Sf=p.forwardRef((e,t)=>{const n=kf(vn,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=Ct(vn,e.__scopeDialog);return s.jsx(gt,{present:r||i.open,children:i.modal?s.jsx(p_,{...o,ref:t}):s.jsx(h_,{...o,ref:t})})});Sf.displayName=vn;var p_=p.forwardRef((e,t)=>{const n=Ct(vn,e.__scopeDialog),r=p.useRef(null),o=Oe(t,n.contentRef,r);return p.useEffect(()=>{const i=r.current;if(i)return xf(i)},[]),s.jsx(Cf,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ce(e.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Ce(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0;(a.button===2||l)&&i.preventDefault()}),onFocusOutside:Ce(e.onFocusOutside,i=>i.preventDefault())})}),h_=p.forwardRef((e,t)=>{const n=Ct(vn,e.__scopeDialog),r=p.useRef(!1),o=p.useRef(!1);return s.jsx(Cf,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(r.current||n.triggerRef.current?.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=i.target;n.triggerRef.current?.contains(a)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),Cf=p.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,...a}=e,l=Ct(vn,n),c=p.useRef(null),u=Oe(t,c);return lf(),s.jsxs(s.Fragment,{children:[s.jsx(Ra,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:s.jsx(fo,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":Pa(l.open),...a,ref:u,onDismiss:()=>l.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(m_,{titleId:l.titleId}),s.jsx(x_,{contentRef:c,descriptionId:l.descriptionId})]})]})}),Oa="DialogTitle",Nf=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ct(Oa,n);return s.jsx(Ae.h2,{id:o.titleId,...r,ref:t})});Nf.displayName=Oa;var Tf="DialogDescription",Ef=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ct(Tf,n);return s.jsx(Ae.p,{id:o.descriptionId,...r,ref:t})});Ef.displayName=Tf;var Af="DialogClose",Rf=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ct(Af,n);return s.jsx(Ae.button,{type:"button",...r,ref:t,onClick:Ce(e.onClick,()=>o.onOpenChange(!1))})});Rf.displayName=Af;function Pa(e){return e?"open":"closed"}var If="DialogTitleWarning",[YR,zf]=Hw(If,{contentName:vn,titleName:Oa,docsSlug:"dialog"}),m_=({titleId:e})=>{const t=zf(If),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
82
|
+
|
|
83
|
+
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
84
|
+
|
|
85
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return p.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},g_="DialogDescriptionWarning",x_=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${zf(g_).contentName}}.`;return p.useEffect(()=>{const o=e.current?.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},b_=vf,v_=wf,y_=_f,w_=jf,k_=Sf,__=Nf,j_=Ef,S_=Rf;function zr({...e}){return s.jsx(b_,{"data-slot":"dialog",...e})}function Ma({...e}){return s.jsx(v_,{"data-slot":"dialog-trigger",...e})}function C_({...e}){return s.jsx(y_,{"data-slot":"dialog-portal",...e})}function N_({className:e,...t}){return s.jsx(w_,{"data-slot":"dialog-overlay",className:de("fixed inset-0 z-40 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t})}function Or({className:e,children:t,...n}){return s.jsxs(C_,{children:[s.jsx(N_,{}),s.jsxs(k_,{"data-slot":"dialog-content",className:de("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-lg",e),...n,children:[t,s.jsxs(S_,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[s.jsx(Ta,{className:"size-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Pr({className:e,...t}){return s.jsx("div",{"data-slot":"dialog-header",className:de("flex flex-col space-y-1.5 text-center sm:text-left",e),...t})}function Mr({className:e,...t}){return s.jsx(__,{"data-slot":"dialog-title",className:de("text-lg font-semibold leading-none tracking-tight",e),...t})}function T_({className:e,...t}){return s.jsx(j_,{"data-slot":"dialog-description",className:de("text-sm text-muted-foreground",e),...t})}const uc=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,dc=Bd,La=(e,t)=>n=>{var r;if(t?.variants==null)return dc(e,n?.class,n?.className);const{variants:o,defaultVariants:i}=t,a=Object.keys(o).map(u=>{const d=n?.[u],f=i?.[u];if(d===null)return null;const h=uc(d)||uc(f);return o[u][h]}),l=n&&Object.entries(n).reduce((u,d)=>{let[f,h]=d;return h===void 0||(u[f]=h),u},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((u,d)=>{let{class:f,className:h,...m}=d;return Object.entries(m).every(v=>{let[g,x]=v;return Array.isArray(x)?x.includes({...i,...l}[g]):{...i,...l}[g]===x})?[...u,f,h]:u},[]);return dc(e,a,c,n?.class,n?.className)},E_=La("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function Ne({className:e,variant:t,size:n,...r}){return s.jsx("button",{"data-slot":"button",className:de(E_({variant:t,size:n,className:e})),...r})}function Of({open:e,onOpenChange:t,title:n,description:r,confirmLabel:o="Confirm",variant:i="default",onConfirm:a}){return s.jsx(zr,{open:e,onOpenChange:t,children:s.jsxs(Or,{children:[s.jsx(Pr,{children:s.jsx(Mr,{children:n})}),s.jsx("p",{className:"text-sm text-muted-foreground",children:r}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(Ne,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),s.jsx(Ne,{variant:i,size:"sm",onClick:()=>{a(),t(!1)},children:o})]})]})})}const A_={codex:"Codex",opencode:"OpenCode","mimo-code":"MiMo Code","claude-code":"Claude Code"};function Go(e){return e?.toLowerCase()??""}function rs(e,t){for(const n of t)if(e.includes(n))return!0;return!1}function R_(e){const t=[Go(e.userAgent),Go(e.conversationId),Go(e.clientProjectFolder)].join(" ");return rs(t,["mimocode","mimo-code","mimo code"])?"mimo-code":rs(t,["opencode","open-code","open code"])?"opencode":rs(t,["claude-code","claude code","claudecode"])?"claude-code":rs(t,["codex desktop","codex-cli","openai-codex","codex"])?"codex":"unknown"}function Pf(e){switch(e){case"codex":case"opencode":case"mimo-code":case"claude-code":return A_[e];case"unknown":return null}}function I_(){return s.jsxs("svg",{viewBox:"0 0 24 24",className:"size-full","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"12",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"2.2"}),s.jsx("path",{d:"M14.8 8.6a4.8 4.8 0 1 0 0 6.8",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"2.2"})]})}function z_(){return s.jsxs("svg",{viewBox:"0 0 24 24",className:"size-full","aria-hidden":"true",children:[s.jsx("path",{d:"M7 4h10v16H7z",fill:"none",stroke:"currentColor",strokeWidth:"2.2"}),s.jsx("path",{d:"M10 8h4M10 12h4M10 16h2",stroke:"currentColor",strokeLinecap:"round"})]})}function O_(){return s.jsx("svg",{viewBox:"0 0 24 24",className:"size-full","aria-hidden":"true",children:s.jsx("path",{d:"M5 18V6h3.2l3.8 6.1L15.8 6H19v12h-3V11.3l-3.1 5h-1.8L8 11.3V18z",fill:"currentColor"})})}function P_(){return s.jsx("svg",{viewBox:"0 0 24 24",className:"size-full","aria-hidden":"true",children:s.jsx("path",{fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",d:"M21 10.95h3v3.1h-3v3.03h-1.49V20H18v-2.92h-1.49V20H15v-2.92H9V20H7.49v-2.92H6V20H4.49v-2.92H3v-3.03H0v-3.1h3V5h18v5.95zM6 10.95h1.49V8.1H6v2.85zm10.51 0H18V8.1h-1.49v2.85z"})})}function M_({client:e,className:t}){const n=Pf(e);return n===null?null:s.jsxs("span",{className:de("inline-flex size-6 shrink-0 items-center justify-center rounded-md border border-white/10 bg-black/20 p-1 text-cyan-100 shadow-[inset_0_1px_0_rgba(255,255,255,0.05)]",t),"aria-label":n,title:n,children:[e==="codex"&&s.jsx(I_,{}),e==="opencode"&&s.jsx(z_,{}),e==="mimo-code"&&s.jsx(O_,{}),e==="claude-code"&&s.jsx(P_,{})]})}const L_="data:image/svg+xml,%3csvg%20height='2500'%20viewBox='0%206.603%201192.672%201193.397'%20width='2500'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='m233.96%20800.215%20234.684-131.678%203.947-11.436-3.947-6.363h-11.436l-39.221-2.416-134.094-3.624-116.296-4.832-112.67-6.04-28.35-6.04-26.577-35.035%202.738-17.477%2023.84-16.027%2034.147%202.98%2075.463%205.155%20113.235%207.812%2082.147%204.832%20121.692%2012.644h19.329l2.738-7.812-6.604-4.832-5.154-4.832-117.182-79.41-126.845-83.92-66.443-48.321-35.92-24.484-18.12-22.953-7.813-50.093%2032.618-35.92%2043.812%202.98%2011.195%202.98%2044.375%2034.147%2094.792%2073.37%20123.786%2091.167%2018.12%2015.06%207.249-5.154.886-3.624-8.135-13.61-67.329-121.692-71.838-123.785-31.974-51.302-8.456-30.765c-2.98-12.645-5.154-23.275-5.154-36.242l37.127-50.416%2020.537-6.604%2049.53%206.604%2020.86%2018.121%2030.765%2070.39%2049.852%20110.818%2077.315%20150.684%2022.631%2044.698%2012.08%2041.396%204.51%2012.645h7.813v-7.248l6.362-84.886%2011.759-104.215%2011.436-134.094%203.946-37.772%2018.685-45.262%2037.127-24.482%2028.994%2013.852%2023.839%2034.148-3.303%2022.067-14.174%2092.134-27.785%20144.323-18.121%2096.644h10.55l12.08-12.08%2048.887-64.913%2082.147-102.685%2036.242-40.752%2042.282-45.02%2027.14-21.423h51.303l37.772%2056.135-16.913%2057.986-52.832%2067.007-43.812%2056.779-62.82%2084.563-39.22%2067.651%203.623%205.396%209.343-.886%20141.906-30.201%2076.671-13.852%2091.49-15.705%2041.396%2019.329%204.51%2019.65-16.269%2040.189-97.852%2024.16-114.764%2022.954-170.9%2040.43-2.093%201.53%202.416%202.98%2076.993%207.248%2032.94%201.771h80.617l150.12%2011.195%2039.222%2025.933%2023.517%2031.732-3.946%2024.16-60.403%2030.766-81.503-19.33-190.228-45.26-65.235-16.27h-9.02v5.397l54.362%2053.154%2099.624%2089.96%20124.752%20115.973%206.362%2028.671-16.027%2022.63-16.912-2.415-109.611-82.47-42.282-37.127-95.758-80.618h-6.363v8.456l22.067%2032.296%20116.537%20175.167%206.04%2053.719-8.456%2017.476-30.201%2010.55-33.181-6.04-68.215-95.758-70.39-107.84-56.778-96.644-6.926%203.947-33.503%20360.886-15.705%2018.443-36.243%2013.852-30.201-22.953-16.027-37.127%2016.027-73.37%2019.329-95.758%2015.704-76.107%2014.175-94.55%208.456-31.41-.563-2.094-6.927.886-71.275%2097.852-108.402%20146.497-85.772%2091.812-20.537%208.134-35.597-18.443%203.301-32.94%2019.893-29.315%20118.712-151.007%2071.597-93.583%2046.228-54.04-.322-7.813h-2.738l-315.302%20204.725-56.135%207.248-24.16-22.63%202.98-37.128%2011.435-12.08%2094.792-65.236-.322.323z'%20fill='%23d97757'/%3e%3c/svg%3e",D_="data:image/svg+xml,%3csvg%20height='2500'%20viewBox='-1%20-.1%20949.1%20959.8'%20width='2474'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='m925.8%20456.3c10.4%2023.2%2017%2048%2019.7%2073.3%202.6%2025.3%201.3%2050.9-4.1%2075.8-5.3%2024.9-14.5%2048.8-27.3%2070.8-8.4%2014.7-18.3%2028.5-29.7%2041.2-11.3%2012.6-23.9%2024-37.6%2034-13.8%2010-28.5%2018.4-44.1%2025.3-15.5%206.8-31.7%2012-48.3%2015.4-7.8%2024.2-19.4%2047.1-34.4%2067.7-14.9%2020.6-33%2038.7-53.6%2053.6-20.6%2015-43.4%2026.6-67.6%2034.4-24.2%207.9-49.5%2011.8-75%2011.8-16.9.1-33.9-1.7-50.5-5.1-16.5-3.5-32.7-8.8-48.2-15.7s-30.2-15.5-43.9-25.5c-13.6-10-26.2-21.5-37.4-34.2-25%205.4-50.6%206.7-75.9%204.1-25.3-2.7-50.1-9.3-73.4-19.7-23.2-10.3-44.7-24.3-63.6-41.4s-35-37.1-47.7-59.1c-8.5-14.7-15.5-30.2-20.8-46.3s-8.8-32.7-10.6-49.6c-1.8-16.8-1.7-33.8.1-50.7%201.8-16.8%205.5-33.4%2010.8-49.5-17-18.9-31-40.4-41.4-63.6-10.3-23.3-17-48-19.6-73.3-2.7-25.3-1.3-50.9%204-75.8s14.5-48.8%2027.3-70.8c8.4-14.7%2018.3-28.6%2029.6-41.2s24-24%2037.7-34%2028.5-18.5%2044-25.3c15.6-6.9%2031.8-12%2048.4-15.4%207.8-24.3%2019.4-47.1%2034.3-67.7%2015-20.6%2033.1-38.7%2053.7-53.7%2020.6-14.9%2043.4-26.5%2067.6-34.4%2024.2-7.8%2049.5-11.8%2075-11.7%2016.9-.1%2033.9%201.6%2050.5%205.1s32.8%208.7%2048.3%2015.6c15.5%207%2030.2%2015.5%2043.9%2025.5%2013.7%2010.1%2026.3%2021.5%2037.5%2034.2%2024.9-5.3%2050.5-6.6%2075.8-4s50%209.3%2073.3%2019.6c23.2%2010.4%2044.7%2024.3%2063.6%2041.4%2018.9%2017%2035%2036.9%2047.7%2059%208.5%2014.6%2015.5%2030.1%2020.8%2046.3%205.3%2016.1%208.9%2032.7%2010.6%2049.6%201.8%2016.9%201.8%2033.9-.1%2050.8-1.8%2016.9-5.5%2033.5-10.8%2049.6%2017.1%2018.9%2031%2040.3%2041.4%2063.6zm-333.2%20426.9c21.8-9%2041.6-22.3%2058.3-39s30-36.5%2039-58.4c9-21.8%2013.7-45.2%2013.7-68.8v-223q-.1-.3-.2-.7-.1-.3-.3-.6-.2-.3-.5-.5-.3-.3-.6-.4l-80.7-46.6v269.4c0%202.7-.4%205.5-1.1%208.1-.7%202.7-1.7%205.2-3.1%207.6s-3%204.6-5%206.5a32.1%2032.1%200%200%201%20-6.5%205l-191.1%20110.3c-1.6%201-4.3%202.4-5.7%203.2%207.9%206.7%2016.5%2012.6%2025.5%2017.8%209.1%205.2%2018.5%209.6%2028.3%2013.2%209.8%203.5%2019.9%206.2%2030.1%208%2010.3%201.8%2020.7%202.7%2031.1%202.7%2023.6%200%2047-4.7%2068.8-13.8zm-455.1-151.4c11.9%2020.5%2027.6%2038.3%2046.3%2052.7%2018.8%2014.4%2040.1%2024.9%2062.9%2031s46.6%207.7%2070%204.6%2045.9-10.7%2066.4-22.5l193.2-111.5.5-.5q.2-.2.3-.6.2-.3.3-.6v-94l-233.2%20134.9c-2.4%201.4-4.9%202.4-7.5%203.2-2.7.7-5.4%201-8.2%201-2.7%200-5.4-.3-8.1-1-2.6-.8-5.2-1.8-7.6-3.2l-191.1-110.4c-1.7-1-4.2-2.5-5.6-3.4-1.8%2010.3-2.7%2020.7-2.7%2031.1s1%2020.8%202.8%2031.1c1.8%2010.2%204.6%2020.3%208.1%2030.1%203.6%209.8%208%2019.2%2013.2%2028.2zm-50.2-417c-11.8%2020.5-19.4%2043.1-22.5%2066.5s-1.5%2047.1%204.6%2070c6.1%2022.8%2016.6%2044.1%2031%2062.9%2014.4%2018.7%2032.3%2034.4%2052.7%2046.2l193.1%20111.6q.3.1.7.2h.7q.4%200%20.7-.2.3-.1.6-.3l81-46.8-233.2-134.6c-2.3-1.4-4.5-3.1-6.5-5a32.1%2032.1%200%200%201%20-5-6.5c-1.3-2.4-2.4-4.9-3.1-7.6-.7-2.6-1.1-5.3-1-8.1v-227.1c-9.8%203.6-19.3%208-28.3%2013.2-9%205.3-17.5%2011.3-25.5%2018-7.9%206.7-15.3%2014.1-22%2022.1-6.7%207.9-12.6%2016.5-17.8%2025.5zm663.3%20154.4c2.4%201.4%204.6%203%206.6%205%201.9%201.9%203.6%204.1%205%206.5%201.3%202.4%202.4%205%203.1%207.6.6%202.7%201%205.4.9%208.2v227.1c32.1-11.8%2060.1-32.5%2080.8-59.7%2020.8-27.2%2033.3-59.7%2036.2-93.7s-3.9-68.2-19.7-98.5-39.9-55.5-69.5-72.5l-193.1-111.6q-.3-.1-.7-.2h-.7q-.3.1-.7.2-.3.1-.6.3l-80.6%2046.6%20233.2%20134.7zm80.5-121h-.1v.1zm-.1-.1c5.8-33.6%201.9-68.2-11.3-99.7-13.1-31.5-35-58.6-63-78.2-28-19.5-61-30.7-95.1-32.2-34.2-1.4-68%206.9-97.6%2023.9l-193.1%20111.5q-.3.2-.5.5l-.4.6q-.1.3-.2.7-.1.3-.1.7v93.2l233.2-134.7c2.4-1.4%205-2.4%207.6-3.2%202.7-.7%205.4-1%208.1-1%202.8%200%205.5.3%208.2%201%202.6.8%205.1%201.8%207.5%203.2l191.1%20110.4c1.7%201%204.2%202.4%205.6%203.3zm-505.3-103.2c0-2.7.4-5.4%201.1-8.1.7-2.6%201.7-5.2%203.1-7.6%201.4-2.3%203-4.5%205-6.5%201.9-1.9%204.1-3.6%206.5-4.9l191.1-110.3c1.8-1.1%204.3-2.5%205.7-3.2-26.2-21.9-58.2-35.9-92.1-40.2-33.9-4.4-68.3%201-99.2%2015.5-31%2014.5-57.2%2037.6-75.5%2066.4-18.3%2028.9-28%2062.3-28%2096.5v223q.1.4.2.7.1.3.3.6.2.3.5.6.2.2.6.4l80.7%2046.6zm43.8%20294.7%20103.9%2060%20103.9-60v-119.9l-103.8-60-103.9%2060z'/%3e%3c/svg%3e",$_="data:image/svg+xml,%3csvg%20fill='none'%20height='1320'%20viewBox='3.771%206.973%2023.993%2017.652'%20width='2500'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='m27.501%208.469c-.252-.123-.36.111-.508.23-.05.04-.093.09-.135.135-.368.395-.797.652-1.358.621-.821-.045-1.521.213-2.14.842-.132-.776-.57-1.238-1.235-1.535-.349-.155-.701-.309-.944-.645-.171-.238-.217-.504-.303-.765-.054-.159-.108-.32-.29-.348-.197-.031-.274.135-.352.273-.31.567-.43%201.192-.419%201.825.028%201.421.628%202.554%201.82%203.36.136.093.17.186.128.321-.081.278-.178.547-.264.824-.054.178-.135.217-.324.14a5.448%205.448%200%200%201%20-1.719-1.169c-.848-.82-1.614-1.726-2.57-2.435-.225-.166-.449-.32-.681-.467-.976-.95.128-1.729.383-1.82.267-.096.093-.428-.77-.424s-1.653.293-2.659.677a2.782%202.782%200%200%201%20-.46.135%209.554%209.554%200%200%200%20-2.853-.1c-1.866.21-3.356%201.092-4.452%202.6-1.315%201.81-1.625%203.87-1.246%206.018.399%202.261%201.552%204.136%203.326%205.601%201.837%201.518%203.955%202.262%206.37%202.12%201.466-.085%203.1-.282%204.942-1.842.465.23.952.322%201.762.392.623.059%201.223-.031%201.687-.127.728-.154.677-.828.414-.953-2.132-.994-1.665-.59-2.09-.916%201.084-1.285%202.717-2.619%203.356-6.94.05-.343.007-.558%200-.837-.004-.168.034-.235.228-.254a4.084%204.084%200%200%200%201.529-.47c1.382-.757%201.938-1.997%202.07-3.485.02-.227-.004-.463-.243-.582zm-12.041%2013.391c-2.067-1.627-3.07-2.162-3.483-2.138-.387.021-.318.465-.233.754.089.285.205.482.368.732.113.166.19.414-.112.598-.666.414-1.823-.139-1.878-.166-1.347-.793-2.473-1.842-3.267-3.276-.765-1.38-1.21-2.861-1.284-4.441-.02-.383.093-.518.472-.586a4.692%204.692%200%200%201%201.514-.04c2.109.31%203.905%201.255%205.41%202.749.86.853%201.51%201.871%202.18%202.865.711%201.057%201.478%202.063%202.454%202.887.343.289.619.51.881.672-.792.088-2.117.107-3.022-.61zm.99-6.38a.304.304%200%201%201%20.609%200c0%20.17-.136.304-.306.304a.3.3%200%200%201%20-.303-.305zm3.077%201.581c-.197.08-.394.15-.584.159a1.246%201.246%200%200%201%20-.79-.252c-.27-.227-.463-.354-.546-.752a1.752%201.752%200%200%201%20.016-.582c.07-.324-.008-.531-.235-.72-.187-.155-.422-.196-.682-.196a.551.551%200%200%201%20-.252-.078c-.108-.055-.197-.19-.112-.356.027-.053.159-.183.19-.207.352-.201.758-.135%201.134.016.349.142.611.404.99.773.388.448.457.573.678.906.174.264.333.534.441.842.066.192-.02.35-.248.448z'%20fill='%234d6bfe'/%3e%3c/svg%3e",F_="/assets/minimax-BPMzvuL-.jpeg",B_="/assets/alibaba-TTwafVwX.svg",U_="/assets/qwen-CONDcHqt.png",W_="/assets/zhipuai-BPNAnxo-.svg",H_={"claude-":"anthropic","gpt-":"openai","o1-":"openai","o3-":"openai","deepseek-":"deepseek",MiniMax:"minimax",qwen:"qwen","glm-":"zhipuai"};function Z_(e){if(e===null)return"unknown";const t=e.toLowerCase();for(const[n,r]of Object.entries(H_))if(t.startsWith(n.toLowerCase()))return r;return"unknown"}const Nn={width:24,height:24,objectFit:"contain"},V_=rt.memo(({className:e})=>s.jsx("img",{src:L_,alt:"Anthropic",className:e,style:Nn})),q_=rt.memo(({className:e})=>s.jsx("img",{src:D_,alt:"OpenAI",className:e,style:{...Nn,background:"white",borderRadius:"4px"}})),G_=rt.memo(({className:e})=>s.jsx("img",{src:$_,alt:"DeepSeek",className:e,style:Nn})),K_=rt.memo(({className:e})=>s.jsx("img",{src:F_,alt:"MiniMax",className:e,style:Nn})),J_=rt.memo(({className:e})=>s.jsx("img",{src:B_,alt:"Alibaba",className:e,style:Nn})),Y_=rt.memo(({className:e})=>s.jsx("img",{src:U_,alt:"Qwen",className:e,style:Nn})),X_=rt.memo(({className:e})=>s.jsx("img",{src:W_,alt:"ZhipuAI",className:e,style:Nn}));function Q_({provider:e,className:t}){switch(e){case"anthropic":return s.jsx(V_,{className:t});case"openai":return s.jsx(q_,{className:t});case"deepseek":return s.jsx(G_,{className:t});case"minimax":return s.jsx(K_,{className:t});case"alibaba":return s.jsx(J_,{className:t});case"qwen":return s.jsx(Y_,{className:t});case"zhipuai":return s.jsx(X_,{className:t});case"unknown":return null}}var Mf=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"}),ej="VisuallyHidden",Lf=p.forwardRef((e,t)=>s.jsx(Ae.span,{...e,ref:t,style:{...Mf,...e.style}}));Lf.displayName=ej;var tj=Lf;function Df(e){const t=e+"CollectionProvider",[n,r]=Zt(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=g=>{const{scope:x,children:b}=g,y=rt.useRef(null),_=rt.useRef(new Map).current;return s.jsx(o,{scope:x,itemMap:_,collectionRef:y,children:b})};a.displayName=t;const l=e+"CollectionSlot",c=Gn(l),u=rt.forwardRef((g,x)=>{const{scope:b,children:y}=g,_=i(l,b),j=Oe(x,_.collectionRef);return s.jsx(c,{ref:j,children:y})});u.displayName=l;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=Gn(d),m=rt.forwardRef((g,x)=>{const{scope:b,children:y,..._}=g,j=rt.useRef(null),S=Oe(x,j),T=i(d,b);return rt.useEffect(()=>(T.itemMap.set(j,{ref:j,..._}),()=>{T.itemMap.delete(j)})),s.jsx(h,{[f]:"",ref:S,children:y})});m.displayName=d;function v(g){const x=i(e+"CollectionConsumer",g);return rt.useCallback(()=>{const y=x.collectionRef.current;if(!y)return[];const _=Array.from(y.querySelectorAll(`[${f}]`));return Array.from(x.itemMap.values()).sort((T,C)=>_.indexOf(T.ref.current)-_.indexOf(C.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:a,Slot:u,ItemSlot:m},v,r]}var go="Collapsible",[nj]=Zt(go),[rj,Da]=nj(go),$f=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:i,onOpenChange:a,...l}=e,[c,u]=bn({prop:r,defaultProp:o??!1,onChange:a,caller:go});return s.jsx(rj,{scope:n,disabled:i,contentId:At(),open:c,onOpenToggle:p.useCallback(()=>u(d=>!d),[u]),children:s.jsx(Ae.div,{"data-state":Fa(c),"data-disabled":i?"":void 0,...l,ref:t})})});$f.displayName=go;var Ff="CollapsibleTrigger",Bf=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=Da(Ff,n);return s.jsx(Ae.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":Fa(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:Ce(e.onClick,o.onOpenToggle)})});Bf.displayName=Ff;var $a="CollapsibleContent",Uf=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Da($a,e.__scopeCollapsible);return s.jsx(gt,{present:n||o.open,children:({present:i})=>s.jsx(sj,{...r,ref:t,present:i})})});Uf.displayName=$a;var sj=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...i}=e,a=Da($a,n),[l,c]=p.useState(r),u=p.useRef(null),d=Oe(t,u),f=p.useRef(0),h=f.current,m=p.useRef(0),v=m.current,g=a.open||l,x=p.useRef(g),b=p.useRef(void 0);return p.useEffect(()=>{const y=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(y)},[]),Ye(()=>{const y=u.current;if(y){b.current=b.current||{transitionDuration:y.style.transitionDuration,animationName:y.style.animationName},y.style.transitionDuration="0s",y.style.animationName="none";const _=y.getBoundingClientRect();f.current=_.height,m.current=_.width,x.current||(y.style.transitionDuration=b.current.transitionDuration,y.style.animationName=b.current.animationName),c(r)}},[a.open,r]),s.jsx(Ae.div,{"data-state":Fa(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!g,...i,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":v?`${v}px`:void 0,...e.style},children:g&&o})});function Fa(e){return e?"open":"closed"}var oj=$f,ij=p.createContext(void 0);function xo(e){const t=p.useContext(ij);return e||t||"ltr"}function aj(e){const t=p.useRef({value:e,previous:e});return p.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function lj(e){const[t,n]=p.useState(void 0);return Ye(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let a,l;if("borderBoxSize"in i){const c=i.borderBoxSize,u=Array.isArray(c)?c[0]:c;a=u.inlineSize,l=u.blockSize}else a=e.offsetWidth,l=e.offsetHeight;n({width:a,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}const cj=["top","right","bottom","left"],nn=Math.min,it=Math.max,Ds=Math.round,ss=Math.floor,Rt=e=>({x:e,y:e}),uj={left:"right",right:"left",bottom:"top",top:"bottom"},dj={start:"end",end:"start"};function Ti(e,t,n){return it(e,nn(t,n))}function Ut(e,t){return typeof e=="function"?e(t):e}function Wt(e){return e.split("-")[0]}function nr(e){return e.split("-")[1]}function Ba(e){return e==="x"?"y":"x"}function Ua(e){return e==="y"?"height":"width"}const fj=new Set(["top","bottom"]);function Et(e){return fj.has(Wt(e))?"y":"x"}function Wa(e){return Ba(Et(e))}function pj(e,t,n){n===void 0&&(n=!1);const r=nr(e),o=Wa(e),i=Ua(o);let a=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=$s(a)),[a,$s(a)]}function hj(e){const t=$s(e);return[Ei(e),t,Ei(t)]}function Ei(e){return e.replace(/start|end/g,t=>dj[t])}const fc=["left","right"],pc=["right","left"],mj=["top","bottom"],gj=["bottom","top"];function xj(e,t,n){switch(e){case"top":case"bottom":return n?t?pc:fc:t?fc:pc;case"left":case"right":return t?mj:gj;default:return[]}}function bj(e,t,n,r){const o=nr(e);let i=xj(Wt(e),n==="start",r);return o&&(i=i.map(a=>a+"-"+o),t&&(i=i.concat(i.map(Ei)))),i}function $s(e){return e.replace(/left|right|bottom|top/g,t=>uj[t])}function vj(e){return{top:0,right:0,bottom:0,left:0,...e}}function Wf(e){return typeof e!="number"?vj(e):{top:e,right:e,bottom:e,left:e}}function Fs(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function hc(e,t,n){let{reference:r,floating:o}=e;const i=Et(t),a=Wa(t),l=Ua(a),c=Wt(t),u=i==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[l]/2-o[l]/2;let m;switch(c){case"top":m={x:d,y:r.y-o.height};break;case"bottom":m={x:d,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:f};break;case"left":m={x:r.x-o.width,y:f};break;default:m={x:r.x,y:r.y}}switch(nr(t)){case"start":m[a]-=h*(n&&u?-1:1);break;case"end":m[a]+=h*(n&&u?-1:1);break}return m}async function yj(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:i,rects:a,elements:l,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:m=0}=Ut(t,e),v=Wf(m),x=l[h?f==="floating"?"reference":"floating":f],b=Fs(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(x)))==null||n?x:x.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:u,rootBoundary:d,strategy:c})),y=f==="floating"?{x:r,y:o,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),j=await(i.isElement==null?void 0:i.isElement(_))?await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1}:{x:1,y:1},S=Fs(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:y,offsetParent:_,strategy:c}):y);return{top:(b.top-S.top+v.top)/j.y,bottom:(S.bottom-b.bottom+v.bottom)/j.y,left:(b.left-S.left+v.left)/j.x,right:(S.right-b.right+v.right)/j.x}}const wj=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:a}=n,l=i.filter(Boolean),c=await(a.isRTL==null?void 0:a.isRTL(t));let u=await a.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=hc(u,r,c),h=r,m={},v=0;for(let x=0;x<l.length;x++){var g;const{name:b,fn:y}=l[x],{x:_,y:j,data:S,reset:T}=await y({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:m,rects:u,platform:{...a,detectOverflow:(g=a.detectOverflow)!=null?g:yj},elements:{reference:e,floating:t}});d=_??d,f=j??f,m={...m,[b]:{...m[b],...S}},T&&v<=50&&(v++,typeof T=="object"&&(T.placement&&(h=T.placement),T.rects&&(u=T.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:o}):T.rects),{x:d,y:f}=hc(u,h,c)),x=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:m}},kj=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:i,platform:a,elements:l,middlewareData:c}=t,{element:u,padding:d=0}=Ut(e,t)||{};if(u==null)return{};const f=Wf(d),h={x:n,y:r},m=Wa(o),v=Ua(m),g=await a.getDimensions(u),x=m==="y",b=x?"top":"left",y=x?"bottom":"right",_=x?"clientHeight":"clientWidth",j=i.reference[v]+i.reference[m]-h[m]-i.floating[v],S=h[m]-i.reference[m],T=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let C=T?T[_]:0;(!C||!await(a.isElement==null?void 0:a.isElement(T)))&&(C=l.floating[_]||i.floating[v]);const A=j/2-S/2,E=C/2-g[v]/2-1,P=nn(f[b],E),J=nn(f[y],E),R=P,F=C-g[v]-J,k=C/2-g[v]/2+A,M=Ti(R,k,F),Y=!c.arrow&&nr(o)!=null&&k!==M&&i.reference[v]/2-(k<R?P:J)-g[v]/2<0,D=Y?k<R?k-R:k-F:0;return{[m]:h[m]+D,data:{[m]:M,centerOffset:k-M-D,...Y&&{alignmentOffset:D}},reset:Y}}}),_j=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:i,rects:a,initialPlacement:l,platform:c,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=Ut(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const b=Wt(o),y=Et(l),_=Wt(l)===l,j=await(c.isRTL==null?void 0:c.isRTL(u.floating)),S=h||(_||!g?[$s(l)]:hj(l)),T=v!=="none";!h&&T&&S.push(...bj(l,g,v,j));const C=[l,...S],A=await c.detectOverflow(t,x),E=[];let P=((r=i.flip)==null?void 0:r.overflows)||[];if(d&&E.push(A[b]),f){const k=pj(o,a,j);E.push(A[k[0]],A[k[1]])}if(P=[...P,{placement:o,overflows:E}],!E.every(k=>k<=0)){var J,R;const k=(((J=i.flip)==null?void 0:J.index)||0)+1,M=C[k];if(M&&(!(f==="alignment"?y!==Et(M):!1)||P.every(B=>Et(B.placement)===y?B.overflows[0]>0:!0)))return{data:{index:k,overflows:P},reset:{placement:M}};let Y=(R=P.filter(D=>D.overflows[0]<=0).sort((D,B)=>D.overflows[1]-B.overflows[1])[0])==null?void 0:R.placement;if(!Y)switch(m){case"bestFit":{var F;const D=(F=P.filter(B=>{if(T){const U=Et(B.placement);return U===y||U==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(U=>U>0).reduce((U,ie)=>U+ie,0)]).sort((B,U)=>B[1]-U[1])[0])==null?void 0:F[0];D&&(Y=D);break}case"initialPlacement":Y=l;break}if(o!==Y)return{reset:{placement:Y}}}return{}}}};function mc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function gc(e){return cj.some(t=>e[t]>=0)}const jj=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:o="referenceHidden",...i}=Ut(e,t);switch(o){case"referenceHidden":{const a=await r.detectOverflow(t,{...i,elementContext:"reference"}),l=mc(a,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:gc(l)}}}case"escaped":{const a=await r.detectOverflow(t,{...i,altBoundary:!0}),l=mc(a,n.floating);return{data:{escapedOffsets:l,escaped:gc(l)}}}default:return{}}}}},Hf=new Set(["left","top"]);async function Sj(e,t){const{placement:n,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),a=Wt(n),l=nr(n),c=Et(n)==="y",u=Hf.has(a)?-1:1,d=i&&c?-1:1,f=Ut(t,e);let{mainAxis:h,crossAxis:m,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof v=="number"&&(m=l==="end"?v*-1:v),c?{x:m*d,y:h*u}:{x:h*u,y:m*d}}const Cj=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:a,middlewareData:l}=t,c=await Sj(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:i+c.y,data:{...c,placement:a}}}}},Nj=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o,platform:i}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:c={fn:b=>{let{x:y,y:_}=b;return{x:y,y:_}}},...u}=Ut(e,t),d={x:n,y:r},f=await i.detectOverflow(t,u),h=Et(Wt(o)),m=Ba(h);let v=d[m],g=d[h];if(a){const b=m==="y"?"top":"left",y=m==="y"?"bottom":"right",_=v+f[b],j=v-f[y];v=Ti(_,v,j)}if(l){const b=h==="y"?"top":"left",y=h==="y"?"bottom":"right",_=g+f[b],j=g-f[y];g=Ti(_,g,j)}const x=c.fn({...t,[m]:v,[h]:g});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[m]:a,[h]:l}}}}}},Tj=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:i,middlewareData:a}=t,{offset:l=0,mainAxis:c=!0,crossAxis:u=!0}=Ut(e,t),d={x:n,y:r},f=Et(o),h=Ba(f);let m=d[h],v=d[f];const g=Ut(l,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(c){const _=h==="y"?"height":"width",j=i.reference[h]-i.floating[_]+x.mainAxis,S=i.reference[h]+i.reference[_]-x.mainAxis;m<j?m=j:m>S&&(m=S)}if(u){var b,y;const _=h==="y"?"width":"height",j=Hf.has(Wt(o)),S=i.reference[f]-i.floating[_]+(j&&((b=a.offset)==null?void 0:b[f])||0)+(j?0:x.crossAxis),T=i.reference[f]+i.reference[_]+(j?0:((y=a.offset)==null?void 0:y[f])||0)-(j?x.crossAxis:0);v<S?v=S:v>T&&(v=T)}return{[h]:m,[f]:v}}}},Ej=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:i,platform:a,elements:l}=t,{apply:c=()=>{},...u}=Ut(e,t),d=await a.detectOverflow(t,u),f=Wt(o),h=nr(o),m=Et(o)==="y",{width:v,height:g}=i.floating;let x,b;f==="top"||f==="bottom"?(x=f,b=h===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(b=f,x=h==="end"?"top":"bottom");const y=g-d.top-d.bottom,_=v-d.left-d.right,j=nn(g-d[x],y),S=nn(v-d[b],_),T=!t.middlewareData.shift;let C=j,A=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=_),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=y),T&&!h){const P=it(d.left,0),J=it(d.right,0),R=it(d.top,0),F=it(d.bottom,0);m?A=v-2*(P!==0||J!==0?P+J:it(d.left,d.right)):C=g-2*(R!==0||F!==0?R+F:it(d.top,d.bottom))}await c({...t,availableWidth:A,availableHeight:C});const E=await a.getDimensions(l.floating);return v!==E.width||g!==E.height?{reset:{rects:!0}}:{}}}};function bo(){return typeof window<"u"}function rr(e){return Zf(e)?(e.nodeName||"").toLowerCase():"#document"}function lt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Pt(e){var t;return(t=(Zf(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Zf(e){return bo()?e instanceof Node||e instanceof lt(e).Node:!1}function kt(e){return bo()?e instanceof Element||e instanceof lt(e).Element:!1}function It(e){return bo()?e instanceof HTMLElement||e instanceof lt(e).HTMLElement:!1}function xc(e){return!bo()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof lt(e).ShadowRoot}const Aj=new Set(["inline","contents"]);function Lr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=_t(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Aj.has(o)}const Rj=new Set(["table","td","th"]);function Ij(e){return Rj.has(rr(e))}const zj=[":popover-open",":modal"];function vo(e){return zj.some(t=>{try{return e.matches(t)}catch{return!1}})}const Oj=["transform","translate","scale","rotate","perspective"],Pj=["transform","translate","scale","rotate","perspective","filter"],Mj=["paint","layout","strict","content"];function Ha(e){const t=Za(),n=kt(e)?_t(e):e;return Oj.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||Pj.some(r=>(n.willChange||"").includes(r))||Mj.some(r=>(n.contain||"").includes(r))}function Lj(e){let t=rn(e);for(;It(t)&&!Kn(t);){if(Ha(t))return t;if(vo(t))return null;t=rn(t)}return null}function Za(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Dj=new Set(["html","body","#document"]);function Kn(e){return Dj.has(rr(e))}function _t(e){return lt(e).getComputedStyle(e)}function yo(e){return kt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function rn(e){if(rr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||xc(e)&&e.host||Pt(e);return xc(t)?t.host:t}function Vf(e){const t=rn(e);return Kn(t)?e.ownerDocument?e.ownerDocument.body:e.body:It(t)&&Lr(t)?t:Vf(t)}function Sr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Vf(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),a=lt(o);if(i){const l=Ai(a);return t.concat(a,a.visualViewport||[],Lr(o)?o:[],l&&n?Sr(l):[])}return t.concat(o,Sr(o,[],n))}function Ai(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function qf(e){const t=_t(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=It(e),i=o?e.offsetWidth:n,a=o?e.offsetHeight:r,l=Ds(n)!==i||Ds(r)!==a;return l&&(n=i,r=a),{width:n,height:r,$:l}}function Va(e){return kt(e)?e:e.contextElement}function Bn(e){const t=Va(e);if(!It(t))return Rt(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=qf(t);let a=(i?Ds(n.width):n.width)/r,l=(i?Ds(n.height):n.height)/o;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const $j=Rt(0);function Gf(e){const t=lt(e);return!Za()||!t.visualViewport?$j:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Fj(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==lt(e)?!1:t}function yn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=Va(e);let a=Rt(1);t&&(r?kt(r)&&(a=Bn(r)):a=Bn(e));const l=Fj(i,n,r)?Gf(i):Rt(0);let c=(o.left+l.x)/a.x,u=(o.top+l.y)/a.y,d=o.width/a.x,f=o.height/a.y;if(i){const h=lt(i),m=r&&kt(r)?lt(r):r;let v=h,g=Ai(v);for(;g&&r&&m!==v;){const x=Bn(g),b=g.getBoundingClientRect(),y=_t(g),_=b.left+(g.clientLeft+parseFloat(y.paddingLeft))*x.x,j=b.top+(g.clientTop+parseFloat(y.paddingTop))*x.y;c*=x.x,u*=x.y,d*=x.x,f*=x.y,c+=_,u+=j,v=lt(g),g=Ai(v)}}return Fs({width:d,height:f,x:c,y:u})}function wo(e,t){const n=yo(e).scrollLeft;return t?t.left+n:yn(Pt(e)).left+n}function Kf(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-wo(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Bj(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i=o==="fixed",a=Pt(r),l=t?vo(t.floating):!1;if(r===a||l&&i)return n;let c={scrollLeft:0,scrollTop:0},u=Rt(1);const d=Rt(0),f=It(r);if((f||!f&&!i)&&((rr(r)!=="body"||Lr(a))&&(c=yo(r)),It(r))){const m=yn(r);u=Bn(r),d.x=m.x+r.clientLeft,d.y=m.y+r.clientTop}const h=a&&!f&&!i?Kf(a,c):Rt(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-c.scrollTop*u.y+d.y+h.y}}function Uj(e){return Array.from(e.getClientRects())}function Wj(e){const t=Pt(e),n=yo(e),r=e.ownerDocument.body,o=it(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=it(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+wo(e);const l=-n.scrollTop;return _t(r).direction==="rtl"&&(a+=it(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:a,y:l}}const bc=25;function Hj(e,t){const n=lt(e),r=Pt(e),o=n.visualViewport;let i=r.clientWidth,a=r.clientHeight,l=0,c=0;if(o){i=o.width,a=o.height;const d=Za();(!d||d&&t==="fixed")&&(l=o.offsetLeft,c=o.offsetTop)}const u=wo(r);if(u<=0){const d=r.ownerDocument,f=d.body,h=getComputedStyle(f),m=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,v=Math.abs(r.clientWidth-f.clientWidth-m);v<=bc&&(i-=v)}else u<=bc&&(i+=u);return{width:i,height:a,x:l,y:c}}const Zj=new Set(["absolute","fixed"]);function Vj(e,t){const n=yn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=It(e)?Bn(e):Rt(1),a=e.clientWidth*i.x,l=e.clientHeight*i.y,c=o*i.x,u=r*i.y;return{width:a,height:l,x:c,y:u}}function vc(e,t,n){let r;if(t==="viewport")r=Hj(e,n);else if(t==="document")r=Wj(Pt(e));else if(kt(t))r=Vj(t,n);else{const o=Gf(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Fs(r)}function Jf(e,t){const n=rn(e);return n===t||!kt(n)||Kn(n)?!1:_t(n).position==="fixed"||Jf(n,t)}function qj(e,t){const n=t.get(e);if(n)return n;let r=Sr(e,[],!1).filter(l=>kt(l)&&rr(l)!=="body"),o=null;const i=_t(e).position==="fixed";let a=i?rn(e):e;for(;kt(a)&&!Kn(a);){const l=_t(a),c=Ha(a);!c&&l.position==="fixed"&&(o=null),(i?!c&&!o:!c&&l.position==="static"&&!!o&&Zj.has(o.position)||Lr(a)&&!c&&Jf(e,a))?r=r.filter(d=>d!==a):o=l,a=rn(a)}return t.set(e,r),r}function Gj(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const a=[...n==="clippingAncestors"?vo(t)?[]:qj(t,this._c):[].concat(n),r],l=a[0],c=a.reduce((u,d)=>{const f=vc(t,d,o);return u.top=it(f.top,u.top),u.right=nn(f.right,u.right),u.bottom=nn(f.bottom,u.bottom),u.left=it(f.left,u.left),u},vc(t,l,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Kj(e){const{width:t,height:n}=qf(e);return{width:t,height:n}}function Jj(e,t,n){const r=It(t),o=Pt(t),i=n==="fixed",a=yn(e,!0,i,t);let l={scrollLeft:0,scrollTop:0};const c=Rt(0);function u(){c.x=wo(o)}if(r||!r&&!i)if((rr(t)!=="body"||Lr(o))&&(l=yo(t)),r){const m=yn(t,!0,i,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}else o&&u();i&&!r&&o&&u();const d=o&&!r&&!i?Kf(o,l):Rt(0),f=a.left+l.scrollLeft-c.x-d.x,h=a.top+l.scrollTop-c.y-d.y;return{x:f,y:h,width:a.width,height:a.height}}function Ko(e){return _t(e).position==="static"}function yc(e,t){if(!It(e)||_t(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Pt(e)===n&&(n=n.ownerDocument.body),n}function Yf(e,t){const n=lt(e);if(vo(e))return n;if(!It(e)){let o=rn(e);for(;o&&!Kn(o);){if(kt(o)&&!Ko(o))return o;o=rn(o)}return n}let r=yc(e,t);for(;r&&Ij(r)&&Ko(r);)r=yc(r,t);return r&&Kn(r)&&Ko(r)&&!Ha(r)?n:r||Lj(e)||n}const Yj=async function(e){const t=this.getOffsetParent||Yf,n=this.getDimensions,r=await n(e.floating);return{reference:Jj(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Xj(e){return _t(e).direction==="rtl"}const Qj={convertOffsetParentRelativeRectToViewportRelativeRect:Bj,getDocumentElement:Pt,getClippingRect:Gj,getOffsetParent:Yf,getElementRects:Yj,getClientRects:Uj,getDimensions:Kj,getScale:Bn,isElement:kt,isRTL:Xj};function Xf(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function eS(e,t){let n=null,r;const o=Pt(e);function i(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function a(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),i();const u=e.getBoundingClientRect(),{left:d,top:f,width:h,height:m}=u;if(l||t(),!h||!m)return;const v=ss(f),g=ss(o.clientWidth-(d+h)),x=ss(o.clientHeight-(f+m)),b=ss(d),_={rootMargin:-v+"px "+-g+"px "+-x+"px "+-b+"px",threshold:it(0,nn(1,c))||1};let j=!0;function S(T){const C=T[0].intersectionRatio;if(C!==c){if(!j)return a();C?a(!1,C):r=setTimeout(()=>{a(!1,1e-7)},1e3)}C===1&&!Xf(u,e.getBoundingClientRect())&&a(),j=!1}try{n=new IntersectionObserver(S,{..._,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,_)}n.observe(e)}return a(!0),i}function tS(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=Va(e),d=o||i?[...u?Sr(u):[],...Sr(t)]:[];d.forEach(b=>{o&&b.addEventListener("scroll",n,{passive:!0}),i&&b.addEventListener("resize",n)});const f=u&&l?eS(u,n):null;let h=-1,m=null;a&&(m=new ResizeObserver(b=>{let[y]=b;y&&y.target===u&&m&&(m.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var _;(_=m)==null||_.observe(t)})),n()}),u&&!c&&m.observe(u),m.observe(t));let v,g=c?yn(e):null;c&&x();function x(){const b=yn(e);g&&!Xf(g,b)&&n(),g=b,v=requestAnimationFrame(x)}return n(),()=>{var b;d.forEach(y=>{o&&y.removeEventListener("scroll",n),i&&y.removeEventListener("resize",n)}),f?.(),(b=m)==null||b.disconnect(),m=null,c&&cancelAnimationFrame(v)}}const nS=Cj,rS=Nj,sS=_j,oS=Ej,iS=jj,wc=kj,aS=Tj,lS=(e,t,n)=>{const r=new Map,o={platform:Qj,...n},i={...o.platform,_c:r};return wj(e,t,{...o,platform:i})};var cS=typeof document<"u",uS=function(){},_s=cS?p.useLayoutEffect:uS;function Bs(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Bs(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const i=o[r];if(!(i==="_owner"&&e.$$typeof)&&!Bs(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function Qf(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function kc(e,t){const n=Qf(e);return Math.round(t*n)/n}function Jo(e){const t=p.useRef(e);return _s(()=>{t.current=e}),t}function dS(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:a}={},transform:l=!0,whileElementsMounted:c,open:u}=e,[d,f]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,m]=p.useState(r);Bs(h,r)||m(r);const[v,g]=p.useState(null),[x,b]=p.useState(null),y=p.useCallback(B=>{B!==T.current&&(T.current=B,g(B))},[]),_=p.useCallback(B=>{B!==C.current&&(C.current=B,b(B))},[]),j=i||v,S=a||x,T=p.useRef(null),C=p.useRef(null),A=p.useRef(d),E=c!=null,P=Jo(c),J=Jo(o),R=Jo(u),F=p.useCallback(()=>{if(!T.current||!C.current)return;const B={placement:t,strategy:n,middleware:h};J.current&&(B.platform=J.current),lS(T.current,C.current,B).then(U=>{const ie={...U,isPositioned:R.current!==!1};k.current&&!Bs(A.current,ie)&&(A.current=ie,Ar.flushSync(()=>{f(ie)}))})},[h,t,n,J,R]);_s(()=>{u===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,f(B=>({...B,isPositioned:!1})))},[u]);const k=p.useRef(!1);_s(()=>(k.current=!0,()=>{k.current=!1}),[]),_s(()=>{if(j&&(T.current=j),S&&(C.current=S),j&&S){if(P.current)return P.current(j,S,F);F()}},[j,S,F,P,E]);const M=p.useMemo(()=>({reference:T,floating:C,setReference:y,setFloating:_}),[y,_]),Y=p.useMemo(()=>({reference:j,floating:S}),[j,S]),D=p.useMemo(()=>{const B={position:n,left:0,top:0};if(!Y.floating)return B;const U=kc(Y.floating,d.x),ie=kc(Y.floating,d.y);return l?{...B,transform:"translate("+U+"px, "+ie+"px)",...Qf(Y.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:U,top:ie}},[n,l,Y.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:F,refs:M,elements:Y,floatingStyles:D}),[d,F,M,Y,D])}const fS=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?wc({element:r.current,padding:o}).fn(n):{}:r?wc({element:r,padding:o}).fn(n):{}}}},pS=(e,t)=>({...nS(e),options:[e,t]}),hS=(e,t)=>({...rS(e),options:[e,t]}),mS=(e,t)=>({...aS(e),options:[e,t]}),gS=(e,t)=>({...sS(e),options:[e,t]}),xS=(e,t)=>({...oS(e),options:[e,t]}),bS=(e,t)=>({...iS(e),options:[e,t]}),vS=(e,t)=>({...fS(e),options:[e,t]});var yS="Arrow",ep=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...i}=e;return s.jsx(Ae.svg,{...i,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:s.jsx("polygon",{points:"0,0 30,0 15,10"})})});ep.displayName=yS;var wS=ep,qa="Popper",[tp,ko]=Zt(qa),[kS,np]=tp(qa),rp=e=>{const{__scopePopper:t,children:n}=e,[r,o]=p.useState(null);return s.jsx(kS,{scope:t,anchor:r,onAnchorChange:o,children:n})};rp.displayName=qa;var sp="PopperAnchor",op=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,i=np(sp,n),a=p.useRef(null),l=Oe(t,a),c=p.useRef(null);return p.useEffect(()=>{const u=c.current;c.current=r?.current||a.current,u!==c.current&&i.onAnchorChange(c.current)}),r?null:s.jsx(Ae.div,{...o,ref:l})});op.displayName=sp;var Ga="PopperContent",[_S,jS]=tp(Ga),ip=p.forwardRef((e,t)=>{const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:i="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:m="optimized",onPlaced:v,...g}=e,x=np(Ga,n),[b,y]=p.useState(null),_=Oe(t,ce=>y(ce)),[j,S]=p.useState(null),T=lj(j),C=T?.width??0,A=T?.height??0,E=r+(i!=="center"?"-"+i:""),P=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},J=Array.isArray(u)?u:[u],R=J.length>0,F={padding:P,boundary:J.filter(CS),altBoundary:R},{refs:k,floatingStyles:M,placement:Y,isPositioned:D,middlewareData:B}=dS({strategy:"fixed",placement:E,whileElementsMounted:(...ce)=>tS(...ce,{animationFrame:m==="always"}),elements:{reference:x.anchor},middleware:[pS({mainAxis:o+A,alignmentAxis:a}),c&&hS({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?mS():void 0,...F}),c&&gS({...F}),xS({...F,apply:({elements:ce,rects:me,availableWidth:le,availableHeight:ae})=>{const{width:re,height:pe}=me.reference,ye=ce.floating.style;ye.setProperty("--radix-popper-available-width",`${le}px`),ye.setProperty("--radix-popper-available-height",`${ae}px`),ye.setProperty("--radix-popper-anchor-width",`${re}px`),ye.setProperty("--radix-popper-anchor-height",`${pe}px`)}}),j&&vS({element:j,padding:l}),NS({arrowWidth:C,arrowHeight:A}),h&&bS({strategy:"referenceHidden",...F})]}),[U,ie]=cp(Y),W=nt(v);Ye(()=>{D&&W?.()},[D,W]);const H=B.arrow?.x,ue=B.arrow?.y,ne=B.arrow?.centerOffset!==0,[se,je]=p.useState();return Ye(()=>{b&&je(window.getComputedStyle(b).zIndex)},[b]),s.jsx("div",{ref:k.setFloating,"data-radix-popper-content-wrapper":"",style:{...M,transform:D?M.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:se,"--radix-popper-transform-origin":[B.transformOrigin?.x,B.transformOrigin?.y].join(" "),...B.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:s.jsx(_S,{scope:n,placedSide:U,onArrowChange:S,arrowX:H,arrowY:ue,shouldHideArrow:ne,children:s.jsx(Ae.div,{"data-side":U,"data-align":ie,...g,ref:_,style:{...g.style,animation:D?void 0:"none"}})})})});ip.displayName=Ga;var ap="PopperArrow",SS={top:"bottom",right:"left",bottom:"top",left:"right"},lp=p.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,i=jS(ap,r),a=SS[i.placedSide];return s.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:s.jsx(wS,{...o,ref:n,style:{...o.style,display:"block"}})})});lp.displayName=ap;function CS(e){return e!==null}var NS=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:o}=t,a=o.arrow?.centerOffset!==0,l=a?0:e.arrowWidth,c=a?0:e.arrowHeight,[u,d]=cp(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(o.arrow?.x??0)+l/2,m=(o.arrow?.y??0)+c/2;let v="",g="";return u==="bottom"?(v=a?f:`${h}px`,g=`${-c}px`):u==="top"?(v=a?f:`${h}px`,g=`${r.floating.height+c}px`):u==="right"?(v=`${-c}px`,g=a?f:`${m}px`):u==="left"&&(v=`${r.floating.width+c}px`,g=a?f:`${m}px`),{data:{x:v,y:g}}}});function cp(e){const[t,n="center"]=e.split("-");return[t,n]}var up=rp,dp=op,fp=ip,pp=lp,Yo="rovingFocusGroup.onEntryFocus",TS={bubbles:!1,cancelable:!0},Dr="RovingFocusGroup",[Ri,hp,ES]=Df(Dr),[AS,mp]=Zt(Dr,[ES]),[RS,IS]=AS(Dr),gp=p.forwardRef((e,t)=>s.jsx(Ri.Provider,{scope:e.__scopeRovingFocusGroup,children:s.jsx(Ri.Slot,{scope:e.__scopeRovingFocusGroup,children:s.jsx(zS,{...e,ref:t})})}));gp.displayName=Dr;var zS=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:a,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,h=p.useRef(null),m=Oe(t,h),v=xo(i),[g,x]=bn({prop:a,defaultProp:l??null,onChange:c,caller:Dr}),[b,y]=p.useState(!1),_=nt(u),j=hp(n),S=p.useRef(!1),[T,C]=p.useState(0);return p.useEffect(()=>{const A=h.current;if(A)return A.addEventListener(Yo,_),()=>A.removeEventListener(Yo,_)},[_]),s.jsx(RS,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:p.useCallback(A=>x(A),[x]),onItemShiftTab:p.useCallback(()=>y(!0),[]),onFocusableItemAdd:p.useCallback(()=>C(A=>A+1),[]),onFocusableItemRemove:p.useCallback(()=>C(A=>A-1),[]),children:s.jsx(Ae.div,{tabIndex:b||T===0?-1:0,"data-orientation":r,...f,ref:m,style:{outline:"none",...e.style},onMouseDown:Ce(e.onMouseDown,()=>{S.current=!0}),onFocus:Ce(e.onFocus,A=>{const E=!S.current;if(A.target===A.currentTarget&&E&&!b){const P=new CustomEvent(Yo,TS);if(A.currentTarget.dispatchEvent(P),!P.defaultPrevented){const J=j().filter(Y=>Y.focusable),R=J.find(Y=>Y.active),F=J.find(Y=>Y.id===g),M=[R,F,...J].filter(Boolean).map(Y=>Y.ref.current);vp(M,d)}}S.current=!1}),onBlur:Ce(e.onBlur,()=>y(!1))})})}),xp="RovingFocusGroupItem",bp=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,children:a,...l}=e,c=At(),u=i||c,d=IS(xp,n),f=d.currentTabStopId===u,h=hp(n),{onFocusableItemAdd:m,onFocusableItemRemove:v,currentTabStopId:g}=d;return p.useEffect(()=>{if(r)return m(),()=>v()},[r,m,v]),s.jsx(Ri.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:s.jsx(Ae.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...l,ref:t,onMouseDown:Ce(e.onMouseDown,x=>{r?d.onItemFocus(u):x.preventDefault()}),onFocus:Ce(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:Ce(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const b=MS(x,d.orientation,d.dir);if(b!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let _=h().filter(j=>j.focusable).map(j=>j.ref.current);if(b==="last")_.reverse();else if(b==="prev"||b==="next"){b==="prev"&&_.reverse();const j=_.indexOf(x.currentTarget);_=d.loop?LS(_,j+1):_.slice(j+1)}setTimeout(()=>vp(_))}}),children:typeof a=="function"?a({isCurrentTabStop:f,hasTabStop:g!=null}):a})})});bp.displayName=xp;var OS={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function PS(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function MS(e,t,n){const r=PS(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return OS[r]}function vp(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function LS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var DS=gp,$S=bp;function Ii(e,[t,n]){return Math.min(n,Math.max(t,e))}function FS(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Ka="ScrollArea",[yp]=Zt(Ka),[BS,xt]=yp(Ka),wp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:i=600,...a}=e,[l,c]=p.useState(null),[u,d]=p.useState(null),[f,h]=p.useState(null),[m,v]=p.useState(null),[g,x]=p.useState(null),[b,y]=p.useState(0),[_,j]=p.useState(0),[S,T]=p.useState(!1),[C,A]=p.useState(!1),E=Oe(t,J=>c(J)),P=xo(o);return s.jsx(BS,{scope:n,type:r,dir:P,scrollHideDelay:i,scrollArea:l,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:m,onScrollbarXChange:v,scrollbarXEnabled:S,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:C,onScrollbarYEnabledChange:A,onCornerWidthChange:y,onCornerHeightChange:j,children:s.jsx(Ae.div,{dir:P,...a,ref:E,style:{position:"relative","--radix-scroll-area-corner-width":b+"px","--radix-scroll-area-corner-height":_+"px",...e.style}})})});wp.displayName=Ka;var kp="ScrollAreaViewport",_p=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...i}=e,a=xt(kp,n),l=p.useRef(null),c=Oe(t,l,a.onViewportChange);return s.jsxs(s.Fragment,{children:[s.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),s.jsx(Ae.div,{"data-radix-scroll-area-viewport":"",...i,ref:c,style:{overflowX:a.scrollbarXEnabled?"scroll":"hidden",overflowY:a.scrollbarYEnabled?"scroll":"hidden",...e.style},children:s.jsx("div",{ref:a.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});_p.displayName=kp;var Mt="ScrollAreaScrollbar",jp=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=xt(Mt,e.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:a}=o,l=e.orientation==="horizontal";return p.useEffect(()=>(l?i(!0):a(!0),()=>{l?i(!1):a(!1)}),[l,i,a]),o.type==="hover"?s.jsx(US,{...r,ref:t,forceMount:n}):o.type==="scroll"?s.jsx(WS,{...r,ref:t,forceMount:n}):o.type==="auto"?s.jsx(Sp,{...r,ref:t,forceMount:n}):o.type==="always"?s.jsx(Ja,{...r,ref:t}):null});jp.displayName=Mt;var US=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=xt(Mt,e.__scopeScrollArea),[i,a]=p.useState(!1);return p.useEffect(()=>{const l=o.scrollArea;let c=0;if(l){const u=()=>{window.clearTimeout(c),a(!0)},d=()=>{c=window.setTimeout(()=>a(!1),o.scrollHideDelay)};return l.addEventListener("pointerenter",u),l.addEventListener("pointerleave",d),()=>{window.clearTimeout(c),l.removeEventListener("pointerenter",u),l.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),s.jsx(gt,{present:n||i,children:s.jsx(Sp,{"data-state":i?"visible":"hidden",...r,ref:t})})}),WS=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=xt(Mt,e.__scopeScrollArea),i=e.orientation==="horizontal",a=jo(()=>c("SCROLL_END"),100),[l,c]=FS("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return p.useEffect(()=>{if(l==="idle"){const u=window.setTimeout(()=>c("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[l,o.scrollHideDelay,c]),p.useEffect(()=>{const u=o.viewport,d=i?"scrollLeft":"scrollTop";if(u){let f=u[d];const h=()=>{const m=u[d];f!==m&&(c("SCROLL"),a()),f=m};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,i,c,a]),s.jsx(gt,{present:n||l!=="hidden",children:s.jsx(Ja,{"data-state":l==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:Ce(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:Ce(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),Sp=p.forwardRef((e,t)=>{const n=xt(Mt,e.__scopeScrollArea),{forceMount:r,...o}=e,[i,a]=p.useState(!1),l=e.orientation==="horizontal",c=jo(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;a(l?u:d)}},10);return Jn(n.viewport,c),Jn(n.content,c),s.jsx(gt,{present:r||i,children:s.jsx(Ja,{"data-state":i?"visible":"hidden",...o,ref:t})})}),Ja=p.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=xt(Mt,e.__scopeScrollArea),i=p.useRef(null),a=p.useRef(0),[l,c]=p.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=Ap(l.viewport,l.content),d={...r,sizes:l,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:h=>i.current=h,onThumbPointerUp:()=>a.current=0,onThumbPointerDown:h=>a.current=h};function f(h,m){return KS(h,a.current,l,m)}return n==="horizontal"?s.jsx(HS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const h=o.viewport.scrollLeft,m=_c(h,l,o.dir);i.current.style.transform=`translate3d(${m}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?s.jsx(ZS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const h=o.viewport.scrollTop,m=_c(h,l);i.current.style.transform=`translate3d(0, ${m}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),HS=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,i=xt(Mt,e.__scopeScrollArea),[a,l]=p.useState(),c=p.useRef(null),u=Oe(t,c,i.onScrollbarXChange);return p.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),s.jsx(Np,{"data-orientation":"horizontal",...o,ref:u,sizes:n,style:{bottom:0,left:i.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:i.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":_o(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(i.viewport){const h=i.viewport.scrollLeft+d.deltaX;e.onWheelScroll(h),Ip(h,f)&&d.preventDefault()}},onResize:()=>{c.current&&i.viewport&&a&&r({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Ws(a.paddingLeft),paddingEnd:Ws(a.paddingRight)}})}})}),ZS=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,i=xt(Mt,e.__scopeScrollArea),[a,l]=p.useState(),c=p.useRef(null),u=Oe(t,c,i.onScrollbarYChange);return p.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),s.jsx(Np,{"data-orientation":"vertical",...o,ref:u,sizes:n,style:{top:0,right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":_o(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(i.viewport){const h=i.viewport.scrollTop+d.deltaY;e.onWheelScroll(h),Ip(h,f)&&d.preventDefault()}},onResize:()=>{c.current&&i.viewport&&a&&r({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Ws(a.paddingTop),paddingEnd:Ws(a.paddingBottom)}})}})}),[VS,Cp]=yp(Mt),Np=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:i,onThumbPointerUp:a,onThumbPointerDown:l,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:d,onResize:f,...h}=e,m=xt(Mt,n),[v,g]=p.useState(null),x=Oe(t,E=>g(E)),b=p.useRef(null),y=p.useRef(""),_=m.viewport,j=r.content-r.viewport,S=nt(d),T=nt(c),C=jo(f,10);function A(E){if(b.current){const P=E.clientX-b.current.left,J=E.clientY-b.current.top;u({x:P,y:J})}}return p.useEffect(()=>{const E=P=>{const J=P.target;v?.contains(J)&&S(P,j)};return document.addEventListener("wheel",E,{passive:!1}),()=>document.removeEventListener("wheel",E,{passive:!1})},[_,v,j,S]),p.useEffect(T,[r,T]),Jn(v,C),Jn(m.content,C),s.jsx(VS,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:nt(i),onThumbPointerUp:nt(a),onThumbPositionChange:T,onThumbPointerDown:nt(l),children:s.jsx(Ae.div,{...h,ref:x,style:{position:"absolute",...h.style},onPointerDown:Ce(e.onPointerDown,E=>{E.button===0&&(E.target.setPointerCapture(E.pointerId),b.current=v.getBoundingClientRect(),y.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),A(E))}),onPointerMove:Ce(e.onPointerMove,A),onPointerUp:Ce(e.onPointerUp,E=>{const P=E.target;P.hasPointerCapture(E.pointerId)&&P.releasePointerCapture(E.pointerId),document.body.style.webkitUserSelect=y.current,m.viewport&&(m.viewport.style.scrollBehavior=""),b.current=null})})})}),Us="ScrollAreaThumb",Tp=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Cp(Us,e.__scopeScrollArea);return s.jsx(gt,{present:n||o.hasThumb,children:s.jsx(qS,{ref:t,...r})})}),qS=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,i=xt(Us,n),a=Cp(Us,n),{onThumbPositionChange:l}=a,c=Oe(t,f=>a.onThumbChange(f)),u=p.useRef(void 0),d=jo(()=>{u.current&&(u.current(),u.current=void 0)},100);return p.useEffect(()=>{const f=i.viewport;if(f){const h=()=>{if(d(),!u.current){const m=JS(f,l);u.current=m,l()}};return l(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[i.viewport,d,l]),s.jsx(Ae.div,{"data-state":a.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:Ce(e.onPointerDownCapture,f=>{const m=f.target.getBoundingClientRect(),v=f.clientX-m.left,g=f.clientY-m.top;a.onThumbPointerDown({x:v,y:g})}),onPointerUp:Ce(e.onPointerUp,a.onThumbPointerUp)})});Tp.displayName=Us;var Ya="ScrollAreaCorner",Ep=p.forwardRef((e,t)=>{const n=xt(Ya,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?s.jsx(GS,{...e,ref:t}):null});Ep.displayName=Ya;var GS=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=xt(Ya,n),[i,a]=p.useState(0),[l,c]=p.useState(0),u=!!(i&&l);return Jn(o.scrollbarX,()=>{const d=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(d),c(d)}),Jn(o.scrollbarY,()=>{const d=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(d),a(d)}),u?s.jsx(Ae.div,{...r,ref:t,style:{width:i,height:l,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Ws(e){return e?parseInt(e,10):0}function Ap(e,t){const n=e/t;return isNaN(n)?0:n}function _o(e){const t=Ap(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function KS(e,t,n,r="ltr"){const o=_o(n),i=o/2,a=t||i,l=o-a,c=n.scrollbar.paddingStart+a,u=n.scrollbar.size-n.scrollbar.paddingEnd-l,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return Rp([c,u],f)(e)}function _c(e,t,n="ltr"){const r=_o(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,i=t.scrollbar.size-o,a=t.content-t.viewport,l=i-r,c=n==="ltr"?[0,a]:[a*-1,0],u=Ii(e,c);return Rp([0,a],[0,l])(u)}function Rp(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Ip(e,t){return e>0&&e<t}var JS=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return(function o(){const i={left:e.scrollLeft,top:e.scrollTop},a=n.left!==i.left,l=n.top!==i.top;(a||l)&&t(),n=i,r=window.requestAnimationFrame(o)})(),()=>window.cancelAnimationFrame(r)};function jo(e,t){const n=nt(e),r=p.useRef(0);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),p.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Jn(e,t){const n=nt(t);Ye(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var YS=wp,XS=_p,QS=Ep,eC=[" ","Enter","ArrowUp","ArrowDown"],tC=[" ","Enter"],wn="Select",[So,Co,nC]=Df(wn),[sr]=Zt(wn,[nC,ko]),No=ko(),[rC,an]=sr(wn),[sC,oC]=sr(wn),zp=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:i,value:a,defaultValue:l,onValueChange:c,dir:u,name:d,autoComplete:f,disabled:h,required:m,form:v}=e,g=No(t),[x,b]=p.useState(null),[y,_]=p.useState(null),[j,S]=p.useState(!1),T=xo(u),[C,A]=bn({prop:r,defaultProp:o??!1,onChange:i,caller:wn}),[E,P]=bn({prop:a,defaultProp:l,onChange:c,caller:wn}),J=p.useRef(null),R=x?v||!!x.closest("form"):!0,[F,k]=p.useState(new Set),M=Array.from(F).map(Y=>Y.props.value).join(";");return s.jsx(up,{...g,children:s.jsxs(rC,{required:m,scope:t,trigger:x,onTriggerChange:b,valueNode:y,onValueNodeChange:_,valueNodeHasChildren:j,onValueNodeHasChildrenChange:S,contentId:At(),value:E,onValueChange:P,open:C,onOpenChange:A,dir:T,triggerPointerDownPosRef:J,disabled:h,children:[s.jsx(So.Provider,{scope:t,children:s.jsx(sC,{scope:e.__scopeSelect,onNativeOptionAdd:p.useCallback(Y=>{k(D=>new Set(D).add(Y))},[]),onNativeOptionRemove:p.useCallback(Y=>{k(D=>{const B=new Set(D);return B.delete(Y),B})},[]),children:n})}),R?s.jsxs(th,{"aria-hidden":!0,required:m,tabIndex:-1,name:d,autoComplete:f,value:E,onChange:Y=>P(Y.target.value),disabled:h,form:v,children:[E===void 0?s.jsx("option",{value:""}):null,Array.from(F)]},M):null]})})};zp.displayName=wn;var Op="SelectTrigger",Pp=p.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,i=No(n),a=an(Op,n),l=a.disabled||r,c=Oe(t,a.onTriggerChange),u=Co(n),d=p.useRef("touch"),[f,h,m]=rh(g=>{const x=u().filter(_=>!_.disabled),b=x.find(_=>_.value===a.value),y=sh(x,g,b);y!==void 0&&a.onValueChange(y.value)}),v=g=>{l||(a.onOpenChange(!0),m()),g&&(a.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return s.jsx(dp,{asChild:!0,...i,children:s.jsx(Ae.button,{type:"button",role:"combobox","aria-controls":a.contentId,"aria-expanded":a.open,"aria-required":a.required,"aria-autocomplete":"none",dir:a.dir,"data-state":a.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":nh(a.value)?"":void 0,...o,ref:c,onClick:Ce(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:Ce(o.onPointerDown,g=>{d.current=g.pointerType;const x=g.target;x.hasPointerCapture(g.pointerId)&&x.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(v(g),g.preventDefault())}),onKeyDown:Ce(o.onKeyDown,g=>{const x=f.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&h(g.key),!(x&&g.key===" ")&&eC.includes(g.key)&&(v(),g.preventDefault())})})})});Pp.displayName=Op;var Mp="SelectValue",Lp=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:i,placeholder:a="",...l}=e,c=an(Mp,n),{onValueNodeHasChildrenChange:u}=c,d=i!==void 0,f=Oe(t,c.onValueNodeChange);return Ye(()=>{u(d)},[u,d]),s.jsx(Ae.span,{...l,ref:f,style:{pointerEvents:"none"},children:nh(c.value)?s.jsx(s.Fragment,{children:a}):i})});Lp.displayName=Mp;var iC="SelectIcon",Dp=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return s.jsx(Ae.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Dp.displayName=iC;var aC="SelectPortal",$p=e=>s.jsx(po,{asChild:!0,...e});$p.displayName=aC;var kn="SelectContent",Fp=p.forwardRef((e,t)=>{const n=an(kn,e.__scopeSelect),[r,o]=p.useState();if(Ye(()=>{o(new DocumentFragment)},[]),!n.open){const i=r;return i?Ar.createPortal(s.jsx(Bp,{scope:e.__scopeSelect,children:s.jsx(So.Slot,{scope:e.__scopeSelect,children:s.jsx("div",{children:e.children})})}),i):null}return s.jsx(Up,{...e,ref:t})});Fp.displayName=kn;var yt=10,[Bp,ln]=sr(kn),lC="SelectContentImpl",cC=Gn("SelectContent.RemoveScroll"),Up=p.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:i,onPointerDownOutside:a,side:l,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:m,sticky:v,hideWhenDetached:g,avoidCollisions:x,...b}=e,y=an(kn,n),[_,j]=p.useState(null),[S,T]=p.useState(null),C=Oe(t,ce=>j(ce)),[A,E]=p.useState(null),[P,J]=p.useState(null),R=Co(n),[F,k]=p.useState(!1),M=p.useRef(!1);p.useEffect(()=>{if(_)return xf(_)},[_]),lf();const Y=p.useCallback(ce=>{const[me,...le]=R().map(pe=>pe.ref.current),[ae]=le.slice(-1),re=document.activeElement;for(const pe of ce)if(pe===re||(pe?.scrollIntoView({block:"nearest"}),pe===me&&S&&(S.scrollTop=0),pe===ae&&S&&(S.scrollTop=S.scrollHeight),pe?.focus(),document.activeElement!==re))return},[R,S]),D=p.useCallback(()=>Y([A,_]),[Y,A,_]);p.useEffect(()=>{F&&D()},[F,D]);const{onOpenChange:B,triggerPointerDownPosRef:U}=y;p.useEffect(()=>{if(_){let ce={x:0,y:0};const me=ae=>{ce={x:Math.abs(Math.round(ae.pageX)-(U.current?.x??0)),y:Math.abs(Math.round(ae.pageY)-(U.current?.y??0))}},le=ae=>{ce.x<=10&&ce.y<=10?ae.preventDefault():_.contains(ae.target)||B(!1),document.removeEventListener("pointermove",me),U.current=null};return U.current!==null&&(document.addEventListener("pointermove",me),document.addEventListener("pointerup",le,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",me),document.removeEventListener("pointerup",le,{capture:!0})}}},[_,B,U]),p.useEffect(()=>{const ce=()=>B(!1);return window.addEventListener("blur",ce),window.addEventListener("resize",ce),()=>{window.removeEventListener("blur",ce),window.removeEventListener("resize",ce)}},[B]);const[ie,W]=rh(ce=>{const me=R().filter(re=>!re.disabled),le=me.find(re=>re.ref.current===document.activeElement),ae=sh(me,ce,le);ae&&setTimeout(()=>ae.ref.current.focus())}),H=p.useCallback((ce,me,le)=>{const ae=!M.current&&!le;(y.value!==void 0&&y.value===me||ae)&&(E(ce),ae&&(M.current=!0))},[y.value]),ue=p.useCallback(()=>_?.focus(),[_]),ne=p.useCallback((ce,me,le)=>{const ae=!M.current&&!le;(y.value!==void 0&&y.value===me||ae)&&J(ce)},[y.value]),se=r==="popper"?zi:Wp,je=se===zi?{side:l,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:m,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return s.jsx(Bp,{scope:n,content:_,viewport:S,onViewportChange:T,itemRefCallback:H,selectedItem:A,onItemLeave:ue,itemTextRefCallback:ne,focusSelectedItem:D,selectedItemText:P,position:r,isPositioned:F,searchRef:ie,children:s.jsx(Ia,{as:cC,allowPinchZoom:!0,children:s.jsx(Ra,{asChild:!0,trapped:y.open,onMountAutoFocus:ce=>{ce.preventDefault()},onUnmountAutoFocus:Ce(o,ce=>{y.trigger?.focus({preventScroll:!0}),ce.preventDefault()}),children:s.jsx(fo,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:ce=>ce.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:s.jsx(se,{role:"listbox",id:y.contentId,"data-state":y.open?"open":"closed",dir:y.dir,onContextMenu:ce=>ce.preventDefault(),...b,...je,onPlaced:()=>k(!0),ref:C,style:{display:"flex",flexDirection:"column",outline:"none",...b.style},onKeyDown:Ce(b.onKeyDown,ce=>{const me=ce.ctrlKey||ce.altKey||ce.metaKey;if(ce.key==="Tab"&&ce.preventDefault(),!me&&ce.key.length===1&&W(ce.key),["ArrowUp","ArrowDown","Home","End"].includes(ce.key)){let ae=R().filter(re=>!re.disabled).map(re=>re.ref.current);if(["ArrowUp","End"].includes(ce.key)&&(ae=ae.slice().reverse()),["ArrowUp","ArrowDown"].includes(ce.key)){const re=ce.target,pe=ae.indexOf(re);ae=ae.slice(pe+1)}setTimeout(()=>Y(ae)),ce.preventDefault()}})})})})})})});Up.displayName=lC;var uC="SelectItemAlignedPosition",Wp=p.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,i=an(kn,n),a=ln(kn,n),[l,c]=p.useState(null),[u,d]=p.useState(null),f=Oe(t,C=>d(C)),h=Co(n),m=p.useRef(!1),v=p.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:b,focusSelectedItem:y}=a,_=p.useCallback(()=>{if(i.trigger&&i.valueNode&&l&&u&&g&&x&&b){const C=i.trigger.getBoundingClientRect(),A=u.getBoundingClientRect(),E=i.valueNode.getBoundingClientRect(),P=b.getBoundingClientRect();if(i.dir!=="rtl"){const re=P.left-A.left,pe=E.left-re,ye=C.left-pe,w=C.width+ye,K=Math.max(w,A.width),V=window.innerWidth-yt,z=Ii(pe,[yt,Math.max(yt,V-K)]);l.style.minWidth=w+"px",l.style.left=z+"px"}else{const re=A.right-P.right,pe=window.innerWidth-E.right-re,ye=window.innerWidth-C.right-pe,w=C.width+ye,K=Math.max(w,A.width),V=window.innerWidth-yt,z=Ii(pe,[yt,Math.max(yt,V-K)]);l.style.minWidth=w+"px",l.style.right=z+"px"}const J=h(),R=window.innerHeight-yt*2,F=g.scrollHeight,k=window.getComputedStyle(u),M=parseInt(k.borderTopWidth,10),Y=parseInt(k.paddingTop,10),D=parseInt(k.borderBottomWidth,10),B=parseInt(k.paddingBottom,10),U=M+Y+F+B+D,ie=Math.min(x.offsetHeight*5,U),W=window.getComputedStyle(g),H=parseInt(W.paddingTop,10),ue=parseInt(W.paddingBottom,10),ne=C.top+C.height/2-yt,se=R-ne,je=x.offsetHeight/2,ce=x.offsetTop+je,me=M+Y+ce,le=U-me;if(me<=ne){const re=J.length>0&&x===J[J.length-1].ref.current;l.style.bottom="0px";const pe=u.clientHeight-g.offsetTop-g.offsetHeight,ye=Math.max(se,je+(re?ue:0)+pe+D),w=me+ye;l.style.height=w+"px"}else{const re=J.length>0&&x===J[0].ref.current;l.style.top="0px";const ye=Math.max(ne,M+g.offsetTop+(re?H:0)+je)+le;l.style.height=ye+"px",g.scrollTop=me-ne+g.offsetTop}l.style.margin=`${yt}px 0`,l.style.minHeight=ie+"px",l.style.maxHeight=R+"px",r?.(),requestAnimationFrame(()=>m.current=!0)}},[h,i.trigger,i.valueNode,l,u,g,x,b,i.dir,r]);Ye(()=>_(),[_]);const[j,S]=p.useState();Ye(()=>{u&&S(window.getComputedStyle(u).zIndex)},[u]);const T=p.useCallback(C=>{C&&v.current===!0&&(_(),y?.(),v.current=!1)},[_,y]);return s.jsx(fC,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:m,onScrollButtonChange:T,children:s.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:j},children:s.jsx(Ae.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Wp.displayName=uC;var dC="SelectPopperPosition",zi=p.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=yt,...i}=e,a=No(n);return s.jsx(fp,{...a,...i,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...i.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});zi.displayName=dC;var[fC,Xa]=sr(kn,{}),Oi="SelectViewport",Hp=p.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,i=ln(Oi,n),a=Xa(Oi,n),l=Oe(t,i.onViewportChange),c=p.useRef(0);return s.jsxs(s.Fragment,{children:[s.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),s.jsx(So.Slot,{scope:n,children:s.jsx(Ae.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Ce(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=a;if(h?.current&&f){const m=Math.abs(c.current-d.scrollTop);if(m>0){const v=window.innerHeight-yt*2,g=parseFloat(f.style.minHeight),x=parseFloat(f.style.height),b=Math.max(g,x);if(b<v){const y=b+m,_=Math.min(v,y),j=y-_;f.style.height=_+"px",f.style.bottom==="0px"&&(d.scrollTop=j>0?j:0,f.style.justifyContent="flex-end")}}}c.current=d.scrollTop})})})]})});Hp.displayName=Oi;var Zp="SelectGroup",[pC,hC]=sr(Zp),mC=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=At();return s.jsx(pC,{scope:n,id:o,children:s.jsx(Ae.div,{role:"group","aria-labelledby":o,...r,ref:t})})});mC.displayName=Zp;var Vp="SelectLabel",gC=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=hC(Vp,n);return s.jsx(Ae.div,{id:o.id,...r,ref:t})});gC.displayName=Vp;var Hs="SelectItem",[xC,qp]=sr(Hs),Gp=p.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:i,...a}=e,l=an(Hs,n),c=ln(Hs,n),u=l.value===r,[d,f]=p.useState(i??""),[h,m]=p.useState(!1),v=Oe(t,y=>c.itemRefCallback?.(y,r,o)),g=At(),x=p.useRef("touch"),b=()=>{o||(l.onValueChange(r),l.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return s.jsx(xC,{scope:n,value:r,disabled:o,textId:g,isSelected:u,onItemTextChange:p.useCallback(y=>{f(_=>_||(y?.textContent??"").trim())},[]),children:s.jsx(So.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:s.jsx(Ae.div,{role:"option","aria-labelledby":g,"data-highlighted":h?"":void 0,"aria-selected":u&&h,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...a,ref:v,onFocus:Ce(a.onFocus,()=>m(!0)),onBlur:Ce(a.onBlur,()=>m(!1)),onClick:Ce(a.onClick,()=>{x.current!=="mouse"&&b()}),onPointerUp:Ce(a.onPointerUp,()=>{x.current==="mouse"&&b()}),onPointerDown:Ce(a.onPointerDown,y=>{x.current=y.pointerType}),onPointerMove:Ce(a.onPointerMove,y=>{x.current=y.pointerType,o?c.onItemLeave?.():x.current==="mouse"&&y.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ce(a.onPointerLeave,y=>{y.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:Ce(a.onKeyDown,y=>{c.searchRef?.current!==""&&y.key===" "||(tC.includes(y.key)&&b(),y.key===" "&&y.preventDefault())})})})})});Gp.displayName=Hs;var gr="SelectItemText",Kp=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...i}=e,a=an(gr,n),l=ln(gr,n),c=qp(gr,n),u=oC(gr,n),[d,f]=p.useState(null),h=Oe(t,b=>f(b),c.onItemTextChange,b=>l.itemTextRefCallback?.(b,c.value,c.disabled)),m=d?.textContent,v=p.useMemo(()=>s.jsx("option",{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=u;return Ye(()=>(g(v),()=>x(v)),[g,x,v]),s.jsxs(s.Fragment,{children:[s.jsx(Ae.span,{id:c.textId,...i,ref:h}),c.isSelected&&a.valueNode&&!a.valueNodeHasChildren?Ar.createPortal(i.children,a.valueNode):null]})});Kp.displayName=gr;var Jp="SelectItemIndicator",Yp=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return qp(Jp,n).isSelected?s.jsx(Ae.span,{"aria-hidden":!0,...r,ref:t}):null});Yp.displayName=Jp;var Pi="SelectScrollUpButton",Xp=p.forwardRef((e,t)=>{const n=ln(Pi,e.__scopeSelect),r=Xa(Pi,e.__scopeSelect),[o,i]=p.useState(!1),a=Oe(t,r.onScrollButtonChange);return Ye(()=>{if(n.viewport&&n.isPositioned){let l=function(){const u=c.scrollTop>0;i(u)};const c=n.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),o?s.jsx(eh,{...e,ref:a,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop-c.offsetHeight)}}):null});Xp.displayName=Pi;var Mi="SelectScrollDownButton",Qp=p.forwardRef((e,t)=>{const n=ln(Mi,e.__scopeSelect),r=Xa(Mi,e.__scopeSelect),[o,i]=p.useState(!1),a=Oe(t,r.onScrollButtonChange);return Ye(()=>{if(n.viewport&&n.isPositioned){let l=function(){const u=c.scrollHeight-c.clientHeight,d=Math.ceil(c.scrollTop)<u;i(d)};const c=n.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),o?s.jsx(eh,{...e,ref:a,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop+c.offsetHeight)}}):null});Qp.displayName=Mi;var eh=p.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,i=ln("SelectScrollButton",n),a=p.useRef(null),l=Co(n),c=p.useCallback(()=>{a.current!==null&&(window.clearInterval(a.current),a.current=null)},[]);return p.useEffect(()=>()=>c(),[c]),Ye(()=>{l().find(d=>d.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[l]),s.jsx(Ae.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:Ce(o.onPointerDown,()=>{a.current===null&&(a.current=window.setInterval(r,50))}),onPointerMove:Ce(o.onPointerMove,()=>{i.onItemLeave?.(),a.current===null&&(a.current=window.setInterval(r,50))}),onPointerLeave:Ce(o.onPointerLeave,()=>{c()})})}),bC="SelectSeparator",vC=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return s.jsx(Ae.div,{"aria-hidden":!0,...r,ref:t})});vC.displayName=bC;var Li="SelectArrow",yC=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=No(n),i=an(Li,n),a=ln(Li,n);return i.open&&a.position==="popper"?s.jsx(pp,{...o,...r,ref:t}):null});yC.displayName=Li;var wC="SelectBubbleInput",th=p.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=p.useRef(null),i=Oe(r,o),a=aj(t);return p.useEffect(()=>{const l=o.current;if(!l)return;const c=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(a!==t&&d){const f=new Event("change",{bubbles:!0});d.call(l,t),l.dispatchEvent(f)}},[a,t]),s.jsx(Ae.select,{...n,style:{...Mf,...n.style},ref:i,defaultValue:t})});th.displayName=wC;function nh(e){return e===""||e===void 0}function rh(e){const t=nt(e),n=p.useRef(""),r=p.useRef(0),o=p.useCallback(a=>{const l=n.current+a;t(l),(function c(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>c(""),1e3))})(l)},[t]),i=p.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,i]}function sh(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let a=kC(e,Math.max(i,0));o.length===1&&(a=a.filter(u=>u!==n));const c=a.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function kC(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var _C=zp,jC=Pp,SC=Lp,CC=Dp,NC=$p,TC=Fp,EC=Hp,AC=Gp,RC=Kp,IC=Yp,zC=Xp,OC=Qp,To="Tabs",[PC]=Zt(To,[mp]),oh=mp(),[MC,Qa]=PC(To),ih=p.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:a="horizontal",dir:l,activationMode:c="automatic",...u}=e,d=xo(l),[f,h]=bn({prop:r,onChange:o,defaultProp:i??"",caller:To});return s.jsx(MC,{scope:n,baseId:At(),value:f,onValueChange:h,orientation:a,dir:d,activationMode:c,children:s.jsx(Ae.div,{dir:d,"data-orientation":a,...u,ref:t})})});ih.displayName=To;var ah="TabsList",lh=p.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,i=Qa(ah,n),a=oh(n);return s.jsx(DS,{asChild:!0,...a,orientation:i.orientation,dir:i.dir,loop:r,children:s.jsx(Ae.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});lh.displayName=ah;var ch="TabsTrigger",uh=p.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=e,a=Qa(ch,n),l=oh(n),c=ph(a.baseId,r),u=hh(a.baseId,r),d=r===a.value;return s.jsx($S,{asChild:!0,...l,focusable:!o,active:d,children:s.jsx(Ae.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":u,"data-state":d?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:c,...i,ref:t,onMouseDown:Ce(e.onMouseDown,f=>{!o&&f.button===0&&f.ctrlKey===!1?a.onValueChange(r):f.preventDefault()}),onKeyDown:Ce(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&a.onValueChange(r)}),onFocus:Ce(e.onFocus,()=>{const f=a.activationMode!=="manual";!d&&!o&&f&&a.onValueChange(r)})})})});uh.displayName=ch;var dh="TabsContent",fh=p.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...a}=e,l=Qa(dh,n),c=ph(l.baseId,r),u=hh(l.baseId,r),d=r===l.value,f=p.useRef(d);return p.useEffect(()=>{const h=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(h)},[]),s.jsx(gt,{present:o||d,children:({present:h})=>s.jsx(Ae.div,{"data-state":d?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":c,hidden:!h,id:u,tabIndex:0,...a,ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0},children:h&&i})})});fh.displayName=dh;function ph(e,t){return`${e}-trigger-${t}`}function hh(e,t){return`${e}-content-${t}`}var LC=ih,DC=lh,$C=uh,FC=fh,[Eo]=Zt("Tooltip",[ko]),Ao=ko(),mh="TooltipProvider",BC=700,Di="tooltip.open",[UC,el]=Eo(mh),gh=e=>{const{__scopeTooltip:t,delayDuration:n=BC,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:i}=e,a=p.useRef(!0),l=p.useRef(!1),c=p.useRef(0);return p.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),s.jsx(UC,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:p.useCallback(()=>{window.clearTimeout(c.current),a.current=!1},[]),onClose:p.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:p.useCallback(u=>{l.current=u},[]),disableHoverableContent:o,children:i})};gh.displayName=mh;var Cr="Tooltip",[WC,$r]=Eo(Cr),xh=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:i,disableHoverableContent:a,delayDuration:l}=e,c=el(Cr,e.__scopeTooltip),u=Ao(t),[d,f]=p.useState(null),h=At(),m=p.useRef(0),v=a??c.disableHoverableContent,g=l??c.delayDuration,x=p.useRef(!1),[b,y]=bn({prop:r,defaultProp:o??!1,onChange:C=>{C?(c.onOpen(),document.dispatchEvent(new CustomEvent(Di))):c.onClose(),i?.(C)},caller:Cr}),_=p.useMemo(()=>b?x.current?"delayed-open":"instant-open":"closed",[b]),j=p.useCallback(()=>{window.clearTimeout(m.current),m.current=0,x.current=!1,y(!0)},[y]),S=p.useCallback(()=>{window.clearTimeout(m.current),m.current=0,y(!1)},[y]),T=p.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{x.current=!0,y(!0),m.current=0},g)},[g,y]);return p.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),s.jsx(up,{...u,children:s.jsx(WC,{scope:t,contentId:h,open:b,stateAttribute:_,trigger:d,onTriggerChange:f,onTriggerEnter:p.useCallback(()=>{c.isOpenDelayedRef.current?T():j()},[c.isOpenDelayedRef,T,j]),onTriggerLeave:p.useCallback(()=>{v?S():(window.clearTimeout(m.current),m.current=0)},[S,v]),onOpen:j,onClose:S,disableHoverableContent:v,children:n})})};xh.displayName=Cr;var $i="TooltipTrigger",bh=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=$r($i,n),i=el($i,n),a=Ao(n),l=p.useRef(null),c=Oe(t,l,o.onTriggerChange),u=p.useRef(!1),d=p.useRef(!1),f=p.useCallback(()=>u.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),s.jsx(dp,{asChild:!0,...a,children:s.jsx(Ae.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:c,onPointerMove:Ce(e.onPointerMove,h=>{h.pointerType!=="touch"&&!d.current&&!i.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:Ce(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:Ce(e.onPointerDown,()=>{o.open&&o.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Ce(e.onFocus,()=>{u.current||o.onOpen()}),onBlur:Ce(e.onBlur,o.onClose),onClick:Ce(e.onClick,o.onClose)})})});bh.displayName=$i;var tl="TooltipPortal",[HC,ZC]=Eo(tl,{forceMount:void 0}),vh=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,i=$r(tl,t);return s.jsx(HC,{scope:t,forceMount:n,children:s.jsx(gt,{present:n||i.open,children:s.jsx(po,{asChild:!0,container:o,children:r})})})};vh.displayName=tl;var Yn="TooltipContent",yh=p.forwardRef((e,t)=>{const n=ZC(Yn,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...i}=e,a=$r(Yn,e.__scopeTooltip);return s.jsx(gt,{present:r||a.open,children:a.disableHoverableContent?s.jsx(wh,{side:o,...i,ref:t}):s.jsx(VC,{side:o,...i,ref:t})})}),VC=p.forwardRef((e,t)=>{const n=$r(Yn,e.__scopeTooltip),r=el(Yn,e.__scopeTooltip),o=p.useRef(null),i=Oe(t,o),[a,l]=p.useState(null),{trigger:c,onClose:u}=n,d=o.current,{onPointerInTransitChange:f}=r,h=p.useCallback(()=>{l(null),f(!1)},[f]),m=p.useCallback((v,g)=>{const x=v.currentTarget,b={x:v.clientX,y:v.clientY},y=JC(b,x.getBoundingClientRect()),_=YC(b,y),j=XC(g.getBoundingClientRect()),S=e5([..._,...j]);l(S),f(!0)},[f]);return p.useEffect(()=>()=>h(),[h]),p.useEffect(()=>{if(c&&d){const v=x=>m(x,d),g=x=>m(x,c);return c.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{c.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[c,d,m,h]),p.useEffect(()=>{if(a){const v=g=>{const x=g.target,b={x:g.clientX,y:g.clientY},y=c?.contains(x)||d?.contains(x),_=!QC(b,a);y?h():_&&(h(),u())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[c,d,a,u,h]),s.jsx(wh,{...e,ref:i})}),[qC,GC]=Eo(Cr,{isInside:!1}),KC=Qw("TooltipContent"),wh=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:i,onPointerDownOutside:a,...l}=e,c=$r(Yn,n),u=Ao(n),{onClose:d}=c;return p.useEffect(()=>(document.addEventListener(Di,d),()=>document.removeEventListener(Di,d)),[d]),p.useEffect(()=>{if(c.trigger){const f=h=>{h.target?.contains(c.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[c.trigger,d]),s.jsx(fo,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:s.jsxs(fp,{"data-state":c.stateAttribute,...u,...l,ref:t,style:{...l.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:[s.jsx(KC,{children:r}),s.jsx(qC,{scope:n,isInside:!0,children:s.jsx(tj,{id:c.contentId,role:"tooltip",children:o||r})})]})})});yh.displayName=Yn;var kh="TooltipArrow",_h=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Ao(n);return GC(kh,n).isInside?null:s.jsx(pp,{...o,...r,ref:t})});_h.displayName=kh;function JC(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,r,o,i)){case i:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function YC(e,t,n=5){const 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 XC(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function QC(e,t){const{x:n,y:r}=e;let o=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){const l=t[i],c=t[a],u=l.x,d=l.y,f=c.x,h=c.y;d>r!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(o=!o)}return o}function e5(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),t5(t)}function t5(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const i=t[t.length-1],a=t[t.length-2];if((i.x-a.x)*(o.y-a.y)>=(i.y-a.y)*(o.x-a.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const i=n[n.length-1],a=n[n.length-2];if((i.x-a.x)*(o.y-a.y)>=(i.y-a.y)*(o.x-a.x))n.pop();else break}n.push(o)}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 n5=gh,r5=xh,s5=bh,o5=vh,i5=yh,a5=_h;function Je({delayDuration:e=0,...t}){return s.jsx(n5,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Me({...e}){return s.jsx(r5,{"data-slot":"tooltip",...e})}function Le({...e}){return s.jsx(s5,{"data-slot":"tooltip-trigger",...e})}function De({className:e,sideOffset:t=0,children:n,...r}){return s.jsx(o5,{children:s.jsxs(i5,{"data-slot":"tooltip-content",sideOffset:t,className:de("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,s.jsx(a5,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const l5=3,nl="flex h-8 w-5 shrink-0 items-center justify-center text-muted-foreground";function c5({items:e,ariaLabel:t,className:n}){if(e.length===0)return s.jsx("span",{className:de("flex h-8 w-12 shrink-0 items-center",n),"aria-hidden":"true"});const r=e.slice(0,l5),o=e.length-r.length;return s.jsx(Je,{delayDuration:150,children:s.jsxs("span",{className:de("flex h-8 w-12 shrink-0 items-center",n),"aria-label":t,children:[r.map((i,a)=>s.jsxs(Me,{children:[s.jsx(Le,{asChild:!0,children:s.jsx("span",{className:de("inline-flex size-6 shrink-0 items-center justify-center rounded-md border border-white/10 bg-black/20 shadow-[inset_0_1px_0_rgba(255,255,255,0.05)]",a>0&&"-ml-2"),children:s.jsx(Q_,{provider:i.provider,className:"size-4"})})}),s.jsx(De,{children:i.tooltip})]},`${i.provider}-${String(a)}`)),o>0&&s.jsxs("span",{className:"-ml-2 inline-flex h-6 min-w-6 shrink-0 items-center justify-center rounded-md border border-white/10 bg-black/40 px-1 font-mono text-[10px] text-muted-foreground",children:["+",o]})]})})}const u5="/v1/chat/completions",d5="/chat/completions",f5="/v1/responses",p5="/responses",h5="/v1/messages";class m5{handlers=new Map;pathMap=new Map;register(t){this.handlers.set(t.format,t)}registerPath(t,n){this.pathMap.set(t,n)}get(t){return this.handlers.get(t)}getByPath(t){const n=t.split("?")[0]??"",r=this.pathMap.get(n);return r===void 0?void 0:this.handlers.get(r)}getApiFormatByPath(t){const n=t.split("?")[0]??"";return this.pathMap.get(n)}detectFormat(t){if(t===null)return"unknown";for(const n of this.handlers.values())if(n.detectFormat(t))return n.format;return"unknown"}}const cn=new m5;function g5(e){return cn.getApiFormatByPath(e)??"unknown"}cn.registerPath(h5,"anthropic");cn.registerPath(u5,"openai");cn.registerPath(d5,"openai");cn.registerPath(f5,"openai");cn.registerPath(p5,"openai");function x5(e){if(e==="")return{};try{const t=JSON.parse(e);return t!==null&&typeof t=="object"&&!Array.isArray(t)?{...t}:{}}catch{return{}}}function b5(e){switch(e.type){case"text":return{type:"text",text:e.text};case"thinking":{const t={type:"thinking",thinking:e.thinking};return e.signature!==""&&(t.signature=e.signature),t}case"think":{const t={type:"think",thinking:e.thinking};return e.signature!==""&&(t.signature=e.signature),t}case"tool_use":return{type:"tool_use",id:e.id,name:e.name,input:x5(e.inputJson)}}}function jh(e,t,n,r){const o=new Map;let i="",a="",l=null,c=null,u=0,d=0;const f=1e3;let h=0,m=0;const v=[];for(const x of e.split(`
|
|
86
|
+
`)){const b=x.trim();if(b.startsWith("data: "))try{const y=JSON.parse(b.slice(6)),_=Wv.safeParse(y);if(!_.success)continue;const j=_.data;switch(h===0&&(m=Date.now()),r===!0&&v.length<f&&v.push({index:h,timestamp:Date.now()-m,type:j.type,data:j}),h++,j.type){case"message_start":i=j.message.id,a=j.message.model,u=j.message.usage.input_tokens,t.inputTokens=u,t.cacheCreationInputTokens=j.message.usage.cache_creation_input_tokens??null,t.cacheReadInputTokens=j.message.usage.cache_read_input_tokens??null,t.model===null&&(t.model=a);break;case"content_block_start":{const S=j.content_block;switch(S.type){case"text":o.set(j.index,{type:"text",text:S.text??""});break;case"thinking":o.set(j.index,{type:"thinking",thinking:S.thinking??"",signature:S.signature??""});break;case"think":o.set(j.index,{type:"think",thinking:S.thinking??"",signature:S.signature??""});break;case"tool_use":o.set(j.index,{type:"tool_use",id:S.id,name:S.name,inputJson:""});break}break}case"content_block_delta":{const S=o.get(j.index);if(S===void 0)break;const T=j.delta;T.type==="text_delta"&&S.type==="text"?S.text+=T.text:T.type==="thinking_delta"&&(S.type==="thinking"||S.type==="think")?S.thinking+=T.thinking:T.type==="signature_delta"&&(S.type==="thinking"||S.type==="think")?S.signature+=T.signature:T.type==="input_json_delta"&&S.type==="tool_use"&&(S.inputJson+=T.partial_json);break}case"message_delta":l=j.delta.stop_reason,c=j.delta.stop_sequence??null,d=j.usage.output_tokens,t.outputTokens=d,j.usage.cache_creation_input_tokens!==void 0&&(t.cacheCreationInputTokens=j.usage.cache_creation_input_tokens),j.usage.cache_read_input_tokens!==void 0&&(t.cacheReadInputTokens=j.usage.cache_read_input_tokens);break;case"error":t.error=j.error.message;break;case"content_block_stop":case"message_stop":case"ping":break}}catch{}}r===!0&&(t.streamingChunks={chunks:v,truncated:h>f});const g=[...o.entries()].sort(([x],[b])=>x-b).map(([,x])=>b5(x));return JSON.stringify({id:i,type:"message",model:a!==""?a:n??"",role:"assistant",content:g,stop_reason:l,stop_sequence:c,usage:{input_tokens:u,output_tokens:d}})}const v5={format:"anthropic",parseRequest(e,t){try{const n=JSON.parse(e),r=pd.safeParse(n);return r.success?{model:r.data.model,sessionId:r.data.metadata?.user_id??t?.get("x-session-affinity")??null}:null}catch{return null}},extractTokens(e){try{const t=JSON.parse(e),n=hd.safeParse(t);if(n.success)return{inputTokens:n.data.usage.input_tokens??null,outputTokens:n.data.usage.output_tokens??null,cacheCreationInputTokens:n.data.usage.cache_creation_input_tokens??null,cacheReadInputTokens:n.data.usage.cache_read_input_tokens??null}}catch{}return{inputTokens:null,outputTokens:null,cacheCreationInputTokens:null,cacheReadInputTokens:null}},extractStream(e,t,n,r){return jh(e,t,n,r)},detectFormat(e){if(e===null)return!1;try{const t=JSON.parse(e);if(typeof t=="object"&&t!==null&&!Array.isArray(t)){const n=Object.keys(t);return n.includes("model")&&n.includes("messages")&&n.includes("system")}return!1}catch{return!1}}};cn.register(v5);class y5{providers=[];register(t){this.providers.push(t)}findProvider(t){let n=null;for(const r of this.providers)if(r.matches(t)){if(r.name!=="anthropic")return r;n=r}return n}getAll(){return[...this.providers]}}const Ro=new y5,w5="https://api.anthropic.com",k5={MiniMax:"https://api.minimaxi.com/anthropic"},_5={name:"anthropic",matches(e){const t=e.toLowerCase();if(t.startsWith("openai-"))return!1;if(t.includes("claude")||t.includes("anthropic"))return!0;for(const n of Object.keys(k5))if(t.startsWith(n.toLowerCase()))return!0;return!0},getUpstreamBase(e,t){return t?.baseUrl!==void 0?t.baseUrl:w5},extractStream(e,t,n,r){return jh(e,t,n,r)}};Ro.register(_5);const rl=1e3;function Fr(e,t){if(!(e===null||typeof e!="object"||Array.isArray(e)))return Object.getOwnPropertyDescriptor(e,t)?.value}function et(e,t){const n=Fr(e,t);return typeof n=="string"?n:null}function Sh(e,t){const n=Fr(e,t);return typeof n=="number"&&Number.isFinite(n)?n:null}function Zs(e,t){const n=Fr(e,t);return n!==null&&typeof n=="object"&&!Array.isArray(n)?n:null}function j5(e,t){const n=Fr(e,t);return Array.isArray(n)?n:[]}function S5(e){const t=[];let n=null,r=[];const o=()=>{n===null&&r.length===0||(t.push({event:n,data:r.join(`
|
|
87
|
+
`)}),n=null,r=[])};for(const i of e.split(`
|
|
88
|
+
`)){const a=i.endsWith("\r")?i.slice(0,-1):i;if(a===""){o();continue}if(a.startsWith(":"))continue;const l=a.indexOf(":"),c=l===-1?a:a.slice(0,l),u=l===-1?"":a.slice(l+1),d=u.startsWith(" ")?u.slice(1):u;switch(c){case"event":n=d;break;case"data":n===null&&r.length>0&&(d.startsWith("{")||d==="[DONE]")&&o(),r.push(d);break}}return o(),t}function sl(e){try{return JSON.parse(e)}catch{return null}}function Ch(e,t){if(e.event!==null&&e.event!=="")return e.event;const n=Qv.safeParse(t);return n.success?n.data.type:""}function C5(e){if(e.data==="[DONE]")return!1;const t=sl(e.data),n=Ch(e,t);return n.startsWith("response.")||n==="error"}function Nh(e,t,n,r,o){e.length>=rl||e.push({index:t,timestamp:Date.now()-n,type:r,data:o})}function Fi(e,t){const n=Zs(t,"error"),r=et(n,"message")??et(t,"message")??et(t,"error");r!==null&&r.length>0&&(e.error=r)}function N5(e,t,n,r){let o="",i="",a="",l="",c=null,u=0,d=0,f=!1,h=!1;const m=new Map;let v=0,g=0;const x=[];for(const y of e){if(y.data==="[DONE]")break;const _=sl(y.data);if(_===null)continue;Fi(t,_);const j=Jv.safeParse(_);if(!j.success)continue;const S=j.data;if(v===0&&(g=Date.now()),r&&Nh(x,v,g,"chat.completion.chunk",S),v++,h||(o=S.id,i=S.model,h=!0),!f&&S.usage!==void 0&&S.usage!==null){u=S.usage.prompt_tokens??0,d=S.usage.completion_tokens??0,t.inputTokens=u;const T=Zs(_,"usage"),C=Zs(T,"prompt_tokens_details"),A=Sh(C,"cached_tokens");A!==null&&(t.cacheReadInputTokens=A),f=!0}for(const T of S.choices){const C=T.delta;C.content!==void 0&&C.content!==null&&(a+=C.content),C.reasoning_content!==void 0&&C.reasoning_content!==null&&(l+=C.reasoning_content),C.thinking!==void 0&&C.thinking!==null&&(l+=C.thinking);const A=C.think;if(A!=null&&(l+=A),T.finish_reason!==void 0&&T.finish_reason!==null&&(c=T.finish_reason),C.tool_calls!==void 0&&C.tool_calls!==null)for(const E of C.tool_calls){let P=m.get(E.index);P===void 0&&(P={index:E.index,type:"function",function:{name:"",arguments:""}},m.set(E.index,P)),E.id!==void 0&&(P.id=E.id),E.function?.name!==void 0&&(P.function.name+=E.function.name),E.function?.arguments!==void 0&&(P.function.arguments+=E.function.arguments)}}}r&&(t.streamingChunks={chunks:x,truncated:v>rl}),f||(d=Math.ceil(a.length/4)),t.outputTokens=d;const b={role:"assistant",content:a};return l.length>0&&(b.reasoning_content=l),m.size>0&&(b.tool_calls=[...m.values()]),JSON.stringify({id:o,object:"chat.completion",created:Math.floor(Date.now()/1e3),model:i!==""?i:n??"",choices:[{index:0,message:b,finish_reason:c}],usage:{prompt_tokens:u,completion_tokens:d,total_tokens:u+d}})}function T5(e){const t=Es.safeParse(Fr(e,"response"));if(t.success)return t.data;const n=Es.safeParse(e);return n.success?n.data:null}function Th(e){if(e.output_text!==void 0&&e.output_text.length>0)return e.output_text;const t=[];for(const n of e.output??[]){const r=j5(n,"content");for(const o of r){const i=et(o,"type"),a=et(o,"text");(i==="output_text"||i==="text")&&a!==null&&a.length>0&&t.push(a)}}return t.join(`
|
|
89
|
+
`)}function jc(e,t){const n=e.usage,r=n?.input_tokens??null,o=n?.output_tokens??null;r!==null&&(t.inputTokens=r),o!==null&&(t.outputTokens=o);const i=n?.input_tokens_details?.cached_tokens??null;return i!==null&&(t.cacheReadInputTokens=i),{inputTokens:r,outputTokens:o}}function Xo(e,t){const n=et(e,"item_id");if(n!==null&&n.length>0)return n;const r=Sh(e,"output_index");return r!==null?String(r):`function-${String(t)}`}function Bi(e,t){const n=e.get(t);if(n!==void 0)return n;const r={type:"function_call",arguments:""};return e.set(t,r),r}function E5(e,t,n){if(et(n,"type")!=="function_call")return;const r=Bi(e,t),o=et(n,"id"),i=et(n,"call_id"),a=et(n,"name"),l=et(n,"arguments"),c=et(n,"status");o!==null&&(r.id=o),i!==null&&(r.call_id=i),a!==null&&(r.name=a),l!==null&&(r.arguments=l),c!==null&&(r.status=c)}function A5(e,t){const n=[];e.length>0&&n.push({type:"message",role:"assistant",content:[{type:"output_text",text:e,annotations:[]}]});for(const r of t.values())n.push(r);return n}function R5(e,t,n){const r=t??Math.ceil(n.length/4);return{input_tokens:e,output_tokens:r,total_tokens:e===null?r:e+r}}function I5(e){const t=e.completedResponse===null?"":Th(e.completedResponse),n=t.length>0?t:e.outputText,r=e.completedResponse?.output,o=r!==void 0&&r.length>0?r:A5(n,e.calls),i=e.completedResponse?.usage??R5(e.inputTokens,e.outputTokens,n);return{...e.completedResponse??{},id:e.completedResponse?.id??e.responseId,object:"response",created_at:e.completedResponse?.created_at??Math.floor(Date.now()/1e3),status:e.completedResponse?.status??e.status??"completed",model:e.completedResponse?.model??e.model,output:o,output_text:n,usage:i}}function z5(e,t,n,r){let o=null,i="",a=n??"",l=null,c="",u=null,d=null,f=0,h=0;const m=[],v=new Map;for(const b of e){if(b.data==="[DONE]")break;const y=sl(b.data);if(y===null)continue;const _=Ch(b,y);if(f===0&&(h=Date.now()),r&&Nh(m,f,h,_===""?"response.event":_,y),f++,Fi(t,y),_==="error")continue;const j=T5(y);if(j!==null){o=j,i=j.id,a=j.model??a,l=j.status??l;const T=jc(j,t);u=T.inputTokens??u,d=T.outputTokens??d,Fi(t,j)}const S=et(y,"delta");switch(_){case"response.output_text.delta":S!==null&&(c+=S);break;case"response.output_text.done":{const T=et(y,"text");c.length===0&&T!==null&&(c=T);break}case"response.function_call_arguments.delta":{if(S!==null){const T=Bi(v,Xo(y,v.size));T.arguments+=S}break}case"response.function_call_arguments.done":{const T=et(y,"arguments");if(T!==null){const C=Bi(v,Xo(y,v.size));C.arguments=T}break}case"response.output_item.added":case"response.output_item.done":{const T=Zs(y,"item");E5(v,Xo(y,v.size),T);break}case"response.failed":case"response.incomplete":l=_.slice(9);break;case"response.completed":l="completed";break}}r&&(t.streamingChunks={chunks:m,truncated:f>rl});const g=I5({completedResponse:o,responseId:i,model:a,status:l,outputText:c,calls:v,inputTokens:u,outputTokens:d}),x=Es.safeParse(g);if(x.success){if(jc(x.data,t).outputTokens===null){const y=Th(x.data),_=Math.ceil(y.length/4);t.outputTokens=_}return JSON.stringify(x.data)}if(t.outputTokens===null){const b=et(g,"output_text")??c,y=Math.ceil(b.length/4);t.outputTokens=y}return JSON.stringify(g)}function Io(e,t,n,r=!0){const o=S5(e);return o.some(C5)?z5(o,t,n,r):N5(o,t,n,r)}function O5(){return{inputTokens:null,outputTokens:null,cacheCreationInputTokens:null,cacheReadInputTokens:null}}const P5={format:"openai",parseRequest(e,t){try{const n=JSON.parse(e),r=xd.safeParse(n);if(r.success)return{model:r.data.model,sessionId:t?.get("x-session-affinity")??null};const o=bd.safeParse(n);return o.success?{model:o.data.model,sessionId:t?.get("x-session-affinity")??null}:null}catch{return null}},extractTokens(e){const t=yd(e);if(t){let r=null;try{const o=JSON.parse(e);if(o!==null&&typeof o=="object"&&!Array.isArray(o)){const i=Object.getOwnPropertyDescriptor(o,"usage");if(i!==void 0&&typeof i.value=="object"&&i.value!==null){const a=Object.getOwnPropertyDescriptor(i.value,"prompt_tokens_details");if(a!==void 0&&typeof a.value=="object"&&a.value!==null){const l=Object.getOwnPropertyDescriptor(a.value,"cached_tokens");l!==void 0&&typeof l.value=="number"&&(r=l.value)}}}}catch{}return{inputTokens:t.usage.prompt_tokens??null,outputTokens:t.usage.completion_tokens??null,cacheCreationInputTokens:null,cacheReadInputTokens:r}}const n=wd(e);if(n!==null){const r=n.usage;return{inputTokens:r?.input_tokens??null,outputTokens:r?.output_tokens??null,cacheCreationInputTokens:null,cacheReadInputTokens:r?.input_tokens_details?.cached_tokens??null}}return O5()},extractStream(e,t,n,r){return Io(e,t,n,r)},detectFormat(e){if(e===null)return!1;try{const t=JSON.parse(e);if(typeof t=="object"&&t!==null&&!Array.isArray(t)){const n=Object.keys(t);return n.includes("model")&&(n.includes("messages")||n.includes("input"))&&!n.includes("system")}return!1}catch{return!1}}};cn.register(P5);const M5="https://api.openai.com/v1",L5={name:"openai",matches(e){const t=e.toLowerCase();return!!(t.startsWith("openai-")||t.includes("gpt-")||t.includes("o1")||t.includes("o2")||t.includes("o3"))},getUpstreamBase(e,t){return t?.baseUrl!==void 0?t.baseUrl:M5},extractStream(e,t,n,r){return Io(e,t,n,r)}};Ro.register(L5);const D5="https://open.bigmodel.cn/api/paas/v4",$5=["glm-","charglm-","cogview-","embedding-","rerank-"],F5={name:"zhipu",matches(e){const t=e.toLowerCase().replace(/\s+/g,"-");return $5.some(n=>t.startsWith(n))},getUpstreamBase(e,t){return t?.baseUrl??D5},extractStream(e,t,n,r){return Io(e,t,n,r)}};Ro.register(F5);const B5="https://dashscope.aliyuncs.com/compatible-mode/v1",U5={name:"alibaba",matches(e){const t=e.toLowerCase().replace(/\s+/g,"-");return!!(t.startsWith("glm-5")||t.startsWith("qwen"))},getUpstreamBase(e,t){return B5},extractStream(e,t,n){return Io(e,t,n)}};Ro.register(U5);function Eh(e,t){for(const n of Array.from(e))t(n)}const W5=/[\u3000-\u9FFF\uAC00-\uD7FF\uF900-\uFAFF\uFF00-\uFFEF\u{1F300}-\u{1FAFF}]/u;function ol(e){if(e.length===0)return 0;let t=0,n=0;return Eh(e,r=>{W5.test(r)?t+=1:n+=1}),Math.ceil(t*1)+Math.ceil(n/4)}function il(e){if(e.length===0)return 0;let t=0;return Eh(e,()=>{t+=1}),t}function xn(e){return{parsed:null,comparisonValue:e,messageCount:null,toolCount:null}}const Un={parsed:null,toolNames:null};function H5(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";const t=[];for(const n of e){if(n===null||typeof n!="object")continue;const r=n;switch(r.type){case"text":typeof r.text=="string"&&t.push(r.text);break;case"thinking":case"think":typeof r.thinking=="string"&&t.push(r.thinking);break;case"tool_use":{const i=typeof r.name=="string"?r.name:"",a=r.input!==void 0?JSON.stringify(r.input):"";t.push(`${i} ${a}`.trim());break}case"tool_result":{const i=r.content;if(typeof i=="string")t.push(i);else if(Array.isArray(i)){for(const a of i)if(a!==null&&typeof a=="object"){const l=a.text;typeof l=="string"&&t.push(l)}}break}case"image":t.push("[image]");break}}return t.join(`
|
|
90
|
+
`)}function Z5(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";const t=[];for(const n of e)if(n!==null&&typeof n=="object"){const r=n.text;n.type==="text"&&typeof r=="string"&&t.push(r)}return t.join(`
|
|
91
|
+
`)}function V5(e){if(!Array.isArray(e))return"";const t=[];for(const n of e){if(n===null||typeof n!="object")continue;const r=n;typeof r.name=="string"&&t.push(r.name),typeof r.description=="string"&&t.push(r.description),r.input_schema!==void 0&&t.push(JSON.stringify(r.input_schema))}return t.join(`
|
|
92
|
+
`)}function Qo(e,t,n,r){return{role:e,label:t,text:n,size:ol(n),characters:il(n),path:r}}const q5={format:"anthropic",analyzeRequest(e){if(e===null)return xn(e);try{const t=pd.safeParse(JSON.parse(e));return t.success?{parsed:t.data,comparisonValue:t.data,messageCount:t.data.messages.length,toolCount:t.data.tools!==void 0&&t.data.tools.length>0?t.data.tools.length:null}:xn(e)}catch{return xn(e)}},analyzeResponse(e){if(e===null)return Un;try{let t=JSON.parse(e);typeof t=="string"&&(t=JSON.parse(t));const n=hd.safeParse(t);if(!n.success)return Un;const r=n.data.content.filter(o=>o.type==="tool_use").map(o=>o.name);return{parsed:n.data,toolNames:r.length>0?r:null}}catch{return Un}},anatomySegments(e){if(e===null||typeof e!="object")return null;const t=e,n=[];if(t.system!==void 0){const r=Z5(t.system);r.length>0&&n.push(Qo("system","system",r,"/system"))}if(Array.isArray(t.messages)&&t.messages.forEach((r,o)=>{if(r===null||typeof r!="object")return;const i=r,a=i.role==="user"||i.role==="assistant"?i.role:"user",l=H5(i.content);n.push(Qo(a,`[${o}] ${a}`,l,`/messages/${o}`))}),Array.isArray(t.tools)&&t.tools.length>0){const r=V5(t.tools);n.push(Qo("tools","tools",r,"/tools"))}return n.length>0?n:null}};function al(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ke(e,t){return e===null||typeof e!="object"||Array.isArray(e)?void 0:Object.getOwnPropertyDescriptor(e,t)?.value}function Ui(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";const t=[];for(const n of e){if(n===null||typeof n!="object")continue;const r=n,o=r.type;(o==="text"||o==="input_text"||o==="output_text")&&typeof r.text=="string"?t.push(r.text):(o==="image_url"||o==="input_image")&&t.push("[image]")}return t.join(`
|
|
93
|
+
`)}function G5(e){const t=[],n=Ui(e.content);n.length>0&&t.push(n);const r=typeof e.reasoning_content=="string"?e.reasoning_content:typeof e.thinking=="string"?e.thinking:typeof e.think=="string"?e.think:"";r.length>0&&t.push(r);const o=e.tool_calls;if(Array.isArray(o))for(const i of o){if(i===null||typeof i!="object")continue;const a=i.function;if(a===void 0)continue;const l=typeof a.name=="string"?a.name:"",c=typeof a.arguments=="string"?a.arguments:"";t.push(`${l} ${c}`.trim())}return t.join(`
|
|
94
|
+
`)}function K5(e){if(!Array.isArray(e))return"";const t=[];for(const n of e){if(n===null||typeof n!="object")continue;const r=ke(n,"function"),o=ke(r,"name")??ke(n,"name"),i=ke(r,"description")??ke(n,"description"),a=ke(r,"parameters")??ke(n,"parameters");typeof o=="string"&&t.push(o),typeof i=="string"&&t.push(i),a!==void 0&&t.push(JSON.stringify(a))}return t.join(`
|
|
95
|
+
`)}function J5(e){return typeof e=="string"?e.length>0?1:0:Array.isArray(e)?e.length:e==null?null:1}function Y5(e){if(typeof e=="string")return e;const t=ke(e,"text");if(typeof t=="string")return t;const n=Ui(ke(e,"content"));if(n.length>0)return n;const r=Ui(ke(e,"output"));if(r.length>0)return r;const o=ke(e,"arguments");return typeof o=="string"?o:""}function X5(e){const t=ke(e,"role");if(t==="system"||t==="user"||t==="assistant"||t==="tool")return t;const n=ke(e,"type");return n==="function_call_output"?"tool":"user"}function Q5(e){const t=ke(e,"output");if(!Array.isArray(t))return[];const n=[];for(const r of t){if(ke(r,"type")!=="function_call")continue;const o=ke(r,"name");typeof o=="string"&&o.length>0&&n.push(o)}return n}function ar(e,t,n,r){return{role:e,label:t,text:n,size:ol(n),characters:il(n),path:r}}const eN={format:"openai",analyzeRequest(e){if(e===null)return xn(e);try{const t=xd.safeParse(JSON.parse(e));if(!t.success){const n=bd.safeParse(JSON.parse(e));return n.success?{parsed:n.data,comparisonValue:n.data,messageCount:J5(n.data.input),toolCount:n.data.tools!==void 0&&n.data.tools.length>0?n.data.tools.length:null}:xn(e)}return{parsed:t.data,comparisonValue:t.data,messageCount:t.data.messages.length,toolCount:t.data.tools!==void 0&&t.data.tools.length>0?t.data.tools.length:null}}catch{return xn(e)}},analyzeResponse(e){if(e===null)return Un;const t=yd(e);if(t===null){const r=wd(e);if(r===null)return Un;const o=Q5(r);return{parsed:r,toolNames:o.length>0?o:null}}const n=t.choices[0]?.message?.tool_calls?.map(r=>r.function?.name??"").filter(r=>r!=="")??[];return{parsed:t,toolNames:n.length>0?n:null}},anatomySegments(e){if(e===null||typeof e!="object")return null;const t=e,n=[];if(typeof t.instructions=="string"&&t.instructions.length>0&&n.push(ar("system","instructions",t.instructions,"/instructions")),Array.isArray(t.messages)&&t.messages.forEach((r,o)=>{if(r===null||typeof r!="object")return;const i=r,a=i.role==="user"||i.role==="assistant"||i.role==="system"||i.role==="tool"?i.role:"user",l=G5(i);n.push(ar(a,`[${o}] ${a}`,l,`/messages/${o}`))}),Array.isArray(t.messages)||(typeof t.input=="string"&&t.input.length>0?n.push(ar("user","input",t.input,"/input")):Array.isArray(t.input)&&t.input.forEach((r,o)=>{const i=X5(r),a=Y5(r);n.push(ar(i,`[${o}] ${i}`,a,`/input/${o}`))})),Array.isArray(t.tools)&&t.tools.length>0){const r=K5(t.tools);n.push(ar("tools","tools",r,"/tools"))}return n.length>0?n:null}},tN={format:"unknown",analyzeRequest(e){return xn(e)},analyzeResponse(){return Un},anatomySegments(){return null}},nN={anthropic:q5,openai:eN,unknown:tN};function Ah(e){return nN[e]}function Nr(e){const t=g5(e.path);return t==="unknown"?e.apiFormat:t}function rN({conversationId:e,startTime:t,endTime:n,totalCalls:r,totalInputTokens:o,totalOutputTokens:i,expanded:a,onToggle:l,providers:c,isLoading:u=!1,userAgent:d,clientPid:f,clientProjectFolder:h,timeDisplayFormat:m,onClear:v}){const[g,x]=p.useState(!1),b=E=>{E.stopPropagation(),v!==void 0&&x(!0)},y=p.useCallback(E=>{E.stopPropagation(),window.open(Au(e),"_blank","noopener,noreferrer")},[e]),_=c?.map(({provider:E,models:P})=>({provider:E,tooltip:P.length===1?P[0]??E:P.join(", ")}))??[],j=R_({userAgent:d,conversationId:e,clientProjectFolder:h}),S=Pf(j),T=d!=null&&d!=="",C=S??d??null,A=S!==null&&T?`${S} - ${d}`:null;return s.jsxs("div",{role:"button",tabIndex:0,"data-nav-id":`conv-${e}`,"data-nav-action":a?"collapse":"expand",className:de("flex items-center gap-3 px-3 py-2 cursor-pointer transition-colors","hover:bg-muted/50","select-none","border border-border rounded-lg mb-2 bg-background sticky top-0 z-10","focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none"),onClick:l,onKeyDown:E=>{E.target===E.currentTarget&&(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),l())},children:[s.jsx(c5,{items:_,ariaLabel:"Models used in this session"}),s.jsx("span",{className:nl,children:a?s.jsx(ct,{className:"size-4 shrink-0"}):u?s.jsx(ht,{className:"size-4 shrink-0 animate-spin"}):s.jsx(Ot,{className:"size-4 shrink-0"})}),e.startsWith("PID:")||e.includes("|")?s.jsxs(s.Fragment,{children:[f!=null?s.jsxs("span",{className:"text-purple-400/90 font-mono text-xs font-semibold shrink-0",title:`PID ${f}`,children:["PID ",f]}):s.jsx("span",{className:"text-purple-400/90 font-mono text-xs font-semibold shrink-0",children:e}),h!=null&&h!==""&&s.jsx("span",{className:"text-muted-foreground text-xs font-mono truncate max-w-[200px] shrink-0",title:h,children:h})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-purple-400/90 font-mono text-xs font-semibold shrink-0",title:e,children:e.length>24?e.slice(0,12)+"..."+e.slice(-12):e}),f!=null&&s.jsxs("span",{className:"text-muted-foreground text-xs font-mono tabular-nums shrink-0 px-1.5 py-0.5 rounded border border-border bg-muted/40",title:`Client process ID ${f}`,children:["PID ",f]})]}),C!==null&&C!==""&&s.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-xs shrink-0",title:A??C,children:[s.jsx(M_,{client:j,className:"size-5"}),s.jsx("span",{className:"font-mono tabular-nums truncate max-w-[120px]",children:C})]}),s.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-xs shrink-0",children:[s.jsx(Bt,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:Ea(t,n,m)})]}),s.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-xs shrink-0",children:[s.jsx(uo,{className:"size-3"}),s.jsxs("span",{className:"font-mono tabular-nums",children:[r," call",r!==1?"s":""]})]}),s.jsxs("span",{className:"flex items-center gap-1 text-xs shrink-0",children:[s.jsx(jr,{className:"size-3 text-muted-foreground"}),s.jsxs("span",{className:"font-mono tabular-nums",children:[s.jsx("span",{className:"text-blue-400",children:Be(o)})," / ",s.jsx("span",{className:"text-amber-400",children:Be(i)})]})]}),s.jsx("span",{className:"flex-1 min-w-0"}),s.jsx("button",{type:"button",onClick:y,onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&y(E)},"aria-label":`Open session ${e} in a new tab`,title:"Open this session in a new tab",className:"text-muted-foreground hover:text-foreground transition-colors shrink-0 inline-flex items-center justify-center size-8 rounded hover:bg-muted cursor-pointer",children:s.jsx(_a,{className:"size-3.5"})}),v!==void 0&&s.jsx("button",{type:"button",onClick:b,"aria-label":`Clear group (${r} request${r!==1?"s":""})`,title:"Clear this group",className:"text-muted-foreground hover:text-foreground transition-colors shrink-0 inline-flex items-center justify-center size-8 rounded hover:bg-muted cursor-pointer",children:s.jsx(qn,{className:"size-3.5"})}),s.jsx(Of,{open:g,onOpenChange:x,title:"Clear this group?",description:`This will remove ${r} request${r!==1?"s":""} from this conversation. This action cannot be undone.`,confirmLabel:"Clear",variant:"destructive",onConfirm:()=>{v?.()}})]})}function sN(e){if(e.isTest===!0)return"provider-test";if(e.sessionId!==null&&e.sessionId!==""&&e.sessionId!==void 0)return e.sessionId;const t=e.clientPid!==null&&e.clientPid!==void 0,n=e.clientProjectFolder!==null&&e.clientProjectFolder!==void 0;if(!t&&!n)return"default";const r=t?`PID:${e.clientPid}`:"unknown",o=n?e.clientProjectFolder:"no-folder";return`${r}|${o}`}function oN(e){const t=new Map;for(const r of e){const o=sN(r),i=t.get(o);i!==void 0?i.push(r):t.set(o,[r])}const n=[];for(const[r,o]of t){const i=[...o].sort((a,l)=>a.timestamp.localeCompare(l.timestamp));n.push({id:r,conversationId:r,logs:i})}return n.sort((r,o)=>(r.logs[0]?.timestamp??"").localeCompare(o.logs[0]?.timestamp??"")),n}function iN(e,t,n){const r=new Array(e);return new Proxy(r,{get(o,i,a){if(typeof i=="string"){const l=i.charCodeAt(0);if(l>=48&&l<=57){const c=+i;if(Number.isInteger(c)&&c>=0&&c<e){let u=o[c];if(!u){const d=t[c*2];u=o[c]={index:c,key:n(c),start:d,size:t[c*2+1],end:d+t[c*2+1],lane:0}}return u}}if(i==="length")return e}return Reflect.get(o,i,a)}})}function In(e,t,n){let r=n.initialDeps??[],o,i=!0;function a(){const l=e();return(l.length!==r.length||l.some((u,d)=>r[d]!==u))&&(r=l,o=t(...l),n?.onChange&&!(i&&n.skipInitialOnChange)&&n.onChange(o),i=!1),o}return a.updateDeps=l=>{r=l},a}function Sc(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const Cc=(e,t)=>Math.abs(e-t)<1.01,aN=(e,t,n)=>{let r;return function(...o){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,o),n)}};let lr;const Nc=()=>{if(lr!==void 0)return lr;if(typeof navigator>"u")return lr=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return lr=!0;const e=navigator.maxTouchPoints;return lr=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Tc=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},lN=e=>e,cN=e=>{const t=Math.max(e.startIndex-e.overscan,0),r=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,o=new Array(r);for(let i=0;i<r;i++)o[i]=t+i;return o},uN=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const o=a=>{const{width:l,height:c}=a;t({width:Math.round(l),height:Math.round(c)})};if(o(Tc(n)),!r.ResizeObserver)return()=>{};const i=new r.ResizeObserver(a=>{const l=()=>{const c=a[0];if(c?.borderBoxSize){const u=c.borderBoxSize[0];if(u){o({width:u.inlineSize,height:u.blockSize});return}}o(Tc(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()});return i.observe(n,{box:"border-box"}),()=>{i.unobserve(n)}},Tr={passive:!0},dN=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=()=>{t({width:n.innerWidth,height:n.innerHeight})};return r(),n.addEventListener("resize",r,Tr),()=>{n.removeEventListener("resize",r)}},fN=typeof window>"u"?!0:"onscrollend"in window,Rh=(e,t,n)=>{const r=e.scrollElement;if(!r)return;const o=e.targetWindow;if(!o)return;const i=e.options.useScrollendEvent&&fN;let a=0;const l=i?null:aN(o,()=>t(a,!1),e.options.isScrollingResetDelay),c=f=>()=>{a=n(r),l?.(),t(a,f)},u=c(!0),d=c(!1);return r.addEventListener("scroll",u,Tr),i&&r.addEventListener("scrollend",d,Tr),()=>{r.removeEventListener("scroll",u),i&&r.removeEventListener("scrollend",d)}},pN=(e,t)=>Rh(e,t,n=>{const{horizontal:r,isRtl:o}=e.options;return r?n.scrollLeft*(o&&-1||1):n.scrollTop}),hN=(e,t)=>Rh(e,t,n=>e.options.horizontal?n.scrollX:n.scrollY),mN=(e,t,n)=>{if(t?.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},Ih=(e,{adjustments:t=0,behavior:n},r)=>{var o,i;(i=(o=r.scrollElement)==null?void 0:o.scrollTo)==null||i.call(o,{[r.options.horizontal?"left":"top"]:e+t,behavior:n})},gN=Ih,xN=Ih;class bN{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var n,r,o;return((o=(r=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:r.now)==null?void 0:o.call(r))??Date.now()},this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(o=>{o.forEach(i=>{const a=()=>{const l=i.target,c=this.indexFromElement(l);if(!l.isConnected){this.observer.unobserve(l);for(const[u,d]of this.elementsCache)if(d===l){this.elementsCache.delete(u);break}return}this.shouldMeasureDuringScroll(c)&&this.resizeItem(c,this.options.measureElement(l,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()})}));return{disconnect:()=>{var o;(o=r())==null||o.disconnect(),n=null},observe:o=>{var i;return(i=r())==null?void 0:i.observe(o,{box:"border-box"})},unobserve:o=>{var i;return(i=r())==null?void 0:i.unobserve(o)}}})(),this.range=null,this.setOptions=n=>{var r,o;const i={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:lN,rangeExtractor:cN,onChange:()=>{},measureElement:mN,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate"};for(const u in n){const d=n[u];d!==void 0&&(i[u]=d)}const a=this.options;let l=null,c=null;if(a!==void 0&&a.enabled&&i.enabled&&i.anchorTo==="end"&&this.scrollElement!==null){const u=a.count,d=i.count,f=this.getMeasurements(),h=u>0?((r=f[0])==null?void 0:r.key)??a.getItemKey(0):null,m=u>0?((o=f[u-1])==null?void 0:o.key)??a.getItemKey(u-1):null;if(d!==u||u>0&&d>0&&(i.getItemKey(0)!==h||i.getItemKey(d-1)!==m)){const x=u>0?this.getVirtualItemForOffset(this.getScrollOffset())??f[0]:null;x&&(l=[x.key,this.getScrollOffset()-x.start]);const b=i.followOnAppend===!0?"auto":i.followOnAppend||null;b&&d>u&&this.isAtEnd(a.scrollEndThreshold)&&(u===0||i.getItemKey(d-1)!==m)&&(c=b)}}this.options=i,(l||c)&&(this.pendingScrollAnchor=[l?.[0]??null,l?.[1]??0,c])},this.notify=n=>{var r,o;(o=(r=this.options).onChange)==null||o.call(r,this,n)},this.maybeNotify=In(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}if(this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)}),this.unsubs.push(this.options.observeElementRect(this,i=>{this.scrollRect=i,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(i,a)=>{this._intendedScrollOffset!==null&&Math.abs(i-this._intendedScrollOffset)<1.5&&(i=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=a?this.getScrollOffset()<i?"forward":"backward":null,this.scrollOffset=i,this.isScrolling=a,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const i=this.scrollElement,a=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},l=()=>{this._iosTouching=!1,!(!Nc()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",a,Tr),i.addEventListener("touchend",l,Tr),this.unsubs.push(()=>{i.removeEventListener("touchstart",a),i.removeEventListener("touchend",l),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const o=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,o&&this.scrollElement&&this.options.enabled){const[i,a,l]=o;if(i!==null){const{count:c,getItemKey:u}=this.options;let d=0;for(;d<c&&u(d)!==i;)d++;const f=d<c?this.getMeasurements()[d]:void 0;if(f){const h=f.start+a-this.getScrollOffset();Cc(h,0)||this.applyScrollAdjustment(h)}}l&&this.scrollToEnd({behavior:l})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const n=this.getScrollOffset(),r=this.getMaxScrollOffset();if(n<0||n>r)return;const o=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(n,{adjustments:this.scrollAdjustments+=o,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(n,r)=>{const o=new Map,i=new Map;for(let a=r-1;a>=0;a--){const l=n[a];if(o.has(l.lane))continue;const c=i.get(l.lane);if(c==null||l.end>c.end?i.set(l.lane,l):l.end<c.end&&o.set(l.lane,!0),o.size===this.options.lanes)break}return i.size===this.options.lanes?Array.from(i.values()).sort((a,l)=>a.end===l.end?a.index-l.index:a.end-l.end)[0]:void 0},this.getMeasurementOptions=In(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(n,r,o,i,a,l,c)=>(this.prevLanes!==void 0&&this.prevLanes!==l&&(this.lanesChangedFlag=!0),this.prevLanes=l,this.pendingMin=null,{count:n,paddingStart:r,scrollMargin:o,getItemKey:i,enabled:a,lanes:l,laneAssignmentMode:c}),{key:!1}),this.getMeasurements=In(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:n,paddingStart:r,scrollMargin:o,getItemKey:i,enabled:a,lanes:l,laneAssignmentMode:c},u)=>{const d=this.itemSizeCache;if(!a)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const v of this.laneAssignments.keys())v>=n&&this.laneAssignments.delete(v);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(v=>{this.itemSizeCache.set(v.key,v.size)}));const f=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1),l===1){const v=this.options.gap,g=n*2;let x=this._flatMeasurements;if(!x||x.length<g){const _=new Float64Array(g);x&&f>0&&_.set(x.subarray(0,f*2)),x=_,this._flatMeasurements=x}let b;if(f===0)b=r+o;else{const _=f-1;b=x[_*2]+x[_*2+1]+v}for(let _=f;_<n;_++){const j=i(_),S=d.get(j),T=typeof S=="number"?S:this.options.estimateSize(_);x[_*2]=b,x[_*2+1]=T,b+=T+v}const y=iN(n,x,i);return this.measurementsCache=y,y}const h=this.measurementsCache.slice(0,f),m=new Array(l).fill(void 0);for(let v=0;v<f;v++){const g=h[v];g&&(m[g.lane]=v)}for(let v=f;v<n;v++){const g=i(v),x=this.laneAssignments.get(v);let b,y;const _=c==="estimate"||d.has(g);if(x!==void 0&&this.options.lanes>1){b=x;const C=m[b],A=C!==void 0?h[C]:void 0;y=A?A.end+this.options.gap:r+o}else{const C=this.options.lanes===1?h[v-1]:this.getFurthestMeasurement(h,v);y=C?C.end+this.options.gap:r+o,b=C?C.lane:v%this.options.lanes,this.options.lanes>1&&_&&this.laneAssignments.set(v,b)}const j=d.get(g),S=typeof j=="number"?j:this.options.estimateSize(v),T=y+S;h[v]={index:v,start:y,size:S,end:T,key:g,lane:b},m[b]=v}return this.measurementsCache=h,h},{key:!1,debug:()=>this.options.debug}),this.calculateRange=In(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,r,o,i)=>this.range=n.length>0&&r>0?vN({measurements:n,outerSize:r,scrollOffset:o,lanes:i,flat:i===1&&this._flatMeasurements!=null?this._flatMeasurements:null}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=In(()=>{let n=null,r=null;const o=this.calculateRange();return o&&(n=o.startIndex,r=o.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,o,i,a)=>i===null||a===null?[]:n({startIndex:i,endIndex:a,overscan:r,count:o}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,o=n.getAttribute(r);return o?parseInt(o,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{var r;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const o=this.scrollState.index??((r=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:r.index);if(o!==void 0&&this.range){const i=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),a=Math.max(0,o-i),l=Math.min(this.options.count-1,o+i);return n>=a&&n<=l}return!0},this.measureElement=n=>{if(!n){this.elementsCache.forEach((a,l)=>{a.isConnected||(this.observer.unobserve(a),this.elementsCache.delete(l))});return}const r=this.indexFromElement(n),o=this.options.getItemKey(r),i=this.elementsCache.get(o);i!==n&&(i&&this.observer.unobserve(i),this.observer.observe(n),this.elementsCache.set(o,n)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(r)&&this.resizeItem(r,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,r)=>{var o,i;if(n<0||n>=this.options.count)return;let a,l,c;const u=this._flatMeasurements;if(this.options.lanes===1&&u!==null)c=this.options.getItemKey(n),l=u[n*2],a=u[n*2+1];else{const h=this.measurementsCache[n];if(!h)return;c=h.key,l=h.start,a=h.size}const d=this.itemSizeCache.get(c)??a,f=r-d;if(f!==0){const h=this.options.anchorTo==="end"&&((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,m=h?this.getTotalSize():0,v=((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[n]??{index:n,key:c,start:l,size:a,end:l+a,lane:0},f,this):l<this.getScrollOffset()+this.scrollAdjustments&&this.scrollDirection!=="backward");(this.pendingMin===null||n<this.pendingMin)&&(this.pendingMin=n),this.itemSizeCache.set(c,r),this.itemSizeCacheVersion++,h?this.applyScrollAdjustment(this.getTotalSize()-m):v&&this.applyScrollAdjustment(f),this.notify(!1)}},this.getVirtualItems=In(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const o=[];for(let i=0,a=n.length;i<a;i++){const l=n[i],c=r[l];o.push(c)}return o},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length===0)return;const o=this._flatMeasurements,i=this.options.lanes===1&&o!=null,a=zh(0,r.length-1,i?l=>o[l*2]:l=>Sc(r[l]).start,n);return Sc(r[a])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const n=this.scrollElement.document.documentElement;return this.options.horizontal?n.scrollWidth-this.scrollElement.innerWidth:n.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(n=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=n,this.getOffsetForAlignment=(n,r,o=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),a=this.getScrollOffset();r==="auto"&&(r=n>=a+i?"end":"start"),r==="center"?n+=(o-i)/2:r==="end"&&(n-=i);const l=this.getMaxScrollOffset();return Math.max(Math.min(l,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const o=this.getSize(),i=this.getScrollOffset(),a=this.measurementsCache[n];if(!a)return;if(r==="auto")if(a.end>=i+o-this.options.scrollPaddingEnd)r="end";else if(a.start<=i+this.options.scrollPaddingStart)r="start";else return[i,r];if(r==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),r];const l=r==="end"?a.end+this.options.scrollPaddingEnd:a.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(l,r,a.size),r]},this.scrollToOffset=(n,{align:r="start",behavior:o="auto"}={})=>{const i=this.getOffsetForAlignment(n,r),a=this.now();this.scrollState={index:null,align:r,behavior:o,startedAt:a,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:r="auto",behavior:o="auto"}={})=>{n=Math.max(0,Math.min(n,this.options.count-1));const i=this.getOffsetForIndex(n,r);if(!i)return;const[a,l]=i,c=this.now();this.scrollState={index:n,align:l,behavior:o,startedAt:c,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:r="auto"}={})=>{const o=this.getScrollOffset()+n,i=this.now();this.scrollState={index:null,align:"start",behavior:r,startedAt:i,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:n="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:n});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:n})},this.getTotalSize=()=>{var n;const r=this.getMeasurements();let o;if(r.length===0)o=this.options.paddingStart;else if(this.options.lanes===1){const i=r.length-1,a=this._flatMeasurements;a!=null?o=a[i*2]+a[i*2+1]:o=((n=r[i])==null?void 0:n.end)??0}else{const i=Array(this.options.lanes).fill(null);let a=r.length-1;for(;a>=0&&i.some(l=>l===null);){const l=r[a];i[l.lane]===null&&(i[l.lane]=l.end),a--}o=Math.max(...i.filter(l=>l!==null))}return Math.max(o-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const n=[];if(this.itemSizeCache.size===0)return n;const r=this.getMeasurements();for(const o of r)o&&this.itemSizeCache.has(o.key)&&n.push({index:o.index,key:o.key,start:o.start,size:o.size,end:o.end,lane:o.lane});return n},this._scrollToOffset=(n,{adjustments:r,behavior:o})=>{this._intendedScrollOffset=n+(r??0),this.options.scrollToFn(n,{behavior:o,adjustments:r},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(t)}applyScrollAdjustment(t,n){t!==0&&(Nc()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=t:this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=t,behavior:n}))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const r=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,o=r?r[0]:this.scrollState.lastTargetOffset,i=1,a=o!==this.scrollState.lastTargetOffset;if(!a&&Cc(o,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=i){this.getScrollOffset()!==o&&this._scrollToOffset(o,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,a){const l=this.getSize()||600,c=Math.abs(o-this.getScrollOffset()),u=this.scrollState.behavior==="smooth"&&c>l;this.scrollState.lastTargetOffset=o,u||(this.scrollState.behavior="auto"),this._scrollToOffset(o,{adjustments:void 0,behavior:u?"smooth":"auto"})}this.scheduleScrollReconcile()}}const zh=(e,t,n,r)=>{for(;e<=t;){const o=(e+t)/2|0,i=n(o);if(i<r)e=o+1;else if(i>r)t=o-1;else return o}return e>0?e-1:0};function vN({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:o}){const i=e.length-1,a=o?d=>o[d*2]:d=>e[d].start,l=o?d=>o[d*2]+o[d*2+1]:d=>e[d].end;if(e.length<=r)return{startIndex:0,endIndex:i};let c=zh(0,i,a,n),u=c;if(r===1)for(;u<i&&l(u)<n+t;)u++;else if(r>1){const d=Array(r).fill(0);for(;u<i&&d.some(h=>h<n+t);){const h=e[u];d[h.lane]=h.end,u++}const f=Array(r).fill(n+t);for(;c>=0&&f.some(h=>h>=n);){const h=e[c];f[h.lane]=h.start,c--}c=Math.max(0,c-c%r),u=Math.min(i,u+(r-1-u%r))}return{startIndex:c,endIndex:u}}const Ec=typeof document<"u"?p.useLayoutEffect:p.useEffect;function Oh({useFlushSync:e=!0,...t}){const n=p.useReducer(i=>i+1,0)[1],r={...t,onChange:(i,a)=>{var l;e&&a?Ar.flushSync(n):n(),(l=t.onChange)==null||l.call(t,i,a)}},[o]=p.useState(()=>new bN(r));return o.setOptions(r),Ec(()=>o._didMount(),[]),Ec(()=>o._willUpdate()),o}function yN(e){return Oh({observeElementRect:uN,observeElementOffset:pN,scrollToFn:xN,...e})}function Ph(e){return Oh({getScrollElement:()=>typeof document<"u"?window:null,observeElementRect:dN,observeElementOffset:hN,scrollToFn:gN,initialOffset:()=>typeof document<"u"?window.scrollY:0,...e})}const jt="agent-inspector:focus-log";function Vs(e){window.dispatchEvent(new CustomEvent(jt,{detail:e}))}function Br(e){if(typeof CustomEvent>"u"||!(e instanceof CustomEvent))return null;const t=e.detail,n=ke(t,"logId");if(typeof n!="number"||!Number.isInteger(n)||n<0)return null;const r=ke(t,"tab");switch(r){case"anatomy":case"request":break;case void 0:break;default:return null}const o=ke(t,"source");switch(o){case"virtualizer":return{logId:n,tab:r??"request",source:o};case void 0:return{logId:n,tab:r??"request"};default:return null}}function os(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function wN(e){switch(e){case"end_turn":case"tool_use":return e;default:return null}}function kN(e){switch(e){case"stop":case"length":return e;default:return null}}function _N(e){switch(e){case"max_output_tokens":case"max_tokens":return!0;default:return!1}}function jN(e){if(e.responseText===null)return null;try{let t=JSON.parse(e.responseText);if(typeof t=="string"&&(t=JSON.parse(t)),!os(t))return null;if(typeof t.stop_reason=="string")return wN(t.stop_reason);if(Array.isArray(t.choices))for(const n of t.choices){if(!os(n)||typeof n.finish_reason!="string")continue;const r=kN(n.finish_reason);if(r!==null)return r}if(Array.isArray(t.output)){for(const n of t.output)if(os(n)&&n.type==="function_call")return"tool_use";if(t.status==="completed")return"stop"}if(t.status==="incomplete"&&os(t.incomplete_details)){const n=t.incomplete_details.reason;if(typeof n=="string"&&_N(n))return"length"}return null}catch{return null}}function ll(e){return e==="end_turn"||e==="stop"||e==="length"}function bt({className:e,style:t,d:n,eyeStalks:r,eyes:o,legs:i,extras:a}){return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:t,className:de("inline-block size-5",e),children:[s.jsx("path",{d:n}),r,o,i,a]})}const un=s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"6.5",y1:"16",x2:"4.5",y2:"19.5"}),s.jsx("line",{x1:"9",y1:"17.5",x2:"8",y2:"20.5"}),s.jsx("line",{x1:"15",y1:"17.5",x2:"16",y2:"20.5"}),s.jsx("line",{x1:"17.5",y1:"16",x2:"19.5",y2:"19.5"})]}),Mh=s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"7",y1:"16",x2:"5.5",y2:"18.5"}),s.jsx("line",{x1:"9.5",y1:"17",x2:"8.5",y2:"19.5"}),s.jsx("line",{x1:"14.5",y1:"17",x2:"15.5",y2:"19.5"}),s.jsx("line",{x1:"17",y1:"16",x2:"18.5",y2:"18.5"})]});function Lh({className:e}){return s.jsx(bt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),s.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"})]}),legs:un,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),s.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"})]})})}function SN({className:e}){return s.jsx(bt,{className:e,d:"M4 13 C4 7 7.5 5.5 12 5.5 C16.5 5.5 20 7 20 13 C20 17.5 16.5 19 12 19 C7.5 19 4 17.5 4 13 Z",eyeStalks:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"9.5",y1:"6.5",x2:"9.5",y2:"4.5"}),s.jsx("line",{x1:"14.5",y1:"6.5",x2:"14.5",y2:"4.5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9.5",cy:"4",r:"1.1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14.5",cy:"4",r:"1.1",fill:"currentColor",stroke:"none"})]}),legs:Mh,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C4 9.5 2.5 10 3 12 C3.5 13.5 4.5 13 5 12"}),s.jsx("path",{d:"M19 11 C20 9.5 21.5 10 21 12 C20.5 13.5 19.5 13 19 12"})]})})}function CN({className:e}){return s.jsx(bt,{className:e,d:"M3 13.5 C3 8 7 6 12 6 C17 6 21 8 21 13.5 C21 17 17 19 12 19 C7 19 3 17 3 13.5 Z",eyeStalks:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"7",y1:"7",x2:"6.5",y2:"4.5"}),s.jsx("line",{x1:"17",y1:"7",x2:"17.5",y2:"4.5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"6.5",cy:"4",r:"0.8",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"17.5",cy:"4",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:un,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M4 12 C2.5 10.5 1 11 1.5 13 C2 14.5 3.5 14 4.5 13"}),s.jsx("path",{d:"M20 12 C21.5 10.5 23 11 22.5 13 C22 14.5 20.5 14 19.5 13"})]})})}function NN({className:e}){return s.jsx(bt,{className:e,d:"M6 14 C6 8 9 5.5 12 5.5 C15 5.5 18 8 18 14 C18 18 15 20 12 20 C9 20 6 18 6 14 Z",eyeStalks:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"6.5",x2:"10",y2:"3.5"}),s.jsx("line",{x1:"14",y1:"6.5",x2:"14",y2:"3.5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"10",cy:"3",r:"0.7",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14",cy:"3",r:"0.7",fill:"currentColor",stroke:"none"})]}),legs:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"7",y1:"17",x2:"5",y2:"20.5"}),s.jsx("line",{x1:"9.5",y1:"18.5",x2:"8.5",y2:"21.5"}),s.jsx("line",{x1:"14.5",y1:"18.5",x2:"15.5",y2:"21.5"}),s.jsx("line",{x1:"17",y1:"17",x2:"19",y2:"20.5"})]}),extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M6.5 11 C5 8.5 3 9 3.5 11.5 C4 13.5 5 13 6 12"}),s.jsx("path",{d:"M17.5 11 C19 8.5 21 9 20.5 11.5 C20 13.5 19 13 18 12"})]})})}function TN({className:e}){return s.jsx(bt,{className:e,d:"M5 13 C5 9 8 7 12 7 L13 4 L14 7 C16 7 19 9 19 13 C19 16 16 18 13 18 L12 21 L11 18 C8 18 5 16 5 13 Z",eyeStalks:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),s.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.8",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:un,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),s.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"})]})})}function EN({className:e}){return s.jsx(bt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),s.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),s.jsx("line",{x1:"13.5",y1:"4",x2:"15.5",y2:"5"})]}),legs:un,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),s.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"})]})})}function AN({className:e}){return s.jsx(bt,{className:e,d:"M5.5 13.5 C5.5 10 8.5 8 12 8 C15.5 8 18.5 10 18.5 13.5 C18.5 16 15.5 17.5 12 17.5 C8.5 17.5 5.5 16 5.5 13.5 Z",eyeStalks:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"8",x2:"10",y2:"6"}),s.jsx("line",{x1:"14",y1:"8",x2:"14",y2:"6"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"9",y1:"6",x2:"11",y2:"6.5"}),s.jsx("line",{x1:"13",y1:"6",x2:"15",y2:"6.5"})]}),legs:Mh,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M6 11.5 C4.5 10.5 3 11 3.5 12.5 C4 13.5 5 13 5.5 12.5"}),s.jsx("path",{d:"M18 11.5 C19.5 10.5 21 11 20.5 12.5 C20 13.5 19 13 18.5 12.5"})]})})}function RN({className:e}){return s.jsx(bt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),s.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"})]}),legs:un,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),s.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),s.jsx("line",{x1:"8.5",y1:"4",x2:"10.5",y2:"4.5"}),s.jsx("line",{x1:"15.5",y1:"4",x2:"13.5",y2:"4.5"}),s.jsx("path",{d:"M9 15.5 C10 14.5 14 14.5 15 15.5"})]})})}function IN({className:e}){return s.jsx(bt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),s.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9.5",cy:"4.5",r:"1.2",fill:"none",stroke:"currentColor"}),s.jsx("circle",{cx:"14.5",cy:"4.5",r:"1.2",fill:"none",stroke:"currentColor"})]}),legs:un,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),s.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),s.jsx("ellipse",{cx:"12",cy:"15",rx:"2",ry:"1.5",fill:"currentColor",stroke:"none"})]})})}function zN({className:e}){return s.jsx(bt,{className:e,d:"M4.5 13 C4.5 8 7.5 6 12 6 C16.5 6 19.5 8 19.5 13 C19.5 17 16.5 18.5 12 18.5 C7.5 18.5 4.5 17 4.5 13 Z",eyeStalks:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"9.5",y1:"7",x2:"9",y2:"5"}),s.jsx("line",{x1:"14.5",y1:"7",x2:"15",y2:"5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"15",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"})]}),legs:un,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C3.5 9 2 9.5 2.5 12 C3 14 4 13 5 12"}),s.jsx("path",{d:"M19 11 C20.5 9 22 9.5 21.5 12 C21 14 20 13 19 12"}),s.jsx("path",{d:"M9 14.5 C10 16 14 16 15 14.5"}),s.jsx("circle",{cx:"7",cy:"13",r:"1",fill:"currentColor",stroke:"none",opacity:"0.3"}),s.jsx("circle",{cx:"17",cy:"13",r:"1",fill:"currentColor",stroke:"none",opacity:"0.3"})]})})}function ON({className:e}){return s.jsx(bt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5.5"}),s.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5.5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"7.5",y1:"5.5",x2:"16.5",y2:"5.5"}),s.jsx("rect",{x:"7",y:"5",width:"4",height:"2",rx:"0.5",fill:"currentColor",stroke:"none"}),s.jsx("rect",{x:"13",y:"5",width:"4",height:"2",rx:"0.5",fill:"currentColor",stroke:"none"})]}),legs:un,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),s.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),s.jsx("path",{d:"M9.5 15 C10.5 16 13.5 16 14.5 15"})]})})}function PN({className:e}){return s.jsx(bt,{className:e,d:"M7 13.5 C7 10.5 9.5 9 12 9 C14.5 9 17 10.5 17 13.5 C17 16 14.5 17.5 12 17.5 C9.5 17.5 7 16 7 13.5 Z",eyeStalks:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10.5",y1:"9.5",x2:"10.5",y2:"8"}),s.jsx("line",{x1:"13.5",y1:"9.5",x2:"13.5",y2:"8"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"10.5",cy:"7.5",r:"0.8",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"13.5",cy:"7.5",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"8",y1:"16",x2:"6.5",y2:"18"}),s.jsx("line",{x1:"10",y1:"17",x2:"9.5",y2:"19"}),s.jsx("line",{x1:"14",y1:"17",x2:"14.5",y2:"19"}),s.jsx("line",{x1:"16",y1:"16",x2:"17.5",y2:"18"})]}),extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M7.5 12 C6.5 11 5.5 11.5 6 13 C6.5 14 7 13.5 7.5 13"}),s.jsx("path",{d:"M16.5 12 C17.5 11 18.5 11.5 18 13 C17.5 14 17 13.5 16.5 13"})]})})}const Er=[Lh,SN,CN,NN,TN,EN,AN,RN,IN,zN,ON,PN];function qs(e){return Er[Math.abs(e)%Er.length]??Lh}function MN(e){const t=Er.length-2;return t<=0?0:1+((Number.isFinite(e)?Math.trunc(e):0)%t+t)%t}function LN(e){return qs(MN(e))}const DN="x-anthropic-billing-header:";function $N(e){return e.trimStart().toLowerCase().startsWith(DN)}function FN(e){return al(e)?Object.prototype.hasOwnProperty.call(e,"system"):!1}function BN(e){if(!al(e))return!1;const t=ke(e,"type"),n=ke(e,"text");return typeof t!="string"||t!=="text"||typeof n!="string"?!1:$N(n)}function UN(e){let t;try{t=JSON.parse(e)}catch{return{body:e,removed:0}}if(!FN(t))return{body:e,removed:0};const n=t.system;if(!Array.isArray(n)||n.length===0)return{body:e,removed:0};const r=[];let o=0;for(const i of n){if(BN(i)){o+=1;continue}r.push(i)}return o===0?{body:e,removed:0}:(r.length===0?delete t.system:t.system=r,{body:JSON.stringify(t),removed:o})}const WN=400,Ac=2e3;function HN(e){return Array.isArray(e)}function ZN(e,t){const n=[e];let r=0;for(;n.length>0;){const o=n.pop();if(o!==void 0){if(r+=1,r>t)return r;if(!(o===null||typeof o!="object")){if(HN(o)){for(const i of o)n.push(i);continue}for(const i of Object.keys(o)){const a=o[i];a!==void 0&&n.push(a)}}}}return r}function VN(e){const t=ZN(e,Ac+1);return t<=WN?{depth:Number.POSITIVE_INFINITY}:t<=Ac?{depth:3}:{depth:2}}function qN(e){try{const t=JSON.parse(e);return{kind:"json",data:Gs(t)}}catch{return{kind:"text"}}}function ei(e){const t=p.useMemo(()=>e===null?null:qN(e),[e]),n=t?.kind==="json"?t.data:null,r=p.useMemo(()=>n===null?null:VN(n),[n]),[o,i]=p.useState(!1),[a,l]=p.useState(0),[c,u]=p.useState(0),[d,f]=p.useTransition(),h=p.useCallback(()=>{const m=!o,v=m&&r!==null?r.depth:0;f(()=>{i(m),l(v),u(g=>g+1)})},[o,r]);return{parsedData:n,policy:r,isExpanded:o,toggle:h,isPending:d,bulkDepth:a,bulkRevision:c}}function Gs(e){if(e==null)return null;switch(typeof e){case"string":return e;case"number":return e;case"boolean":return e;case"object":{if(Array.isArray(e))return e.map(n=>Gs(n));const t={};for(const n of Object.keys(e)){const r=Object.getOwnPropertyDescriptor(e,n);t[n]=Gs(r?.value)}return t}case"bigint":case"symbol":case"function":case"undefined":return String(e)}return null}function Dh({className:e,orientation:t="horizontal",...n}){return s.jsx(LC,{"data-slot":"tabs","data-orientation":t,orientation:t,className:de("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",e),...n})}const GN=La("rounded-lg p-[3px] group-data-[orientation=horizontal]/tabs:h-9 data-[variant=line]:rounded-none group/tabs-list text-muted-foreground inline-flex w-fit items-center justify-center group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function $h({className:e,variant:t="default",...n}){return s.jsx(DC,{"data-slot":"tabs-list","data-variant":t,className:de(GN({variant:t}),e),...n})}function dt({className:e,...t}){return s.jsx($C,{"data-slot":"tabs-trigger",className:de("focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-foreground/60 hover:text-foreground dark:text-muted-foreground dark:hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent","data-[state=active]:bg-background dark:data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 data-[state=active]:text-foreground","after:bg-foreground after:absolute after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",e),...t})}function ft({className:e,...t}){return s.jsx(FC,{"data-slot":"tabs-content",className:de("flex-1 outline-none",e),...t})}function $t(e){const[t,n]=p.useState(!1),r=p.useRef(null);p.useEffect(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]);const o=p.useCallback(i=>{i.stopPropagation(),e!==null&&Ht(e).then(a=>{a&&(n(!0),r.current!==null&&clearTimeout(r.current),r.current=setTimeout(()=>n(!1),2e3))})},[e]);return{copied:t,copy:o}}const KN=p.lazy(()=>jn(()=>import("./CompareDrawer-BcEd6V-V.js"),__vite__mapDeps([0,1])).then(e=>({default:e.CompareDrawer}))),JN=p.lazy(()=>jn(()=>import("./ReplayDialog-BNpC0548.js"),__vite__mapDeps([2,1,3])).then(e=>({default:e.ReplayDialog}))),YN=p.lazy(()=>jn(()=>import("./RequestAnatomy-Ds1uRLVB.js"),__vite__mapDeps([4,1])).then(e=>({default:e.RequestAnatomy}))),XN=p.lazy(()=>jn(()=>import("./ResponseView-7KPVqKl5.js"),__vite__mapDeps([3,1])).then(e=>({default:e.ResponseView}))),QN=p.lazy(()=>jn(()=>import("./StreamingChunkSequence-BHQT261s.js"),__vite__mapDeps([5,1])).then(e=>({default:e.StreamingChunkSequence}))),Wi=p.lazy(()=>jn(()=>import("./json-viewer-CkCu-rka.js"),__vite__mapDeps([6,1])).then(e=>({default:e.JsonViewer}))),e3=p.lazy(()=>jn(()=>import("./json-viewer-CkCu-rka.js"),__vite__mapDeps([6,1])).then(e=>({default:e.JsonViewerFromString}))),t3=1200,n3=12;function r3(e){const{containerRef:t,setExpandToPath:n,ensureTabActive:r,highlightMs:o}=e,i=p.useRef(null);return p.useCallback(a=>{r?.(),n(a.path);const l=f=>{f.scrollIntoView({behavior:"smooth",block:"center"}),f.classList.add("ring-2","ring-primary/60","ring-offset-1","ring-offset-background","rounded-sm","transition-shadow"),i.current!==null&&clearTimeout(i.current),i.current=setTimeout(()=>{f.classList.remove("ring-2","ring-primary/60","ring-offset-1","ring-offset-background","rounded-sm","transition-shadow"),n(null)},o??t3)},u=`[data-anatomy-path="${(f=>typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(f):f.replace(/(["'\\[\](){}])/g,"\\$1"))(a.path)}"]`,d=f=>{const h=t.current;if(h!==null){const m=h.querySelector(u);if(m!==null){l(m);return}}f>0?window.requestAnimationFrame(()=>d(f-1)):n(null)};window.requestAnimationFrame(()=>d(n3))},[t,r,o,n])}class Fh{diff(t,n,r={}){let o;typeof r=="function"?(o=r,r={}):"callback"in r&&(o=r.callback);const i=this.castInput(t,r),a=this.castInput(n,r),l=this.removeEmpty(this.tokenize(i,r)),c=this.removeEmpty(this.tokenize(a,r));return this.diffWithOptionsObj(l,c,r,o)}diffWithOptionsObj(t,n,r,o){var i;const a=y=>{if(y=this.postProcess(y,r),o){setTimeout(function(){o(y)},0);return}else return y},l=n.length,c=t.length;let u=1,d=l+c;r.maxEditLength!=null&&(d=Math.min(d,r.maxEditLength));const f=(i=r.timeout)!==null&&i!==void 0?i:1/0,h=Date.now()+f,m=[{oldPos:-1,lastComponent:void 0}];let v=this.extractCommon(m[0],n,t,0,r);if(m[0].oldPos+1>=c&&v+1>=l)return a(this.buildValues(m[0].lastComponent,n,t));let g=-1/0,x=1/0;const b=()=>{for(let y=Math.max(g,-u);y<=Math.min(x,u);y+=2){let _;const j=m[y-1],S=m[y+1];j&&(m[y-1]=void 0);let T=!1;if(S){const A=S.oldPos-y;T=S&&0<=A&&A<l}const C=j&&j.oldPos+1<c;if(!T&&!C){m[y]=void 0;continue}if(!C||T&&j.oldPos<S.oldPos?_=this.addToPath(S,!0,!1,0,r):_=this.addToPath(j,!1,!0,1,r),v=this.extractCommon(_,n,t,y,r),_.oldPos+1>=c&&v+1>=l)return a(this.buildValues(_.lastComponent,n,t))||!0;m[y]=_,_.oldPos+1>=c&&(x=Math.min(x,y-1)),v+1>=l&&(g=Math.max(g,y+1))}u++};if(o)(function y(){setTimeout(function(){if(u>d||Date.now()>h)return o(void 0);b()||y()},0)})();else for(;u<=d&&Date.now()<=h;){const y=b();if(y)return y}}addToPath(t,n,r,o,i){const a=t.lastComponent;return a&&!i.oneChangePerToken&&a.added===n&&a.removed===r?{oldPos:t.oldPos+o,lastComponent:{count:a.count+1,added:n,removed:r,previousComponent:a.previousComponent}}:{oldPos:t.oldPos+o,lastComponent:{count:1,added:n,removed:r,previousComponent:a}}}extractCommon(t,n,r,o,i){const a=n.length,l=r.length;let c=t.oldPos,u=c-o,d=0;for(;u+1<a&&c+1<l&&this.equals(r[c+1],n[u+1],i);)u++,c++,d++,i.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return d&&!i.oneChangePerToken&&(t.lastComponent={count:d,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=c,u}equals(t,n,r){return r.comparator?r.comparator(t,n):t===n||!!r.ignoreCase&&t.toLowerCase()===n.toLowerCase()}removeEmpty(t){const n=[];for(let r=0;r<t.length;r++)t[r]&&n.push(t[r]);return n}castInput(t,n){return t}tokenize(t,n){return Array.from(t)}join(t){return t.join("")}postProcess(t,n){return t}get useLongestToken(){return!1}buildValues(t,n,r){const o=[];let i;for(;t;)o.push(t),i=t.previousComponent,delete t.previousComponent,t=i;o.reverse();const a=o.length;let l=0,c=0,u=0;for(;l<a;l++){const d=o[l];if(d.removed)d.value=this.join(r.slice(u,u+d.count)),u+=d.count;else{if(!d.added&&this.useLongestToken){let f=n.slice(c,c+d.count);f=f.map(function(h,m){const v=r[u+m];return v.length>h.length?v:h}),d.value=this.join(f)}else d.value=this.join(n.slice(c,c+d.count));c+=d.count,d.added||(u+=d.count)}}return o}}class s3 extends Fh{constructor(){super(...arguments),this.tokenize=Uh}equals(t,n,r){return r.ignoreWhitespace?((!r.newlineIsToken||!t.includes(`
|
|
96
|
+
`))&&(t=t.trim()),(!r.newlineIsToken||!n.includes(`
|
|
97
|
+
`))&&(n=n.trim())):r.ignoreNewlineAtEof&&!r.newlineIsToken&&(t.endsWith(`
|
|
98
|
+
`)&&(t=t.slice(0,-1)),n.endsWith(`
|
|
99
|
+
`)&&(n=n.slice(0,-1))),super.equals(t,n,r)}}const o3=new s3;function Bh(e,t,n){return o3.diff(e,t,n)}function Uh(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
|
|
100
|
+
`));const n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let o=0;o<r.length;o++){const i=r[o];o%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}class i3 extends Fh{constructor(){super(...arguments),this.tokenize=Uh}get useLongestToken(){return!0}castInput(t,n){const{undefinedReplacement:r,stringifyReplacer:o=(i,a)=>typeof a>"u"?r:a}=n;return typeof t=="string"?t:JSON.stringify(Hi(t,null,null,o),null," ")}equals(t,n,r){return super.equals(t.replace(/,([\r\n])/g,"$1"),n.replace(/,([\r\n])/g,"$1"),r)}}const a3=new i3;function l3(e,t,n){return a3.diff(e,t,n)}function Hi(e,t,n,r,o){t=t||[],n=n||[],r&&(e=r(o===void 0?"":o,e));let i;for(i=0;i<t.length;i+=1)if(t[i]===e)return n[i];let a;if(Object.prototype.toString.call(e)==="[object Array]"){for(t.push(e),a=new Array(e.length),n.push(a),i=0;i<e.length;i+=1)a[i]=Hi(e[i],t,n,r,String(i));return t.pop(),n.pop(),a}if(e&&e.toJSON&&(e=e.toJSON()),typeof e=="object"&&e!==null){t.push(e),a={},n.push(a);const l=[];let c;for(c in e)Object.prototype.hasOwnProperty.call(e,c)&&l.push(c);for(l.sort(),i=0;i<l.length;i+=1)c=l[i],a[c]=Hi(e[c],t,n,r,c);t.pop(),n.pop()}else a=e;return a}function Rc(e){return e===void 0?[]:Object.entries(e).map(t=>[t[0].toLowerCase(),t[1]]).sort(([t],[n])=>t.localeCompare(n))}function Ic([e,t]){return`${e}: ${t}`}function Zi(e){const t=[];let n=0,r=0;for(const o of e){const i=o.value.split(`
|
|
101
|
+
`);i.length>0&&i[i.length-1]===""&&i.pop();for(const a of i)o.added?(r+=1,t.push({kind:"added",text:a,oldLineNumber:null,newLineNumber:r})):o.removed?(n+=1,t.push({kind:"removed",text:a,oldLineNumber:n,newLineNumber:null})):(n+=1,r+=1,t.push({kind:"context",text:a,oldLineNumber:n,newLineNumber:r}))}return t}function c3(e,t){const n=Rc(e).map(Ic).join(`
|
|
102
|
+
`),r=Rc(t).map(Ic).join(`
|
|
103
|
+
`);if(n===r)return{lines:[],isEmpty:!0};const o=Bh(n,r);return{lines:Zi(o),isEmpty:!1}}function zc(e){try{const t=JSON.parse(e);return t===null||typeof t=="string"||typeof t=="object"?t:null}catch{return null}}function u3(e,t){const n=e??"",r=t??"";if(n===r)return{lines:[],isEmpty:!0};const o=zc(n),i=zc(r);if(o!==null&&i!==null){const l=l3(o,i)??[];if(l.length===1){const c=l[0];if(c!==void 0&&!c.added&&!c.removed)return{lines:[],isEmpty:!0}}return{lines:Zi(l),isEmpty:!1}}const a=Bh(n,r);return{lines:Zi(a),isEmpty:!1}}const d3=22,ti=1e4;function f3(e){return e==="added"?"+":e==="removed"?"-":" "}function p3(e){return e==="added"?"bg-green-500/10 text-green-700 dark:text-green-300":e==="removed"?"bg-red-500/10 text-red-700 dark:text-red-300":"text-foreground/80"}const h3=function({result:t,emptyLabel:n}){const[r,o]=p.useState("unified"),i=p.useRef(null),a=yN({count:t.lines.length,getScrollElement:()=>i.current,estimateSize:()=>d3,overscan:10});if(t.isEmpty)return s.jsx("div",{className:"rounded border border-dashed border-border bg-muted/30 px-4 py-6 text-center text-xs text-muted-foreground","data-testid":"diff-empty",children:n??"No transformation applied — raw and processed are identical."});const l=t.lines.length,c=l>ti,u=c?t.lines.slice(0,ti):t.lines;return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[s.jsxs("span",{children:[l.toLocaleString()," line",l===1?"":"s",c&&` (showing first ${ti.toLocaleString()})`]}),s.jsxs("div",{className:"inline-flex rounded-md border border-border overflow-hidden",children:[s.jsxs("button",{type:"button",onClick:()=>o("unified"),"aria-pressed":r==="unified",className:de("flex items-center gap-1 px-2 py-1 transition-colors",r==="unified"?"bg-muted text-foreground":"hover:bg-muted/50"),title:"Unified diff (single column)",children:[s.jsx(n2,{className:"size-3"}),"Unified"]}),s.jsxs("button",{type:"button",onClick:()=>o("split"),"aria-pressed":r==="split",className:de("flex items-center gap-1 px-2 py-1 transition-colors border-l border-border",r==="split"?"bg-muted text-foreground":"hover:bg-muted/50"),title:"Split diff (side by side)",children:[s.jsx(dy,{className:"size-3"}),"Split"]})]})]}),s.jsx("div",{ref:i,className:"max-h-[60vh] overflow-auto rounded border border-border bg-background font-mono text-xs","data-testid":"diff-viewport",children:r==="unified"?s.jsx(m3,{virtualizer:a,lines:u}):s.jsx(b3,{lines:u})})]})};function m3({virtualizer:e,lines:t}){return s.jsx("div",{style:{height:`${e.getTotalSize()}px`,width:"100%",position:"relative"},children:e.getVirtualItems().map(n=>{const r=t[n.index];return r===void 0?null:s.jsxs("div",{"data-index":n.index,ref:e.measureElement,className:de("flex items-start gap-3 px-2",p3(r.kind)),style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${n.start}px)`},children:[s.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:r.oldLineNumber??""}),s.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:r.newLineNumber??""}),s.jsx("span",{className:de("select-none w-3 text-right font-bold",r.kind==="added"&&"text-green-600 dark:text-green-400",r.kind==="removed"&&"text-red-600 dark:text-red-400"),children:f3(r.kind)}),s.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:r.text})]},n.key)})})}function g3(e){const t=[];let n=0;for(;n<e.length;){const r=e[n];if(r===void 0)break;if(r.kind==="context"){t.push({left:{text:r.text,lineNumber:r.oldLineNumber},right:{text:r.text,lineNumber:r.newLineNumber},kind:"equal"}),n+=1;continue}const o=[],i=[];for(;n<e.length&&e[n]?.kind==="removed";){const l=e[n];l!==void 0&&o.push(l),n+=1}for(;n<e.length&&e[n]?.kind==="added";){const l=e[n];l!==void 0&&i.push(l),n+=1}const a=Math.max(o.length,i.length);for(let l=0;l<a;l+=1){const c=o[l],u=i[l];c!==void 0&&u!==void 0?t.push({left:{text:c.text,lineNumber:c.oldLineNumber},right:{text:u.text,lineNumber:u.newLineNumber},kind:"changed"}):c!==void 0?t.push({left:{text:c.text,lineNumber:c.oldLineNumber},right:null,kind:"removed"}):u!==void 0&&t.push({left:null,right:{text:u.text,lineNumber:u.newLineNumber},kind:"added"})}}return t}function x3(e){switch(e){case"changed":return"bg-amber-500/10";case"removed":return"bg-red-500/10";case"added":return"bg-green-500/10";case"equal":return""}}function b3({lines:e}){const t=g3(e);return s.jsx("div",{"data-testid":"diff-split",children:t.map((n,r)=>s.jsxs("div",{className:de("grid grid-cols-2 font-mono text-xs",x3(n.kind)),children:[s.jsxs("div",{className:"flex items-start gap-2 px-2 border-r border-border/50",children:[s.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:n.left?.lineNumber??""}),s.jsx("span",{className:de("select-none w-3 text-right font-bold",(n.kind==="removed"||n.kind==="changed")&&"text-red-600 dark:text-red-400"),children:n.left!==null?"-":" "}),s.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:n.left?.text??""})]}),s.jsxs("div",{className:"flex items-start gap-2 px-2",children:[s.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:n.right?.lineNumber??""}),s.jsx("span",{className:de("select-none w-3 text-right font-bold",(n.kind==="added"||n.kind==="changed")&&"text-green-600 dark:text-green-400"),children:n.right!==null?"+":" "}),s.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:n.right?.text??""})]})]},r))})}const Wh=p.memo(h3),v3=La("inline-flex items-center justify-center rounded-full border border-transparent px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",ghost:"[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",link:"text-primary underline-offset-4 [a&]:hover:underline"}},defaultVariants:{variant:"default"}});function Fe({className:e,variant:t="default",asChild:n=!1,...r}){const o=n?Yw:"span";return s.jsx(o,{"data-slot":"badge","data-variant":t,className:de(v3({variant:t}),e),...r})}const y3={success:"bg-emerald-400/[0.08] text-emerald-200 border-emerald-300/25",client_error:"bg-amber-300/[0.10] text-amber-100 border-amber-300/30",server_error:"bg-rose-400/[0.10] text-rose-100 border-rose-300/30",pending:"bg-cyan-300/[0.08] text-cyan-100 border-cyan-300/25"},w3={success:{frame:"border-emerald-300/20 bg-emerald-300/[0.06] text-emerald-100",dot:"bg-emerald-300 shadow-[0_0_14px_rgba(110,231,183,0.8)]",rail:"bg-emerald-300/45 shadow-[0_0_22px_rgba(110,231,183,0.28)]"},client_error:{frame:"border-amber-300/25 bg-amber-300/[0.08] text-amber-100",dot:"bg-amber-200 shadow-[0_0_14px_rgba(252,211,77,0.8)]",rail:"bg-amber-300/50 shadow-[0_0_22px_rgba(252,211,77,0.28)]"},server_error:{frame:"border-rose-300/25 bg-rose-300/[0.08] text-rose-100",dot:"bg-rose-300 shadow-[0_0_14px_rgba(253,164,175,0.8)]",rail:"bg-rose-300/50 shadow-[0_0_22px_rgba(253,164,175,0.28)]"},pending:{frame:"border-cyan-300/25 bg-cyan-300/[0.08] text-cyan-100",dot:"bg-cyan-200 shadow-[0_0_14px_rgba(103,232,249,0.8)]",rail:"bg-cyan-300/50 shadow-[0_0_22px_rgba(103,232,249,0.28)]"}},cr="size-8 border-white/10 bg-[#0a0d11] text-muted-foreground shadow-none hover:border-cyan-300/30 hover:bg-cyan-400/10 hover:text-cyan-100",vt="flex h-7 items-center gap-1 rounded-md border border-white/10 bg-black/20 px-2 text-xs shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]";function ur(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function k3(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function _3(e,t){switch(e){case"success":return t===null?"OK":String(t);case"client_error":return t===null?"WARN":String(t);case"server_error":return t===null?"FAIL":String(t);case"pending":return"ROLL"}}function Oc({trend:e}){if(e===null)return null;const t=e.direction==="up",n=t?T1:k1,r=t?"+":"-";return s.jsxs("span",{className:"flex items-center gap-0.5 text-muted-foreground tabular-nums",children:[s.jsx(n,{className:t?"size-3 text-emerald-400":"size-3 text-rose-400"}),s.jsxs("span",{className:"font-mono",children:[r,Be(e.delta)]})]})}const j3=p.memo(function({log:e,displayNumber:t,messageCount:n=null,toolCount:r=null,expanded:o,onToggle:i,cacheTrend:a=null,activeTab:l,tabActions:c,onReplay:u,slowResponseThresholdSeconds:d=0,timeDisplayFormat:f}){const h=Bw(e.responseStatus),m=e.elapsedMs!==null&&d>0&&e.elapsedMs>d*1e3,v=e.inputTokens!==null||e.outputTokens!==null,g=e.firstChunkMs??null,x=e.tokensPerSecond??null,b=g===null?null:ur(g),y=x===null||x<=0?null:k3(x),_=e.warnings?.length??0,j=e.clientPid!==null&&e.clientPid!==void 0,S=e.clientProjectFolder!==null&&e.clientProjectFolder!==void 0&&e.clientProjectFolder!=="",T=e.clientCwd!==null&&e.clientCwd!==void 0&&e.clientCwd!=="",C=w3[h],A=_3(h,e.responseStatus);return s.jsx(Je,{children:s.jsxs("div",{id:`log-${e.id}`,role:"button",tabIndex:0,"data-nav-id":`log-${e.id}`,"data-nav-action":o?"collapse":"expand",className:de("group/header relative isolate flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 overflow-hidden px-3 py-2 cursor-pointer transition-[background-color,border-color,box-shadow]",o?"bg-[linear-gradient(90deg,#0f1720_0%,#090d12_50%,#07090d_100%)] shadow-[inset_0_1px_0_rgba(255,255,255,0.06)]":"bg-[#080b10] hover:bg-[#0b1016]","select-none before:pointer-events-none before:absolute before:inset-x-0 before:top-0 before:h-px before:bg-white/10","focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none"),onClick:i,onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),i())},children:[s.jsx("span",{className:de("absolute left-0 top-2 bottom-2 w-0.5 rounded-r-full transition-colors",C.rail),"aria-hidden":"true"}),s.jsx("span",{className:nl,children:o?s.jsx(ct,{className:"size-4 shrink-0"}):s.jsx(Ot,{className:"size-4 shrink-0"})}),s.jsxs("span",{className:de("inline-flex h-8 shrink-0 items-center gap-2 rounded-md border px-2 font-mono shadow-[inset_0_1px_0_rgba(255,255,255,0.05)]",C.frame),children:[s.jsx("span",{className:de("size-1.5 rounded-full",C.dot),"aria-hidden":"true"}),s.jsxs("span",{className:"text-xs font-semibold tabular-nums",title:`Log ID ${String(e.id)}`,children:["#",t]})]}),s.jsxs("span",{className:"flex h-7 items-center gap-1 rounded-md border border-white/10 bg-black/20 px-2 text-muted-foreground text-xs shrink-0",children:[s.jsx(Bt,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",title:e.timestamp,children:ji(e.timestamp,f)})]}),s.jsxs(Fe,{variant:"outline",className:de("h-6 gap-1 rounded-md px-2 py-0 font-mono text-[10px] font-semibold uppercase tabular-nums shadow-[inset_0_1px_0_rgba(255,255,255,0.05)]",y3[h]),children:[h==="success"?s.jsx(Ge,{className:"size-3","aria-label":"Success"}):h==="server_error"?s.jsx(qy,{className:"size-3","aria-label":"Server error"}):h==="client_error"?s.jsx(gn,{className:"size-3","aria-label":"Client error"}):s.jsx(ht,{className:"size-3 animate-spin","aria-label":"Pending"}),A]}),_>0&&s.jsxs(Me,{children:[s.jsx(Le,{asChild:!0,children:s.jsxs(Fe,{variant:"outline",className:"h-6 gap-1 rounded-md border-amber-300/30 bg-amber-300/[0.10] px-2 py-0 font-mono text-[10px] tabular-nums text-amber-100",children:[s.jsx(gn,{className:"size-3","aria-label":"Tool schema warnings"}),_]})}),s.jsx(De,{children:_===1?"1 tool schema warning":`${_} tool schema warnings`})]}),e.elapsedMs!==null&&(m?s.jsxs(Me,{children:[s.jsx(Le,{asChild:!0,children:s.jsxs("span",{className:de(vt,"shrink-0 border-amber-300/25 text-amber-200"),children:[s.jsx(Bt,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:ur(e.elapsedMs)}),s.jsx(gn,{className:"size-3","aria-label":"Slow response"})]})}),s.jsxs(De,{children:["Slow response: ",ur(e.elapsedMs)," exceeds"," ",ur(d*1e3)]})]}):s.jsxs("span",{className:de(vt,"shrink-0 text-muted-foreground"),children:[s.jsx(Bt,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:ur(e.elapsedMs)})]})),e.streaming&&b!==null&&s.jsxs(Me,{children:[s.jsx(Le,{asChild:!0,children:s.jsxs("span",{className:de(vt,"shrink-0 text-cyan-300"),children:[s.jsx(Bl,{className:"size-3"}),s.jsxs("span",{className:"font-mono tabular-nums",children:["first ",b]})]})}),s.jsx(De,{children:"Time to first streaming chunk"})]}),e.streaming&&y!==null&&s.jsxs(Me,{children:[s.jsx(Le,{asChild:!0,children:s.jsxs("span",{className:de(vt,"shrink-0 text-emerald-300"),children:[s.jsx(Ca,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:y})]})}),s.jsx(De,{children:"Output token throughput after first chunk"})]}),v&&s.jsxs("span",{className:de(vt,"min-w-0 sm:shrink-0"),children:[s.jsx(jr,{className:"size-3 text-muted-foreground"}),s.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-1 font-mono tabular-nums",children:[s.jsxs("span",{className:de("whitespace-nowrap",e.inputTokens!==null?"text-blue-400":"text-muted-foreground"),children:["IN ",e.inputTokens!==null?Be(e.inputTokens):"—"]}),s.jsx("span",{className:"text-muted-foreground",children:"/"}),s.jsxs("span",{className:de("whitespace-nowrap",e.outputTokens!==null?"text-amber-400":"text-muted-foreground"),children:["OUT ",e.outputTokens!==null?Be(e.outputTokens):"—"]})]})]}),e.cacheCreationInputTokens!==null&&e.cacheCreationInputTokens>0&&s.jsxs("span",{className:de(vt,"shrink-0"),children:[s.jsx(Oc,{trend:a?.creation??null}),s.jsxs("span",{className:"font-mono tabular-nums text-emerald-400",children:["KV Cache +",Be(e.cacheCreationInputTokens)]})]}),e.cacheReadInputTokens!==null&&e.cacheReadInputTokens>0&&s.jsxs("span",{className:de(vt,"shrink-0"),children:[s.jsx(Oc,{trend:a?.read??null}),s.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["KV Cache ~",Be(e.cacheReadInputTokens)]})]}),n!==null&&s.jsxs("span",{className:de(vt,"shrink-0 text-muted-foreground"),children:[s.jsx(uo,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:n})]}),r!==null&&s.jsxs("span",{className:de(vt,"shrink-0 text-muted-foreground"),children:[s.jsx(Ir,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:r})]}),e.origin!==null&&s.jsxs("span",{className:de(vt,"hidden shrink-0 text-muted-foreground xl:flex"),title:`Origin: ${e.origin}`,children:[s.jsx(Pd,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums truncate max-w-[120px]",title:e.origin,children:e.origin})]}),(j||S)&&s.jsxs(Me,{children:[s.jsx(Le,{asChild:!0,children:s.jsxs("span",{className:de(vt,"hidden shrink-0 text-purple-300 xl:flex"),children:[s.jsx(Cy,{className:"size-3"}),S?s.jsx("span",{className:"font-mono tabular-nums",children:e.clientProjectFolder}):s.jsxs("span",{className:"font-mono tabular-nums",children:["PID ",e.clientPid]})]})}),s.jsx(De,{children:T?`PID: ${e.clientPid??"?"} CWD: ${e.clientCwd}`:`Process ID: ${e.clientPid??"?"}`})]}),e.streaming&&s.jsxs(Me,{children:[s.jsx(Le,{asChild:!0,children:s.jsx(Bl,{className:"size-3 text-muted-foreground/60 shrink-0"})}),s.jsx(De,{children:"Request used SSE streaming"})]}),s.jsx("span",{className:"flex-1 min-w-0"}),o&&s.jsxs("span",{className:"flex items-center gap-1.5 shrink-0",onClick:E=>E.stopPropagation(),onKeyDown:E=>E.stopPropagation(),children:[c!==void 0&&l!==void 0&&(()=>{const E=c[l];return E===void 0?null:s.jsxs(s.Fragment,{children:[E.expansion!==null&&s.jsxs(Me,{children:[s.jsx(Le,{asChild:!0,children:s.jsx(Ne,{variant:"outline",size:"icon",className:cr,onClick:E.expansion.onToggle,disabled:E.expansion.isPending,"aria-pressed":E.expansion.isExpanded,"aria-label":E.expansion.isExpanded?"Collapse all JSON":"Expand all JSON",children:E.expansion.isExpanded?s.jsx(q1,{className:"size-3.5"}):s.jsx(B1,{className:"size-3.5"})})}),s.jsx(De,{children:E.expansion.isExpanded?"Collapse all JSON nodes":"Expand all JSON nodes"})]}),E.diffWithRaw!==void 0&&s.jsxs(Me,{children:[s.jsx(Le,{asChild:!0,children:s.jsx(Ne,{variant:"outline",size:"icon",className:de(cr,E.diffWithRaw.active&&"border-cyan-300/35 bg-cyan-400/15 text-cyan-100"),onClick:E.diffWithRaw.onToggle,"aria-pressed":E.diffWithRaw.active,"aria-label":E.diffWithRaw.active?"Hide raw diff":"Diff with raw",children:s.jsx(ky,{className:"size-3.5"})})}),s.jsx(De,{children:E.diffWithRaw.active?"Hide diff with raw request":"Show diff between displayed and raw request body"})]}),E.diffWithPrevious!==void 0&&s.jsxs(Me,{children:[s.jsx(Le,{asChild:!0,children:s.jsx(Ne,{variant:"outline",size:"icon",className:cr,onClick:E.diffWithPrevious,"aria-label":"Diff with previous",children:s.jsx(Oy,{className:"size-3.5"})})}),s.jsx(De,{children:"Compare this request with the immediately preceding one"})]}),E.copyText!==null&&s.jsxs(Me,{children:[s.jsx(Le,{asChild:!0,children:s.jsx(Ne,{variant:"outline",size:"icon",className:cr,onClick:E.onCopy,"aria-label":E.copyCopied?"Copied":E.copyLabel,children:E.copyCopied?s.jsx(Ge,{className:"size-3.5 text-emerald-500"}):s.jsx(St,{className:"size-3.5"})})}),s.jsx(De,{children:E.copyCopied?"Copied to clipboard":E.copyLabel})]})]})})(),u!==void 0&&s.jsxs(Me,{children:[s.jsx(Le,{asChild:!0,children:s.jsx(Ne,{variant:"outline",size:"icon",className:cr,onClick:u,"aria-label":"Replay request",children:s.jsx(Qy,{className:"size-3.5"})})}),s.jsx(De,{children:"Re-send this request to the provider"})]})]})]})})});function S3({...e}){return s.jsx(oj,{"data-slot":"collapsible",...e})}function XR({...e}){return s.jsx(Bf,{"data-slot":"collapsible-trigger",...e})}function C3({...e}){return s.jsx(Uf,{"data-slot":"collapsible-content",...e})}function N3({className:e,children:t,...n}){return s.jsxs(YS,{"data-slot":"scroll-area",className:de("relative overflow-hidden",e),...n,children:[s.jsx(XS,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full max-h-[inherit] rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:t}),s.jsx(T3,{}),s.jsx(QS,{})]})}function T3({className:e,orientation:t="vertical",...n}){return s.jsx(jp,{"data-slot":"scroll-area-scrollbar",orientation:t,className:de("flex touch-none p-px transition-colors select-none",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",e),...n,children:s.jsx(Tp,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const Hh={file:"file",shell:"shell",browser:"browser",web:"web",mcp:"MCP",code:"code",other:"other"},E3={file:"border-blue-400/20 bg-blue-400/5 text-blue-300",shell:"border-teal-400/20 bg-teal-400/5 text-teal-300",browser:"border-cyan-400/20 bg-cyan-400/5 text-cyan-300",web:"border-sky-400/20 bg-sky-400/5 text-sky-300",mcp:"border-violet-400/20 bg-violet-400/5 text-violet-300",code:"border-emerald-400/20 bg-emerald-400/5 text-emerald-300",other:"border-muted-foreground/20 bg-muted/30 text-muted-foreground"};function A3({category:e}){switch(e){case"file":return s.jsx(Ty,{className:"size-3.5"});case"shell":return s.jsx(Na,{className:"size-3.5"});case"browser":return s.jsx(Zy,{className:"size-3.5"});case"web":return s.jsx(Pd,{className:"size-3.5"});case"mcp":return s.jsx(I1,{className:"size-3.5"});case"code":return s.jsx(cy,{className:"size-3.5"});case"other":return s.jsx(my,{className:"size-3.5"})}}function R3({names:e}){return e.length===0?null:s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"required"}),e.slice(0,4).map(t=>s.jsx(Fe,{variant:"outline",className:"h-5 max-w-36 truncate rounded-md px-1.5 py-0 font-mono text-[10px]",children:t},t)),e.length>4&&s.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["+",e.length-4]})]})}function I3({tool:e,called:t}){const[n,r]=p.useState(!1),o=$t(e.name),i=e.description!==null||e.requiredParameters.length>0||e.schema!==null;return s.jsx(S3,{open:n,onOpenChange:r,children:s.jsxs("div",{className:"rounded-md border border-white/10 bg-black/20 shadow-[inset_0_1px_0_rgba(255,255,255,0.03)]",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-2.5 py-2",children:[s.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>r(a=>!a),"aria-expanded":n,disabled:!i,children:[s.jsx(A3,{category:e.category}),s.jsx("span",{className:"min-w-0 truncate font-mono text-xs font-semibold text-foreground/90",children:e.name}),t&&s.jsx(Fe,{variant:"outline",className:"h-5 rounded-md border-emerald-400/20 bg-emerald-400/5 px-1.5 py-0 text-[10px] text-emerald-300",children:"called"}),s.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:[e.parameterCount," params"]}),e.descriptionPreview!==null&&s.jsx("span",{className:"hidden min-w-0 truncate text-xs text-muted-foreground md:inline",children:e.descriptionPreview}),s.jsx("span",{className:"flex-1"}),i&&(n?s.jsx(ct,{className:"size-3.5 shrink-0 text-muted-foreground"}):s.jsx(Ot,{className:"size-3.5 shrink-0 text-muted-foreground"}))]}),s.jsx("button",{type:"button",className:"inline-flex size-7 shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:o.copy,"aria-label":o.copied?"Copied tool name":"Copy tool name",children:o.copied?s.jsx(Ge,{className:"size-3.5 text-emerald-400"}):s.jsx(St,{className:"size-3.5"})})]}),s.jsx(C3,{children:n&&s.jsxs("div",{className:"space-y-2 border-t border-white/10 bg-white/[0.02] px-2.5 py-2",children:[e.description!==null&&s.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:e.description}),s.jsx(R3,{names:e.requiredParameters}),e.schema!==null&&s.jsx(N3,{className:"max-h-64 rounded-md border border-white/10 bg-[#06080b] p-2",children:s.jsx(p.Suspense,{fallback:s.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading JSON..."}),children:s.jsx(Wi,{data:Gs(e.schema),defaultExpandDepth:0})})})]})})]})})}function z3(e,t){return t.length===0?!0:`${e.name} ${e.description??""} ${Hh[e.category]}`.toLowerCase().trim().includes(t)}const O3=p.memo(function({summary:t,calledToolNames:n}){const[r,o]=p.useState(!1),[i,a]=p.useState(""),l=p.useMemo(()=>new Set(n),[n]),c=i.trim().toLowerCase(),u=p.useMemo(()=>t===null?[]:t.tools.filter(h=>z3(h,c)),[c,t]);if(t===null)return null;const d=t.tools.slice(0,6),f=t.tools.length-d.length;return s.jsxs("section",{className:"mb-3 overflow-hidden rounded-md border border-white/10 bg-[#080b0f] shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 px-3 py-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s.jsx(Ir,{className:"size-4 shrink-0 text-sky-300/80"}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[s.jsx("span",{className:"text-sm font-semibold text-foreground",children:"Request Tools"}),s.jsx(Fe,{variant:"outline",className:"h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",children:t.tools.length}),t.toolChoiceLabel!==null&&s.jsxs(Fe,{variant:"outline",className:"h-5 rounded-md px-1.5 py-0 font-mono text-[10px] text-muted-foreground",children:["tool_choice: ",t.toolChoiceLabel]})]}),s.jsx("div",{className:"mt-1 flex min-w-0 flex-wrap gap-1",children:t.categories.map(h=>s.jsxs(Fe,{variant:"outline",className:de("h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",E3[h.category]),children:[h.count," ",Hh[h.category]]},h.category))})]})]}),s.jsxs(Ne,{type:"button",variant:"ghost",size:"sm",className:"h-7 border border-white/10 bg-black/20 px-2 text-muted-foreground hover:border-cyan-300/30 hover:bg-cyan-400/10 hover:text-cyan-100",onClick:()=>o(h=>!h),"aria-expanded":r,children:[r?s.jsx(ct,{className:"size-3.5"}):s.jsx(Ot,{className:"size-3.5"}),r?"Hide":"Show"]})]}),s.jsxs("div",{className:"flex min-w-0 flex-wrap gap-1.5 border-t border-white/10 bg-black/10 px-3 py-2",children:[d.map(h=>s.jsx(Fe,{variant:"outline",className:de("h-5 max-w-44 truncate rounded-md px-1.5 py-0 font-mono text-[10px]",l.has(h.name)&&"border-emerald-400/20 text-emerald-300"),children:h.name},h.name)),f>0&&s.jsxs("span",{className:"font-mono text-[10px] leading-5 text-muted-foreground",children:["+",f]})]}),r&&s.jsxs("div",{className:"space-y-2 border-t border-white/10 bg-black/15 px-3 py-3",children:[s.jsxs("label",{className:"flex h-8 items-center gap-2 rounded-md border border-white/10 bg-[#06080b] px-2 text-xs",children:[s.jsx(l2,{className:"size-3.5 shrink-0 text-muted-foreground"}),s.jsx("input",{value:i,onChange:h=>a(h.target.value),placeholder:"Filter tools",className:"min-w-0 flex-1 bg-transparent font-mono text-xs outline-none placeholder:text-muted-foreground/70"})]}),s.jsx("div",{className:"grid gap-1.5",children:u.length>0?u.map(h=>s.jsx(I3,{tool:h,called:l.has(h.name)},h.name)):s.jsx("p",{className:"py-2 text-xs text-muted-foreground",children:"No matching tools"})})]})]})});function Pc(e,t,n){return e==="anthropic"&&t==="full"&&n}function P3(e,t){return e==="full"&&t}function M3(e,t,n,r){return e==="anthropic"&&t==="full"&&n&&r}const L3=["file","shell","browser","web","mcp","code","other"];function Vi(e){const t=e.replace(/\s+/g," ").trim();return t.length<=120?t:`${t.slice(0,119)}...`}function Zh(e){if(e===null)return null;const t=e.replace(/\s+/g," ").trim();if(t.length===0)return null;const n=t.search(/[.!?。!?]/);return n>=24?Vi(t.slice(0,n+1)):Vi(t)}function D3(e,t){return`${e} ${t??""}`.toLowerCase()}function zn(e,t){return t.some(n=>e.includes(n))}function Vh(e,t){const n=D3(e,t);return e.startsWith("mcp__")||e.startsWith("inspector_")||zn(n,[" mcp","model context protocol"])?"mcp":zn(n,["bash","shell","terminal","command","powershell","exec","process"])?"shell":zn(n,["browser","playwright","screenshot","click","navigate","page","tab"])?"browser":zn(n,["read","write","edit","file","glob","grep","patch","filesystem","directory"])?"file":zn(n,["web","search","http","url","fetch"])?"web":zn(n,["code","typescript","javascript","python","repl"])?"code":"other"}function qh(e){const t=ke(e,"properties");return t===null||typeof t!="object"||Array.isArray(t)?[]:Object.keys(t).sort((n,r)=>n.localeCompare(r))}function Gh(e){const t=ke(e,"required");if(!Array.isArray(t))return[];const n=[];for(const r of t)typeof r=="string"&&r.length>0&&n.push(r);return n.sort((r,o)=>r.localeCompare(o))}function $3(e){const t=ke(e,"name");if(typeof t!="string"||t.length===0)return null;const n=ke(e,"description"),r=ke(e,"input_schema")??null,o=typeof n=="string"?n:null;return{name:t,description:o,descriptionPreview:Zh(o),category:Vh(t,o),parameterCount:qh(r).length,requiredParameters:Gh(r),schema:r}}function F3(e){const t=ke(e,"function"),n=ke(e,"type");if(t===void 0&&n!=="function")return null;const r=ke(t,"name")??ke(e,"name");if(typeof r!="string"||r.length===0)return null;const o=ke(t,"description")??ke(e,"description"),i=ke(t,"parameters")??ke(e,"parameters")??null,a=typeof o=="string"?o:null;return{name:r,description:a,descriptionPreview:Zh(a),category:Vh(r,a),parameterCount:qh(i).length,requiredParameters:Gh(i),schema:i}}function B3(e){const t=F3(e);return t!==null?t:$3(e)}function U3(e){if(e==null)return null;if(typeof e=="string")return e;const t=ke(e,"type"),n=ke(e,"name"),r=ke(ke(e,"function"),"name");if(typeof t=="string"&&typeof r=="string"&&r.length>0)return`${t}: ${r}`;if(typeof t=="string"&&typeof n=="string"&&n.length>0)return`${t}: ${n}`;if(typeof t=="string")return t;const o=JSON.stringify(e);return o===void 0?null:Vi(o)}function W3(e){const t=new Map;for(const n of e)t.set(n.category,(t.get(n.category)??0)+1);return L3.flatMap(n=>{const r=t.get(n)??0;return r>0?[{category:n,count:r}]:[]})}function H3(e){const t=ke(e,"tools");if(!Array.isArray(t)||t.length===0)return null;const n=[];for(const r of t){const o=B3(r);o!==null&&n.push(o)}return n.length===0?null:{tools:n,toolChoiceLabel:U3(ke(e,"tool_choice")),categories:W3(n)}}function On(){return s.jsx("div",{className:"h-1","aria-hidden":"true"})}function Z3(e,t){switch(e){case"anatomy":return t===null?"request":"anatomy";case"request":return"request"}}const V3=15e3,q3=15e3,G3=256*1024,Ks=1024*1024,fn="h-9 flex-none rounded-none border-0 border-b-2 border-transparent bg-transparent px-3 text-xs font-semibold text-muted-foreground shadow-none transition-colors hover:bg-cyan-400/[0.05] hover:text-foreground data-[state=active]:border-cyan-300 data-[state=active]:bg-cyan-300/[0.04] data-[state=active]:text-cyan-100 data-[state=active]:shadow-none";function is(e=null){return{status:"idle",text:"",offset:0,totalBytes:e,hasMore:e!==null&&e>0,error:null}}function Js(e){return e??0}function Kh(e){return e.bodyContentMode==="compact"||e.bodyContentMode==="truncated"}function Jh(e){return Kh(e)?Js(e.rawRequestBodyBytes)>Ks||Js(e.responseTextBytes)>Ks:!1}function K3(e){return Kh(e)&&!Jh(e)}function as(e){return e<1024?`${e.toLocaleString()} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MiB`:`${(e/1024/1024/1024).toFixed(1)} GiB`}function J3(e){return e instanceof kd?"Body preview timed out. The log is still available on disk; try loading again.":e instanceof Error?e.message:"Body preview could not be loaded."}function Mc(e,t){return e?t.text!==""?t.text:t.status==="success"?"":null:null}function pn({children:e,className:t}){return s.jsx("div",{className:de("inspector-scrollbar mx-3 mb-3 max-h-[72vh] overflow-auto rounded-md border border-cyan-300/10 bg-[#05070a] p-3 shadow-[0_16px_45px_rgba(0,0,0,0.24),inset_0_1px_0_rgba(255,255,255,0.05)]",t),children:e})}function js({children:e}){return s.jsx("div",{className:"rounded-md border border-dashed border-white/10 bg-white/[0.02] px-3 py-5 text-center text-xs italic text-muted-foreground",children:e})}function ls({children:e}){return s.jsx("pre",{className:"inspector-scrollbar max-h-[64vh] overflow-auto whitespace-pre-wrap break-words rounded-md border border-white/10 bg-black/30 p-3 font-mono text-xs leading-relaxed text-muted-foreground",children:e})}const Y3={loading:"border-cyan-400/25 bg-cyan-400/[0.06] text-cyan-100",warning:"border-amber-400/25 bg-amber-400/[0.08] text-amber-100",danger:"border-rose-400/25 bg-rose-400/[0.08] text-rose-100"};function xr({tone:e,title:t,children:n}){return s.jsxs("div",{className:de("mb-3 rounded-md border px-3 py-2 text-xs shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]",Y3[e]),children:[t!==void 0&&s.jsx("div",{className:"mb-1 font-semibold",children:t}),s.jsx("div",{className:"leading-relaxed text-muted-foreground",children:n})]})}function cs({label:e,state:t,expectedBytes:n,onLoadMore:r}){const o=t.totalBytes??n,i=o===null?as(t.offset):`${as(t.offset)} / ${as(o)}`,a=t.status!=="loading"&&t.hasMore,l=t.status==="failed"?"Retry":"Load more";return s.jsx(xr,{tone:t.status==="failed"?"warning":"loading",title:`${e} body preview`,children:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("span",{children:[t.status==="idle"&&o!==null?`${e} body is ${as(o)}. Loading the first preview chunk.`:`Loaded ${i}.`,t.status==="failed"&&t.error!==null&&` ${t.error}`]}),a&&s.jsx(Ne,{type:"button",variant:"outline",size:"sm",className:"h-7 border-white/10 bg-black/20 text-xs text-cyan-100 hover:border-cyan-300/35 hover:bg-cyan-400/10",onClick:r,children:l})]})})}function Lc({headers:e,emptyLabel:t}){const n=e===void 0?[]:Object.entries(e).sort(([r],[o])=>r.localeCompare(o));return n.length===0?s.jsx(js,{children:t}):s.jsx("div",{className:"overflow-hidden rounded-md border border-white/10 bg-black/20 font-mono text-xs",children:n.map(([r,o])=>s.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(140px,0.32fr)_minmax(0,1fr)] border-b border-white/5 last:border-b-0",children:[s.jsx("div",{className:"min-w-0 truncate border-r border-white/5 bg-white/[0.03] px-2.5 py-2 font-semibold text-cyan-200",children:r}),s.jsx("div",{className:"min-w-0 truncate px-2.5 py-2 text-muted-foreground",title:o,children:o})]},r))})}function X3({active:e,onClick:t}){return s.jsxs(Me,{children:[s.jsx(Le,{asChild:!0,children:s.jsxs(Ne,{variant:e?"default":"outline",size:"sm",className:de("h-8 border-white/10 text-xs shadow-none",e?"bg-cyan-300 text-black hover:bg-cyan-200":"bg-[#0a0d11] text-muted-foreground hover:border-cyan-300/30 hover:bg-cyan-400/10 hover:text-cyan-100"),onClick:t,"aria-pressed":e,children:[s.jsx(Ry,{className:"size-3.5 mr-1"}),e?"Showing diff":"Diff with Raw"]})}),s.jsx(De,{children:e?"Hide diff view":"Compare proxy output against the original raw version"})]})}const Q3=p.memo(function({rawBody:e,displayedBody:t,emptyLabel:n}){const r=p.useMemo(()=>u3(e,t),[e,t]);return s.jsx(Wh,{result:r,emptyLabel:n})}),eT=p.memo(function({rawHeaders:e,headers:t,emptyLabel:n}){const r=p.useMemo(()=>c3(e,t),[e,t]);return s.jsx(Wh,{result:r,emptyLabel:n})}),tT=p.memo(function({log:e,displayNumber:t,viewMode:n="simple",strip:r,slowResponseThresholdSeconds:o,timeDisplayFormat:i,cacheTrend:a=null,onCompareWithPrevious:l}){const[c,u]=p.useState(!1),[d,f]=p.useState(!1),[h,m]=p.useState(!1),[v,g]=p.useState(!1),[x,b]=p.useState("request"),[y,_]=p.useState(null),[j,S]=p.useState(null),[T,C]=p.useState("idle"),[A,E]=p.useState(()=>is(e.rawRequestBodyBytes??null)),[P,J]=p.useState(()=>is(e.responseTextBytes??null)),R=p.useRef(null),F=p.useRef(e.id),k=p.useRef(!1),M=j??e,Y=j===null&&Jh(e),D=Mc(Y,A),B=Mc(Y,P),U=M.rawRequestBody??D,ie=M.responseText??B,W=M.rawRequestBody===null&&D!==null,H=M.responseText===null&&B!==null,ue=!W||A.hasMore===!1&&Js(A.totalBytes)<=Ks,ne=!H||P.hasMore===!1&&Js(P.totalBytes)<=Ks,se=Nr(M),je=Ah(se),ce=p.useMemo(()=>je.analyzeRequest(M.rawRequestBody),[je,M.rawRequestBody]),me=p.useMemo(()=>je.analyzeResponse(M.responseText),[je,M.responseText]),ae=p.useMemo(()=>!r||se!=="anthropic"||M.rawRequestBody===null?null:UN(M.rawRequestBody).body,[M.rawRequestBody,se,r])??U,re=ei(ue?ae:null),pe=ei(x==="raw-request"&&ue?U:null),ye=ei(x==="raw"&&ne?ie:null),w=p.useMemo(()=>M.headers&&Object.keys(M.headers).length>0?JSON.stringify(M.headers,null,2):null,[M.headers]),K=p.useMemo(()=>M.rawHeaders&&Object.keys(M.rawHeaders).length>0?JSON.stringify(M.rawHeaders,null,2):null,[M.rawHeaders]),V=$t(ae),z=$t(U),I=$t(w),$=$t(K),ee=$t(ie),oe=p.useMemo(()=>({request:{copyLabel:W?"Copy loaded request preview":"Copy request body",copyText:ae,copyCopied:V.copied,onCopy:V.copy,expansion:ue?{isExpanded:re.isExpanded,isPending:re.isPending,onToggle:re.toggle}:null,diffWithRaw:M3(se,n,r,M.rawRequestBody!==null)?{active:v,onToggle:()=>g(!v)}:void 0,diffWithPrevious:l===void 0?void 0:()=>{l(M)}},"raw-request":{copyLabel:W?"Copy loaded raw request preview":"Copy raw request",copyText:U,copyCopied:z.copied,onCopy:z.copy,expansion:ue?{isExpanded:pe.isExpanded,isPending:pe.isPending,onToggle:pe.toggle}:null},headers:{copyLabel:"Copy headers",copyText:w,copyCopied:I.copied,onCopy:I.copy,expansion:null},"raw-headers":{copyLabel:"Copy raw headers",copyText:K,copyCopied:$.copied,onCopy:$.copy,expansion:null},raw:{copyLabel:H?"Copy loaded response preview":"Copy response",copyText:ie,copyCopied:ee.copied,onCopy:ee.copy,expansion:ne?{isExpanded:ye.isExpanded,isPending:ye.isPending,onToggle:ye.toggle}:null}}),[ae,W,ue,V,re,v,M,M.rawRequestBody,U,z,pe,w,I,K,$,M.responseText,H,ne,ie,ee,ye,se,n,r,l]),Z=p.useMemo(()=>re.parsedData!==null?je.anatomySegments(re.parsedData):null,[je,re.parsedData]),te=p.useMemo(()=>H3(re.parsedData),[re.parsedData]),O=M.warnings??[],L=p.useMemo(()=>{if(Z!==null)return new Set(Z.map(_e=>_e.path))},[Z]),Q=r3({containerRef:R,setExpandToPath:_,ensureTabActive:()=>{x!=="request"&&b("request")}}),fe=p.useCallback((_e,Pe)=>{const Se=_e==="request"?E:J;Se(Ie=>({...Ie,status:"loading",error:null}));const ut=new URLSearchParams({part:_e,offset:String(Pe),limit:String(G3)});Vn(`/api/logs/${String(e.id)}/body?${ut.toString()}`,wv,q3).then(Ie=>{F.current===e.id&&Se(Vt=>({status:"success",text:Ie.offset===0?Ie.text:`${Vt.text}${Ie.text}`,offset:Ie.nextOffset??Ie.totalBytes,totalBytes:Ie.totalBytes,hasMore:Ie.hasMore,error:null}))}).catch(Ie=>{F.current===e.id&&Se(Vt=>({...Vt,status:"failed",error:J3(Ie)}))})},[e.id]),xe=p.useCallback(()=>{const _e=!c;_e&&b(Z!==null?"anatomy":"request"),u(_e)},[Z,c]);return p.useEffect(()=>{F.current=e.id,k.current=!1,S(null),C("idle"),E(is(e.rawRequestBodyBytes??null)),J(is(e.responseTextBytes??null))},[e.id,e.rawRequestBodyBytes,e.responseTextBytes]),p.useEffect(()=>{if(!c||!K3(e)||j!==null||k.current)return;let _e=!1;return k.current=!0,C("loading"),Vn(`/api/logs/${String(e.id)}`,kr,V3).then(Pe=>{_e||(k.current=!1,S(Pe),C("idle"))}).catch(()=>{_e||(k.current=!1,C("failed"))}),()=>{_e=!0,k.current=!1}},[c,j,e.bodyContentMode,e.id,e.rawRequestBodyBytes,e.responseTextBytes]),p.useEffect(()=>{c&&Y&&A.status==="idle"&&(x!=="request"&&x!=="raw-request"&&x!=="anatomy"||fe("request",0))},[x,c,fe,A.status,Y]),p.useEffect(()=>{c&&Y&&P.status==="idle"&&(x!=="parsed"&&x!=="raw"||fe("response",0))},[x,c,fe,P.status,Y]),p.useEffect(()=>{const _e=Pe=>{const Se=Br(Pe);Se!==null&&Se.logId===e.id&&(u(!0),b(Z3(Se.tab,Z)))};return window.addEventListener(jt,_e),()=>{window.removeEventListener(jt,_e)}},[Z,e.id]),s.jsxs(Je,{children:[s.jsxs("div",{className:de("relative mb-2 overflow-hidden rounded-lg border bg-[#07090d] transition-[background-color,border-color,box-shadow]",c?"border-cyan-300/25 shadow-[0_24px_80px_rgba(0,0,0,0.34),0_0_0_1px_rgba(103,232,249,0.04),inset_0_1px_0_rgba(255,255,255,0.06)]":"border-white/10 shadow-[0_6px_24px_rgba(0,0,0,0.16)] hover:border-cyan-300/15"),children:[s.jsx("div",{className:de("pointer-events-none absolute inset-y-3 left-1 w-px rounded-full",c?"bg-cyan-300/45 shadow-[0_0_20px_rgba(103,232,249,0.28)]":"bg-white/10"),"aria-hidden":"true"}),s.jsx("div",{className:"pointer-events-none absolute inset-x-3 top-0 h-px bg-gradient-to-r from-transparent via-white/15 to-transparent","aria-hidden":"true"}),s.jsx(j3,{log:M,displayNumber:t,messageCount:ce.messageCount,toolCount:ce.toolCount,expanded:c,onToggle:xe,cacheTrend:a,slowResponseThresholdSeconds:o,timeDisplayFormat:i,activeTab:x,tabActions:oe,onReplay:l===void 0?void 0:()=>{f(!0)}}),c&&s.jsxs("div",{className:"relative border-t border-cyan-300/10 bg-[linear-gradient(180deg,#06090d_0%,#040506_100%)] pt-2",onClick:_e=>_e.stopPropagation(),onKeyDown:_e=>_e.stopPropagation(),children:[s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-12 bg-gradient-to-b from-cyan-300/[0.035] to-transparent","aria-hidden":"true"}),s.jsxs(Dh,{value:x,onValueChange:b,className:"gap-2",children:[s.jsxs($h,{variant:"line",className:"inspector-scrollbar relative mx-3 h-auto w-[calc(100%-1.5rem)] justify-start overflow-x-auto rounded-none border-b border-cyan-300/10 bg-black/10 p-0",children:[n==="full"&&s.jsx(dt,{className:fn,value:"raw-headers",children:"Raw Headers"}),n==="full"&&s.jsx(dt,{className:fn,value:"headers",children:"Headers"}),Z!==null&&s.jsx(dt,{className:fn,value:"anatomy",children:"Context"}),Pc(se,n,r)&&s.jsx(dt,{className:fn,value:"raw-request",children:"Raw Request"}),s.jsx(dt,{className:fn,value:"request",children:"Request"}),n==="full"&&s.jsx(dt,{className:fn,value:"raw",children:"Raw Response"}),s.jsx(dt,{className:fn,value:"parsed",children:"Response"})]}),Pc(se,n,r)&&s.jsx(ft,{value:"raw-request",children:x==="raw-request"&&s.jsxs(pn,{children:[Y&&s.jsx(cs,{label:"Request",state:A,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>fe("request",A.offset)}),U===null?s.jsx(js,{children:Y?"Request preview is loading":"No request body"}):pe.parsedData!==null?s.jsx(p.Suspense,{fallback:s.jsx(On,{}),children:s.jsx(Wi,{data:pe.parsedData,bulkDepth:pe.bulkDepth,bulkRevision:pe.bulkRevision})}):s.jsx(ls,{children:U})]})}),s.jsx(ft,{value:"request",children:x==="request"&&s.jsxs(pn,{children:[T==="loading"&&s.jsx(xr,{tone:"loading",children:"Loading full request and response bodies..."}),T==="failed"&&s.jsx(xr,{tone:"warning",children:"Full request and response bodies could not be loaded. Compact metadata is still available."}),Y&&s.jsx(cs,{label:"Request",state:A,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>fe("request",A.offset)}),O.length>0&&s.jsxs(xr,{tone:"warning",children:[s.jsxs("div",{className:"flex items-center gap-2 font-semibold text-amber-300",children:[s.jsx(gn,{className:"size-3.5"}),"Tool schema warnings"]}),s.jsx("ul",{className:"mt-2 space-y-1 text-muted-foreground",children:O.map(_e=>s.jsx("li",{children:_e},_e))})]}),s.jsx(O3,{summary:te,calledToolNames:me.toolNames??[]}),v?s.jsx(Q3,{rawBody:M.rawRequestBody,displayedBody:ae,emptyLabel:"No transformation applied; raw and sent request bodies are identical."}):s.jsx("div",{ref:R,children:ae===null?s.jsx(js,{children:Y?"Request preview is loading":"No request body"}):re.parsedData!==null?s.jsx(p.Suspense,{fallback:s.jsx(On,{}),children:s.jsx(Wi,{data:re.parsedData,bulkDepth:re.bulkDepth,bulkRevision:re.bulkRevision,anatomyPaths:L,expandToPath:y})}):s.jsx(ls,{children:ae})})]})}),Z!==null&&s.jsx(ft,{value:"anatomy",children:x==="anatomy"&&s.jsx(pn,{className:"p-0",children:s.jsx(p.Suspense,{fallback:s.jsx(On,{}),children:s.jsx(YN,{parsed:re.parsedData,inputTokens:M.inputTokens??null,model:M.model,segments:Z,onSegmentActivate:Q})})})}),n==="full"&&s.jsx(ft,{value:"headers",children:x==="headers"&&s.jsxs(pn,{children:[s.jsx("div",{className:"flex justify-end gap-2 mb-2",children:P3(n,M.rawHeaders!==void 0&&Object.keys(M.rawHeaders).length>0)&&s.jsx(X3,{active:h,onClick:_e=>{_e.stopPropagation(),m(!h)}})}),h?s.jsx(eT,{rawHeaders:M.rawHeaders,headers:M.headers,emptyLabel:"No transformation applied; raw and processed headers are identical."}):s.jsx(Lc,{headers:M.headers,emptyLabel:"No headers captured"})]})}),n==="full"&&s.jsx(ft,{value:"raw-headers",children:x==="raw-headers"&&s.jsx(pn,{children:s.jsx(Lc,{headers:M.rawHeaders,emptyLabel:"No raw headers captured"})})}),s.jsx(ft,{value:"raw",children:x==="raw"&&s.jsxs(pn,{className:"space-y-3",children:[Y&&s.jsx(cs,{label:"Response",state:P,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>fe("response",P.offset)}),M.error!==void 0&&M.error!==null&&s.jsx(xr,{tone:"danger",title:"SSE Error",children:s.jsx("span",{className:"font-mono",children:M.error})}),ie!==null&&ne?s.jsx(p.Suspense,{fallback:s.jsx(On,{}),children:s.jsx(e3,{text:ie,defaultExpandDepth:0,bulkDepth:ye.bulkDepth,bulkRevision:ye.bulkRevision})}):ie!==null?s.jsx(ls,{children:ie}):s.jsx(js,{children:Y?"Response preview is loading":"No response"}),M.streaming===!0&&s.jsx(p.Suspense,{fallback:s.jsx(On,{}),children:s.jsx(QN,{logId:M.id,truncated:M.streamingChunksPath!==null})})]})}),s.jsx(ft,{value:"parsed",children:x==="parsed"&&s.jsxs(pn,{children:[Y&&s.jsx(cs,{label:"Response",state:P,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>fe("response",P.offset)}),H&&!ne?s.jsx(ls,{children:ie}):s.jsx(p.Suspense,{fallback:s.jsx(On,{}),children:s.jsx(XN,{responseText:ie,responseStatus:M.responseStatus,streaming:M.streaming,inputTokens:M.inputTokens,outputTokens:M.outputTokens,cacheCreationInputTokens:M.cacheCreationInputTokens,cacheReadInputTokens:M.cacheReadInputTokens,apiFormat:se,error:M.error})})]})})]})]})]}),s.jsx(p.Suspense,{fallback:null,children:s.jsx(JN,{log:M,displayNumber:t,open:d,onOpenChange:f})})]})});function nT(e){switch(e){case"end_turn":return"End of Turn (Anthropic)";case"stop":return"End of Turn (OpenAI)";case"length":return"End of Turn (length limit)";case"tool_use":case null:return"End of Turn"}}function rT({stopReason:e,isPending:t,isFirst:n,isTurnStart:r,isOnlyEntry:o=!1,crabIndex:i=0,collapsible:a=!1,onToggle:l}){const c=ll(e),u=o&&r&&c,d=t&&!c,f=p.useMemo(()=>qs(i),[i]),h=p.useMemo(()=>LN(i),[i]),m=a&&l?{role:"button",tabIndex:0,className:"cursor-pointer",onClick:v=>{v.stopPropagation(),l()},onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),l())}}:{};return s.jsxs("div",{className:"flex flex-col items-center w-6 shrink-0 pt-0.5 pb-0.5",children:[s.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]",children:!n&&s.jsx("div",{className:"w-0.5 bg-muted-foreground/30 h-full"})}),u?s.jsx("span",{title:"Start and end of turn",children:s.jsx(h,{className:de("size-3.5 text-[#80FF00]","animate-crab-settle","drop-shadow-[0_0_4px_rgba(128,255,0,0.5)]")})}):c?s.jsx("span",{title:nT(e),...m,children:s.jsx(f,{className:de("size-3.5 text-amber-400","animate-crab-settle","drop-shadow-[0_0_4px_rgba(251,191,36,0.5)]")})}):r?s.jsx("span",{title:"Start of turn",...m,children:s.jsx(f,{className:de("size-3.5 text-emerald-400","animate-crab-appear","drop-shadow-[0_0_4px_rgba(52,211,153,0.5)]")})}):d?s.jsx("span",{title:"Processing…",children:s.jsx(f,{className:de("size-3.5 text-amber-300/80","animate-crab-crawl")})}):s.jsx("span",{children:s.jsx(f,{className:"size-3.5 text-muted-foreground/40"})}),s.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:!c&&s.jsx("div",{className:de("w-0.5 h-full",t?"border-dashed bg-transparent border-l-2 border-muted-foreground/20":"bg-muted-foreground/30")})})]})}function sT({event:e}){const t=$t(e.argumentsText),n=e.argumentsText!==null;return s.jsxs("div",{className:"group/tool-trace flex min-w-0 items-center gap-2 rounded-md border border-border/70 bg-muted/20 px-2.5 py-1.5 text-xs",children:[s.jsx(Ir,{className:"size-3.5 shrink-0 text-sky-400/70"}),s.jsx("span",{className:"font-mono font-semibold text-foreground/80",children:e.name}),e.argumentsPreview!==null&&s.jsxs(s.Fragment,{children:[s.jsx(Ot,{className:"size-3 shrink-0 text-muted-foreground/60"}),s.jsx("span",{className:"min-w-0 truncate font-mono text-muted-foreground",children:e.argumentsPreview})]}),n&&s.jsx("button",{type:"button",className:"ml-auto inline-flex size-6 shrink-0 items-center justify-center rounded text-muted-foreground opacity-0 transition-opacity hover:bg-background/80 hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring group-hover/tool-trace:opacity-100 group-focus-within/tool-trace:opacity-100",onClick:t.copy,"aria-label":t.copied?"Copied tool arguments":"Copy tool arguments",title:t.copied?"Copied tool arguments":"Copy tool arguments",children:t.copied?s.jsx(Ge,{className:"size-3.5"}):s.jsx(St,{className:"size-3.5"})})]},e.id)}function oT({events:e}){return e.length===0?null:s.jsx("div",{className:"mx-3 mb-2 grid gap-1.5",children:e.map(t=>s.jsx(sT,{event:t},t.id))})}const Dc=180,ni=new WeakMap;function iT(e,t){const n=e.responseText;if(n===null)return!1;switch(t){case"anthropic":return n.includes("tool_use");case"openai":return n.includes("tool_calls")||n.includes("function_call");case"unknown":return!1}}function aT(e,t){return e||t}function lT(e,t,n){return e>1&&t&&!n}function cT(e){const t=[];let n=[],r=0;for(let o=0;o<e.length;o+=1){const i=e[o];if(i===void 0)continue;n.push({log:i,stopReason:jN(i),sessionLogNumber:o+1});const a=n[n.length-1];a!==void 0&&ll(a.stopReason)&&(t.push({entries:n,turnIndex:r}),n=[],r+=1)}return n.length>0&&t.push({entries:n,turnIndex:r}),t}function uT(e){const t=new Map;for(const n of e)for(let r=1;r<n.logs.length;r+=1){const o=n.logs[r],i=n.logs[r-1];if(o===void 0||i===void 0)continue;const a=Nr(o),l=Nr(i);a==="unknown"||a!==l||t.set(o.id,i)}return t}function Yh(e){if(e===null)return null;try{const t=JSON.parse(e);return typeof t=="string"?JSON.parse(t):t}catch{return null}}function qi(e){if(e==null)return null;const t=typeof e=="string"?e:JSON.stringify(e);if(t===void 0)return null;const n=t.replace(/\s+/g," ").trim();return n.length===0?null:n.length>Dc?`${n.slice(0,Dc-1)}...`:n}function Gi(e){if(e==null)return null;if(typeof e=="string")return e.length>0?e:null;const t=JSON.stringify(e,null,2);return t===void 0||t.length===0?null:t}function dT(e){const t=Yh(e.responseText),n=ke(t,"content");if(!Array.isArray(n))return[];const r=[];for(const o of n){if(ke(o,"type")!=="tool_use")continue;const a=ke(o,"name");if(typeof a!="string"||a.length===0)continue;const l=ke(o,"input");r.push({id:`${String(e.id)}-anthropic-tool-${String(r.length)}`,logId:e.id,index:r.length,provider:"anthropic",name:a,argumentsText:Gi(l),argumentsPreview:qi(l)})}return r}function fT(e){const t=Yh(e.responseText),n=ke(t,"choices");if(!Array.isArray(n))return[];const r=[];for(const i of n){const a=ke(i,"message"),l=ke(a,"tool_calls");if(Array.isArray(l))for(const c of l){const u=ke(c,"function"),d=ke(u,"name");if(typeof d!="string"||d.length===0)continue;const f=ke(u,"arguments");r.push({id:`${String(e.id)}-openai-tool-${String(r.length)}`,logId:e.id,index:r.length,provider:"openai",name:d,argumentsText:Gi(f),argumentsPreview:qi(f)})}}const o=ke(t,"output");if(Array.isArray(o))for(const i of o){if(ke(i,"type")!=="function_call")continue;const a=ke(i,"name");if(typeof a!="string"||a.length===0)continue;const l=ke(i,"arguments");r.push({id:`${String(e.id)}-openai-tool-${String(r.length)}`,logId:e.id,index:r.length,provider:"openai",name:a,argumentsText:Gi(l),argumentsPreview:qi(l)})}return r}function cl(e){const t=ni.get(e);if(t!==void 0&&t.apiFormat===e.apiFormat&&t.responseText===e.responseText)return t.events;const n=Nr(e);if(!iT(e,n)){const o=[];return ni.set(e,{apiFormat:e.apiFormat,responseText:e.responseText,events:o}),o}let r;switch(n){case"anthropic":r=dT(e);break;case"openai":r=fT(e);break;case"unknown":r=[];break}return ni.set(e,{apiFormat:e.apiFormat,responseText:e.responseText,events:r}),r}function pT(e,t,n=0){let r=0,o=0,i=0,a=0,l=0,c=0,u=0,d=0,f=null,h=0;for(const m of e)m.responseStatus===null?o+=1:m.responseStatus>=400&&(r+=1),m.elapsedMs!==null&&t>0&&m.elapsedMs>t*1e3&&(i+=1),m.inputTokens!==null&&(a+=m.inputTokens),m.outputTokens!==null&&(l+=m.outputTokens),m.cacheCreationInputTokens!==null&&(c+=m.cacheCreationInputTokens),m.cacheReadInputTokens!==null&&(u+=m.cacheReadInputTokens),m.elapsedMs!==null&&(d+=m.elapsedMs,f=f===null?m.elapsedMs:Math.max(f,m.elapsedMs)),h+=cl(m).length;return{llmCallCount:e.length,toolCallCount:h,failedCallCount:r,pendingCallCount:o,slowCallCount:i,totalInputTokens:a,totalOutputTokens:l,totalCacheCreationInputTokens:c,totalCacheReadInputTokens:u,totalElapsedMs:d,maxElapsedMs:f,startedAt:e[0]?.timestamp??null,endedAt:e[e.length-1]?.timestamp??null,knowledgeCandidateCount:n}}function ri(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}const hT=p.memo(function({entries:t,viewMode:n,strip:r,slowResponseThresholdSeconds:o,cacheTrends:i,onCompareWithPrevious:a,comparisonPredecessors:l,turnIndex:c=0,timeDisplayFormat:u,pendingFocusRequest:d}){const f=t.length-1,h=t[f]?.stopReason??null,m=h!==null?ll(h):!1,v=t[f]?.log.responseStatus===null,g=t.length===1,x=lT(t.length,m,v),[b,y]=p.useState(!1),_=p.useRef(!1);p.useEffect(()=>{x?m&&!_.current&&y(!0):y(!1),_.current=m},[x,m]),p.useEffect(()=>{const D=B=>{const U=Br(B);U!==null&&t.some(ie=>ie.log.id===U.logId)&&x&&y(!1)};return window.addEventListener(jt,D),()=>{window.removeEventListener(jt,D)}},[x,t]),p.useEffect(()=>{if(d===void 0||!t.some(B=>B.log.id===d.logId))return;x&&y(!1);const D=window.setTimeout(()=>{Vs({logId:d.logId,tab:d.tab,source:"virtualizer"})},0);return()=>window.clearTimeout(D)},[x,t,d]);const j=p.useCallback(()=>{x&&y(D=>!D)},[x]),S=p.useMemo(()=>{let D=0,B=0,U=null,ie=!1;for(const W of t)W.log.inputTokens!==null&&(D+=W.log.inputTokens,ie=!0),W.log.outputTokens!==null&&(B+=W.log.outputTokens,ie=!0),W.log.elapsedMs!==null&&(U=U===null?W.log.elapsedMs:Math.max(U,W.log.elapsedMs));return{totalInput:D,totalOutput:B,hasTokens:ie,maxElapsed:U}},[t,f]),T=p.useMemo(()=>qs(t[0]?.log.id??0),[t]),C=p.useMemo(()=>qs(t[f]?.log.id??0),[t,f]),A=c%2===0?"bg-[#070a0f]":"bg-[#090d12]",E=S.maxElapsed!==null&&o>0&&S.maxElapsed>o*1e3,P=p.useMemo(()=>{const D=new Map;for(const B of t){const U=cl(B.log);U.length>0&&D.set(B.log.id,U)}return D},[t]),[J,R]=p.useState(0),F=p.useRef(null);p.useEffect(()=>{const D=F.current;if(!D)return;let B=0;const U=new ResizeObserver(()=>{window.cancelAnimationFrame(B),B=window.requestAnimationFrame(()=>R(ie=>ie+1))});return U.observe(D),()=>{U.disconnect(),window.cancelAnimationFrame(B)}},[]);const k=t[0]?.log.id??c,M=`Turn ${String(c+1)}`,Y=p.useMemo(()=>({contentVisibility:"auto",containIntrinsicSize:b?"48px":"160px"}),[b]);return s.jsx("div",{ref:F,style:Y,tabIndex:b?void 0:0,role:b?void 0:"group","aria-label":b?void 0:M,"data-nav-id":b?void 0:`turn-${String(k)}`,className:de("border rounded-lg transition-[border-color,box-shadow]",v?"border-amber-300/15 shadow-[0_0_0_1px_rgba(252,211,77,0.04)]":"border-transparent",!b&&"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none"),children:b?s.jsxs("div",{"data-nav-id":`turn-collapsed-${String(k)}`,"data-nav-action":"expand",role:"button",tabIndex:0,className:"flex items-stretch cursor-pointer focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none rounded-lg",onClick:j,onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),j())},children:[s.jsx("div",{className:"w-5 shrink-0 flex items-start pt-1.5",children:s.jsx("span",{className:"text-[10px] text-muted-foreground/50 font-mono tabular-nums leading-none select-none",children:c+1})}),s.jsxs("div",{className:"w-6 shrink-0 flex flex-col items-center pt-0.5 pb-0.5",children:[s.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]"}),s.jsx("span",{role:"button",tabIndex:0,title:"Start of turn — click to expand",className:"cursor-pointer",onClick:D=>{D.stopPropagation(),j()},onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),j())},children:s.jsx(T,{className:de("size-3.5 text-emerald-400","animate-crab-appear drop-shadow-[0_0_4px_rgba(52,211,153,0.5)]")})}),s.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:s.jsx("div",{className:"w-0.5 bg-muted-foreground/30 h-full"})}),s.jsx("span",{role:"button",tabIndex:0,title:"End of Turn — click to expand",className:"cursor-pointer",onClick:D=>{D.stopPropagation(),j()},onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),j())},children:s.jsx(C,{className:de("size-3.5 text-amber-400","animate-crab-settle drop-shadow-[0_0_4px_rgba(251,191,36,0.5)]")})})]}),t.length>1&&s.jsxs("div",{className:de("flex-1 min-w-0 mb-0.5 rounded-lg border border-cyan-300/10 py-1.5 px-3 flex items-center gap-3 text-xs shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]",A),children:[s.jsx("span",{className:nl,children:s.jsx(Ot,{className:"size-4 shrink-0"})}),s.jsxs("span",{className:"text-blue-400/80 font-mono font-semibold tabular-nums shrink-0",title:`Log IDs ${String(t[0]?.log.id??"?")} ~ ${String(t[f]?.log.id??"?")}`,children:["#",t[0]?.sessionLogNumber??"?"," ~ #",t[f]?.sessionLogNumber??"?"]}),s.jsxs("span",{className:"text-muted-foreground shrink-0",children:[t.length," request",t.length>1?"s":""]}),S.maxElapsed!==null&&s.jsx(Je,{children:s.jsxs(Me,{children:[s.jsx(Le,{asChild:!0,children:s.jsxs("span",{className:de("flex items-center gap-1 shrink-0",E?"text-amber-400":"text-muted-foreground"),children:[s.jsx(Bt,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:ri(S.maxElapsed)}),E&&s.jsx(gn,{className:"size-3","aria-label":"Slow response"})]})}),s.jsx(De,{children:E?`Slow response: ${ri(S.maxElapsed)} exceeds ${ri(o*1e3)}`:"Slowest request in this turn"})]})}),S.hasTokens&&s.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[s.jsx(jr,{className:"size-3 text-muted-foreground"}),s.jsxs("span",{className:"font-mono tabular-nums",children:[s.jsxs("span",{className:"text-blue-400",children:["IN ",Be(S.totalInput)]})," / ",s.jsxs("span",{className:"text-amber-400",children:["OUT ",Be(S.totalOutput)]})]})]}),s.jsx("span",{className:"flex-1 min-w-0"})]})]}):t.map((D,B)=>{const{log:U,stopReason:ie}=D,W=B===0;return s.jsxs("div",{className:"flex items-stretch",children:[W?s.jsx("div",{className:"w-5 shrink-0 flex items-start pt-1.5",children:s.jsx("span",{className:"text-[10px] text-muted-foreground/50 font-mono tabular-nums leading-none select-none",children:c+1})}):s.jsx("div",{className:"w-5 shrink-0"}),s.jsx(rT,{stopReason:ie,isPending:U.responseStatus===null,isFirst:B===0,isTurnStart:W,isOnlyEntry:g,crabIndex:U.id%12,collapsible:x&&W,onToggle:j}),s.jsxs("div",{className:de("flex-1 min-w-0 mb-0.5 rounded-lg",A),children:[s.jsx(tT,{log:U,displayNumber:D.sessionLogNumber,viewMode:n,strip:r,slowResponseThresholdSeconds:o,timeDisplayFormat:u,cacheTrend:i?.get(U.id)??null,onCompareWithPrevious:l.has(U.id)?a:void 0}),s.jsx(oT,{events:P.get(U.id)??[]})]})]},U.id)})})}),mT=24,gT=132,xT=8;function bT(e){return e>mT}function vT(e){const t=new Map;for(let n=0;n<e.length;n++){const r=e[n];if(r!==void 0)for(const o of r.entries)t.set(o.log.id,n)}return t}function Xh(e,t,n){return s.jsx(hT,{entries:e.entries,viewMode:t.viewMode,strip:t.strip,slowResponseThresholdSeconds:t.slowResponseThresholdSeconds,timeDisplayFormat:t.timeDisplayFormat,cacheTrends:t.cacheTrends,onCompareWithPrevious:t.onCompareWithPrevious,comparisonPredecessors:t.comparisonPredecessors,turnIndex:e.turnIndex,pendingFocusRequest:n},e.turnIndex)}function yT(e){return bT(e.turnGroups.length)?s.jsx(wT,{...e}):s.jsx(s.Fragment,{children:e.turnGroups.map(t=>Xh(t,e))})}function wT(e){const{turnGroups:t}=e,[n,r]=p.useState(null),o=Ph({count:t.length,estimateSize:()=>gT,overscan:xT,getItemKey:a=>t[a]?.turnIndex??a}),i=p.useMemo(()=>vT(t),[t]);return p.useEffect(()=>{const a=l=>{const c=Br(l);if(c===null||c.source==="virtualizer")return;const u=i.get(c.logId);u!==void 0&&(o.scrollToIndex(u,{align:"center"}),r(d=>({...c,turnIndex:u,nonce:d===null?1:d.nonce+1})))};return window.addEventListener(jt,a),()=>{window.removeEventListener(jt,a)}},[i,o]),s.jsx("div",{className:"relative w-full",style:{height:`${o.getTotalSize()}px`},"data-virtualized-turn-list":"true",children:o.getVirtualItems().map(a=>{const l=t[a.index];if(l===void 0)return null;const c=n!==null&&n.turnIndex===a.index?n:void 0;return s.jsx("div",{"data-index":a.index,ref:o.measureElement,className:"absolute left-0 top-0 w-full",style:{transform:`translateY(${a.start}px)`},children:Xh(l,e,c)},a.key)})})}const ul=Ee(["episode","procedure","preference","project-fact"]),kT=Ee(["draft","promoted","failed"]),Qh=G({source:Te("agent-inspector"),sessionId:N(),logIds:he(q().int().positive()),project:N().nullable(),models:he(N())}),_T=G({redacted:$e(),patterns:he(N())}),Ur=G({id:N(),type:ul,title:N(),content:N(),tags:he(N()),source:Te("agent-inspector"),sessionId:N(),logIds:he(q().int().positive()),evidence:Qh,status:kT,createdAt:N(),updatedAt:N(),openClawMemoryId:N().nullable(),error:N().nullable(),redaction:_T});G({idempotencyKey:N(),type:ul,title:N(),content:N(),tags:he(N()),source:Te("agent-inspector"),project:N().nullable(),evidence:Qh});const jT=G({id:N(),type:ul.or(N()),title:N(),content:N(),score:q().nullable(),source:N().nullable(),project:N().nullable(),evidence:mn().optional()});G({results:he(jT),warning:N().nullable()});const ST=G({candidates:he(Ur)}),CT=G({candidate:Ur}),NT=G({error:N().optional(),candidate:Ur.optional()}),TT=G({candidate:Ur}),ET={draft:"border-amber-500/30 bg-amber-500/10 text-amber-500",promoted:"border-emerald-500/30 bg-emerald-500/10 text-emerald-500",failed:"border-destructive/30 bg-destructive/10 text-destructive"};function Ki(e){return e===null?"-":e<1e3?`${String(e)}ms`:`${(e/1e3).toFixed(1)}s`}function AT(e,t,n){return e===null||t===null?null:Ea(e,t,n)}function RT(e){return`${String(e)} candidate${e===1?"":"s"}`}function em(e){return`log-${String(e)}`}function tm(e){const t=em(e),n=document.getElementById(t);window.history.replaceState(null,"",`#${t}`),n instanceof HTMLElement&&(n.scrollIntoView({block:"center",behavior:"smooth"}),n.focus({preventScroll:!0}))}function IT(e){for(const t of e)if(t.responseStatus!==null&&t.responseStatus>=400)return t;return null}function zT(e){let t=null,n=-1;for(const r of e)r.elapsedMs!==null&&r.elapsedMs>n&&(t=r,n=r.elapsedMs);return t}function OT(e){for(const t of e)if(cl(t).length>0)return t;return null}function PT(e){const t=new Map;for(let n=0;n<e.length;n+=1){const r=e[n];r!==void 0&&t.set(r.id,n+1)}return t}function Wn(e,t){return String(t.get(e)??e)}function MT(e){const t=[{kind:"session",title:`${String(e.summary.llmCallCount)} LLM call${e.summary.llmCallCount===1?"":"s"}`,detail:`Scope ${e.scopeId}`,logId:e.logs[0]?.id??null}],n=OT(e.logs);e.summary.toolCallCount>0&&n!==null&&t.push({kind:"tool",title:`${String(e.summary.toolCallCount)} tool call${e.summary.toolCallCount===1?"":"s"}`,detail:`First tool evidence at #${Wn(n.id,e.displayNumberByLogId)}`,logId:n.id});const r=IT(e.logs);r!==null&&t.push({kind:"failure",title:`Failure #${String(r.responseStatus)}`,detail:`First failed request is #${Wn(r.id,e.displayNumberByLogId)}`,logId:r.id});const o=zT(e.logs);if(o!==null&&e.summary.maxElapsedMs!==null&&t.push({kind:"slow",title:`Slowest ${Ki(e.summary.maxElapsedMs)}`,detail:`Max latency observed at #${Wn(o.id,e.displayNumberByLogId)}`,logId:o.id}),e.candidates.length>0){const i=e.candidates.filter(l=>l.status==="draft").length,a=e.candidates.filter(l=>l.status==="promoted").length;t.push({kind:"candidate",title:`${String(e.candidates.length)} memory candidate${e.candidates.length===1?"":"s"}`,detail:`${String(i)} draft / ${String(a)} promoted`,logId:e.candidates[0]?.logIds[0]??null})}return t}function LT(e){switch(e){case"session":return s.jsx(uo,{className:"size-3.5 text-blue-400"});case"tool":return s.jsx(Ir,{className:"size-3.5 text-sky-400/70"});case"slow":return s.jsx(Bt,{className:"size-3.5 text-amber-400"});case"failure":return s.jsx(Od,{className:"size-3.5 text-destructive"});case"candidate":return s.jsx(zd,{className:"size-3.5 text-emerald-400"})}}function DT({insights:e}){return e.length===0?null:s.jsx("div",{className:"mt-2 grid gap-1.5 border-t border-border/70 pt-2 md:grid-cols-2 xl:grid-cols-3",children:e.map(t=>s.jsxs("button",{type:"button",className:de("flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs","text-muted-foreground transition-colors hover:bg-muted/40 hover:text-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),onClick:()=>{t.logId!==null&&tm(t.logId)},disabled:t.logId===null,children:[LT(t.kind),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block truncate font-medium text-foreground/90",children:t.title}),s.jsx("span",{className:"block truncate font-mono text-[10px]",children:t.detail})]})]},`${t.kind}-${t.title}`))})}function $T(e){switch(e){case"draft":return"Draft";case"promoted":return"Promoted";case"failed":return"Failed"}}function FT(e,t){if(t)return"Promoting";switch(e.status){case"draft":return"Promote";case"failed":return"Retry";case"promoted":return"Promoted"}}function BT(e){return e.redaction.redacted?`Redacted ${e.redaction.patterns.join(", ")}`:"No sensitive pattern matched"}function UT(e,t){const n=e.replace(/\s+/g," ").trim();return n.length<=t?n:`${n.slice(0,t-3)}...`}function WT(e,t){const n=e[0],r=e[e.length-1];if(n===void 0)return"No evidence logs";const o=Wn(n,t);return r===void 0||n===r?`#${o}`:`#${o}-#${Wn(r,t)}`}function $c(e){return e.join(", ")}function HT(e){return e.split(",").map(t=>t.trim()).filter(t=>t.length>0)}function ZT({candidate:e,isPromoting:t,isUpdating:n,onPromoteCandidate:r,onUpdateCandidate:o,displayNumberByLogId:i}){const[a,l]=p.useState(!1),[c,u]=p.useState(e.type),[d,f]=p.useState(e.title),[h,m]=p.useState(e.content),[v,g]=p.useState($c(e.tags)),[x,b]=p.useState(null),y=e.status!=="promoted",_=e.status!=="promoted",j=p.useCallback(()=>{u(e.type),f(e.title),m(e.content),g($c(e.tags)),b(null)},[e.content,e.tags,e.title,e.type]),S=p.useCallback(async()=>{const T=d.trim(),C=h.trim(),A=HT(v);if(T.length===0){b("Title is required.");return}if(C.length===0){b("Content is required.");return}if(A.length===0){b("At least one tag is required.");return}b(null),await o(e.id,{type:c,title:T,content:C,tags:A})&&l(!1)},[e.id,h,v,d,c,o]);return a?s.jsx("div",{className:"rounded-md border border-border/80 bg-background/60 px-2.5 py-2",children:s.jsxs("div",{className:"grid gap-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("select",{value:c,disabled:n,onChange:T=>{const C=Ur.shape.type.safeParse(T.currentTarget.value);C.success&&u(C.data)},className:"h-7 rounded-md border border-input bg-background px-2 text-xs","aria-label":"Candidate type",children:[s.jsx("option",{value:"episode",children:"episode"}),s.jsx("option",{value:"procedure",children:"procedure"}),s.jsx("option",{value:"preference",children:"preference"}),s.jsx("option",{value:"project-fact",children:"project-fact"})]}),s.jsx("input",{value:d,disabled:n,onChange:T=>f(T.currentTarget.value),className:"h-7 min-w-[220px] flex-1 rounded-md border border-input bg-background px-2 text-xs","aria-label":"Candidate title"})]}),s.jsx("textarea",{value:h,disabled:n,onChange:T=>m(T.currentTarget.value),className:"min-h-28 rounded-md border border-input bg-background px-2 py-1.5 font-mono text-[11px] leading-relaxed","aria-label":"Candidate content"}),s.jsx("input",{value:v,disabled:n,onChange:T=>g(T.currentTarget.value),className:"h-7 rounded-md border border-input bg-background px-2 text-xs","aria-label":"Candidate tags"}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-muted-foreground",children:[s.jsx(Ul,{className:"size-3"}),"Saving reruns Inspector redaction before promotion."]}),s.jsx("span",{className:"flex-1"}),x!==null&&s.jsx("span",{className:"text-[10px] text-destructive",children:x}),s.jsxs(Ne,{type:"button",variant:"ghost",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:n,onClick:()=>{j(),l(!1)},children:[s.jsx(Ta,{className:"size-3.5"}),"Cancel"]}),s.jsxs(Ne,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:n,onClick:()=>{S()},children:[n?s.jsx(zs,{className:"size-3.5 animate-spin"}):s.jsx(s2,{className:"size-3.5"}),"Save"]})]})]})}):s.jsxs("div",{className:"rounded-md border border-border/80 bg-background/60 px-2.5 py-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(Fe,{variant:"outline",className:"h-5 px-1.5 text-[10px] font-mono",children:e.type}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",title:e.title,children:e.title}),s.jsx(Fe,{variant:"outline",className:de("h-5 shrink-0 px-1.5 text-[10px] font-mono",ET[e.status]),children:$T(e.status)})]}),s.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",title:e.content,children:UT(e.content,360)}),s.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] text-muted-foreground",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(jy,{className:"size-3"}),WT(e.logIds,i)]}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(Ul,{className:"size-3"}),BT(e)]}),e.status==="promoted"&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-500",children:[s.jsx($l,{className:"size-3"}),e.openClawMemoryId??"OpenClaw"]}),e.status==="failed"&&e.error!==null&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-destructive",children:[s.jsx(Od,{className:"size-3"}),e.error]})]}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[e.logIds.map(T=>{const C=Wn(T,i);return s.jsxs("a",{href:`#${em(T)}`,onClick:A=>{A.preventDefault(),tm(T)},className:"rounded border border-blue-400/25 px-1.5 py-0.5 font-mono text-[10px] text-blue-400 underline-offset-2 transition-colors hover:bg-blue-400/10 hover:text-blue-300 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":`Jump to evidence log ${C}`,title:`Log ID ${String(T)}`,children:["#",C]},T)}),s.jsx("span",{className:"flex-1"}),_&&s.jsxs(Ne,{type:"button",variant:"ghost",size:"sm",className:"h-6 gap-1.5 px-2 text-[10px]",disabled:n||t,onClick:()=>l(!0),children:[s.jsx(Md,{className:"size-3"}),"Review"]}),s.jsxs(Ne,{type:"button",variant:y?"outline":"ghost",size:"sm",className:"h-6 gap-1.5 px-2 text-[10px]",onClick:()=>r(e.id),disabled:!y||t||n,children:[t?s.jsx(zs,{className:"size-3 animate-spin"}):y?s.jsx(ay,{className:"size-3"}):s.jsx($l,{className:"size-3"}),FT(e,t)]})]})]})}function VT({candidates:e,promotingCandidateIds:t,updatingCandidateIds:n,onPromoteCandidate:r,onUpdateCandidate:o,displayNumberByLogId:i}){return e.length===0?null:s.jsx("div",{className:"mt-2 grid gap-1.5",children:e.map(a=>s.jsx(ZT,{candidate:a,isPromoting:t.has(a.id),isUpdating:n.has(a.id),onPromoteCandidate:r,onUpdateCandidate:o,displayNumberByLogId:i},a.id))})}function qT({logs:e,scopeId:t,slowResponseThresholdSeconds:n,showRollupMetrics:r,timeDisplayFormat:o}){const[i,a]=p.useState([]),[l,c]=p.useState(!0),[u,d]=p.useState({status:"idle",error:null}),[f,h]=p.useState(()=>new Set),[m,v]=p.useState(()=>new Set),g=i.length>0,x=p.useMemo(()=>pT(e,n,i.length),[i.length,e,n]),b=p.useMemo(()=>PT(e),[e]),y=p.useMemo(()=>MT({logs:e,scopeId:t,summary:x,candidates:i,displayNumberByLogId:b}),[i,b,e,t,x]),_=r||x.maxElapsedMs!==null,j=p.useMemo(()=>AT(x.startedAt,x.endedAt,o),[x.endedAt,x.startedAt,o]),S=p.useCallback(()=>{e.length===0||u.status==="loading"||(d({status:"loading",error:null}),(async()=>{try{const A=await fetch(`/api/knowledge/sessions/${encodeURIComponent(t)}/candidates`,{method:"POST"});if(!A.ok){const P=await Ft(A,`Candidate generation failed with ${String(A.status)}`);d({status:"failed",error:P});return}const E=await wt(A,ST);a(E.candidates),c(E.candidates.length>0),d(E.candidates.length>0?{status:"ready",error:null}:{status:"failed",error:"No candidate was generated for this trace scope."})}catch(A){d({status:"failed",error:A instanceof Error?A.message:"Candidate response was invalid"})}})())},[u.status,e.length,t]),T=p.useCallback(A=>{h(E=>{if(E.has(A))return E;const P=new Set(E);return P.add(A),P}),(async()=>{try{const E=await fetch(`/api/knowledge/candidates/${encodeURIComponent(A)}/promote`,{method:"POST"}),P=await E.json().catch(()=>null),J=CT.safeParse(P);if(E.ok&&J.success){a(F=>F.map(k=>k.id===J.data.candidate.id?J.data.candidate:k)),d({status:"ready",error:null});return}const R=NT.safeParse(P);R.success&&R.data.candidate!==void 0&&a(F=>F.map(k=>k.id===R.data.candidate?.id?R.data.candidate:k)),d({status:"failed",error:R.success?R.data.error??"Candidate promotion failed":`Candidate promotion failed with ${String(E.status)}`})}catch(E){d({status:"failed",error:E instanceof Error?E.message:"Candidate promotion failed"})}finally{h(E=>{const P=new Set(E);return P.delete(A),P})}})()},[]),C=p.useCallback(async(A,E)=>{v(P=>{if(P.has(A))return P;const J=new Set(P);return J.add(A),J});try{const P=await fetch(`/api/knowledge/candidates/${encodeURIComponent(A)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(E)});if(!P.ok){const R=await Ft(P,`Candidate update failed with ${String(P.status)}`);return d({status:"failed",error:R}),!1}const J=await wt(P,TT);return a(R=>R.map(F=>F.id===J.candidate.id?J.candidate:F)),d({status:"ready",error:null}),!0}catch(P){return d({status:"failed",error:P instanceof Error?P.message:"Candidate update failed"}),!1}finally{v(P=>{const J=new Set(P);return J.delete(A),J})}},[]);return e.length===0?null:s.jsxs("section",{className:"mb-2 rounded-lg border border-border bg-muted/10 px-3 py-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 text-xs",children:[r&&s.jsxs("span",{className:"inline-flex items-center gap-1.5 font-semibold text-foreground",children:[s.jsx(uo,{className:"size-3.5 text-blue-400"}),x.llmCallCount," LLM"]}),s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[s.jsx(Ir,{className:"size-3.5 text-sky-400/70"}),x.toolCallCount," tools"]}),r&&s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[s.jsx(jr,{className:"size-3.5 text-emerald-400"}),s.jsxs("span",{className:"font-mono",children:[Be(x.totalInputTokens)," / ",Be(x.totalOutputTokens)]})]}),(x.totalCacheCreationInputTokens>0||x.totalCacheReadInputTokens>0)&&s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[s.jsx(jr,{className:"size-3.5 text-purple-400"}),s.jsxs("span",{className:"font-mono",children:["KV Cache +",Be(x.totalCacheCreationInputTokens)," / ~",Be(x.totalCacheReadInputTokens)]})]}),_&&s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[s.jsx(Bt,{className:"size-3.5"}),r&&s.jsx("span",{className:"font-mono",children:Ki(x.totalElapsedMs)}),x.maxElapsedMs!==null&&s.jsxs("span",{className:"font-mono text-muted-foreground/70",children:["max ",Ki(x.maxElapsedMs)]})]}),r&&j!==null&&s.jsx("span",{className:"font-mono text-muted-foreground/70",children:j}),(x.failedCallCount>0||x.pendingCallCount>0||x.slowCallCount>0)&&s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-amber-400",children:[s.jsx(gn,{className:"size-3.5"}),s.jsxs("span",{className:"font-mono",children:[x.failedCallCount," fail / ",x.pendingCallCount," pending /"," ",x.slowCallCount," slow"]})]}),s.jsx("span",{className:"flex-1"}),g&&s.jsx(Fe,{variant:"outline",className:"h-6 px-2 text-[10px] font-mono",children:RT(x.knowledgeCandidateCount)}),s.jsxs(Ne,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",onClick:S,disabled:u.status==="loading",children:[u.status==="loading"?s.jsx(ht,{className:"size-3.5 animate-spin"}):s.jsx(zd,{className:"size-3.5"}),"Candidate"]}),g&&s.jsx(Ne,{type:"button",variant:"ghost",size:"icon",className:"size-7 text-muted-foreground",onClick:()=>c(A=>!A),"aria-expanded":l,"aria-label":l?"Collapse memory candidates":"Expand memory candidates",children:l?s.jsx(ct,{className:"size-3.5"}):s.jsx(Ot,{className:"size-3.5"})})]}),u.status==="failed"&&s.jsx("p",{className:"mt-2 text-xs text-destructive",children:u.error}),s.jsx(DT,{insights:y}),l&&s.jsx(VT,{candidates:i,promotingCandidateIds:f,updatingCandidateIds:m,onPromoteCandidate:T,onUpdateCandidate:C,displayNumberByLogId:b})]})}function GT(e){let t=0,n=0;for(const r of e)r.inputTokens!==null&&(t+=r.inputTokens),r.outputTokens!==null&&(n+=r.outputTokens);return{totalInputTokens:t,totalOutputTokens:n}}function KT(e){const t=new Map;for(const n of e){if(n.model===null)continue;const r=Z_(n.model);if(r==="unknown")continue;let o=t.get(r);o===void 0&&(o=new Set,t.set(r,o)),o.add(n.model)}return[...t.entries()].map(([n,r])=>({provider:n,models:[...r]}))}function JT(e){for(const t of e){const n=t.clientPid;if(n!=null)return n}return null}function YT(e){for(const t of e){const n=t.clientProjectFolder;if(n!=null&&n!=="")return n}return null}const nm=p.memo(function({group:e,viewMode:t="simple",strip:n,slowResponseThresholdSeconds:r,cacheTrends:o,onCompareWithPrevious:i,comparisonPredecessors:a,onClearGroup:l,standalone:c=!1,hasPinnedSessionContext:u=!1,timeDisplayFormat:d,expanded:f,onExpandedChange:h}){const[m,v]=p.useState(!1),g=f??m,x=p.useCallback(P=>{if(h!==void 0){h(P);return}v(P)},[h]),b=p.useMemo(()=>GT(e.logs),[e.logs]),y=p.useMemo(()=>KT(e.logs),[e.logs]),_=e.logs[0]?.timestamp??new Date().toISOString(),j=e.logs[e.logs.length-1]?.timestamp??new Date().toISOString(),S=e.logs.some(P=>P.responseStatus===null),T=c&&!u,C=p.useMemo(()=>JT(e.logs),[e.logs]),A=p.useMemo(()=>YT(e.logs),[e.logs]),E=p.useMemo(()=>cT(e.logs),[e.logs]);return p.useEffect(()=>{const P=J=>{if(c)return;const R=Br(J);R!==null&&e.logs.some(F=>F.id===R.logId)&&x(!0)};return window.addEventListener(jt,P),()=>{window.removeEventListener(jt,P)}},[e.logs,x,c]),s.jsxs("div",{className:"mb-2",children:[!c&&s.jsx(rN,{conversationId:e.conversationId,startTime:_,endTime:j,totalCalls:e.logs.length,totalInputTokens:b.totalInputTokens,totalOutputTokens:b.totalOutputTokens,expanded:g,onToggle:()=>x(!g),providers:y,isLoading:S,userAgent:e.logs[0]?.userAgent??null,clientPid:C,clientProjectFolder:A,timeDisplayFormat:d,onClear:()=>l(e.logs.map(P=>P.id))}),aT(c,g)&&s.jsxs("div",{children:[s.jsx(qT,{logs:e.logs,scopeId:e.conversationId,slowResponseThresholdSeconds:r,showRollupMetrics:T,timeDisplayFormat:d}),s.jsx(yT,{turnGroups:E,viewMode:t,strip:n,slowResponseThresholdSeconds:r,timeDisplayFormat:d,cacheTrends:o,onCompareWithPrevious:i,comparisonPredecessors:a})]})]})});function Fc({className:e}){return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:de("inline-block size-5",e),children:[s.jsx("path",{d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z"}),s.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),s.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),s.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),s.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"}),s.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),s.jsx("line",{x1:"6.5",y1:"16",x2:"4.5",y2:"19.5"}),s.jsx("line",{x1:"9",y1:"17.5",x2:"8",y2:"20.5"}),s.jsx("line",{x1:"15",y1:"17.5",x2:"16",y2:"20.5"}),s.jsx("line",{x1:"17.5",y1:"16",x2:"19.5",y2:"19.5"})]})}const XT="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPoAAAD6CAQAAAAi5ZK2AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QA/4ePzL8AAAAHdElNRQfpCxsJDCnsge2KAAAM2ElEQVR42u2de3AW1RnGnyQQDARDwiUFpHIVMHIpYgFRB2nLxQrC0FIDiCKDWNqBUqBlai8wvciIpaRTWh3QDqCDIIjKDL0IaBC5SKlysWJArgqh3BMICYFs/wgpGUi+8579dr89e/Z5zp/59j2755fn3d2z5wJQFEVRFEVRoVQSm+AG1UFrtEdT1EcjNEA5SlCMIhxDAQoJ3S4lIwf9cD+6ozXq1vKbYuzHNmxEPo6xwcKtungIS3EajkYpwLPoyqYLp3KwACe1cFcvezATmWzEMOk+rMBV18CrSjHy0IqNGQb1wMa4cV8vZfgzGrNRTVYm8nDFQ+SV5QymIIWNa6ZGaz6y6ZR/I4cNbJrSkOcb8MpyCVPYzCapKz71GXllWY5b2dhm6EGcTwhyBw52oyUbPHgNx6WEIXfg4CDuYKMHq0kevI/rlhP4Ghs+OE1ERcKRO3BwEh3Z+NFC7sDBATQngMRrcoDIHTj4iE/yUXJ5VVlhYsMkWezy+a6urgRbsAP7cRincQGpqI+maI+O6IMuSHYRbwIW0X/mJvZTeAH9ah1CATTCaKxBmWbUi7iTOMxEXoCncIsodgvM1ezo2cFPMebdy89qfyHL0vxSN5FQzHL5ajRxVU8v7NO4cWQRjCnIy/DDOOq6FcvENS0gGjMS+wUMjvvdZ5awrsv4KvEE7/Iz+Lontc4Q1vc8AQXt8rO4x7Oa54hqLOLI2aBdfrenHVyviWqdQUx2uLxS6fhMUO8ugrLD5VXqLfpmfxdh2eHyKi0S1P5b4rLF5ZVqiiJl/Z8SmD0ur9TzgnNoQWi2uLxSt+Gy8ixGEpvZLs9AN3RGqsYRa5Xn8SeCM9XlDfFT7Ll2bDnWYYRwOMZjyjP5kOjMdPkDOHpTjPX4iuDILOWL2znCMxH5IyitMc4+ZAuO3q08nyYEaFpiHxbjYWyDIMm/qDyje4kwPMgdOBihjDBNeU7fJcQwIXewTnBzUJ3Vk8Rozr18mOAtuxT1FFH6KmNMJkhTkH+7lse3G0s7RZyuygjPEGVYEntV6aSIlKOM8CvCDEtirywVyFDE6q2M8WPiDJPLJcMgBiljPEWg4XG5AwfTlfEmKWPkEml4XO7gCBooI85TRvlm8I1ax3CX68w8PYeB2KGFfEWM6Yo3qgy5uKj8VU/lLz5HG2QjHRlIA1CCIhTjBI6ggg43LbGXYYggZj3lgkYVtbwaluITvIlf4gHhNEomdheJXfpeXoX8EVHUAR4sY1CKfEyN5gibMCIHXvJsBYur2IDxSCNy05HXx1mPFy/5L2ZFZb6rGR2uusiByb6sWlOMZ5FOl5vocqAuDvm2XNExjLV5t52wuhyY7vM6Ve+jA11uksuB5glYcLgIY+hyc1yeJBj87E35q6BXkC5PAHJgdgKXI9xlzzt8eF0OjE/wypQH7Li7h9nl4wJYjPQ4utPlwSF/LKD1Z8+gC10eLeQOHHyJ1nR54pGPCniVadmcGyK3xOVVZYvWnNpqb5hBIv+L1hCJAdiuhXyVcpT6dV3GSLylhXyxy7YrxHYU4CBO4yKABmiCNuiIe9DMVbT5mMp7eWJc/rgLl1dgC6bE2NelM6Zim4uoDzOxm5nYS/GicNOuznhJc0X5k2HprIkS8gos1cTSSrgYodFbhkQ5sR/F/a7aqD8Oa9TSny43x+UblDNialcmVovr2WP2qOYoIV8V57tREuaK6/o+E7sJid2bO+00Ya0HTPV6lFy+3LNWmymsMZfIg+1w9fZ5ep6ozp3mjaKjy90rGetF9d5H5Ha4vFLZOB62zYGIPH6NEk2NqEvk4U/s1V/f8gX1DyJye5ADQC/BGfyRyO1I7Nf1rvIcPiZye1xeqaGCua6ZNiMf7sOSAolD3h+v4otrH2RewYPCo1JxWnkmQ4jcROTZNcyGWSMcN7PQ5KUJw4zc33t5G+xHzfu3S7655wqmPRG5ccgPxxjkqN7DvbnyfDYRuVmJvY1iYMQEQYxCxRkVEnlYXF5ZdguibFLEKI/6S9pQg1x+Ow4IYrZSxlmqjJFGl4fF5dLVJBcoYzQl8jDcy3XestV7tbcl8vC43IGD3spo6gEVtxF5mJCXCu7H6u6ZRlFE/nAoE7sDB8sEEd9URqkTfuT2P7FXlSuiZQb2KKKU0OXhcbmDGYKYdZWrTO8l8nDcyx04mCeKqh5IsYaJPRyJ3cEfhHFnePTPQ+ShQQ68r4z1NJEHkdj9Q95KcN7didwmlwOzBC2dTOT2uByoj5PBPcbR5UEgly0tPo3I7XE5kI1zgoVOWhO5PS4HXhHE/IDI7XE5MFIU9QdEbo/LO6NIEPWS98Mn/F04pD+R16oWOCiK+4LXyMf4irwnin1ErrtWzGtGIW+MXcJvdB4v/H87LvqIvL1yWG90XZ6J7UHNpVvoI/KGKPDxS5q/Lm/ry5e06i7/SBi5HHd5izxVI/nqIpcM6aXL1WW+1z7v6SPyJ0I7RMJvl+sgP+H9uLihviFvp5FDmNhrL096/34+2Jf3cgBYw8TuAfI3/OiHu8MXl+tsMM97ee3lKBr7AT1JuVuwG+Sp2EvkcSMvR1+/PqbO9Bw5MIn38rgTu69rP6fFeJd2hzwFn/OJPU6XO5gNX5VTy6iNk66QA4+KLqoCY5nYay0L4bs6YedN1e5EJ5fRdogu60dM7DE+/SZk+lIqxmMzrl5br2wzxrvbCA5Ad9FlraTLay2vJ3YV2DS0Rds4VzuYI7isQ1q9TNG6l79uzsK/8ldAyffhYRoRwz0qJgLIgT6CC/uHMcjpck/0c8Gl9aHLbUIO/FN5aflEbhfyOoJBfrlEbhNyydf5C0jnvdwm5MAY5eWtInK7kAOzlRc4mYndLuTAq8pL7KGMMTzUXTGGdrj6qc2KS7yq7O27E1fYxx4ufaK4yCOK41M0ofg7dYHIRVIh2xr3gyBdbpxUW8+8ozh+PV0ePqkmSK1RJPdLhrj890Qu1ynFxa6PeXRTQ76X871cS6rPqh/GPDrLiJc0ulxTqgVtj8U8OglneS8Pn9RrHjaMefwbvJeHT4vj/JY+iMjDJ/UQip8oIqyNcewyJnYT9T3lpf9NEaEJPqvlyEV0uZnqKpjVkqWIkV3DTuKlmusfE3kClYwzygaYIIiSi03XxuA7OIF5aE7kJuttZRPsQpIoUga64W601l75mF0xCZdkYdvBPtZP5AGom6Ahtvu2brnfiZ3IXfbKye7rdHmo9AtBc5zyYftIujxAtRONcduIFLrcJm3wpdmDdfm/iDy2BgqbZnpoXE7kSiUJOy8qMNWD2nJwlC43QY+Km+i5OF/fHhD0ARJ5grpjt4qbaT1auM4oU1DGxG6Oev2/71xdCpEr7Jqtro5YpwWELk+AXtZqsHz01ojdDHM1PU7kCVEznNDEko8RuEXQ0bsAJZqRiTxhGqQ5FdGBg3NYgsfRpoZoDTEIv8N/tCNGDnlSwPU/hxkujyzCPhzBOZQiBY3QFB3i6Lidp7lhZSbe0VorcyVGoZwer1JdbHHlTC8LE3vC1US8CLg/xf+XtDqEfLPa4BiRR0/dBXsGhzOxE3kMdcGXCUc+h8iDT/IFCQR+BROJ3ARlaw5DcF8uYAiRm6J6yHPRXaNb9mhvUknkPmuocuGC+MoS1Cdy89QSK3wCvg8PaZ8NkSdM/YT7hsvLRcwSfKwh8kBVB08LN/JSlxIscNUzT+QBKBlDsC1O4OeR53LkDZEHqN7Ic9VRW4a3kav92EbkxigF38BcbEO5CMBhLME45Tz3yCJPChn8dPRBF7RHB3RARrVtvC6hGIewHwUowBYcirMW/e/lubhCZybunyALmR7/6zKxR05ETuRETuRETuRsNCKniJwicorIKSKniJwicorIKSKniJyqGfnHmvsyE3nIlRJzHxi63ErlEXnUNI6JPWrKUO7rTJdbp98QedSUjWIm9qjpGSKPnrYysUdNzYRLEBO5RRrLxF6p5AhB7yz4zUqMtn+CUpSgZyt/sZpz0mzTWuXU5sbRaIgoOT1T8fdCnCZ026RC2lJzQ25CD4EKFX9PwWLUI/RoQQe+hbdcrEBFGazRovf0tdFwe1SUJVyx5u90u03aKOx7J3aLNEP8lY1J3ho10hg3Q7dbo59pjJwhdkvUAMeJPXr6jtY2Ary3W6Jfaw2CptutUJLmJgLEboXSsUkLO5O8JQ9079LtxE7sxE7sxE7sFqkhH+mIXV1WhG43DMoD7OPZZNHD/gWnPUUR+4BwX2wyeQMAijEYH4h/fS+hRw97c0K3B/tAvCf6ZRmh26OLGCpy+wE2VfQe6XLYTFHD/h6bKGrYy9CDDWQr9vwakV/FE2wce5WGl29CfgrD2TC2qy+W4/w14Hsxy5aVKvjFSN1CLVAPp1DEpqAoiqIoyiz9D9lYMumhgrvLAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDI1LTExLTI3VDA5OjEyOjQxKzAwOjAwvIZCxQAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyNS0xMS0yN1QwOToxMjo0MSswMDowMM3b+nkAAAAASUVORK5CYII=";function QT({className:e}){return s.jsx("img",{src:XT,alt:"Model Context Protocol","aria-hidden":"true",className:de("inline-block size-8 object-contain invert",e)})}function Ys({...e}){return s.jsx(_C,{"data-slot":"select",...e})}function Xs({...e}){return s.jsx(SC,{"data-slot":"select-value",...e})}function Qs({className:e,size:t="default",children:n,...r}){return s.jsxs(jC,{"data-slot":"select-trigger","data-size":t,className:de("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r,children:[n,s.jsx(CC,{asChild:!0,children:s.jsx(ct,{className:"size-4 opacity-50"})})]})}function eo({className:e,children:t,position:n="popper",align:r="center",...o}){return s.jsx(NC,{children:s.jsxs(TC,{"data-slot":"select-content",className:de("bg-popover text-popover-foreground 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 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,align:r,...o,children:[s.jsx(eE,{}),s.jsx(EC,{className:de("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),s.jsx(tE,{})]})})}function Nt({className:e,children:t,...n}){return s.jsxs(AC,{"data-slot":"select-item",className:de("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...n,children:[s.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:s.jsx(IC,{children:s.jsx(Ge,{className:"size-4"})})}),s.jsx(RC,{children:t})]})}function eE({className:e,...t}){return s.jsx(zC,{"data-slot":"select-scroll-up-button",className:de("flex cursor-default items-center justify-center py-1",e),...t,children:s.jsx(ka,{className:"size-4"})})}function tE({className:e,...t}){return s.jsx(OC,{"data-slot":"select-scroll-down-button",className:de("flex cursor-default items-center justify-center py-1",e),...t,children:s.jsx(ct,{className:"size-4"})})}const nE=Ee(["critical","warning","notice"]),rE=Ee(["open"]),sE=Ee(["proxy","tool-schema","run","group"]),rm=Ee(["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"]),oE=Ee(["log","session","run","group"]),iE=Ee(["anthropic","openai","unknown"]),aE=G({kind:oE,id:N(),label:N(),href:N().nullable()}),lE=G({id:N(),fingerprint:N(),severity:nE,category:rm,source:sE,status:rE,title:N(),message:N(),count:q().int().positive(),firstSeenAt:N(),lastSeenAt:N(),logIds:he(q().int().positive()),sessionIds:he(N()),runIds:he(N()),groupIds:he(N()),provider:N().nullable(),model:N().nullable(),apiFormat:iE.nullable(),evidence:he(aE),metadata:qe(N(),Xe)}),cE=G({category:rm,count:q().int().nonnegative()}),sm=G({total:q().int().nonnegative(),open:q().int().nonnegative(),critical:q().int().nonnegative(),warning:q().int().nonnegative(),notice:q().int().nonnegative(),byCategory:he(cE)}),uE=G({alerts:he(lE),total:q().int().nonnegative(),limit:q().int().positive(),summary:sm}),dE=8e3,fE=1e4;function pE(e){const t=new URLSearchParams;e.severity!==void 0&&t.set("severity",e.severity),e.category!==void 0&&t.set("category",e.category),e.source!==void 0&&t.set("source",e.source),e.limit!==void 0&&t.set("limit",String(e.limit));const n=t.toString();return n.length>0?`/api/alerts?${n}`:"/api/alerts"}function hE(e,t){const n=_n(t?pE(e):null,r=>Vn(r,uE,fE));return{alerts:n.data?.alerts??[],total:n.data?.total??0,summary:n.data?.summary??null,isLoading:n.isLoading,error:n.error,mutate:n.mutate}}function mE(){const e=_n("/api/alerts/summary",t=>Vn(t,sm,dE),{refreshInterval:5e3,revalidateOnFocus:!0});return{summary:e.data??null,isLoading:e.isLoading,error:e.error,mutate:e.mutate}}const gE=["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"];function om(e){switch(e){case"critical":return"Critical";case"warning":return"Warning";case"notice":return"Notice"}}function xE(e){switch(e){case"proxy":return"Proxy";case"tool-schema":return"Tool schema";case"run":return"Run";case"group":return"Group"}}function dl(e){switch(e){case"request-failure":return"Request failure";case"request-timeout":return"Timeout";case"slow-response":return"Slow response";case"tool-schema":return"Tool calling";case"run-failure":return"Run failure";case"group-failure":return"Group failure";case"group-incomplete":return"Group incomplete"}}function bE(e){switch(e){case"critical":return"border-red-400/40 bg-red-500/12 text-red-100";case"warning":return"border-amber-300/35 bg-amber-400/12 text-amber-100";case"notice":return"border-sky-300/35 bg-sky-400/12 text-sky-100"}}function vE(e){switch(e){case"critical":return"bg-red-400";case"warning":return"bg-amber-300";case"notice":return"bg-sky-300"}}function yE(e){switch(e){case"critical":return"text-red-200";case"warning":return"text-amber-100";case"notice":return"text-sky-100"}}function wE(e){switch(e){case"request-failure":case"run-failure":case"group-failure":return s.jsx(h2,{className:"size-3.5"});case"request-timeout":case"slow-response":return s.jsx(sy,{className:"size-3.5"});case"tool-schema":return s.jsx(gn,{className:"size-3.5"});case"group-incomplete":return s.jsx(A1,{className:"size-3.5"})}}function Ji(e){const t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat(void 0,{month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t)):e}function at(e){return e.toLocaleString()}function im(e){return e.provider!==null&&e.model!==null?`${e.provider} / ${e.model}`:e.provider!==null?e.provider:e.model!==null?e.model:"Unknown target"}function kE(e,t){const n={limit:100};return e!=="all"&&(n.severity=e),t!=="all"&&(n.category=t),n}function _E(e,t){if(t!==null){const n=e.find(r=>r.id===t);if(n!==void 0)return n}return e[0]??null}function us({label:e,count:t,tone:n}){const r=n==="critical"?"border-red-400/30 bg-red-500/10 text-red-100":n==="warning"?"border-amber-300/30 bg-amber-400/10 text-amber-100":n==="notice"?"border-sky-300/30 bg-sky-400/10 text-sky-100":"border-border bg-muted/40 text-foreground";return s.jsxs("div",{className:de("rounded-md border px-3 py-2",r),children:[s.jsx("div",{className:"text-[10px] font-semibold uppercase opacity-75",children:e}),s.jsx("div",{className:"mt-1 text-lg font-semibold leading-none",children:at(t)})]})}function ds({value:e,active:t,label:n,count:r,onClick:o}){return s.jsxs(Ne,{type:"button",variant:t?"secondary":"ghost",size:"sm","aria-pressed":t,onClick:()=>o(e),className:"h-7 px-2",children:[n,r!==null?s.jsx(Fe,{variant:"outline",children:at(r)}):null]})}function jE({category:e,active:t,count:n,onClick:r}){return s.jsxs(Ne,{type:"button",variant:t?"secondary":"ghost",size:"sm","aria-pressed":t,onClick:()=>r(e),className:"h-7 px-2",children:[wE(e),dl(e),s.jsx(Fe,{variant:"outline",children:at(n)})]})}function SE({alerts:e,selectedAlertId:t,isLoading:n,error:r,onSelect:o}){return n?s.jsxs("div",{className:"flex min-h-56 items-center justify-center rounded-md border border-dashed border-border text-xs text-muted-foreground",children:[s.jsx(ht,{className:"mr-2 size-3.5 animate-spin"}),"Loading alerts..."]}):r!==void 0?s.jsx("div",{className:"rounded-md border border-red-300/30 bg-red-500/10 px-3 py-2 text-xs text-red-100",children:r.message}):e.length===0?s.jsx("div",{className:"flex min-h-56 items-center justify-center rounded-md border border-dashed border-border px-4 text-center text-xs text-muted-foreground",children:"No alerts match the current filters."}):s.jsx("div",{className:"min-h-0 space-y-2 overflow-y-auto pr-1",children:e.map(i=>{const a=i.id===t;return s.jsxs("button",{type:"button",onClick:()=>o(i.id),className:de("w-full rounded-md border px-3 py-3 text-left transition-colors",a?"border-primary/60 bg-primary/12":"border-border bg-background/70 hover:border-primary/30 hover:bg-muted/60"),children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:de("size-2 rounded-full",vE(i.severity))}),s.jsx("span",{className:de("text-xs font-semibold",yE(i.severity)),children:om(i.severity)}),s.jsx("span",{className:"truncate text-xs text-muted-foreground",children:dl(i.category)})]}),s.jsx("div",{className:"mt-1 truncate text-sm font-semibold",children:i.title}),s.jsx("div",{className:"mt-1 line-clamp-2 text-xs text-muted-foreground",children:i.message})]}),i.count>1?s.jsxs(Fe,{variant:"outline",className:"shrink-0",children:["x",at(i.count)]}):null]}),s.jsxs("div",{className:"mt-2 flex min-w-0 items-center justify-between gap-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"truncate",children:im(i)}),s.jsx("span",{className:"shrink-0",children:Ji(i.lastSeenAt)})]})]},i.id)})})}function CE({alert:e,onNavigate:t}){return e.evidence.length===0?s.jsx("span",{className:"text-xs text-muted-foreground",children:"No linked evidence"}):s.jsx("div",{className:"flex flex-wrap gap-2",children:e.evidence.map(n=>n.href===null?s.jsx(Fe,{variant:"outline",children:n.label},`${n.kind}:${n.id}`):s.jsx(Fe,{variant:"outline",asChild:!0,children:s.jsx("a",{href:n.href,onClick:t,children:n.label})},`${n.kind}:${n.id}`))})}function NE({alert:e,onNavigate:t}){return e===null?s.jsx("div",{className:"flex min-h-56 items-center justify-center rounded-md border border-dashed border-border px-4 text-center text-xs text-muted-foreground",children:"Select an alert to inspect its evidence."}):s.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-border bg-background/70",children:[s.jsx("div",{className:de("border-b px-4 py-3",bE(e.severity)),children:s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(Fe,{variant:"outline",children:om(e.severity)}),s.jsx(Fe,{variant:"outline",children:xE(e.source)}),s.jsx(Fe,{variant:"outline",children:dl(e.category)})]}),s.jsx("h3",{className:"mt-3 text-base font-semibold",children:e.title}),s.jsx("p",{className:"mt-1 text-sm opacity-85",children:e.message})]}),e.count>1?s.jsxs(Fe,{variant:"outline",className:"shrink-0",children:[at(e.count)," hits"]}):null]})}),s.jsxs("div",{className:"space-y-4 p-4",children:[s.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[s.jsx(Gt,{label:"Target",value:im(e)}),s.jsx(Gt,{label:"Last seen",value:Ji(e.lastSeenAt)}),s.jsx(Gt,{label:"First seen",value:Ji(e.firstSeenAt)}),s.jsx(Gt,{label:"Protocol",value:e.apiFormat??"n/a"})]}),s.jsxs("div",{children:[s.jsx("div",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:"Evidence"}),s.jsx(CE,{alert:e,onNavigate:t})]}),s.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[s.jsx(Gt,{label:"Logs",value:e.logIds.length===0?"n/a":at(e.logIds.length)}),s.jsx(Gt,{label:"Sessions",value:e.sessionIds.length===0?"n/a":at(e.sessionIds.length)}),s.jsx(Gt,{label:"Runs",value:e.runIds.length===0?"n/a":at(e.runIds.length)}),s.jsx(Gt,{label:"Groups",value:e.groupIds.length===0?"n/a":at(e.groupIds.length)})]})]})]})}function Gt({label:e,value:t}){return s.jsxs("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2",children:[s.jsx("div",{className:"text-[10px] font-semibold uppercase text-muted-foreground",children:e}),s.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-foreground",children:t})]})}function Bc(){const[e,t]=p.useState(!1),[n,r]=p.useState("all"),[o,i]=p.useState("all"),[a,l]=p.useState(null),{summary:c,isLoading:u}=mE(),d=p.useMemo(()=>kE(n,o),[o,n]),{alerts:f,total:h,isLoading:m,error:v,mutate:g}=hE(d,e),x=p.useMemo(()=>_E(f,a),[f,a]);p.useEffect(()=>{!e||a!==null&&f.some(C=>C.id===a)||l(f[0]?.id??null)},[f,e,a]);const b=c?.total??0,y=c?.critical??0,_=c?.warning??0,j=c?.notice??0,S=y>0?"bg-red-500":_>0?"bg-amber-400":"bg-sky-400";return s.jsxs(zr,{open:e,onOpenChange:t,children:[s.jsx(Ma,{asChild:!0,children:s.jsxs(Ne,{type:"button",variant:"ghost",size:"icon",className:"relative size-8","aria-label":"Alerts",title:"Alerts",children:[s.jsx(yi,{className:"size-4"}),u?s.jsx(ht,{className:"absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground"}):b>0?s.jsx("span",{className:de("absolute -right-1 -top-1 min-w-4 rounded-full px-1 text-[10px] font-semibold leading-4 text-white",S),children:at(b)}):null,s.jsx("span",{className:"sr-only",children:"Alerts"})]})}),s.jsxs(Or,{className:"flex max-h-[86vh] max-w-6xl flex-col overflow-hidden",children:[s.jsxs(Pr,{children:[s.jsxs(Mr,{className:"flex items-center gap-2 pr-8",children:[s.jsx(yi,{className:"size-5 text-red-300"}),s.jsx("span",{children:"Alerts"}),s.jsx(Fe,{variant:"outline",children:at(b)})]}),s.jsx(T_,{className:"sr-only",children:"Local alert board for captured Inspector evidence."})]}),s.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[s.jsx(us,{label:"Open",count:c?.open??0,tone:"neutral"}),s.jsx(us,{label:"Critical",count:y,tone:"critical"}),s.jsx(us,{label:"Warning",count:_,tone:"warning"}),s.jsx(us,{label:"Notice",count:j,tone:"notice"})]}),s.jsxs("div",{className:"flex min-h-0 flex-wrap items-center justify-between gap-2 border-y border-border py-3",children:[s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsx(ds,{value:"all",active:n==="all",label:"All",count:c?.total??null,onClick:r}),s.jsx(ds,{value:"critical",active:n==="critical",label:"Critical",count:y,onClick:r}),s.jsx(ds,{value:"warning",active:n==="warning",label:"Warning",count:_,onClick:r}),s.jsx(ds,{value:"notice",active:n==="notice",label:"Notice",count:j,onClick:r})]}),s.jsxs(Ne,{type:"button",variant:"outline",size:"sm",className:"h-7 shrink-0 px-2",onClick:()=>{g()},children:[s.jsx(zs,{className:"size-3.5"}),"Refresh"]})]}),s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsx(Ne,{type:"button",variant:o==="all"?"secondary":"ghost",size:"sm","aria-pressed":o==="all",onClick:()=>i("all"),className:"h-7 px-2",children:"All categories"}),gE.map(T=>{const C=c?.byCategory.find(A=>A.category===T)?.count??0;return C===0?null:s.jsx(jE,{category:T,active:o===T,count:C,onClick:i},T)})]}),s.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 md:grid-cols-[360px_minmax(0,1fr)]",children:[s.jsxs("div",{className:"flex min-h-0 flex-col",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between text-xs text-muted-foreground",children:[s.jsxs("span",{children:[at(h)," matched"]}),s.jsx("span",{children:f.length<h?`${at(f.length)} shown`:"Latest"})]}),s.jsx(SE,{alerts:f,selectedAlertId:x?.id??null,isLoading:m,error:v,onSelect:l})]}),s.jsx(NE,{alert:x,onNavigate:()=>t(!1)})]})]})]})}const TE=12e3;function EE(e){return e===null||e.evidence===null?null:`/api/groups/${encodeURIComponent(e.id)}/evidence`}function AE(e){const t=_n(EE(e),n=>Vn(n,c1,TE));return{evidenceResponse:t.data??null,isLoading:t.isLoading,error:t.error,mutate:t.mutate}}const RE=8e3;function IE(){const e=_n("/api/groups",t=>Vn(t,Ad,RE));return{groups:e.data?.groups??[],isLoading:e.isLoading,error:e.error,mutate:e.mutate}}function zE(e,t){const n=`/api/groups/${encodeURIComponent(e)}`;return t?`${n}?deleteEvidence=1`:n}function am(e){let t=0,n=0,r=0,o=0;for(const i of e.members)switch(i.status){case"completed":t+=1;break;case"failed":case"cancelled":n+=1;break;case"running":r+=1;break;case"created":break;case null:o+=1;break}return{memberCount:e.members.length,completedMembers:t,failedMembers:n,runningMembers:r,missingStatusMembers:o}}function OE(e,t,n=null){return t!==null&&t.group.id===e.id?t.members.map(r=>({member:r.member,exportMember:r,source:"export"})):n!==null&&n.group.id===e.id&&n.members!==null?n.members.map(r=>({member:r.member,exportMember:r,source:"evidence"})):e.members.map(r=>({member:r,exportMember:null,source:"group"}))}function fl(e){switch(e){case"completed":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"failed":case"cancelled":return"border-red-200 bg-red-50 text-red-700";case"running":return"border-sky-200 bg-sky-50 text-sky-700";case"created":return"border-zinc-200 bg-zinc-50 text-zinc-600";case null:return"border-zinc-200 bg-zinc-50 text-zinc-500"}}function pl(e){return e??"unknown"}function PE(e){switch(e){case"PASS":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"FAIL":return"border-red-200 bg-red-50 text-red-700";case"RUNNING":return"border-sky-200 bg-sky-50 text-sky-700";case"UNKNOWN":return"border-zinc-200 bg-zinc-50 text-zinc-600"}}function zo(e){return e===null||e.trim().length===0?"-":e}function pt(e){return e.toLocaleString()}function Yi(e){return e==null?"-":e<1e3?`${pt(e)} ms`:`${(e/1e3).toFixed(1)} s`}function Xn(e){const t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat(void 0,{month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t)):e}function Uc(e){return e===null?"-":Xn(e)}function ME(e){const t=JSON.stringify(e),n=t===void 0?String(e):t;return n.length<=160?n:`${n.slice(0,157)}...`}function lm(...e){for(const t of e)if(t!==null&&t.trim().length>0)return t;return"-"}function LE(e){const t=e.provider,n=e.model;return t!==null&&t.length>0&&n!==null&&n.length>0?`${t} / ${n}`:lm(t,n)}function DE(e,t){if(t!==null){const n=e.find(r=>r.id===t);if(n!==void 0)return n}return e[0]??null}function $E(e){return(e.exportMember?.session?.latestLogs??[])[0]??null}function FE(e){switch(e){case"export":return"fresh export";case"evidence":return"evidence";case"group":return"group"}}function BE(e,t){return t!==null&&t.group.id===e.id?t.evidence:e.evidence}function UE(e,t,n){return t!==null&&t.group.id===e.id?t.summary:n!==null&&n.group.id===e.id?n.summary:null}function WE(e,t,n){return t!==null&&t.group.id===e.id?t.jenkinsReport:n!==null&&n.group.id===e.id?n.report:null}function Wc(){const[e,t]=p.useState(!1),[n,r]=p.useState(null),[o,i]=p.useState(null),[a,l]=p.useState(null),[c,u]=p.useState(null),[d,f]=p.useState(null),[h,m]=p.useState(!1),[v,g]=p.useState(null),[x,b]=p.useState(null),{groups:y,isLoading:_,error:j,mutate:S}=IE(),T=p.useMemo(()=>DE(y,n),[y,n]);p.useEffect(()=>{!e||n!==null&&y.some(U=>U.id===n)||r(y[0]?.id??null)},[y,e,n]);const C=T!==null&&c!==null&&c.group.id===T.id?c:null,{evidenceResponse:A,isLoading:E,error:P,mutate:J}=AE(T),R=p.useCallback(()=>{S()},[S]),F=p.useCallback(async B=>{i(B.id),l(null);try{const U=await fetch(`/api/groups/${encodeURIComponent(B.id)}/evidence`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({latestLogLimit:10})});if(!U.ok){l(await Ft(U,`Export failed with status ${String(U.status)}`));return}const ie=await wt(U,u1);u(ie),await S(),await J()}catch(U){l(U instanceof Error?U.message:String(U))}finally{i(null)}},[S,J]),k=p.useCallback(B=>{f(B),m(!1),b(null)},[]),M=p.useCallback(()=>{v===null&&(f(null),m(!1),b(null))},[v]),Y=p.useCallback(B=>{r(B),f(null),m(!1),b(null)},[]),D=p.useCallback(async()=>{const B=d;if(B!==null){g(B.id),b(null);try{const U=await fetch(zE(B.id,h),{method:"DELETE"});if(!U.ok){b(await Ft(U,`Delete failed with status ${String(U.status)}`));return}await wt(U,l1),u(ie=>ie!==null&&ie.group.id===B.id?null:ie),r(ie=>ie===B.id?null:ie),f(null),m(!1),await S(),await J()}catch(U){b(U instanceof Error?U.message:String(U))}finally{g(null)}}},[h,d,S,J]);return s.jsxs(zr,{open:e,onOpenChange:t,children:[s.jsx(Ma,{asChild:!0,children:s.jsxs(Ne,{type:"button",variant:"ghost",size:"icon",className:"relative size-8","aria-label":"Evaluation groups",title:"Evaluation groups",children:[s.jsx(Fl,{className:"size-4"}),_?s.jsx(ht,{className:"absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground"}):y.length>0?s.jsx("span",{className:"absolute -right-1 -top-1 min-w-4 rounded-full bg-primary px-1 text-[10px] leading-4 text-primary-foreground",children:y.length}):null,s.jsx("span",{className:"sr-only",children:"Evaluation groups"})]})}),s.jsxs(Or,{className:"flex max-h-[85vh] max-w-5xl flex-col overflow-hidden",children:[s.jsx(Pr,{children:s.jsxs(Mr,{className:"flex items-center gap-2 pr-8",children:[s.jsx(Fl,{className:"size-5 text-muted-foreground"}),s.jsx("span",{children:"Groups"}),s.jsx(Fe,{variant:"outline",children:pt(y.length)})]})}),s.jsxs("div",{className:"flex min-h-0 items-center justify-between gap-3 border-b border-border pb-3",children:[s.jsx("p",{className:"text-xs text-muted-foreground",children:"Evaluation batches, model runs, and exported evidence packs."}),s.jsxs(Ne,{type:"button",variant:"outline",size:"sm",className:"shrink-0",onClick:R,children:[s.jsx(zs,{className:"size-3.5"}),"Refresh"]})]}),s.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 md:grid-cols-[260px_minmax(0,1fr)]",children:[s.jsx(HE,{groups:y,selectedGroupId:T?.id??null,isLoading:_,error:j,onSelect:Y}),s.jsx(ZE,{group:T,deleteTarget:d,deleteEvidence:h,exportResult:C,evidenceResponse:A,evidenceLoading:E,evidenceError:P,exportError:a,deleteError:x,exportingGroupId:o,deletingGroupId:v,onDeleteEvidenceChange:m,onExport:F,onRequestDelete:k,onCancelDelete:M,onConfirmDelete:()=>{D()}})]})]})]})}function HE({groups:e,selectedGroupId:t,isLoading:n,error:r,onSelect:o}){return n?s.jsx("div",{className:"flex min-h-48 items-center justify-center rounded-md border border-dashed border-border text-xs text-muted-foreground",children:"Loading groups..."}):r!==void 0?s.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:r.message}):e.length===0?s.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-8 text-center text-xs text-muted-foreground",children:"No groups yet."}):s.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:s.jsx("div",{className:"space-y-2",children:e.map(i=>{const a=am(i),l=t===i.id;return s.jsxs("button",{type:"button",onClick:()=>o(i.id),className:de("w-full rounded-md border px-3 py-2 text-left text-xs transition-colors",l?"border-primary bg-primary/5":"border-border bg-background hover:bg-muted/50"),children:[s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[s.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:i.title}),s.jsx(Fe,{variant:"outline",className:fl(i.status),children:pl(i.status)})]}),s.jsxs("div",{className:"mt-1 flex items-center gap-2 text-muted-foreground",children:[s.jsxs("span",{children:[a.memberCount," sessions"]}),s.jsx("span",{children:Xn(i.updatedAt)})]})]},i.id)})})})}function ZE({group:e,deleteTarget:t,deleteEvidence:n,exportResult:r,evidenceResponse:o,evidenceLoading:i,evidenceError:a,exportError:l,deleteError:c,exportingGroupId:u,deletingGroupId:d,onDeleteEvidenceChange:f,onExport:h,onRequestDelete:m,onCancelDelete:v,onConfirmDelete:g}){if(e===null)return s.jsx("div",{className:"flex min-h-48 items-center justify-center rounded-md border border-dashed border-border text-xs text-muted-foreground",children:"Select a group to inspect."});const x=am(e),b=UE(e,r,o),y=WE(e,r,o),_=BE(e,r),j=OE(e,r,o),S=u===e.id,T=d===e.id,C=t?.id===e.id;return s.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex min-w-0 flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.jsx("h3",{className:"min-w-0 truncate text-base font-semibold",children:e.title}),s.jsx(Fe,{variant:"outline",className:fl(e.status),children:pl(e.status)}),s.jsx(Fe,{variant:"outline",children:e.kind})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[s.jsx("span",{children:zo(e.project)}),s.jsxs("span",{children:["updated ",Xn(e.updatedAt)]})]})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsx(Ne,{type:"button",variant:"outline",size:"icon",className:"size-8 text-red-600 hover:text-red-700","aria-label":"Delete group",title:"Delete group",disabled:T,onClick:()=>m(e),children:T?s.jsx(ht,{className:"size-3.5 animate-spin"}):s.jsx(qn,{className:"size-3.5"})}),s.jsxs(Ne,{type:"button",variant:"default",size:"sm",className:"shrink-0",disabled:S||T,onClick:()=>{h(e)},children:[S?s.jsx(ht,{className:"size-3.5 animate-spin"}):s.jsx(co,{className:"size-3.5"}),"Export evidence"]})]})]}),e.task!==null&&e.task.trim().length>0&&s.jsx("p",{className:"rounded-md border border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:e.task}),C&&s.jsx(VE,{group:e,deleteEvidence:n,isDeleting:T,error:c,onDeleteEvidenceChange:f,onCancel:v,onConfirm:g}),s.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[s.jsx(Kt,{label:"Members",value:x.memberCount}),s.jsx(Kt,{label:"Done",value:x.completedMembers}),s.jsx(Kt,{label:"Failed",value:x.failedMembers}),s.jsx(Kt,{label:"Running",value:x.runningMembers})]}),b!==null&&s.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[s.jsx(Kt,{label:"Requests",value:b.requestCount}),s.jsx(Kt,{label:"Errors",value:b.errorCount}),s.jsx(Kt,{label:"Tokens",value:b.tokenUsage.total}),s.jsx(Kt,{label:"Missing",value:b.missingSessions})]}),s.jsx(qE,{report:y,loading:i,error:a,hasEvidence:_!==null}),s.jsx(GE,{evidence:_}),l!==null&&s.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:l}),c!==null&&!C&&s.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:c}),s.jsx(KE,{rows:j})]})})}function VE({group:e,deleteEvidence:t,isDeleting:n,error:r,onDeleteEvidenceChange:o,onCancel:i,onConfirm:a}){const l=e.evidence!==null,c=e.evidence?.markdownPath??"No evidence pack exported.";return s.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-3 text-red-900",children:s.jsxs("div",{className:"flex min-w-0 flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[s.jsxs("div",{className:"min-w-0 space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[s.jsx(qn,{className:"size-4 text-red-600"}),s.jsx("span",{children:"Delete group?"})]}),s.jsxs("p",{className:"text-xs text-red-800",children:["Delete ",s.jsx("span",{className:"font-medium",children:e.title}),". Session logs and run records stay intact."]}),s.jsxs("label",{className:de("flex min-w-0 items-start gap-2 text-xs",l?"cursor-pointer":"opacity-60"),children:[s.jsx("input",{type:"checkbox",className:"mt-0.5 size-4 shrink-0",checked:t,disabled:!l||n,onChange:u=>o(u.currentTarget.checked)}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block font-medium",children:"Also delete exported evidence files"}),s.jsx("code",{className:"mt-1 block truncate font-mono text-[11px] text-red-700",children:c})]})]}),r!==null&&s.jsx("div",{className:"rounded-md border border-red-200 bg-white px-2 py-1.5 text-xs text-red-700",children:r})]}),s.jsxs("div",{className:"flex shrink-0 justify-end gap-2",children:[s.jsx(Ne,{type:"button",variant:"outline",size:"sm",disabled:n,onClick:i,children:"Cancel"}),s.jsxs(Ne,{type:"button",variant:"destructive",size:"sm",disabled:n,onClick:a,children:[n?s.jsx(ht,{className:"size-3.5 animate-spin"}):s.jsx(qn,{className:"size-3.5"}),"Delete"]})]})]})})}function Kt({label:e,value:t}){return s.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[s.jsx("div",{className:"text-[11px] font-medium uppercase text-muted-foreground",children:e}),s.jsx("div",{className:"mt-1 font-mono text-sm font-semibold",children:pt(t)})]})}function qE({report:e,loading:t,error:n,hasEvidence:r}){const{copied:o,copy:i}=$t(e?.markdown??null);return e===null&&!t&&n===void 0?null:t?s.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:[s.jsx(ht,{className:"size-3.5 animate-spin"}),"Loading evidence report..."]}):n!==void 0&&r?s.jsxs("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:["Failed to load evidence report: ",n.message]}):e===null?null:s.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:"text-xs font-semibold",children:"Evidence report"}),s.jsx(Fe,{variant:"outline",className:PE(e.status),children:e.status})]}),s.jsx(Ne,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0","aria-label":o?"Copied evidence report":"Copy evidence report",onClick:i,children:o?s.jsx(Ge,{className:"size-3.5 text-emerald-500"}):s.jsx(St,{className:"size-3.5"})})]}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:e.summary})]})}function GE({evidence:e}){return e===null?s.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-2 text-xs text-muted-foreground",children:"No evidence pack exported yet."}):s.jsxs("div",{className:"space-y-2 rounded-md border border-border bg-muted/20 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-xs font-semibold",children:"Evidence paths"}),s.jsx("span",{className:"text-[11px] text-muted-foreground",children:Xn(e.exportedAt)})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(si,{label:"JSON",value:e.jsonPath}),s.jsx(si,{label:"Markdown",value:e.markdownPath}),s.jsx(si,{label:"HTML",value:e.htmlPath})]})]})}function si({label:e,value:t}){const{copied:n,copy:r}=$t(t);return s.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md border border-border bg-background px-2 py-1.5",children:[s.jsx("span",{className:"w-16 shrink-0 text-[11px] font-medium text-muted-foreground",children:e}),s.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:t}),s.jsx(Ne,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0","aria-label":n?`Copied ${e} path`:`Copy ${e} path`,onClick:r,children:n?s.jsx(Ge,{className:"size-3.5 text-emerald-500"}):s.jsx(St,{className:"size-3.5"})})]})}function KE({rows:e}){const[t,n]=p.useState(null),r=p.useCallback(o=>{n(i=>i===o?null:o)},[]);return e.length===0?s.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-8 text-center text-xs text-muted-foreground",children:"No sessions attached."}):s.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[s.jsx("div",{className:"border-b border-border bg-muted/30 px-3 py-2 text-xs font-semibold",children:"Members"}),s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[760px] text-left text-xs",children:[s.jsx("thead",{className:"border-b border-border bg-muted/20 text-muted-foreground",children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-3 py-2 font-medium",children:"Session"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"Provider / Model"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"Status"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"Requests"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"Errors"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"First chunk"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"Tokens"})]})}),s.jsx("tbody",{children:e.map(o=>{const i=t===o.member.id;return s.jsxs(p.Fragment,{children:[s.jsx(JE,{row:o,isExpanded:i,onToggleDetails:r}),s.jsx(YE,{row:o,isExpanded:i})]},o.member.id)})})]})})]})}function JE({row:e,isExpanded:t,onToggleDetails:n}){const r=e.member,o=e.exportMember?.session??null,i=$E(e),a=o?.inspectorPath??Au(r.sessionId),l=e.source!=="evidence",c=o?.requestCount??null,u=o?.errorCount??null,d=o?.tokenUsage.total??null,f=i?.firstChunkMs??null,h=lm(r.label,r.sessionId);return s.jsxs("tr",{className:"border-b border-border last:border-0 hover:bg-muted/20",children:[s.jsxs("td",{className:"max-w-56 px-3 py-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(Ne,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground","aria-label":t?`Hide member ${h}`:`Show member ${h}`,title:t?"Hide member details":"Show member details",onClick:()=>{n(r.id)},children:t?s.jsx(ct,{className:"size-3.5"}):s.jsx(Ot,{className:"size-3.5"})}),l?s.jsxs("a",{href:a,target:"_blank",rel:"noreferrer",className:"inline-flex max-w-full min-w-0 items-center gap-2 rounded-sm font-mono text-xs text-primary outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","aria-label":`Open session ${h}`,title:`Open session ${h}`,children:[s.jsx("span",{className:"min-w-0 truncate",children:h}),s.jsx(_a,{className:"size-3 shrink-0 text-muted-foreground"})]}):s.jsxs("button",{type:"button",className:"inline-flex max-w-full min-w-0 items-center gap-2 rounded-sm font-mono text-xs text-foreground outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",title:`Show evidence snapshot for ${h}`,"aria-label":`Show evidence snapshot for ${h}`,onClick:()=>{n(r.id)},children:[s.jsx("span",{className:"min-w-0 truncate",children:h}),s.jsx(Fe,{variant:"outline",className:"shrink-0 border-zinc-200 bg-zinc-50 text-zinc-600",children:"evidence"})]})]}),s.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:zo(r.agent)})]}),s.jsx("td",{className:"max-w-52 px-3 py-2",children:s.jsx("span",{className:"block truncate",children:LE(r)})}),s.jsx("td",{className:"px-3 py-2",children:s.jsx(Fe,{variant:"outline",className:fl(r.status),children:pl(r.status)})}),s.jsx("td",{className:"px-3 py-2 font-mono",children:c===null?"-":pt(c)}),s.jsx("td",{className:"px-3 py-2 font-mono",children:u===null?"-":pt(u)}),s.jsx("td",{className:"px-3 py-2 font-mono",children:Yi(f)}),s.jsx("td",{className:"px-3 py-2 font-mono",children:d===null?"-":pt(d)})]})}function YE({row:e,isExpanded:t}){if(!t)return null;const n=e.member,r=e.exportMember,o=r?.session??null,i=r?.run??null,a=Object.entries(n.metadata);return s.jsx("tr",{className:"border-b border-border bg-muted/10",children:s.jsx("td",{colSpan:7,className:"px-3 pb-4 pt-2",children:s.jsxs("div",{className:"space-y-3 rounded-md border border-border bg-background p-3",children:[s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[s.jsx(Qe,{label:"Source",value:FE(e.source)}),s.jsx(Qe,{label:"Member ID",value:n.id,mono:!0}),s.jsx(Qe,{label:"Session ID",value:n.sessionId,mono:!0}),s.jsx(Qe,{label:"Run ID",value:i?.id??n.runId??"-",mono:!0}),s.jsx(Qe,{label:"Created",value:Xn(n.addedAt)}),s.jsx(Qe,{label:"Updated",value:Xn(n.updatedAt)}),s.jsx(Qe,{label:"Session created",value:Uc(o?.createdAt??null)}),s.jsx(Qe,{label:"Session updated",value:Uc(o?.updatedAt??null)})]}),o===null?s.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-2 text-xs text-muted-foreground",children:"No session snapshot is available for this member."}):s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[s.jsx(Qe,{label:"Log coverage",value:o.logCoverage}),s.jsx(Qe,{label:"Runtime",value:zo(o.runtimeMode)}),s.jsx(Qe,{label:"Requests",value:pt(o.requestCount),mono:!0}),s.jsx(Qe,{label:"Errors",value:pt(o.errorCount),mono:!0}),s.jsx(Qe,{label:"Input tokens",value:pt(o.tokenUsage.input),mono:!0}),s.jsx(Qe,{label:"Output tokens",value:pt(o.tokenUsage.output),mono:!0}),s.jsx(Qe,{label:"Cache read",value:pt(o.tokenUsage.cacheRead),mono:!0}),s.jsx(Qe,{label:"Total tokens",value:pt(o.tokenUsage.total),mono:!0})]}),s.jsx(XE,{logs:o?.latestLogs??[]}),s.jsx(QE,{entries:a})]})})})}function Qe({label:e,value:t,mono:n=!1}){return s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:e}),s.jsx("div",{className:de("truncate text-xs text-foreground",n?"font-mono":""),title:t,children:t})]})}function XE({logs:e}){const t=e.slice(0,5);return t.length===0?s.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-2 text-xs text-muted-foreground",children:"No latest logs in this snapshot."}):s.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[s.jsx("div",{className:"border-b border-border bg-muted/30 px-3 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Latest logs"}),s.jsx("div",{className:"divide-y divide-border",children:t.map(n=>{const r=n.sessionLogNumber??n.id;return s.jsxs("div",{className:"grid gap-2 px-3 py-2 text-xs sm:grid-cols-[72px_1fr_88px_88px]",children:[s.jsxs("span",{className:"font-mono text-muted-foreground",title:`Log ID ${String(n.id)}`,children:["#",r]}),s.jsxs("span",{className:"min-w-0 truncate",children:[zo(n.model)," · ",n.apiFormat," · ",n.path]}),s.jsx("span",{className:"font-mono text-muted-foreground",children:Yi(n.firstChunkMs)}),s.jsx("span",{className:"font-mono text-muted-foreground",children:Yi(n.latencyMs)})]},n.id)})})]})}function QE({entries:e}){return e.length===0?null:s.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[s.jsx("div",{className:"border-b border-border bg-muted/30 px-3 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Metadata"}),s.jsx("div",{className:"grid gap-x-3 gap-y-2 p-3 text-xs sm:grid-cols-2",children:e.map(([t,n])=>{const r=ME(n);return s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"mr-2 text-muted-foreground",children:t}),s.jsx("span",{className:"font-mono text-foreground",title:r,children:r})]},t)})})]})}function e4(){return s.jsxs("svg",{fill:"currentColor",fillRule:"evenodd",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"size-6 shrink-0",children:[s.jsx("title",{children:"Claude Code"}),s.jsx("path",{clipRule:"evenodd",d:"M20.998 10.949H24v3.102h-3v3.028h-1.487V20H18v-2.921h-1.487V20H15v-2.921H9V20H7.488v-2.921H6V20H4.487v-2.921H3V14.05H0V10.95h3V5h17.998v5.949zM6 10.949h1.488V8.102H6v2.847zm10.51 0H18V8.102h-1.49v2.847z"})]})}function t4(){return s.jsxs("svg",{fill:"currentColor",fillRule:"evenodd",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"size-6 shrink-0",children:[s.jsx("title",{children:"OpenCode"}),s.jsx("path",{d:"M16 6H8v12h8V6zm4 16H4V2h16v20z"})]})}function n4(){return s.jsxs("svg",{fill:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"size-6 shrink-0",children:[s.jsx("title",{children:"MiMo Code"}),s.jsx("text",{x:"12",y:"18",textAnchor:"middle",fontSize:"16",fontWeight:"800",fontFamily:"system-ui, sans-serif",children:"M"})]})}const r4=G({name:N(),apiKey:N(),format:Ee(["anthropic","openai"]),anthropicBaseUrl:N(),openaiBaseUrl:N(),openaiResponsesBaseUrl:N().optional().default(""),models:he(N()),sourceTool:Ee(["claude-code","opencode","mimo-code"]),alreadyExists:$e()}),s4=G({providers:he(r4),warnings:he(N()).optional()}),o4=G({success:$e().optional(),imported:q().optional(),message:N().optional(),errors:he(N()).optional()}),i4={"claude-code":e4,opencode:t4,"mimo-code":n4};function a4({open:e,onOpenChange:t,onImportComplete:n}){const[r,o]=p.useState(!1),[i,a]=p.useState(null),[l,c]=p.useState([]),[u,d]=p.useState([]),[f,h]=p.useState(new Set),[m,v]=p.useState(!1),[g,x]=p.useState(null),[b,y]=p.useState(null),_=p.useCallback(()=>{o(!0),a(null),d([]),c([]),h(new Set),x(null),y(null),fetch("/api/providers/scan").then(C=>C.ok?C.json().then(A=>{const E=s4.safeParse(A);if(!E.success){a(`Invalid response: ${E.error.message}`);return}c(E.data.providers),d(E.data.warnings??[]);const P=new Set;E.data.providers.forEach((J,R)=>{J.alreadyExists||P.add(R)}),h(P)}):C.text().then(A=>{a(`Scan failed (${C.status}): ${A}`)})).catch(C=>{a(C instanceof Error?C.message:String(C))}).finally(()=>{o(!1)})},[]);p.useEffect(()=>{e&&_()},[e,_]);const j=p.useCallback(C=>{h(A=>{const E=new Set(A);return E.has(C)?E.delete(C):E.add(C),E})},[]),S=p.useCallback(()=>{const C=l.filter((P,J)=>f.has(J));if(C.length===0)return;v(!0),y(null),x(null);const A=new Date().toISOString(),E=C.map(P=>({id:window.crypto.randomUUID(),name:P.name,apiKey:P.apiKey,format:P.format,anthropicBaseUrl:P.anthropicBaseUrl,openaiBaseUrl:P.openaiBaseUrl,openaiResponsesBaseUrl:P.openaiResponsesBaseUrl,models:P.models,createdAt:A,updatedAt:A}));fetch("/api/providers/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providers:E})}).then(P=>P.json()).then(P=>{const J=o4.safeParse(P);if(!J.success){y(`Invalid response: ${J.error.message}`);return}const R=J.data;c(F=>F.map((k,M)=>f.has(M)?{...k,alreadyExists:!0}:k)),h(new Set),R.errors!==void 0&&R.errors.length>0&&R.message!==void 0?x(R.message):x(`Imported ${R.imported??C.length} provider(s)`),n()}).catch(P=>{y(P instanceof Error?P.message:String(P))}).finally(()=>{v(!1)})},[l,f,n]),T=l.some(C=>!C.alreadyExists);return s.jsx(zr,{open:e,onOpenChange:t,children:s.jsxs(Or,{className:"max-w-xl max-h-[80vh] overflow-hidden flex flex-col",children:[s.jsxs(Pr,{children:[s.jsx(Mr,{children:"Import from External Tools"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Detect provider configurations from Claude Code, OpenCode, and MiMo Code."})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto space-y-3",children:[r&&s.jsxs("div",{className:"flex items-center justify-center py-8 gap-2 text-muted-foreground",children:[s.jsx(ht,{className:"size-4 animate-spin"}),s.jsx("span",{className:"text-sm",children:"Scanning for external providers..."})]}),i!==null&&s.jsxs("div",{className:"flex items-center gap-2 text-destructive text-sm py-4",children:[s.jsx(_r,{className:"size-4"}),i]}),!r&&i===null&&l.length===0&&s.jsxs("p",{className:"text-sm text-muted-foreground py-8 text-center",children:["No external provider configurations found.",s.jsx("br",{}),s.jsx("span",{className:"text-xs",children:"Supported tools: Claude Code (~/.claude/settings.json), OpenCode (~/.config/opencode/opencode.json), MiMo Code (~/.config/mimocode/mimocode.jsonc)"})]}),!r&&l.map((C,A)=>s.jsxs("label",{className:`flex items-start gap-3 p-3 border rounded-md ${C.alreadyExists?"":"cursor-pointer hover:bg-muted/50"}`,children:[!C.alreadyExists&&s.jsx("input",{type:"checkbox",checked:f.has(A),disabled:m,onChange:()=>j(A),className:"mt-0.5 size-4"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[(()=>{const E=i4[C.sourceTool];return E===void 0?null:s.jsx(E,{})})(),C.alreadyExists&&s.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Already added"})]}),s.jsxs("div",{className:"text-xs text-muted-foreground mt-1 truncate",children:[C.models.slice(0,4).join(", "),C.models.length>4?` +${C.models.length-4} more`:""]}),s.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:C.format==="anthropic"?C.anthropicBaseUrl:C.openaiResponsesBaseUrl!==""?C.openaiResponsesBaseUrl:C.openaiBaseUrl}),s.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 font-mono",children:C.apiKey.length>8?`${C.apiKey.slice(0,4)}••••${C.apiKey.slice(-4)}`:"••••"})]})]},`${C.sourceTool}-${C.name}`)),u.length>0&&s.jsx("div",{className:"text-xs text-muted-foreground space-y-1 border-t pt-2",children:u.map((C,A)=>s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(_r,{className:"size-3"}),C]},A))}),g!==null&&s.jsx("div",{className:"text-sm text-green-500 border-t pt-2",children:g}),b!==null&&s.jsx("div",{className:"text-sm text-destructive border-t pt-2",children:b})]}),s.jsxs("div",{className:"flex items-center justify-between pt-3 border-t",children:[s.jsxs(Ne,{variant:"outline",size:"sm",onClick:_,disabled:r,children:[s.jsx(ht,{className:`size-3 mr-1 ${r?"animate-spin":""}`}),"Rescan"]}),s.jsxs(Ne,{size:"sm",onClick:S,disabled:!T||f.size===0||m,children:[s.jsx(co,{className:"size-3 mr-1"}),m?"Importing...":`Import Selected (${f.size})`]})]})]})})}function cm(e){return e.length<=8?"••••••••":e.slice(0,4)+"••••••••"+e.slice(-4)}const um=G({id:N().min(1),aliases:he(N()).optional().default([]),contextWindow:q().int().positive().optional(),outputLimit:q().int().positive().optional(),sourceUrl:N().optional()}),l4=G({name:N().min(1).optional(),aliases:he(N()).optional().default([]),baseUrls:he(N()).optional().default([]),models:he(um).min(1)});G({version:q().int().positive().optional(),updatedAt:N().optional(),providers:he(l4).optional().default([]),models:he(um).optional().default([])});function Hc(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function c4(e){const t=e.models.filter(n=>n.trim()!=="");return t.length>0?t:e.model!==void 0&&e.model.trim()!==""?[e.model]:[]}function hl(e,t){const n=Hc(t);return(e.modelMetadata??[]).find(o=>Hc(o.model)===n)??null}function u4(e){const t=c4(e);return t.length===0?!1:t.every(n=>{const r=hl(e,n);return r!==null&&r.contextWindow!==void 0})}function d4(e,t){if(e===null)return null;for(const n of t){const r=hl(n,e);if(r!==null&&r.contextWindow!==void 0)return{providerName:n.name,model:r.model,tokens:r.contextWindow,sourceUrl:r.sourceUrl}}return null}const f4={deepseek:"https://api-docs.deepseek.com/zh-cn/"};function p4(e){return Object.prototype.hasOwnProperty.call(e,"success")}function h4(e){return Object.prototype.hasOwnProperty.call(e,"notConfigured")}function ot(e){return e!==void 0&&e.trim()!==""}function Xi(e){if(e===void 0)return;const t=Object.entries(e).map(([n,r])=>`${n}: ${r}`);if(t.length!==0)return t.join(`
|
|
104
|
+
`)}function Zc(e){return Xi(e)!==void 0}function Vc(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function m4(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function g4(e){const t=e.debug;return ot(e.error?.hint)||ot(e.error?.details)||ot(e.rawResponse)||ot(t?.requestUrl)||ot(t?.requestBody)||ot(t?.responseBody)||Zc(t?.requestHeaders)||Zc(t?.responseHeaders)||t?.responseStatus!==void 0}function Jt({title:e,children:t}){return s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"font-medium text-foreground/80",children:e}),t]})}function dr({value:e}){return s.jsx("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap break-all rounded-md bg-background/80 p-2 font-mono text-[11px] leading-relaxed text-foreground/80",children:e})}function x4({result:e}){const t=e.debug,n=t?.requestUrl,r=t?.requestMethod??"POST",o=Xi(t?.requestHeaders),i=Xi(t?.responseHeaders),a=t?.responseStatus!==void 0?`${t.responseStatus}${ot(t.responseStatusText)?` ${t.responseStatusText}`:""}`:void 0,l=t?.responseBody??e.rawResponse;return s.jsxs("div",{className:"max-h-80 max-w-full space-y-2 overflow-auto rounded-md border bg-muted/50 p-2 text-xs text-muted-foreground shadow-sm sm:w-[520px]",children:[ot(e.error?.hint)&&s.jsx(Jt,{title:"Hint",children:s.jsx("div",{children:e.error.hint})}),ot(e.error?.details)&&s.jsx(Jt,{title:"Error",children:s.jsx(dr,{value:e.error.details})}),ot(n)&&s.jsx(Jt,{title:"Request",children:s.jsxs("div",{className:"rounded-md bg-background/80 p-2 font-mono text-[11px] break-all text-foreground/80",children:[r," ",n]})}),o!==void 0&&s.jsx(Jt,{title:"Request Headers",children:s.jsx(dr,{value:o})}),ot(t?.requestBody)&&s.jsx(Jt,{title:"Request Body",children:s.jsx(dr,{value:t.requestBody})}),ot(a)&&s.jsx(Jt,{title:"Response Status",children:s.jsx("div",{className:"rounded-md bg-background/80 p-2 font-mono text-[11px] text-foreground/80",children:a})}),i!==void 0&&s.jsx(Jt,{title:"Response Headers",children:s.jsx(dr,{value:i})}),ot(l)&&s.jsx(Jt,{title:"Response Body",children:s.jsx(dr,{value:l})})]})}function fs({results:e}){return s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Non-stream"}),s.jsx(qc,{result:e.nonStreaming})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Stream"}),s.jsx(qc,{result:e.streaming})]})]})}function b4(e){const t={className:"size-3",strokeWidth:2};switch(e){case"timeout":return s.jsx(Bt,{...t});case"network_unreachable":return s.jsx(k2,{...t});case"connection_refused":return s.jsx(j2,{...t});case"auth_failed":return s.jsx(Fy,{...t});case"rate_limited":return s.jsx(Ca,{...t});case"server_error":return s.jsx(u2,{...t});case"invalid_response":return s.jsx(Q1,{...t});case"unknown":return s.jsx(_r,{...t});default:return s.jsx(_r,{...t})}}function qc({result:e}){const[t,n]=p.useState(!1);if(!p4(e))return h4(e)?s.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground shrink-0",children:[s.jsx(Wy,{className:"size-3"}),s.jsx("span",{children:"Not configured"})]}):s.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground shrink-0",children:[s.jsx(vi,{className:"size-3 animate-spin"}),s.jsx("span",{children:"Testing..."})]});if(e.success){const l=[],c=[];e.inputTokens!==void 0&&l.push(s.jsxs("span",{children:[e.inputTokens," in"]},"in")),e.outputTokens!==void 0&&l.push(s.jsxs("span",{children:[e.outputTokens," out"]},"out")),e.cacheCreationInputTokens!==void 0&&e.cacheCreationInputTokens>0&&l.push(s.jsxs("span",{className:"font-mono tabular-nums text-emerald-400",children:["KV Cache +",e.cacheCreationInputTokens]},"cache-create")),e.cacheReadInputTokens!==void 0&&e.cacheReadInputTokens>0&&l.push(s.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["KV Cache ~",e.cacheReadInputTokens]},"cache-read")),e.firstChunkMs!==void 0&&e.firstChunkMs!==null&&c.push(s.jsxs("span",{children:["first ",Vc(e.firstChunkMs)]},"first")),e.totalStreamMs!==void 0&&e.totalStreamMs!==null&&c.push(s.jsxs("span",{children:["total ",Vc(e.totalStreamMs)]},"total")),e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0&&c.push(s.jsxs("span",{children:[m4(e.tokensPerSecond)," tok/s"]},"rate"));const u=[];for(let f=0;f<l.length;f++)f>0&&u.push(", "),u.push(l[f]);const d=[];for(let f=0;f<c.length;f++)f>0&&d.push(", "),d.push(c[f]);return s.jsx(Je,{children:s.jsxs(Me,{children:[s.jsx(Le,{asChild:!0,children:s.jsxs("div",{className:"flex items-center gap-1 text-xs text-green-600 shrink-0",children:[s.jsx(J1,{className:"size-3"}),s.jsx("span",{children:"Connected"}),l.length>0&&s.jsxs("span",{className:"text-muted-foreground",children:["(",u,")"]}),c.length>0&&s.jsxs("span",{className:"hidden text-muted-foreground lg:inline",children:["(",d,")"]})]})}),s.jsx(De,{children:"Connection test passed"})]})})}const r=e.error,o=r?.message??"Connection failed",i=r?.type??"unknown",a=g4(e);return s.jsxs("div",{className:"flex flex-col gap-1 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-1 text-xs text-red-600 max-w-[200px]",children:[b4(i),s.jsx(Je,{children:s.jsxs(Me,{children:[s.jsx(Le,{asChild:!0,children:s.jsx("span",{className:"truncate",children:o})}),s.jsx(De,{children:"Connection test failed"})]})}),a&&s.jsxs("button",{type:"button",onClick:()=>n(l=>!l),"aria-expanded":t,"aria-label":t?"Hide provider test diagnostics":"Show provider test diagnostics",className:"inline-flex h-5 shrink-0 items-center gap-1 rounded border border-border/70 bg-background/70 px-1.5 text-[10px] text-muted-foreground transition-colors hover:text-foreground",children:[t?s.jsx(ja,{className:"size-3"}):s.jsx(Sa,{className:"size-3"}),s.jsx("span",{children:t?"Hide":"Details"})]})]}),t&&a&&s.jsx(x4,{result:e})]})}function v4(e){const t=Date.now(),n=new Date(e).getTime(),r=t-n,o=Math.floor(r/1e3);if(o<60)return"just now";const i=Math.floor(o/60);if(i<60)return`${i}m ago`;const a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function y4(e){if(e===void 0||e.trim()==="")return null;try{const t=new URL(e);if(t.protocol!=="https:"&&t.protocol!=="http:")return null;const n=t.hostname.toLowerCase(),r=n==="huggingface.co"||n.endsWith(".huggingface.co");return{label:r?"HF":"Source",title:r?"Open Hugging Face model source":"Open model metadata source",url:e}}catch{return null}}function w4({provider:e,testResults:t,isTesting:n,testingTimeLeft:r,isHighlighted:o,onEdit:i,onDelete:a,onTest:l,onRefreshMetadata:c,isRefreshingMetadata:u=!1}){const[d,f]=p.useState(!1),[h,m]=p.useState(!1),[v,g]=p.useState(!1);function x(){Ht(e.apiKey).then(S=>{S&&(m(!0),setTimeout(()=>m(!1),2e3))})}const b=e.apiDocsUrl??Object.entries(f4).find(([S])=>e.name.toLowerCase().includes(S))?.[1],y=u4(e),_=e.modelMetadataUrl!==void 0&&e.modelMetadataUrl.trim()!=="",j=_?"Refresh":"Import defaults";return s.jsxs("div",{className:`border rounded-lg p-4 flex flex-col gap-3 bg-card transition-all duration-500 ${o===!0?"ring-2 ring-primary shadow-md":""}`,children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"font-medium truncate",children:e.name}),e.source==="company"&&s.jsx(Je,{children:s.jsxs(Me,{children:[s.jsx(Le,{asChild:!0,children:s.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400 shrink-0",children:"公司"})}),s.jsx(De,{children:"Company-provided API key"})]})}),e.source==="personal"&&s.jsx(Je,{children:s.jsxs(Me,{children:[s.jsx(Le,{asChild:!0,children:s.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400 shrink-0",children:"个人"})}),s.jsx(De,{children:"Your personal API key"})]})})]}),b!==void 0&&s.jsxs("a",{href:b,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1 text-xs",title:"View API documentation",children:[s.jsx(_a,{className:"size-3"}),s.jsx("span",{className:"sr-only",children:"Docs"})]})]}),e.models!==void 0&&e.models.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1",children:e.models.map(S=>{const T=hl(e,S),C=y4(T?.sourceUrl);return s.jsxs("span",{className:"inline-flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:[s.jsx("span",{children:S}),T!==null&&T.contextWindow!==void 0&&s.jsx("span",{className:"font-mono text-foreground/80",children:ef(T.contextWindow)}),C!==null&&s.jsx(Je,{children:s.jsxs(Me,{children:[s.jsx(Le,{asChild:!0,children:s.jsx("a",{href:C.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-0.5 rounded border border-border/70 bg-background/70 px-1 font-mono text-[10px] leading-4 text-muted-foreground transition-colors hover:text-foreground","aria-label":C.title,children:C.label})}),s.jsx(De,{children:C.title})]})})]},S)})}),!y&&s.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-amber-500/25 bg-amber-500/6 px-2 py-1.5 text-xs text-muted-foreground",children:[s.jsx("span",{children:"Context window metadata missing"}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.jsxs(Ne,{type:"button",variant:"outline",size:"sm",onClick:()=>c?.(e.id),className:"h-6 gap-1 px-2 text-xs",disabled:u,children:[s.jsx(vi,{className:`size-3 ${u?"animate-spin":""}`}),j]}),!_&&s.jsx(Ne,{type:"button",variant:"ghost",size:"sm",onClick:()=>i(e),className:"h-6 px-2 text-xs",children:"Set URL"})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"text-xs text-muted-foreground bg-muted px-2 py-1 rounded flex-1 truncate",children:d?e.apiKey:cm(e.apiKey)}),s.jsx("button",{type:"button",onClick:()=>f(S=>!S),className:"text-muted-foreground hover:text-foreground transition-colors p-1","aria-label":d?"Hide API key":"Show API key",children:d?s.jsx(ja,{className:"size-4"}):s.jsx(Sa,{className:"size-4"})}),s.jsx("button",{type:"button",onClick:x,className:"text-muted-foreground hover:text-foreground transition-colors p-1","aria-label":"Copy API key",children:h?s.jsx(Ge,{className:"size-4 text-green-500"}):s.jsx(St,{className:"size-4"})})]}),e.anthropicBaseUrl!==void 0&&e.anthropicBaseUrl!==""&&s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[s.jsxs("div",{className:"min-w-0 text-xs text-muted-foreground",children:[s.jsx("span",{className:"font-medium",children:"Anthropic:"})," ",s.jsx("span",{className:"truncate",children:e.anthropicBaseUrl})]}),t!==void 0&&s.jsx(fs,{results:t.anthropic})]}),e.openaiBaseUrl!==void 0&&e.openaiBaseUrl!==""&&s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[s.jsxs("div",{className:"min-w-0 text-xs text-muted-foreground",children:[s.jsx("span",{className:"font-medium",children:"OpenAI Chat:"})," ",s.jsx("span",{className:"truncate",children:e.openaiBaseUrl})]}),t!==void 0&&s.jsx(fs,{results:t.openai})]}),e.openaiResponsesBaseUrl!==void 0&&e.openaiResponsesBaseUrl!==""&&s.jsx("div",{className:"flex min-w-0 flex-col gap-2",children:s.jsxs("div",{className:"min-w-0 text-xs text-muted-foreground",children:[s.jsx("span",{className:"font-medium",children:"OpenAI Responses:"})," ",s.jsx("span",{className:"truncate",children:e.openaiResponsesBaseUrl})]})}),t?.testedAt!==void 0&&s.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[s.jsx(Bt,{className:"size-3"}),s.jsxs("span",{children:["Tested ",v4(t.testedAt)]})]}),t?.models!==void 0&&Object.keys(t.models).length>0&&s.jsxs("div",{className:"border-t pt-2",children:[s.jsxs("button",{type:"button",onClick:()=>g(S=>!S),className:"text-xs text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1",children:[v?s.jsx(ct,{className:"size-3"}):s.jsx(Ot,{className:"size-3"}),"Model Test Results (",Object.keys(t.models).length,")"]}),v&&s.jsx("div",{className:"mt-2 overflow-x-auto",children:s.jsxs("table",{className:"w-full text-xs border-collapse",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border",children:[s.jsx("th",{className:"text-left py-1 px-2 font-medium text-muted-foreground",children:"Model"}),e.anthropicBaseUrl!==void 0&&e.anthropicBaseUrl!==""&&s.jsx("th",{className:"text-left py-1 px-2 font-medium text-muted-foreground",children:"Anthropic"}),e.openaiBaseUrl!==void 0&&e.openaiBaseUrl!==""&&s.jsx("th",{className:"text-left py-1 px-2 font-medium text-muted-foreground",children:"OpenAI"})]})}),s.jsx("tbody",{children:Object.entries(t.models).map(([S,T])=>s.jsxs("tr",{className:"border-b border-border/50 last:border-0",children:[s.jsx("td",{className:"py-1 px-2 font-medium",children:S}),e.anthropicBaseUrl!==void 0&&e.anthropicBaseUrl!==""&&s.jsx("td",{className:"py-1 px-2 align-top",children:s.jsx(fs,{results:T.anthropic})}),e.openaiBaseUrl!==void 0&&e.openaiBaseUrl!==""&&s.jsx("td",{className:"py-1 px-2 align-top",children:s.jsx(fs,{results:T.openai})})]},S))})]})})]}),s.jsxs("div",{className:"flex gap-2 pt-1 border-t",children:[l!==void 0&&s.jsxs(Ne,{variant:"outline",size:"sm",onClick:()=>l(e.id),className:"text-xs h-7 gap-1",disabled:n??!1,children:[s.jsx(vi,{className:`size-3 ${n??!1?"animate-spin":""}`}),n??!1?r!==void 0?`Testing (${r}s)`:"Testing...":"Test"]}),s.jsxs(Ne,{variant:"outline",size:"sm",onClick:()=>i(e),className:"text-xs h-7 gap-1",disabled:n??!1,children:[s.jsx(Md,{className:"size-3"}),"Edit"]}),s.jsxs(Ne,{variant:"outline",size:"sm",onClick:()=>a(e.id),className:"text-xs h-7 gap-1 text-destructive hover:text-destructive",disabled:n??!1,children:[s.jsx(qn,{className:"size-3"}),"Delete"]})]})]})}const oi="/v1/chat/completions";function k4(e,t){const n=e.endsWith("/")?e.slice(0,-1):e,r=t.split("?")[0]??t,o=t.indexOf("?"),i=o>=0?t.slice(o):"";return r!==""&&n.endsWith(r)?n+i:j4(n)&&_4(t)||n.endsWith("/v1")&&t.startsWith("/v1/")?n+t.slice(3):n+t}function _4(e){return e===oi||e.startsWith(`${oi}?`)||e.startsWith(`${oi}/`)}function j4(e){try{const t=new URL(e),n=t.pathname.replace(/\/+$/,"");return t.hostname==="open.bigmodel.cn"&&(n==="/api/paas/v4"||n==="/api/coding/paas/v4")}catch{return!1}}const Gc=["zhipu","zhipuai","bigmodel","z.ai","zai","glm"],Kc=["zhipu coding","glm coding","bigmodel coding","z.ai coding","zai coding"],ps="/v1/messages",hs="/v1/chat/completions",ms="/v1/responses",S4={deepseek:{openaiBaseUrl:"https://api.deepseek.com"},minimax:{anthropicBaseUrl:"https://api.minimaxi.com/anthropic",openaiBaseUrl:"https://api.minimaxi.com",openaiResponsesBaseUrl:"https://api.minimaxi.com",apiDocsUrl:"https://platform.minimaxi.com/docs/api-reference/api-overview"},"zhipu coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},"glm coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},"bigmodel coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},"z.ai coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},"zai coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},zhipu:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},zhipuai:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},bigmodel:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},"z.ai":{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},zai:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},glm:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},alibaba:{openaiBaseUrl:"https://dashscope.aliyuncs.com/compatible-mode"}},Jc=["MiniMax M3","MiniMax M2.7","MiniMax M2.7-highspeed","MiniMax M2.5","MiniMax M2.5-highspeed","MiniMax M2.1","MiniMax M2.1-highspeed","MiniMax M2"],Yc=["glm-5","glm-5.1","glm-5.2","qwen3.6-plus","qwen3.7-max"],Xc=["glm-5.2","glm-5.1","glm-5","glm-5-turbo","glm-4.7","glm-4.7-flashx","glm-4.6","glm-4.5","glm-4.5-air","glm-4.5-x","glm-4.5-airx","glm-4.5-flash"],Qi="__unset__",to="__custom__",dm=[{value:"32K",label:"Small"},{value:"64K",label:"Standard"},{value:"128K",label:"Medium"},{value:"200K",label:"Long"},{value:"256K",label:"Extended"},{value:"512K",label:"Large"},{value:"1M",label:"Max"}];function hn(){return{contextWindow:"",contextWindowMode:"unset",outputLimit:""}}function Qc(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function fm(e,t){const n=Qc(t);return e?.modelMetadata?.find(r=>Qc(r.model)===n)??null}function pm(e){const t=Ps(e);if(t===null)return null;for(const n of dm)if(Ps(n.value)===t)return n.value;return null}function C4(e){return e.trim()===""?"unset":pm(e)!==null?"preset":"custom"}function N4(e){switch(e.contextWindowMode){case"unset":return Qi;case"custom":return to;case"preset":return pm(e.contextWindow)??to}}function ii(e){const t=e.trim().replaceAll(",","");if(t==="")return{amount:"",unit:"K"};const n=/^(\d+(?:\.\d+)?)\s*([kKmM])?$/.exec(t);if(n===null)return{amount:t,unit:"K"};const r=n[1];if(r===void 0)return{amount:t,unit:"K"};const o=n[2];if(o===void 0||o==="")return{amount:r,unit:"tokens"};switch(o.toLowerCase()){case"k":return{amount:r,unit:"K"};case"m":return{amount:r,unit:"M"};default:return{amount:t,unit:"K"}}}function eu(e,t){const n=e.trim();if(n==="")return"";switch(t){case"K":return`${n}K`;case"M":return`${n}M`;case"tokens":return n}}function tu(e,t){return t.map(n=>{const r=fm(e,n),o=r?.contextWindow!==void 0?$w(r.contextWindow):"";return{contextWindow:o,contextWindowMode:C4(o),outputLimit:r?.outputLimit?.toString()??""}})}function nu(e){const t=e.trim();if(t==="")return null;const n=Number(t);return!Number.isInteger(n)||n<=0?null:n}function Pn(e,t){if(e===void 0)return"";const n=e.trim(),r=n.replace(/\/+$/,"");return r.endsWith(t)?r.slice(0,-t.length).replace(/\/+$/,""):n}function T4(e,t){const n=e.trim();return n===""?null:k4(n,t)}function ai({baseUrl:e,endpoint:t}){const n=T4(e,t);return n===null?null:s.jsxs("div",{className:"rounded-md border border-border/70 bg-muted/35 px-3 py-2 text-xs",children:[s.jsx("div",{className:"text-muted-foreground",children:"Final URL"}),s.jsx("div",{className:"break-all font-mono text-foreground",children:n})]})}function E4({provider:e,onSubmit:t,onCancel:n}){const[r,o]=p.useState(e?.name??""),[i,a]=p.useState(e?.apiKey??""),[l,c]=p.useState(!1),[u,d]=p.useState(!1),f=e?.models,[h,m]=p.useState(f!==void 0&&f.length>0?f:[""]),[v,g]=p.useState(()=>tu(e,f!==void 0&&f.length>0?f:[""])),[x,b]=p.useState("anthropic"),[y,_]=p.useState(Pn(e?.anthropicBaseUrl,ps)),[j,S]=p.useState(Pn(e?.openaiBaseUrl,hs)),[T,C]=p.useState(Pn(e?.openaiResponsesBaseUrl,ms)),[A,E]=p.useState(e?.apiDocsUrl??""),[P,J]=p.useState(e?.modelMetadataUrl??""),[R,F]=p.useState(e?.source),[k,M]=p.useState({}),[Y,D]=p.useState(!1),[B,U]=p.useState(null),ie=p.useRef([]);p.useEffect(()=>{if(B===null)return;const O=B;function L(Q){if(!(Q.target instanceof Node))return;const fe=ie.current[O];fe!=null&&!fe.contains(Q.target)&&U(null)}return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[B]);const[W,H]=p.useState(!1),[ue,ne]=p.useState(!1),[se,je]=p.useState(!1),ce=r.toLowerCase().includes("minimax"),me=r.toLowerCase().includes("alibaba"),le=[...Gc,...Kc].some(O=>r.toLowerCase().includes(O)),ae=ce?Jc:le?Xc:me?Yc:[],re=e?.modelMetadata?.some(O=>O.contextWindow!==void 0)??!1;function pe(){Ht(i).then(O=>{O&&(d(!0),setTimeout(()=>d(!1),2e3))})}p.useEffect(()=>{if(e){o(e.name),a(e.apiKey);const O=(e.models?.length??0)>0?e.models:[""];m(O),g(tu(e,O)),_(Pn(e.anthropicBaseUrl,ps)),S(Pn(e.openaiBaseUrl,hs)),C(Pn(e.openaiResponsesBaseUrl,ms)),E(e.apiDocsUrl??""),J(e.modelMetadataUrl??""),F(e.source),H(!1),ne(!1),je(!1)}},[e]),p.useEffect(()=>{const O=r.toLowerCase();for(const[L,Q]of Object.entries(S4))if(O.includes(L)){Q.anthropicBaseUrl!==void 0&&!W&&_(Q.anthropicBaseUrl),Q.openaiBaseUrl!==void 0&&!ue&&S(Q.openaiBaseUrl),Q.openaiResponsesBaseUrl!==void 0&&!se&&C(Q.openaiResponsesBaseUrl),Q.apiDocsUrl!==void 0&&!A&&E(Q.apiDocsUrl),L==="minimax"&&h.length===1&&h[0]===""&&m([Jc[0]??""]),L==="alibaba"&&h.length===1&&h[0]===""&&m([Yc[0]??""]),(Gc.includes(L)||Kc.includes(L))&&h.length===1&&h[0]===""&&m([Xc[0]??""]);break}},[r]);function ye(){const O={};return r.trim()||(O.name="Name is required"),i.trim()||(O.apiKey="API key is required"),(h.length===0||h.every(L=>!L.trim()))&&(O.models="At least one model is required"),y.trim()&&!w(y.trim())&&(O.anthropicBaseUrl="Invalid URL format"),j.trim()&&!w(j.trim())&&(O.openaiBaseUrl="Invalid URL format"),T.trim()&&!w(T.trim())&&(O.openaiResponsesBaseUrl="Invalid URL format"),P.trim()&&!w(P.trim())&&(O.modelMetadataUrl="Invalid URL format"),v.forEach((L,Q)=>{const fe=Ps(L.contextWindow),xe=nu(L.outputLimit);L.contextWindow.trim()!==""&&fe===null&&(O[`modelMetadata.${Q}.contextWindow`]="Context window must be a positive number, optionally using K or M"),L.outputLimit.trim()!==""&&xe===null&&(O[`modelMetadata.${Q}.outputLimit`]="Output limit must be a positive integer"),fe!==null&&xe!==null&&xe>fe&&(O[`modelMetadata.${Q}.outputLimit`]="Output limit should not exceed context window")}),!y.trim()&&!j.trim()&&!T.trim()&&(O.format="At least one format URL (Anthropic or OpenAI) is required"),M(O),Object.keys(O).length===0}function w(O){try{return new URL(O),!0}catch{return!1}}function K(O,L){m(Q=>{const fe=[...Q];return fe[O]=L,fe})}function V(O,L){g(Q=>{const fe=[...Q];return fe[O]={...fe[O]??hn(),...L},fe})}function z(O,L){switch(L){case Qi:V(O,{contextWindow:"",contextWindowMode:"unset"});return;case to:{const Q=v[O]??hn();V(O,{contextWindow:Q.contextWindow,contextWindowMode:"custom"});return}default:V(O,{contextWindow:L,contextWindowMode:"preset"});return}}function I(O,L){const Q=v[O]??hn(),fe=ii(Q.contextWindow);V(O,{contextWindow:eu(L,fe.unit),contextWindowMode:"custom"})}function $(O,L){const Q=v[O]??hn(),fe=ii(Q.contextWindow);switch(L){case"K":case"M":case"tokens":V(O,{contextWindow:eu(fe.amount,L),contextWindowMode:"custom"});return;default:return}}function ee(O){m(L=>L.filter((Q,fe)=>fe!==O)),g(L=>L.filter((Q,fe)=>fe!==O))}function oe(){m(O=>[...O,""]),g(O=>[...O,hn()])}function Z(){const O=new Date().toISOString(),L=[];return h.forEach((Q,fe)=>{const xe=Q.trim();if(xe==="")return;const _e=v[fe]??hn(),Pe=Ps(_e.contextWindow),Se=nu(_e.outputLimit);if(Pe===null&&Se===null)return;const ut=fm(e,xe);if(ut!==null&&ut.contextWindow===(Pe??void 0)&&ut.outputLimit===(Se??void 0)){L.push({...ut,model:xe});return}const Ie={model:xe,source:"manual",updatedAt:O};Pe!==null&&(Ie.contextWindow=Pe),Se!==null&&(Ie.outputLimit=Se),L.push(Ie)}),L.length>0?L:e?.modelMetadata!==void 0?[]:void 0}function te(O){if(O.preventDefault(),!!ye()){D(!0);try{t({name:r.trim(),apiKey:i.trim(),models:h.map(L=>L.trim()).filter(L=>L!==""),anthropicBaseUrl:y.trim()||void 0,openaiBaseUrl:j.trim()||void 0,openaiResponsesBaseUrl:T.trim()||void 0,apiDocsUrl:A.trim()||void 0,modelMetadataUrl:P.trim()||void 0,modelMetadata:Z(),source:R})}finally{D(!1)}}}return s.jsxs("form",{onSubmit:te,className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{htmlFor:"provider-name",className:"text-sm font-medium",children:["Name ",s.jsx("span",{className:"text-destructive",children:"*"})]}),s.jsx("input",{id:"provider-name",type:"text",value:r,onChange:O=>o(O.target.value),placeholder:"Provider Name",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),k.name!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:k.name})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:"provider-source",className:"text-sm font-medium",children:"Token Source"}),s.jsxs("select",{id:"provider-source",value:R??"",onChange:O=>F(O.target.value==="company"||O.target.value==="personal"?O.target.value:void 0),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",children:[s.jsx("option",{value:"",children:"—"}),s.jsx("option",{value:"personal",children:"个人 (Personal)"}),s.jsx("option",{value:"company",children:"公司 (Company)"})]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Label whether this API key is company-provided or personal."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:"provider-model-metadata-url",className:"text-sm font-medium",children:"Model Metadata URL"}),s.jsx("input",{id:"provider-model-metadata-url",type:"text",value:P,onChange:O=>J(O.target.value),placeholder:"https://example.com/agent-inspector-models.json",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),k.modelMetadataUrl!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:k.modelMetadataUrl}),P.trim()===""&&s.jsx("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:"Built-in limits cover DeepSeek v4 pro/flash, MiniMax M3/M2.7/M2.5/M2.1, and GLM coding models. Use a registry URL for private or custom model limits."}),e!==void 0&&!re&&P.trim()===""&&s.jsx("p",{className:"text-xs text-amber-400",children:"This provider has no matching context metadata yet."}),P.trim()!==""&&s.jsx("p",{className:"text-xs text-muted-foreground",children:"Agent Inspector will refresh model limits from this JSON registry after save."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{htmlFor:"provider-apikey",className:"text-sm font-medium",children:["API Key ",s.jsx("span",{className:"text-destructive",children:"*"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{id:"provider-apikey",type:"text",value:l||i.length===0?i:cm(i),onChange:O=>a(O.target.value),onFocus:()=>{!l&&i.length>0&&c(!0)},placeholder:"sk-ant-...",readOnly:!l&&i.length>0,className:"flex-1 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),s.jsx("button",{type:"button",onClick:()=>c(O=>!O),className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":l?"Hide API key":"Show API key",children:l?s.jsx(ja,{className:"size-4"}):s.jsx(Sa,{className:"size-4"})}),s.jsx("button",{type:"button",onClick:pe,className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":"Copy API key",children:u?s.jsx(Ge,{className:"size-4 text-green-500"}):s.jsx(St,{className:"size-4"})})]}),k.apiKey!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:k.apiKey})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{className:"text-sm font-medium",children:["Models ",s.jsx("span",{className:"text-destructive",children:"*"})]}),h.map((O,L)=>{const Q=v[L]??hn(),fe=k[`modelMetadata.${L}.contextWindow`],xe=k[`modelMetadata.${L}.outputLimit`],_e=N4(Q),Pe=ii(Q.contextWindow);return s.jsxs("div",{ref:Se=>{ie.current[L]=Se},className:"space-y-2 rounded-md border border-border bg-muted/10 p-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx("input",{type:"text",value:O,onChange:Se=>K(L,Se.target.value),placeholder:ae.length>0?"Type or select a model...":"Model name",className:"w-full rounded-md border border-input bg-background px-4 py-3 pr-8 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),ae.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:()=>U(B===L?null:L),className:"absolute right-1 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors p-1 z-10","aria-label":"Show model suggestions",children:s.jsx(ct,{className:"size-4"})}),B===L&&s.jsx("div",{className:"absolute left-0 right-0 top-full mt-1 z-50 bg-popover border border-border rounded-md shadow-md max-h-48 overflow-y-auto",children:ae.map(Se=>s.jsx("button",{type:"button",onClick:()=>{K(L,Se),U(null)},className:"w-full text-left px-3 py-2 text-sm hover:bg-muted transition-colors",children:Se},Se))})]})]}),h.length>1&&s.jsx("button",{type:"button",onClick:()=>ee(L),className:"text-muted-foreground hover:text-destructive transition-colors p-1 shrink-0","aria-label":"Remove model",children:s.jsxs("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",children:[s.jsx("path",{d:"M3 6h18"}),s.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),s.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})})]}),s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[s.jsx("span",{children:"Context Window"}),s.jsxs(Ys,{value:_e,onValueChange:Se=>z(L,Se),children:[s.jsx(Qs,{size:"sm",className:"w-full bg-background font-mono text-xs",children:s.jsx(Xs,{})}),s.jsxs(eo,{className:"max-h-64",children:[s.jsx(Nt,{value:Qi,children:"Not set"}),dm.map(Se=>s.jsxs(Nt,{value:Se.value,children:[Se.label," · ",Se.value]},Se.value)),s.jsx(Nt,{value:to,children:"Custom"})]})]}),Q.contextWindowMode==="custom"&&s.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_5.75rem] gap-1.5",children:[s.jsx("input",{type:"text",inputMode:"decimal",value:Pe.amount,onChange:Se=>I(L,Se.target.value),placeholder:"128",className:"w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-xs text-foreground ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px]"}),s.jsxs(Ys,{value:Pe.unit,onValueChange:Se=>$(L,Se),children:[s.jsx(Qs,{size:"sm",className:"w-full bg-background font-mono text-xs",children:s.jsx(Xs,{})}),s.jsxs(eo,{children:[s.jsx(Nt,{value:"K",children:"K"}),s.jsx(Nt,{value:"M",children:"M"}),s.jsx(Nt,{value:"tokens",children:"tokens"})]})]})]}),fe!==void 0&&s.jsx("span",{className:"block text-destructive",children:fe})]}),s.jsxs("label",{className:"space-y-1 text-xs text-muted-foreground",children:[s.jsx("span",{children:"Output Limit"}),s.jsx("input",{type:"number",min:1,step:1e3,value:Q.outputLimit,onChange:Se=>V(L,{outputLimit:Se.target.value}),placeholder:"e.g. 8192",className:"w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-xs text-foreground ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px]"}),xe!==void 0&&s.jsx("span",{className:"block text-destructive",children:xe})]})]})]},L)}),s.jsx("button",{type:"button",onClick:oe,className:"text-xs text-primary hover:underline flex items-center gap-1",children:"+ Add Model"}),k.models!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:k.models})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex gap-1 border-b border-border",children:[s.jsx(Je,{children:s.jsxs(Me,{children:[s.jsx(Le,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>b("anthropic"),className:`px-3 py-2 text-sm font-medium border-b-2 transition-colors ${x==="anthropic"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Anthropic Format"})}),s.jsx(De,{children:"Anthropic Messages API format"})]})}),s.jsx(Je,{children:s.jsxs(Me,{children:[s.jsx(Le,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>b("openai"),className:`px-3 py-2 text-sm font-medium border-b-2 transition-colors ${x==="openai"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"OpenAI Format"})}),s.jsx(De,{children:"OpenAI Chat Completions API format"})]})})]}),k.format!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:k.format})]}),x==="anthropic"&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:"provider-anthropic-base-url",className:"text-sm font-medium",children:"Anthropic Base URL"}),s.jsxs("div",{className:"flex min-w-0 overflow-hidden rounded-md border border-input bg-background ring-offset-background focus-within:border-ring focus-within:outline-ring focus-within:ring-[3px]",children:[s.jsx("input",{id:"provider-anthropic-base-url",type:"text",value:y,onChange:O=>{H(!0),_(O.target.value)},placeholder:"https://api.anthropic.com",className:"min-w-0 flex-1 bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"}),s.jsx("span",{className:"shrink-0 select-none border-l bg-muted px-3 py-2 font-mono text-xs text-muted-foreground",children:ps})]}),k.anthropicBaseUrl!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:k.anthropicBaseUrl}),s.jsx(ai,{baseUrl:y,endpoint:ps}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Anthropic-compatible base URL. Leave empty if this provider does not support Anthropic format."})]}),x==="openai"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:"provider-openai-base-url",className:"text-sm font-medium",children:"OpenAI Chat Base URL"}),s.jsxs("div",{className:"flex min-w-0 overflow-hidden rounded-md border border-input bg-background ring-offset-background focus-within:border-ring focus-within:outline-ring focus-within:ring-[3px]",children:[s.jsx("input",{id:"provider-openai-base-url",type:"text",value:j,onChange:O=>{ne(!0),S(O.target.value)},placeholder:"https://api.openai.com",className:"min-w-0 flex-1 bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"}),s.jsx("span",{className:"shrink-0 select-none border-l bg-muted px-3 py-2 font-mono text-xs text-muted-foreground",children:hs})]}),k.openaiBaseUrl!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:k.openaiBaseUrl}),s.jsx(ai,{baseUrl:j,endpoint:hs}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"OpenAI Chat Completions-compatible base URL. Leave empty if this provider only supports the Responses API."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:"provider-openai-responses-base-url",className:"text-sm font-medium",children:"OpenAI Responses Base URL"}),s.jsxs("div",{className:"flex min-w-0 overflow-hidden rounded-md border border-input bg-background ring-offset-background focus-within:border-ring focus-within:outline-ring focus-within:ring-[3px]",children:[s.jsx("input",{id:"provider-openai-responses-base-url",type:"text",value:T,onChange:O=>{je(!0),C(O.target.value)},placeholder:"https://api.openai.com",className:"min-w-0 flex-1 bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"}),s.jsx("span",{className:"shrink-0 select-none border-l bg-muted px-3 py-2 font-mono text-xs text-muted-foreground",children:ms})]}),k.openaiResponsesBaseUrl!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:k.openaiResponsesBaseUrl}),s.jsx(ai,{baseUrl:T,endpoint:ms}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional Responses-compatible base URL. Set only when the provider supports the Responses API."})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:"provider-api-docs-url",className:"text-sm font-medium",children:"API Docs URL"}),s.jsx("input",{id:"provider-api-docs-url",type:"text",value:A,onChange:O=>E(O.target.value),placeholder:"https://api.example.com/docs",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional API documentation URL. If not set, uses known provider docs."})]}),s.jsxs("div",{className:"sticky bottom-0 bg-card border-t flex gap-2 justify-end pt-2 pb-2",children:[s.jsx(Ne,{type:"button",variant:"outline",onClick:n,disabled:Y,children:"Cancel"}),s.jsx(Ne,{type:"submit",disabled:Y,children:Y?"Saving...":e?"Update Provider":"Add Provider"})]})]})}const A4=Ee(["timeout","network_unreachable","connection_refused","auth_failed","rate_limited","server_error","invalid_response","unknown"]),R4=G({message:N(),type:A4,details:N().optional(),hint:N().optional()}),I4=G({type:Ee(["text","thinking"]),text:N().optional(),thinking:N().optional()}),z4=G({requestUrl:N().optional(),requestMethod:N().optional(),requestHeaders:qe(N(),N()).optional(),requestBody:N().optional(),responseStatus:q().optional(),responseStatusText:N().optional(),responseHeaders:qe(N(),N()).optional(),responseBody:N().optional()}),O4=G({success:$e(),error:R4.optional(),model:N().optional(),inputTokens:q().optional(),outputTokens:q().optional(),cacheCreationInputTokens:q().optional(),cacheReadInputTokens:q().optional(),latencyMs:q().optional(),firstChunkMs:q().nullable().optional(),totalStreamMs:q().nullable().optional(),tokensPerSecond:q().nullable().optional(),content:he(I4).optional(),rawResponse:N().optional(),streaming:$e().optional(),streamingChunks:G({chunks:he(cd),truncated:$e().default(!1)}).optional(),requestHeaders:qe(N(),N()).optional(),debug:z4.optional()}),ru=zt([O4,G({notConfigured:Te(!0)}),G({testing:Te(!0)})]),no=G({nonStreaming:ru,streaming:ru}),P4=G({anthropic:no,openai:no}),M4=G({anthropic:no,openai:no,models:qe(N(),P4).optional(),testedAt:N().optional()});function L4(){return{anthropic:{nonStreaming:{testing:!0},streaming:{testing:!0}},openai:{nonStreaming:{testing:!0},streaming:{testing:!0}}}}function su(e,t){const n=()=>({nonStreaming:{success:!1,error:{message:e,type:t}},streaming:{notConfigured:!0}});return{anthropic:n(),openai:n()}}const D4=G({providerConfig:N()}),$4=G({success:$e().optional(),imported:q().optional(),message:N().optional(),errors:he(N()).optional()}),F4=G({provider:Ms,imported:q(),matchedModels:he(N()),missingModels:he(N()),sourceUrl:N()}),gs="Network error: could not reach the server. Is the proxy running?";function ou(e){return{name:e.name,apiKey:e.apiKey,models:e.models,anthropicBaseUrl:(e.anthropicBaseUrl?.length??0)>0?e.anthropicBaseUrl:void 0,openaiBaseUrl:(e.openaiBaseUrl?.length??0)>0?e.openaiBaseUrl:void 0,openaiResponsesBaseUrl:(e.openaiResponsesBaseUrl?.length??0)>0?e.openaiResponsesBaseUrl:void 0,apiDocsUrl:(e.apiDocsUrl?.length??0)>0?e.apiDocsUrl:void 0,modelMetadataUrl:(e.modelMetadataUrl?.length??0)>0?e.modelMetadataUrl:void 0,modelMetadata:e.modelMetadata,source:e.source}}function B4(e,t){const n=e?.models?.map(r=>r.trim()).filter(r=>r!=="").length??0;return Math.max(1,n)*t}async function U4(e,t){if(t.models!==void 0)try{await fetch(`/api/providers/${e}/test/log`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}catch{}}function W4({externalProviders:e,isLoading:t=!1,externalTestResults:n,externalTestingProviders:r,externalTestingTimeLeft:o,onProvidersMutate:i,onTestResultsChange:a,onTestingProvidersChange:l,onTestingTimeLeftChange:c}){const[u,d]=p.useState(!1),[f,h]=p.useState(),[m,v]=p.useState(null),[g,x]=p.useState({}),[b,y]=p.useState(new Set),[_,j]=p.useState({}),[S,T]=p.useState(null),[C,A]=p.useState(!1),[E,P]=p.useState(null),[J,R]=p.useState(!1),[F,k]=p.useState(!1),[M,Y]=p.useState(null),[D,B]=p.useState("all"),[U,ie]=p.useState(new Set),{providerTestTimeoutSeconds:W}=wa(),H=p.useRef(null),ue=p.useRef(null),ne=e??[],se=p.useMemo(()=>{const O=D==="all"?ne:ne.filter(L=>L.source===D);return D==="all"?[...O].sort((L,Q)=>{const fe={personal:0,company:1};return(fe[L.source??""]??2)-(fe[Q.source??""]??2)}):O},[ne,D]),je=n??g,ce=r??b,me=o??_,le=c?(O,L)=>c(O,L):(O,L)=>{j(L===void 0?Q=>{const fe={...Q};return delete fe[O],fe}:Q=>({...Q,[O]:L}))};p.useEffect(()=>{(async()=>{try{const O=await fetch("/api/config/paths");if(O.ok){const L=await wt(O,D4);T(L.providerConfig)}}catch{}})()},[]);const ae=p.useCallback(O=>{ue.current!==null&&clearTimeout(ue.current),P(O),H.current?.scrollTo({top:H.current.scrollHeight,behavior:"smooth"}),ue.current=setTimeout(()=>{P(null),ue.current=null},2e3)},[]);p.useEffect(()=>()=>{ue.current!==null&&clearTimeout(ue.current)},[]);const re=p.useCallback(()=>{i?.().catch(()=>{})},[i]),pe=p.useCallback((O,L)=>{a?a(O,L):x(Q=>({...Q,[O]:L}))},[a]),ye=p.useCallback((O,L)=>{if(l){l(O,L);return}y(Q=>{const fe=new Set(Q);return L?fe.add(O):fe.delete(O),fe})},[l]),w=p.useCallback(async O=>{pe(O,L4()),ye(O,!0);const L=new AbortController,Q=ne.find(Pe=>Pe.id===O);let xe=B4(Q,W);le(O,xe);const _e=setInterval(()=>{xe--,le(O,xe),xe<=0&&(clearInterval(_e),L.abort())},1e3);try{const Pe=await fetch(`/api/providers/${O}/test`,{method:"POST",signal:L.signal});if(Pe.ok){const Se=await wt(Pe,M4);pe(O,Se),await U4(O,Se)}else pe(O,su(`HTTP ${Pe.status}: ${Pe.statusText}`,"server_error"))}catch(Pe){Pe instanceof Error&&Pe.name==="AbortError"&&pe(O,su("Request timed out","timeout"))}finally{clearInterval(_e),le(O,void 0),ye(O,!1)}},[W,ne,le,pe,ye]),K=p.useCallback(async(O,L,Q=!0)=>{ie(fe=>{const xe=new Set(fe);return xe.add(O),xe});try{const fe=L!==void 0&&L.trim()!==""?{url:L}:{},xe=await fetch(`/api/providers/${O}/model-metadata`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(fe)});if(!xe.ok)return Q&&v(await Ft(xe,"Failed to refresh model metadata")),!1;const _e=await wt(xe,F4);return _e.imported===0&&Q?v("No matching model metadata found for this provider."):v(null),ae(_e.provider.id),re(),_e.imported>0}catch{return Q&&v(gs),!1}finally{ie(fe=>{const xe=new Set(fe);return xe.delete(O),xe})}},[re,ae]);function V(O){(async()=>{try{const L=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ou(O))});if(!L.ok){v(await Ft(L,"Failed to add provider"));return}const Q=await wt(L,Ms);d(!1),ae(Q.id),O.modelMetadataUrl!==void 0&&O.modelMetadataUrl.trim()!==""&&await K(Q.id,O.modelMetadataUrl,!1),re(),await w(Q.id)}catch{v(gs)}})()}function z(O){f&&(async()=>{try{const L=await fetch(`/api/providers/${f.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(ou(O))});if(!L.ok){v(await Ft(L,"Failed to update provider"));return}const Q=await wt(L,Ms);h(void 0),ae(Q.id),O.modelMetadataUrl!==void 0&&O.modelMetadataUrl.trim()!==""&&await K(Q.id,O.modelMetadataUrl,!1),re(),((O.apiKey??"")!==(f.apiKey??"")||JSON.stringify(O.models)!==JSON.stringify(f.models)||(O.anthropicBaseUrl??"")!==(f.anthropicBaseUrl??"")||(O.openaiBaseUrl??"")!==(f.openaiBaseUrl??"")||(O.openaiResponsesBaseUrl??"")!==(f.openaiResponsesBaseUrl??""))&&await w(Q.id)}catch{v(gs)}})()}function I(O){Y(O),k(!0)}function $(){const O=M;O!==null&&(async()=>{let L;try{L=await fetch(`/api/providers/${O}`,{method:"DELETE"})}catch{v(gs);return}if(!L.ok){v(await Ft(L,"Failed to delete provider"));return}re()})()}const ee=p.useRef(null);function oe(O){const L="/api/providers/export";(async()=>{try{const Q=await fetch(L);if(!Q.ok){v("Failed to export providers");return}const fe=await Q.blob(),xe=URL.createObjectURL(fe),_e=document.createElement("a");_e.href=xe,_e.download=Q.headers.get("Content-Disposition")?.match(/filename="(.+)"/)?.[1]??"providers.json",document.body.appendChild(_e),_e.click(),document.body.removeChild(_e),URL.revokeObjectURL(xe)}catch{v("Failed to export providers")}})()}function Z(){ee.current?.click()}function te(O){const L=O.target.files?.[0];L&&(async()=>{try{const Q=await L.text(),fe=await fetch("/api/providers/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Q)}),xe=await wt(fe,$4);fe.ok&&xe.imported!==void 0&&xe.imported>0?(re(),v(null)):xe.errors&&xe.errors.length>0?v(xe.errors.join("; ")):v(xe.message??"Import failed")}catch{v("Failed to import providers")}O.target.value=""})()}return t?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading providers..."})}):u||f?s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"flex items-center justify-between sticky top-0 bg-background z-10 pb-2",children:s.jsx("h3",{className:"text-lg font-medium",children:f?"Edit Provider":"Add New Provider"})}),s.jsx(E4,{provider:f,onSubmit:f?z:V,onCancel:()=>{d(!1),h(void 0)}})]}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between sticky top-0 z-10 bg-background pb-2",children:[s.jsx("h3",{className:"text-lg font-medium",children:"Providers"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Je,{children:s.jsxs(Me,{children:[s.jsx(Le,{asChild:!0,children:s.jsxs(Ne,{variant:"outline",size:"sm",onClick:()=>oe(),className:"gap-1 hover:bg-muted",children:[s.jsx(co,{className:"size-3"}),"Export"]})}),s.jsx(De,{children:"Download providers as JSON for backup or sharing"})]})}),s.jsx(Je,{children:s.jsxs(Me,{children:[s.jsx(Le,{asChild:!0,children:s.jsxs(Ne,{variant:"outline",size:"sm",onClick:Z,className:"gap-1 hover:bg-muted",children:[s.jsx(Ld,{className:"size-3"}),"Import"]})}),s.jsx(De,{children:"Import providers from an exported JSON file"})]})}),s.jsx("input",{type:"file",ref:ee,accept:".json",onChange:te,style:{display:"none"}}),s.jsx(Je,{children:s.jsxs(Me,{children:[s.jsx(Le,{asChild:!0,children:s.jsxs(Ne,{variant:"outline",size:"sm",onClick:()=>R(!0),className:"gap-1",children:[s.jsx(i2,{className:"size-3"}),"Scan"]})}),s.jsx(De,{children:"Detect and import provider configs from Claude Code and OpenCode"})]})}),s.jsxs(Ne,{onClick:()=>d(!0),size:"sm",className:"gap-1",children:[s.jsx(bi,{className:"size-4"}),"Add Provider"]})]})]}),S!==null&&s.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground bg-muted/30 rounded-md px-3 py-2",children:[s.jsx("span",{className:"shrink-0",children:"Config:"}),s.jsx("span",{className:"font-mono truncate",title:S,children:S}),s.jsx(Je,{children:s.jsxs(Me,{children:[s.jsx(Le,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>{Ht(S).then(O=>{O&&(A(!0),setTimeout(()=>A(!1),2e3))})},className:"shrink-0 ml-auto text-muted-foreground hover:text-foreground transition-colors","aria-label":C?"Copied config file path":"Copy config file path",children:C?s.jsx(Ge,{className:"size-3 text-green-500"}):s.jsx(St,{className:"size-3"})})}),s.jsx(De,{children:"Copy config file path to clipboard"})]})})]}),m!==null&&s.jsxs("div",{className:"flex items-center gap-2 text-sm text-destructive bg-destructive/10 rounded-md px-3 py-2",children:[s.jsx(_r,{className:"size-4 shrink-0"}),m]}),ne.length===0?s.jsxs("div",{className:"text-center py-12 space-y-3",children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:"No providers configured yet."}),s.jsxs(Ne,{onClick:()=>d(!0),variant:"outline",size:"sm",children:[s.jsx(bi,{className:"size-4"}),"Add Your First Provider"]})]}):s.jsxs("div",{className:"space-y-3",children:[s.jsx("div",{className:"flex gap-1 border-b border-border",children:["all","personal","company"].map(O=>s.jsx(Je,{children:s.jsxs(Me,{children:[s.jsx(Le,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>B(O),className:`px-3 py-2 text-sm font-medium border-b-2 transition-colors ${D===O?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:O==="all"?"All":O==="personal"?"Personal":"Company"})}),s.jsx(De,{children:O==="all"?"Show all providers":O==="personal"?"Providers you configured yourself":"Providers set by your organization"})]})},O))}),s.jsx("div",{ref:H,className:"space-y-3",children:se.map(O=>s.jsx(w4,{provider:O,testResults:je[O.id],isTesting:ce.has(O.id),testingTimeLeft:me[O.id],isHighlighted:O.id===E,onEdit:L=>h(L),onDelete:I,onRefreshMetadata:L=>{K(L)},isRefreshingMetadata:U.has(O.id),onTest:L=>{w(L)}},O.id))})]}),s.jsx(a4,{open:J,onOpenChange:R,onImportComplete:()=>{i!==void 0&&i()}}),s.jsx(Of,{open:F,onOpenChange:k,title:"Delete Provider",description:"Are you sure you want to delete this provider? This action cannot be undone.",confirmLabel:"Delete",variant:"destructive",onConfirm:$})]})}function iu(){const[e,t]=p.useState(!1),[n,r]=p.useState("providers"),{providers:o,isLoading:i,mutate:a}=tf(),[l,c]=p.useState({}),[u,d]=p.useState(new Set),[f,h]=p.useState({}),m=p.useCallback((x,b)=>{c(y=>({...y,[x]:b}))},[]),v=p.useCallback((x,b)=>{d(y=>{const _=new Set(y);return b?_.add(x):_.delete(x),_})},[]),g=p.useCallback((x,b)=>{h(y=>{if(b===void 0){const _={...y};return delete _[x],_}return{...y,[x]:b}})},[]);return s.jsxs(zr,{open:e,onOpenChange:t,children:[s.jsx(Ma,{asChild:!0,children:s.jsxs(Ne,{variant:"ghost",size:"icon",className:"size-8",children:[s.jsx(f2,{className:"size-4"}),s.jsx("span",{className:"sr-only",children:"Settings"})]})}),s.jsxs(Or,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[s.jsx(Pr,{children:s.jsx(Mr,{children:"Settings"})}),s.jsxs(Dh,{value:n,onValueChange:r,className:"flex-1 overflow-hidden",children:[s.jsxs($h,{children:[s.jsx(dt,{value:"providers",children:"Providers"}),s.jsx(dt,{value:"proxy",children:"Proxy"}),s.jsx(dt,{value:"storage",children:"Storage"}),s.jsx(dt,{value:"mcp",children:"MCP"}),s.jsx(dt,{value:"onboarding",children:"Onboarding"})]}),s.jsxs("div",{className:"mt-4 flex-1 overflow-x-hidden overflow-y-auto pr-3",children:[s.jsx(ft,{value:"providers",children:s.jsx(W4,{externalProviders:o,isLoading:i,externalTestResults:l,externalTestingProviders:u,externalTestingTimeLeft:f,onProvidersMutate:()=>a(),onTestResultsChange:m,onTestingProvidersChange:v,onTestingTimeLeftChange:g})}),s.jsx(ft,{value:"proxy",children:s.jsx(G4,{})}),s.jsx(ft,{value:"storage",children:s.jsx(Z4,{})}),s.jsx(ft,{value:"mcp",children:s.jsx(q4,{})}),s.jsx(ft,{value:"onboarding",children:s.jsx(V4,{})})]})]})]})]})}const H4=G({memoryCount:q(),logDir:N(),logFileCount:q(),logBytes:q(),chunkDir:N(),chunkFileCount:q(),chunkBytes:q(),sessionArchiveDir:N(),sessionArchiveFileCount:q(),sessionArchiveBytes:q()});function li(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MiB`:`${(e/1024/1024/1024).toFixed(1)} GiB`}function Z4(){const[e,t]=p.useState(null),[n,r]=p.useState(null),[o,i]=p.useState(!1),[a,l]=p.useState(null),c=p.useCallback(async()=>{i(!0),r(null);try{const d=await fetch("/api/logs?stats=1");if(!d.ok){r(`Failed to load storage stats: HTTP ${String(d.status)}`);return}const f=await d.json(),h=H4.safeParse(f);if(!h.success){r("Storage stats response was not valid.");return}t(h.data)}catch(d){r(d instanceof Error?d.message:String(d))}finally{i(!1)}},[]);p.useEffect(()=>{c()},[c]);const u=p.useCallback((d,f)=>{Ht(f).then(h=>{h&&(l(d),setTimeout(()=>l(null),1600))})},[]);return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-semibold",children:"Log storage"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Inspect local log and streaming chunk footprint before exporting or clearing sessions."})]}),s.jsx(Ne,{type:"button",variant:"outline",size:"sm",onClick:()=>{c()},children:o?"Refreshing...":"Refresh"})]}),e!==null&&s.jsxs("div",{className:"grid gap-2 text-xs",children:[s.jsx(br,{id:"log-dir",label:"Log storage path",value:e.logDir,copiedId:a,onCopy:u}),s.jsx(br,{id:"chunk-dir",label:"Streaming chunks storage path",value:e.chunkDir,copiedId:a,onCopy:u}),s.jsx(br,{id:"session-archive-dir",label:"Session archive storage path",value:e.sessionArchiveDir,copiedId:a,onCopy:u}),s.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[s.jsx("div",{className:"font-medium",children:"In-memory logs"}),s.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.memoryCount.toLocaleString()," loaded"]})]}),s.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[s.jsx("div",{className:"font-medium",children:"Log files"}),s.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.logFileCount.toLocaleString()," files / ",li(e.logBytes)]})]}),s.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[s.jsx("div",{className:"font-medium",children:"Streaming chunks"}),s.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.chunkFileCount.toLocaleString()," files / ",li(e.chunkBytes)]})]}),s.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[s.jsx("div",{className:"font-medium",children:"Session archives"}),s.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.sessionArchiveFileCount.toLocaleString()," files /"," ",li(e.sessionArchiveBytes)]})]})]}),n!==null&&s.jsx("p",{className:"text-xs text-destructive",children:n})]})}function br({id:e,label:t,value:n,copiedId:r,onCopy:o}){const i=r===e;return s.jsxs("div",{className:"min-w-0 rounded-md border border-border bg-muted/20 px-3 py-2",children:[s.jsx("div",{className:"mb-1 text-xs font-medium text-muted-foreground",children:t}),s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground",children:n}),s.jsx(Ne,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0",onClick:()=>o(e,n),"aria-label":i?`Copied ${t}`:`Copy ${t}`,children:i?s.jsx(Ge,{className:"size-3.5 text-emerald-500"}):s.jsx(St,{className:"size-3.5"})})]})]})}function V4(){const[e,t]=p.useState(null),n=p.useMemo(()=>typeof window>"u"?"http://localhost:25947":window.location.origin,[]),r=p.useMemo(()=>[{id:"status",label:"Check onboarding",value:"agent-inspector onboard --status"},{id:"status-json",label:"Check onboarding JSON",value:"agent-inspector onboard --status --json"},{id:"refresh",label:"Refresh generated files",value:"agent-inspector onboard --force"},{id:"uninstall",label:"Remove matching generated files",value:"agent-inspector onboard --uninstall"},{id:"claude",label:"Claude Code command",value:"/agent-inspector:onboard"},{id:"codex",label:"Codex prompt",value:"Use the agent-inspector-onboard skill"},{id:"opencode-config",label:"OpenCode config",value:"agent-inspector onboard --opencode-only"},{id:"opencode-status",label:"OpenCode status",value:"agent-inspector onboard --status --opencode-only"},{id:"opencode-verify",label:"OpenCode verify",value:"opencode mcp list"},{id:"opencode-proxy",label:"OpenCode proxy",value:`LLM_BASE_URL=${n}/proxy`},{id:"mimo-config",label:"MiMo Code config",value:"agent-inspector onboard --mimo-only"},{id:"mimo-status",label:"MiMo Code status",value:"agent-inspector onboard --status --mimo-only"},{id:"mimo-verify",label:"MiMo Code verify",value:"mimo mcp list"},{id:"mimo-proxy",label:"MiMo Code proxy",value:`OPENAI_BASE_URL=${n}/proxy`},{id:"mcp",label:"MCP URL",value:`${n}/api/mcp`},{id:"proxy",label:"Proxy URL",value:`${n}/proxy`},{id:"anthropic",label:"Anthropic base",value:`ANTHROPIC_BASE_URL=${n}/proxy`},{id:"openai",label:"OpenAI base",value:`OPENAI_BASE_URL=${n}/proxy`}],[n]),o=p.useCallback((i,a)=>{Ht(a).then(l=>{l&&(t(i),setTimeout(()=>t(null),1600))})},[]);return s.jsxs("div",{className:"min-w-0 space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Na,{className:"size-4 text-muted-foreground"}),s.jsx("h3",{className:"text-sm font-semibold",children:"Agent onboarding"})]}),s.jsx("div",{className:"grid gap-2",children:r.map(i=>s.jsx(br,{id:i.id,label:i.label,value:i.value,copiedId:e,onCopy:o},i.id))}),s.jsxs("div",{className:"grid gap-2 rounded-md border border-border bg-background px-3 py-2 text-xs text-muted-foreground",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ge,{className:"size-3.5 text-emerald-500"}),s.jsx("span",{children:"Provider test creates a traceable memory probe session."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ge,{className:"size-3.5 text-emerald-500"}),s.jsx("span",{children:"Captured sessions can produce reviewable memory candidates."})]}),s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Ge,{className:"mt-0.5 size-3.5 text-emerald-500"}),s.jsxs("span",{children:["Streamable HTTP clients should use the MCP URL directly. Stdio-only clients should use",s.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"agent-inspector-mcp stdio"}),"instead. Configure only one entry for the same Inspector."]})]}),s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Ge,{className:"mt-0.5 size-3.5 text-emerald-500"}),s.jsxs("span",{children:["OpenCode onboarding safely merges"," ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mcp.agent-inspector"})," ","into"," ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"opencode.json"}),", then verify with"," ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"opencode mcp list"}),"."]})]}),s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Ge,{className:"mt-0.5 size-3.5 text-emerald-500"}),s.jsxs("span",{children:["MiMo Code onboarding safely merges"," ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mcp.agent-inspector"})," ","into"," ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mimocode.jsonc"}),", then route OpenAI-format traffic with"," ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"OPENAI_BASE_URL"}),"."]})]}),s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Ge,{className:"mt-0.5 size-3.5 text-emerald-500"}),s.jsx("span",{children:"If your AI tool runs in another container or host, replace localhost with an address reachable from that tool and verify the network/firewall path."})]})]})]})}function q4(){const[e,t]=p.useState(null),r=`${p.useMemo(()=>typeof window>"u"?"http://localhost:25947":window.location.origin,[])}/api/mcp`,o=p.useMemo(()=>[{id:"mcp-url",label:"Streamable HTTP MCP URL",value:r},{id:"stdio",label:"Stdio bridge command",value:`agent-inspector-mcp stdio --url ${r}`},{id:"doctor",label:"Bridge doctor",value:`agent-inspector-mcp doctor --url ${r}`},{id:"readonly",label:"Readonly mode",value:"AGENT_INSPECTOR_MCP_READONLY=1 agent-inspector"},{id:"capabilities",label:"Capabilities resource",value:"inspector://mcp/capabilities"},{id:"context",label:"Current context resource",value:"inspector://context/current"},{id:"streamable-json",label:"Streamable HTTP JSON",value:JSON.stringify({mcpServers:{"agent-inspector":{type:"streamableHttp",url:r}}},null,2)},{id:"stdio-json",label:"Stdio MCP JSON",value:JSON.stringify({mcpServers:{"agent-inspector":{command:"agent-inspector-mcp",args:["stdio","--url",r]}}},null,2)},{id:"opencode-local",label:"OpenCode local MCP",value:JSON.stringify({mcp:{"agent-inspector":{type:"local",command:["agent-inspector-mcp","stdio","--url",r],enabled:!0}}},null,2)},{id:"mimo-local",label:"MiMo Code local MCP",value:JSON.stringify({mcp:{"agent-inspector":{type:"local",command:["agent-inspector-mcp","stdio","--url",r],enabled:!0}}},null,2)},{id:"codex-toml",label:"Codex TOML",value:`[mcp_servers.agent-inspector]
|
|
105
|
+
command = "agent-inspector-mcp"
|
|
106
|
+
args = ["stdio", "--url", "${r}"]`}],[r]),i=p.useCallback((a,l)=>{Ht(l).then(c=>{c&&(t(a),setTimeout(()=>t(null),1600))})},[]);return s.jsxs("div",{className:"min-w-0 space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Na,{className:"size-4 text-muted-foreground"}),s.jsx("h3",{className:"text-sm font-semibold",children:"MCP access"})]}),s.jsxs("div",{className:"grid gap-2 rounded-md border border-border bg-background px-3 py-2 text-xs text-muted-foreground",children:[s.jsx("div",{children:"Use Streamable HTTP when the client supports URL-based MCP. Use the stdio bridge only for stdio-only clients. Configure one entry for the same Inspector instance."}),s.jsx("div",{children:"If the MCP client runs in another container or host, replace localhost with a reachable host/IP and verify the network path."})]}),s.jsx("div",{className:"grid gap-2",children:o.map(a=>s.jsx(br,{id:a.id,label:a.label,value:a.value,copiedId:e,onCopy:i},a.id))})]})}function G4(){const{strip:e,slowResponseThresholdSeconds:t,providerTestTimeoutSeconds:n,timeDisplayFormat:r,isLoading:o,setStrip:i,setSlowResponseThresholdSeconds:a,setProviderTestTimeoutSeconds:l,setTimeDisplayFormat:c}=wa(),[u,d]=p.useState(null),[f,h]=p.useState(!1),m=p.useCallback(async b=>{d(null),h(!0);try{await i(b)}catch(y){d(y instanceof Error?y.message:String(y))}finally{h(!1)}},[i]),v=p.useCallback(async b=>{d(null),h(!0);try{await a(b)}catch(y){d(y instanceof Error?y.message:String(y))}finally{h(!1)}},[a]),g=p.useCallback(async b=>{d(null),h(!0);try{await l(b)}catch(y){d(y instanceof Error?y.message:String(y))}finally{h(!1)}},[l]),x=p.useCallback(async b=>{d(null),h(!0);try{await c(b)}catch(y){d(y instanceof Error?y.message:String(y))}finally{h(!1)}},[c]);return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("h3",{className:"text-sm font-semibold",children:"Claude Code billing header"}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["When enabled, the proxy strips the synthetic ",s.jsx("code",{children:"x-anthropic-billing-header"})," text block that Claude Code prepends to the system prompt before forwarding to upstream. Improves prefix-cache hit rates against third-party upstreams. The default at startup is controlled by the ",s.jsx("code",{children:"AGENT_INSPECTOR_STRIP_CLAUDE_CODE_BILLING_HEADER"})," ","environment variable; your choice is persisted to ",s.jsx("code",{children:"config.json"})," and overrides the env var for subsequent requests."]})]}),s.jsxs("label",{className:"flex items-center gap-3",children:[s.jsx("input",{type:"checkbox",role:"switch",checked:e,disabled:o||f,onChange:b=>{m(b.currentTarget.checked)},className:"size-4 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50"}),s.jsx("span",{className:"text-sm",children:o?"Loading...":e?"Stripping enabled":"Stripping disabled"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{htmlFor:"slow-response-threshold",className:"text-sm font-semibold",children:"Slow response threshold"}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Logs whose elapsed time exceeds this many seconds show a warning icon next to the duration. Set to ",s.jsx("code",{children:"0"})," to disable the indicator."]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{id:"slow-response-threshold",type:"number",min:0,max:gi,step:1,value:t,disabled:o||f,onChange:b=>{const y=Number(b.currentTarget.value);Number.isInteger(y)&&(y<0||y>gi||v(y))},className:"h-8 w-24 rounded-md border border-input bg-transparent px-2 text-sm font-mono disabled:cursor-not-allowed disabled:opacity-50"}),s.jsx("span",{className:"text-xs text-muted-foreground",children:"seconds"})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{htmlFor:"provider-test-timeout",className:"text-sm font-semibold",children:"Provider test timeout"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Provider Test waits this many seconds per configured model before aborting slow probes. The full test window scales with model count."}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{id:"provider-test-timeout",type:"number",min:1,max:xi,step:1,value:n,disabled:o||f,onChange:b=>{const y=Number(b.currentTarget.value);Number.isInteger(y)&&(y<1||y>xi||g(y))},className:"h-8 w-24 rounded-md border border-input bg-transparent px-2 text-sm font-mono disabled:cursor-not-allowed disabled:opacity-50"}),s.jsx("span",{className:"text-xs text-muted-foreground",children:"seconds / model"})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{htmlFor:"time-display-format",className:"text-sm font-semibold",children:"Time display"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Controls timestamps in session summaries, conversation headers, and log rows."}),s.jsxs("select",{id:"time-display-format",value:r,disabled:o||f,onChange:b=>{const y=Rd.safeParse(b.currentTarget.value);y.success&&x(y.data)},className:"h-8 rounded-md border border-input bg-background px-2 text-sm disabled:cursor-not-allowed disabled:opacity-50",children:[s.jsx("option",{value:"time",children:"Time only"}),s.jsx("option",{value:"full",children:"Full ISO"})]})]}),u!==null&&s.jsxs("p",{className:"text-xs text-destructive",children:["Failed to save: ",u]})]})}function K4(e){const t=new Map;for(const n of e){const r=n.logs;for(let o=1;o<r.length;o++){const i=r[o-1],a=r[o];i===void 0||a===void 0||t.set(a.id,{creation:au(i.cacheCreationInputTokens,a.cacheCreationInputTokens),read:au(i.cacheReadInputTokens,a.cacheReadInputTokens)})}}return t}function au(e,t){return t===null||e===null?null:t>e?{direction:"up",delta:t-e}:t<e?{direction:"down",delta:e-t}:null}const J4=30,Y4=112,X4=6;function Q4(e){return e>J4}function eA({groups:e,standalone:t,...n}){return Q4(e.length)?s.jsx(tA,{groups:e,standalone:t,...n}):s.jsx(s.Fragment,{children:e.map(r=>s.jsx(nm,{group:r,standalone:t,...n},r.id))})}function tA({groups:e,standalone:t,...n}){const[r,o]=p.useState(()=>new Map),i=Ph({count:e.length,estimateSize:()=>Y4,overscan:X4,getItemKey:c=>e[c]?.id??c}),a=p.useCallback((c,u)=>{o(d=>{const f=new Map(d);return u?f.set(c,!0):f.delete(c),f})},[]),l=p.useMemo(()=>{const c=new Map;for(let u=0;u<e.length;u++){const d=e[u];if(d!==void 0)for(const f of d.logs)c.set(f.id,u)}return c},[e]);return p.useEffect(()=>{const c=u=>{const d=Br(u);if(d===null)return;const f=l.get(d.logId);if(f===void 0)return;const h=e[f];h!==void 0&&(a(h.id,!0),i.scrollToIndex(f,{align:"center"}))};return window.addEventListener(jt,c),()=>{window.removeEventListener(jt,c)}},[e,l,a,i]),s.jsx("div",{className:"relative w-full",style:{height:`${i.getTotalSize()}px`},"data-virtualized-conversation-list":"true",children:i.getVirtualItems().map(c=>{const u=e[c.index];return u===void 0?null:s.jsx("div",{"data-index":c.index,ref:i.measureElement,className:"absolute left-0 top-0 w-full",style:{transform:`translateY(${c.start}px)`},children:s.jsx(nm,{group:u,standalone:t,expanded:r.get(u.id)??!1,onExpandedChange:d=>a(u.id,d),...n})},c.key)})})}const ro="data-nav-id",nA="data-nav-action";function lu(e){return Array.from(e.querySelectorAll(`[${ro}]`))}function cu(e){return e instanceof HTMLElement}function rA(e,t){let n=e;for(;n!==null&&n!==t;){if(n.hasAttribute(ro))return n;n=n.parentElement}return e.hasAttribute(ro)?e:null}function ci(e){const t=e.getAttribute(nA);return t==="toggle"||t==="expand"||t==="collapse"?t:null}function fr(e){e.focus({preventScroll:!0}),e.scrollIntoView({block:"nearest",behavior:"smooth"})}function pr(e,t){return e[t]??null}function hm(e){const t=e.tagName;return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable)}function uu(e){const t=e.tagName;return t==="BUTTON"||t==="A"||hm(e)?!0:e.closest("[role='button'],[role='menuitem'],[role='option']")!==null}function sA(e){return e.closest("[role='dialog'],[role='menu'],[role='listbox']")!==null?!0:document.querySelector("[role='dialog'],[role='menu'],[role='listbox']")!==null}function oA(){const e=window.getSelection();return e===null?!1:e.type==="Range"&&e.toString().length>0}function xs(e,t){return e.key===t&&e.shiftKey}function iA(e,t,n={}){const r=t??e,o=n.pageWide===!0,i=p.useCallback(a=>{const l=e.current,c=r.current;if(!l||!c)return;const u=a.target;if(!cu(u)||u!==c)return;const d=lu(l),f=pr(d,0);f!==null&&fr(f)},[e,r]);p.useEffect(()=>{const a=l=>{if(l.altKey||l.ctrlKey||l.metaKey)return;const c=e.current;if(!c)return;const u=l.target;if(!cu(u)||hm(u)||oA())return;const d=c.contains(u);if(d&&uu(u)&&!u.hasAttribute(ro)||!d&&(!o||uu(u)||sA(u)))return;const f=lu(c);if(f.length===0)return;const h=rA(u,c),m=h!==null?f.indexOf(h):-1;let v=!1;switch(l.key){case"ArrowUp":case"W":{if(l.shiftKey&&l.key==="ArrowUp"||l.key==="W"&&!xs(l,"W"))break;l.preventDefault();const g=m>0?m-1:m===-1?f.length-1:-1;if(g!==-1){const x=pr(f,g);x!==null&&fr(x)}v=!0;break}case"ArrowDown":case"S":{if(l.shiftKey&&l.key==="ArrowDown"||l.key==="S"&&!xs(l,"S"))break;l.preventDefault();const g=m<f.length-1?m+1:m===-1?0:-1;if(g!==-1){const x=pr(f,g);x!==null&&fr(x)}v=!0;break}case"ArrowLeft":case"A":{if(l.shiftKey&&l.key==="ArrowLeft"||l.key==="A"&&!xs(l,"A")||h===null)break;if(l.preventDefault(),ci(h)==="collapse")h.click();else if(m>0){const x=pr(f,m-1);x!==null&&fr(x)}v=!0;break}case"ArrowRight":case"D":{if(l.shiftKey&&l.key==="ArrowRight"||l.key==="D"&&!xs(l,"D")||h===null)break;if(l.preventDefault(),ci(h)==="expand")h.click();else if(m<f.length-1){const x=pr(f,m+1);x!==null&&fr(x)}v=!0;break}case" ":{if(h===null)break;l.preventDefault(),ci(h)!==null&&h.click(),v=!0;break}}v&&l.stopPropagation()};return document.addEventListener("keydown",a,{capture:!0}),()=>document.removeEventListener("keydown",a,{capture:!0})},[e,o,r]),p.useEffect(()=>(document.addEventListener("focusin",i),()=>document.removeEventListener("focusin",i)),[i])}const aA={system:"System",user:"User",assistant:"Assistant",tool:"Tool Results",tools:"Tool Definitions"},lA={system:"bg-sky-500/70",user:"bg-emerald-500/70",assistant:"bg-violet-500/70",tool:"bg-sky-400/55",tools:"bg-slate-500/70"},cA={system:"focus-visible:ring-sky-300",user:"focus-visible:ring-emerald-300",assistant:"focus-visible:ring-violet-300",tool:"focus-visible:ring-sky-300",tools:"focus-visible:ring-slate-300"},ui=12,bs=1,du=80,fu=24;function uA(e){return e.length<=fu?e:`${e.slice(0,fu-3)}...`}function dA(e){const t=e.replace(/\s+/g," ").trim();return t.length<=du?t:`${t.slice(0,du)}...`}function vs(e){return e>=10?`${e.toFixed(0)}%`:e>=1?`${e.toFixed(1)}%`:e>0?"<1%":"0%"}const fA=p.memo(function({segments:t,totalTokens:n,showLabels:r=!0,onActivate:o}){const i=p.useMemo(()=>n>0?n:t.reduce((x,b)=>x+b.size,0),[t,n]),a=t.slice(0,ui),l=t.slice(ui),c=l.reduce((x,b)=>x+b.size,0),u=l.length,d=ui,f=d+u-1,h=u>0,m=o!==void 0,v=p.useMemo(()=>a.reduce((x,b)=>x+b.size,0),[a]),g=p.useMemo(()=>`Request context: ~${Be(i)} tokens across ${t.length} segment${t.length===1?"":"s"}`,[t.length,i]);return t.length===0||i<=0?s.jsx("div",{role:"img","aria-label":g,className:"h-6"}):s.jsx(Je,{delayDuration:150,children:s.jsxs("div",{role:"img","aria-label":g,className:"flex flex-col gap-1.5",children:[s.jsxs("div",{className:"relative flex h-6 w-full overflow-hidden rounded border border-border/40 bg-muted/30","data-testid":"anatomy-segment-bar",children:[a.map((x,b)=>{const y=i>0?x.size/i*100:0,_=Math.max(bs,y),j=de("h-full border-r border-background/80 last:border-r-0",m?"opacity-90 hover:opacity-100 focus:opacity-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-offset-background":"opacity-90",lA[x.role],m?cA[x.role]:""),S={width:`${_}%`},T=`${x.label}, ${vs(y)}, ~${Be(x.size)} tokens`;return s.jsxs(Me,{children:[s.jsx(Le,{asChild:!0,children:m?s.jsx("button",{type:"button",role:"button",tabIndex:0,onClick:()=>o(x),onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),o(x))},"data-anatomy-path":x.path,"aria-label":T,className:j,style:S}):s.jsx("span",{"aria-label":T,className:j,style:S})}),s.jsxs(De,{side:"bottom",className:"max-w-sm text-xs p-2 space-y-0.5",children:[s.jsxs("div",{className:"font-semibold",children:[x.label," - ",vs(y)," - ~",Be(x.size)," ","tokens"]}),s.jsx("div",{className:"text-muted-foreground",children:aA[x.role]}),s.jsxs("div",{className:"text-muted-foreground",children:[x.characters.toLocaleString()," chars"]}),x.text.length>0&&s.jsx("div",{className:"text-muted-foreground/90 break-words whitespace-pre-wrap",children:dA(x.text)})]})]},`${x.path}-${b}`)}),h&&s.jsxs(Me,{children:[s.jsx(Le,{asChild:!0,children:s.jsxs("div",{role:"img","aria-label":`${u} additional segments`,className:"flex h-full items-center justify-center bg-muted-foreground/30 px-1.5 text-[10px] font-mono text-background",style:{width:`${Math.max(bs,c/i*100)}%`},children:["... +",u]})}),s.jsxs(De,{side:"bottom",className:"text-xs",children:[u," more segment",u===1?"":"s"," (indices"," ",d,"-",f,")"]})]})]}),r&&s.jsxs("div",{className:"flex w-full gap-1 text-[10px] text-muted-foreground",children:[a.map((x,b)=>{const y=i>0?x.size/i*100:0,_=Math.max(bs,y);return s.jsxs("div",{className:"flex flex-col gap-0.5 truncate",style:{width:`${_}%`},title:`${x.label} - ${vs(y)} - ~${Be(x.size)} tokens`,children:[s.jsx("span",{className:"truncate font-mono text-foreground/80",children:uA(x.label)}),s.jsxs("span",{className:"truncate font-mono text-muted-foreground/70",children:[vs(y)," - ~",Be(x.size)]})]},`label-${x.path}-${b}`)}),h&&s.jsxs("div",{className:"flex flex-col gap-0.5 truncate text-muted-foreground",style:{width:`${Math.max(bs,c/i*100)}%`},children:[s.jsxs("span",{className:"truncate font-mono text-foreground/60",children:["... +",u]}),s.jsxs("span",{className:"truncate font-mono text-muted-foreground/60",children:["~",Be(c)]})]})]}),v<i*.1&&s.jsx("div",{className:"h-0"})]})})}),mm=.75,gm=.9,ea=8e3,pA=.35,xm=40,bm=160,hA=5,mA=8,gA=18,xA=6e4,bA=.7,pu=3e3,vA=.3,hu=160,yA=new Set(["answer","body","content","data","error","message","markdown","output","response","result","stderr","stdout","text","transcript"]),wA=["context_window","contextWindow","context_length","contextLength","max_context_length","maxContextLength","max_input_tokens","maxInputTokens"],kA=["max_tokens","maxTokens","max_completion_tokens","maxCompletionTokens","max_output_tokens","maxOutputTokens"],_A=[{family:"OpenAI GPT-4.1",tokens:1047576,mode:"prefix",patterns:["gpt-4.1"]},{family:"OpenAI GPT-4o",tokens:128e3,mode:"prefix",patterns:["gpt-4o"]},{family:"OpenAI o-series",tokens:128e3,mode:"prefix",patterns:["o1","o3","o4"]},{family:"Anthropic Claude",tokens:2e5,mode:"prefix",patterns:["claude-"]},{family:"DeepSeek V4",tokens:1048576,mode:"prefix",patterns:["deepseek-v4-pro","deepseek-v4-flash"]},{family:"DeepSeek",tokens:64e3,mode:"prefix",patterns:["deepseek-"]},{family:"MiniMax M3",tokens:1048576,mode:"includes",patterns:["minimax-m3"]},{family:"MiniMax M2.7",tokens:204800,mode:"includes",patterns:["minimax-m2.7"]},{family:"MiniMax M2.5/M2.1",tokens:196608,mode:"includes",patterns:["minimax-m2.5","minimax-m2.1"]},{family:"GLM-5.2",tokens:1048576,mode:"prefix",patterns:["glm-5.2"]},{family:"GLM-5",tokens:202752,mode:"prefix",patterns:["glm-5","glm-5.1"]}],jA={system:"System",user:"User messages",assistant:"Assistant messages",tool:"Tool results",tools:"Tool definitions"};function SA(e){if(typeof e=="number")return Number.isFinite(e)&&e>0?Math.floor(e):null;if(typeof e=="string"){const t=Number(e);if(Number.isFinite(t)&&t>0)return Math.floor(t)}return null}function vm(e,t){for(const n of t){const r=SA(ke(e,n));if(r!==null)return r}return null}function CA(e){const t=ke(e,"model");if(typeof t!="string")return null;const n=t.trim();return n===""?null:n}function NA(e,t){switch(t.mode){case"prefix":return t.patterns.some(n=>e.startsWith(n));case"includes":return t.patterns.some(n=>e.includes(n))}}function TA(e,t,n=[]){const r=vm(t,wA);if(r!==null)return{tokens:r,label:"Request metadata",source:"request"};const o=d4(e,n);if(o!==null)return{tokens:o.tokens,label:`${o.providerName} config`,source:"provider"};if(e===null)return{tokens:null,label:"Unknown model",source:"unknown"};const i=e.trim().toLowerCase().replace(/\s+/g,"-");for(const a of _A)if(NA(i,a))return{tokens:a.tokens,label:`${a.family} local rule`,source:"model-rule"};return{tokens:null,label:"No local rule",source:"unknown"}}function EA(e){return e<0?0:e>1?1:e}function AA(e){return e===null?"unknown":e>=gm?"danger":e>=mm?"watch":"ok"}function RA(e,t){return e.filter(n=>n.role===t).reduce((n,r)=>n+r.size,0)}function IA(e,t){return["system","user","assistant","tool","tools"].map(r=>{const o=RA(e,r);return{role:r,label:jA[r],tokens:o,percent:t>0?o/t:0}}).filter(r=>r.tokens>0).sort((r,o)=>o.tokens-r.tokens)}function ta(e){return e.replace(/\s+/g," ").trim().toLowerCase()}function zA(e){const t=e.replace(/\s+/g," ").trim();return t.length<=hu?t:`${t.slice(0,hu-3)}...`}function OA(e){return{role:e.role,label:e.label,path:e.path,tokens:e.tokens,characters:e.characters}}function PA(e){return{role:e.role,label:e.label,path:e.path,tokens:e.size,characters:e.characters,text:e.text}}function MA(e){const t=e.trim();return t.startsWith("{")||t.startsWith("[")}function LA(e){if(!MA(e))return null;try{return JSON.parse(e)}catch{return null}}function DA(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}function $A(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t]??"";if(!(n.startsWith("[")&&n.endsWith("]")))return n}return null}function FA(e){const t=$A(e);return t===null?!1:yA.has(DA(t))}function BA(e){return e.map(t=>t.startsWith("[")?t:`.${t}`).join("").replace(/^\./,"")}function UA(e,t,n){const r=il(t);if(r<bm)return null;const o=ol(t);return o<xm?null:{role:e.role,label:`${e.label} ${BA(n)}`,path:e.path,tokens:o,characters:r,text:t}}function na({value:e,segment:t,path:n,depth:r,candidates:o}){if(!(o.length>=mA)&&!(r>hA)){if(typeof e=="string"){if(!FA(n))return;const i=UA(t,e,n);i!==null&&o.push(i);return}if(Array.isArray(e)){e.forEach((i,a)=>na({value:i,segment:t,path:[...n,`[${String(a)}]`],depth:r+1,candidates:o}));return}al(e)&&Object.entries(e).forEach(([i,a])=>na({value:a,segment:t,path:[...n,i],depth:r+1,candidates:o}))}}function WA(e){const t=PA(e),n=LA(e.text);if(n===null)return[t];const r=[];na({value:n,segment:e,path:[],depth:0,candidates:r});const o=ta(e.text),i=new Set([o]),a=r.filter(l=>{const c=ta(l.text);return c===""||i.has(c)?!1:(i.add(c),!0)});return[t,...a]}function HA(e){const t=new Map;for(const r of e){const o=WA(r);for(const i of o){if(i.tokens<xm||i.characters<bm)continue;const a=ta(i.text);if(a==="")continue;const l=t.get(a);if(l===void 0){t.set(a,{tokens:i.tokens,candidates:[i]});continue}t.set(a,{tokens:l.tokens+i.tokens,candidates:[...l.candidates,i]})}}const n=[];for(const r of t.values()){if(r.candidates.length<2)continue;const o=r.candidates[0]??null;if(o===null)continue;const i=r.tokens-o.tokens;n.push({key:`${o.path}:${o.label}:${String(r.candidates.length)}:${String(r.tokens)}`,count:r.candidates.length,totalTokens:r.tokens,repeatedTokens:i,preview:zA(o.text),firstLabel:o.label,segments:r.candidates.map(OA)})}return n.sort((r,o)=>o.repeatedTokens-r.repeatedTokens||o.totalTokens-r.totalTokens)}function ZA(e){if(e.length===0)return null;const t=e.length,n=e.reduce((o,i)=>o+i.count,0),r=e.reduce((o,i)=>o+i.repeatedTokens,0);return{kind:"duplicate",severity:r>=ea?"danger":"watch",title:"Duplicate context",detail:`${String(n)} repeated blocks across ${String(t)} group${t===1?"":"s"}, ~${String(r)} repeated tokens.`}}function VA(e){return e.reduce((t,n)=>t+n.repeatedTokens,0)}function qA(e,t,n){const r=[],o=e.find(c=>c.role==="tools")??null;o!==null&&(o.tokens>=ea||o.percent>=pA&&o.tokens>=pu)&&r.push({kind:"tool-schema",severity:o.tokens>=ea?"danger":"watch",title:"Large tool schema",detail:`Tool definitions take ${Math.round(o.percent*100)}% of request context.`});const i=e.find(c=>c.role==="system")??null;i!==null&&i.tokens>=pu&&i.percent>=vA&&r.push({kind:"system-heavy",severity:"watch",title:"Large system prompt",detail:`System instructions take ${Math.round(i.percent*100)}% of request context.`});const a=e.filter(c=>c.role==="user"||c.role==="assistant"||c.role==="tool").reduce((c,u)=>c+u.tokens,0),l=t>0?a/t:0;return n>=gA&&(a>=xA||l>=bA)&&r.push({kind:"history-bloat",severity:l>=.85?"danger":"watch",title:"Conversation history growth",detail:`${String(n)} message blocks take ${Math.round(l*100)}% of request context.`}),r}function GA({risk:e,contextWindow:t,diagnostics:n,duplicateGroups:r}){let i=new Set(n.map(c=>c.kind)).size;(e==="watch"||e==="danger")&&(i+=1),t.source==="unknown"&&(i+=1);const a=n.some(c=>c.severity==="danger");return{level:e==="danger"||a?"risk":i>0?"optimizable":"ok",opportunityCount:i,reclaimableTokens:VA(r)}}function KA({segments:e,inputTokens:t,parsed:n,model:r,providers:o=[]}){const i=e.reduce((T,C)=>T+C.size,0),a=r??CA(n),l=t??i,c=vm(n,kA),u=TA(a,n,o),d=c??0,f=u.tokens===null?null:l+d,h=u.tokens===null?null:u.tokens-l,m=u.tokens===null?null:u.tokens-l-d,v=u.tokens===null||f===null?null:EA(f/u.tokens),g=IA(e,i),x=g[0]??null,b=e.filter(T=>T.role!=="tools").length,y=HA(e),_=ZA(y),j=qA(g,i,b);_!==null&&j.unshift(_);const S=AA(v);return{model:a,contextWindow:u,estimatedInputTokens:l,outputReserveTokens:c,windowUsedTokens:f,remainingInputTokens:h,remainingAfterReserveTokens:m,usagePercent:v,riskLevel:S,roleUsages:g,largestRole:x,diagnostics:j,duplicateGroups:y,health:GA({risk:S,contextWindow:u,diagnostics:j,duplicateGroups:y})}}const QR={watch:mm,danger:gm},mu=new WeakMap;function JA(e){return e.map(t=>{const n=t.modelMetadata?.map(r=>`${r.model}:${String(r.contextWindow??"")}`).join(",")??"";return`${t.id}:${t.updatedAt}:${t.models.join(",")}:${n}`}).join("|")}function YA(e){if(e===null)return null;try{return JSON.parse(e)}catch{return null}}function XA(e){return{role:e.role,label:e.label,size:e.tokens,characters:e.tokens*4,text:"",path:`role:${e.role}`}}function QA(e,t){const n=YA(e.rawRequestBody);if(n===null)return null;const o=Ah(Nr(e)).anatomySegments(n);if(o===null)return null;const i=KA({segments:o,inputTokens:e.inputTokens??null,parsed:n,model:e.model,providers:t}),a=i.model??e.model??"Unknown model",l=i.roleUsages.map(XA);return{logId:e.id,model:a,timestamp:e.timestamp,contextWindow:i.contextWindow,estimatedInputTokens:i.estimatedInputTokens,windowUsedTokens:i.windowUsedTokens,usagePercent:i.usagePercent,riskLevel:i.riskLevel,health:i.health,diagnostics:i.diagnostics.map(c=>c.title),roleSegments:l,roleTotalTokens:l.reduce((c,u)=>c+u.size,0)}}function eR(e,t,n){const r=mu.get(e);if(r!==void 0&&r.id===e.id&&r.rawRequestBody===e.rawRequestBody&&r.inputTokens===e.inputTokens&&r.model===e.model&&r.path===e.path&&r.apiFormat===e.apiFormat&&r.timestamp===e.timestamp&&r.providersSignature===n)return r.snapshot;const o=QA(e,t);return mu.set(e,{id:e.id,rawRequestBody:e.rawRequestBody,inputTokens:e.inputTokens,model:e.model,path:e.path,apiFormat:e.apiFormat,timestamp:e.timestamp,providersSignature:n,snapshot:o}),o}function tR(e,t){return e.usagePercent!==null&&t.usagePercent!==null?e.usagePercent>t.usagePercent:e.usagePercent!==null&&t.usagePercent===null?!0:e.usagePercent===null&&t.usagePercent!==null?!1:e.estimatedInputTokens>t.estimatedInputTokens}function gu(e){switch(e){case"danger":return 4;case"watch":return 3;case"unknown":return 2;case"ok":return 1}}function nR(e,t){const n=gu(t.latest.riskLevel)-gu(e.latest.riskLevel);if(n!==0)return n;const r=e.peak.usagePercent??-1,i=(t.peak.usagePercent??-1)-r;return i!==0?i:t.latest.logId-e.latest.logId}function rR(e,t){return e.usagePercent===null||t.usagePercent===null?null:(t.usagePercent-e.usagePercent)*100}function sR(e){for(let t=1;t<e.length;t++){const n=e[t-1],r=e[t];if(!(n===void 0||r===void 0)&&n.id>r.id)return[...e].sort((o,i)=>o.id-i.id)}return e}function oR(e,t=[]){const n=sR(e),r=JA(t),o=new Map;for(const a of n){const l=eR(a,t,r);if(l===null)continue;const c=o.get(l.model);if(c===void 0){o.set(l.model,{model:l.model,requestCount:1,first:l,latest:l,peak:l});continue}o.set(l.model,{model:c.model,requestCount:c.requestCount+1,first:c.first,latest:l,peak:tR(l,c.peak)?l:c.peak})}return{models:[...o.values()].map(a=>({model:a.model,requestCount:a.requestCount,first:a.first,latest:a.latest,peak:a.peak,trendPercent:rR(a.first,a.latest)})).sort(nR)}}function Xt(e){return e.length<=30?e:`${e.slice(0,12)}...${e.slice(-12)}`}function iR(e){const t=new Map;for(const n of e)for(let r=0;r<n.logs.length;r+=1){const o=n.logs[r];o!==void 0&&t.set(o.id,r+1)}return t}function xu(e,t){return t.get(e.id)??e.id}function aR(e){return e==="full"}function lR(e,t){const n=t>0;return{redacted:n,raw:n&&aR(e)}}function bu(e){let t=0,n=0;for(const r of e)r.inputTokens!==null&&(t+=r.inputTokens),r.outputTokens!==null&&(n+=r.outputTokens);return{totalIn:t,totalOut:n}}function ym(e,t){const n=e[0],r=e[e.length-1];return n===void 0||r===void 0?null:Ea(n.timestamp,r.timestamp,t)}function cR(e){for(const t of e)if(t.userAgent!==null&&t.userAgent!==void 0&&t.userAgent!=="")return t.userAgent;return null}function uR(e){return e.error!==null&&e.error!==void 0&&e.error.length>0?!0:e.responseStatus!==null&&e.responseStatus>=400}function dR(e){const t=new Set;for(const r of e)r.model!==null&&r.model.length>0&&t.add(r.model);const n=[...t].sort();return n.length===0?"Model unknown":n.length===1?n[0]??"Model unknown":`${n.length} models`}function fR({logs:e,isLoading:t,timeDisplayFormat:n,slowResponseThresholdSeconds:r}){let o=0,i=0,a=0,l=0;const c=r*1e3;for(const f of e)uR(f)&&(o+=1),r>0&&f.elapsedMs!==null&&f.elapsedMs>=c&&(i+=1),f.inputTokens!==null&&(a+=f.inputTokens),f.outputTokens!==null&&(l+=f.outputTokens);const u=t?"rolling":o>0?"failed":i>0?"watch":"clear";return{status:u,statusLabel:u==="rolling"?"Rolling":u==="failed"?"Failure":u==="watch"?"Watch":"Clear",modelLabel:dR(e),requests:e.length,failures:o,slow:i,timeRange:ym(e,n),tokenLabel:`${Be(a)} in / ${Be(l)} out`}}function pR(e){switch(e){case"rolling":return"border-cyan-400/35 bg-cyan-500/10 text-cyan-200";case"failed":return"border-red-400/35 bg-red-500/10 text-red-100";case"watch":return"border-amber-300/35 bg-amber-400/10 text-amber-100";case"clear":return"border-emerald-400/30 bg-emerald-500/10 text-emerald-100"}}function hR({stats:e}){return e.requests===0?null:s.jsx("div",{className:"mb-4 rounded-md border border-border bg-[#0c0d0f] shadow-[0_14px_50px_rgba(0,0,0,0.25)]",children:s.jsxs("div",{className:"grid grid-cols-2 gap-0 md:grid-cols-[minmax(220px,1.2fr)_repeat(4,minmax(120px,1fr))]",children:[s.jsxs("div",{className:"col-span-2 border-b border-border/70 px-4 py-3 md:col-span-1 md:border-b-0 md:border-r",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-semibold uppercase text-muted-foreground",children:[s.jsx(ny,{className:"size-3.5 text-cyan-300"}),"Opening Slate"]}),s.jsx("div",{className:"mt-2 min-w-0 truncate font-mono text-sm font-semibold text-foreground",children:e.modelLabel}),s.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-muted-foreground",children:e.timeRange??"Timeline pending"})]}),s.jsxs("div",{className:"border-r border-b border-border/70 px-4 py-3 md:border-b-0",children:[s.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Status"}),s.jsx("div",{className:de("mt-2 inline-flex h-7 items-center rounded-md border px-2.5 font-mono text-xs font-semibold",pR(e.status)),children:e.statusLabel})]}),s.jsxs("div",{className:"border-b border-border/70 px-4 py-3 md:border-b-0 md:border-r",children:[s.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Requests"}),s.jsx("div",{className:"mt-2 font-mono text-xl font-semibold text-foreground",children:e.requests})]}),s.jsxs("div",{className:"border-r border-border/70 px-4 py-3 md:border-r",children:[s.jsxs("div",{className:"flex items-center gap-1 text-[10px] uppercase text-muted-foreground",children:[s.jsx(yi,{className:"size-3 text-red-300"}),"Failure"]}),s.jsx("div",{className:"mt-2 font-mono text-xl font-semibold text-red-100",children:e.failures})]}),s.jsxs("div",{className:"px-4 py-3",children:[s.jsxs("div",{className:"flex items-center gap-1 text-[10px] uppercase text-muted-foreground",children:[s.jsx(Ca,{className:"size-3 text-amber-200"}),"Tempo"]}),s.jsxs("div",{className:"mt-2 font-mono text-sm font-semibold text-foreground",children:[e.slow," slow"]}),s.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-muted-foreground",children:e.tokenLabel})]})]})})}function mR({pinnedSessionId:e,selectedSession:t,sessions:n,logs:r}){if(e!==void 0){const a=r.filter(l=>l.sessionId===e);return a.length===0?null:{label:e,logs:a,showBackLink:!0}}if(t!=="__all__"){const a=r.filter(l=>l.sessionId===t);return a.length===0?null:{label:t,logs:a,showBackLink:!0}}const o=n.length===1?n[0]??null:null;return o!==null&&r.every(l=>l.sessionId===o)?{label:o,logs:[...r],showBackLink:!1}:n.length===0&&r.length>0&&r.every(a=>a.sessionId===null)?{label:"Visible requests",logs:[...r],showBackLink:!1}:null}function vr(e){if(e===null)return"Unknown";const t=e*100;return t>=10?`${t.toFixed(0)}%`:t>=1?`${t.toFixed(1)}%`:t>0?"<1%":"0%"}function gR(e){return e===null?"n/a":Math.abs(e)<.1?"0%":`${e>0?"+":""}${e.toFixed(1)}%`}function ra(e){return e===null||!Number.isFinite(e)?0:Math.min(Math.max(e*100,0),100)}function xR(e,t){if(t===null)return null;const n=ra(e),r=ra(t);return r<=0||Math.abs(r-n)<.5?null:r}function bR(e){switch(e){case"danger":return"bg-red-400";case"watch":return"bg-amber-300";case"unknown":return"bg-muted-foreground/50";case"ok":return"bg-emerald-400"}}function vR(e){const t=e.latest.contextWindow.tokens;return t===null?"Context window unknown":`Context window ${ef(t)}`}const yR=["score","decision","final_status","validation_pass_ratio","semantic_memory_score","opencode_exit","actual_model","run_dir","workspace","project_dir","work_dir"];function wm(e){return typeof e=="string"?e.length>0?e:null:typeof e=="number"||typeof e=="boolean"?String(e):e===null?null:JSON.stringify(e)}function di(e,t){if(e===null)return null;const n=e.metadata[t];return n===void 0?null:wm(n)}function wR(e){const t=e.toLowerCase();return t.includes("reject")||t.includes("fail")||t.includes("error")?"border-red-400/35 bg-red-500/10 text-red-100":t.includes("partial")||t.includes("pending")||t.includes("slow")?"border-amber-300/35 bg-amber-400/10 text-amber-100":t.includes("pass")||t.includes("complete")||t.includes("accept")?"border-emerald-400/30 bg-emerald-500/10 text-emerald-100":"border-border/70 bg-background/70 text-muted-foreground"}function kR(e){const t=[];for(const n of yR){const r=e.metadata[n];if(r===void 0)continue;const o=wm(r);o!==null&&t.push({key:n,value:o})}return t}function vu({memberships:e,defaultOpen:t=!1}){const[n,r]=p.useState(t);if(e.length===0)return null;const o=e[0],i=o?.member??null,a=di(i,"score"),l=di(i,"decision"),c=di(i,"final_status"),u=[a===null?null:{label:`score ${a}`,value:a},l===null?null:{label:l,value:l},c===null?null:{label:c,value:c},i?.model===null||i?.model===void 0?null:{label:i.model,value:i.model}].filter(d=>d!==null&&d.label.length>0&&d.value.length>0);return s.jsxs("div",{className:"mb-3 overflow-hidden rounded-md border border-border bg-[#0c0d0f] text-xs",children:[s.jsxs("button",{type:"button",onClick:()=>r(d=>!d),className:"flex w-full items-center gap-3 px-3 py-2 text-left transition-colors hover:bg-muted/30","aria-expanded":n,children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsx("span",{className:"font-semibold text-foreground",children:"Case File"}),o!==void 0&&s.jsx("span",{className:"truncate text-muted-foreground",title:o.groupTitle,children:o.groupTitle}),s.jsxs("span",{className:"font-mono text-[10px] uppercase text-muted-foreground",children:[e.length," group",e.length===1?"":"s"]})]}),u.length>0&&s.jsx("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:u.slice(0,4).map(d=>s.jsx("span",{className:de("rounded border px-1.5 py-0.5 font-mono text-[10px]",wR(d.value)),children:d.label},d.label))})]}),n?s.jsx(ka,{className:"size-4 shrink-0 text-muted-foreground"}):s.jsx(ct,{className:"size-4 shrink-0 text-muted-foreground"})]}),n&&s.jsx("div",{className:"space-y-2 border-t border-border/70 px-3 py-2",children:e.map(d=>{const f=d.member,h=kR(f);return s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsx("span",{className:"truncate font-medium text-foreground",title:d.groupTitle,children:d.groupTitle}),s.jsx("span",{className:"font-mono text-[10px] uppercase text-muted-foreground",children:d.groupStatus}),f.status!==null&&s.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["member ",f.status]})]}),s.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-muted-foreground",children:[s.jsx("span",{className:"font-mono",title:f.sessionId,children:Xt(f.sessionId)}),f.label!==null&&s.jsx("span",{children:f.label}),f.provider!==null&&s.jsx("span",{children:f.provider}),f.model!==null&&s.jsx("span",{className:"font-mono",children:f.model}),f.runId!==null&&s.jsxs("span",{className:"font-mono",title:f.runId,children:["run ",Xt(f.runId)]})]}),h.length>0&&s.jsx("div",{className:"mt-2 grid gap-1 sm:grid-cols-2 xl:grid-cols-3",children:h.map(m=>s.jsxs("div",{className:"min-w-0 rounded border border-border/60 px-2 py-1",children:[s.jsx("div",{className:"font-mono text-[10px] text-muted-foreground",children:m.key}),s.jsx("div",{className:"truncate font-mono text-[11px] text-foreground",title:m.value,children:m.value})]},m.key))})]},`${d.groupId}:${f.id}`)})})]})}function _R({logs:e,pagination:t}){if(t.isLoading&&e.length===0)return"Loading logs...";if(e.length===0)return"No logs on this page";const n=e[0],r=e[e.length-1],o=n===void 0||r===void 0?"Current page":`#${n.id}-#${r.id}`,i=t.total===null?"logs":`${t.total} logs`;return`Showing ${o} of ${i}`}function ys({label:e,title:t,icon:n,disabled:r,onClick:o}){return s.jsxs("button",{type:"button",onClick:o,disabled:r,className:"inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-45",title:t,children:[n,s.jsx("span",{children:e})]})}function yu({logs:e,pagination:t,embedded:n=!1}){if(t===void 0)return null;const r=t.isLoading;return s.jsxs("div",{className:de("flex min-h-9 flex-col gap-2 px-1 py-1 sm:flex-row sm:items-center",n?"border-t border-border/70 pt-2":"mb-3 rounded-md border border-border bg-muted/10 px-2"),children:[s.jsxs("div",{className:"w-full min-w-0 px-1 font-mono text-[11px] text-muted-foreground sm:flex-1",children:[_R({logs:e,pagination:t}),t.isLoading&&e.length>0&&s.jsx("span",{className:"ml-2",children:"Loading..."})]}),s.jsxs("div",{className:"flex w-full items-center gap-1 overflow-x-auto sm:w-auto",children:[s.jsx(ys,{label:"Oldest",title:"Load the oldest logs in this session",icon:s.jsx(W1,{className:"size-3.5"}),disabled:r||!t.hasOlder,onClick:t.onOldest}),s.jsx(ys,{label:"Older",title:"Load older logs",icon:s.jsx(L1,{className:"size-3.5"}),disabled:r||!t.hasOlder,onClick:t.onOlder}),s.jsx(ys,{label:"Newer",title:"Load newer logs",icon:s.jsx(Ot,{className:"size-3.5"}),disabled:r||!t.hasNewer,onClick:t.onNewer}),s.jsx(ys,{label:"Newest",title:"Load the newest logs in this session",icon:s.jsx(Z1,{className:"size-3.5"}),disabled:r||!t.hasNewer,onClick:t.onNewest})]})]})}function jR(e){return`${e} ${e===1?"request":"requests"}`}function wu(e){return`#${String(e)}`}function ku(e){switch(e){case"danger":return"text-red-300";case"watch":return"text-amber-200";case"unknown":return"text-muted-foreground";case"ok":return"text-emerald-300"}}function SR(e){switch(e){case"risk":return"border-red-400/30 bg-red-500/10 text-red-100";case"optimizable":return"border-amber-400/25 bg-amber-400/8 text-amber-100";case"ok":return"border-emerald-400/25 bg-emerald-400/8 text-emerald-100"}}function CR(e){switch(e){case"risk":return"Risk";case"optimizable":return"Optimizable";case"ok":return"OK"}}const NR=10,TR=80;function ER(e){e.setAttribute("data-deep-link-highlight","true"),window.setTimeout(()=>{e.removeAttribute("data-deep-link-highlight")},1800)}function AR(e){const t=document.getElementById(`log-${String(e)}`);return t instanceof HTMLElement?(t.scrollIntoView({block:"center",behavior:"smooth"}),t.focus({preventScroll:!0}),ER(t),!0):!1}function km(e){Vs({logId:e,tab:"anatomy"});let t=0;const n=()=>{Vs({logId:e,tab:"anatomy"}),!AR(e)&&(t+=1,t<NR&&window.setTimeout(n,TR))};window.setTimeout(n,0)}function _u({command:e}){const[t,n]=p.useState(!1),r=p.useCallback(()=>{Ht(e).then(o=>{o&&(n(!0),setTimeout(()=>n(!1),2e3))})},[e]);return s.jsxs("div",{className:"inline-flex items-center gap-2 bg-muted rounded-md px-3 py-2",children:[s.jsx("pre",{className:"text-blue-500 font-mono text-sm m-0",children:e}),s.jsx("button",{type:"button",onClick:r,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0 cursor-pointer","aria-label":"Copy command",children:t?s.jsx(Ge,{className:"size-4"}):s.jsx(St,{className:"size-4"})})]})}function ju(){return s.jsx(Je,{children:s.jsxs(Me,{children:[s.jsx(Le,{asChild:!0,children:s.jsxs("span",{className:"inline-flex h-7 items-center gap-2 rounded-md border border-cyan-400/30 bg-cyan-500/10 px-2.5 font-mono text-[11px] font-medium text-cyan-300 shadow-[0_0_16px_rgba(34,211,238,0.08)]",children:[s.jsx("span",{className:"size-1.5 rounded-full bg-emerald-300 shadow-[0_0_8px_rgba(110,231,183,0.8)]"}),"MCP Ready",s.jsx("span",{className:"hidden text-cyan-200/70 sm:inline",children:"/api/mcp"})]})}),s.jsx(De,{sideOffset:8,className:"max-w-[320px] text-left leading-relaxed",children:"Coding agents can inspect logs, replay requests, test providers, and debug sessions through MCP at /api/mcp."})]})})}const RR=["text-amber-500","text-rose-500","text-sky-500","text-emerald-500","text-violet-500","text-orange-500","text-cyan-500","text-pink-500","text-lime-500","text-blue-500","text-yellow-500","text-fuchsia-500"];function Su({compact:e,entrancePhase:t}){return e?s.jsx(Fc,{className:"size-7 text-amber-500"}):s.jsxs("span",{className:"flex shrink-0 items-end gap-1 group cursor-default","aria-hidden":"true",children:[s.jsx(Fc,{className:"size-10 text-amber-500 transition-all duration-300 group-hover:scale-125 group-hover:-translate-y-1.5"}),s.jsx("span",{className:"hidden items-end gap-0.5 sm:flex",children:Er.map((n,r)=>{const o=RR[r]??"text-amber-500",i=t==="hidden"?"opacity-0 scale-0":t==="playing"?"animate-crab-piano-pop":"";return s.jsx(n,{className:`size-5 ${o} transition-all duration-300 ease-out group-hover:scale-125 group-hover:-translate-y-1 ${i}`,style:{transitionDelay:`${r*50}ms`,...t==="playing"?{animationDelay:`${r*400}ms`}:{}}},r)})})]})}function IR({compact:e,crabEntrancePhase:t}){return e?s.jsxs("div",{className:"pb-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[s.jsx(Su,{compact:!0,entrancePhase:t}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[s.jsx("span",{className:"truncate text-base font-bold",children:"Inspector"}),s.jsxs("span",{className:"hidden shrink-0 font-mono text-[11px] font-semibold text-muted-foreground sm:inline",children:["v",ki.version]})]}),s.jsx("div",{className:"hidden text-[11px] font-semibold text-muted-foreground sm:block",children:"Local First. Evidence First."})]})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.jsx(Bc,{}),s.jsx(Wc,{}),s.jsx(iu,{})]})]}),s.jsx("div",{className:"mt-2 hidden sm:block",children:s.jsx(ju,{})})]}):s.jsxs("div",{className:"grid grid-cols-[1fr_auto_1fr] items-start gap-3 pb-6",children:[s.jsx("div",{}),s.jsxs("h1",{className:"flex min-w-0 flex-col items-center gap-2 text-center",children:[s.jsxs("span",{className:"flex max-w-[calc(100vw-7rem)] items-end gap-2 whitespace-nowrap",children:[s.jsx(Su,{compact:!1,entrancePhase:t}),s.jsxs("span",{className:"flex min-w-0 items-baseline gap-2 pl-1",children:[s.jsx("span",{className:"truncate text-lg font-bold",children:"Agent Inspector"}),s.jsxs("span",{className:"shrink-0 font-mono text-xs font-semibold text-muted-foreground",children:["v",ki.version]})]}),s.jsx(bi,{className:"size-4 shrink-0 text-muted-foreground/70","aria-hidden":"true"}),s.jsx(QT,{className:"size-10 shrink-0"})]}),s.jsx("span",{className:"max-w-[calc(100vw-7rem)] text-sm font-semibold text-muted-foreground",children:"Local First. Evidence First."}),s.jsx(ju,{})]}),s.jsxs("div",{className:"justify-self-end flex items-center gap-1",children:[s.jsx(Bc,{}),s.jsx(Wc,{}),s.jsx(iu,{})]})]})}function Cu({label:e,logId:t}){return s.jsxs("button",{type:"button",onClick:()=>km(t),className:"inline-flex h-5 items-center rounded px-1 font-mono text-[10px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",title:`Open Context for ${wu(t)}`,children:[e," ",wu(t)]})}function zR({latestPercent:e,peakPercent:t,risk:n,onOpenContext:r}){const o=ra(e),i=xR(e,t),a=t===null?`Latest context window usage ${vr(e)}`:`Latest context window usage ${vr(e)}, peak ${vr(t)}`;return s.jsx("button",{type:"button",onClick:r,className:"group block w-full rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1","aria-label":`${a}. Open latest Context details`,title:"Open latest Context details",children:s.jsxs("span",{className:"relative block h-2.5 overflow-hidden rounded-full border border-border/70 bg-background transition-colors group-hover:border-foreground/30",role:"meter","aria-label":a,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(o),children:[s.jsx("span",{className:de("block h-full rounded-full transition-[width]",bR(n)),style:{width:`${o}%`}}),i!==null&&s.jsx("span",{className:"absolute top-0 h-full w-0.5 rounded-full bg-amber-100/75 shadow-[0_0_0_1px_rgba(0,0,0,0.25)]",style:{left:`calc(${i}% - 0.5px)`},"aria-hidden":"true"})]})})}function OR({summary:e}){const t=e.trendPercent,n=t===null||Math.abs(t)<.1?null:t>0?C1:y1,r=e.latest.diagnostics[0]??null,o=vr(e.latest.usagePercent),i=vr(e.peak.usagePercent),a=()=>{km(e.latest.logId)};return s.jsxs("div",{className:"grid gap-x-4 gap-y-2 border-t border-border/60 py-2 first:border-t-0 lg:grid-cols-[minmax(180px,1fr)_minmax(260px,1fr)_minmax(260px,1.4fr)]",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("button",{type:"button",onClick:a,className:"min-w-0 truncate rounded-sm text-left font-mono font-semibold text-foreground transition-colors hover:text-cyan-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",title:`Open latest Context for ${e.model}`,children:e.model}),s.jsx("span",{className:de("inline-flex h-5 shrink-0 items-center rounded border px-1.5 font-mono text-[10px]",SR(e.latest.health.level)),children:CR(e.latest.health.level)})]}),s.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:jR(e.requestCount)}),s.jsx("span",{children:vR(e)})]})]}),s.jsxs("div",{className:"min-w-0 space-y-2 text-xs",children:[s.jsx(zR,{latestPercent:e.latest.usagePercent,peakPercent:e.peak.usagePercent,risk:e.latest.riskLevel,onOpenContext:a}),s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Latest"}),s.jsx("div",{className:de("mt-0.5 font-mono",ku(e.latest.riskLevel)),children:o}),s.jsx(Cu,{label:"Log",logId:e.latest.logId})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Peak"}),s.jsx("div",{className:de("mt-0.5 font-mono",ku(e.peak.riskLevel)),children:i}),s.jsx(Cu,{label:"Log",logId:e.peak.logId})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Trend"}),s.jsxs("div",{className:"mt-0.5 flex items-center gap-1 font-mono text-foreground",children:[n!==null&&s.jsx(n,{className:de("size-3",t!==null&&t>0?"text-amber-300":"text-emerald-300")}),gR(t)]}),s.jsx("div",{className:"h-5","aria-hidden":"true"})]})]})]}),s.jsxs("div",{className:"min-w-0 space-y-1.5",children:[s.jsx(fA,{segments:e.latest.roleSegments,totalTokens:e.latest.roleTotalTokens,showLabels:!1}),s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground",children:[s.jsxs("span",{className:"font-mono",children:["~",Be(e.latest.estimatedInputTokens)," input"]}),e.latest.windowUsedTokens!==null&&s.jsxs("span",{className:"font-mono",children:["~",Be(e.latest.windowUsedTokens)," used"]}),r!==null&&s.jsx("span",{className:"truncate",children:r})]})]})]})}function PR({summary:e}){return e.models.length===0?null:s.jsxs("div",{className:"mt-3 border-t border-border/70 pt-2",children:[s.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-normal text-muted-foreground",children:"Session Context"}),s.jsxs("div",{className:"font-mono text-[10px] text-muted-foreground",children:[e.models.length," model",e.models.length===1?"":"s"]})]}),s.jsx("div",{className:"max-h-52 overflow-y-auto pr-1",children:e.models.map(t=>s.jsx(OR,{summary:t},t.model))})]})}function MR(e){const t=e.models.filter(r=>r.latest.health.level==="risk").length;if(t>0)return`${t} risk`;const n=e.models.filter(r=>r.latest.health.level==="optimizable").length;return n>0?`${n} optimizable`:`${e.models.length} model${e.models.length===1?"":"s"}`}function LR({label:e,logs:t,totalIn:n,totalOut:r,timeDisplayFormat:o,contextSummary:i,showBackLink:a}){const[l,c]=p.useState(!1),[u,d]=p.useState(!1),f=p.useMemo(()=>ym(t,o),[t,o]),h=p.useMemo(()=>cR(t),[t]),m=p.useMemo(()=>MR(i),[i]),v=p.useCallback(()=>{Ht(window.location.href).then(g=>{g&&(c(!0),setTimeout(()=>c(!1),2e3))})},[]);return s.jsxs("div",{className:"mb-3 rounded-md border border-border bg-muted/15 px-3 py-2 text-xs",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a&&s.jsx("a",{href:"/",className:"inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground","aria-label":"Back to all sessions",title:"Back to all sessions",children:s.jsx(j1,{className:"size-3.5"})}),s.jsxs("div",{className:"min-w-[180px] flex-1",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:"font-mono font-semibold text-purple-400/90 truncate",title:e,children:Xt(e)}),h!==null&&s.jsx("span",{className:"font-mono text-muted-foreground truncate max-w-[220px]",title:h,children:h})]}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-muted-foreground",children:[s.jsxs("span",{children:[t.length," request",t.length!==1?"s":""]}),f!==null&&s.jsx("span",{children:f}),(n>0||r>0)&&s.jsxs("span",{className:"font-mono",children:[Be(n)," in / ",Be(r)," out"]})]})]}),i.models.length>0&&s.jsxs("button",{type:"button",onClick:()=>d(g=>!g),className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-border bg-background/60 px-2.5 font-mono text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground","aria-expanded":u,title:u?"Hide context details":"Show context details",children:[s.jsx("span",{children:m}),u?s.jsx(ka,{className:"size-3.5"}):s.jsx(ct,{className:"size-3.5"})]}),s.jsx("button",{type:"button",onClick:v,className:"inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground","aria-label":l?"Copied session link":"Copy session link",title:l?"Copied session link":"Copy session link",children:l?s.jsx(Ge,{className:"size-3.5"}):s.jsx(St,{className:"size-3.5"})})]}),u&&s.jsx(PR,{summary:i})]})}function DR({logs:e,sessions:t,models:n,selectedSession:r,selectedModel:o,onSessionChange:i,onModelChange:a,onClearAll:l,onClearGroup:c,onImportLogs:u,viewMode:d,captureMode:f,strip:h,slowResponseThresholdSeconds:m,timeDisplayFormat:v,isLoading:g=!1,pagination:x,sessionMemberships:b=[],hideSessionFilter:y=!1,pinnedSessionId:_}){const{totalIn:j,totalOut:S}=p.useMemo(()=>bu(e),[e]),{providers:T}=tf(),[C,A]=p.useState(null),[E,P]=p.useState(null),[J,R]=p.useState(!1),[F,k]=p.useState(null),[M,Y]=p.useState(null),[D,B]=p.useState(null),[U,ie]=p.useState("hidden"),W=p.useRef(null),H=p.useRef(null),ue=p.useRef(null);iA(W,H,{pageWide:!0}),p.useEffect(()=>{const L=50+Er.length*400,Q=setTimeout(()=>ie("playing"),50),fe=setTimeout(()=>ie("done"),L);return()=>{clearTimeout(Q),clearTimeout(fe)}},[]),p.useEffect(()=>{if(_===void 0){document.title="Agent Inspector";return}const te=e.length===1?"1 req":`${e.length} req`;document.title=`${Xt(_)} - ${te} - Agent Inspector`},[e.length,_]);const ne=p.useCallback(async te=>{A(te),P(null);try{const O=await q2(e,te);O.ok||P(O.message)}finally{A(null)}},[e]),se=p.useCallback(()=>{ue.current?.click()},[]),je=p.useCallback(te=>{const O=te.currentTarget.files?.[0];te.currentTarget.value="",!(O===void 0||u===void 0)&&(R(!0),Y(null),k(null),u(O).then(L=>{const Q=L.skipped>0?`, skipped ${String(L.skipped)}`:"";k(`Imported ${String(L.imported)} logs as ${L.sessionId}${Q}.`)}).catch(L=>{Y(L instanceof Error?L.message:"Failed to import logs")}).finally(()=>{R(!1)}))},[u]);p.useEffect(()=>{B(null)},[r,o]);const ce=p.useCallback(()=>{B(null)},[]),me=p.useMemo(()=>oN(e),[e]),le=p.useMemo(()=>iR(me),[me]),ae=p.useMemo(()=>mR({pinnedSessionId:_,selectedSession:r,sessions:t,logs:e}),[e,_,r,t]),re=ae?.logs??[],pe=ae!==null&&re.length>0,{totalIn:ye,totalOut:w}=p.useMemo(()=>bu(re),[re]),K=p.useMemo(()=>oR(re,T),[re,T]),V=p.useMemo(()=>K4(me),[me]),z=p.useMemo(()=>uT(me),[me]),I=lR(f,e.length),$=_!==void 0,ee=pe&&ae!==null?Xt(ae.label):r==="__all__"?"All sessions":Xt(r),oe=p.useMemo(()=>fR({logs:e,isLoading:g,timeDisplayFormat:v,slowResponseThresholdSeconds:m}),[g,e,m,v]),Z=p.useCallback(te=>{const O=z.get(te.id);O!==void 0&&B([O,te])},[z]);return s.jsxs("div",{className:"min-h-screen w-full bg-[#070809] text-foreground",children:[s.jsxs("div",{className:"grid min-h-screen w-full grid-cols-1 lg:grid-cols-[340px_minmax(0,1fr)] xl:grid-cols-[360px_minmax(0,1fr)]",children:[s.jsx("aside",{className:"border-b border-border bg-[#090a0c] lg:sticky lg:top-0 lg:h-screen lg:overflow-y-auto lg:border-b-0 lg:border-r",children:s.jsxs("div",{className:"space-y-4 p-4",children:[s.jsx(IR,{compact:!0,crabEntrancePhase:U}),s.jsxs("div",{className:"grid grid-cols-3 gap-2 border-y border-border/70 py-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"font-mono text-lg font-semibold text-foreground",children:e.length}),s.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Requests"})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"font-mono text-lg font-semibold text-foreground",children:Be(pe?ye:j)}),s.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Input"})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"font-mono text-lg font-semibold text-foreground",children:Be(pe?w:S)}),s.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Output"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-normal text-muted-foreground",children:"Workspace"}),s.jsxs("div",{className:"rounded-md border border-border bg-[#0c0d0f] px-3 py-2",children:[s.jsx("div",{className:"font-mono text-xs font-semibold text-purple-300",title:ee,children:ee}),s.jsx("div",{className:"mt-1 text-[11px] text-muted-foreground",children:$?"Session workspace":"Live workspace"})]})]}),pe&&ae!==null&&s.jsx(LR,{label:ae.label,logs:re,totalIn:ye,totalOut:w,timeDisplayFormat:v,contextSummary:K,showBackLink:ae.showBackLink}),pe&&_!==void 0&&b.length>0&&s.jsx(vu,{memberships:b}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-normal text-muted-foreground",children:"Filters"}),!y&&s.jsxs(Ys,{value:r,onValueChange:i,children:[s.jsx(Qs,{className:"h-9 w-full text-xs",children:s.jsx(Xs,{placeholder:"All sessions"})}),s.jsxs(eo,{children:[s.jsx(Nt,{value:"__all__",children:"All sessions"}),t.map(te=>s.jsx(Nt,{value:te,children:Xt(te)},te))]})]}),s.jsxs(Ys,{value:o,onValueChange:a,children:[s.jsx(Qs,{className:"h-9 w-full text-xs",children:s.jsx(Xs,{placeholder:"All models"})}),s.jsxs(eo,{children:[s.jsx(Nt,{value:"__all__",children:"All models"}),n.map(te=>s.jsx(Nt,{value:te,children:te},te))]})]})]})]})}),s.jsxs("main",{className:"min-w-0",children:[s.jsxs("div",{className:"sticky top-0 z-30 border-b border-border bg-[#08090b]/95 px-4 py-3 shadow-[0_12px_40px_rgba(0,0,0,0.24)] backdrop-blur lg:px-5",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("div",{className:"min-w-[180px] flex-1",children:[s.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Logs"}),s.jsx("div",{className:"mt-0.5 font-mono text-[11px] text-muted-foreground",children:ee})]}),u!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("input",{ref:ue,type:"file",accept:".zip,.json,.jsonl,application/zip,application/json",className:"hidden",onChange:je}),s.jsx("button",{type:"button",onClick:se,disabled:J,className:"inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",title:"Import Agent Inspector export",children:J?s.jsx("span",{children:"Importing..."}):s.jsxs(s.Fragment,{children:[s.jsx(Ld,{className:"size-3.5"}),s.jsx("span",{children:"Import"})]})})]}),I.redacted&&s.jsx("button",{type:"button",onClick:()=>{ne("redacted")},disabled:C!==null,className:"inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",title:"Export redacted logs as JSON ZIP",children:C==="redacted"?s.jsx("span",{children:"Exporting..."}):s.jsxs(s.Fragment,{children:[s.jsx(co,{className:"size-3.5"}),s.jsx("span",{children:"Export"})]})}),I.raw&&s.jsx("button",{type:"button",onClick:()=>{ne("raw")},disabled:C!==null,className:"inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",title:"Export raw logs without redaction",children:C==="raw"?s.jsx("span",{children:"Exporting..."}):s.jsxs(s.Fragment,{children:[s.jsx(yy,{className:"size-3.5"}),s.jsx("span",{children:"Raw"})]})}),s.jsxs("button",{type:"button",onClick:l,className:"inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",title:"Clear all logs",children:[s.jsx(qn,{className:"size-3.5"}),s.jsx("span",{children:"Clear"})]})]}),s.jsx(yu,{logs:e,pagination:x,embedded:!0}),E!==null&&s.jsx("div",{className:"mt-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:E}),M!==null&&s.jsx("div",{className:"mt-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:M}),F!==null&&M===null&&s.jsx("div",{className:"mt-2 rounded-md border border-emerald-500/25 bg-emerald-500/10 px-3 py-2 text-xs text-emerald-200",children:F})]}),s.jsxs("div",{className:"px-4 py-4 lg:px-5",children:[s.jsx(hR,{stats:oe}),e.length===0?r!=="__all__"?s.jsx("div",{className:"py-16 text-center text-muted-foreground",children:s.jsxs("div",{className:"mx-auto max-w-xl space-y-4 rounded-md border border-border bg-muted/10 px-4 py-8",children:[s.jsx("p",{className:"text-sm font-medium",children:g?"Loading session data...":"Session not found"}),s.jsx("p",{className:"inline-block max-w-full rounded bg-muted px-3 py-1 font-mono text-xs break-all",children:Xt(r)}),b.length>0&&s.jsx("div",{className:"text-left",children:s.jsx(vu,{memberships:b})}),!g&&s.jsxs("p",{className:"text-xs",children:["This session may have been cleared or never existed."," ",y?s.jsx("a",{href:"/",className:"underline transition-colors hover:text-foreground",children:"Back to all sessions"}):s.jsx("button",{type:"button",onClick:()=>i("__all__"),className:"underline transition-colors hover:text-foreground",children:"Show all sessions"})]})]})}):s.jsx("div",{className:"py-16 text-center text-muted-foreground",children:s.jsxs("div",{className:"mx-auto max-w-2xl space-y-4 rounded-md border border-border bg-muted/10 px-4 py-8",children:[s.jsx("p",{className:"text-sm",children:"No requests captured yet."}),s.jsxs("div",{className:"flex flex-col items-center gap-2",children:[s.jsx(_u,{command:"ANTHROPIC_BASE_URL=http://localhost:25947/proxy <your-tool>"}),s.jsx(_u,{command:"OPENAI_BASE_URL=http://localhost:25947/proxy <your-tool>"})]}),s.jsx("p",{className:"mx-auto max-w-xl text-xs leading-relaxed text-muted-foreground",children:"Container note: if your AI tool runs in a different container or host than Agent Inspector, replace localhost with an address reachable from that tool and verify the network/firewall path."})]})}):s.jsxs("div",{ref:H,tabIndex:0,className:"flex flex-col gap-2 focus:outline-none",children:[s.jsx("div",{ref:W,children:s.jsx(eA,{groups:me,viewMode:d,strip:h,slowResponseThresholdSeconds:m,cacheTrends:V,onCompareWithPrevious:Z,comparisonPredecessors:z,onClearGroup:c,standalone:me.length===1,hasPinnedSessionContext:pe,timeDisplayFormat:v})}),s.jsx("div",{className:"mt-3",children:s.jsx(yu,{logs:e,pagination:x})})]})]})]})]}),D!==null&&s.jsx(p.Suspense,{fallback:null,children:s.jsx(KN,{left:D[0],right:D[1],leftDisplayNumber:xu(D[0],le),rightDisplayNumber:xu(D[1],le),onClose:ce})})]})}const $R=zt([G({type:Te("init"),logs:he(kr)}),G({type:Te("update"),log:kr})]),FR=G({logs:he(kr),total:q().int().nonnegative(),limit:q().int().positive(),hasOlder:$e(),hasNewer:$e(),oldestLogId:q().int().positive().nullable(),newestLogId:q().int().positive().nullable()});function BR(e,t){const n=[];for(const r of e)for(const o of r.members)o.sessionId===t&&n.push({groupId:r.id,groupTitle:r.title,groupKind:r.kind,groupStatus:r.status,groupTask:r.task,groupProject:r.project,groupEvidence:r.evidence,member:o});return n}function UR(e){const t=new Set;for(const n of e)n.sessionId!==null&&n.sessionId!==""&&t.add(n.sessionId);return[...t]}function WR(e){const t=new Set;for(const n of e)n.model!==null&&n.model!==""&&t.add(n.model);return[...t]}function HR(e,t,n){return t==="__all__"&&n==="__all__"?e:e.filter(r=>!(t!=="__all__"&&r.sessionId!==t||n!=="__all__"&&r.model!==n))}const ZR=100,VR=12,qR=1800,Nu=500,_m=100;function GR(e){const t=new URLSearchParams;e!==void 0&&(t.set("sessionId",e),t.set("compact","1"));const n=t.toString();return n.length>0?`/api/logs/stream?${n}`:"/api/logs/stream"}function KR(e,t){const n=new URLSearchParams({cursor:"1",compact:"1",limit:String(_m),sessionId:e});switch(t.kind){case"oldest":n.set("anchor","oldest");break;case"older":n.set("beforeLogId",String(t.beforeLogId));break;case"newer":n.set("afterLogId",String(t.afterLogId));break}return`/api/logs?${n.toString()}`}function hr(e){const t=new Map;for(let n=0;n<e.length;n++){const r=e[n];r!==void 0&&t.set(r.id,n)}return t}function fi(e){return e.length<=Nu?e:e.slice(e.length-Nu)}function eI({initialSessionId:e}={}){const[t,n]=p.useState([]),[r,o]=p.useState(e??"__all__"),[i,a]=p.useState("__all__"),[l,c]=p.useState(null),[u,d]=p.useState(e===void 0),[f,h]=p.useState(null),[m,v]=p.useState(e!==void 0),[g,x]=p.useState([]),[,b]=p.useTransition(),y=p.useRef(null),_=p.useRef(null),j=p.useRef(null),S=p.useRef(0),T=p.useRef(new Map),C=p.useRef([]),A=p.useRef(null),E=p.useMemo(()=>HR(t,r,i),[t,r,i]),P=p.useMemo(()=>UR(t),[t]),J=p.useMemo(()=>WR(t),[t]),R=p.useCallback(()=>{A.current=null;const le=C.current;C.current=[],le.length!==0&&b(()=>{n(ae=>{const re=[...ae];for(const ye of le){const w=T.current.get(ye.id);if(w!==void 0&&re[w]?.id===ye.id){re[w]=ye;continue}const K=re.findIndex(V=>V.id===ye.id);if(K>=0){re[K]=ye;continue}re.push(ye)}const pe=fi(re);return T.current=hr(pe),pe})})},[b]),F=p.useCallback(le=>{C.current.push(le),A.current===null&&(A.current=setTimeout(R,ZR))},[R]),k=p.useCallback(()=>{y.current&&y.current.close(),d(!1);const le=new EventSource(GR(e));y.current=le,le.onmessage=ae=>{try{const re=String(ae.data),pe=JSON.parse(re),ye=$R.safeParse(pe);if(!ye.success){c("Failed to parse SSE data");return}const w=ye.data;if(w.type==="init"){A.current!==null&&(clearTimeout(A.current),A.current=null),C.current=[];const K=fi(w.logs);T.current=hr(K),n(K),d(!0),c(null)}else w.type==="update"&&F(w.log)}catch{c("Failed to parse SSE data")}},le.onerror=()=>{c("SSE connection lost, reconnecting..."),d(!0),le.close(),_.current!==null&&clearTimeout(_.current),_.current=setTimeout(k,3e3)}},[e,F]),M=p.useCallback(le=>{if(e===void 0)return;const ae=S.current+1;S.current=ae,v(!0),c(null),tn(KR(e,le),FR).then(re=>{if(S.current!==ae)return;const pe=re.logs;T.current=hr(pe),n(pe),h(re),o(e),v(!1),c(null)}).catch(re=>{S.current===ae&&(n([]),h(null),v(!1),c(re instanceof Error?re.message:"Failed to load session logs"))})},[e]);p.useEffect(()=>{if(e===void 0){x([]);return}let le=!1;return fetch("/api/groups").then(async ae=>{if(!ae.ok)return null;const re=await ae.json(),pe=Ad.safeParse(re);return pe.success?pe.data.groups:null}).then(ae=>{le||ae===null||x(BR(ae,e))}).catch(()=>{le||x([])}),()=>{le=!0}},[e]),p.useEffect(()=>{e!==void 0&&M({kind:"newest"})},[e,M]),p.useEffect(()=>{if(e===void 0)return k(),()=>{y.current&&(y.current.close(),y.current=null),_.current!==null&&(clearTimeout(_.current),_.current=null),A.current!==null&&(clearTimeout(A.current),A.current=null)}},[k,e]),p.useEffect(()=>{const le=window.location.hash;if(!le.startsWith("#log-")||j.current===le)return;const ae=le.slice(1),re=Number(ae.replace(/^log-/,""));Number.isInteger(re)&&re>0&&Vs({logId:re,tab:"request"});let pe=!1,ye=0,w=null,K=null;const V=()=>{if(pe)return;const z=document.getElementById(ae);if(z!==null){j.current=le,z.scrollIntoView({block:"center",behavior:"smooth"}),z instanceof HTMLElement&&(w=z,z.setAttribute("data-deep-link-highlight","true"),K=window.setTimeout(()=>{z.removeAttribute("data-deep-link-highlight")},qR),z.focus({preventScroll:!0}),z.getAttribute("data-nav-action")==="expand"&&z.click());return}ye+=1,ye<VR&&window.setTimeout(V,100)};return V(),()=>{pe=!0,K!==null&&window.clearTimeout(K),w!==null&&w.removeAttribute("data-deep-link-highlight")}},[E.length]);const Y=p.useCallback(()=>{e!==void 0&&t.length===0||(async()=>{try{const le=e===void 0?void 0:JSON.stringify({ids:t.map(re=>re.id)});if(!(await fetch("/api/logs",{method:"DELETE",...le===void 0?{}:{headers:{"Content-Type":"application/json"},body:le}})).ok){c("Failed to clear logs");return}T.current.clear(),n([]),c(null)}catch(le){c(le instanceof Error?le.message:"Unknown error clearing logs")}})()},[t,e]),D=p.useCallback(le=>{le.length!==0&&(async()=>{try{if(!(await fetch("/api/logs",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:le})})).ok){c("Failed to clear group");return}const re=new Set(le);n(pe=>{const ye=pe.filter(w=>!re.has(w.id));return T.current=hr(ye),ye}),c(null)}catch(ae){c(ae instanceof Error?ae.message:"Unknown error clearing group")}})()},[]),B=p.useCallback(async le=>{const ae=new FormData;ae.set("file",le);const re=await tn("/api/logs/import",d1,{method:"POST",body:ae});return n(pe=>{const ye=new Set(re.logs.map(V=>V.id)),w=[...pe.filter(V=>!ye.has(V.id)),...re.logs].sort((V,z)=>V.id-z.id),K=fi(w);return T.current=hr(K),K}),o(re.sessionId),a("__all__"),h(null),c(null),re},[]),{strip:U,captureMode:ie,slowResponseThresholdSeconds:W,timeDisplayFormat:H}=wa(),ue=ie,ne=p.useCallback(()=>{M({kind:"oldest"})},[M]),se=p.useCallback(()=>{M({kind:"newest"})},[M]),je=p.useCallback(()=>{const le=t[0],ae=f?.oldestLogId??le?.id??null;ae!==null&&M({kind:"older",beforeLogId:ae})},[t,M,f]),ce=p.useCallback(()=>{const le=t[t.length-1],ae=f?.newestLogId??le?.id??null;ae!==null&&M({kind:"newer",afterLogId:ae})},[t,M,f]),me=p.useMemo(()=>{if(e!==void 0)return{isLoading:m,total:f?.total??null,pageSize:f?.limit??_m,hasOlder:f?.hasOlder??!1,hasNewer:f?.hasNewer??!1,oldestLogId:f?.oldestLogId??null,newestLogId:f?.newestLogId??null,onOldest:ne,onOlder:je,onNewer:ce,onNewest:se}},[e,se,ce,je,ne,f,m]);return s.jsxs(s.Fragment,{children:[l!==null&&s.jsx("div",{className:"fixed top-4 right-4 bg-destructive text-destructive-foreground px-4 py-2 rounded-md text-sm z-50",children:l}),s.jsx(R2,{}),s.jsx(DR,{logs:E,sessions:P,models:J,selectedSession:r,selectedModel:i,onSessionChange:o,onModelChange:a,onClearAll:Y,onClearGroup:D,onImportLogs:e===void 0?B:void 0,isLoading:e===void 0?!u:m,pagination:me,sessionMemberships:g,viewMode:ue,captureMode:ie,strip:U,slowResponseThresholdSeconds:W,timeDisplayFormat:H,hideSessionFilter:e!==void 0,pinnedSessionId:e})]})}export{C3 as $,q as A,Fe as B,dy as C,zr as D,he as E,Vs as F,$e as G,N as H,kr as I,KA as J,My as K,e3 as L,Wy as M,lA as N,aA as O,eI as P,ef as Q,n2 as R,fA as S,Dh as T,QR as U,ct as V,Ae as W,Ta as X,S3 as Y,XR as Z,zd as _,sN as a,N3 as a0,Na as a1,Wi as a2,Gs as a3,jr as a4,ke as a5,gn as a6,Bw as a7,ht as a8,qN as a9,B1 as aa,de as b,ge as c,bi as d,Md as e,Be as f,Ah as g,Ot as h,Ge as i,St as j,Ht as k,Or as l,Pr as m,Mr as n,Qy as o,$h as p,dt as q,Nr as r,ft as s,Ne as t,tf as u,Je as v,Me as w,Le as x,De as y,G as z};
|