tracer-sh 0.2.8 → 0.3.0

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.
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/highlighted-body-OFNGDK62-I1fFFO4T.js","assets/index-C2C5Z4gB.js","assets/index-B4Hwftt4.css","assets/SearchableSelect-CUhWd9KY.js"])))=>i.map(i=>d[i]);
2
- import{s as LN,e as MN,f as dr,g as ne,_ as Gu,h as QT,l as jN,i as ro,o as Ve,k as de,m as Zt,n as Hn,p as BN,q as Co,v as FN,w as $N,x as Je,y as UN,r as m,z as Nn,j as v,B as sc,D as em,R as HN,c as Jt,b as F,E as zN,F as zn,G as vh,H as qN,I as WN,J as JT,W as Ra,K as ew,C as tw,t as dt,U as wa,L as rw,N as nw,O as Rg,P as ou,Q as VN,T as Lg,V as xh,X as YN,Y as KN}from"./index-C2C5Z4gB.js";import{r as Io,u as GN}from"./SearchableSelect-CUhWd9KY.js";const iw=new Set(["timestamp","start","end","created_at","updated_at","time"]);function XN(e,t){return iw.has(e)?t>1e12:/time/i.test(e)&&t>1e12&&t<3e12}function ZN(e,t){return iw.has(e)?t>1e9&&t<1e12:/time/i.test(e)&&t>1e9&&t<3e9}var aw="vercel.ai.error",QN=Symbol.for(aw),Mg,jg,un=class sw extends(jg=Error,Mg=QN,jg){constructor({name:t,message:r,cause:n}){super(r),this[Mg]=!0,this.name=t,this.cause=n}static isInstance(t){return sw.hasMarker(t,aw)}static hasMarker(t,r){const n=Symbol.for(r);return t!=null&&typeof t=="object"&&n in t&&typeof t[n]=="boolean"&&t[n]===!0}};function ow(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var uw="AI_InvalidArgumentError",lw=`vercel.ai.error.${uw}`,JN=Symbol.for(lw),Bg,Fg,eP=class extends(Fg=un,Bg=JN,Fg){constructor({message:e,cause:t,argument:r}){super({name:uw,message:e,cause:t}),this[Bg]=!0,this.argument=r}static isInstance(e){return un.hasMarker(e,lw)}},cw="AI_JSONParseError",fw=`vercel.ai.error.${cw}`,tP=Symbol.for(fw),$g,Ug,Hg=class extends(Ug=un,$g=tP,Ug){constructor({text:e,cause:t}){super({name:cw,message:`JSON parsing failed: Text: ${e}.
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/highlighted-body-OFNGDK62-ClhPAwAu.js","assets/index-BfsXwolP.js","assets/index-B4Hwftt4.css","assets/SearchableSelect-ClBD3uDN.js"])))=>i.map(i=>d[i]);
2
+ import{s as LN,e as MN,f as dr,g as ne,_ as Gu,h as QT,l as jN,i as ro,o as Ve,k as de,m as Zt,n as Hn,p as BN,q as Co,v as FN,w as $N,x as Je,y as UN,r as m,z as Nn,j as v,B as sc,D as em,R as HN,c as Jt,b as F,E as zN,F as zn,G as vh,H as qN,I as WN,J as JT,W as Ra,K as ew,C as tw,t as dt,U as wa,L as rw,N as nw,O as Rg,P as ou,Q as VN,T as Lg,V as xh,X as YN,Y as KN}from"./index-BfsXwolP.js";import{r as Io,u as GN}from"./SearchableSelect-ClBD3uDN.js";const iw=new Set(["timestamp","start","end","created_at","updated_at","time"]);function XN(e,t){return iw.has(e)?t>1e12:/time/i.test(e)&&t>1e12&&t<3e12}function ZN(e,t){return iw.has(e)?t>1e9&&t<1e12:/time/i.test(e)&&t>1e9&&t<3e9}var aw="vercel.ai.error",QN=Symbol.for(aw),Mg,jg,un=class sw extends(jg=Error,Mg=QN,jg){constructor({name:t,message:r,cause:n}){super(r),this[Mg]=!0,this.name=t,this.cause=n}static isInstance(t){return sw.hasMarker(t,aw)}static hasMarker(t,r){const n=Symbol.for(r);return t!=null&&typeof t=="object"&&n in t&&typeof t[n]=="boolean"&&t[n]===!0}};function ow(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var uw="AI_InvalidArgumentError",lw=`vercel.ai.error.${uw}`,JN=Symbol.for(lw),Bg,Fg,eP=class extends(Fg=un,Bg=JN,Fg){constructor({message:e,cause:t,argument:r}){super({name:uw,message:e,cause:t}),this[Bg]=!0,this.argument=r}static isInstance(e){return un.hasMarker(e,lw)}},cw="AI_JSONParseError",fw=`vercel.ai.error.${cw}`,tP=Symbol.for(fw),$g,Ug,Hg=class extends(Ug=un,$g=tP,Ug){constructor({text:e,cause:t}){super({name:cw,message:`JSON parsing failed: Text: ${e}.
3
3
  Error message: ${ow(t)}`,cause:t}),this[$g]=!0,this.text=e}static isInstance(e){return un.hasMarker(e,fw)}},dw="AI_TypeValidationError",hw=`vercel.ai.error.${dw}`,rP=Symbol.for(hw),zg,qg,La=class Eh extends(qg=un,zg=rP,qg){constructor({value:t,cause:r,context:n}){let i="Type validation failed";if(n?.field&&(i+=` for ${n.field}`),n?.entityName||n?.entityId){i+=" (";const a=[];n.entityName&&a.push(n.entityName),n.entityId&&a.push(`id: "${n.entityId}"`),i+=a.join(", "),i+=")"}super({name:dw,message:`${i}: Value: ${JSON.stringify(t)}.
4
4
  Error message: ${ow(r)}`,cause:r}),this[zg]=!0,this.value=t,this.context=n}static isInstance(t){return un.hasMarker(t,hw)}static wrap({value:t,cause:r,context:n}){var i,a,s;return Eh.isInstance(r)&&r.value===t&&((i=r.context)==null?void 0:i.field)===n?.field&&((a=r.context)==null?void 0:a.entityName)===n?.entityName&&((s=r.context)==null?void 0:s.entityId)===n?.entityId?r:new Eh({value:t,cause:r,context:n})}},no;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function r(i){throw new Error}e.assertNever=r,e.arrayToEnum=i=>{const a={};for(const s of i)a[s]=s;return a},e.getValidEnumValues=i=>{const a=e.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),s={};for(const o of a)s[o]=i[o];return e.objectValues(s)},e.objectValues=i=>e.objectKeys(i).map(function(a){return i[a]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const a=[];for(const s in i)Object.prototype.hasOwnProperty.call(i,s)&&a.push(s);return a},e.find=(i,a)=>{for(const s of i)if(a(s))return s},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function n(i,a=" | "){return i.map(s=>typeof s=="string"?`'${s}'`:s).join(a)}e.joinValues=n,e.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(no||(no={}));var Wg;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(Wg||(Wg={}));no.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);no.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Xu extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){const r=t||function(a){return a.message},n={_errors:[]},i=a=>{for(const s of a.issues)if(s.code==="invalid_union")s.unionErrors.map(i);else if(s.code==="invalid_return_type")i(s.returnTypeError);else if(s.code==="invalid_arguments")i(s.argumentsError);else if(s.path.length===0)n._errors.push(r(s));else{let o=n,u=0;for(;u<s.path.length;){const l=s.path[u];u===s.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(r(s))):o[l]=o[l]||{_errors:[]},o=o[l],u++}}};return i(this),n}static assert(t){if(!(t instanceof Xu))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,no.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){const r=Object.create(null),n=[];for(const i of this.issues)if(i.path.length>0){const a=i.path[0];r[a]=r[a]||[],r[a].push(t(i))}else n.push(t(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}Xu.create=e=>new Xu(e);var Vg;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(Vg||(Vg={}));var Ee;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(Ee||(Ee={}));class Yg extends Error{constructor(t,r){super(t),this.name="ParseError",this.type=r.type,this.field=r.field,this.value=r.value,this.line=r.line}}const Kg=10,nP=13,pi=32;function pf(e){}function iP(e){if(typeof e=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:t=pf,onError:r=pf,onRetry:n=pf,onComment:i}=e,a=[];let s=!0,o,u="",l=0,c;function f(x){if(s&&(s=!1,x.charCodeAt(0)===239&&x.charCodeAt(1)===187&&x.charCodeAt(2)===191&&(x=x.slice(3))),a.length===0){const k=d(x);k!==""&&a.push(k);return}if(x.indexOf(`
5
5
  `)===-1&&x.indexOf("\r")===-1){a.push(x);return}a.push(x);const T=a.join("");a.length=0;const E=d(T);E!==""&&a.push(E)}function d(x){let T=0;if(x.indexOf("\r")===-1){let E=x.indexOf(`
@@ -128,7 +128,7 @@ ${t}</tr>
128
128
  `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${vn(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:r,tokens:n}){let i=this.parser.parseInline(n),a=_y(t);if(a===null)return i;t=a;let s='<a href="'+t+'"';return r&&(s+=' title="'+vn(r)+'"'),s+=">"+i+"</a>",s}image({href:t,title:r,text:n,tokens:i}){i&&(n=this.parser.parseInline(i,this.parser.textRenderer));let a=_y(t);if(a===null)return vn(n);t=a;let s=`<img src="${t}" alt="${n}"`;return r&&(s+=` title="${vn(r)}"`),s+=">",s}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:vn(t.text)}},Mm=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},Fr=class qh{options;renderer;textRenderer;constructor(t){this.options=t||Zi,this.options.renderer=this.options.renderer||new ol,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Mm}static parse(t,r){return new qh(r).parse(t)}static parseInline(t,r){return new qh(r).parseInline(t)}parse(t){let r="";for(let n=0;n<t.length;n++){let i=t[n];if(this.options.extensions?.renderers?.[i.type]){let s=i,o=this.options.extensions.renderers[s.type].call({parser:this},s);if(o!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(s.type)){r+=o||"";continue}}let a=i;switch(a.type){case"space":{r+=this.renderer.space(a);break}case"hr":{r+=this.renderer.hr(a);break}case"heading":{r+=this.renderer.heading(a);break}case"code":{r+=this.renderer.code(a);break}case"table":{r+=this.renderer.table(a);break}case"blockquote":{r+=this.renderer.blockquote(a);break}case"list":{r+=this.renderer.list(a);break}case"checkbox":{r+=this.renderer.checkbox(a);break}case"html":{r+=this.renderer.html(a);break}case"def":{r+=this.renderer.def(a);break}case"paragraph":{r+=this.renderer.paragraph(a);break}case"text":{r+=this.renderer.text(a);break}default:{let s='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return r}parseInline(t,r=this.renderer){let n="";for(let i=0;i<t.length;i++){let a=t[i];if(this.options.extensions?.renderers?.[a.type]){let o=this.options.extensions.renderers[a.type].call({parser:this},a);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){n+=o||"";continue}}let s=a;switch(s.type){case"escape":{n+=r.text(s);break}case"html":{n+=r.html(s);break}case"link":{n+=r.link(s);break}case"image":{n+=r.image(s);break}case"checkbox":{n+=r.checkbox(s);break}case"strong":{n+=r.strong(s);break}case"em":{n+=r.em(s);break}case"codespan":{n+=r.codespan(s);break}case"br":{n+=r.br(s);break}case"del":{n+=r.del(s);break}case"text":{n+=r.text(s);break}default:{let o='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}},Rs=class{options;block;constructor(e){this.options=e||Zi}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?Pr.lex:Pr.lexInline}provideParser(){return this.block?Fr.parse:Fr.parseInline}},QF=class{defaults=Cm();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Fr;Renderer=ol;TextRenderer=Mm;Lexer=Pr;Tokenizer=sl;Hooks=Rs;constructor(...e){this.use(...e)}walkTokens(e,t){let r=[];for(let n of e)switch(r=r.concat(t.call(this,n)),n.type){case"table":{let i=n;for(let a of i.header)r=r.concat(this.walkTokens(a.tokens,t));for(let a of i.rows)for(let s of a)r=r.concat(this.walkTokens(s.tokens,t));break}case"list":{let i=n;r=r.concat(this.walkTokens(i.items,t));break}default:{let i=n;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(a=>{let s=i[a].flat(1/0);r=r.concat(this.walkTokens(s,t))}):i.tokens&&(r=r.concat(this.walkTokens(i.tokens,t)))}}return r}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(r=>{let n={...r};if(n.async=this.defaults.async||n.async||!1,r.extensions&&(r.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let a=t.renderers[i.name];a?t.renderers[i.name]=function(...s){let o=i.renderer.apply(this,s);return o===!1&&(o=a.apply(this,s)),o}:t.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let a=t[i.level];a?a.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),n.extensions=t),r.renderer){let i=this.defaults.renderer||new ol(this.defaults);for(let a in r.renderer){if(!(a in i))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;let s=a,o=r.renderer[s],u=i[s];i[s]=(...l)=>{let c=o.apply(i,l);return c===!1&&(c=u.apply(i,l)),c||""}}n.renderer=i}if(r.tokenizer){let i=this.defaults.tokenizer||new sl(this.defaults);for(let a in r.tokenizer){if(!(a in i))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;let s=a,o=r.tokenizer[s],u=i[s];i[s]=(...l)=>{let c=o.apply(i,l);return c===!1&&(c=u.apply(i,l)),c}}n.tokenizer=i}if(r.hooks){let i=this.defaults.hooks||new Rs;for(let a in r.hooks){if(!(a in i))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;let s=a,o=r.hooks[s],u=i[s];Rs.passThroughHooks.has(a)?i[s]=l=>{if(this.defaults.async&&Rs.passThroughHooksRespectAsync.has(a))return(async()=>{let f=await o.call(i,l);return u.call(i,f)})();let c=o.call(i,l);return u.call(i,c)}:i[s]=(...l)=>{if(this.defaults.async)return(async()=>{let f=await o.apply(i,l);return f===!1&&(f=await u.apply(i,l)),f})();let c=o.apply(i,l);return c===!1&&(c=u.apply(i,l)),c}}n.hooks=i}if(r.walkTokens){let i=this.defaults.walkTokens,a=r.walkTokens;n.walkTokens=function(s){let o=[];return o.push(a.call(this,s)),i&&(o=o.concat(i.call(this,s))),o}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Pr.lex(e,t??this.defaults)}parser(e,t){return Fr.parse(e,t??this.defaults)}parseMarkdown(e){return(t,r)=>{let n={...r},i={...this.defaults,...n},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&n.async===!1)return a(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return a(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let s=i.hooks?await i.hooks.preprocess(t):t,o=await(i.hooks?await i.hooks.provideLexer():e?Pr.lex:Pr.lexInline)(s,i),u=i.hooks?await i.hooks.processAllTokens(o):o;i.walkTokens&&await Promise.all(this.walkTokens(u,i.walkTokens));let l=await(i.hooks?await i.hooks.provideParser():e?Fr.parse:Fr.parseInline)(u,i);return i.hooks?await i.hooks.postprocess(l):l})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let s=(i.hooks?i.hooks.provideLexer():e?Pr.lex:Pr.lexInline)(t,i);i.hooks&&(s=i.hooks.processAllTokens(s)),i.walkTokens&&this.walkTokens(s,i.walkTokens);let o=(i.hooks?i.hooks.provideParser():e?Fr.parse:Fr.parseInline)(s,i);return i.hooks&&(o=i.hooks.postprocess(o)),o}catch(s){return a(s)}}}onError(e,t){return r=>{if(r.message+=`
129
129
  Please report this to https://github.com/markedjs/marked.`,e){let n="<p>An error occurred:</p><pre>"+vn(r.message+"",!0)+"</pre>";return t?Promise.resolve(n):n}if(t)return Promise.reject(r);throw r}}},Fi=new QF;function qe(e,t){return Fi.parse(e,t)}qe.options=qe.setOptions=function(e){return Fi.setOptions(e),qe.defaults=Fi.defaults,G2(qe.defaults),qe};qe.getDefaults=Cm;qe.defaults=Zi;qe.use=function(...e){return Fi.use(...e),qe.defaults=Fi.defaults,G2(qe.defaults),qe};qe.walkTokens=function(e,t){return Fi.walkTokens(e,t)};qe.parseInline=Fi.parseInline;qe.Parser=Fr;qe.parser=Fr.parse;qe.Renderer=ol;qe.TextRenderer=Mm;qe.Lexer=Pr;qe.lexer=Pr.lex;qe.Tokenizer=sl;qe.Hooks=Rs;qe.parse=qe;qe.options;qe.setOptions;qe.use;qe.walkTokens;qe.parseInline;Fr.parse;Pr.lex;var JF=300,e7="300px",t7=500;function r7(e={}){let{immediate:t=!1,debounceDelay:r=JF,rootMargin:n=e7,idleTimeout:i=t7}=e,[a,s]=m.useState(!1),o=m.useRef(null),u=m.useRef(null),l=m.useRef(null),c=m.useMemo(()=>h=>{let p=Date.now();return window.setTimeout(()=>{h({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-p))})},1)},[]),f=m.useMemo(()=>typeof window<"u"&&window.requestIdleCallback?(h,p)=>window.requestIdleCallback(h,p):c,[c]),d=m.useMemo(()=>typeof window<"u"&&window.cancelIdleCallback?h=>window.cancelIdleCallback(h):h=>{clearTimeout(h)},[]);return m.useEffect(()=>{if(t){s(!0);return}let h=o.current;if(!h)return;u.current&&(clearTimeout(u.current),u.current=null),l.current&&(d(l.current),l.current=null);let p=()=>{u.current&&(clearTimeout(u.current),u.current=null),l.current&&(d(l.current),l.current=null)},b=E=>{l.current=f(k=>{k.timeRemaining()>0||k.didTimeout?(s(!0),E.disconnect()):l.current=f(()=>{s(!0),E.disconnect()},{timeout:i/2})},{timeout:i})},y=E=>{p(),u.current=window.setTimeout(()=>{var k,w;let A=E.takeRecords();(A.length===0||(w=(k=A.at(-1))==null?void 0:k.isIntersecting)!=null&&w)&&b(E)},r)},x=(E,k)=>{E.isIntersecting?y(k):p()},T=new IntersectionObserver(E=>{for(let k of E)x(k,T)},{rootMargin:n,threshold:0});return T.observe(h),()=>{u.current&&clearTimeout(u.current),l.current&&d(l.current),T.disconnect()}},[t,r,n,i,d,f]),{shouldRender:a,containerRef:o}}var sk=/\s/,n7=/^\s+$/,i7=new Set(["code","pre","svg","math","annotation"]),a7=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",s7=e=>e.some(t=>a7(t)&&i7.has(t.tagName)),o7=e=>{let t=[],r="",n=!1;for(let i of e){let a=sk.test(i);a!==n&&r&&(t.push(r),r=""),r+=i,n=a}return r&&t.push(r),t},u7=e=>{let t=[],r="";for(let n of e)sk.test(n)?r+=n:(r&&(t.push(r),r=""),t.push(n));return r&&t.push(r),t},l7=(e,t,r,n,i,a)=>{let s=`--sd-animation:sd-${t};--sd-duration:${i?0:r}ms;--sd-easing:${n}`;return a&&(s+=`;--sd-delay:${a}ms`),{type:"element",tagName:"span",properties:{"data-sd-animate":!0,style:s},children:[{type:"text",value:e}]}},c7=(e,t,r,n,i)=>{let a=t.at(-1);if(!(a&&"children"in a))return;if(s7(t))return Aa;let s=a,o=s.children.indexOf(e);if(o===-1)return;let u=e.value;if(!u.trim()){i.count+=u.length;return}let l=r.sep==="char"?u7(u):o7(u),c=n.prevContentLength,f=l.map(d=>{let h=i.count;if(i.count+=d.length,n7.test(d))return{type:"text",value:d};let p=c>0&&h<c,b=p?0:i.newIndex++*r.stagger;return l7(d,r.animation,r.duration,r.easing,p,b)});return s.children.splice(o,1,...f),o+f.length},f7=0;function Wh(e){var t,r,n,i,a;let s={animation:(t=e?.animation)!=null?t:"fadeIn",duration:(r=e?.duration)!=null?r:150,easing:(n=e?.easing)!=null?n:"ease",sep:(i=e?.sep)!=null?i:"word",stagger:(a=e?.stagger)!=null?a:40},o={prevContentLength:0,lastRenderCharCount:0},u=f7++,l=()=>c=>{let f={count:0,newIndex:0};nm(c,"text",(d,h)=>c7(d,h,s,o,f)),o.lastRenderCharCount=f.count,o.prevContentLength=0};return Object.defineProperty(l,"name",{value:`rehypeAnimate$${u}`}),{name:"animate",type:"animate",rehypePlugin:l,setPrevContentLength(c){o.prevContentLength=c},getLastRenderCharCount(){let c=o.lastRenderCharCount;return o.lastRenderCharCount=0,c}}}Wh();var ok=m.createContext(!1),d7=()=>m.useContext(ok),jm=(...e)=>B2(Fe(e)),h7=(e,t)=>{if(!e||!t)return t;let r=`${e}:`;return t.split(/\s+/).filter(Boolean).map(n=>n.startsWith(r)?n:`${e}:${n}`).join(" ")},p7=e=>e?(...t)=>h7(e,B2(Fe(t))):jm,Ia=(e,t,r)=>{let n=typeof t=="string"&&r.startsWith("text/csv")?"\uFEFF":"",i=typeof t=="string"?new Blob([n+t],{type:r}):t,a=URL.createObjectURL(i),s=document.createElement("a");s.href=a,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(a)},Vh=m.createContext(jm),Ie=()=>m.useContext(Vh),m7=jm("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-6","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),g7=e=>{let t={};for(let r of e.split(";")){let n=r.indexOf(":");if(n>0){let i=r.slice(0,n).trim(),a=r.slice(n+1).trim();i&&a&&(t[i]=a)}}return t},b7=m.memo(({children:e,result:t,language:r,className:n,startLine:i,lineNumbers:a=!0,...s})=>{let o=Ie(),u=m.useMemo(()=>o(m7),[o]),l=m.useMemo(()=>{let c={};return t.bg&&(c["--sdm-bg"]=t.bg),t.fg&&(c["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(c,g7(t.rootStyle)),c},[t.bg,t.fg,t.rootStyle]);return v.jsx("div",{className:o(n,"overflow-x-auto rounded-md border border-border bg-background p-4 text-sm"),"data-language":r,"data-streamdown":"code-block-body",...s,children:v.jsx("pre",{className:o(n,"bg-[var(--sdm-bg,inherit]","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit)]"),style:l,children:v.jsx("code",{className:a?o("[counter-increment:line_0] [counter-reset:line]"):void 0,style:a&&i&&i>1?{counterReset:`line ${i-1}`}:void 0,children:t.tokens.map((c,f)=>v.jsx("span",{className:a?u:void 0,children:c.length===0||c.length===1&&c[0].content===""?`
130
130
  `:c.map((d,h)=>{let p={},b=!!d.bgColor;if(d.color&&(p["--sdm-c"]=d.color),d.bgColor&&(p["--sdm-tbg"]=d.bgColor),d.htmlStyle)for(let[y,x]of Object.entries(d.htmlStyle))y==="color"?p["--sdm-c"]=x:y==="background-color"?(p["--sdm-tbg"]=x,b=!0):p[y]=x;return v.jsx("span",{className:o("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",b&&"bg-[var(--sdm-tbg)]",b&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:p,...d.htmlAttrs,children:d.content},h)})},f))})})})},(e,t)=>e.result===t.result&&e.language===t.language&&e.className===t.className&&e.startLine===t.startLine&&e.lineNumbers===t.lineNumbers),y7=({className:e,language:t,style:r,isIncomplete:n,...i})=>{let a=Ie();return v.jsx("div",{className:a("my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",e),"data-incomplete":n||void 0,"data-language":t,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...r},...i})},uk=m.createContext({code:""}),lk=()=>m.useContext(uk),v7=({language:e})=>{let t=Ie();return v.jsx("div",{className:t("flex h-8 items-center text-muted-foreground text-xs"),"data-language":e,"data-streamdown":"code-block-header",children:v.jsx("span",{className:t("ml-1 font-mono lowercase"),children:e})})},x7=e=>{let t=e.length;for(;t>0&&e[t-1]===`
131
- `;)t--;return e.slice(0,t)},E7=m.lazy(()=>sc(()=>import("./highlighted-body-OFNGDK62-I1fFFO4T.js"),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.HighlightedCodeBlockBody}))),T7=({code:e,language:t,className:r,children:n,isIncomplete:i=!1,startLine:a,lineNumbers:s,...o})=>{let u=Ie(),l=m.useMemo(()=>x7(e),[e]),c=m.useMemo(()=>({bg:"transparent",fg:"inherit",tokens:l.split(`
131
+ `;)t--;return e.slice(0,t)},E7=m.lazy(()=>sc(()=>import("./highlighted-body-OFNGDK62-ClhPAwAu.js"),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.HighlightedCodeBlockBody}))),T7=({code:e,language:t,className:r,children:n,isIncomplete:i=!1,startLine:a,lineNumbers:s,...o})=>{let u=Ie(),l=m.useMemo(()=>x7(e),[e]),c=m.useMemo(()=>({bg:"transparent",fg:"inherit",tokens:l.split(`
132
132
  `).map(f=>[{content:f,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[l]);return v.jsx(uk.Provider,{value:{code:e},children:v.jsxs(y7,{isIncomplete:i,language:t,children:[v.jsx(v7,{language:t}),n?v.jsx("div",{className:u("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:v.jsx("div",{className:u("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"code-block-actions",children:n})}):null,v.jsx(m.Suspense,{fallback:v.jsx(b7,{className:r,language:t,lineNumbers:s,result:c,startLine:a,...o}),children:v.jsx(E7,{className:r,code:l,language:t,lineNumbers:s,raw:c,startLine:a,...o})})]})})},w7=e=>v.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:v.jsx("path",{clipRule:"evenodd",d:"M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z",fill:"currentColor",fillRule:"evenodd"})}),A7=e=>v.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:v.jsx("path",{clipRule:"evenodd",d:"M2.75 0.5C1.7835 0.5 1 1.2835 1 2.25V9.75C1 10.7165 1.7835 11.5 2.75 11.5H3.75H4.5V10H3.75H2.75C2.61193 10 2.5 9.88807 2.5 9.75V2.25C2.5 2.11193 2.61193 2 2.75 2H8.25C8.38807 2 8.5 2.11193 8.5 2.25V3H10V2.25C10 1.2835 9.2165 0.5 8.25 0.5H2.75ZM7.75 4.5C6.7835 4.5 6 5.2835 6 6.25V13.75C6 14.7165 6.7835 15.5 7.75 15.5H13.25C14.2165 15.5 15 14.7165 15 13.75V6.25C15 5.2835 14.2165 4.5 13.25 4.5H7.75ZM7.5 6.25C7.5 6.11193 7.61193 6 7.75 6H13.25C13.3881 6 13.5 6.11193 13.5 6.25V13.75C13.5 13.8881 13.3881 14 13.25 14H7.75C7.61193 14 7.5 13.8881 7.5 13.75V6.25Z",fill:"currentColor",fillRule:"evenodd"})}),k7=e=>v.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:v.jsx("path",{clipRule:"evenodd",d:"M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z",fill:"currentColor",fillRule:"evenodd"})}),_7=e=>v.jsxs("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:[v.jsx("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),v.jsx("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),v.jsx("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),v.jsx("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),v.jsx("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),v.jsx("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),v.jsx("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),v.jsx("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),v.jsx("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),v.jsx("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),S7=e=>v.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:v.jsx("path",{clipRule:"evenodd",d:"M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z",fill:"currentColor",fillRule:"evenodd"})}),C7=e=>v.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:v.jsx("path",{clipRule:"evenodd",d:"M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z",fill:"currentColor",fillRule:"evenodd"})}),I7=e=>v.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:v.jsx("path",{clipRule:"evenodd",d:"M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z",fill:"currentColor",fillRule:"evenodd"})}),O7=e=>v.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:v.jsx("path",{clipRule:"evenodd",d:"M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z",fill:"currentColor",fillRule:"evenodd"})}),N7=e=>v.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:v.jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})}),P7=e=>v.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:v.jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})}),Ls={CheckIcon:w7,CopyIcon:A7,DownloadIcon:k7,ExternalLinkIcon:O7,Loader2Icon:_7,Maximize2Icon:S7,RotateCcwIcon:C7,XIcon:I7,ZoomInIcon:N7,ZoomOutIcon:P7},ck=m.createContext(Ls),D7=(e,t)=>{if(e===t)return!0;if(!(e&&t))return e===t;let r=Object.keys(e),n=Object.keys(t);return r.length!==n.length?!1:r.every(i=>e[i]===t[i])},Iy=({icons:e,children:t})=>{let r=m.useRef(e),n=m.useRef(e?{...Ls,...e}:Ls);D7(r.current,e)||(r.current=e,n.current=e?{...Ls,...e}:Ls);let i=n.current;return v.jsx(ck.Provider,{value:i,children:t})},Kr=()=>m.useContext(ck),fk={copyCode:"Copy Code",downloadFile:"Download file",downloadDiagram:"Download diagram",downloadDiagramAsSvg:"Download diagram as SVG",downloadDiagramAsPng:"Download diagram as PNG",downloadDiagramAsMmd:"Download diagram as MMD",viewFullscreen:"View fullscreen",exitFullscreen:"Exit fullscreen",mermaidFormatSvg:"SVG",mermaidFormatPng:"PNG",mermaidFormatMmd:"MMD",copyTable:"Copy table",copyTableAsMarkdown:"Copy table as Markdown",copyTableAsCsv:"Copy table as CSV",copyTableAsTsv:"Copy table as TSV",downloadTable:"Download table",downloadTableAsCsv:"Download table as CSV",downloadTableAsMarkdown:"Download table as Markdown",tableFormatMarkdown:"Markdown",tableFormatCsv:"CSV",tableFormatTsv:"TSV",imageNotAvailable:"Image not available",downloadImage:"Download image",openExternalLink:"Open external link?",externalLinkWarning:"You're about to visit an external website.",close:"Close",copyLink:"Copy link",copied:"Copied",openLink:"Open link"},Yh=m.createContext(fk),Dn=()=>m.useContext(Yh),Oy=({onCopy:e,onError:t,timeout:r=2e3,children:n,className:i,code:a,...s})=>{let o=Ie(),[u,l]=m.useState(!1),c=m.useRef(0),{code:f}=lk(),{isAnimating:d}=m.useContext(Tr),h=Dn(),p=a??f,b=async()=>{var T;if(typeof window>"u"||!((T=navigator?.clipboard)!=null&&T.writeText)){t?.(new Error("Clipboard API not available"));return}try{u||(await navigator.clipboard.writeText(p),l(!0),e?.(),c.current=window.setTimeout(()=>l(!1),r))}catch(E){t?.(E)}};m.useEffect(()=>()=>{window.clearTimeout(c.current)},[]);let y=Kr(),x=u?y.CheckIcon:y.CopyIcon;return v.jsx("button",{className:o("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",i),"data-streamdown":"code-block-copy-button",disabled:d,onClick:b,title:h.copyCode,type:"button",...s,children:n??v.jsx(x,{size:14})})},Ny={"1c":"1c","1c-query":"1cq",abap:"abap","actionscript-3":"as",ada:"ada",adoc:"adoc","angular-html":"html","angular-ts":"ts",apache:"conf",apex:"cls",apl:"apl",applescript:"applescript",ara:"ara",asciidoc:"adoc",asm:"asm",astro:"astro",awk:"awk",ballerina:"bal",bash:"sh",bat:"bat",batch:"bat",be:"be",beancount:"beancount",berry:"berry",bibtex:"bib",bicep:"bicep",blade:"blade.php",bsl:"bsl",c:"c","c#":"cs","c++":"cpp",cadence:"cdc",cairo:"cairo",cdc:"cdc",clarity:"clar",clj:"clj",clojure:"clj","closure-templates":"soy",cmake:"cmake",cmd:"cmd",cobol:"cob",codeowners:"CODEOWNERS",codeql:"ql",coffee:"coffee",coffeescript:"coffee","common-lisp":"lisp",console:"sh",coq:"v",cpp:"cpp",cql:"cql",crystal:"cr",cs:"cs",csharp:"cs",css:"css",csv:"csv",cue:"cue",cypher:"cql",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",docker:"dockerfile",dockerfile:"dockerfile",dotenv:"env","dream-maker":"dm",edge:"edge",elisp:"el",elixir:"ex",elm:"elm","emacs-lisp":"el",erb:"erb",erl:"erl",erlang:"erl",f:"f","f#":"fs",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"f90",f95:"f95",fennel:"fnl",fish:"fish",fluent:"ftl",for:"for","fortran-fixed-form":"f","fortran-free-form":"f90",fs:"fs",fsharp:"fs",fsl:"fsl",ftl:"ftl",gdresource:"tres",gdscript:"gd",gdshader:"gdshader",genie:"gs",gherkin:"feature","git-commit":"gitcommit","git-rebase":"gitrebase",gjs:"js",gleam:"gleam","glimmer-js":"js","glimmer-ts":"ts",glsl:"glsl",gnuplot:"plt",go:"go",gql:"gql",graphql:"graphql",groovy:"groovy",gts:"gts",hack:"hack",haml:"haml",handlebars:"hbs",haskell:"hs",haxe:"hx",hbs:"hbs",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",hs:"hs",html:"html","html-derivative":"html",http:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",jade:"jade",java:"java",javascript:"js",jinja:"jinja",jison:"jison",jl:"jl",js:"js",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",julia:"jl",kotlin:"kt",kql:"kql",kt:"kt",kts:"kts",kusto:"kql",latex:"tex",lean:"lean",lean4:"lean",less:"less",liquid:"liquid",lisp:"lisp",lit:"lit",llvm:"ll",log:"log",logo:"logo",lua:"lua",luau:"luau",make:"mak",makefile:"mak",markdown:"md",marko:"marko",matlab:"m",md:"md",mdc:"mdc",mdx:"mdx",mediawiki:"wiki",mermaid:"mmd",mips:"s",mipsasm:"s",mmd:"mmd",mojo:"mojo",move:"move",nar:"nar",narrat:"narrat",nextflow:"nf",nf:"nf",nginx:"conf",nim:"nim",nix:"nix",nu:"nu",nushell:"nu",objc:"m","objective-c":"m","objective-cpp":"mm",ocaml:"ml",pascal:"pas",perl:"pl",perl6:"p6",php:"php",plsql:"pls",po:"po",polar:"polar",postcss:"pcss",pot:"pot",potx:"potx",powerquery:"pq",powershell:"ps1",prisma:"prisma",prolog:"pl",properties:"properties",proto:"proto",protobuf:"proto",ps:"ps",ps1:"ps1",pug:"pug",puppet:"pp",purescript:"purs",py:"py",python:"py",ql:"ql",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",racket:"rkt",raku:"raku",razor:"cshtml",rb:"rb",reg:"reg",regex:"regex",regexp:"regexp",rel:"rel",riscv:"s",rs:"rs",rst:"rst",ruby:"rb",rust:"rs",sas:"sas",sass:"sass",scala:"scala",scheme:"scm",scss:"scss",sdbl:"sdbl",sh:"sh",shader:"shader",shaderlab:"shader",shell:"sh",shellscript:"sh",shellsession:"sh",smalltalk:"st",solidity:"sol",soy:"soy",sparql:"rq",spl:"spl",splunk:"spl",sql:"sql","ssh-config":"config",stata:"do",styl:"styl",stylus:"styl",svelte:"svelte",swift:"swift","system-verilog":"sv",systemd:"service",talon:"talon",talonscript:"talon",tasl:"tasl",tcl:"tcl",templ:"templ",terraform:"tf",tex:"tex",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"ts","ts-tags":"ts",tsp:"tsp",tsv:"tsv",tsx:"tsx",turtle:"ttl",twig:"twig",typ:"typ",typescript:"ts",typespec:"tsp",typst:"typ",v:"v",vala:"vala",vb:"vb",verilog:"v",vhdl:"vhdl",vim:"vim",viml:"vim",vimscript:"vim",vue:"vue","vue-html":"html","vue-vine":"vine",vy:"vy",vyper:"vy",wasm:"wasm",wenyan:"wy",wgsl:"wgsl",wiki:"wiki",wikitext:"wiki",wit:"wit",wl:"wl",wolfram:"wl",xml:"xml",xsl:"xsl",yaml:"yaml",yml:"yml",zenscript:"zs",zig:"zig",zsh:"zsh",文言:"wy"},R7=({onDownload:e,onError:t,language:r,children:n,className:i,code:a,...s})=>{let o=Ie(),{code:u}=lk(),{isAnimating:l}=m.useContext(Tr),c=Dn(),f=Kr(),d=a??u,h=`file.${r&&r in Ny?Ny[r]:"txt"}`,p="text/plain",b=()=>{try{Ia(h,d,p),e?.()}catch(y){t?.(y)}};return v.jsx("button",{className:o("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",i),"data-streamdown":"code-block-download-button",disabled:l,onClick:b,title:c.downloadFile,type:"button",...s,children:n??v.jsx(f.DownloadIcon,{size:14})})},Py=()=>{let{Loader2Icon:e}=Kr(),t=Ie();return v.jsxs("div",{className:t("w-full divide-y divide-border overflow-hidden rounded-xl border border-border"),children:[v.jsx("div",{className:t("h-[46px] w-full bg-muted/80")}),v.jsx("div",{className:t("flex w-full items-center justify-center p-4"),children:v.jsx(e,{className:t("size-4 animate-spin")})})]})},L7=/\.[^/.]+$/,M7=({node:e,className:t,src:r,alt:n,onLoad:i,onError:a,...s})=>{let{DownloadIcon:o}=Kr(),u=Ie(),l=m.useRef(null),[c,f]=m.useState(!1),[d,h]=m.useState(!1),p=Dn(),b=s.width!=null||s.height!=null,y=(c||b)&&!d,x=d&&!b;m.useEffect(()=>{let w=l.current;if(w!=null&&w.complete){let A=w.naturalWidth>0;f(A),h(!A)}},[]);let T=m.useCallback(w=>{f(!0),h(!1),i?.(w)},[i]),E=m.useCallback(w=>{f(!1),h(!0),a?.(w)},[a]),k=async()=>{if(r)try{let w=await(await fetch(r)).blob(),A=new URL(r,window.location.origin).pathname.split("/").pop()||"",S=A.split(".").pop(),O=A.includes(".")&&S!==void 0&&S.length<=4,R="";if(O)R=A;else{let C=w.type,M="png";C.includes("jpeg")||C.includes("jpg")?M="jpg":C.includes("png")?M="png":C.includes("svg")?M="svg":C.includes("gif")?M="gif":C.includes("webp")&&(M="webp"),R=`${(n||A||"image").replace(L7,"")}.${M}`}Ia(R,w,w.type)}catch{window.open(r,"_blank")}};return r?v.jsxs("div",{className:u("group relative my-4 inline-block"),"data-streamdown":"image-wrapper",children:[v.jsx("img",{alt:n,className:u("max-w-full rounded-lg",x&&"hidden",t),"data-streamdown":"image",onError:E,onLoad:T,ref:l,src:r,...s}),x&&v.jsx("span",{className:u("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:p.imageNotAvailable}),v.jsx("div",{className:u("pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block")}),y&&v.jsx("button",{className:u("absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background","opacity-0 group-hover:opacity-100"),onClick:k,title:p.downloadImage,type:"button",children:v.jsx(o,{size:14})})]}):null},Zs=0,Bm=()=>{Zs+=1,Zs===1&&(document.body.style.overflow="hidden")},Fm=()=>{Zs=Math.max(0,Zs-1),Zs===0&&(document.body.style.overflow="")},j7=({url:e,isOpen:t,onClose:r,onConfirm:n})=>{let{CheckIcon:i,CopyIcon:a,ExternalLinkIcon:s,XIcon:o}=Kr(),u=Ie(),[l,c]=m.useState(!1),f=Dn(),d=m.useCallback(async()=>{try{await navigator.clipboard.writeText(e),c(!0),setTimeout(()=>c(!1),2e3)}catch{}},[e]),h=m.useCallback(()=>{n(),r()},[n,r]);return m.useEffect(()=>{if(t){Bm();let p=b=>{b.key==="Escape"&&r()};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p),Fm()}}},[t,r]),t?v.jsx("div",{className:u("fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm"),"data-streamdown":"link-safety-modal",onClick:r,onKeyDown:p=>{p.key==="Escape"&&r()},role:"button",tabIndex:0,children:v.jsxs("div",{className:u("relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg"),onClick:p=>p.stopPropagation(),onKeyDown:p=>p.stopPropagation(),role:"presentation",children:[v.jsx("button",{className:u("absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:r,title:f.close,type:"button",children:v.jsx(o,{size:16})}),v.jsxs("div",{className:u("flex flex-col gap-2"),children:[v.jsxs("div",{className:u("flex items-center gap-2 font-semibold text-lg"),children:[v.jsx(s,{size:20}),v.jsx("span",{children:f.openExternalLink})]}),v.jsx("p",{className:u("text-muted-foreground text-sm"),children:f.externalLinkWarning})]}),v.jsx("div",{className:u("break-all rounded-md bg-muted p-3 font-mono text-sm",e.length>100&&"max-h-32 overflow-y-auto"),children:e}),v.jsxs("div",{className:u("flex gap-2"),children:[v.jsx("button",{className:u("flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted"),onClick:d,type:"button",children:l?v.jsxs(v.Fragment,{children:[v.jsx(i,{size:14}),v.jsx("span",{children:f.copied})]}):v.jsxs(v.Fragment,{children:[v.jsx(a,{size:14}),v.jsx("span",{children:f.copyLink})]})}),v.jsxs("button",{className:u("flex flex-1 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 font-medium text-primary-foreground text-sm transition-all hover:bg-primary/90"),onClick:h,type:"button",children:[v.jsx(s,{size:14}),v.jsx("span",{children:f.openLink})]})]})]})}):null},Kh=m.createContext(null),$m=()=>m.useContext(Kh),Qse=()=>{var e;let t=$m();return(e=t?.code)!=null?e:null},Um=()=>{var e;let t=$m();return(e=t?.mermaid)!=null?e:null},B7=e=>{var t;let r=$m();return r!=null&&r.renderers&&e&&(t=r.renderers.find(n=>Array.isArray(n.language)?n.language.includes(e):n.language===e))!=null?t:null},F7=(e,t)=>{var r;let n=(r=void 0)!=null?r:5;return new Promise((i,a)=>{let s="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),o=new Image;o.crossOrigin="anonymous",o.onload=()=>{let u=document.createElement("canvas"),l=o.width*n,c=o.height*n;u.width=l,u.height=c;let f=u.getContext("2d");if(!f){a(new Error("Failed to create 2D canvas context for PNG export"));return}f.drawImage(o,0,0,l,c),u.toBlob(d=>{if(!d){a(new Error("Failed to create PNG blob"));return}i(d)},"image/png")},o.onerror=()=>a(new Error("Failed to load SVG image")),o.src=s})},$7=({chart:e,children:t,className:r,onDownload:n,config:i,onError:a})=>{let s=Ie(),[o,u]=m.useState(!1),l=m.useRef(null),{isAnimating:c}=m.useContext(Tr),f=Kr(),d=Um(),h=Dn(),p=async b=>{try{if(b==="mmd"){Ia("diagram.mmd",e,"text/plain"),u(!1),n?.(b);return}if(!d){a?.(new Error("Mermaid plugin not available"));return}let y=d.getMermaid(i),x=e.split("").reduce((k,w)=>(k<<5)-k+w.charCodeAt(0)|0,0),T=`mermaid-${Math.abs(x)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:E}=await y.render(T,e);if(!E){a?.(new Error("SVG not found. Please wait for the diagram to render."));return}if(b==="svg"){Ia("diagram.svg",E,"image/svg+xml"),u(!1),n?.(b);return}if(b==="png"){let k=await F7(E);Ia("diagram.png",k,"image/png"),n?.(b),u(!1);return}}catch(y){a?.(y)}};return m.useEffect(()=>{let b=y=>{let x=y.composedPath();l.current&&!x.includes(l.current)&&u(!1)};return document.addEventListener("mousedown",b),()=>{document.removeEventListener("mousedown",b)}},[]),v.jsxs("div",{className:s("relative"),ref:l,children:[v.jsx("button",{className:s("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:c,onClick:()=>u(!o),title:h.downloadDiagram,type:"button",children:t??v.jsx(f.DownloadIcon,{size:14})}),o?v.jsxs("div",{className:s("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[v.jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>p("svg"),title:h.downloadDiagramAsSvg,type:"button",children:h.mermaidFormatSvg}),v.jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>p("png"),title:h.downloadDiagramAsPng,type:"button",children:h.mermaidFormatPng}),v.jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>p("mmd"),title:h.downloadDiagramAsMmd,type:"button",children:h.mermaidFormatMmd})]}):null]})},U7=({chart:e,config:t,onFullscreen:r,onExit:n,className:i,...a})=>{let{Maximize2Icon:s,XIcon:o}=Kr(),u=Ie(),[l,c]=m.useState(!1),{isAnimating:f,controls:d}=m.useContext(Tr),h=Dn(),p=(()=>{if(typeof d=="boolean")return d;let y=d.mermaid;return y===!1?!1:y===!0||y===void 0?!0:y.panZoom!==!1})(),b=()=>{c(!l)};return m.useEffect(()=>{if(l){Bm();let y=x=>{x.key==="Escape"&&c(!1)};return document.addEventListener("keydown",y),()=>{document.removeEventListener("keydown",y),Fm()}}},[l]),m.useEffect(()=>{l?r?.():n&&n()},[l,r,n]),v.jsxs(v.Fragment,{children:[v.jsx("button",{className:u("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",i),disabled:f,onClick:b,title:h.viewFullscreen,type:"button",...a,children:v.jsx(s,{size:14})}),l?Io.createPortal(v.jsxs("div",{className:u("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),onClick:b,onKeyDown:y=>{y.key==="Escape"&&b()},role:"button",tabIndex:0,children:[v.jsx("button",{className:u("absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:b,title:h.exitFullscreen,type:"button",children:v.jsx(o,{size:20})}),v.jsx("div",{className:u("flex size-full items-center justify-center p-4"),onClick:y=>y.stopPropagation(),onKeyDown:y=>y.stopPropagation(),role:"presentation",children:v.jsx(Wk,{chart:e,className:u("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:!0,showControls:p})})]}),document.body):null]})},dk=e=>{var t,r;let n=[],i=[],a=e.querySelectorAll("thead th");for(let o of a)n.push(((t=o.textContent)==null?void 0:t.trim())||"");let s=e.querySelectorAll("tbody tr");for(let o of s){let u=[],l=o.querySelectorAll("td");for(let c of l)u.push(((r=c.textContent)==null?void 0:r.trim())||"");i.push(u)}return{headers:n,rows:i}},hk=e=>{let{headers:t,rows:r}=e,n=o=>{let u=!1,l=!1;for(let c of o){if(c==='"'){u=!0,l=!0;break}(c===","||c===`
133
133
  `)&&(u=!0)}return u?l?`"${o.replace(/"/g,'""')}"`:`"${o}"`:o},i=t.length>0?r.length+1:r.length,a=new Array(i),s=0;t.length>0&&(a[s]=t.map(n).join(","),s+=1);for(let o of r)a[s]=o.map(n).join(","),s+=1;return a.join(`
134
134
  `)},H7=e=>{let{headers:t,rows:r}=e,n=o=>{let u=!1;for(let c of o)if(c===" "||c===`
@@ -14,7 +14,7 @@
14
14
  media="print"
15
15
  onload="this.media='all'"
16
16
  />
17
- <script type="module" crossorigin src="/assets/index-C2C5Z4gB.js"></script>
17
+ <script type="module" crossorigin src="/assets/index-BfsXwolP.js"></script>
18
18
  <link rel="stylesheet" crossorigin href="/assets/index-B4Hwftt4.css">
19
19
  </head>
20
20
  <body>
@@ -1 +0,0 @@
1
- import{t as p,r as g,j as e,S as T,c as _,b as i,C as K,A as B,u as ee,d as se,W as q,M as te}from"./index-C2C5Z4gB.js";import{S as ne}from"./SearchableSelect-CUhWd9KY.js";function Z({type:s,label:n}){const o=p.useUtils(),{data:a,isLoading:c}=p.settings.getApiKey.useQuery(s),m=p.settings.saveApiKey.useMutation({onSuccess:()=>o.settings.getApiKey.invalidate(s)}),x=p.settings.removeApiKey.useMutation({onSuccess:()=>o.settings.getApiKey.invalidate(s)}),[d,r]=g.useState(!1),[h,l]=g.useState(""),[f,v]=g.useState(!1);async function N(){await m.mutateAsync({type:s,apiKey:h}),l(""),r(!1)}async function u(){await x.mutateAsync(s),r(!1),v(!1)}return c?e.jsx("div",{className:"px-4 py-3",children:e.jsx(T,{size:"sm"})}):e.jsxs("div",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("span",{className:"text-sm font-medium w-24 shrink-0",children:n}),e.jsx("span",{className:i.maskedKey+" flex-1 truncate",style:a?{color:_.success}:void 0,children:a?a.maskedApiKey:"Not configured"}),!d&&e.jsx("button",{onClick:()=>{l(""),r(!0)},className:i.secondaryBtn+" text-xs px-3 py-1",children:a?"Edit":"Add"})]}),d&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-[#e8e6e1] space-y-2",children:[e.jsx("input",{type:h?"password":"text",value:h,onChange:b=>l(b.target.value),placeholder:a?.maskedApiKey??"Enter API key",className:i.input}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:N,disabled:!h||m.isPending,className:i.primaryBtn+" text-xs px-3 py-1",children:m.isPending?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(T,{size:"sm"})," Saving..."]}):"Save"}),e.jsx("button",{onClick:()=>r(!1),disabled:m.isPending,className:i.secondaryBtn+" text-xs px-3 py-1",children:"Cancel"}),a&&e.jsx("button",{onClick:()=>v(!0),disabled:x.isPending,className:i.dangerBtn+" text-xs px-3 py-1",children:"Remove"})]})]}),e.jsx(K,{open:f,title:"Remove API key",message:`Remove the ${n} API key?`,confirmLabel:"Remove",onConfirm:u,onCancel:()=>v(!1)})]})}function ie({configuredProviders:s}){return e.jsx("div",{className:"border-t border-[#e8e6e1]",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:i.tableHeaderRow,children:[e.jsx("th",{className:i.tableHeaderCell+" text-xs py-2",children:"Model"}),e.jsx("th",{className:i.tableHeaderCell+" text-xs py-2",children:"Provider"}),e.jsx("th",{className:i.tableHeaderCell+" text-xs py-2 text-right",children:"Input ($/M)"}),e.jsx("th",{className:i.tableHeaderCell+" text-xs py-2 text-right",children:"Output ($/M)"})]})}),e.jsx("tbody",{className:"divide-y divide-[#e8e6e1]",children:B.map(n=>{const o=s.has(n.provider);return e.jsxs("tr",{style:o?{color:_.success}:{color:_.inkFaint},children:[e.jsx("td",{className:"px-4 py-2 font-mono text-xs",children:n.modelId}),e.jsx("td",{className:"px-4 py-2 capitalize",children:n.provider}),e.jsxs("td",{className:"px-4 py-2 text-right font-mono text-xs",children:["$",n.inputPrice.toFixed(2)]}),e.jsxs("td",{className:"px-4 py-2 text-right font-mono text-xs",children:["$",n.outputPrice.toFixed(2)]})]},n.modelId)})})]})})}function ae(){const[s,n]=g.useState(!1),o=ee();return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"max-w-lg bg-white border border-[#d4d2cd] rounded divide-y divide-[#e8e6e1] overflow-hidden",children:[e.jsx(Z,{type:"anthropic",label:"Anthropic"}),e.jsx(Z,{type:"google",label:"Google AI"})]}),e.jsxs("div",{className:"bg-white border border-[#d4d2cd] rounded overflow-hidden",children:[e.jsxs("button",{onClick:()=>n(!s),className:"w-full flex items-center justify-between px-4 py-3 text-sm text-[#666666] hover:bg-[#f5f4f0] transition-colors font-sans",children:[e.jsx("span",{className:"font-medium",children:"Model Pricing"}),e.jsx("span",{className:"text-xs transition-transform duration-200",style:{transform:s?"rotate(180deg)":"rotate(0deg)"},children:"▾"})]}),s&&e.jsx(ie,{configuredProviders:o})]})]})}function oe({status:s,label:n}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`inline-block h-2 w-2 rounded-full ${i.statusDot[s]}`}),n&&e.jsx("span",{className:i.statusLabel,children:n})]})}const U=`${B[1]?.provider??B[0].provider}:${B[1]?.modelId??B[0].modelId}`;function le({providerType:s}){const n=p.useUtils(),{data:o,isLoading:a}=p.settings.getSubAgentModel.useQuery(s),c=p.settings.saveSubAgentModel.useMutation({onSuccess:()=>n.settings.getSubAgentModel.invalidate(s)}),m=se(),x=o?`${o.provider}:${o.modelId}`:U,d=m.some(l=>`${l.provider}:${l.modelId}`===x),r=d?x:`${m[0].provider}:${m[0].modelId}`;if(g.useEffect(()=>{!a&&o&&!d&&c.mutate({providerType:s,model:null})},[a,d]),a)return null;function h(l){if(l===U&&!o)return;const f=m.find(v=>`${v.provider}:${v.modelId}`===l);f&&(l===U?c.mutate({providerType:s,model:null}):c.mutate({providerType:s,model:{provider:f.provider,modelId:f.modelId}}))}return e.jsxs("div",{className:"flex items-center gap-3 mt-3 pt-3 border-t border-[#d4d2cd]",children:[e.jsx("span",{className:"text-xs text-[#666666] whitespace-nowrap w-14",children:"Model"}),e.jsxs("div",{className:"relative flex-1",children:[e.jsx("select",{value:r,onChange:l=>h(l.target.value),disabled:c.isPending,className:"w-full appearance-none bg-white border border-[#d4d2cd] rounded px-3 py-2 pr-7 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-sans disabled:opacity-50 disabled:cursor-not-allowed",children:m.map(l=>e.jsx("option",{value:`${l.provider}:${l.modelId}`,children:l.modelId},`${l.provider}:${l.modelId}`))}),e.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[#9c9890] text-[10px]",children:"▾"})]})]})}function re({existingConfig:s}){const n=p.useUtils(),{data:o,isLoading:a}=p.provider.listGcpProjects.useQuery(void 0,{staleTime:q.updateCheckStaleTimeMs}),c=p.provider.saveConfig.useMutation({onSuccess:()=>{n.provider.getConfigs.invalidate(),n.provider.list.invalidate()}}),m=g.useMemo(()=>(o??[]).map(r=>({value:r.projectId,label:r.name?`${r.name} (${r.projectId})`:r.projectId,displayLabel:r.name||r.projectId})),[o]),x=s.projectId??"";function d(r){r!==x&&c.mutate({type:"gcp",config:{...s,projectId:r}})}return e.jsxs("div",{className:"flex items-center gap-3 mt-3 pt-3 border-t border-[#d4d2cd]",children:[e.jsx("span",{className:"text-xs text-[#666666] whitespace-nowrap w-14",children:"Project"}),e.jsx("div",{className:"flex-1",children:e.jsx(ne,{options:m,value:x,onChange:d,placeholder:a?"Loading...":"Select project...",storageKey:"gcp-projectId",fitContent:!0,disabled:a||c.isPending})})]})}function ce({checked:s,onChange:n,disabled:o,"aria-label":a}){return e.jsx("button",{type:"button",role:"switch","aria-checked":s,"aria-label":a,disabled:o,onClick:()=>n(!s),className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${s?"bg-[#2b5ea7]":"bg-[#d4d2cd]"} ${o?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:e.jsx("span",{className:`inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform ${s?"translate-x-[18px]":"translate-x-[3px]"}`})})}function de({type:s,label:n,connected:o,configured:a,onConfigure:c,onToggle:m,togglePending:x,toggleError:d,pingError:r,hasConfigFields:h,existingConfig:l}){const f=a||o;return e.jsxs("div",{className:i.settingsCard+" w-80",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{checked:a,onChange:v=>{v&&h?c():m(v)},disabled:x}),e.jsx("span",{className:"font-medium",children:n}),f?e.jsx(oe,{status:o?"connected":"disconnected"}):e.jsx("span",{className:"text-xs opacity-40",children:"Not configured"})]}),e.jsx("button",{onClick:c,className:`${i.secondaryBtn} ${a&&h?"":"invisible"}`,children:"Edit"})]}),f&&e.jsx(le,{providerType:s}),f&&s==="gcp"&&l&&e.jsx(re,{existingConfig:l}),r&&!o&&e.jsx("p",{className:i.warnText+" mt-2",children:r}),d&&e.jsx("p",{className:i.errorText+" mt-2",children:d})]})}function H(s,n){return!!s&&!!n&&s===n}function ue({open:s,label:n,configFields:o,formValues:a,onFormChange:c,existingConfig:m,saveResult:x,savePending:d,configured:r,onSave:h,onClose:l,onRemove:f}){const v=o.some(u=>u.required!==!1&&u.type==="password"&&H(a[u.key],m?.[u.key])),N=o.some(u=>u.required!==!1&&!a[u.key]);return e.jsxs(te,{open:s,onClose:l,children:[e.jsxs("div",{className:i.dialogTitle+" text-base mb-4",children:["Configure ",n]}),e.jsx("div",{className:"space-y-3",children:o.map(u=>{const b=u.type==="password"&&H(a[u.key],m?.[u.key]);return e.jsxs("div",{children:[e.jsxs("label",{className:i.sectionTitle,children:[u.label,u.required===!1&&e.jsx("span",{className:"text-xs opacity-40 ml-1",children:"(optional)"})]}),e.jsx("input",{type:u.type==="password"&&a[u.key]&&!b?"password":"text",value:a[u.key]??"",onChange:S=>c(u.key,S.target.value),onFocus:S=>{b&&S.target.select()},placeholder:`Enter ${u.label.toLowerCase()}`,className:`${i.input} ${b?"!text-[#999] !border-l-2 !border-l-amber-400":""}`})]},u.key)})}),e.jsxs("div",{className:"flex items-center gap-2 mt-4 pt-4 border-t border-[#d4d2cd]",children:[e.jsx("button",{onClick:h,disabled:N||v||d,className:i.primaryBtn,children:d?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(T,{size:"sm"})," Saving..."]}):"Save & Test"}),e.jsx("button",{onClick:l,disabled:d,className:i.secondaryBtn,children:"Cancel"}),r&&e.jsx("button",{onClick:f,disabled:d,className:i.dangerBtn,children:"Remove"})]}),v&&!d&&!x&&e.jsx("p",{className:"mt-2 text-xs text-amber-600",children:"Re-enter highlighted fields to save"}),x&&e.jsx("div",{className:`mt-3 ${x.success?i.successText:i.errorText}`,children:x.success?"Connected successfully":x.error||"Connection failed"})]})}function me(s,n){const o={};for(const a of s)o[a.key]=n?.[a.key]??"";return o}function xe(){const s=p.useUtils(),{data:n,isLoading:o}=p.provider.list.useQuery(),{data:a,isLoading:c}=p.provider.getConfigs.useQuery(),{data:m,isLoading:x}=p.provider.getRegisteredTypes.useQuery(),{data:d}=p.provider.ping.useQuery(void 0,{staleTime:q.sessionStaleTimeMs,refetchOnMount:"always"}),r=p.provider.saveConfig.useMutation({onSuccess:()=>{s.provider.list.invalidate(),s.provider.getConfigs.invalidate(),s.provider.ping.invalidate()}}),h=p.provider.removeConfig.useMutation({onSuccess:()=>{s.provider.list.invalidate(),s.provider.getConfigs.invalidate(),s.provider.ping.invalidate()}}),[l,f]=g.useState(null),[v,N]=g.useState({}),[u,b]=g.useState(null),[S,A]=g.useState(null),[k,j]=g.useState({});function P(t){const y=a?.find(w=>w.type===t),C=m?.find(w=>w.type===t);N(me(C?.configFields??[],y?.config)),b(null),f(t)}function E(){f(null),N({}),b(null)}async function R(t){b(null);try{const y=await r.mutateAsync({type:t,config:v});b(y),y.success&&(f(null),N({}))}catch{b({success:!1,error:"Failed to save configuration"})}}async function z(t,y){if(y){j(C=>{const w={...C};return delete w[t],w});try{const C=await r.mutateAsync({type:t,config:{}});C.success||j(w=>({...w,[t]:C.error??"Connection failed"}))}catch{j(C=>({...C,[t]:"Failed to save configuration"}))}}else A(t)}async function F(t){await h.mutateAsync(t),f(null),N({}),b(null),A(null)}const O=o||c||x,$=m??[];if(O)return e.jsx(T,{size:"lg",centered:!0});const M=l?$.find(t=>t.type===l):null,D=l?a?.find(t=>t.type===l):null;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-3",children:$.map(({type:t,label:y,configFields:C})=>{const w=n?.find(I=>I.type===t),Q=a?.find(I=>I.type===t),W=!!Q,L=d?.find(I=>I.type===t),Y=L?L.ok:!!w?.connected,J=C.length>0,X=L&&!L.ok?L.error:void 0;return e.jsx(de,{type:t,label:y,connected:Y,configured:W,onConfigure:()=>P(t),onToggle:I=>z(t,I),togglePending:r.isPending||h.isPending,toggleError:k[t],pingError:X,hasConfigFields:J,existingConfig:Q?.config},t)})}),l&&M&&e.jsx(ue,{open:!0,label:M.label,configFields:M.configFields,formValues:v,onFormChange:(t,y)=>N(C=>({...C,[t]:y})),existingConfig:D?.config??null,saveResult:u,savePending:r.isPending,configured:!!D,onSave:()=>R(l),onClose:E,onRemove:()=>A(l)}),e.jsx(K,{open:S!==null,title:"Disable provider",message:`Disable ${$.find(t=>t.type===S)?.label??S}?`,confirmLabel:"Disable",onConfirm:()=>{S&&F(S)},onCancel:()=>A(null)})]})}function pe({memory:s,editingId:n,editNote:o,setEditNote:a,onUpdate:c,onCancelEdit:m,onStartEdit:x,onDelete:d,updatePending:r,removePending:h}){return e.jsxs("li",{className:"flex items-start justify-between gap-3 py-1.5 border-b border-[#d4d2cd] last:border-b-0",children:[e.jsx("div",{className:"flex-1 min-w-0",children:n===s.id?e.jsxs("div",{className:"space-y-2",children:[e.jsx("input",{type:"text",value:o,onChange:l=>a(l.target.value),className:i.input}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>c(s.id),disabled:!o||r,className:i.primaryBtn,children:"Save"}),e.jsx("button",{onClick:m,disabled:r,className:i.secondaryBtn,children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-[#444444]",children:s.note}),s.reviewNote&&e.jsx("p",{className:"text-xs text-[#9c9890] italic mt-0.5",children:s.reviewNote}),e.jsx("p",{className:"text-xs text-[#666666] mt-0.5",children:new Date(s.createdAt*1e3).toLocaleDateString()})]})}),n!==s.id&&e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>x(s.id,s.note),className:i.secondaryBtn,children:"Edit"}),e.jsx("button",{onClick:()=>d(s.id),disabled:h,className:i.dangerBtn,children:"Delete"})]})]})}function ge(){const s=p.useUtils(),{data:n,isLoading:o}=p.memory.list.useQuery(),{data:a}=p.provider.getRegisteredTypes.useQuery(),c=p.memory.create.useMutation({onSuccess:()=>{s.memory.list.invalidate(),E(""),j("unified"),A(!1)}}),m=p.memory.update.useMutation({onSuccess:()=>s.memory.list.invalidate()}),x=p.memory.remove.useMutation({onSuccess:()=>s.memory.list.invalidate()}),[d,r]=g.useState(null),h=p.memory.optimize.useMutation({onSuccess:t=>{s.memory.list.invalidate(),r(t.stats)}}),[l,f]=g.useState(null),[v,N]=g.useState(""),[u,b]=g.useState(null),[S,A]=g.useState(!1),[k,j]=g.useState("unified"),[P,E]=g.useState("");function R(t,y){f(t),N(y)}async function z(t){await m.mutateAsync({id:t,note:v}),f(null),N("")}function F(){f(null),N("")}const O=[{value:"unified",label:"Unified"},...(a??[]).map(t=>({value:t.type,label:t.label}))],$=5;if(o)return e.jsx(T,{size:"lg",centered:!0});const M=new Map;if(n)for(const t of n){const y=M.get(t.toolName)??[];y.push(t),M.set(t.toolName,y)}const D={editingId:l,editNote:v,setEditNote:N,onUpdate:z,onCancelEdit:F,onStartEdit:R,onDelete:t=>b(t),updatePending:m.isPending,removePending:x.isPending};return e.jsxs("div",{className:"space-y-4",children:[S?e.jsxs("div",{className:i.settingsCard+" space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("label",{className:"text-sm font-medium text-[#666666] font-sans",children:"Provider"}),e.jsx("select",{value:k,onChange:t=>{j(t.target.value),t.target.blur()},className:"bg-white border border-[#d4d2cd] rounded px-3 py-2 pr-8 text-sm text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-sans appearance-none bg-[length:16px_16px] bg-[right_8px_center] bg-no-repeat",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E")`},children:O.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))})]}),e.jsxs("div",{children:[e.jsx("label",{className:i.sectionTitle,children:"Note"}),e.jsx("input",{type:"text",value:P,onChange:t=>E(t.target.value),onKeyDown:t=>{t.key==="Enter"&&P.trim()&&!c.isPending&&c.mutate({toolName:k,note:P})},placeholder:"Reusable lesson or pattern...",className:i.input})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>c.mutate({toolName:k,note:P}),disabled:!P.trim()||c.isPending,className:i.primaryBtn,children:c.isPending?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(T,{size:"sm"})," Saving..."]}):"Save"}),e.jsx("button",{onClick:()=>{A(!1),E(""),j("unified")},disabled:c.isPending,className:i.secondaryBtn,children:"Cancel"})]})]}):e.jsx("button",{onClick:()=>A(!0),className:i.secondaryBtn,children:"+ Add Memory"}),M.size===0&&e.jsx("div",{className:i.settingsCard,children:e.jsx("p",{className:"text-sm text-[#666666]",children:"No memories yet. The agent will save notes here as it learns from tool usage."})}),[...M.entries()].map(([t,y])=>{const C=y.length>$;return e.jsxs("div",{className:i.settingsCard,children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx("span",{className:`${i.badge} ${i.badgeVariants.info}`,children:t}),C&&e.jsxs("span",{className:"text-xs text-[#666666]",children:[y.length," memories"]}),e.jsx("button",{onClick:()=>h.mutate({toolName:t}),disabled:h.isPending||y.length===0,className:`ml-auto ${i.outlineBtn}`,title:"Optimize memories with AI",children:h.isPending&&h.variables?.toolName===t?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(T,{size:"sm"})," Optimizing..."]}):"Optimize"})]}),e.jsx("ul",{className:`space-y-2${C?" max-h-64 overflow-y-auto":""}`,children:y.map(w=>e.jsx(pe,{memory:w,...D},w.id))})]},t)}),e.jsx(K,{open:u!==null,title:"Delete memory",message:"Delete this agent memory?",onConfirm:()=>{u!==null&&x.mutate({id:u}),b(null)},onCancel:()=>b(null)}),e.jsx(K,{open:d!==null,title:"Optimization Complete",message:d&&e.jsxs("div",{className:"space-y-1.5 text-sm text-[#444444]",children:[e.jsxs("p",{children:["Kept: ",e.jsx("span",{className:"font-medium",children:d.kept})]}),e.jsxs("p",{children:["Updated: ",e.jsx("span",{className:"font-medium",children:d.updated})]}),e.jsxs("p",{children:["Deleted: ",e.jsx("span",{className:"font-medium",children:d.deleted})]})]}),confirmLabel:"OK",cancelLabel:null,confirmStyle:"primary",onConfirm:()=>r(null),onCancel:()=>r(null)})]})}const G=["Pacific/Auckland","Australia/Sydney","Asia/Tokyo","Asia/Shanghai","Asia/Kolkata","Asia/Dubai","Europe/Moscow","Europe/Berlin","UTC","Europe/London","America/Sao_Paulo","America/New_York","America/Chicago","America/Denver","America/Los_Angeles","Pacific/Honolulu"];function V(s){try{const n=new Intl.DateTimeFormat("en-US",{timeZone:s,timeZoneName:"short"}).formatToParts(new Date).find(a=>a.type==="timeZoneName")?.value??"",o=new Intl.DateTimeFormat("en-US",{timeZone:s,timeZoneName:"shortOffset"}).formatToParts(new Date).find(a=>a.type==="timeZoneName")?.value??"";return`${n} (${o})`}catch{return s}}const he=new Map(G.map(s=>[s,V(s)]));function fe(){const s=p.useUtils(),{data:n,isLoading:o}=p.settings.getAgentConfig.useQuery(),a=p.settings.saveAgentConfig.useMutation({onSuccess:()=>{s.settings.getAgentConfig.invalidate(),b(!1)}}),[c,m]=g.useState(""),[x,d]=g.useState(100),[r,h]=g.useState(50),[l,f]=g.useState(1024),[v,N]=g.useState(1e4),[u,b]=g.useState(!1);if(g.useEffect(()=>{n&&(m(n.timezone),d(n.directModeMaxSteps),h(n.subAgentMaxSteps),f(n.thinkingBudgetGoogle),N(n.thinkingBudgetAnthropic),b(!1))},[n]),o||!n)return null;const S=u&&(c!==n.timezone||x!==n.directModeMaxSteps||r!==n.subAgentMaxSteps||l!==n.thinkingBudgetGoogle||v!==n.thinkingBudgetAnthropic);function A(){a.mutate({timezone:c,directModeMaxSteps:x,subAgentMaxSteps:r,thinkingBudgetGoogle:l,thinkingBudgetAnthropic:v})}function k(){b(!0)}return e.jsx("div",{className:"max-w-lg",children:e.jsxs("div",{className:i.settingsCard,children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"text-xs text-[#666666] w-44 shrink-0",children:"Timezone"}),e.jsxs("select",{value:c,onChange:j=>{m(j.target.value),k()},className:"appearance-none bg-white border border-[#d4d2cd] rounded px-3 py-1.5 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-sans",children:[G.map(j=>e.jsx("option",{value:j,children:he.get(j)??j},j)),!G.includes(c)&&e.jsx("option",{value:c,children:V(c)})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"text-xs text-[#666666] w-44 shrink-0",children:"Direct mode max steps"}),e.jsx("input",{type:"number",min:1,max:500,value:x,onChange:j=>{d(Number(j.target.value)),k()},className:"w-20 bg-white border border-[#d4d2cd] rounded px-3 py-1.5 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-mono"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"text-xs text-[#666666] w-44 shrink-0",children:"Sub-agent max steps"}),e.jsx("input",{type:"number",min:1,max:500,value:r,onChange:j=>{h(Number(j.target.value)),k()},className:"w-20 bg-white border border-[#d4d2cd] rounded px-3 py-1.5 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-mono"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"text-xs text-[#666666] w-44 shrink-0",children:"Google thinking budget"}),e.jsx("input",{type:"number",min:0,max:1e5,step:256,value:l,onChange:j=>{f(Number(j.target.value)),k()},className:"w-24 bg-white border border-[#d4d2cd] rounded px-3 py-1.5 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-mono"}),e.jsx("span",{className:"text-[10px] text-[#9c9890]",children:"tokens"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"text-xs text-[#666666] w-44 shrink-0",children:"Anthropic thinking budget"}),e.jsx("input",{type:"number",min:0,max:1e5,step:1e3,value:v,onChange:j=>{N(Number(j.target.value)),k()},className:"w-24 bg-white border border-[#d4d2cd] rounded px-3 py-1.5 text-xs text-[#2c2c2c] focus:outline-none focus:border-[#2b5ea7] font-mono"}),e.jsx("span",{className:"text-[10px] text-[#9c9890]",children:"tokens"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-3 border-t border-[#e8e6e1]",children:[e.jsx("button",{onClick:A,disabled:!S||a.isPending,className:i.primaryBtn,children:a.isPending?"Saving...":"Save"}),a.isSuccess&&!u&&e.jsx("span",{className:i.successText,children:"Saved"})]})]})})}function be(){return e.jsxs("div",{className:i.page,children:[e.jsxs("div",{children:[e.jsx("h3",{className:i.sectionTitle,children:"LLM API Keys"}),e.jsx(ae,{})]}),e.jsxs("div",{children:[e.jsx("h3",{className:i.sectionTitle,children:"Data Providers"}),e.jsx(xe,{})]}),e.jsxs("div",{children:[e.jsx("h3",{className:i.sectionTitle,children:"Agent Configuration"}),e.jsx(fe,{})]}),e.jsxs("div",{children:[e.jsx("h3",{className:i.sectionTitle,children:"Agent Memory"}),e.jsx(ge,{})]})]})}export{be as Settings};